# FixedInterestOnlyLoan

`FixedInterestOnlyLoans` is an ERC-721 contract. Each minted NFT represents a loan that must be paid back to the NFT owner.&#x20;

{% embed url="<https://github.com/trusttoken/contracts-helium>" %}

### Loan Parameters

Each loan is parametrized by:&#x20;

* Underlying token with which funds are lent out and repaid (e.g. USDC)&#x20;
* Principal debt (minting price)&#x20;
* Period payment (interest paid at each installment)&#x20;
* Period length (a period when the borrower pays installments)&#x20;
* Period count (total number of installments)&#x20;
* End date (date of the last installment to be paid together with the principal, set when the loan is started)&#x20;
* Recipient’s address&#x20;
* Grace period (time by which borrower can be late in repayment of each installment)&#x20;
* A canBeRepaidAfterDefault flag that allows a loan to be repaid after a loan was marked as defaulted&#x20;

### Loan states & state transitions

A loan can have one of the possible statuses: `Created`, `Accepted`, `Started`, `Repaid`, `Canceled`, or `Defaulted`.&#x20;

Upon minting the loan status is set to `Created`. In this state, a borrower can accept a loan by calling `acceptLoan(id)` and the loan status is changed to `Accepted`.&#x20;

The NFT owner can call `start(id)` on loans whose status is `Accepted`. When a loan is started the loan end date is calculated for the loan and the loan status is changed to `Started`.&#x20;

The NFT owner can mark loans as canceled whose status is `Created` or `Accepted`.&#x20;

The NFT owner can mark loans as `Defaulted` whose status is `Started` and the current block time is after a current period `endDate + grace`P`eriod` time.

The NFT owner can update the loan's `gracePeriod` at any time by calling `updateInstrument(id)`. The NFT owner must call `repay(id, amount)` to recalculate repaid periods and the current period end date.&#x20;

The repaid amount must be equal to the period payment or period payment + principal for the last installment. The loan can be repaid after it was marked as defaulted only if the proper `canBeRepaidAfterDefault` flag was set to true.
