ASK KNOX
beta
LESSON 263

CLOB Architecture and Order Flow

How Polymarket's Central Limit Order Book actually works. Maker, taker, orderbook depth, the balance-allowance endpoint, and why thin books change how execution logic has to be written.

9 min read

Polymarket is a Central Limit Order Book — not an AMM. That one fact shapes every integration decision downstream.

Where the Book Lives

The orderbook itself is off-chain. Bids and asks are held in Polymarket's backend database, sorted by price, matched by a centralized engine. This is why orderbook depth queries go through a REST API (/book?token_id=...) and not through an RPC call to Polygon. Only the settlement of matched orders happens on-chain: the ERC-1155 conditional token transfers and the USDC.e collateral movements.

That off-chain structure gives Polymarket the speed advantage of a traditional exchange: sub-second order placement, deep price levels, standard limit-order mechanics. It also means your bot needs to speak HTTP to the Polymarket CLOB API — not just Web3.

The Four Endpoints That Matter

  1. /markets — Lists all active markets with their condition IDs and token IDs.
  2. /book?token_id=... — Returns the live orderbook for a specific outcome token. Bids and asks, sorted.
  3. /balance-allowance?asset=...&wallet=... — Returns what Polymarket believes your wallet has available. Use this instead of direct Web3 balance calls during pre-trade checks.
  4. /orders — POST to place an order (signed EIP-712 payload), GET to inspect existing orders.

A Polymarket bot that understands these four endpoints can do 90% of what it needs to do. The remaining 10% — position resolution, PnL queries, historical fills — lives at other endpoints but is not on the critical path for trade execution.

Inline Diagram — Order Flow

POLYMARKET CLOB — ORDER FLOWHERMES BOTsignal → order decisionCLOB REST APIorders · book · balanceMATCHING ENGINEbids ⟷ asks (off-chain)POLYGON CHAINERC-1155 + USDC.e settleORDERBOOK SNAPSHOT (thin political market)ASK 0.58 × 220ASK 0.57 × 80ASK 0.56 × 40BID 0.54 × 50BID 0.53 × 100BID 0.52 × 160spread 0.02 · a $50 taker walks 2 levels

Why Thin Books Matter

Political markets on Polymarket are typically thin. A top-of-book size of 100 shares is normal. A taker order of $50 can walk two or three price levels before it fills, costing 2-4 cents of slippage — which is meaningful when most contracts trade between $0.30 and $0.70.

The implication for bot logic:

  • Check depth before placing taker orders. Query /book and compute the walked-price at your intended size.
  • Set a max slippage tolerance. If the walked price exceeds threshold, place a maker order instead and accept possible non-fill.
  • Size orders to the book. Do not blindly send $500 at a market showing $80 at top-of-book.

The Rule

Understand the CLOB before integrating. The four endpoints are your API surface. The off-chain matching engine is your speed layer. Polygon is your settlement layer. Thin books are your execution constraint. Every Polymarket bot decision flows from these four facts.