Skip to main content
A non-custodial order is a standard limit order authorized by an EIP-712 signature. You build the typed Order, sign it with your EOA, and post it to Calibri, which validates the signature and places the order on the book. The resting order locks your locked_safe pool.
Orders are placed at POST /api/v2/atlas/account/orders so the signature can be validated and attached, and read back at GET /api/v2/pythia/orders. There is no unsigned placement path — every order on Calibri carries your signature.

1. Read the market’s CTF config

GET /api/v2/atlas/account/wallet/markets/:id Returns your funding config plus the market’s condition_id, yes_token_id, and no_token_id. Returns 404 if the market is not CTF-registered. The config gives you every value needed to build and sign the order: exchange_address, chain_id, domain_name, proxy_address (your Safe / the maker), owner_address (what owns the Safe), signature_type, session_keys_enabled, safe_status, and the token ids.
The YES/NO token ids are also published on the public market payload as yes_token_id / no_token_id, so a client that already holds a market can build an order without a per-market authenticated call.
Check safe_status before signing. deposit_required, deploying and setup_required mean the Safe is not funded, not created yet, or still owes its approvals, and an order placed then is rejected with 422 Member safe is not settlement-ready. Only ready can trade. Right after you relay setup, safe_status stays setup_required until setup is final: wait for ready. Right after a new trading key, a session-signed order can be refused with 409 session.pending until the key is final, and 409 wallet.state_pending means Calibri has not recorded your Safe’s current state yet — retry both.
domain_name is served by the API — it is the EIP-712 domain name of Calibri’s exchange. You must sign with the value the API returns, not a copied constant, or the signature will not recover.

2. The EIP-712 domain

3. The Order struct

EIP-712 field names are camelCase:
YES vs NO is carried only by tokenId. side is the buy/sell axis: 0 (BUY) for a direction: "buy" order, 1 (SELL) for a direction: "sell" order. A signature whose side does not match the order’s direction is rejected.

Signature types

Your signature type determines how you sign an order. Read it from signature_type on GET /api/v2/atlas/account/wallet and sign the way your type requires — an order signed the wrong way is rejected.
  • 2 — sign the order with your wallet key. Set maker to your Safe and signer to your wallet address.
  • 3 — sign the SafeMessage, not the order hash, using a signing key you added. Set both maker and signer to your Safe. In the browser your passkey does this for you. Your type follows from what owns your Safe: a wallet you hold the key for (2) or a passkey (3) — so it is fixed by how you set your wallet up. The names below are the exchange contract’s enum and mean the same as the numbers:
For POLY_1271 the exchange does no address derivation — it requires signer == maker, that maker has code, and that isValidSignatureNow(maker, hash, sig) passes. That is exactly what allows a contract to own the Safe. A passkey order sent as type 2 cannot work: that path ECDSA-recovers a key which does not exist.
For type 2 the signature is your EOA signing the typed data above. Type 3 has no EOA key by default — a passkey owns the Safe. Adding your own wallet as a signing key gives it one, and that is what makes type 3 scriptable: the type does not change, only the signature. See Your wallet options.

Type 3: three signature shapes

A POLY_1271 order carries one of three signature shapes, and the server tells them apart by length alone — never by a client-supplied flag: The third is the only one a server-side client can produce: a passkey signs only in a browser on a device that holds it, and a session key cannot be read out of the browser. Add your own wallet as a signing key and your code signs as an owner of the Safe. It signs the SafeMessage, not the order hash. Safe re-wraps the hash before checking it, so signing orderHash directly recovers to a different address and the Safe rejects it — reported as 422 Invalid signed_order signature, on a signature that verifies perfectly if you check it yourself. The full recipe, computable without a node, is under type 3 in Authentication. The grant id is read out of the envelope’s first word, so a client cannot name a live grant while signing with an expired key. A session-signed order is additionally checked against its grant’s expiry at intake; an expired grant is rejected with 422 Your trading key has expired or been revoked — approve with your passkey. A revoked grant gets the same answer, from the moment the revocation is relayed. See Trading without a prompt per order.

