> ## Documentation Index
> Fetch the complete documentation index at: https://docs.li.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# FeeForwarder

> LI.FI 的 FeeForwarder 合约如何工作，以及它对合作伙伴意味着什么

LI.FI 已在受支持的 EVM 链上升级了其费用处理机制，从 **FeeCollector** 合约迁移到新的 **FeeForwarder** 合约。本页解释了发生了哪些变化、这对您的集成意味着什么，以及您需要做什么（如果需要的话）。

## 为什么进行此项变更？

之前的 FeeCollector 模型要求费用在合约中累积，之后再手动提取。这增加了运营开销，并延迟了向费用接收方的支付。

有了 FeeForwarder，费用会在交易执行时立即转发到配置的接收方钱包。无需手动提取步骤。该合约还设计为支持未来的多方费用分配模型，例如在 LI.FI、集成商和分销商之间拆分费用。

## 对合作伙伴有哪些变化？

### 即时费用转发

在部署了 FeeForwarder 的链上，交易会调用新合约，费用在执行时自动分配。

合作伙伴无需采取任何操作。

### 向后兼容性

在尚未部署 FeeForwarder 的链上，系统会自动回退到旧版 FeeCollector 合约。现有的提取端点仍然可用，且未引入任何 API 变更。`/status` 响应中的费用数据保持不变。

## 事件变更

对于解析链上事件的合作伙伴，EVM 费用事件签名已发生变化。

**先前的事件（[合约](https://github.com/lifinance/contracts/blob/main/src/Periphery/FeeCollector.sol)）：**

```solidity theme={"system"}
event FeesCollected(
    address indexed _token,
    address indexed _integrator,
    uint256 _integratorFee,
    uint256 _lifiFee
);
```

**新事件（[合约](https://github.com/lifinance/contracts/blob/main/src/Periphery/FeeForwarder.sol)）：**

```solidity theme={"system"}
struct FeeDistribution {
    address recipient;
    uint256 amount;
}

event FeesForwarded(
    address indexed token,
    FeeDistribution[] distributions
);
```

这个[示例交易](https://basescan.org/tx/0x02e7f968e97382b43126d8f15a90b41f35a8b595b5a1a2d3be36a48ec5eb9854)展示了费用如何从 LiFiDiamond 地址直接转发到配置的费用接收钱包。

Status API 已更新，以正确解析新的事件格式。费用数据（包括 `integratorFeeCost`）仍在相同的 `/status` 响应结构中返回。

## 哪些内容没有变化

* API 响应结构没有变化
* 费用配置没有变化
* 合作伙伴集成代码无需变更
* Solana、Bitcoin、Sui 和 Move 的实现不受影响
* FeeCollector 中已累积的现有费用不会自动迁移；请参阅下方章节了解如何提取

## 提取先前收取的费用

在 FeeForwarder 升级之前通过旧版 FeeCollector 合约收取的费用**不会**自动迁移。它们仍保留在 FeeCollector 合约中，必须手动提取。

<Warning>
  只有在费用累积时被指定用于费用收取的钱包地址才能提取这些费用。如果您此后更新了费用钱包，请使用**原始**钱包来领取较早的余额。
</Warning>

### 检查您的旧版余额

**通过 Partner Portal：**

登录 [portal.li.fi](https://portal.li.fi/) 并查看您的费用余额仪表板。

**通过 API：**

```http theme={"system"}
GET https://li.quest/v1/integrators/{integratorId}
```

这将按链和按代币返回您的费用余额：

```json theme={"system"}
{
  "integratorId": "your-integrator-id",
  "feeBalances": [
    {
      "chainId": 137,
      "tokenBalances": [
        {
          "token": {
            "address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
            "symbol": "USDC",
            "decimals": 6,
            "chainId": 137,
            "name": "USD Coin",
            "priceUSD": "1.00"
          },
          "amount": "50000000",
          "amountUsd": "50.00"
        }
      ]
    }
  ]
}
```

### 提取旧版费用

**通过 Partner Portal：**

使用 [portal.li.fi](https://portal.li.fi/) 中的提取功能。

**通过 API：**

```http theme={"system"}
GET https://li.quest/v1/integrators/{integratorId}/withdraw/{chainId}
```

这将返回一个交易请求，您需要用原始费用钱包对其进行签名并提交：

```json theme={"system"}
{
  "transactionRequest": {
    "to": "0x...",
    "data": "0x...",
    "value": "0"
  }
}
```

<Note>
  提取端点仅适用于 EVM 链。在 Solana、Sui 和 Bitcoin 上，费用始终直接发送到您的钱包，无需提取。
</Note>

## 小结

|          | FeeCollector（旧版） | FeeForwarder（新版）          |
| -------- | ---------------- | ------------------------- |
| 费用结算     | 累积，手动领取          | 执行时立即转发                   |
| 手动提取     | 需要               | 不需要                       |
| 需要合作伙伴操作 | 无                | 无                         |
| 向后兼容     | —                | 是，没有 FeeForwarder 的链会自动回退 |

这是一次后端合约升级。合作伙伴无需采取任何操作。

<Note>
  如果您对费用配置或 Status API 如何报告您交易的费用有疑问，请通过您常用的支持渠道联系我们。
</Note>
