> 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/shan-dui-he-yue.md).

# 闪兑合约

### 先查询报价

| 函数                       | 返回                                 |
| ------------------------ | ---------------------------------- |
| `usdtbuysun(usdtAmount)` | 输入 USDT 预计得到的 SUN，尚未扣用户设置的滑点保护     |
| `sunsellusdt(sunAmount)` | 卖出 SUN 预计得到的 USDT，已按合约的 3% 卖出税模型估算 |

### 买入 SUN

1. 用 `usdtbuysun(usdtAmount)` 查询预计结果。
2. 授权 USDT 给本合约。
3. 调用 `buySun(usdtAmount,slippageBps)`。

买入滑点 `slippageBps` 不能超过 `MAX_BUY_SLIPPAGE_BPS()`，当前源码上限为 `200`（2%）。例如 `100` 表示 1%。

### 卖出 SUN

1. 用 `sunsellusdt(sunAmount)` 查询税后预计结果。
2. 授权 SUN 给本合约。
3. 调用 `sellSun(sunAmount,slippageBps)`。

卖出滑点不能超过 `MAX_SELL_SLIPPAGE_BPS()`，当前源码上限为 `500`（5%）。实际成交受池子状态、价格变化影响。


---

# 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/shan-dui-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.