4. Amount and unit rules

CTF_UNIT_SCALE = 1_000_000. USDC and CTF outcome tokens are both 6-decimal — 1 contract = 1 outcome token = 1e6 base units. Which amount is the token side depends on the direction:
  • The token amount must equal round(volume * 1e6) exactly.
  • legPrice is the order’s own outcome price — a NO order signs the NO’s own price, not an inverted YES probability.
  • The implied price (USDC amount / token amount) must equal price within 1e-4.
  • price and volume must be within the market’s precision — prices are whole cents (0.27, not 0.275). A finer value is rejected (market.order.invalid_price_precision / market.order.invalid_volume_precision), never rounded.
Example — buy 100 YES contracts at 0.60: Example — sell 100 YES contracts at 0.65:

5. Sign and build the wire object

Sign the typed data with your EOA key (wallet.signTypedData(domain, { Order: [...] }, order)), then assemble the signed_order wire object (snake_case). Every big-integer field is a decimal string — including fee_rate_bps; side and signature_type are numbers:

6. Place the order

POST /api/v2/atlas/account/orders Places a non-custodial (signed) order. Calibri validates the signed_order, places it as a self-custody order (custody = "self"), and attaches the signature to the order record. Returns the order object, 201. Request body:
ioc (immediate-or-cancel) is for a market-style order: a limit at a price ceiling, signed with a short expiration. With ioc: true, whatever the book can’t fill when the order arrives is refunded instead of resting at the ceiling. It is recorded on the order, so a wallet’s market orders can be told apart from its limit orders (both are ord_type: "limit"). Ignored if post_only is set. If Calibri cannot record the order with its signature, the request fails with a 500 (Failed to record signed order; the order was cancelled) and the order is cancelled.

Selling a position

A direction: "sell" order offers outcome tokens you already hold, so it locks inventory, not cash. It must be backed by a sellable position: read sellable_volume from GET /api/v2/atlas/account/positions and sell no more than that. A sell larger than your sellable holding is rejected with 422 market.order.create_failed, or 422 market.order.tokens_settling when the shortfall is shares still settling on-chain. Selling is how you exit a position before resolution. Buying the opposite outcome does not: YES and NO are separate positions, each backed by its own stake, so a YES holder who buys NO locks more USDC and holds both until the market resolves, when each YES+NO pair redeems for 1.00. Calibri does not merge your YES and NO back into USDC before resolution; your Safe can do it itself by calling mergePositions on the ConditionalTokens contract. A sell’s proceeds are held as pending until the match settles on-chain, then they are in your Safe and spendable. If the match fails to settle, the sale is undone and the tokens come back — see If a match fails to settle.

client_order_id

Send your own id to make a placement safe to retry. It is echoed on the order and on its order WebSocket frames, and you can look an order up by it with GET /api/v2/pythia/orders?client_order_id=…. Reusing an id you sent in the last 7 days is rejected with 409 order.duplicate_client_order_id, so a retried request can never create a second order.

Several orders at once

POST /api/v2/atlas/account/orders/batch takes up to 20 orders, each the body POST /account/orders takes, each with its own signed_order:
Each order is validated and placed exactly as the single route places it, one after another. The batch is not atomic: one order failing does not stop the others. The response is 200 with one entry per order, in request order:
A body that is not an array of 1 to 20 orders is 422 and places nothing. The batch counts one order per element against the order rate limit — see Rate limits.

Replacing an order

