Calculating APY
Due to the vast amount of data involved and the limitations in indexing speed, it is impractical to query blockchains every time a new block is added. Instead, we calculate yield using accrued interest, an obtainable figure for most yield-bearing products. This allows APY to be extrapolated from limited data points.
Simple interest
We use the following formula to calculate APY for simple (i.e., not compounding) interest:
Compounding interest
To determine compounding interest, we use the following formula:
Interest Rate Calculation
The interest rate at any given point in time is determined by:
Where the share price is:
Rewards APY
To calculate the rewards APY for a desired time range (1 day, 7 days, 30 days), we:
Calculate the number of reward tokens distributed per token deposited in the vault during the chosen period by taking a weighted average of emissions based on the TVL.
Calculate the average price ratio between the reward token and the deposited token for that period.
Use this ratio to convert the accumulated reward tokens' value to a single deposited token's value.
Compare this converted value to the initial deposit to determine the APY.
The average of the reward token price (PIT - Price In Token) to deposited token price is calculated using the formula:
The APY at time range of xday is calculated using the formula:
Adjusting for changes in TVL
To offer a more representative APY in scenarios where the amount of funds held in the vault ("TVL") fluctuates significantly, we calculate APY using a weighted average over a specified period (x days).
Weighting Mechanism for Range APY
In calculating the weighted average rate for the range, each point in time within the range is assigned a weight. This weight is determined by taking the minimum of the TVL at that specific time (TVLti) and the TVL at the preceding time (TVLti−1).
The TVL between these two consecutive points in time (t_{i} and t_{i-1}) is inherently uncertain. To maintain a conservative approach, we use the lower TVL between these two points in time.
Thus with this weighting method, the average interest rate over a given period is calculated using the formula:
Last updated