{s}omniamarkets

Somnia Markets

Somnia Markets is a prediction-market protocol on Somnia. All markets live today are binary — a YES/NO question such as an asset above a strike at expiry — whose outcome shares trade on a fully on-chain central limit order book. Shares are ERC-6909 positions backed 1:1 by collateral: a complete set (1 YES + 1 NO) always mints from and merges back to exactly one collateral unit, the winning side redeems 1:1 at resolution, and resolution itself is driven on-chain by the Prophecy oracle through Somnia's reactivity — no operator in the loop. Each market carries an on-chain kind tag (marketType()); future kinds (multi-outcome, dual-book) extend the same protocol.

Everything is on-chain and permissionless: order matching, escrow, settlement, market creation (per-venue), and resolution. The APIs below are conveniences over the same public contracts — nothing they do is privileged.

Ways to integrate

The TypeScript SDK — @somnia-chain/markets-sdk. The fastest path for apps and bots in a JS runtime: realtime order books, trades, candles, and positions streamed with zero polling, plus a typed trader for placing orders and minting/redeeming shares. Start with The SDK, then The exchange API and Binary markets; Architecture explains how it works under the hood.

Raw smart contracts — no SDK. Any language, any runtime, nothing but an RPC node and the ABIs: discover markets, place orders, and materialize a live local order book straight from contract events. Raw Smart-Contract Integration is the end-to-end guide; Market Making covers what is venue-specific for quoting operations — book encoding, escrow semantics, event caveats, market lifecycle.

Going deeper

  • The System page is the live deployment view: every protocol contract with its address, owner, and implementation, plus indexer health.
  • The API reference in the sidebar is generated from the SDK source (TypeDoc).
  • These docs are also served machine-readable at /llms.txt and /llms-full.txt.