Skip to main content

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, including tokens with a price and those without, like MORPHO.

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:

Native APY+Rewards APR+MORPHO tokens\text{Native APY} + \text{Rewards APR} + \text{MORPHO tokens}

For this purpose, the method is always the same:

First one has to get the Rate (of Native APY or Reward APR or Number of MORPHO tokens) 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.

Steps

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=

APYmarketAassets allocatedInMarketA+APYmarketBassets allocatedInMarketB+totalAssetsAllocated\small{ \frac{\text{APY}_{\text{marketA}} \cdot \text{assets}_{\text{ allocatedInMarketA}} + \text{APY}_{\text{marketB}} \cdot \text{assets}_{\text{ allocatedInMarketB}} + \ldots}{\text{totalAssetsAllocated}} }
  • 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

Rewards can be divided into two categories: tokens with a price and tokens without a price (MORPHO).

A. Tokens with a Price

Steps:

  1. Get Reward Emission: Retrieve the reward emission rate. Refer to the dedicated section.

  2. Calculate Reward Value:

RewardValue=(emissionRate perYearpriceRewardToken USD)10assetDecimalsrewardTokenDecimals(marketTotalAssetsassetPriceUSD)\small{ \text{RewardValue} = \frac{\left(\text{emissionRate}_{\text{ perYear}} \cdot \text{priceRewardToken}_{\text{ USD}}\right) \cdot 10^{\text{assetDecimals}-{\text{rewardTokenDecimals}}}}{\left(\text{marketTotalAssets} \cdot \text{assetPriceUSD}\right) }}
  • 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=

rewardsmarketAassets allocatedInMarketA+RewardsmarketBassets allocatedInMarketB+totalAssetsAllocated\small{ \frac{\text{rewards}_{\text{marketA}} \cdot \text{assets}_{\text{ allocatedInMarketA}} + \text{Rewards}_{\text{marketB}} \cdot \text{assets}_{\text{ allocatedInMarketB}} + \ldots}{\text{totalAssetsAllocated}} }

B. Tokens without a Price (MORPHO)

For tokens like MORPHO that do not have a defined price, the amount should be displayed based on the logic provided in this section of the documentation.

Once one has the number for a given market, one can compute the weighted number of MORPHO tokens across allocated markets:

Number of MORPHO tokens=

MORPHOmarketAassets allocatedInMarketA+MORPHOmarketBassets allocatedInMarketB+totalAssetsAllocated\small{ \frac{\text{MORPHO}_{\text{marketA}} \cdot \text{assets}_{\text{ allocatedInMarketA}} + \text{MORPHO}_{\text{marketB}} \cdot \text{assets}_{\text{ allocatedInMarketB}} + \ldots}{\text{totalAssetsAllocated}} }