# 交换（Swap）

### **介绍**

Megaton Finance能够基于流动性池相互交换{Token standard}代币。Token 交换是基于Uniswap v2 AMM的方程 x \* y = k 执行的，并且在token swap过程中会出现滑点。

在Megaton Finance的池中兑换代币时，根据每个流动性池的费用政策收取 0.1% 的交易费用。交易费用 100% 支付给 LP。

<figure><img src="/files/krGHNPk3Jz9aQfVeWl6F" alt=""><figcaption></figcaption></figure>

### 池创建和交换

Megaton Finance的流动性池建立在WTON、ETH、USDT等基础上。 V1 不支持池创建。由于所有矿池都是基于WTON创建的，而Megaton Finance早期版本没有路由功能，所以在兑换WTON以外的代币时需要经过两次兑换流程。oUSDT兑换oDAI的情况下，首先要先将oUSDT兑换成WTON，然后再将WTON兑换成WTON-oDAI池中的oDAI。<br>

### x \* y = k 的定价算法

\- x： WTON / y： MEGA\
\- 假设提供给池的 x 和 y 的储备数量各为 100\
\- x(100) \* y(100) = k(10,000)\
\- 如果交易者支付 10 WTON 并购买 MEGA，则交易者获得的 MEGA 数量和池中剩余的 MEGA 代币数量计算如下：\
\
**a. 池中剩余的WTON数量**\
x(110) \* y(储备) = 10,000\
y（储备）= 90.9 MEGA\
\
**b. 交易者赚取的 MEGA 数量**\
**100 - 90.9 MEGA = 9.1 MEGA**\
在目前我们看到的例子中，初始 WTON/MEGA 池的代币价格比为 1:1。所以交易者会支付 10 TON 并期望收到 10 MEGA。 然而，交易者实际获得的 MEGA 数量为 9.1 MEGA。这样，在 x \* y = k 算法中，您订购的代币价格与实际成交的代币价格之间的差值称为滑点。交易者在下掉期订单之前必须检查滑点。<br>


---

# Agent Instructions: 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:

```
GET https://docs.megaton.fi/zh-cn/products/jiao-huan-swap.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
