Loans
A Loan is a shared object that holds its own collateral. Whoever holds its LoanDeed repays it, refinances it and takes any surplus. Refinancing into a higher-rate offer is allowed on chain. The chain checks the new offer's own terms, not that the new rate is lower.
Types#
There are two loan types, set by who lent.
- offer loan — funded from a lender's treasury through an offer or a sealed room. Fixed rate, fixed maturity set at fill.
- pool loan — funded from the pool. No maturity; it owes principal on the pool's floating index.
Objects#
| Object | Who holds it | What it does |
|---|---|---|
| Loan | Shared | Holds the collateral and the terms. |
| LoanDeed | The borrower (or, through the borrower desk, the borrower's SUI treasury) | Repays, refinances, claims a surplus. |
| LenderClaim | The lender's treasury (offer loans only) | Collects a default. Repayment does not depend on who holds it: the loan records the lender's treasury. |
A repayment of an offer loan can only go to that loan's own lender: the payout object has no abilities, so the same transaction must hand it to the lender's treasury.
Interest#
Interest is a yearly simple rate on principal, accrued per whole second, rounded up.
interest = ceil(principal × rate_bps × seconds / (10,000 × 31,536,000))A pool loan owes principal × index_now / index_at_open, rounded up.
Lifecycle#
Loans progress through the following states:
- open (0) — the loan is live and holds its collateral. Anyone may add collateral to it.
- repaid (1) — the deed holder paid what was owed and took the collateral back.
- liquidated (2) — someone paid the whole debt while the loan was underwater and took collateral worth the debt plus the bonus.
- written-off (3) — the loan was worth less than its debt at both prices; a payer bought all the collateral for at least its value, and the lender bore the rest.
- refinancing (4) — only inside a refinance transaction, between taking the collateral out and repaying in full; the transaction aborts unless it ends repaid.
- claimed (5) — after a liquidation, write-off or default, the deed holder took what was left.
- defaulted (6) — an offer loan past maturity plus five minutes; the LenderClaim holder took collateral worth what was owed plus the bonus.
+--> repaid
|
open ---------+--> liquidated ---+
| | |
| +--> written-off --+--> claimed
| | |
| +--> defaulted ----+
|
+--> refinancing --> repaid (same transaction; new loan opens)Refinance#
A refinance moves a loan to a new offer in one transaction: begin_refi spends the deed and lends the collateral to the transaction, the new offer is filled with it, and finish_refi repays the old loan in full.
Reading a loan#
info returns market, collateral, principal, rate, start, lender type, lender id, cap id, claim id, state and maturity. owed gives what an offer loan owes now; owed_in_pool what a pool loan owes.