What Somnia provides
This project exists because of two host primitives that don’t normally coexist: a chain that can run an LLM in consensus, and a fully on-chain order book to trade on. Here is exactly what the platform gives, and which parts are used.
Somnia Agents — on-chain inference
A smart contract can call out to a model and get an answer back that a committee of validators agreed on — the answer is only accepted when a majority threshold (two of three, by default) matches. That is the primitive the entire project rests on: without it, the “AI” half would have to run on a server and every trust guarantee would be social again.
| Agent | Cost / validator | Used here? |
|---|---|---|
LLM InferenceinferString, inferNumber, inferChat, inferToolsChat | 0.07 STT | Yes — inferString with a closed allowedValues set, which is what makes the answer safe to act on. |
| JSON API Request fetch and parse any public endpoint | 0.03 STT | Not in the current build. It would let an agent read an off-chain price feed as a second input. |
| LLM Parse Website scrape a page, extract structure | 0.10 STT | Not used — nothing here needs to read the open web. |
Requests are asynchronous: the contract calls createAdvancedRequest and the answer arrives later in a callback. We set a 60-second timeout rather than the platform’s 15-minute default, because 15 minutes is long enough to straddle an entire trading window.
Tool-calling is available, and deliberately not used yet
inferToolsChat lets the model return ABI-encoded calldata for on-chain tools rather than text — the adapter already defines the order-placement tool signature and a strict decoder for it. It is not on the live path. Letting a model produce calldata directly is a much larger surface than letting it pick one of three tokens, and the closed-vocabulary design is the safety property worth keeping.
DreamDEX Event Contracts — the venue
Binary markets on a fully on-chain central limit order book. Up and Down share a single book, so a Down price is always one minus the Up price, and prices are the market’s implied probability.
The full lifecycle is used, through the raw Solidity interface rather than an SDK:
| Call | What it does here |
|---|---|
getBookLevels | Reads the live book, both to build the prompt and to price the order. |
getOrderBookParameters | Tick, lot and minimum size — every order is snapped to this grid. |
marketExpiryNs | The only authority on expiry. The gate reads the pool, never a cached row. |
placeBinaryOrder | The order itself, IOC, priced and sized by the gate. |
markets(marketId) | Authoritative record — pool, collateral, operator and venue id. It is what makes permissionless market registration safe. |
redeem · payoutNumerators | Settlement. Voided markets pay both sides, so both are redeemed. |
Mint-a-pair solves the cold start
A Buy Up at p crossing a Buy Down at 1−p needs no seller and no inventory — the pool mints a fresh pair and gives one side to each buyer. Two agents that genuinely disagree can therefore fill each other on a completely empty book. Fees are zero across maker, taker and settlement, so published P&L is pure market outcome with no fee drag.
Somnia’s block rate shapes the client too
The RPC caps getLogs at 1000 blocks, and Somnia produces blocks fast enough that a contract a few hours old is already tens of thousands of blocks back. Reading its own history means many windows no matter how tightly the range is bounded.
So discovery bounds scans to the factory’s own deploy block — there is nothing to find before that — and then runs the remaining window reads concurrently rather than one at a time. Designing for Ethereum’s block rate here would produce a page that takes minutes to load.