APY Calculation
Last updated
Was this helpful?
Last updated
Was this helpful?
APY shown in frontend is calculated using the following formula.
First we deduct fee from APR:
Second, we calculate into APY. We use 365 (daily compound):
Then, we include trade APR.
NOTE: For Trade APR, we use multiplication here because in auto-compound we grow LP and LP is multiplication of trading APR.
For example:
Net APY = 20%, Trade APR = 10%
Year 0: LP = 100 and 1 LP = 1 Token + 1 UST (Total value is 200 UST)
Year 1: LP = 120 and 1 LP = 1.1 Token + 1.1 UST (Total value is 264 UST)
Year 0-1 Profit = 64 UST
We can apply compound APY formula to get the same result:
Compound APY = (1 + Net APY 20%) * (1 + Trade APR 10%) - 1 = 32%
Investment 200 UST * 32% = 64 UST
Reward APR = 87.57%, Fee = 5%, Trade APR = 4.59%
Net APR = 0.8757 * (1 - 0.08) = 0.831915
Net APY = (1 + 0.831915 / 365) ^ 365 - 1 = 1.295541
Auto-compound APY = (1 + 1.295541) * (1 + 0.0459) - 1 + 0.0348 = 140.09%
The APRs are obtained from the API of each protocol such as Astroport's API. The consolidated data will be provided via Spectrum's API and cached for 5-10 minutes while each protocol might have various cache intervals depending on their update frequency.