> For the complete documentation index, see [llms.txt](https://document.sunprotocol.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://document.sunprotocol.io/zhi-neng-he-yue/wo-lun-he-yue.md).

# 涡轮合约

Bond 质押合约领取的个人收益和推荐奖励会先记入涡轮合约。用户在这里选择释放方案、形成可用 SUN，并完成后续领取流程。

### 一次查询用户全貌

调用 `getUserTurbineInfo(user)`，返回：

1. `claimableReward_`：可创建释放订单的个人收益；
2. `claimableRef_`：可创建释放订单的推荐奖励；
3. `rewardQuota_`：最终领取所需的奖励额度；
4. `availableSun_`：已经可用于创建提现订单的 SUN，包含实时待释放部分；
5. 活跃/已完成的释放订单数量；
6. 活跃/已完成的提现订单数量。

简化查询可使用 `getUserInfo(user)`。单独读取时可调用 `claimableReward(user)`、`claimableRef(user)`、`rewardQuota(user)` 和 `availableSun(user)`。

### 释放订单

1. 调用 `getAllPlan()` 查看方案。`duration` 为秒，`feeBps` 的分母是 `1,000,000`。
2. 调用 `quoteReleaseFee(amountSUN,planId)` 查询所需 USDT 费用。
3. 如费用大于 0，先授权 USDT 给涡轮合约。
4. 调用 `createReleaseOrder(rewardType,amountSUN,planId)`。

`rewardType=1` 使用个人收益，`rewardType=2` 使用推荐奖励。订单按方案持续时间线性释放。`pendingRelease(orderId)` 查询尚未入账的实时释放量。

分页查询函数：

* `getActiveReleaseOrders(user,page)`
* `getFinishedReleaseOrders(user,page)`

页码从 `1` 开始，每页最多 `20` 条。返回值包括总额、已释放、实时待释放、开始/结束时间和费用。

### 提现订单与最终领取

1. 确认 `availableSun(user)` 足够。
2. 调用 `quoteWithdrawMaxUSDT(amountSUN)` 获取本次最多需要的 USDT。
3. 授权足够的 USDT。
4. 调用 `createWithdrawOrder(amountSUN)`。合约会用 USDT 为用户兑换精确数量的 SUN，多余 USDT 退回，并记录带解锁时间的提现订单。
5. 到达 `unlockTime` 后，确认 `rewardQuota(user) >= amountSUN`。
6. 调用 `claimWithdrawOrder(orderId)`，消耗对应奖励额度并向用户铸造该笔奖励 SUN。

活跃和历史提现订单使用 `getActiveWithdrawOrders(user,page)`、`getFinishedWithdrawOrders(user,page)` 查询。不要在 `unlockTime` 前调用领取。

### 购买奖励额度

`buyRewardQuota(usdtAmount)` 使用 USDT 增加奖励额度。写入前需要授权 USDT；可用 `quoteUSDTToSUN(usdtAmount)` 和 `quotaMultiplierBps()`辅助估算，但最终以交易执行为准。


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://document.sunprotocol.io/zhi-neng-he-yue/wo-lun-he-yue.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
