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 ?