Skip to main content
All trading happens through a single instruction, place_order, parameterized by PlaceOrderParams.

PlaceOrderParams

Market order

Behavior:
  • Walks the book immediately, taking up to 4 fills per tx (compute-unit cap).
  • Any remainder is cancelled, not rested, limit orders are a separate thing.
  • Reverts SlippageExceeded if the average fill price exceeds the quote + max_slippage_bps.

Limit order

Behavior:
  • If it crosses (the limit price already matches resting orders on the other side), it takes up to 4 fills as a taker and rests the remainder.
  • Otherwise, it rests on the book at price, reserving baseAmount × price × initialMarginRatio / 10_000 of collateral.

Post-only

Behavior:
  • If placing the order would cross the book (immediately match as a taker), the tx reverts with OrderWouldCross.
  • Otherwise, rests on the book, guaranteed maker fill semantics.

Direction semantics

Direction::Long = bid = buy = entering a long or closing a short. Direction::Short = ask = sell = entering a short or closing a long. Kimia does not distinguish “entering” vs “closing” at the instruction level the direction simply flips your base_amount. If you’re long 1 SOL and place a short order of 2 SOL, you end up short 1 SOL. This is called flipping, and the realized PnL on the closed leg is banked automatically.

Cancel orders

Or in bulk:
Cancelling refunds the reserved margin back to free_collateral immediately.

Limits

If the book is full, new orders revert OrderbookFull. V2 expands this.