Order actions are the core of day-to-day trading on the Proof Exchange. They cover the full lifecycle of a resting order — creation, modification, cancellation, and position closure — plus the atomic basket primitive for multi-leg strategies. Every order action is user-signed: the envelope signer’s derived address must match theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Proof-labs/trading-sdk/llms.txt
Use this file to discover all available pages before exploring further.
owner field (or belong to an approved agent). Type signatures are drawn directly from src/types.ts.
PlaceOrder
Place a limit order on the order book. The order rests until filled, cancelled, or expired (ifdefaultTtlMs is set on the market).
Market identifier (unique integer). Use
1 for BTC-PERP, 2 for ETH-PERP, etc.20-byte account address derived from the Ed25519 public key via
pubkeyToOwner(publicKey).Order side:
Side.Buy (1) to go long, Side.Sell (2) to go short.Limit price in integer cents with 2 decimal places. For example,
6675234n represents $66,752.34.Order quantity in integer contracts (lots).
1n = 1 lot.Optional client-assigned order ID for correlation and deduplication. Echoed in
OrderPlacedEvent and subsequent cancel/fill events.When
true, the engine rejects the order if it would cross the book on placement (PostOnlyWouldCross, error code 34). Use this to guarantee maker-side execution. Defaults to false.When
true, the order may only reduce an existing position. Same-side orders that would increase the position are rejected (ReduceOnlyWouldIncrease, error code 35); over-closing quantity is clamped to the current position size. Defaults to false.Time-in-force policy.
TimeInForce.Gtc (default) — unmatched quantity rests on the book. TimeInForce.Ioc — unmatched quantity is dropped after crossing. TimeInForce.Fok — the entire order must fill immediately or is rejected without any mutation.CancelOrder
Cancel an existing resting order by its engine-assigned ID.Engine-assigned order ID to cancel. Obtain this from the
OrderPlacedEvent.orderId field or from queryOpenOrders.20-byte account address of the order owner. Must match the order’s recorded owner; the engine rejects mismatches.
CancelClientOrder
Cancel a resting order using the owner-scoped client order ID assigned at placement. Useful when you know your own ID but have not yet observed the engine-assigned ID.20-byte account address of the order owner.
The client-assigned order ID originally passed in
PlaceOrder.clientOrderId.CancelAllOrders
Cancel all resting orders for an account, optionally scoped to a single market.20-byte account address whose resting orders should be cancelled.
Optional market scope. Pass a market ID to cancel only orders on that market. Omit or pass
null to cancel across all markets.CancelReplaceOrder
Atomically cancel one resting order and place its replacement in a single transaction. If the cancel half fails (e.g., the order is already filled), the placement does not execute.20-byte account address whose order should be cancelled and replaced.
Engine-assigned order ID to cancel. Mutually exclusive with
cancelClientOrderId; provide exactly one.Owner-scoped client order ID to cancel. Mutually exclusive with
cancelOrderId; provide exactly one.Market for the replacement order.
Side for the replacement order:
Side.Buy or Side.Sell.Replacement limit price in integer cents.
Replacement order quantity in integer contracts.
Optional client-assigned ID for the replacement order.
Post-only flag for the replacement order. Defaults to
false.Reduce-only flag for the replacement order. Defaults to
false.Time-in-force for the replacement order. Defaults to
TimeInForce.Gtc.AmendOrder
Amend an existing resting order’s price or quantity in place, preserving the engine-assigned order ID and queue priority (subject to engine rules on price-improving amendments).20-byte account address whose order should be amended.
Engine-assigned order ID to amend.
Optional replacement price in integer cents. Omit or pass
null to keep the existing price.Optional new total order quantity in integer contracts. Omit or pass
null to keep the existing quantity.MarketOrder
Place a market order that crosses immediately against resting orders. Unmatched quantity after crossing is dropped (IOC semantics). Subscribe toMarketOrderProcessedEvent to determine how much was filled.
Market identifier.
20-byte account address of the order owner.
Order side:
Side.Buy or Side.Sell.Order quantity in integer contracts. Any unfilled remainder after crossing is silently dropped.
Optional client-assigned order ID echoed in the
MarketOrderProcessedEvent.ClosePosition
Close an entire open position by placing an opposite-side IOC order priced at oracle ± spread. The action is idempotent — if no position exists the engine returns code 0 without emitting any events.owner must equal the envelope signer’s derived address; agents cannot close on behalf of owners via this action.
Market identifier of the position to close.
20-byte account address of the position owner. Must equal the envelope signer’s derived address.
AtomicBasketOrder
A native all-or-revert multi-leg basket. Every leg executes as a fill-or-kill limit order at the given price limit. If any single leg cannot fully fill, the entire transaction rolls back through the overlay — no partial state is committed.20-byte account address of the basket owner. Must equal the envelope signer’s derived address.
Ordered list of basket legs. Each leg executes as a fill-or-kill limit order; the whole basket reverts if any leg fails.
Basket-wide slippage budget in basis points. The engine enforces each leg’s explicit price limit independently; this value is emitted for auditability and client/UI reconciliation only. Encodes as
0 when absent (not nil).AtomicBasketLeg
Market identifier for this leg.
Leg side:
Side.Buy or Side.Sell.Worst acceptable execution price in integer cents. Buy legs will not pay above this; sell legs will not sell below it.
Leg quantity in integer contracts.
Optional client-assigned order ID echoed in events for correlation.
When
true, this leg may only reduce an existing position.