Aavescan logo Aavescan

Live and historical Aave rates

How to Calculate Historical Interest Rates on Aave

A guide for crypto researchers, borrowers and depositors. Learn how to accurately track DeFi APRs and APYs.

Aavescan Insights - Published 07.11.2022

Why Calculate Your Historical Interest Rate?

Whether you're lending or borrowing on platforms like Aave, Compound, or Euler, knowing your historical interest rate helps you clearly understand your gains or interest owed over time.

Two Ways to Calculate DeFi Interest Rates

1. Use Historical APRs

You can take an average of the historical APRs listed on Aavescan. This is quick and straightforward but does not account for intraday fluctuations and compounding effects.

2. Use the Interest Index

The most accurate method for calculating historical interest is to track the growth of the market index (available on Aavescan exports), such as Aave's liquidityIndex for deposits or variableBorrowIndex for borrows. This method precisely captures compounded interest and all associated fees.

What is the Interest Index?

The interest index (such as Aave’s liquidityIndex or variableBorrowIndex) is a number that continuously increases to reflect accumulated interest. By comparing the index values of two different dates you can precisely calculate the interest that has accrued, i.e. the interest earned or owed, fully accounting for compounding and additional sources of income such as flash loan fees.

Aave V3 USDC Liquidity Index
The chart shows the liquidity index for USDC on Aave V3 Ethereum. The index starts at 1 and increases with accrued interest. It shows the total amount of interest that has accumulated in this market since it began.

Calculating Interest Using the Index

To find your accurate historical interest:

  1. Locate the initial value of the interest index when you entered the market. This is either the liquidityIndex or the variableBorrowIndex depending on whether you want to calculate deposit interest or borrow interest. These values can be found on the Aavescan data exports.
  2. Find the value of the same index when you exited the market. The difference between the initial index and the final index represents the amount of interest that accrued during the period.
  3. Divide the current index by the initial index, subtract 1, and then multiply by your original deposit or borrowed amount.

The resulting number reflects the total interest earned or owed, fully accounting for compounding and additional fees or rewards. This is the most accurate way to calculate historical interest for research or tax accounting purposes.

Calculating Interest Rates Using the Index

Take the delta between two snapshots to calculate the actual interest accrued during that period. This is the most precise method for calculating historical interest rates.

// 1. Get liquidityIndex values
snapshotNow = currentSnapshot.liquidityIndex
snapshot24hAgo = snapshot24hAgo.liquidityIndex

// 2. Compute daily growth
growth = snapshotNow / snapshot24hAgo

// 3. Convert to APR
depositApr = (growth - 1) * 365

// 4. Annualise to APY
depositApy = Math.pow(growth, 365) - 1

Rate reflects the actual interest accrued during the past 24 hours.

Aave Interest Technical Details

The amount of interest earned by lenders and paid by borrowers depends on lending rates, compounding frequency and extra rewards such as flash loan fees.

Aave V2 and V3 use APRs that accrue every second. Borrow interest compounds every second. However, deposit interest only compounds when the market is updated, typically when users interact with it. Depositors also receive additional yield from flash loan fees.

Rates example

The chart below illustrates how APY calculations can differ depending on how blockchain data is intepreted. This is pronounced in Compound V2 lending market data where rates are quoted on a per-block basis.

Compound USDC APR comparison
The chart shows three different APY calculations for the Compound V2 USDC market using different measures. Notice how different assumptions about the number of blocks per day leads to different results when using the borrowRate as opposed to using the index.

Special thanks to @samlafer for insights in this Twitter thread and to Robert L. in Compound’s Discord.

Join the discussion on Aavescan Discord.

Read More

Aave Interest Rates History
Exploring major events in the history of Aave interest rates including the USDC depeg, ETH PoW fork and sUSDe looping
Aave Introduction
Learn key terms and features of Aave market contracts including liquidity rate, borrow rate and APR to APY conversions.
DeFi Strategies
Learn how Aave is used by investors and traders to maximise yields, leverage and hedge exposure