Onchain order books for any market.
Somnia Markets is one fully onchain order-book engine for spot pairs, binary event contracts and perpetuals. Matching, escrow, settlement, market creation and resolution all run in public contracts; the SDK and APIs are conveniences over them, with no privileged access.
- Spot
- Live on mainnet
- Event contracts
- Live on mainnet
- Perpetuals
- Testnet · mainnet coming soon
- Liquidity Vaults
- Coming soon
- Quote and collateral
- USDso
- Protocol fee
- None · venue and builder fees may apply
Live spot pairs: WETH, WBTC, SOMI and USDC.e against USDso.
Venue front end (Branded app, your fee), TypeScript SDK (Books, trades, positions), Raw contracts (Any language, RPC and ABIs) reach One order-book engine: Price-time matching, Escrow on placement, Same-block settlement. It runs Spot (Live on mainnet), Binary events (Live on mainnet), Perpetuals (Testnet · mainnet coming soon), with Index price feed: Mark prices for stops and margin; Somnia Oracle: Resolves binary markets; GraphQL indexer: Books, fills and candles. Every step onchain · APIs add no privilege.
Who builds with it, and what they get.
One set of contracts serves every role. Each reaches it differently, and none needs a privileged API.
Venues and exchanges
Register as an operator, create a venue and list markets on the shared books. You set the fee and the front end; matching and settlement are already running.
Start with the Venues guideMarket makers
Quote with batch place, amend and cancel, and use order expiry as a dead man’s switch. On binary books, two buy orders form a full quote with no inventory.
Start with the market-making guideApps, brokers and wallets
Route user orders with your builder attribution. Each trader approves your builder per pool, and the pool caps the fee.
Start with builder fees in the SDKBots and developers
Stream books, trades, candles and positions with the SDK, or read and write the contracts directly from any language.
Start with the TypeScript SDK
From order to fill, in one state transition.
Placing an order escrows its worst-case value up front. The matching contract pairs orders by price and time, and balances move in the same transition as the match: a fill is complete and final, or it never happened.
Place order: Venue app, SDK or code. Escrow: Buys lock quote, sells lock base. Match: Price-time priority. Settle: Balances move with the match. Index and stream: Shared GraphQL indexer. One state transition: match and settle. No offchain matcher · No batch reconciliation · A fill is final or never happened.
Three market families. One engine.
Spot, binary event contracts and perpetuals share one order-book core, one settlement path and one indexer. Each family keeps its own rules.
Spot
Live on mainnetBase and quote books against USDso, for crypto and tokenized RWAs.
- Orders
- GTC, IOC, FOK and post-only
- Stops
- Stop-loss and take-profit, onchain registry
- Quoting
- Amend, batch place and batch cancel
- Live pairs
- WETH, WBTC, SOMI, USDC.e
Event contracts
Live on mainnetA yes or no question whose shares trade at prices that read as probabilities.
- Shares
- ERC-6909, backed 1:1 by collateral
- Payout
- 1 USDso per winning share, less venue settlement fee
- Void
- Refunds 0.5 USDso per side
- Resolution
- Somnia Oracle via Reactivity
Perpetuals
TestnetLinear, collateral-settled perps on crypto and RWAs, on the same engine. Mainnet is coming soon.
- Margin
- Cross-margin from one USDso pool
- Funding
- Settled onchain between longs and shorts
- Mark
- EMA price, published onchain
- Liquidation
- Staged waterfall to auto-deleveraging
What a trade costs, and who sets each part.
Somnia Markets charges no protocol fee. That does not make trading free: venue fees, builder fees, gas, spread and, on perps, funding and liquidation are separate costs.
| Cost | Who sets it | Where it applies |
|---|---|---|
| Protocol fee | Somnia Markets: none | Every market |
| Venue fee | The venue. On binary markets, maker, taker and settlement rates are frozen at market creation | Markets the venue operates |
| Builder fee | The routing front end, after the trader approves it for that pool, up to the pool’s cap | Orders that carry builder attribution |
| Network gas | The Somnia network; venues can sponsor it on core pairs | Every transaction |
| Funding and liquidation | Onchain perp rules | Perpetuals, on testnet |
| Spread | The order book | Every taker trade |
Who controls what, written into the contracts.
A venue configures its markets. A trader keeps control of funds and approvals. The protocol runs the parts no venue or API can bend.
- TraderSelf-custody
- Funds
- Escrowed by the pool contract, not held by a venue
- Builders
- Approved per pool, with a maximum fee
- Keys
- Operators and session keys can trade spot and perps without custody
- Orders
- Expiry and self-match choice on every order
- Venue operatorConfigurable
- Venue
- Registered under your operator address
- Market type
- Fixed when the venue is created
- Fees
- Rates and recipient; binary rates frozen per market
- Listing
- Open or gated market creation
- Users
- Open or allow-list, optional gas sponsorship
- ProtocolSame for every venue
- Matching
- Price-time, deterministic within the block
- Settlement
- Atomic with the match
- Resolution
- Binary markets resolve onchain, no operator in the loop
- Prices
- Each pool pushes its own mark price
- APIs
- Conveniences over public contracts, no privilege
Start building. Two ways in.
Both paths reach the same public contracts. Build and test on the Shannon testnet first, then point the same code at mainnet.
For apps and bots in a JS runtime
Realtime books, trades, candles and positions, plus a typed trader for orders, margin and outcome shares.
No SDK needed. Discover markets, place orders and build a live local order book straight from contract events.
- Needs
- An RPC node and the contract ABIs
- Pools
- SpotPool, BinaryPool and PerpPool
- Book
- Materialized from contract events
- Live view
- System page: contracts, owners, indexer health
Put your market on Somnia Markets.
Talk to the team about launching a venue, quoting the books or routing flow, or start in the docs today.