# How to calculate the value of supply apy seen on the aave frontend?

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 ?

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".

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

• ok thanks as soon as I can I check if can be a viable an quick solution Commented Aug 9, 2023 at 18:06

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

• This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review
– PSS
Commented Mar 28, 2023 at 14:43