Post
Share your knowledge.
aTokens balance gets updated for every block - implementation Aave error
So in the contract logic itself, I read that the aTokens balance gets updated for every block. How is this being implemented?
- Aave Protocol
- aTokens
Answers
1aToken balances are updated when the index (accrued interest for the entire pool of this reserve) is updated. The index update occurs whenever any user in the pool performs an action on this reserve: supply, borrow, etc..
When you call balanceOf
on the aToken contract, it calls a function on the Pool contract to calculate the initial balance + income:
AToken -> LendingPool -> ReserveLogic
Whenever you perform an action with aTokens such as transfer, withdraw, borrow, liquidate, etc. It checks the balance in this way and allows you to access the aTokens which you've accumulated.
By doing the update in this way, the aToken balance is increasing continuously, and the aTokens are allocated, not transferred to the users wallet;
The calculation of accrued interest is based on the liquidityIndex. Since the income is distributed across all depositors proportional to their balance, a single index is used to track the accumulated interest for everyone in the pool. The index and rate are updated on the pool contract for every deposit, borrow, withdrawal, repay of ANY Aave user. The update works like this:
Utilization Rate (borrows/deposits) -> Liquidity Rate -> Liquidity Index
Do you know the answer?
Please log in and share it.
Aave is a decentralized non-custodial liquidity protocol where users can participate as depositors or borrowers.
- Error "No matching key" when trying to unstake USDC on BNB chain32
- How to tell the code to, rather than "deposit 1 eth worth of WBTC" deposit "500$ worth of WBTC"?22
- How to interpret configuration field in a response from the getReserveData view function in Aave v2?21
- Getting a return value of '25 - INVALID BURN AMOUNT'21
- Is there any way to stake in the security module on Görli?23