Borrow
Whitelisted Borrowers in Cap can borrow and repay the underlying Vault assets, provided they have secured sufficient collateral from an Underwriter.
Mechanics
Borrow
The borrow process flow is as follows:
Borrower calls the borrow function on the Lender contract
Underwriter interest is realized first to prevent charging for compounded interest
If eligible to borrow*, assets are lent out from the Vault to the Borrower
Debt tokens are minted to track the loan
Key Validations*:
Borrower must have sufficient collateral and health factor
Borrower must be whitelisted and not paused
Asset being borrowed should not be paused
Borrow amount must meet minimum requirements, and may not exceed maximum borrows
Minimum: set by Admin via the setMinBorrow function
Maximum: The smaller value of the Borrower's remaining borrow capacity, and the remaining available amount to be borrowed from the Vault
Repay
The repay process flow is as follows:
Borrower calls the repay function on the Lender contract
Underwriter interest is realized first to ensure all interest is accounted for
The repayment is processed in the following order:
Unrealized underwriting premium (if any)
Vault principal debt
Vault interest
Debt tokens corresponding to the total amount repaid are burned
If the repayment is not in full, the system will maintain a minimum borrow amount for the Borrower.
Interest Distribution
The repaid assets are distributed back to the shareholders:
Vault Principal: Sent to Vault contract's reserves
Vault Interest: Sent to
interestReceiver(set to Fee Auction). Any excess interest will go to the interest receiverUnderwriting Premium: Sent to Delegation contract for distribution to Underwriters
Unrealized Interest: Added to Borrower's debt balance for future repayment
Realizing Interest
Interest in Cap is accrued continuously but realized discretely:
Accrued Interest: Calculated in real-time based on elapsed time and rates
Realized Interest: Actually borrowed from vault and distributed to recipients
Unrealized Interest: Accrued but not yet realized due to vault liquidity constraints
As can be seen, interest can be realized prior to repayment in Cap. Both stcUSD holders and Underwriters may permissionlessly realize interest by borrowing from the vault and distributing to interest receivers.
There are two functions to realize interest: realizeInterest and realizeRestakerInterest
RealizeInterest:
Realizes vault interest (interest paid to the stcUSD holders)
Interest is borrowed from the Vault and paid to the interest receiver
RealizeRestakerInterest:
Realizes underwriting premium (premium paid to Underwriters)
Interest is borrowed from the Vault and paid to the Delegation contract
For both functions, the process flow is as follows:
Determine available interest to realize
Increase reserve debt
Borrow interest amount from Vault
Transfer assets to recipient
For function signatures, parameters, and data structures, see the Lender Contract Reference.
Last updated