Skip to main content
The Exchange client performs every state-changing operation. Each call is signed with your wallet key using EIP-712; the SDK builds the envelope, selects the signing path, and manages the nonce for you.
wallet may be a private-key hex string or an eth_account LocalAccount. Optional arguments: account_id (set it when signing with an agent key — see Agent delegation) and a shared nonce_manager.
Prices and sizes are raw integer strings, scaled by the contract’s priceScale / qtyScale from configs. Order placement is asynchronous and HTTP 200 does not always mean success — see key behaviors.

Register an account

Orders

order builds a single-order bulk_orders call. For builder-fee sharing, pass builder_address / builder_fee; in a batch only orders[0]’s builder fields apply to the whole request. A client order id (cloid) is a positive int64; wrap it with Cloid.from_int(...) so you can locate the order later with orders_by_cloids or cancel_by_cloid.

Cancel & modify

modify changes only price / size / TIF / cloid — provide just the fields you want to change; side, asset, and reduce-only cannot change.

Margin & leverage

update_margin_mode requires no open position or orders on the contract. Omit is_hedge to keep the current position mode; switching to isolated (is_cross=False) requires HEDGE mode.

Conditional orders (TP/SL)

At least one of tp_price / sl_price must be greater than 0. A limit price of "0" fires a market IOC on trigger; a value above 0 places a GTC limit. A size of "0" closes the whole position. Trigger type selects the reference price (0 = mark, 1 = index, 2 = last).

Collateral transfers

Agent (API-wallet) delegation

Keep the master key offline and authorize a hot agent key to sign trades. The server routes an agent-signed action to the master account from the recovered signer, so the agent Exchange keeps account_id pointed at the master.
approve_agent and revoke_agent are master-only. valid_until is a Unix-ms expiry (0 = permanent). See API Wallets for the delegation model.