Docs/Market mechanics/CLOB trading
Trade YES and NO shares through escrowed limit orders.
Predistate markets keep an onchain order book with partial fills, batch fills, and maker-controlled cancellation.
Orders#
Every order names the outcome, buy or sell side, price, and share amount. Buy orders escrow collateral. Sell orders escrow the selected outcome token. Price is collateral per share on a 1e18 scale and must be greater than zero and at most one.
// price is collateral per share, scaled by 1e18
const price = parseUnits("0.64", 18);
const amount = parseUnits("100", collateralDecimals);
// Escrows collateral for a buy, or outcome shares for a sell.
const orderId = await market.write.createOrder([
true, // YES token
true, // buy
price,
amount,
]);
await market.write.fillOrder([orderId, amount / 2n]);
await market.write.cancelOrder([orderId]);Execution#
fillOrdersupports full and partial fills.fillOrdersskips stale, invalid, and self-owned entries while filling the remaining valid orders. If batch execution itself fails, the transaction reverts instead of succeeding without a fill.- Gross quote rounds up to collateral precision. A final fill consumes the order's exact remaining quote so partial fills preserve one-for-one accounting.
- Taker buys pay gross quote plus fee; taker sells receive gross quote minus fee.
- Self-fills revert so makers cannot farm their own rebate.
- Only the maker can cancel; cancellation remains available after market resolution.
- The matching endpoint sorts best price first and returns expected average price and any unmatched amount.
Complementary prices#
YES and NO each trade at their own execution price. For a normalized binary quote, NO Buy now equals 1 − YES Sell now, while NO Sell now equals 1 − YES Buy now. This preserves the crossed perspective of the book.