> 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/en/smart-contracts/turbine-contract.md).

# Turbine Contract

Personal and referral rewards claimed from Stake and Bond are first credited to Turbine. Users choose a release plan here, build available SUN, and complete the withdrawal flow.

### Read the complete user position

`getUserTurbineInfo(user)` returns personal claimable rewards, referral claimable rewards, reward quota, available SUN, and active/finished counts for release and withdrawal orders. `getUserInfo(user)` is a shorter version. Individual getters include `claimableReward`, `claimableRef`, `rewardQuota`, and `availableSun`.

### Release orders

1. Call `getAllPlan()`. `duration` is seconds; `feeBps` uses `1,000,000` as denominator.
2. Call `quoteReleaseFee(amountSUN,planId)`.
3. Approve USDT if the fee is nonzero.
4. Call `createReleaseOrder(rewardType,amountSUN,planId)`.

`rewardType=1` uses personal rewards; `rewardType=2` uses referral rewards. `pendingRelease(orderId)` returns the live unreconciled release amount.

Use `getActiveReleaseOrders(user,page)` and `getFinishedReleaseOrders(user,page)`. Pages start at 1 and contain at most 20 records.

### Withdrawal and final claim

1. Confirm that `availableSun(user)` is sufficient.
2. Call `quoteWithdrawMaxUSDT(amountSUN)`.
3. Approve enough USDT.
4. Call `createWithdrawOrder(amountSUN)`. The contract swaps USDT for the exact SUN amount to the user, refunds unused USDT, and creates a timed withdrawal record.
5. After `unlockTime`, confirm `rewardQuota(user) >= amountSUN`.
6. Call `claimWithdrawOrder(orderId)`. This consumes reward quota and mints the reward SUN to the user.

Read active and historical records with `getActiveWithdrawOrders` and `getFinishedWithdrawOrders`. Do not claim before `unlockTime`.

### Reward quota

`buyRewardQuota(usdtAmount)` spends approved USDT to increase reward quota. `quoteUSDTToSUN` and `quotaMultiplierBps()` help estimate the quota before submitting.


---

# 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/en/smart-contracts/turbine-contract.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.
