Popcorn-Limited / vaultcraft-sdk

0 stars 2 forks source link

Fix convex apy resolver #11

Closed RedVeil closed 11 months ago

RedVeil commented 1 year ago

Currently the convex apy resolver uses the llama api to get the apy. The problem here is that while the total number seems accurate it doesnt return the apy per rewardToken. We should use contract reads to calculate the apy per rewardToken.

To calculate the rewards for each convex pool we need to do the following steps:

  1. Get the BaseRewardPool for the stakingToken. (It rewards crv)
  2. Read extraRewards(0) to get the cvx reward contract (Which rewards cvx)
  3. Read rewardRate on the cvx reward Contract and the BaseRewardPool this is the amount of token paid out per second for the whole pool
  4. Reward totalSupply on both contracts
  5. Use the rewardRate per second and totalSupply to arrive at the apy in crv and cvx for the pool.

Note -> Just doing that math manually for some pools didnt give me the apy displayed on llama or the convex frontend. Not sure what i was missing there