> ## Documentation Index
> Fetch the complete documentation index at: https://polymarketcn.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 流動性獎勵

> 如何通過提供流動性獲得 Polymarket 獎勵

<Callout type="success">
  還沒有帳號？[點擊這裡註冊 Polymarket](https://polymarket.com/?r=2026VIP) 並完成入金，才能用錢包私鑰為訂單籤名、實際成交。
</Callout>

<Warning>
  **法律合規提醒**：在使用 Polymarket 服務或 API 前，請確認您所在地區的法律規定。Polymarket 目前不支援比利時、法國、新加坡、泰國、中國大陸等地區，政策可能隨時變化。
</Warning>

Polymarket 為在訂單簿上提供流動性的做市商提供獎勵計劃，鼓勵用戶提供更好的市場流動性。

## 什麼是流動性獎勵？

流動性獎勵（Liquidity Mining）是 Polymarket 向在訂單簿上掛單的做市商提供的激勵計劃。通過在市場上提供流動性，你可以獲得額外的收益。

<CardGroup cols={2}>
  <Card title="被動收入" icon="coins">
    通過掛單賺取獎勵
  </Card>

  <Card title="價差收益" icon="chart-line">
    買賣價差利潤
  </Card>

  <Card title="流動性激勵" icon="gift">
    Polymarket 額外獎勵
  </Card>

  <Card title="降低風險" icon="shield">
    雙邊掛單對衝風險
  </Card>
</CardGroup>

## 如何獲得流動性獎勵

### 基本流程

<Steps>
  <Step title="1. 存入資金">
    在 Polymarket 帳戶存入 USDC
  </Step>

  <Step title="2. 選擇市場">
    選擇流動性需求大的市場
  </Step>

  <Step title="3. 掛限價單">
    在買賣兩邊掛限價單提供流動性
  </Step>

  <Step title="4. 保持活躍">
    訂單需要持續掛在訂單簿上
  </Step>

  <Step title="5. 獲得獎勵">
    根據提供的流動性獲得獎勵
  </Step>
</Steps>

### 獎勵計算方式

流動性獎勵通常基於以下因素：

| 因素        | 權重 | 說明          |
| --------- | -- | ----------- |
| **訂單簿深度** | 高  | 提供的流動性數量    |
| **價格質量**  | 高  | 訂單距離中間價的遠近  |
| **持續時間**  | 中  | 訂單保持活躍的時間   |
| **市場優先級** | 中  | 某些市場有額外獎勵   |
| **競爭程度**  | 低  | 市場上的其他做市商數量 |

### 獎勵公式（簡化版）

```
每日獎勵 = (你的流動性 / 總流動性) × 市場獎勵池 × 時間權重 × 價格權重
```

## 做市策略

### 1. 簡單雙邊掛單

最基礎的策略，在中間價上下掛單：

```python theme={null}
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY, SELL

def simple_market_making(client, token_id, spread=0.02):
    """
    簡單的雙邊掛單策略
    
    Args:
        client: CLOB 客戶端
        token_id: 代幣 ID
        spread: 買賣價差（默認 2%）
    """
    # 獲取當前中間價
    midpoint = float(client.get_midpoint(token_id))
    
    # 計算買賣價格
    buy_price = round(midpoint - spread / 2, 2)
    sell_price = round(midpoint + spread / 2, 2)
    
    # 下買單
    buy_order = OrderArgs(
        price=buy_price,
        size=100.0,  # 100 USDC
        side=BUY,
        token_id=token_id
    )
    signed_buy = client.create_order(buy_order)
    client.post_order(signed_buy, OrderType.GTC)
    print(f"買單: {buy_price} × 100")
    
    # 下賣單
    sell_order = OrderArgs(
        price=sell_price,
        size=100.0,
        side=SELL,
        token_id=token_id
    )
    signed_sell = client.create_order(sell_order)
    client.post_order(signed_sell, OrderType.GTC)
    print(f"賣單: {sell_price} × 100")

# 使用示例
# simple_market_making(client, "YOUR_TOKEN_ID", spread=0.04)
```

### 2. 多層訂單簿

在多個價格層級提供流動性：

```python theme={null}
def layered_market_making(client, token_id, num_layers=3, spread=0.02, size=50):
    """
    多層訂單簿策略
    
    Args:
        num_layers: 價格層數
        spread: 每層的價差
        size: 每層的訂單大小
    """
    midpoint = float(client.get_midpoint(token_id))
    
    for i in range(num_layers):
        # 計算每層的價格
        layer_spread = spread * (i + 1)
        buy_price = round(midpoint - layer_spread / 2, 2)
        sell_price = round(midpoint + layer_spread / 2, 2)
        
        # 每層訂單大小遞減
        layer_size = size * (1 - i * 0.2)
        
        # 下買單
        buy_order = OrderArgs(
            price=buy_price,
            size=layer_size,
            side=BUY,
            token_id=token_id
        )
        signed_buy = client.create_order(buy_order)
        client.post_order(signed_buy, OrderType.GTC)
        print(f"第{i+1}層買單: {buy_price} × {layer_size}")
        
        # 下賣單
        sell_order = OrderArgs(
            price=sell_price,
            size=layer_size,
            side=SELL,
            token_id=token_id
        )
        signed_sell = client.create_order(sell_order)
        client.post_order(signed_sell, OrderType.GTC)
        print(f"第{i+1}層賣單: {sell_price} × {layer_size}")

# 使用示例
# layered_market_making(client, "YOUR_TOKEN_ID", num_layers=5)
```

### 3. 動態調整策略

根據市場波動自動調整：

```python theme={null}
import time

def dynamic_market_making(client, token_id, target_spread=0.03):
    """
    動態調整的做市策略
    """
    while True:
        try:
            # 取消現有訂單
            client.cancel_market_orders(token_id)
            
            # 獲取訂單簿
            book = client.get_order_book(token_id)
            
            if not book['bids'] or not book['asks']:
                print("訂單簿為空，跳過")
                time.sleep(30)
                continue
            
            # 計算當前價差
            best_bid = float(book['bids'][0]['price'])
            best_ask = float(book['asks'][0]['price'])
            current_spread = best_ask - best_bid
            
            # 根據市場情況調整價格
            if current_spread > target_spread * 2:
                # 價差過大，收緊價差
                our_spread = target_spread
            else:
                # 價差正常，稍微放寬
                our_spread = current_spread * 0.9
            
            midpoint = (best_bid + best_ask) / 2
            
            # 下單
            buy_price = round(midpoint - our_spread / 2, 2)
            sell_price = round(midpoint + our_spread / 2, 2)
            
            # 確保價格在合理範圍內
            if 0.01 <= buy_price <= 0.99 and 0.01 <= sell_price <= 0.99:
                # 下买单
                buy_order = client.create_order(OrderArgs(
                    price=buy_price,
                    size=100.0,
                    side=BUY,
                    token_id=token_id
                ))
                client.post_order(buy_order, OrderType.GTC)
                
                # 下卖单
                sell_order = client.create_order(OrderArgs(
                    price=sell_price,
                    size=100.0,
                    side=SELL,
                    token_id=token_id
                ))
                client.post_order(sell_order, OrderType.GTC)
                
                print(f"已挂单: 买 {buy_price} / 卖 {sell_price}")
            
            # 等待 60 秒后重新调整
            time.sleep(60)
            
        except Exception as e:
            print(f"错误: {e}")
            time.sleep(30)

# 使用示例
# dynamic_market_making(client, "YOUR_TOKEN_ID")
```

## 收益计算

### 收益来源

做市商的总收益包括：

```
总收益 = 价差收益 + 流动性奖励 - Gas 费用 - 风险损失
```

#### 1. 价差收益

```python theme={null}
# 示例计算
buy_price = 0.49
sell_price = 0.51
spread = sell_price - buy_price  # 0.02 (2%)

# 如果买单和卖单都成交
buy_amount = 1000  # 买入 1000 个代币
sell_amount = 1000  # 卖出 1000 个代币

profit_from_spread = (sell_price - buy_price) * min(buy_amount, sell_amount)
# 利润 = 0.02 × 1000 = 20 USDC
```

#### 2. 流动性奖励

```python theme={null}
# 假设参数
your_liquidity = 5000  # USDC
total_market_liquidity = 50000  # USDC
daily_reward_pool = 100  # USDC/天

your_daily_reward = (your_liquidity / total_market_liquidity) * daily_reward_pool
# 奖励 = (5000 / 50000) × 100 = 10 USDC/天
```

### 年化收益率计算

```python theme={null}
def calculate_apy(capital, daily_spread_profit, daily_rewards):
    """
    计算年化收益率
    
    Args:
        capital: 投入资金
        daily_spread_profit: 每日价差收益
        daily_rewards: 每日流动性奖励
    """
    daily_profit = daily_spread_profit + daily_rewards
    daily_return = daily_profit / capital
    
    # 年化收益率（复利）
    apy = (1 + daily_return) ** 365 - 1
    
    print(f"投入资金: ${capital}")
    print(f"每日收益: ${daily_profit}")
    print(f"每日回报率: {daily_return * 100:.2f}%")
    print(f"年化收益率: {apy * 100:.2f}%")
    
    return apy

# 示例
calculate_apy(
    capital=10000,
    daily_spread_profit=50,
    daily_rewards=30
)
# 输出：
# 投入资金: $10000
# 每日收益: $80
# 每日回报率: 0.80%
# 年化收益率: 1428.95%
```

## 风险管理

<Warning>
  **重要風險提示**：

  1. **庫存風險**：持有單邊頭寸的風險
  2. **價格風險**：市場突然大幅波動
  3. **流動性風險**：無法及時平倉
  4. **智能合約風險**：合約漏洞
  5. **Gas 費用**：頻繁調整訂單的成本
</Warning>

### 風險控制策略

#### 1. 設置止損

```python theme={null}
def check_inventory_and_hedge(client, token_id, max_imbalance=100):
    """
    檢查庫存不平衡並對衝
    """
    # 獲取持倉
    positions = client.get_positions()
    
    yes_balance = 0
    no_balance = 0
    
    for pos in positions:
        if pos['token_id'] == token_id:
            if pos['outcome'] == 'Yes':
                yes_balance = pos['size']
            else:
                no_balance = pos['size']
    
    # 計算不平衡
    imbalance = abs(yes_balance - no_balance)
    
    if imbalance > max_imbalance:
        print(f"⚠ 庫存不平衡: {imbalance} USDC")
        # 在此處實施對衝策略
        # hedge_position(client, token_id, imbalance)
```

#### 2. 限制單邊暴露

```python theme={null}
def limit_directional_exposure(yes_size, no_size, max_exposure=1000):
    """
    限制單邊暴露
    """
    net_exposure = abs(yes_size - no_size)
    
    if net_exposure > max_exposure:
        # 減少暴露較大的一邊
        if yes_size > no_size:
            return yes_size - (net_exposure - max_exposure), no_size
        else:
            return yes_size, no_size - (net_exposure - max_exposure)
    
    return yes_size, no_size
```

## 最佳實踐

### 1. 選擇合適的市場

✅ **好的市場特徵**：

* 交易量大
* 波動性適中
* 價差穩定
* 有流動性激勵

❌ **避免的市場**：

* 流動性極低
* 接近到期
* 結果即將揭曉
* 價格單邊行情

### 2. 資金管理

```python theme={null}
# 推薦的資金分配
total_capital = 10000  # USDC

# 分配方案
active_orders = total_capital * 0.7   # 70% 掛單
reserve = total_capital * 0.2          # 20% 備用
emergency = total_capital * 0.1        # 10% 應急

print(f"掛單資金: ${active_orders}")
print(f"備用資金: ${reserve}")
print(f"應急資金: ${emergency}")
```

### 3. 監控和調整

```python theme={null}
def monitoring_dashboard(client):
    """
    監控面板
    """
    print("\n=== 做市監控面板 ===")
    
    # 餘額
    balance = client.get_balance()
    print(f"可用餘額: ${balance}")
    
    # 活躍訂單
    orders = client.get_orders()
    print(f"活躍訂單: {len(orders)} 個")
    
    # 持倉
    positions = client.get_positions()
    total_position_value = sum(float(p['value']) for p in positions)
    print(f"持倉價值: ${total_position_value}")
    
    # 今日交易
    trades = client.get_trades()
    today_volume = sum(float(t['size']) for t in trades if is_today(t['timestamp']))
    print(f"今日交易量: ${today_volume}")

# 定期運行
import schedule
schedule.every(5).minutes.do(lambda: monitoring_dashboard(client))
```

## 查詢獎勵

### 通過 Data API 查詢

```python theme={null}
import requests

def get_liquidity_rewards(address):
    """
    查詢流動性獎勵
    """
    response = requests.get(
        f'https://data-api.polymarket.com/rewards/{address}'
    )
    
    rewards = response.json()
    
    print(f"總獎勵: ${rewards['total_rewards']}")
    print(f"本周獎勵: ${rewards['weekly_rewards']}")
    print(f"待領取: ${rewards['unclaimed']}")
    
    return rewards
```

## 常見問題

### Q: 做市需要多少資金？

A: 建議至少 1000 USDC 起步，5000-10000 USDC 更理想。

### Q: 收益率有多少？

A: 取決於市場和策略，通常日收益率在 0.1%-2% 之間。

### Q: 需要一直盯盤嗎？

A: 可以使用自動化腳本，但建議定期檢查和調整。

### Q: 最大的風險是什麼？

A: 單邊庫存積累和市場突然大幅波動。

### Q: 如何獲得更多獎勵？

A: 選擇高獎勵市場，提供更深的流動性，保持訂單活躍。

## 下一步

<CardGroup cols={2}>
  <Card title="第一筆訂單" icon="rocket" href="/api-tutorial/first-order">
    開始你的第一筆訂單
  </Card>

  <Card title="CLOB 快速開始" icon="chart-line" href="/api-tutorial/clob/quickstart">
    學習 CLOB 交易
  </Card>

  <Card title="訂單管理" icon="list-check" href="/api-tutorial/clob/order-management">
    管理你的訂單
  </Card>

  <Card title="套利策略" icon="coins" href="/trading/polymarket-arbitrage">
    了解套利機會
  </Card>
</CardGroup>

## 參考資源

* **Polymarket 做市指南**：[https://polymarket.com/market-making](https://polymarket.com/market-making)
* **流動性獎勵計劃**：[https://polymarket.com/rewards](https://polymarket.com/rewards)
* **Discord 社区**：[https://discord.gg/polymarket](https://discord.gg/polymarket)
