> For the complete documentation index, see [llms.txt](https://docs.pancakeswap.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pancakeswap.finance/vietnamese/chao-mung-den-voi-pancakeswap/how-to-guides/v3-v2-migration/how-v3-apr-is-calculated.md).

# Cách tính APR V3

{% hint style="info" %}
Trong V3 Liquidity và Farms, với thanh khoản không thể thay thế mới và khả năng phạm vi giá có thể tùy chỉnh. Mỗi vị thế LP sẽ có APR phí LP và farming CAKE riêng.
{% endhint %}

Tổng APR được kết hợp bởi APR phí LP và APR phần thưởng CAKE

### Phí LP

Về mặt lý thuyết, với phạm vi giá và thanh khoản mà người dùng sắp thêm vào, chúng ta có thể ước tính phí dự kiến trong 7 ngày tới như sau

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

* $$fee\_{in}$$ : Số tiền phí tích lũy trong phạm vi giá do người dùng chỉ định trong 7 ngày qua
* $$L\_{in}$$: Thanh khoản hiện tại trong phạm vi giá do người dùng chỉ định
* $$\Delta{L}$$: Thanh khoản người dùng muốn thêm vào phạm vi giá

#### Phí trong phạm vi

Đối với $$fee\_{in}$$, chúng ta sử dụng dữ liệu khối lượng giao dịch lịch sử, mức phí và dữ liệu giá lịch sử để ước tính giá trong phạm vi

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

* $$f\_t$$: Mức phí
* $$V\_{7d}$$: Tổng khối lượng giao dịch trong 7 ngày qua
* $$T\_{in}$$: Thời gian, tính bằng giây, giá ở trong phạm vi trong 7 ngày qua
* $$T\_{7d}$$: 7 ngày tính bằng giây

### APR Cake

#### Phân bổ Pool

Tổng phần thưởng cake mỗi giây trong MC v3 sử dụng upkeep và có thể được lấy bằng `latestPeriodCakePerSecond`

`cakePerSecond = lastestPeriodCakePerSecond / 1e12 / 1e18`

Trong mỗi pool, chúng ta có thể sử dụng `poolInfo` để lấy `poolWeight` bằng cách chia `poolInfo.allocPoint / totalAllocPoint`

#### APR CAKE Toàn Cầu

APR toàn cầu được tính bằng cách sử dụng tổng lượng thanh khoản đang hoạt động và đã staking với phần thưởng CAKE của pool.

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

`totalStakedLiquidityUSD` đại diện cho thanh khoản đã staking đang hoạt động của pool hiện tại tính bằng USD, bao gồm tất cả các ticks vị thế trong phạm vi đã staking trong MasterChef v3.

#### APR CAKE Theo Vị Thế

APR cho các vị thế riêng lẻ có thể thay đổi tùy thuộc vào cài đặt phạm vi giá của chúng.

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

* $$USD\_r$$: Phần thưởng CAKE kiếm được USD mỗi năm trong pool
* $$USD\_p$$: Tổng giá trị USD trong vị thế
* $$L\_{p}$$: Thanh khoản vị thế
* $$L\_{lm}$$: Tổng thanh khoản staking được theo dõi bởi LMPool


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.pancakeswap.finance/vietnamese/chao-mung-den-voi-pancakeswap/how-to-guides/v3-v2-migration/how-v3-apr-is-calculated.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
