Skip to content

Order Manager (HTTP)

The matching engine’s HTTP surface, served by axum under /v1/. Authenticated with SIWS; GET /health is the only public route.

Base URL: CLOB_HTTP_ADDR, default http://127.0.0.1:8080.

MethodPathOperation
POST/v1/ordersInsert an order
GET/v1/ordersYour resting orders (query: FilterParams)
GET/v1/orders/value-rangeResting orders above a notional threshold
GET/v1/orders/{id}One order, book only
POST/v1/orders/cancelCancel one
POST/v1/orders/cancel-batchCancel several
POST/v1/orders/cancel-allCancel everything you own
POST/v1/orders/cancel-marketCancel everything in a market/asset
POST/v1/orders/size-updateInternal — X-Internal-Token
GET/v1/tradesTrade history (query: TradeParams)
GET/v1/trades/lastMost recent trade
GET/v1/open-ordersOpen orders from the ledger
GET/v1/open-orders/{id}One open order
GET/v1/order-book-summaryBook summary (condition_id, token_id)
GET/v1/bookAggregated book (token_id, optional condition_id)
GET/v1/marketsCondition ids of every book
GET/v1/tokensEvery known token id
GET/v1/markets/{condition_id}Market metadata
GET/health{"ready": bool} — public

Query parameters are parsed with #[serde(default)], so optional filters may be omitted entirely.

Authorization: Bearer <SIWS JWT>

The sub claim is the authenticated address. It is the owner of every order you insert, the identity for cancels, and the required value of any owner filter. Client-supplied owner fields are accepted but ignored.

GET /v1/orders and GET /v1/orders/value-range are always scoped to that address — other users’ order hashes and owners are never published.

→ Authentication


The raw signed order. Wire names are camelCase.

FieldTypeNotes
salti64
makerstringBase58 Solana address (hex accepted as a fallback)
signerstringBase58; must equal maker
takerstringBase58; must be the zero address
tokenIdstringAsset id
makerAmountstringRaw token units, decimal string
takerAmountstringRaw token units, decimal string
sidestring"BUY" / "SELL"
expirationstringGTD unix seconds; "0" for GTC/FOK
noncestringMust be "0"
feeRateBpsstring
signatureTypeu320 = EOA. 1/2 legacy wallet types are rejected
signaturestring64-byte ed25519 over the order hash, hex or base58
sha256( b"CTF_EXCHANGE_ORDER_V1"
‖ salt:u64LE ‖ maker:32B ‖ signer:32B ‖ taker:32B
‖ token_id_len:u64LE ‖ token_id:UTF8
‖ maker_amount:u64LE ‖ taker_amount:u64LE
‖ expiration:u64LE ‖ nonce:u64LE ‖ fee_rate_bps:u16LE
‖ side:u8 ‖ signature_type:u8 )
side: BUY=0, SELL=1 signature_type: EOA=0

The signature is not part of the hash. This digest is the orderID, the de-dup key, and the value verified on-chain.


{
"order": { /* Order */ },
"owner": "7xKX…", // accepted, ignored
"orderType": "GTC" // "GTC" | "FOK" | "GTD"
}
FieldTypeNotes
successbool
errorMsgstringEmpty on success
orderIDstringThe order hash; empty on failure
transactionsHashesstring[]On-chain signatures for executed fills
statusstringSee below
statusMeaning
liveRested in the book, no match
matchedMatched and executed
delayedScheduled on the pending service (game-start window)
unmatchedCould not match — e.g. a killed FOK

success: true with status: "live" is a normal, unfilled outcome.


All four return CancelOrdersResponse:

FieldTypeNotes
canceledstring[]Order hashes cancelled
not_canceledmap<string,string>Order hash → reason

Cancels are not atomic across a batch — read both fields.

{ "market": "0xdemo-condition", "asset_id": "100" }

Not user-facing. The Executor reports on-chain partial fills and cancels for any owner, so this route is authorized by a shared secret rather than SIWS:

X-Internal-Token: <CLOB_INTERNAL_TOKEN>

The comparison is constant-time and the route fails closed when no token is configured.

FieldType
orderIDstring
isFilledOrCanceledbool
remainingSizeu64

All optional.

FieldTypeNotes
ownerstringMust equal your authenticated address
maxu32Max items, default 100
marketstringCondition id / asset filter
sidestring"buy" / "sell"
start_ts / end_tsi64Unix-second bounds
min_valuestringMin normalized value (size × price)
fidelityu32History accuracy, seconds
FieldType
id, owner, taker, makerstring
market, asset_idstring
limitu32
before, afterstring

id, owner, market, asset_id.


FieldType
idstring
taker_orderstring
marketstring (condition id)
asset_idstring
sidestring
sizestring
fee_rate_bpsstring
pricestring
statusstring
match_time / last_updatestring
outcomestring
bucket_indexu32
ownerstring
maker_addressstring
transaction_hashstring
maker_ordersMakerOrderSummary[]

MakerOrderSummary: order_id, owner, maker_address, matched_amount, price, fee_rate_bps, asset_id, outcome.

One taker sweeping four price levels produces one trade with four maker legs — reconcile against maker_orders, not the trade count.

FieldType
idstring
statusstring
ownerstring
marketstring
asset_idstring
sidestring
original_sizestring
size_matchedstring
pricestring
associate_tradesstring[]
outcomestring
created_ati64
expirationstring
type"GTC" / "FOK" / "GTD"
FieldType
marketstring (condition id)
asset_idstring
bidsOrderSummary[] — { price, size }
asksOrderSummary[]
hashSHA-256 over the canonical JSON of the other fields

  • Amounts are decimal strings. Raw units are u64 with 1e6 scaling; normalized amounts are Decimal. Never floats on the wire.
  • success vs status. Insert can succeed without filling — status disambiguates.
  • Ownership. Cancels require the authenticated address to match the order owner, case-insensitively.
  • Book vs ledger. GET /v1/orders/{id} is book-only; a fully matched order won’t be found there. Use the open-order and trade routes for history.
VariableDefaultMeaning
CLOB_HTTP_ADDR127.0.0.1:8080HTTP listen address
CLOB_GRPC_ADDR127.0.0.1:50051gRPC listen address
CLOB_RPC_URLhttp://localhost:8899Solana JSON-RPC
CLOB_SIWS_AUDGoMarket APISIWS aud claim
CLOB_SIWS_ISS(empty)Expected issuer; empty = unchecked
CLOB_SIWS_MAX_AGE_SECONDS300Max token age
CLOB_INTERNAL_TOKEN(empty)Internal-route secret; empty = disabled
CLOB_MARKET_UPDATES_INTERVAL_MS10000Catalogue pull interval
CLOB_LEDGER_BACKENDgrpcgrpc or in_memory
CLOB_LEDGER_URLhttp://localhost:5000
CLOB_EXECUTION_BACKENDgrpcgrpc or in_memory
CLOB_EXECUTION_URLhttp://localhost:6000
CLOB_RISK_BACKENDon_chainon_chain or in_memory
CLOB_MARKETS_BACKENDapiapi or in_memory
CLOB_MARKETS_API_URLhttp://localhost:8081
CLOB_ENABLE_MINT_MERGE_MATCHING1Same-side matching
CLOB_ENABLE_SERVERS1Bind the network transports
LOG_LEVELinfoRUST_LOG overrides

On SIGINT the binary shuts down gracefully: listen threads are flagged, timer threads stop, all threads are joined.