Aave.

Bài viết

Chia sẻ kiến thức của bạn.

Aaveator.
Feb 07, 2023
Hỏi đáp Chuyên Gia

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
0
1
Chia sẻ
Bình luận
.

Câu trả lời

1
Aaveator.
Feb 14 2023, 12:50

aToken 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

0
Bình luận
.

Bạn có biết câu trả lời không?

Hãy đăng nhập và chia sẻ nó.

Aave is a decentralized non-custodial liquidity protocol where users can participate as depositors or borrowers.

213Bài viết230Câu trả lời
Sui.X.Peera.

Kiếm phần của bạn từ 1000 Sui

Tích lũy điểm danh tiếng và nhận phần thưởng khi giúp cộng đồng Sui phát triển.