Skip to main content
Orders are the fundamental building blocks of trading on Polymarket. The CLOB supports multiple order types with different execution behaviors and a comprehensive order lifecycle from creation to settlement.

Order Types

The Polymarket CLOB supports four order types, each with distinct execution characteristics:
enum OrderType {
    GTC = "GTC",  // Good Till Canceled
    FOK = "FOK",  // Fill or Kill
    GTD = "GTD",  // Good Till Date
    FAK = "FAK",  // Fill and Kill
}

Good Till Canceled (GTC)

GTC orders remain in the order book until fully filled or manually canceled.
GTC is the most common order type for limit orders. Use this when you want to provide liquidity at a specific price point.
import { Side, OrderType } from "@polymarket/clob-client";

const order = await client.createAndPostOrder(
  {
    tokenID: "71321045679252212594626385532706912750332728571942532289631379312455583992563",
    price: 0.65,
    size: 100,
    side: Side.BUY,
  },
  { tickSize: "0.01" },
  OrderType.GTC  // Order stays active until canceled
);
Use cases:
  • Providing liquidity as a market maker
  • Setting limit orders at desired price points
  • Long-term trading strategies

Good Till Date (GTD)

GTD orders remain active until a specified expiration time or until filled/canceled.
// Create order that expires in 1 hour
const oneHour = Math.floor(Date.now() / 1000) + 3600 + 10; // +10s buffer

const order = await client.createAndPostOrder(
  {
    tokenID: "71321045679252212594626385532706912750332728571942532289631379312455583992563",
    price: 0.65,
    size: 100,
    side: Side.BUY,
    expiration: oneHour,  // Unix timestamp
  },
  { tickSize: "0.01" },
  OrderType.GTD
);
Add a 10-second buffer to your expiration timestamp. The CLOB has a 10-second security threshold and will reject orders expiring sooner.
Use cases:
  • Time-sensitive trading opportunities
  • Managing risk with automatic expiration
  • Event-driven trading strategies

Fill or Kill (FOK)

FOK orders must be filled entirely and immediately, or they are canceled. Partial fills are not allowed.
// Market order using FOK
const order = await client.createAndPostMarketOrder(
  {
    tokenID: "71321045679252212594626385532706912750332728571942532289631379312455583992563",
    amount: 100,  // $100 USDC for BUY orders
    side: Side.BUY,
    orderType: OrderType.FOK,
  },
  { tickSize: "0.01" },
  OrderType.FOK
);
Use cases:
  • Market orders requiring full execution
  • All-or-nothing trading strategies
  • Avoiding partial fills and slippage

Fill and Kill (FAK)

FAK orders are filled as much as possible immediately, and any unfilled portion is canceled.
const order = await client.createAndPostMarketOrder(
  {
    tokenID: "71321045679252212594626385532706912750332728571942532289631379312455583992563",
    amount: 100,
    side: Side.BUY,
    orderType: OrderType.FAK,  // Accepts partial fills
  },
  { tickSize: "0.01" },
  OrderType.FAK
);
Use cases:
  • Market orders where partial fills are acceptable
  • Maximizing immediate execution
  • Reducing slippage risk

Order Structure

User-Facing Order

When creating orders, you use the simplified UserOrder interface:
interface UserOrder {
    tokenID: string;        // Conditional token ID
    price: number;          // Price (0.01 to 0.99)
    size: number;           // Number of shares
    side: Side;             // BUY or SELL
    feeRateBps?: number;    // Fee in basis points (optional)
    nonce?: number;         // For onchain cancellations (optional)
    expiration?: number;    // Unix timestamp (optional)
    taker?: string;         // Taker address, "0x0..." for public (optional)
}

Signed Order Structure

The CLOB uses EIP-712 signed orders internally:
interface SignedOrder {
    salt: string;           // Unique salt for entropy
    maker: string;          // Address providing liquidity
    signer: string;         // Address that signed the order
    taker: string;          // Address that can take ("0x0" = anyone)
    tokenId: string;        // Conditional token ID
    makerAmount: string;    // Amount maker provides (wei)
    takerAmount: string;    // Amount taker provides (wei)
    expiration: string;     // Expiration timestamp ("0" = never)
    nonce: string;          // Onchain cancellation nonce
    feeRateBps: string;     // Fee rate in basis points
    side: Side;             // BUY or SELL
    signatureType: SignatureType;  // Wallet type
    signature: string;      // EIP-712 signature
}

Order Lifecycle

1

Creation

Create an order using the SDK. The order is signed with your private key using EIP-712.
const order = await client.createOrder({
  tokenID: "123...",
  price: 0.65,
  size: 100,
  side: Side.BUY,
});
2

Submission

Post the signed order to the CLOB server.
const response = await client.postOrder(order, OrderType.GTC);
console.log(response.orderID); // Track your order
3

Validation

The CLOB validates:
  • Signature authenticity
  • Price within tick size constraints
  • Sufficient balance and allowances
  • Order parameters (expiration, nonce, etc.)
4

Matching

The order is matched against existing orders in the book:
  • Immediate match: Order executes against existing liquidity
  • Partial match: Partially filled, remainder enters book (GTC/GTD only)
  • No match: Order enters the book (GTC/GTD) or is canceled (FOK/FAK)
5

Settlement

Matched orders settle on-chain:
  • Token transfers execute via the CTF Exchange contract
  • Fees are deducted from proceeds
  • Balances update automatically
6

Completion

