How to calculate the value of supply apy seen on the aave frontend?
How to calculate the value of supply apy seen on the aave frontend?
Loading saved threads...
Alessandro Morandi · External communityPost link
External question — Ethereum Stack Exchange
Author: Alessandro Morandi
Original post: https://ethereum.stackexchange.com/questions/132317
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I tried to implement the following aave docs in order to calculate the deposit apy that you can see on the market page in Aave defi protocol.
https://docs.aave.com/developers/v/2.0/guides/apy-and-apr
As written in the doc, I should download the subgraph data , in example from polygon of aave v2 in order tho have the liquidity rate of an ERC20.
https://thegraph.com/hosted-service/subgraph/aave/aave-v2-matic
I should use the following subgraph query
{
reserves {
name
liquidityRate
}
}
Then I shoul use the following formula to calculate the apy
RAY = 10**27 // 10 to the power 27
SECONDS_PER_YEAR = 31536000
depositAPR = liquidityRate/RAY
depositAPY = ((1 + (depositAPR / SECONDS_PER_YEAR)) ^ SECONDS_PER_YEAR) - 1
The value I am getting is not the same as the one I see on the aave frontend, what I am doing wrong ?
Quote
Report
Sai · External communityPost link
External answer — Ethereum Stack Exchange
Author: Sai
Original post: https://ethereum.stackexchange.com/a/148083
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
were you able to solve this as I too have the same issue. The APY doesnot match with aave when calculated using the given formula
Quote
Report
V K · External communityPost link
External answer — Ethereum Stack Exchange
Author: V K
Original post: https://ethereum.stackexchange.com/a/152268
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I used the same link to compute the APY and was able to get the data the same as the UI on Aave. There are two different ways to borrow, stable and variable.
Make sure you are computing the APY for the correct borrow type.
UI shows the borrow type in "APY type".
Quote
Report
Sudeep Sagar · External communityPost link
External answer — Ethereum Stack Exchange
Author: Sudeep Sagar
Original post: https://ethereum.stackexchange.com/a/153171
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
There can be a lot of mathematical errors while calculating this: following this code solved it for me:
https://github.com/aave/aave-js/blob/4edcc76b133fe6c060f3604ccd081114cc059920/src/v2/computations-and-formatting.ts#L669
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Ethereum Stack Exchange Author: Alessandro Morandi Source score (net votes, not local likes): 2 Original post: https://ethereum.stackexchange.com/questions/132317 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I tried to implement the following aave docs in order to calculate the deposit apy that you can see on the market page in Aave defi protocol. https://docs.aave.com/developers/v/2.0/guides/apy-and-apr As written in the doc, I should download the subgraph data , in example from polygon of aave v2 in order tho have the liquidity rate of an ERC20. https://thegraph.com/hosted-service/subgraph/aave/aave-v2-matic I should use the following subgraph query { reserves { name liquidityRate } } Then I shoul use the following formula to calculate the apy RAY = 10**27 // 10 to the power 27 SECONDS_PER_YEAR = 31536000 depositAPR = liquidityRate/RAY depositAPY = ((1 + (depositAPR / SECONDS_PER_YEAR)) ^ SECONDS_PER_YEAR) - 1 The value I am getting is not the same as the one I see on the aave frontend, what I am doing wrong ?
Checking account access…