The variable borrow rate is determined is determined programatically based on the interest rate strategy for a reserve. The InterestRateStrategy for each reserve can be queried from the AaveProtocolDataProvider or UiPoolDataProvider view contracts.
Whenever an action occurs on a reserve (supply, borrow, repay, withdraw, liquidation, etc.), updateInterestRates is called. Most reserves implement the DefaultInterestRateStrategy which updates variable borrow rates based on the variable rate slope parameters determined by Aave Governance and borrow utilitization of the reserve.
An exception to this is the Aave GHO facilitator which uses a custom implementation of the interest rate strategy, more details.
Stable Borrow Rate
The stable borrow rate (for new borrows) is determined programatically based on the interest rate strategy for a reserve. The InterestRateStrategy for each reserve can be queried from the AaveProtocolDataProvider or UiPoolDataProvider view contracts.
Whenever an action occurs on a reserve (supply, borrow, repay, withdraw, liquidation, etc.), updateInterestRates is called. All stable borrow reserves implement the DefaultInterestRateStrategy which updates stable borrow rates based on the stable rate slope parameters determined by Aave Governance and borrow utilitization of the reserve.
The rate for each active stable borrower is stored in a mapping and can be queried from the getUserStableBorrowRate function.
In certain conditions, the stable borrow rate for a borrower can be rebalanced, see the FAQ for specific requirements in Aave V2 and V3.
Supply Rate
The supply rate is determined is determined programatically based on the interest rate strategy for a reserve. The InterestRateStrategy for each reserve can be queried from the AaveProtocolDataProvider or UiPoolDataProvider view contracts.
Whenever an action occurs on a reserve (supply, borrow, repay, withdraw, liquidation, etc.), updateInterestRates is called. The supply rate is updated based on the weighted average of all variable and stable borrow rates minus the reserve factor, which is the percentage of borrow interest to the DAO treasury collector, determined by Aave Goveran
How is yield accrued?
Variable Borrow Balances
Variable borrow balances increase over time, based on a checkpointing variable called variableBorrowIndex:
variableBorrowIndex is shared across all variable borrowers and is updated on all reserve state updates (supply, borrow, withdraw, repay, liquidate, etc.) based on the current variable borrow rate and time since last update.
The variableBorrowIndex can be queried from the Pool.getReserveData(underlyingTokenAddress), AaveProtocolDataProvider.getReserveData(underlyingTokenAddress), or UiPoolDataProvider.getReservesData() functions.
In Aave V3, all VariableDebtTokens contain a function getPreviousIndex which can be used to calculate accrued interest:
where StableDebtToken.principalBalanceOf(user) is the initial borrow amount and accruedInterest is calculated here based on the rate and last update timestamp of an individual address.
The rate and lastUpdateTimestamp for each active stable borrower are stored in mappings and can be queried from the getUserStableBorrowRate and getUserLastUpdated functions respectively.
Supply Balances
The checkpointing for supply balances occurs through the liquidityIndex variable:
liquidityIndex is a variable shared across all suppliers and is updated on all reserve state updates (supply, borrow, withdraw, repay, liquidate, etc.) based on the current supply rate and time since last update.
The liquidityIndex can be queried from the Pool.getReserveData(underlyingTokenAddress), AaveProtocolDataProvider.getReserveData(underlyingTokenAddress), or UiPoolDataProvider.getReservesData() functions.
In Aave V3, all ATokens contain a function getPreviousIndex which can be used to calculate accrued interest:
The Aave Address Book is a registry of all protocol contract addresses.
Rates queried from contracts are in RAY units (10^27) and are not compounded, see formatting rates to convert to compounded percentage form.
Subgraph
The protocol subgraphs are indexed GraphQL endpoints which can be used to query current reserve states.
Subgraph rates come directly from smart contracts: RAY units (10^27) and are not compounded, see formatting rates to convert to compounded percentage form.
Reserve Query
{
reserves {
name
underlyingAsset
liquidityRate
stableBorrowRate
variableBorrowRate
}
}
Historical data for parameters, rates, and balances can be queried through contract events or indexed data sources.
A breakdown of all core protocol events can be found here.
The Aave Protocol subgraphs are an example of an indexed data source that maps contract events to a GraphQL endpoint.
Reward Emissions
This documentation explains the process of reward emissions.
Formatting Rates
All rates and indeces queried on-chain or from subgraphs are expressed in RAY units i.e. 10^27.
Supply and borrow rates queried on-chain or from subgraphs are not compounded (APR). On the smart contract, borrow rates are compounded per second using a binomial approximation (APY). Within each update action, supply rates are applied linearly, however, on an inter-action basis they experience the same compounding effect as the borrow rates, more details.
The Aave Utilities SDK formatting functions (used on the app.aave.com interface) computes the compounded supply and borrow rates using the formula shown below.
Incentive emissions are always non-compounded, they are applied to the scaled supply or borrow balance.
APR -> APY
To convert the APR (non-compounded) to APY (compounded per second), the formula is:
APY=(1+(APR/secondsPerYear))secondsPerYearā1
where the APY and APR are in decimal form (i.e. 2.5% = 0.025)
Weighted Average APY
Weighted Average APY is the single-sided (supply or borrow) affect of rates on an addresses positions. It is calculated as the sum of ((positionBalanceUSD * positionAPY) / totalBalanceUSD) for each position that an address holds.
Example:
Address supplies 100USD of WETH @ 2% and 200USD of WBTC @ 5%.
Net APY is the impact of supply and borrow rates on net worth (totalSupplied - totalBorrowed). It is an estimate of how much net worth will change after one year of current rates.
The Net APY can be higher or lower than the individual weighted average APYs, this is most noticeable when the ratio of totalSupplied to netWorth is large.