APY Calculation
APY shown in frontend is calculated using the following formula.

APY

APY shown on the first page derives from either Auto-compound APY or Auto-stake APY, whichever is greater.
APY=max(autocompoundAPY,autostakeAPY)APY = max(autocompound APY, autostake APY)

Auto-compound APY

First we deduct fee from APR:
NetAPR=RewardAPR(1fee)Net APR = Reward APR * (1 - fee)
Second, we calculate into APY. We use 8760 which comes from 24 * 365 (hourly compound):
NetAPY=(1+NetAPR/8760)87601Net APY = (1 + Net APR / 8760)^{8760} - 1
Then, we include trade APR. And add SPEC APR at the end:
AutocompoundAPY=(1+NetAPY)(1+TradeAPR)1+SPECAPRAutocompound APY = (1 + Net APY) * (1 + Trade APR) - 1 + SPEC 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

Full example for auto-compound APY calculation

Reward APR = 87.57%, Fee = 8%, Trade APR = 4.59%, SPEC APR = 3.48%
Net APR = 0.8757 * (1 - 0.08) = 0.805644
Net APY = (1 + 0.805644 / 8760) ^ 8760 - 1 = 1.238054486
Auto-compound APY = (1 + 1.238054486) * (1 + 0.0459) - 1 + 0.0348 = 137.56%

Auto-stake APY

First we deduct fee from APR:
NetAPR=RewardAPR(1fee)Net APR = Reward APR * (1 - fee)
Second, we combine with Gov APR. If we deposit reward to Gov every hour, throughout a year, on average we will earn half of Gov APR:
NetAPY=NetAPR(1+GovAPR/2)Net APY = Net APR * (1 + Gov APR / 2)
Then we add Trade APR and SPEC APR:
AutostakeAPY=NetAPY+TradeAPR+SPECAPRAutostake APY = Net APY + Trade APR + SPEC APR

Full example for auto-stake calculation

For auto-stake in case of dual rewards, we need to separate calculation and then combine the results.
For token 1 reward:
Reward APR = 46.53%, Fee = 8%, Gov APR = 10.51%
Net APR = 0.4653 * (1 - 0.08) = 0.428076
Net APY = 0.428076 * (1 + 0.1051 / 2) = 0.450571394
For token 2 reward:
Reward APR = 39.91%, Fee = 8%, Gov APR = 48.06%
Net APR = 0.3991 * (1 - 0.08) = 0.367172
Net APY = 0.367172 * (1 + 0.4806 / 2) = 0.455403432
Trade APR = 4.59%, SPEC APR = 3.48%
Total Net APY = 0.450571394 + 0.455403432 = 0.905974826
Autostake APY = 0.905974826 + 0.0459 + 0.0348 = 98.67%

Data source and cache interval

The APRs are obtained from the API of each protocol such as Astroport's API, Mirror's API, or Nexus'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.