# 去中心化交易所（DEX）

### 去中心化交易所（Decentralized Exchange, DEX）是一種不需要中間人的加密貨幣交易平台。你的幣始終在自己錢包裡，透過智能合約直接和其他人（或流動性池）交易。沒有 KYC，沒有託管風險，真正的「你的幣你做主」。

***

## DEX 的運作方式

### 傳統 CEX

```
你的幣 → 存入交易所 → 交易所撮合 → 交易完成
        (失去控制)
```

### DEX

```
你的幣 → 連接錢包 → 智能合約撮合 → 交易完成
        (始終在你錢包)
```

{% hint style="info" %}
**關鍵差異**

在 DEX 上交易，你的資產從頭到尾都在自己的錢包裡。智能合約只在交易的瞬間移動資產，你不需要「存款」到任何地方。
{% endhint %}

***

## DEX 的類型

### 1. 訂單簿模式（Order Book）

傳統的買賣掛單方式，鏈上或鏈下撮合。

* **代表**：dYdX、Serum
* **特點**：體驗接近 CEX，但流動性較難建立

### 2. 自動做市商（AMM）

使用流動性池和數學公式決定價格。

* **代表**：Uniswap、SushiSwap、Curve
* **特點**：永遠有流動性，但可能有滑點

```
AMM 公式（恆定乘積）：
x × y = k

x = 池中代幣 A 的數量
y = 池中代幣 B 的數量
k = 常數

當你用 A 換 B，A 增加、B 減少，但 k 保持不變
這就自動決定了價格
```

***

## 主要的 DEX

| DEX         | 區塊鏈       | 類型        | 特色          |
| ----------- | --------- | --------- | ----------- |
| Uniswap     | 以太坊       | AMM       | 最大的 DEX，創始者 |
| PancakeSwap | BNB Chain | AMM       | BSC 上最大     |
| Curve       | 多鏈        | AMM       | 專注於穩定幣      |
| dYdX        | 自有鏈       | 訂單簿       | 專注於衍生品      |
| Raydium     | Solana    | AMM + 訂單簿 | 高速低費        |

***

## DEX 的優勢

| 優勢    | 說明              |
| ----- | --------------- |
| 無託管   | 資產始終在你錢包        |
| 無 KYC | 不需要身分驗證         |
| 抗審查   | 沒有中心化機構可以凍結你的帳戶 |
| 上幣自由  | 任何人可以創建交易對      |
| 透明    | 所有交易記錄在鏈上       |

***

## DEX 的劣勢

| 劣勢     | 說明          |
| ------ | ----------- |
| 流動性較低  | 小幣可能滑點很大    |
| Gas 費  | 每筆交易都要付鏈上費用 |
| 速度較慢   | 需要等區塊確認     |
| 用戶體驗   | 對新手不友善      |
| 智能合約風險 | 合約可能有漏洞     |

{% hint style="warning" %}
**假幣風險**

因為任何人都可以在 DEX 上創建代幣和交易對，要特別小心假幣。永遠要確認代幣的合約地址是正確的。
{% endhint %}

***

## 流動性提供（LP）

在 AMM DEX 上，普通人可以成為「流動性提供者」：

```
你提供：100 ETH + 等值的 USDC
存入：ETH/USDC 流動性池
獲得：LP Token（代表你的份額）
收益：交易手續費分成
```

{% hint style="danger" %}
**無常損失**

提供流動性有「無常損失」風險——如果兩個代幣的價格比例變化，你可能虧錢。這是 LP 必須了解的風險。
{% endhint %}

***

## 延伸閱讀

* [中心化交易所](/mai-mai-shu-wei-zi-chan-de-chang-suo/zhong-xin-hua-jiao-yi-suo.md) — DEX 的對比
* [Uniswap](https://github.com/dAAAb/Blockpedia/blob/master/jiao-yi-suo/qu-zhong-xin-hua-jiao-yi-suo/uniswap.md) — 最大的 DEX
* [AMM](https://github.com/dAAAb/Blockpedia/blob/master/defi/amm.md) — 自動做市商原理
* [無常損失](https://github.com/dAAAb/Blockpedia/blob/master/defi/wu-chang-sun-shi.md) — LP 的風險

***

#### 參考資料

* [DeFi Llama DEX Rankings](https://defillama.com/dexs)
* [Uniswap Docs](https://docs.uniswap.org/)


---

# 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://www.0x1.academy/mai-mai-shu-wei-zi-chan-de-chang-suo/qu-zhong-xin-hua-jiao-yi-suo.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.
