👻
Aave Book
  • Introduction
  • TradFi vs DeFi: Lending
  • Market forces x Interest Rate Models
  • On Indexes
    • Why use indexes?
  • Scaling and ATokens
  • Deposit & Borrow Interest
  • Stable borrowing
    • 🚧Under construction
  • Liquidation
    • 🚧TODO: Full example
    • 🚧Under construction: oracles
  • Primer
    • Bitmap & Masks
      • 🚧padding and bytes
    • WadRayLibrary
      • Math Operations
      • 🚧WIP: Scaling different decimal representations
      • 🚧WIP: 2's complement
      • 🚧casting: to uint128
    • PercentageMath
    • Embedded vs Linked Libraries
  • Functions
    • General Execution flow
    • Architecture & Design choices
      • 🚧Upgradability and Proxies
    • Common Functions
      • getReserveFactor, getDecimals
      • .cache
      • .updateState
      • .updateInterestRates
      • SupplyCap, BorrowCap
      • getFlags
        • 🚧more on flags
      • calculateUserAccountData
    • supply
      • validateSupply
      • transfer & mint
      • isFirstSupply
        • isUsingAsCollateralOne, isUsingAsCollateralAny
      • On check-effects-interactions pattern
    • withdraw
      • get user balance & withdraw amount
      • validateWithdraw
      • collateral check
      • burn ATokens
      • Ensure existing loans are collateralized
    • borrow
      • getIsolationModeState
      • .validateBorrow
      • Mint debt token
      • setBorrowing
      • update IsolationMode debt
      • transfer underlying to user
    • repay
      • get current debt
      • validateRepay, paybackAmount
      • burn debt tokens
      • Cleanup + Collect repay
    • liquidate
      • _calculateDebt
      • validateLiquidationCall
      • getConfigurationData
      • calculateAvailableCollateralToLiquidate
      • 🚧_burnDebtTokens
      • liquidate/burn collateral
      • liquidation Fee
      • Wrap-up
    • 🚧swapBorrowRateMode
    • 🚧setUserUseReserveAsCollateral
  • Contracts
    • AToken
      • Simple example: mint & balanceOf
    • StableDebtToken
      • Implementation explained
    • VariableDebtToken
    • DefaultReserveInterestRateStrategy
    • L2
      • 🚧PriceOracleSentinel
  • Audit findings
    • 🚧Under construction
  • Appendix
    • Simple, Compound, APR, APY
  • Aave Features
    • Risk Management
      • Supply & Borrow Caps
      • Isolation Mode
      • Siloed Borrowing
    • Other features
      • Repay with ATokens
      • eMode: High efficiency Mode
      • 🚧Aave Vault
      • 🚧Portal
Powered by GitBook
On this page
  • Parameters
  • _getOverallBorrowRate
  • calculateInterestRates

Was this helpful?

Edit on GitHub
  1. Contracts

DefaultReserveInterestRateStrategy

https://docs.aave.com/developers/deployed-contracts/v3-mainnet/ethereum-mainnet

PreviousVariableDebtTokenNextL2

Last updated 1 year ago

Was this helpful?

The DefaultReserveInterestRateStrategy contract is essentially the on-chain interest rate model. It contains two key functions:

  1. calculateInterestRates

  2. _getOverallBorrowRate

calculateInterestRates calculates the latest supply, variable borrow and stable borrow rates as explained previously.

_getOverallBorrowRate calculates the overall borrow rate given how much stable and variable rate loans have been taken.

Parameters

Each asset has its interest rate parameters stored on-chain via a DefaultReserveInterestRateStrategy contract.

These parameters are set in the constructor on deployment. We can explore their values by interacting with the deployed contract. For example, DAI contract on mainnet:

R_intercept = 0
R_slope1 = 0.04
R_slope2 = 0.75
U_optimal = 0.80

These parameters were obtained from DAI's DefaultReserveInterestRateStrategy contract, and are accurate at time of writing.

Periodically, parameters are modified to better suit market conditions. Proposals to update these parameters are submitted and passed via Aave's governance.

_getOverallBorrowRate

Calculates the overall borrow rate as the weighted average between the total variable debt and total stable debt.

calculateInterestRates

Executed as part of .updateInterestRates, it is usually ran towards the end of a state-changing function (borrow, supply, etc). It calculates the new interest rates for

  • supply

  • variable borrow

  • stable borrow

Other contract addresses:

given that liquidity conditions and utilization have changed. This is well explained in the common functions section: .

https://etherscan.io/address/0x694d4cFdaeE639239df949b6E24Ff8576A00d1f2#readContract
https://docs.aave.com/developers/deployed-contracts/v3-mainnet/ethereum-mainnet
on-chain parameters
calculateInterestRates