> 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/chinese/jiao-yi/pancakeswap-infinity/hooks/dynamic-fee-hook.md).

# 动态费用 Hook

PancakeSwap 官方的动态费用 Hook 旨在为流动性提供者和交易者之间创造更公平的价值交换。它在保护 LP 免受过度无常损失（IL）的同时，保持市场对交易者的高效性。

该 hook 由 PancakeSwap 核心团队构建，专门为提供一种智能、自适应的方案以替代传统的固定费用模型而量身打造。

#### 🔍 为什么要用动态费用？

大额套利交易会在资金池中造成更大的价格偏离，增加 LP 的 IL。我们的动态费用模型对更大额的套利交易按比例收取更高的费用，以抵消这一风险——同时仍为套利者留出足够的获利空间，使价格保持一致。

#### 📊 这与其他模型有何不同？

过去其他模型曾使用历史数据来估计波动性，并用其他因素来调整费用。然而：

* 历史数据是一个滞后指标，可能无法准确预测未来的波动性。
* 外部市场事件（如监管变化或经济变动）可能使过去的趋势变得不可靠。
* 复杂的、参数繁多的模型存在过拟合的风险——在历史数据上表现良好，但在新的、未见过的情况下表现不佳。

我们的方法更简单、自适应，并植根于实时交易行为。

#### ⚙️ 工作原理

* **我们不预测波动性或其他宏观因素**\
  相反，我们的模型天然地受益于套利者在不同市场状态下的行为：
  * **高波动性：** 更多更大额的套利交易 → 为 LP 带来更高的费用，覆盖更大份额的 IL。
  * **低波动性：** 更少、更小额的交易 → IL 本质上较低，但 LP 仍比固定费用模型赚取更高的费用。
* **我们的模型使用**
  * 一个指数加权的资金池价格来检测套利交易。
  * 一条基于每次兑换价格影响的指数费用曲线。
  * 最高 5% 的费用上限，以维护对交易者的公平性。

{% hint style="success" %}
这确保费用随交易影响动态变化，同时自动适应不断变化的市场状况。
{% endhint %}

* **平衡的激励**\
  套利者在扣除动态费用后仍保留约 50% 的利润，确保他们有动力使资金池价格与市场保持一致。

#### 📌 关键要点

* 不依赖于对波动性或其他宏观因素的预测。
* 基于实际交易行为自动适应市场波动性。
* 以每次兑换为单位保护 LP 免受 IL 影响。
* 维持强有力的激励，促使套利者弥合价格差距。
* 以更深的流动性和更低的基础费用惠及交易者。


---

# 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/chinese/jiao-yi/pancakeswap-infinity/hooks/dynamic-fee-hook.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.
