Computing Rates in Morpho Vaults
In this tutorial, we'll explore how to compute the APY and rewards for Morpho Vaults. We'll cover both the calculation of the vault's APY based on allocated assets across markets and the computation of rewards.
On a side note, those values are pre-computed on the API, and available in this section.
To get the APY as displayed in the Morpho Interface, one needs to follow the steps below.
The APY is a weighted average based on the liquidity allocated in each market within the vault's withdrawal queue. Thus, some vaults may present:
For this purpose, the method is always the same:
First one has to get the Rate (of Native APY or Reward APR) on the markets belonging to the vault and apply the weight method to get the final values.
Why Rewards APR?
The distinction between APY and APR is that APY takes into account the effect of compounding interest, while APR does not. In the case of rewards, the APR is the most relevant metric to consider, as rewards are not reinvested in users positions.
1. Native APY Computation
To compute the Annual Percentage Yield (APY) of Morpho Vaults, one has to follow a weighted approach based on the liquidity allocated in each market within the vault's withdrawal queue.
1. Retrieve Liquidity: Identify the liquidity allocated in each market in the vault's withdrawal queue.
2. Get APYs: Retrieve the APY of each market thanks to this tutorial.
3. Compute the Weighted APY:
Native APY=
APYMarketX
refers to the APY of market X.assetsAllocatedInMarketA
is the amount of assets the vault has allocated in market X.totalAssetsAllocated
is the sum of all assets allocated across markets.
2. Rewards Computation
-
Get Reward Emission: Retrieve the reward emission rate. Refer to the dedicated rewards section or the Morpho API section related to rewards.
-
Calculate Reward Value:
emissionRatePerYear
is the annual rate of reward emission. Potentially, there are supply, borrow, and collateral emission rates. In the case of Morpho Vaults, only the supply emission rate matters.priceRewardTokenUSD
is the price of the reward token in USD.rewardTokenDecimals
is the decimal places of the reward token.marketTotalAssets
is the total supply of assets in the market.assetPriceUSD
is the price of the asset in USD.assetDecimals
is the decimal of the asset.
RewardsAPY=