Contracts
The Somnia DEX uses a distinct contract for each trading pair. To discover available markets and their contract addresses, query the GET /v0/markets endpoint.
OrderBook API (SpotPool)
- Types — structs and enums used in function signatures and event payloads.
- Functions — place, cancel, reduce, and query orders; deposit and withdraw from the vault; manage builder approvals.
- Events — on-chain events emitted by the order book contract.
StopOrderRegistry API (SpotStopOrderRegistry)
Each SpotPool has a corresponding StopOrderRegistry for stop-loss, take-profit, and stop-buy orders. See Stop Orders for how they work.
- Types —
PendingOrderType,Operator,PendingOrder,PendingOrderWithTrigger - Functions —
createPendingOrder,cancelPendingOrder,claimSomi, and view functions - Events —
PendingOrderCreated,PendingOrderTriggered,PendingOrderCancelled,SomiRefundFailed
SpotRouter API
A multi-stage swap router that walks ordered SpotPool legs as taker orders in a single transaction. Powers the Simple Swap frontend. The router is a pure orchestrator — pools auto-pull / auto-deliver between the user's wallet and the router never custodies funds across legs.
- SpotRouter reference — functions (
swapExactIn/swapExactOut/quoteMarketExactIn/quoteExactIn/quoteExactOut), events, errors, caller prerequisites, and the quote → swap recipe.