APY and APR

You can query latest APY and APR on chain and subgraph

All rates queried on chain or subgraph, are expressed in RAY units i.e. 10^27. All emissions are expressed in WAD units i.e. 10^18.

APY: Compounding interest accrued by deposit or borrow on LendingPool``

APR: Non Compounding rewards earned as part of LiquidityMining

The deposit and borrow APY displayed on the Phantazm front-end is compounded per second.

Fetch Data

Subgraph

Use subgraph to query reserve data.

{
  reserves {
    name
    underlyingAsset
    
    liquidityRate 
    stableBorrowRate
    variableBorrowRate
    
    aEmissionPerSecond
    vEmissionPerSecond
    sEmissionPerSecond
    
    totalATokenSupply
    totalCurrentVariableDebt
  }
}

On-Chain

APR: getAssetData to fetch liquidity mining incentives for a/s/vToken.

APY: getReserveDatato fetch deposit and borrow rates of asset.

Compute Data

Calculate rates as👇🏻with js, python or whatever you like 😉

Conversions

Both of these conversions take the input and ouput in decimal form. Multiply the output by 100 to get the percentage.

APR -> APY

To convert the APR to APY compounded per second the formula is:

APY=(1+(APR/secondsPerYear))secondsPerYear1APY = (1 + (APR / secondsPerYear))^{secondsPerYear} - 1

APY -> APR

To convert APY compounded per second to APR the formula is:

APR=((1+APY)(1/secondsPerYear)1)secondsPerYearAPR = ((1 + APY)^{(1/secondsPerYear)} - 1) * secondsPerYear

Last updated