Prerequisites
Before placing orders, initialize the required clients:OrderClient Constructor
The
OrderClient automatically fetches your user profile data (including ownerId) from the API on the first order. You do not need to supply it manually.Token Approvals
Before trading, your wallet must approve the relevant venue contracts to spend USDC and conditional tokens. This is a one-time setup per venue.Approval Requirements
Manual Approval with ethers
GTC Orders (Good-Til-Cancelled)
GTC orders remain on the orderbook until filled, cancelled, or the market resolves. Specifyprice (probability between 0 and 1) and size (number of shares).
Buy YES shares
Post-only GTC order
UsepostOnly: true to ensure your order is never filled immediately as a taker. If the order would cross the spread (i.e., match against existing orders), it is rejected instead. This guarantees you always receive maker fees.
Sell NO shares
GTC Parameter Reference
Self-Trade Prevention
PassstpPolicy 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 — and applies to any order type. Omit it to keep the server default, cancel_maker.
The create-order response carries an
execution object 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 (Fill-And-Kill)
FAK orders use the sameprice and size inputs as GTC, but they only consume immediately available liquidity and cancel any unmatched remainder.
postOnly is not supported for FAK orders.
Buy with FAK
Sell with FAK
FAK Parameter Reference
FOK Orders (Fill-Or-Kill)
FOK orders execute immediately against the existing orderbook or are rejected entirely. Instead ofprice and size, specify makerAmount which represents the total value to trade.
Buy with FOK
For a BUY FOK order,makerAmount is the amount of USDC you are willing to spend:
Sell with FOK
For a SELL FOK order,makerAmount is the number of shares you want to sell:
FOK Parameter Reference
NegRisk Orders
When trading NegRisk markets, always use the submarket slug — not the group slug. Fetch the group to discover submarkets, then fetch the specific submarket to get its token IDs.Cancel Orders
Cancel an open order by its ID:Order States
Error Handling
The SDK throwsAPIError for HTTP-level failures. Inspect status and message for details.
Validation Rules
Price validation
Price validation
Prices must be between 0 and 1 (exclusive). A price of
0.65 means you value the outcome at 65%. Prices outside this range will be rejected by the API.Size validation
Size validation
Size must be a positive number. Fractional sizes are allowed if they align to the shares step (0.001). Max 3 decimal places.