♾️3.4 Repayment
Last updated
Last updated
In the full repayment cycle, the borrower repays a loan entirely providing enough cash to cover the future value.
As a result,
that debt position is closed,
the tracker of the aggregated borrower debt is reduced for the amount repaid and this results in some of his collateral being freed up
When a position is marked as repaid, the lender(s) can claim the related cash + accrued interests resulting from the repaid money that was deposited on the Variable Pool at the time of the repayment. The claim
function may also be maintained by a keeper bot so as to maximize available liquidity and avoid lenders having to act upon loan repayment. See the Claim section for more details.
A borrower is allowed to reduce part of his debt in a DebtPosition by repaying a specific lender with some of his credit, aka repay with future cashflow.
From the accounting system perspective, a borrower who has some credit, aka future cashflow, in the form of a CreditPosition, can "sell" part of this credit to one of the lenders owning some percentage of a DebtPosition where he is the borrower, in exchange for this lender canceling an equivalent amount of the borrower debt.
This is allowed provided that the credit due date is earlier than the debt due date, as it is understood that by the time of the debt repayment, the credit will have already been available for claim, as it will have been repaid or liquidated if overdue.
This way, the lender who has received the credit is still able to claim his full credit at the due date, when expected.
Observation: in the event of a credit fractionalization due to the Compensate
mechanism, the borrower pays the fragmentation fee with collateral.
Since the Repay function only allows for full repayments, borrowers can repay partially by creating a new DebtPosition/CreditPosition pair and then compensating their original loan's debt. This effectively reduces the original loan's debt and creates a new debt. This means that, if no additional money is brought into the protocol, the borrower's total debt balance is not changed.
The way to achieve this is by calling Compensate
with credit position ID equal to type(uint256).max
, in a similar way as in matching order functions.
The whole process can be streamlined in a multicall
:
deposit
compensate
repay