# How v3 APR is calculated

{% hint style="info" %}
In V3 Liquidity and Farms, with the new non-fungible liquidity and customizable price range ability. Each LP position will have its own LP fee and CAKE farming APR.
{% endhint %}

The total APR is combined by the LP fee APR and CAKE reward APR

### LP fee

Theoretically speaking, given a price range and liquidity user about to add, we can estimate the expected future 7 days fee as following

$$
fee\_{next7d} = fee\_{in} \frac{\Delta{L}}{L\_{in} + \Delta{L}}
$$

* $$fee\_{in}$$ : Fee amount accrued in the user specified price range in last 7 days
* $$L\_{in}$$: Current liquidity in the user specified price range
* $$\Delta{L}$$: Liquidity user want to add to the price range

#### Fee in range

For $$fee\_{in}$$, we use the historical trading volume data, fee tier and historical price data to estimate the price in range

$$fee\_{in} = f\_tV\_{7d}\frac{T\_{in}}{T\_{7d}}$$

* $$f\_t$$: Fee tier
* $$V\_{7d}$$: Total trading volume of last 7 days
* $$T\_{in}$$: Duration, measured in seconds, of prices staying within the price range in the past 7 days
* $$T\_{7d}$$: 7 days measured in seconds

### Cake APR

#### Pool Allocation

The total reward cake per second in MC v3 using upkeep and can be derived by `latestPeriodCakePerSecond`

`cakePerSecond = lastestPeriodCakePerSecond / 1e12 / 1e18`

In each pool, we can use `poolInfo` to get the `poolWeight` by dividing `poolInfo.allocPoint / totalAllocPoint`

#### Global Cake APR

Global APR calculated using the total amount of active & staked liquidity with the pool CAKE reward emissions.

`APR (global) = (cakePerSecond * 31536000) / (totalAllocPoint / pool.allocPoint) * 100 * cakeUSD / totalStakedLiquidityUSD`

`totalStakedLiquidityUSD` represents the current pool active staked liquidity in USD, composing by all the position ticks in range staked in MasterChef v3.

#### Position Cake APR

APRs for individual positions may vary depend on their price range settings.

$$
ARP\_p = {\frac{USD\_{r}}{USD\_{p}}} {\frac{L\_{p}}{L\_{lm}}}
$$

* $$USD\_r$$: CAKE reward earn USD per year in pool
* $$USD\_p$$: Total USD value in position
* $$L\_{p}$$: Position liquidity
* $$L\_{lm}$$: Total staking liquidity which tracked by LMPool


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pancakeswap.finance/welcome-to-pancakeswap/how-to-guides/v3-v2-migration/how-v3-apr-is-calculated.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