Orders complete when:
  • Fully filled
  • Manually canceled
  • Automatically expired (GTD)
  • Rejected (FOK/FAK with no match)

Post-Only Orders

Post-only orders ensure your order is added to the book without immediately matching against existing orders. This guarantees you receive maker fees rather than paying taker fees.
const order = await client.createOrder({
  tokenID: "71321045679252212594626385532706912750332728571942532289631379312455583992563",
  price: 0.65,
  size: 100,
  side: Side.BUY,
});

// Post-only is the 4th parameter (only for GTC/GTD)
await client.postOrder(
  order,
  OrderType.GTC,
  false,  // deferExec
  true    // postOnly - ensures no immediate matching
);
Post-only orders are only supported for GTC and GTD order types. They’re rejected if they would immediately match existing orders.

Order Parameters

Price and Tick Size

Prices must conform to the market’s tick size:
// Get market's tick size
const tickSize = await client.getTickSize(tokenID);
// Returns: "0.01", "0.001", "0.0001", or "0.1"

// Valid prices for tickSize "0.01": 0.01, 0.02, 0.03, ..., 0.99
// Valid prices for tickSize "0.001": 0.001, 0.002, 0.003, ..., 0.999

Fees

Fees are specified in basis points (1 bps = 0.01%):
// Get market's fee rate
const feeRateBps = await client.getFeeRateBps(tokenID);
// Example: 100 = 1.00% fee

// Fees are automatically applied by the SDK
const order = await client.createOrder({
  tokenID,
  price: 0.65,
  size: 100,
  side: Side.BUY,
  // feeRateBps is auto-populated if not specified
});

Nonce

Nonces enable onchain order cancellation:
const order = await client.createOrder({
  tokenID,
  price: 0.65,
  size: 100,
  side: Side.BUY,
  nonce: 12345,  // Custom nonce for onchain cancellation
});

Creating Orders

Limit Orders (GTC/GTD)

// Single step: create and post
const response = await client.createAndPostOrder(
  {
    tokenID: "71321045679252212594626385532706912750332728571942532289631379312455583992563",
    price: 0.65,
    size: 100,
    side: Side.BUY,
  },
  { tickSize: "0.01", negRisk: false },
  OrderType.GTC
);

// Or separate steps
const order = await client.createOrder(
  {
    tokenID: "71321045679252212594626385532706912750332728571942532289631379312455583992563",
    price: 0.65,
    size: 100,
    side: Side.BUY,
  },
  { tickSize: "0.01" }
);

const response = await client.postOrder(order, OrderType.GTC);

Market Orders (FOK/FAK)

// BUY order: amount is in USDC
const buyOrder = await client.createAndPostMarketOrder(
  {
    tokenID: "71321045679252212594626385532706912750332728571942532289631379312455583992563",
    amount: 100,  // Spend $100 USDC
    side: Side.BUY,
    orderType: OrderType.FOK,
  },
  { tickSize: "0.01" },
  OrderType.FOK
);

// SELL order: amount is in shares
const sellOrder = await client.createAndPostMarketOrder(
  {
    tokenID: "71321045679252212594626385532706912750332728571942532289631379312455583992563",
    amount: 100,  // Sell 100 shares
    side: Side.SELL,
    orderType: OrderType.FAK,
  },
  { tickSize: "0.01" },
  OrderType.FAK
);
For BUY orders, amount is denominated in USDC. For SELL orders, amount is denominated in shares.

Managing Orders

Query Open Orders

// Get all open orders
const openOrders = await client.getOpenOrders();

// Filter by market
const marketOrders = await client.getOpenOrders({
  market: "0x1234..." // condition ID
});

// Filter by token
const tokenOrders = await client.getOpenOrders({
  asset_id: "71321045679252212594626385532706912750332728571942532289631379312455583992563"
});

// Get specific order
const order = await client.getOrder("order-id-123");

Cancel Orders

// Cancel single order
await client.cancelOrder({ orderID: "order-id-123" });

// Cancel multiple orders
await client.cancelOrders(["order-id-1", "order-id-2", "order-id-3"]);

// Cancel all orders
await client.cancelAll();

// Cancel all orders for a market
await client.cancelMarketOrders({
  market: "0x1234..."  // condition ID
});

// Cancel all orders for a token
await client.cancelMarketOrders({
  asset_id: "71321045679252212594626385532706912750332728571942532289631379312455583992563"
});

Batch Operations

Posting Multiple Orders

import { OrderType, Side } from "@polymarket/clob-client";

// Create orders
const order1 = await client.createOrder({
  tokenID: "123...",
  price: 0.60,
  size: 100,
  side: Side.BUY,
});

const order2 = await client.createOrder({
  tokenID: "456...",
  price: 0.70,
  size: 50,
  side: Side.SELL,
});

// Post as batch
const responses = await client.postOrders(
  [
    { order: order1, orderType: OrderType.GTC, postOnly: false },
    { order: order2, orderType: OrderType.GTC, postOnly: true },
  ],
  false,  // deferExec
  false   // defaultPostOnly
);

Order Response

When posting an order, you receive:
interface OrderResponse {
    success: boolean;
    errorMsg: string;
    orderID: string;              // Track this ID
    transactionsHashes: string[]; // Onchain tx hashes
    status: string;               // Order status
    takingAmount: string;         // Amount taken
    makingAmount: string;         // Amount made
}

Trading

Learn about the complete trading workflow

Markets

Understand market structure and token IDs

Authentication

Set up API credentials for order submission

Order Reference

Complete API reference for order methods

Build docs developers (and LLMs) love