👻
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

Was this helpful?

Edit on GitHub
  1. On Indexes

Why use indexes?

In a traditional banking setting, interest accruals and corresponding balances can be calculated continuously over any desired period: monthly, daily, hourly. Calculating continuous compounding up to even a per second resolution is trivial as computing power is not expensive.

The same approach cannot be applied on-chain, because computation has to be paid for in gas; and the more complex the computation, the greater the gas fees. Consequently, on-chain lending protocols, such as Aave, use an index to track interest in a gas-efficient manner.

  1. Gas Efficiency: Gas is a measure of computational effort required to execute transactions or smart contracts on the blockchain. On-chain lending protocols need to handle multiple calculations and updates for each user's lending position. By using an index, the protocol can reduce gas costs by performing calculations based on the index value rather than recalculating interest from scratch for each transaction.

  2. Computational Cost: Traditional financial institutions have dedicated systems and infrastructure to handle interest calculations, maintain historical records, and handle complex financial instruments. On-chain lending protocols, operating within the constraints of decentralized networks, need to optimize computational costs. Using an index allows for efficient storage and retrieval of historical interest rates, reducing the computational burden compared to localized storing of interest rates for each transaction.

Traditional financial lending, operating within centralized systems, can rely on centralized databases and infrastructure to handle interest calculations without the same constraints.

PreviousOn IndexesNextScaling and ATokens

Last updated 1 year ago

Was this helpful?