2

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 ?

3 Answers 3

0

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

0

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

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

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

1
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.