Lenders provide liquidity by depositing crytocurrencies in a pool contract, the pooled funds can be borrowed by placing collateral.
Interest rates: for borrowers - depends on cost of money - amount of funds available in pool at specific time. More borrowing -> less funds -> higher interest rate.
Interest rates: for lenders - corresponds to earn rates
Every pool holds reserve in multiple currencies, total amount in Ethereum defined as total liquidity.
Reserve accepts deposits from lenders. Users borrow these funds, by locking greater value as collateral(low risk tokens considered) which backs the borrow position.
Every reserve has specific Loan-to-Value(LTV) calculated as weighted average of different LTVs of currencies composing the collateral.
Weight of each LTV = equivalent amount of collateral in ETH
Every borrow position can be opened with stable or variable rates.
In case of price fluctuations, borrow position might be liquidated. Liquidation happens when price of collateral drops below the threshold, Lq (Liquidation Threshold). Reaching this ratio channels a liquidation bonus, which incentivizes liquidators to buy collateral at discounted price.
At any point the borrow position is checked using the Health factor Hf, a function of total collateral and total borrows which determines if the loan is undercollaterized.
Hf <1 -> undercollaterized loan, can be liquidated.
LendingPoolCore Contract: holds state of every reserve and the assets deposited, handles basic logic(calculations etc.)
LendingPoolDataProvider Contract: performs calculations on higher level of abstraction than LendingPoolCore, calculates ETH equivalent a user's balance( borrow balance, collateral balance, liquidity balance) to check how much user is allowed to borrow and the health factor, collects data from lending pool to provide higher level of information to LendingPool, calculates Avg Loan-To-Value and Avg Liquidation Ratio.
LendingPool: uses LendingPoolCore,LendingPoolContract to interact with reserves. Implements Tokenization of lending position, when user deposits currencies, receives aTokens.
User -> check state -> check conditions -> satisfied, update liquidity/borrow inices -> change state to execute action -> update interest states -> external transfers.
LendingPoolConfigurator: provides main configuration functions for LendingPool and LendingPoolCore(reserve initialization, reserve configuration, enable/disable borrowing, enable/disable usage reserve as collateral)
Redeem action- allows user to exchange aTokens with underlying asset.
The Repay action allows user to repay borrowed amount plus the origination fees and accrues interest. Origination fees - 0/5% to 1% of loan amount for processing loan application.
Swap Rate Action allows user with borrow in progress to swap between variable and stable borrow rate.
Stable rates act as a fixed rate in the short-term, but can be re-balanced in the long-term in response to changes in market conditions. The variable rate is the rate based on the offer and demand in Aave.
Flash Loan: allows users to borrow reserves within a single transaction, as long as the user returns more liquidity that has been taken. Flash loans temporarily transfer funds to a smart contract respecting IFlashLoanEnabledContract.sol interface. excuteOperation() called when funds transferred. Check is performed to verify that funds +fee is returned to LendingPool contract.
Stable rate theory - time, rate constraints.
Questions
Why health factor is checked when a user performs redeem action? He is not borrowing assets by providing collateral rather is exchanging aTokens.
Why is the liquidation call reverted if the amount of collateral in principal currency with discount is above 50% of principal borrow balance?
Is there a specific currency or reserve in which the borrower needs to pay the interest rates? How aTokens implement interest rate redirection?
AAVE
Weight of each LTV = equivalent amount of collateral in ETH
Hf = (TotalCollateralETH * Lq(avg))/(TotalBorrowsETH + TotalFeesETH)
User -> check state -> check conditions -> satisfied, update liquidity/borrow inices -> change state to execute action -> update interest states -> external transfers.
Questions