Trading
Orders, the onchain orderbook, matching, settlement, and batch tools — the full trading surface on every OddMaki market.
Trading on OddMaki runs entirely through a fully onchain central limit order book (CLOB). Every order, fill, and cancel is a transaction on Base — there's no off-chain matching engine, no relay server, no centralised sequencer.
This section covers the trading flow end-to-end: how orders are placed, how the orderbook holds them, how the matching engine crosses them into fills, and how those fills settle into outcome tokens and collateral movements.
Order → Match → Fill → Settlement
┌─────────────┐ placeOrder ┌──────────────────┐
│ Trader │ ───────────────▶│ Orderbook │
└─────────────┘ │ (per-market │
│ tick levels) │
└────────┬─────────┘
│ matchOrders (permissionless)
▼
┌──────────────────┐
│ Matching engine │
│ picks settlement │
│ path per cross │
└────────┬─────────┘
│
┌──────────────────────────────┼──────────────────────────────┐
▼ ▼ ▼
┌────────────┐ ┌──────────────┐ ┌──────────────┐
│ NORMAL │ │ MINT-TO-FILL │ │ MERGE-TO-FILL│
│ buy ⇄ sell│ │ YES + NO │ │ YES + NO │
│ same │ │ buyers │ │ sellers │
│ outcome │ │ split into │ │ merge back │
│ │ │ outcome tokens│ │ to collateral│
└────────────┘ └──────────────┘ └──────────────┘
│
▼
┌──────────────────┐
│ Fill event + │
│ token transfer + │
│ fee distribution │
└──────────────────┘Orders
An order is a request to buy or sell YES or NO outcome tokens at a specific tick (limit) or at the best available price (market). It belongs to exactly one market and one side. Makers pay no fees; takers pay the full fee stack — see Fees.
| Type | Time-in-force | What happens |
|---|---|---|
| Limit | GTC by default; optional expiry timestamp | Rests at the specified tick until matched, cancelled, or expired |
| Market — FOK (Fill-or-Kill) | One-shot | Fills the requested quantity entirely or reverts; partial fills not allowed |
| Market — FAK (Fill-and-Kill) | One-shot | Fills as much as possible against the book, cancels any remainder |
placeOrder always takes a price + amount + side + market. The SDK's placeOrderSimple accepts human-readable strings ("0.80", "100", "24h") and converts to ticks/wei.
Order lifecycle
| State | Description |
|---|---|
| Resting | Limit order sitting on the book at its tick |
| Filled | Fully matched against a counter-order |
| Cancelled | Maker called cancelOrder (or batchCancelOrders) |
| Expired | Pre-set expiry timestamp elapsed; the order is removed on its next interaction |
| Auto-cancelled | Market resolved while the order was still on the book; refundable via cancelOrdersOnResolvedMarket |
Trades
A trade (called a fill on chain) is the event of two orders crossing — one taker, one maker — and the onchain settlement that results. Every fill produces:
- A transfer of outcome tokens between the maker and taker
- A fee distribution across the four-layer stack (taker pays everything)
- A
Fillevent indexed by the subgraph
The matching engine is permissionless: anyone can call matchOrders to cross resting orders and earn the 10 bps match-operator fee.
Three settlement paths
OddMaki has three settlement paths, picked per-cross by the matching engine based on what's available on the book:
| Path | When it fires | What changes hands |
|---|---|---|
| Normal Fill | Buy crosses Sell on the same outcome | Existing YES (or NO) tokens transfer maker → taker; collateral transfers taker → maker |
| Mint-to-Fill | YES buy + NO buy cross | Collateral from both buyers is split into matched YES + NO pairs via the CTF; each buyer ends up holding the side they bought |
| Merge-to-Fill | YES sell + NO sell cross | Both sellers' tokens are merged into collateral via the CTF; collateral is paid out to both sellers |
These three paths are why the CLOB stays liquid even when there's no obvious counter-order on the same side — same-side scarcity gets resolved by minting (for buyers) or merging (for sellers).
In this section
- Overview — this page
- Orderbook — onchain CLOB mechanics: doubly-linked tick levels, FIFO per tick, best-bid/best-ask tracking
- Matching & Settlement — the matching engine, the three settlement paths in detail, and the match-operator fee
- Batch Operations — place up to 20, cancel up to 100, or atomic cancel-and-replace in a single tx