balancer / backend

MIT License
19 stars 8 forks source link

add vebal voting apr #359

Closed franzns closed 4 months ago

franzns commented 6 months ago

We want to track vebal voting APR. Question is, how to calculate that? What is the APR?

@Xeonus to help!

franzns commented 6 months ago

https://github.com/balancer/frontend-v3/issues/480

Xeonus commented 6 months ago

Sure, glad to help! Here is a short step-by-step implementation guide

What you need

APIs might need whitelisting. Can help there to get in contact with the right people.

How to obtain the APR

Ideally, you average voting APR from at least 2-3 rounds. Please note that the Balancer market runs weekly, while the Aura market runs bi-weekly. However, voting usually aligns with the AURA market as there is a veBAL voting cooldown of 10 days Also note that currently, the HH market is the primary voting incentive income source and should be considered first in calculating APRs With that in mind:

  1. Have a helper function that can provide timestamps for Thu 00:00 UTC as this is needed for the request endpoint
  2. To fetch the current round data use this endpoint: https://api.hiddenhand.finance/proposal/balancer
  3. To fetch a historical HiddenHand round use an edpoint like this: https://api.hiddenhand.finance/proposal/balancer/1714003200
  4. Obtain the total amount of votes
  5. Obtain the total amount of incentivized votes = number of votes that have gauges that receive rewards
  6. Calculate the average $ / vote

Calculation

With these parameters, for a given round the Voting APR is

veBALVoteAPR = averageDollarPerVote * 52 / veBALPrice

or

$veBALVoteAPR = \frac{averageDollarPerVote * 52}{veBALPrice}$

franzns commented 6 months ago

Could @gmbronco also create such a voting APR service for Beets HH market? Replace the beetswars APR handler with that. One Beets round is two weeks. https://beets.fi/pool/0x9e4341acef4147196e99d648c5e43b3fc9d026780002000000000000000005ec

franzns commented 4 months ago

done #441