Skip to main content

Slippage Protection

Market orders execute via CLOB book walking — walking through the real Polymarket order book to find liquidity. Slippage protection ensures you don’t get a worse price than expected.

How It Works

  1. The trading engine fetches the real-time order book from Polymarket’s CLOB
  2. Your order is “walked” through bid/ask levels to compute a depth-weighted fill price
  3. The actual fill price is compared to the expected mid-price
  4. If slippage exceeds your max_slippage_bps threshold, the order is rejected
Expected mid: $0.65
Actual fill:  $0.67 (walked through thin liquidity)
Slippage:     200 bps (2%)

If max_slippage_bps = 100 → ORDER REJECTED
If max_slippage_bps = 500 → ORDER FILLED at $0.67

Setting Slippage Tolerance

Add max_slippage_bps to your order request:
{
  "market_id": "0xabc...",
  "side": "BUY",
  "outcome": "Yes",
  "quantity": "10",
  "order_type": "market",
  "max_slippage_bps": 100
}
ValueMeaning
1001% max slippage
5005% max slippage (default)
100010% max slippage
Not setUses server default (500 bps / 5%)

Fill Diagnostics

Every market order response includes transparency metadata:
{
  "order_id": 42,
  "status": "FILLED",
  "price": "0.67",
  "price_source": "clob_book",
  "slippage_bps": 200
}

Price Sources

SourceDescriptionReliability
clob_bookFull order book walk from CLOB APIHighest — real depth
clob_midpointCLOB mid-price (thin book fallback)High
gamma_apiGamma API price feedMedium — may be delayed
redis_cacheCached price from background pollerLower — up to 45s stale
Monitor price_source in your bot logs. If you see frequent redis_cache fills, the CLOB API may be experiencing issues. Consider pausing trading during degraded price quality.

Recommendations by Strategy

StrategySuggested max_slippage_bps
Scalping / HFT50–100 (0.5%–1%)
Swing trading200–500 (2%–5%)
Bulk accumulation500–1000 (5%–10%)
Illiquid markets1000+ or use limit orders
For illiquid markets with wide spreads, consider limit orders instead of market orders. Limits give you price certainty at the cost of fill uncertainty.

Next Steps