Skip to main content

Overview

The Rust SDK provides OrderClient for order creation, EIP-712 signing, and order management. It supports:
  • OrderType::Gtc for resting limit orders
  • OrderType::Fak for fill-and-kill limit orders
  • OrderType::Fok for fill-or-kill market orders

Prerequisites

Before placing orders, you need:
  • an authenticated Client
  • a private key for EIP-712 signing
  • market venue data (fetched via get_market() and cached automatically)
The OrderClient lazily fetches your profile on the first order to determine your owner_id and fee rate. CHAIN_ID defaults to 8453 (Base mainnet) unless you override it.

Token Approvals

Before your first trade on a given venue, you must approve the exchange contracts to spend your tokens. This is a one-time on-chain setup per venue.
Approve USDC and Conditional Tokens to the exchange contract:
Approvals are on-chain transactions that cost gas. Use venue.exchange for both CLOB and NegRisk, and additionally venue.adapter for NegRisk markets.

GTC Orders

GTC orders remain on the book until filled or explicitly cancelled.

Post-only GTC order

Use post_only: true to ensure the order never crosses the spread as a taker:

GtcOrderArgs

Self-Trade Prevention

Set stp_policy on CreateOrderParams to control what happens when your incoming order would match your own resting order on the same token. It is a top-level request field — not part of the EIP-712 signed order args — and applies to any order type. Leave it None to keep the server default, cancel_maker.
The create-order response carries an execution field with the outcome:
Self-trade prevention blocks same-profile matches on the same token only. Orders on a different token of the same profile are unaffected. The wire field is always stpPolicy, regardless of the SDK.

FAK Orders

FAK orders use the same price + size inputs as GTC, but any unmatched remainder is cancelled immediately.
post_only is not supported for FAK orders.

FOK Orders

FOK orders execute immediately and fully, or are cancelled entirely. Instead of price and size, you pass maker_amount.
For buys, maker_amount is the total USDC to spend:

FokOrderArgs

Build and Sign Separately

For advanced flows, build and sign orders without submitting them:
You can also override the signing config explicitly:

Cancelling Orders

Cancel a single order:
Cancel all orders in a market: