Borrowing Protocol
As explained above, a reserve of USDC is maintained and the users holding clETH can take a loan against clETH as collateral.
Fetch clETH price
The clETH price is fetched from the Oracle without updating the contract state.
There are checks put up for pause, price zero and price data timestamps.
Calculate LTV
Base LTV is set to 70 by default.
If the USDC reserve utilization is less than the target utilization, the LTV will remain the same.
Otherwise, the LTV is increased against the LTV constant at 1.
Calculate Interest Rate
Base Interest Rate is set to 6% by default.
Depending on the USDC reserve utilization, the Interest rate is increased by the interest rate constant multiple difference between current and target utilization.
This interest rate constant is set to 1 by default.
Calculate Max Loan Amount
The value of the collateral is always higher than the amount of the Loan.
The Max Loan Amount depends on the max LTV of the smart contract.
Create Loan
Max Loan that can be taken is directly dependent on the current LTV and the clETH price.
A new loan account is created once the clETH is transferred from the user wallet to the smart contract.
Depending on the max loan amount calculation, USDC is transferred to the user’s wallet.
Repay Loan
A loan is expected to be paid in full, so the total repayment amount is calculated when the user wants to repay the loan.
Once the user replays USDC equivalent to the repayment amount, the clETH is transferred to the user’s wallet, and the loan is closed.
Liquidate collateral
If the current LTV of the loan amount is greater than the liquidity threshold of 80%, the collateral is liquidated.
The loan is marked as repaid.
Modifiers
ZeroAmount is used to check if the amount is greater than 0.
Zeroaddress is used to check if the passed address is zero value.
Last updated