# Formulas

Within Yield-Farming there are several important KPIs and formulas:



**APR** ([Source](https://www.investopedia.com/personal-finance/apr-apy-bank-hopes-cant-tell-difference/))

APR does not take into account the compounding of interest within a specific year. It is calculated by multiplying the periodic interest rate by the number of periods in a year in which the periodic rate is applied. It does not indicate how many times the rate is applied to the balance.

$$
APR = PeriodicRate * NumberOfPeriodsPerYear
$$

**APY** ([Source](https://www.investopedia.com/personal-finance/apr-apy-bank-hopes-cant-tell-difference/))

APY is calculated by adding 1+ the periodic rate as a decimal and multiplying it by the number of times equal to the number of periods that the rate is applied, then subtracting. In our platform we use 365 periods (once per day).

$$
APY = (1 + Periodic Rate) ^  (NumberOfPeriods) – 1
$$

**Impermanent Loss** ([Source ](https://academy.binance.com/en/articles/impermanent-loss-explained)and [Source](https://uniswap.org/docs/v2/advanced-topics/understanding-returns/))

Impermanent loss happens when you provide liquidity to a liquidity pool, and the price of your deposited assets changes compared to when you deposited them. At the end the question is, should I have put my money in a liqudiity pool or just hodl'd it. If you have impermanent gain then you are better of in the pool. If you have impermanent loss, then hodl'ing would have been the better decision. You can calculate the impermanent loss with this formula:

$$
ImpermanentLoss = 2 * sqrt(PriceRatio) / (1+PriceRatio) — 1
$$

Losses to liqudiity providers due to price variation:

![Scale of the impermanent loss at different price ratios (Source Uniswap Docs)](https://172418904-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MaKRy6X-bveJcc0PoKT%2F-MaUHiCwYHfOfeT-7cwU%2F-MaUIDGynsFGA1xgcQIP%2Fimage.png?alt=media\&token=4fa32b1f-bcb0-40ce-af9d-7cf04ebb6350)

This is an excellent tool to calculated historical impermanent loss on Sushiswap: [Intotheblock](https://app.intotheblock.com/insights/defi/protocols/sushiswap?address=0xc3f279090a47e80990fe3a9c30d24cb117ef91a8\&pid=sushiswap\&utm_source=sushiswap_widget)

As well as an impermanent loss calculator: [DecentYields](https://decentyields.com/impermanent-loss-calculator)

**Price Divergence** ([Source](https://revert.finance/#/about))

The running difference between the changes in prices (as percentages) for the underlying assets against the prices 30 days ago. Price divergences between a pair of assets can result in losses for liquidity providers (see Impermanent Loss).

$$
Price Divergence = abs(Token0PriceChangePct - Token1PriceChangePct)
$$

**Volume/Reserve Ratio** ([Source](https://revert.finance/#/about))

The ratio of trading volume against the liqudiity/reserves (take average of each for the past 30 days). This ratio signals how lucrative the pair is in terms of rewards (trading fees) for liquidity providers.

$$
(V/R)Ratio = Trading Volume (30d) / Reserves (30d)
$$

**Total PnL** ([Source](https://revert.finance/#/about))

The amount of funds someone has accrued after conducting yield farming activities

```
Total PnL =   value of current LP underlying tokens
              - value of tokens deposited (at current price)
              + value of tokens withdrawn (at current price)
              + pending rewards at current prices
              + claimed rewards at current price
              - deposit fee
              - withdrawel fee
              - gas costs for all deposit and withdrawal transactions at current ETH price.
```



**Other Variables**

In addtion there are other variables who are influenceing the profitability and dynamics of yield farming activities:

```
Vesting = Vesting of a percentage of the rewards
Harvest Lockup = Lockup period for claiming rewards
Collateral Lock Period = Time in which collateral cannot be accessed 
Multiplier = Reward multiplier per pool
Max Pool Cap = Maximum allowed capital per pool
Deposit/Withdrawel Fee = Fees when entering/exiting pools
Auto-Compounding = Autocompounding of rewards (i.e. vault)
Pool2 Rewards/Pool1 Rewards = Selling pressure of native token
```

**Hedging**

There are several vehicles where someone can hedge against impermanent loss, as well as against a drop in price of the underlying collateral. You can read more [here](https://coinmarketcap.com/alexandria/article/hedging-against-impermanent-loss-a-deep-dive-with-finnexus-options).