POST /api/v2/atlas/account/orders/{id}/replace cancels one of your open orders and places a new one in its place. The body is the body of POST /account/orders, with a freshly signed signed_order, for the same market. A new client_order_id is needed if you send one; the old order’s id stays taken. The new order is validated in full first, so a replacement that would be refused leaves the old order resting untouched. The engine then cancels the old order and places the new one, in that order: no fill can land on the old order once the replace has cancelled it, but the placement can still be refused (see below). On success the response is 201 with the new order, as POST /account/orders returns it, plus replaced_order_id. The new order has its own id and is fresh for its full volume — whatever the old one had already filled stays on the old order. If the engine cancelled the old order but then refused the new one, the error body also carries replaced_order_id: the old order is gone and nothing replaced it.

Server-side validation

Calibri fully validates the signed order before anything is placed, rejecting with 422 unless:
  • it is a limit order with a valid side, a valid direction, and price ∈ (0, 1);
  • the market is CTF-registered (looked up by numeric id) and token_id matches the side’s token;
  • price and volume are within the market’s precision;
  • the signed side matches the direction (0 for buy, 1 for sell), taker == 0x0, fee_rate_bps == 0;
  • expiration is non-zero, unexpired, and within 365 days;
  • amounts match the volume and price (see the unit rules above);
  • the maker is a Safe registered to you and settlement-ready;
  • for type 2, signer equals your member EOA and the signature ECDSA-recovers to signer;
  • for type 3, signer == maker and the signature is one your Safe accepts — your passkey, a session key whose grant is live, or an owner’s signature over the SafeMessage. The Safe checks it again (EIP-1271) at settlement.

Expiry is enforced

The engine keeps each order’s expiration and never lets a signature lapse between a match and its on-chain settlement:
  • an order is never matched within 30 seconds of its expiration;
  • a resting order reaching that point is cancelled and refunded (its order update arrives as cancel);
  • an order that arrives with less than 30 seconds left is rejected with market.order.expired.
Sign resting limit orders with a long expiration (up to 365 days) and market-style orders with a short one — the app uses 120 seconds. A check that cannot be completed — Safe readiness unknown, for example — fails closed: the order is rejected rather than placed unverified. A request with no signed_order, or one without a signature, is rejected with 400 signed_order with signature is required for non-custodial orders. Common 422 errors: market_id must be a market id (a number or a numeric string) (often a slug sent as market_id), Market is not CTF-registered, signed_order side must be SELL for a sell order, Member safe is not settlement-ready, signed_order signature does not match the signer. Other errors include 409 order.duplicate_client_order_id. Two 422s are temporary and worth retrying: Unable to verify member safe readiness and Unable to verify signed_order signature mean Calibri could not complete the check; nothing was placed. A failure inside the matching engine returns 502.

If a match fails to settle

The engine matches off-chain; the operator then submits the match to the exchange contract. An order is only accepted from a ready Safe, but a Safe can stop being able to settle after its order is placed — USDC moved out, an approval revoked, the signing key revoked. The match then fails on-chain and is voided — rolled back as if it never happened:
  • Both sides get back what the match moved: each buyer’s stake, a seller’s tokens, or both sellers’ tokens on a merge. The taker fee is refunded.
  • A seller’s proceeds from the match, still pending, are withdrawn. Nothing is taken from a spendable balance.
  • When the failure is traced to one side’s Safe — USDC moved out, or an approval revoked:
    • If the other side was the maker (its order was resting), the order gets the voided volume back and goes back on the book at its price, behind the orders already resting there — if the market is still trading and the order is still open or filled. Otherwise its stake, or its tokens, come back to its balance or position.
    • If the other side was the taker, its stake — or its tokens, if it sold — comes back to its balance or position. Its order does not get the fill back: an order still open stays as it is, and an order that fill had completed reads cancel. Send the order again.
    • The resting orders of the side whose Safe could not settle are cancelled.
  • When it is not — for example a signature that stopped being valid because its key was revoked — no order gets the fill back or goes back on the book, and no other orders are cancelled.
Both members receive a contract frame with state: "voided", a balance frame and a position frame on the private WebSocket. An order put back on the book also sends an order frame with state: "wait", and each cancelled order its cancel frame.