# 交換（Swap）

### 介紹

Megaton Finance能夠基於流動性池相互交換 {Token standard} 代幣。 Token交換是基於Uniswap v2 AMM 的方程 x \* y = k 執行的，並且在 token swap 過程中會出現滑點。

在Megaton Finance的池中兌換代幣時，根據每個流動性池的費用政策收取 0.1% 的交易費用。交易費用 100% 支付給 LP。

<figure><img src="/files/l8SeYiYo20E9SuTDe16n" 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-tw/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.
