Skip to main content

Backend

APR and APY Calculation​

This section describes how pool yields are computed: from swap fees and from incentive rewards. There are no ASTRO emissions any more, so they are not part of the calculation.

Swap Fee Returns​

Swap events from Astroport pools are summed over the last 24 hours to get the pool's 24h volume, valued in USD at the time of each swap. The 24h volume is multiplied by the share of the swap fee that stays with liquidity providers to get 24h LP fees. Multiplying by 365 and dividing by the pool's liquidity gives the fee APR.

The LP share of the fee is the pool's total fee minus the Maker's share:

Pool typeTotal feeMaker shareFee kept by LPs
Constant product (xyk)0.30%33.33%0.20%
Stableswap0.05%50%0.025%
PCLDynamic (mid_fee to out_fee)50%Half of the dynamic fee

The live values are in the factory's config query (pair_configs: total_fee_bps, maker_fee_bps) and, for PCL pools, in the pool's config.

The APY assumes daily compounding:

APY = ((1 + (daily fees) / (pool liquidity))^365) - 1

Incentive Rewards​

Incentive rewards come from external schedules in the Incentives contract. The Incentives pool_info query returns each reward token's rps (reward units per second for the whole pool) and total_lp (LP tokens staked). The reward APR for one token is:

APR = (rps / 10^decimals) × 31,536,000 × (reward token price) / (value of the staked LP tokens)

rps is in base units of the reward token, hence the division by 10^decimals.

Rewards are paid only to staked LP tokens, so the denominator is the value of the LP tokens staked in Incentives, not the whole pool.

Total Rewards​

For LP tokens staked in Incentives, the total APR is the fee APR plus the reward APR of every reward token. Unstaked LP tokens earn the fee APR only. The APR is extrapolated from the last 24 hours of fees and the current reward rates, and the APY is calculated from the APR with daily compounding:

APY = (1 + APR / 365)^365 - 1