# Somnia Markets Documentation > Somnia Markets is a prediction-market CLOB on the Somnia network. Guides for the TypeScript SDK and for SDK-less integration straight against the smart contracts (order placement, materializing the order book from events, market making), plus the full TypeDoc API reference. --- # /docs # Somnia Markets Somnia Markets is a prediction-market protocol on [Somnia](https://somnia.network). 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](../packages/sdk/README.md), then [The exchange API](../packages/sdk/docs/EXCHANGE.md) and [Binary markets](../packages/sdk/docs/BINARY.md); [Architecture](../packages/sdk/docs/ARCHITECTURE.md) 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](./RawIntegration.md) is the end-to-end guide; [Market Making](./MarketMakingTips.md) covers what is venue-specific for quoting operations — book encoding, escrow semantics, event caveats, market lifecycle. ## Going deeper - The [System page](/system) 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`](/llms.txt) and [`/llms-full.txt`](/llms-full.txt). --- # /docs/sdk # @somnia-chain/markets-sdk The TypeScript SDK for building on **Somnia Markets** — read live market data and place trades on the on-chain order book from your own app. - **Realtime data, no wallet required.** Order books, trades, candles, and a user's positions and open orders stream into your UI the moment they happen on-chain — no polling loops to write or manage. - **Trading with a signer.** Place and cancel orders, mint and redeem outcome shares, and more, through a typed trader bound to your wallet. - **Works anywhere, with first-class React.** Use plain async functions in any environment, or drop in the hooks for components that update themselves. ## Install This package is published to **GitHub Packages** under the private `@somnia-chain` scope, so npm needs to know where the scope lives and a token to read it. 1. Create a GitHub [personal access token](https://github.com/settings/tokens) (classic) with the **`read:packages`** scope, and make sure your account has access to the `somnia-chain` organization. 2. Add this to your project's `.npmrc` (do **not** commit the token — use an env var or your user-level `~/.npmrc`): ```ini @somnia-chain:registry=https://npm.pkg.github.com //npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN} ``` 3. Install: ```sh export NODE_AUTH_TOKEN=ghp_your_token_here pnpm add @somnia-chain/markets-sdk viem ``` ## Create an exchange `new SomniaMarkets(config)` is the single entry point — the exchange owns everything: symbols, market data, watches, and writes. No global setup, no hidden singleton; each exchange is isolated. ```ts import { SomniaMarkets } from "@somnia-chain/markets-sdk"; import { testnet } from "@somnia-chain/deployments"; // the deployments hub — the single source of contract addresses import { somniaTestnet } from "viem/chains"; // or your own defineChain() const exchange = new SomniaMarkets({ indexerUrl: "/v1/graphql", chain: somniaTestnet, wsRpcUrl: "wss://api.infra.testnet.somnia.network/ws", addresses: testnet.addresses, // the hub map feeds in as-is — no hand-mapping privateKey, // optional — needed for createOrder & friends }); await exchange.loadMarkets(); const book = await exchange.watchOrderBook("BTC-95000-31DEC26/USDC#YES"); // live, zero RTT const order = await exchange.createOrder("BTC-95000-31DEC26/USDC#YES", "limit", "buy", 10, 0.62); ``` The raw engine tier — bigint-exact, address-keyed — is reached *through* the exchange (`exchange.client`, `exchange.trader`), never constructed separately. The WebSocket opens lazily on first chain I/O, so an indexer-only exchange (e.g. server-side GraphQL reads) never opens one. Nothing is shared between instances: a bot per chain, per-request servers, parallel tests — just construct another. Two exchanges never share watch state or sockets. The guides, in reading order: - **[The exchange API](./docs/EXCHANGE.md)** — the `SomniaMarkets` class, the SDK's primary surface: symbols (`SOMI/USDC`, `BTC-95000-31DEC26/USDC#YES`), `fetch*`/`watch*`/`createOrder`, human-unit structs. Exchange-bot muscle memory (ccxt included) transfers directly — start here. - **[Binary markets](./docs/BINARY.md)** — the binary (YES/NO) CLOB: probability prices, the four sides, mint/burn/redeem, and a maker loop. - **[Spot markets](./docs/SPOT.md)** — base/quote books: ticks and lots, native-base escrow, market orders, and stop orders. - **[Perps](./docs/PERPS.md)** — live on testnet: cross-margin via the MarginBank, funding, positions, and how perps slot into the `marketType` union. - **[Price feeds](./docs/PRICES.md)** — realtime BTC/ETH index prices from the on-chain EMA oracle: `watchPrice`/`getLivePrice`, one-shot history + candles, and the React hooks. - **[The engine (advanced)](./docs/ENGINE.md)** — the raw tier behind the exchange (`exchange.client` / `exchange.trader`): bigint-exact reads, ref-counted watches, React hook wiring, raw writes. - **[Architecture guide](./docs/ARCHITECTURE.md)** — diagrams of the whole machine: the watch seam, event routing, the local order book, the reconnect lifecycle, and the one-round-trip write path. ### Two ways to read | How | What it is | Returns | |---|---|---| | `client.list*` / `client.get*` | **One-shot** read (indexer GraphQL or on-chain) | a `Promise` | | `client.getLive*` + `client.subscribeLive` | **Synchronous** read off the live store (within a `watchMarket` scope) | a value, now | | `use*` hooks (`/react`) | React bindings over the live store (auto-watching) | re-render on change | So `client.getFills` fetches once; `client.getLiveFills` reads the live tape; `useLiveFills` re-renders a component as it updates. In React, provide the client once with `` (from `@somnia-chain/markets-sdk/react`) and the hooks read it from context. Markets come from one discriminated union — `Market = SpotMarket | PerpMarket | BinaryMarket`, keyed on `marketType` — via `client.listMarkets` / `client.getMarket`. Binary-only callers can use `client.listBinaryMarkets` / `client.getBinaryMarket`, the same query pre-narrowed to `BinaryMarket`. (Note: *binary*, not *clob* — a spot market is an order book too, so "CLOB" was never the right label for the binary surface.) Money crosses the API as raw integers (bigint on writes, decimal strings from the indexer) scaled by token decimals. Convert at the edges with `fromHuman` (input) and `toHuman` / `toHumanString` (display); for binary prices, `probabilityToPrice` / `priceToProbability` map a YES price ↔ a 0–1 probability. ## What's included - **Entry point** — `new SomniaMarkets(config)` → the exchange (symbols, `fetch*`/`watch*`/`createOrder`, human-unit structs). Its engine tier — `exchange.client` (`SomniaMarketsClient`, bigint-exact reads + watches) and `exchange.trader` (raw writes) — is reached through it; `ClientConfig` - **React** — `SomniaMarketsProvider`, `useSomniaMarketsClient`, and the hooks `useWatchMarket`, `useWatchUser`, `useLiveStatus`, `useIsTailing`, `useLiveFills`, `useLiveUserFills`, `useLiveMarketByPool`, `useLiveMarketByAddress`, `useLiveUserOrders`, `useLiveBinaryOrderBook`, `useLiveSpotOrderBook` — the pool-keyed data hooks **watch automatically** while mounted - **Client reads** — `client.listMarkets`/`getMarket` (the `Market` union), `listBinaryMarkets`/`getBinaryMarket`, `getCandles`, `getBinaryOrderBook`, `getOpenOrders`, `getPortfolio`, `getSyncStatus`, `getMarketOnchain`, `getSystemInfo`, … (indexer reads **throw** on failure — an empty result always means "no rows", never "request failed") - **Live watches (no React)** — `client.watchMarket(pool)` / `watchMarkets({ discover })` / `watchUser(account)` → ref-counted handles; `getWatchStatus`, `subscribeLive`, `getLiveStatus`, `getLiveMarkets`, `getLiveMarketByPool`/`…ByAddress`, `getLiveFills`, `getLiveUserFills`, `getLiveUserOrders`, and the locally materialized resting books `getLiveBinaryOrderBook` (binary, 4-sided) / `getLiveSpotOrderBook` — synchronous, zero round-trips, scoped to what you watch. Every market kind streams; a discovery watch picks up new markets from the creation events (the MarketCreator's rolling series AND direct `BinaryMarketsModule.createMarket` markets); binary status/resolution stays current from chain events. - **Trading** — `client.createTrader(...)` → `placeOrder`, `cancelOrder`, `approveBuilder` (opt a routing/builder frontend in for per-order builder fees), `placeSpotOrder`, `placeSpotStopOrder`, `mintSet`, `burnSet`, `redeem`, `faucet`, `resolve`, `voidMarket`. Each write **awaits its receipt** and resolves to `{ hash, receipt }` (`placeOrder` adds `orderId` + `fills`). With a `privateKey`/local `account` the SDK signs locally with **fixed fees** and a locally-tracked nonce, and sends via Somnia's `realtime_sendRawTransaction` — send + confirm in **one round-trip**, zero fee/nonce/gas estimation RPCs. In the browser, pass a `walletClient` (confirm rides the newHeads subscription). - **Types & helpers** — `Market`/`SpotMarket`/`BinaryMarket` (+ `isSpotMarket`/ `isBinaryMarket`), `LiveFill`, `LiveOrder`, `BinarySide`, `TailStatus`, `kindOf`, `fillKind`, `fromHuman`/`toHuman`, `DECIMALS`, … Every method, hook, and type is listed in the **API reference**. ## How the live feed works You get instant updates without running your own indexer — scoped to exactly the markets you watch. Opening a watch loads a consistent snapshot of that scope (the one and only indexer touch), then keeps it current by streaming its on-chain events over a WebSocket — so trades, orders, prices, and the resting order book itself update the moment they're final on-chain. There is no polling anywhere: the WebSocket is the only realtime transport, and if it drops the watches heal themselves by reconnecting with backoff and backfilling the missed blocks straight from chain. --- # /docs/exchange # The exchange API The `SomniaMarkets` class is the SDK's primary surface: markets keyed by symbols, `fetch*`/`watch*`/`createOrder` verbs, human-unit structs — the idioms every exchange bot already speaks (if you've driven a venue through ccxt, nothing here will surprise you, down to the field names). Under the hood it runs on the native engine (scoped watches, local books, one-round-trip writes), so the `watch*` channels are zero-round-trip and `createOrder` confirms in a single round-trip. ```ts import { SomniaMarkets } from "@somnia-chain/markets-sdk"; const exchange = new SomniaMarkets({ indexerUrl, chain, wsRpcUrl, privateKey }); // one per chain await exchange.loadMarkets(); const symbol = "BTC-95000-31DEC26/USDC#YES"; const book = await exchange.watchOrderBook(symbol, 10); // live, zero RTT const order = await exchange.createOrder(symbol, "limit", "buy", 10, 0.62); // … later: await exchange.cancelOrder(order.id, symbol); ``` The raw engine stays available at `exchange.client` — bigint-exact, address-keyed — for anything the exchange verbs don't cover; see [the engine guide](./ENGINE.md). ## Symbols A **symbol names a market**; a **tradable symbol** names something you place orders on. For spot they coincide; for outcome markets each outcome is its own tradable: | Kind | Market symbol | Tradables | |---|---|---| | Spot | `SOMI/USDC` | `SOMI/USDC` | | Binary | `BTC-95000-31DEC26/USDC` | `…#YES`, `…#NO` | | Perp | `BTC/USDSO:USDSO` | `BTC/USDSO:USDSO` | | Categorical *(soon)* | `US-ELECTION-28/USDC` | `…#TRUMP`, `…#NEWSOM`, … | Binary symbols are synthesized as `ASSET-STRIKE-DDMONYY/QUOTE` (quote = the collateral's ERC-20 symbol), with an `-HHMM` expiry component for intraday series markets (`ETH-171780-03JUL26-0930/TUSDC`); any residual collision gets a deterministic 4-hex market-id tiebreaker on the base side of the slash. Everything before `#` follows standard exchange symbol conventions; `#OUTCOME` is our extension (binary markets need one). **Any raw ref works wherever a symbol does** — a pool address, market id, or BinaryMarket address resolves to the same tradable (outcome markets default to `#YES`). Numbers are **human units in the tradable's own terms**: a `#NO` price of 0.38 *is* the NO probability — the YES-terms complement, raw integers, and escrow math are all internal. Raw payloads ride on every struct's `info`. ## Verbs | Method | Backed by | Notes | |---|---|---| | `loadMarkets()` / `fetchMarkets()` | indexer (+ one-time `symbol()` reads) | builds the symbol registry | | `fetchOrderBook(symbol, limit?)` | chain | head-fresh one-shot | | `fetchTrades(symbol, since?, limit?)` | indexer | public tape | | `fetchOHLCV(symbol, "5m", since?, limit?)` | indexer | `1m 5m 15m 1h 4h 1d` | | `fetchOpenOrders(symbol?)` · `fetchMyTrades(symbol?)` | indexer | authenticated; lags chain | | `fetchBalance()` | chain | wallet balances by currency code (incl. binary YES/NO ERC-6909 holdings, keyed by tradable symbol) | | `fetchStatus()` | local | watch/socket health | | `watchOrderBook(symbol, limit?)` | **local store** | zero RTT, current to last block | | `watchTrades(symbol)` · `watchOrders(symbol)` · `watchMyTrades(symbol)` | **local store** | streaming | | `createOrder(symbol, type, side, amount, price?, params?)` | chain write | 1-RTT confirm, fills decoded | | `cancelOrder(id, symbol)` | chain write | | | `mintSet` / `burnSet` / `redeem` `(symbol, amount)` | chain write | outcome markets only | | `fetchFundingRate(symbol)` | chain | perps: mark/index + funding rate | | `fetchPositions(symbols?)` | chain | perps: open MarginBank positions | | `depositMargin` / `withdrawMargin` `(symbol, amount)` | chain write | perps: cross-margin collateral | | `watchPrice(asset)` · `fetchPrice(asset)` | price feed | index price (EMA oracle) — see [Price feeds](./PRICES.md) | | `fetchPriceOHLCV(asset, "1m")` | price feed | index candles: `1m`/`1h`/`1d` | | `market(ref)` | local | resolve any handle to its tradable | | `close()` | local | release all watches | Still reserved: `watchPositions`, `setLeverage` (the raw `trader.setPerpLeverage` exists for the latter). ### The `watch*` idiom Each `await` resolves when the channel next changes; the first call resolves immediately after the (ref-counted) market watch hydrates: ```ts while (running) { const book = await exchange.watchOrderBook(symbol, 5); // resolves per change requote(book.bids[0], book.asks[0]); } ``` **"Did my resting order fill?"** — watch your orders and look for the status flip: ```ts const orders = await exchange.watchOrders(symbol); // resolves per change const mine = orders.find((o) => o.id === orderId); if (mine?.status === "closed") … // filled ``` ### `createOrder` params - `type: "limit" | "market"` — market orders compute a crossing limit from the best opposite level ± `params.slippage` (default 1%) and send IOC; they throw if the opposite side is empty. - `params.timeInForce: "GTC" | "IOC" | "FOK" | "PO"` (or `postOnly: true`) — maps to the on-chain order types. - `params.builder` / `params.builderFeeBpsTimes1k` (binary only) — attribute the order to a routing/builder frontend and pay it a per-order fee (pool bps×1000 unit). Requires a prior one-time `exchange.trader.approveBuilder({ pool, builder, maxFeeBpsTimes1k })` opt-in on the pool, else a non-zero fee reverts. Ignored on spot/perp. - The returned order: `status: "open"` (rested), `"closed"` (fully filled in the same round-trip — `filled`/`remaining` say how much), or `"canceled"` (IOC remainder). `info` carries the receipt + raw fills. ## Structs One set of shapes throughout: markets `{ id, symbol, type, base, quote, active, precision, limits, outcomes?, info }`; books as `[price, amount]` pairs, best first; orders `{ id, symbol, type, side, price, amount, filled, remaining, status, timestamp, info }`; trades `{ id, symbol, price, amount, cost, side?, timestamp, info }`; balances `{ [code]: { free, used, total } }` (escrowed funds live in the pools, so wallet `free === total`); OHLCV rows `[ms, open, high, low, close, baseVolume]`. ## How each market kind maps - **Spot** — symbol is the tradable; `side` is base-buy/base-sell; done. - **Binary** — two tradables per market. The engine keeps one YES-terms book; the resolver presents each outcome's own view (prices, sides, candles all outcome-relative). `mintSet`/`burnSet`/`redeem` operate at market level. - **Perps** — `type: "swap"`, settle = quote (linear, collateral-settled); `createOrder` unchanged (margin locks from your MarginBank balance — `depositMargin` first); `fetchPositions`/`fetchFundingRate` read the MarginBank/pool live. - **Categorical / multi-outcome** *(teed up)* — N tradables on one pool (outcome index = the order's `userData`, exactly as binary uses 0/1 today); same verbs, and cross-book complete-set fills will surface in `watchMyTrades` with a shared match id in `info`. The design intent: **the verbs never change again** — every future market kind is new data (a `type`, an `outcomes[]` list), not new API. --- # /docs/binary # Binary markets A binary market is an order book over a YES/NO question ("Will BTC be above $95k at expiry?"). Each market deploys a `BinaryMarket` contract (lifecycle, resolution) and a `BinaryPool` (the CLOB + escrow) with a YES and a NO outcome token backed 1:1 by collateral. This guide covers reading and trading them; the shared client mechanics (watches, read tiers, signers) are in [the engine guide](./ENGINE.md). ## The mental model - **Prices are YES probabilities.** Every price in the API is the YES price in raw collateral units per whole outcome token — `620000` with 6-decimal collateral means 0.62, i.e. a 62% implied probability. Convert with `probabilityToPrice` / `priceToProbability`, and `fromHuman` / `toHuman` at the UI edges. The NO side is always the complement: a NO at 0.38 *is* a YES at 0.62 — the pool keeps ONE book in YES terms. - **Four sides, one book.** `BinarySide` is `BUY_YES | SELL_YES | BUY_NO | SELL_NO`. Buys escrow collateral; sells escrow the outcome token you're selling. Opposite-side orders can match by *minting* a fresh YES+NO pair from collateral (two buyers) or *burning* one back to collateral (two sellers) — the `BinaryFillKind` on a fill tells you which. - **Lifecycle.** `Listed → Trading → Locked → Settling → Resolved | Voided` (`BinaryMarketStatus`). Trading is only possible in `Trading`; after resolution the winning token redeems 1:1 for collateral, net of the venue's one-time settlement fee if it configured one (voided markets refund both sides at 0.5, never fee'd). - **Markets roll themselves.** Each cadence (15m / 1h / 4h / 24h) is a *series* that a `MarketCreator` contract advances autonomously — at every wall-clock boundary it clones the next `BinaryMarket` + `BinaryPool` and schedules the oracle question. Series markets are **reference-mode**: there is no fixed strike (the event's `strike` is always 0) — a market resolves YES iff its own oracle answer is at/above the previous boundary's *reference* answer. Markets can also be created directly via `BinaryMarketsModule.createMarket` under an operator's venue (these can be bucket-mode, with a real strike). Discovery is event-driven either way: an all-markets watch with `discover` picks each new market up from the creation events (see below). You don't need to create markets — you watch, trade, and redeem them. ## The series, and how a market is born `MarketCreator` runs the whole protocol off **one** Somnia reactivity `Schedule` subscription (the precompile at `0x0100`). When it fires, a single callback drains that boundary's whole batch of due series in a **gas-bounded loop** — rolling series until the gas envelope runs low — then re-arms the `Schedule` sub for the next-earliest pending boundary. A batch too large for one callback (the 00:00-UTC collision, where every cadence lands at once) saves a resume index and arms a sub for the **next block** to finish the spill. Exactly one subscription is ever live. (Historical note: an earlier one-series-per-hop `RollNext` reentrancy chain was tried and removed — on live Somnia the self-emitted event wasn't re-queued after a heavy roll, so it stalled after one hop. The gas-bounded loop with next-block spill replaced it.) Each roll emits, from the `MarketCreator`: ``` MarketCreated( bytes32 marketId, address market, address pool, uint256 yesId, uint256 noId, address collateral, string asset, uint256 strike, // always 0 — series markets are reference-mode (no fixed strike) uint64 tradingStart, uint64 expiry, uint256 oracleQuestionId, string question, uint64 intervalSec // series cadence: 900 / 3600 / 14400 / 86400 ) ``` Every market — series-rolled or not — ALSO fires the `BinaryMarketsModule`'s own 19-field `MarketCreated`, the only creation event carrying the `(operatorId, venueId)` origin attribution. A discovery watch (`watchMarkets({ discover: true })`) listens to both, so module-created markets that never pass through a `MarketCreator` join the watch live too. - **Read cadence from `intervalSec`, not the trading window.** A series' first market is a *bootstrap partial* (trigger time → the next aligned boundary), so its `expiry − tradingStart` is shorter than the cadence. `intervalSec` is the true series period. On the SDK's `BinaryMarket` type it surfaces as `intervalSec?: string | null` (the series cadence, preferred over `expiry − tradingStart`; `null` when a market predates the field). **Resolution is a separate loop.** When a market expires, the `ProphecyOracle` posts an `AnswerPosted(uint256 questionId, uint8 outcomeIdx, string outcomeLabel, int256 numericValue, bool voided, VoidReason reason, uint256[] receiptIds)`; the `ProphecyOracleAdapter`'s event subscription catches it and routes to `BinaryMarketsModule`, which resolves the market (or voids it). The SDK sees this as a `Resolved` / `Voided` lifecycle event on the `BinaryMarket` — gate redemption on that, per the rule below. ## Reading Watch the market, then read the live store — synchronous, zero round-trips, current to the last block: ```ts const watch = await client.watchMarket(market.poolAddress); const book = client.getLiveBinaryOrderBook(market.poolAddress, { depth: 11 }); // { yesBids, yesAsks, noBids, noAsks } — NO sides derived as 1 − yesPrice const tape = client.getLiveFills(market.poolAddress, { limit: 40 }); const live = client.getLiveMarketByPool(market.poolAddress); // status, lastPrice, volumes ``` In React the hooks watch automatically: `useLiveBinaryOrderBook(pool)`, `useLiveFills(pool)`, `useLiveMarketByPool(pool)`, `useLiveUserOrders(pool, account)`. Discovery and history come from the indexer tier: `listLiveBinaryMarkets()` / `listPastBinaryMarkets({ limit, offset })` for the market lists, `getCandles(pool, interval)` for charts, `getPortfolio(account)` for a wallet's positions + orders + trades in one round-trip. `listLiveBinaryMarkets()` with no argument returns every live market; pass a filter to narrow (all fields optional, applied server-side): ```ts await client.listLiveBinaryMarkets(); // all live markets await client.listLiveBinaryMarkets({ operatorId: 1 }); // one operator's live board await client.listLiveBinaryMarkets({ venueId: "0x5bc0…", asset: "BTC", intervalSec: 900 }); await client.listLiveBinaryMarkets({ status: "Trading" }); // active only ``` (`operatorId` is the uint32 operator id; `venueId` is the venue's opaque bytes32 hex id — enumerate the pairs in play with `listBinaryVenueIds()`.) For the underlying-asset universe and board size, use `listBinaryAssets()` (the distinct assets with markets, e.g. `["BTC","ETH"]`) and `countBinaryMarkets({ operatorId?, venueId?, asset?, status? })` (the total behind a filtered board, for pagination headers). Each row carries `marketAddress`, `poolAddress`, `operatorId`, and `venueId`, so a multi-venue UI can group the live board by origin without any contract-level call — market discovery is the indexer's job, not the MarketCreator's. One correctness rule: **gate writes on live or on-chain status, never indexer status** — `getLiveMarketByPool(...).status` (chain events) or `getMarketOnchain(marketAddress)` are authoritative; the indexed status lags. ### History + attribution (indexer) Beyond the live board and portfolio, the indexer serves the fee, resolution, router, and vault-credit history the live tail doesn't materialize — all one-shot reads: ```ts // How a market resolves: lifecycle events + the oracle reference link + the // posted numeric oracle answer (joined by oracleQuestionId), in one round-trip. const { events, reference, oracleAnswer } = await client.getMarketResolution(marketId); // Router-level collateral flow for a wallet (redeem / mint / merge complete set), // attributed to the TRUE end user even through the native/Permit2 periphery. const actions = await client.getRouterActions(account, { market, limit: 50 }); // The per-fill fee streams behind getMarketFees' running total (all filter by // `payer` — the order owner who funded the fee — plus recipient/market/pool). const protoFees = await client.listProtocolFees({ market, payer }); const bldFees = await client.listBuilderFees({ builder }); const settleFees = await client.listSettlementFees({ market }); // Builder-approval directory (the indexed complement to the on-chain point read // getBuilderApproval) — every user→builder cap, filterable by user or builder. const approvals = await client.listBuilderApprovals({ user }); ``` **Vault credits.** A payout that can't be delivered to the wallet is credited to the owner's `ERC20Vault` balance instead. That history is append-only — `client.getVaultPayoutFallbacks(owner, { token })` lists the credit log — but the vault's own credit/debit is silent (no event), so the **live claimable balance is a chain read**: `client.getVaultBalance(vault, owner, token)` (`ERC20Vault.getWithdrawableBalance`). Withdraw with `trader.withdrawVault({ vault, token, amount })`. ## Trading ```ts const trader = client.createTrader({ privateKey }); // Node — or { walletClient } in the browser // Rest a limit order: buy 10 YES at 0.62. const { orderId, fills, receipt } = await trader.placeOrder({ pool: market.poolAddress, side: "BUY_YES", price: probabilityToPrice(0.62), // raw collateral units per whole token quantity: fromHuman(10), // raw outcome-token units }); if (fills.length) console.log("crossed immediately:", fills); else console.log("resting as order", orderId); await trader.cancelOrder({ pool: market.poolAddress, orderId }); ``` Every write **awaits its receipt** — there is no bare hash to babysit, and `placeOrder` resolves with the decoded `orderId` + `fills` from the same round-trip. The escrow token (collateral for buys, YES/NO for sells) is approved automatically on first use; pass `autoApprove: false` to manage approvals yourself. - **Market orders** are `orderType: ORDER_TYPE.MARKET` (an IOC) placed at a crossing price — cross the best opposite level ± slippage so it sweeps and the remainder cancels. `ORDER_TYPE` also has `FILL_OR_KILL` and `POST_ONLY`. - **Sides and prices:** all four `BinarySide`s take the YES-terms price. A `BUY_NO` at YES-price 0.62 escrows `quantity × (1 − 0.62)` collateral. - Token wiring resolves from the pool contract automatically (cached); pass `outcomeToken`/`yesId`/`noId`/`collateral` explicitly to skip even that one-time read. ### Builder / routing fees (optional) A frontend that routes orders can attach itself to each order and charge a per-order fee — but only after the trader has opted it in on that pool: ```ts await trader.approveBuilder({ pool, builder, maxFeeBpsTimes1k: 5_000n }); // allow up to 5 bps; 0 revokes await trader.placeOrder({ pool, side: "BUY_YES", price, quantity, builder, // the routing/builder frontend builderFeeBpsTimes1k: 5_000n, // per-order fee, pool bps×1000 unit }); ``` A non-zero `builderFeeBpsTimes1k` without a prior approval reverts. The enforced ceiling is the trader's approval clamped by the pool's protocol-wide cap — read it with `trader.getEffectiveBuilderApproval(pool, user, builder)` (the pool-wide cap alone is `getMaxBuilderFeeBpsTimes1k(pool)`). On the exchange surface the same rides `createOrder`'s `params.builder` / `params.builderFeeBpsTimes1k` (binary markets only). ### Complete sets and settlement ```ts await trader.mintSet({ pool, amount }); // collateral → equal YES + NO await trader.burnSet({ pool, amount }); // YES + NO → collateral back await trader.redeem({ market: marketAddress, amount }); // winning token → collateral (post-resolution) ``` `mintSet`/`burnSet` are how you take (or unwind) a both-sides position without touching the book; `redeem` pays out after resolution (it looks up the winning outcome on-chain if you don't pass it). If the venue configured a settlement fee, the pool skims it ONCE from the whole winning backing at the first winning redeem (`SettlementFeeCharged`) and every winner redeems for `1 − fee` — voided markets refund both sides at 0.5 with no fee. Demo-stack extras: `faucet()` mints the test collateral; `resolve`/`voidMarket` drive the FakeOracle. ### A maker loop, end to end ```ts const watch = await client.watchMarket(pool); const trader = client.createTrader({ privateKey }); client.subscribeLive(async () => { const book = client.getLiveBinaryOrderBook(pool, { depth: 1 }); // zero RTT const mine = client.getLiveUserOrders(pool, me, { limit: 50 }) .filter((o) => o.status === "Open"); // zero RTT // decide → place/cancel; each write confirms in one round-trip (~500ms) }); ``` The live store is the only state a quoting loop needs: the book, your working orders, and fills all update the moment the chain emits them. --- # /docs/spot-markets # Spot markets A spot market is a plain base/quote order book on a `SpotPool` (e.g. SOMI/USDC) — same OrderBook core as the binary pools, so the live machinery is identical; only the semantics differ. This guide covers reading and trading spot; the shared client mechanics (watches, read tiers, signers) are in [the engine guide](./ENGINE.md). ## The mental model - **Prices are quote-per-base.** Raw quote units per whole base token, scaled by the market's own `quoteDecimals`/`baseDecimals` (spot markets are NOT assumed 6dp — read the decimals off the `SpotMarket` row). - **Two sides.** `isBid: true` buys base (escrows quote); `false` sells base (escrows base — or sends native SOMI as `msg.value` when `baseIsNative`). - **Book constraints.** Orders must respect the pool's `tickSize`, `lotSize`, and `minQuantity` (all on the `SpotMarket` row, kept live by the watch). - **Mark price.** Pools publish a smoothed `markPrice` (streamed live via `MarkPriceUpdated`) — it's what stop orders trigger on, distinct from `lastPrice` (last fill). ## Reading Discover markets first (indexer tier) — `listSpotMarkets` returns the board and `getSpotMarket` resolves one by id; both yield the `SpotMarket` rows the live reads key off: ```ts const markets = await client.listSpotMarkets({ limit: 50 }); // SpotMarket[]; filterable (base/quote/…) const spot = await client.getSpotMarket(id); // SpotMarket | null ``` ```ts const watch = await client.watchMarket(spot.poolAddress); const book = client.getLiveSpotOrderBook(spot.poolAddress, { depth: 11 }); // { bids, asks }, best first const tape = client.getLiveFills(spot.poolAddress, { limit: 40 }); const live = client.getLiveMarketByPool(spot.poolAddress); // markPrice, tick/lot, stats ``` React: `useLiveSpotOrderBook(pool)`, `useLiveFills(pool)`, `useLiveMarketByPool(pool)` — all auto-watch while mounted. History and wallet views come from the indexer tier: `getCandles(pool, interval)`, `getSpotPortfolio(account)` (open orders + pending stops + trades), and `getSpotStopOrders(account, { pool })`. Holdings are plain balances — read them on-chain with `getErc20Balance` / `getNativeBalance`, not from the indexer. ## Trading ```ts const trader = client.createTrader({ privateKey }); // Rest a limit bid: buy 5 base at 1.25 quote. const { orderId, fills } = await trader.placeSpotOrder({ pool: spot.poolAddress, isBid: true, price: parseUnits("1.25", spot.quoteDecimals), quantity: parseUnits("5", spot.baseDecimals), baseDecimals: spot.baseDecimals, quoteToken: spot.quoteToken, baseToken: spot.baseToken, baseIsNative: spot.baseIsNative, }); await trader.cancelOrder({ pool: spot.poolAddress, orderId }); // same core as binary ``` Escrow is approved automatically (quote on buys, base on non-native sells; native-base sells pay via `msg.value` instead). A **market order** is `orderType: ORDER_TYPE.MARKET` with a crossing price — take the live book's best opposite level ± slippage, tick-aligned, so it sweeps and the remainder cancels: ```ts const best = client.getLiveSpotOrderBook(pool, { depth: 1 }); // zero RTT, last-block fresh const crossing = (best.asks[0].price * 10100n) / 10000n; // +1% slippage bound ``` ### Stop orders Spot pools with a `stopRegistry` support stop-loss / take-profit orders that rest OFF the book and fire when the **mark price** crosses the trigger: ```ts await trader.placeSpotStopOrder({ registry: spot.stopRegistry, pool: spot.poolAddress, isBid: false, // sell when the market drops… quantity: parseUnits("5", spot.baseDecimals), triggerPrice: parseUnits("1.10", spot.quoteDecimals), triggerOperator: 1, // 1 = LTE (mark ≤ trigger), 0 = GTE stopOrderType: 1, // 1 = MARKET at trigger, 0 = LIMIT (needs limitPrice) quoteToken: spot.quoteToken, baseToken: spot.baseToken, baseIsNative: spot.baseIsNative, }); await trader.cancelStopOrder({ registry: spot.stopRegistry, orderId }); ``` Under the hood the first stop order per account performs a one-time operator approval (so the registry may place the triggered order for you), funds the trigger gas with a small SOMI payment (`msg.value`, refunded on cancel), and ensures the pool can pull the escrow at trigger time — including pre-loading the pool vault for native-base sells. The SDK handles all of it; list pending stops with `getSpotStopOrders(account, { pool })` and stream their market context via the watch. --- # /docs/perps # Perpetuals Perps are live on testnet: `BTC/USDSO:USDSO` and `ETH/USDSO:USDSO`, backed by PerpPool CLOBs riding the same shared OrderBook core as spot and binary. ## The shape `Market` is a three-way discriminated union — `SpotMarket | PerpMarket | BinaryMarket`, keyed on `marketType` (guards: `isSpotMarket` / `isPerpMarket` / `isBinaryMarket`). A `PerpMarket` is a plain base/quote book plus perp state: `marginBank`, `initialMarginBps`, `fundingRate`, `cumulativeFundingPerUnit`, `indexPrice`, `longOpenInterest`, `shortOpenInterest`. - **Watches and live reads are unchanged.** Perp pools emit the same order events, so `watchMarket(pool)`, `getLiveSpotOrderBook`-style depth, `getLiveFills`, `getLiveUserOrders`, and the React hooks just work. Funding (`FundingUpdated`) and open interest (`OpenInterestUpdated`) stream into the perp market row live. - **Margin, not escrow.** Collateral (USDso) lives cross-margin in the MarginBank: `trader.depositMargin` / `withdrawMargin` move it; `trader.placePerpOrder` (or plain `createOrder` on a perp symbol) locks margin from that balance — no per-order token approval. - **Positions are on-chain reads**, not indexed rows: `client.getPerpPosition(marginBank, account, pool)` and `client.getMarginAccount(marginBank, account)` — or the unified `exchange.fetchPositions()`. Live pricing/funding comes from `client.getPerpState(pool)` / `exchange.fetchFundingRate(symbol)`. - **Margin health is a chain read too.** `getMarginAccount` now also returns the requirements + status (`imReq` / `mmReq` / `cmReq` / `marginStatus`, from `MarginBank.getAccountHealth` + `getMarginStatus`); `client.getAccountHealth(marginBank, account)` is the lighter standalone read when only health matters, and `client.getLiquidationPrice(marginBank, pool, account)` estimates the mark at which this pool's move alone would trip maintenance (null when flat). `MarginStatus` / `MARGIN_STATUS` / `AccountHealth` are exported; `exchange.fetchPositions()` now fills `UnifiedPosition.liquidationPrice`. ## History (indexer) The CURRENT position/margin is the chain read above; the **append-only history** the chain doesn't expose is indexed (perp account plane), all one-shot indexer reads: ```ts const funding = await client.getFundingPayments(account, { pool, limit: 50 }); // signed funding paid/received const margin = await client.getMarginEvents(account, { limit: 50 }); // deposit/withdraw/lock/unlock const liqs = await client.getLiquidations({ account, pool }); // liquidation events const rates = await client.getFundingRateHistory(pool); // per-pool funding-rate series const oi = await client.getOpenInterestHistory(pool); // per-pool open-interest series ``` `getFundingRateHistory` / `getOpenInterestHistory` are the append-only counterparts to the overwrite-only `fundingRate` / `longOpenInterest` / `shortOpenInterest` fields on the perp `Market` row (which only carry the latest value). Liquidation history depends on the indexer's `LiquidationEngine` subscription, which is deferred until that contract is deployed — until then `getLiquidations` returns the `MarginBank`-sourced rows only. ## Quick start ```ts const exchange = new SomniaMarkets({ chain, wsRpcUrl, indexerUrl, privateKey }); await exchange.loadMarkets(); await exchange.depositMargin("BTC/USDSO:USDSO", 1_000); // USDso → MarginBank await exchange.createOrder("BTC/USDSO:USDSO", "limit", "buy", 0.001, 62_000); const [pos] = await exchange.fetchPositions(); // long/short + uPnL const { fundingRate, markPrice } = await exchange.fetchFundingRate("BTC/USDSO:USDSO"); ``` ## One-shot reads (no watch) For a plain fetch without a live tail: ```ts const perps = await client.listPerpMarkets({ baseSymbol: "WBTC", limit: 20 }); const one = await client.getPerpMarket(perps[0].id); // null if not a perp const port = await client.getPerpPortfolio(account, { ordersLimit: 50, tradesLimit: 50, since }); const state = await client.getPerpState(one!.poolAddress); // mark/index/funding/OI ``` `listPerpMarkets` takes a `PerpMarketFilter` (`baseSymbol` / `quoteSymbol`, all server-side); `getPerpPortfolio` takes the shared `PortfolioOptions` (`ordersLimit` / `tradesLimit` / `since`). Positions + collateral stay on-chain (`getPerpPosition` / `getMarginAccount`), not indexed rows. ## Writing forward-compatible code ```ts const m = client.getLiveMarketByPool(pool); switch (m?.marketType) { case "BINARY": /* YES/NO book */ break; case "SPOT": /* base/quote book */ break; case "PERP": /* base/quote book + funding/positions */ break; } ``` Key on `marketType` (not on field presence), use the type guards, and read decimals off the market row rather than assuming. --- # /docs/prices # Price feeds A realtime index price for an asset (BTC, ETH) from the **on-chain EMA price oracle** — streamed the same way the order books are: hydrate a snapshot to get roughly up to speed, then tail live. It's a *read-only* feed (an index price, not a tradable market), so there are no orders here — just `watch`/`fetch`. The shared client mechanics (read tiers, the reactive store, React wiring) are in [the engine guide](./ENGINE.md). ## The mental model - **A separate service.** Prices come from a standalone EMA price-feed indexer (Hasura GraphQL), *not* the markets indexer — its own endpoint, its own WebSocket. So price watches are independent of `watchMarket`: their own store, their own `subscribePrices` signal, their own health. - **One endpoint, every asset.** A single endpoint (`config.priceFeed`) serves every tracked asset (`"BTC"`, `"ETH"`, …); callers select an asset by symbol (case-insensitive). Discover what's tracked with `listPriceFeeds()`. With no `priceFeed` configured, the price methods throw with guidance. - **Snapshot, then live tail.** A watch first pulls an HTTP snapshot (current price + recent ticks), then a Hasura subscription streams updates. Unlike the order-book tail there's no seam to stitch — a price subscription is a full-state stream, so a reconnect just re-delivers current state (handled with backoff internally). - **Human numbers + exact raw.** Every price is a 1e18-scaled integer on the wire; the structs carry a display `number` (`price`, `ema`) *and* the exact 1e18 string in `raw` — never round-trip money through the `number`. Timestamps are unix **seconds** (`blockTimestamp` is chain time, monotonic — use it as a series x-axis; `observedAt` is the oracle's own source time and can drift). ## Configuration ```ts import { SomniaMarkets, SOMNIA_TESTNET_PRICE_FEED } from "@somnia-chain/markets-sdk"; const exchange = new SomniaMarkets({ indexerUrl, chain, wsRpcUrl, priceFeed: SOMNIA_TESTNET_PRICE_FEED, // { url } — the deployed dev feed, all assets // or your own: priceFeed: { url: "https://…/v1/graphql" } }); ``` `priceFeed` is `{ url, wsUrl? }`; `wsUrl` is derived from `url` (`http→ws`, `https→wss`) when omitted. Live subscriptions use the global `WebSocket` (browsers, Node ≥ 21). ## Reading — live ```ts const watch = await client.watchPrice("BTC"); // snapshot + subscribe; ref-counted const now = client.getLivePrice("BTC"); // LivePrice | null — { price, ema, blockTimestamp, raw, … } const tape = client.getLivePriceTicks("BTC", { limit: 120 }); // recent ticks, newest first const info = client.getLivePriceFeedInfo("BTC"); // decimals, symbol, description, latest const state = client.getPriceStatus("BTC"); // "unwatched" | "hydrating" | "live" watch.stop(); // release (the last release tears the socket down) ``` **Batch variants** take/return arrays and are the ergonomic choice for a multi-asset ticker — one watch, one read: ```ts const handle = await client.watchPrices(["BTC", "ETH", "SOL"]); // snapshot + subscribe all; ref-counted const rows = client.getLivePrices(["BTC", "ETH", "SOL"]); // (LivePrice | null)[], index-aligned const tailing = client.isTailing(); // true while the price socket is live-tailing handle.stop(); // release all in one call ``` Reads are synchronous, zero-round-trip, and current to the last pushed tick; subscribe to changes with `client.subscribePrices(listener)` (independent of the order-book `subscribeLive`). In React the hooks auto-watch while mounted: ```tsx import { useLivePrice, useLivePriceTicks, useWatchPrice } from "@somnia-chain/markets-sdk/react"; function Ticker() { const price = useLivePrice("BTC"); // updates the moment a tick lands const status = useWatchPrice("BTC"); // "hydrating" | "live" — render loading off this const ticks = useLivePriceTicks("BTC", 120); // for a sparkline return {price ? `$${price.price.toLocaleString()}` : "…"}; } ``` ## Reading — one-shot No watch, one HTTP round-trip each — for history, charts, or a server render: ```ts const info = await client.fetchPriceFeedInfo("BTC"); // metadata + current price const price = await client.fetchPrice("BTC"); // LivePrice | null const history = await client.fetchPriceHistory("BTC", { limit: 500, from, to }); // ticks, newest first const candles = await client.fetchPriceCandles("BTC", "M1", { from, to }); // OHLC, oldest first ``` Candle resolutions are `"M1"` / `"H1"` / `"D1"` (60s / 3600s / 86400s). `count` on a candle is the number of oracle updates in the bucket (update density), **not** trade volume. Like every indexer read these **throw** on request failure — an empty result means "no rows", never "request failed". ## From the exchange The unified [`SomniaMarkets`](./EXCHANGE.md) surface exposes prices by asset (these don't need `loadMarkets` — a price feed isn't a symbol-keyed market): ```ts const px = await exchange.fetchPrice("BTC"); // { symbol, price, ema, timestamp, … } | null for await (const _ of forever) { const tick = await exchange.watchPrice("BTC"); // resolves on each new tick } const ohlcv = await exchange.fetchPriceOHLCV("BTC", "1m"); // [ms, o, h, l, c, count][] — "1m"/"1h"/"1d" ``` The native `LivePrice` (raw strings + block metadata) rides on each struct's `info`. --- # /docs/engine # The engine (advanced) This guide tours the **engine tier** — the raw `SomniaMarketsClient`: bigint-exact, address-keyed. It is not a second entry point: you reach it through the exchange — ```ts const exchange = new SomniaMarkets({ indexerUrl, chain, wsRpcUrl }); const client = exchange.client; // the engine: exact raw-unit reads + watches const trader = exchange.trader; // the raw write tier (needs a signer) ``` Most applications stay on **[the exchange API](./EXCHANGE.md)** itself; the engine is the tier for exact escrow math, custom reads, and anything the exchange verbs don't cover. Both surfaces share one config, one socket, one watch/store. **Multi-chain deployments are multiple exchanges**: one per chain. For market-kind specifics, see the [binary markets](./BINARY.md) and [spot](./SPOT.md) guides. ## The three read tiers Every read on the client belongs to one of three tiers. The method name tells you which — and the tier tells you the freshness and the cost: | Tier | Methods look like | Backed by | Cost & freshness | |---|---|---|---| | **Live store** | `getLive*` (synchronous) | in-memory materialization of **watched markets** | zero round-trips, current to the last block | | **Chain** | `get*Onchain`, `getBinaryOrderBook`, balances | `eth_call` over the socket | one round-trip, current to head | | **Indexer** | `list*`, `getCandles`, `getPortfolio`, … | GraphQL (HTTP) | one round-trip, lags the chain slightly | Rule of thumb: **anything that gates an action reads the live store or the chain; the indexer is for history and aggregates.** Indexer reads throw on request failure — an empty result always means "no rows", never "it broke". ## Watches — scoped, ref-counted live data Nothing is streamed by default. You open a **watch** on what you care about, and the client becomes a local indexer of exactly that scope: ```ts const watch = await client.watchMarket(pool); // one market: book, fills, orders, status const book = client.getLiveBinaryOrderBook(pool); // synchronous, zero round-trips, last-block fresh // ... trade against it ... watch.stop(); // release (ref-counted, brief linger) ``` - [`watchMarket(pool)`](./api/index/interfaces/SomniaMarketsClient.md#watchmarket) — hydrates a consistent snapshot of that market (its row, recent fills, full resting book) and streams its events from the chain WebSocket. Resolves once reads are live. This is the right default: cost scales with what you watch, not with the protocol. - [`watchMarkets({ discover? })`](./api/index/interfaces/SomniaMarketsClient.md#watchmarkets) — everything the indexer knows, for list views and multi-market bots; `discover: true` also watches the creation events (the `MarketCreator` factory AND `BinaryMarketsModule.createMarket`) so newly created markets — rolling-series or module-created — join live. - [`watchUser(user)`](./api/index/interfaces/SomniaMarketsClient.md#watchuser) — hydrates one account's order/fill *history* (live events are attributed to every account automatically within watched markets). - [`getWatchStatus(pool)`](./api/index/interfaces/SomniaMarketsClient.md#getwatchstatus) — `"unwatched" | "hydrating" | "live"`; this is how you distinguish "the book is empty" from "I'm not watching this pool". Watches are **ref-counted**: two watchers of the same pool share one snapshot and one subscription, and a released scope lingers ~30s before teardown so quick re-watches don't re-snapshot. If the socket drops, watches heal themselves — resubscribe with backoff, then backfill the missed blocks straight from chain (the indexer is only ever touched to hydrate a *new* scope). While a market is watched, these answer synchronously with zero round-trips: [`getLiveBinaryOrderBook`](./api/index/interfaces/SomniaMarketsClient.md#getlivebinaryorderbook) / [`getLiveSpotOrderBook`](./api/index/interfaces/SomniaMarketsClient.md#getlivespotorderbook) (the resting book — **the one to render or quote against**), [`getLiveFills`](./api/index/interfaces/SomniaMarketsClient.md#getlivefills) (tape), [`getLiveUserFills`](./api/index/interfaces/SomniaMarketsClient.md#getliveuserfills) / [`getLiveUserOrders`](./api/index/interfaces/SomniaMarketsClient.md#getliveuserorders) (one account's activity), [`getLiveMarkets`](./api/index/interfaces/SomniaMarketsClient.md#getlivemarkets) / [`getLiveMarketByPool`](./api/index/interfaces/SomniaMarketsClient.md#getlivemarketbypool) / [`getLiveMarketByAddress`](./api/index/interfaces/SomniaMarketsClient.md#getlivemarketbyaddress) (market rows with live status + stats), and [`getLiveStatus`](./api/index/interfaces/SomniaMarketsClient.md#getlivestatus) (global health). Reactivity without React: [`subscribeLive`](./api/index/interfaces/SomniaMarketsClient.md#subscribelive) fires after every batch of changes — re-read whatever you need inside the callback: ```ts const watch = await client.watchMarket(pool); client.subscribeLive(() => { const { yesBids, yesAsks } = client.getLiveBinaryOrderBook(pool, { depth: 5 }); requote(yesBids, yesAsks); // runs within ms of the on-chain event }); ``` ## React Provide the client once; the hooks read it from context and **watch automatically** — rendering a market's book is what subscribes to it, and unmounting releases it: ```tsx import { SomniaMarketsProvider, useLiveBinaryOrderBook, useLiveFills, useWatchUser } from "@somnia-chain/markets-sdk/react"; function App({ children }) { return {children}; } function Terminal({ pool, account }: { pool: string; account?: string }) { useWatchUser(account); // hydrate the user's history once const book = useLiveBinaryOrderBook(pool, 11); // auto-watches `pool` while mounted const tape = useLiveFills(pool, 40); // shares the same watch (ref-counted) // ... } ``` The full set: `useLiveBinaryOrderBook`, `useLiveSpotOrderBook`, `useLiveFills`, `useLiveUserFills`, `useLiveUserOrders`, `useLiveMarketByPool`, `useLiveMarketByAddress`, `useLiveStatus`, `useIsTailing`, plus the explicit `useWatchMarket` / `useWatchUser` and `useSomniaMarketsClient`. Every pool-keyed data hook holds a ref-counted watch on its pool while mounted; `useWatchMarket` also returns the pool's `WatchStatus` for loading UI. For the **indexer** tier (history + directories, not the live store) there is a generic engine hook — `useIndexerQuery(fn, deps)` runs `fn(client)` on mount and whenever `deps` change, tracks `{ data, loading, error, refetch }`, and discards stale responses: ```tsx const { data: markets } = useIndexerQuery((c) => c.listBinaryMarkets({ limit: 20 }), []); ``` Concrete wrappers over the common reads: `usePortfolio`, `useMarkets`, `useCandles`, `useMarketFees`, `useOperators`. Separately, `useLiveMarkets` is the zero-round-trip live-store view of every watched market (pair it with a discovery watch), not an indexer fetch. ## Chain reads — head-fresh, no watch required One `eth_call` round-trip over the client's socket (concurrent calls pipeline): - [`getMarketOnchain`](./api/index/interfaces/SomniaMarketsClient.md#getmarketonchain) — a BinaryMarket's full wiring + state. **Authoritative for write eligibility** (status, resolution), and works before the indexer has ever seen the market. - [`getBinaryOrderBook`](./api/index/interfaces/SomniaMarketsClient.md#getbinaryorderbook) / [`getSpotOrderBook`](./api/index/interfaces/SomniaMarketsClient.md#getspotorderbook) — the book from the contract; the one-shot fallback (or checksum) for the live variants. - [`getErc20Balance`](./api/index/interfaces/SomniaMarketsClient.md#geterc20balance) / [`getNativeBalance`](./api/index/interfaces/SomniaMarketsClient.md#getnativebalance) — raw balances (use these, not indexer balances, to gate a write). - `getBalances(tokens, account)` — batch multi-token balance read (one round-trip for a whole wallet); `getOutcomeBalance(outcomeToken, account, id)` — a single ERC-6909 outcome-id balance (the on-chain point read behind the indexer's `getOutcomeBalances`). - `getErc20Metadata(token)` / `getErc20Allowance(token, owner, spender)` — token name/symbol/decimals and a spender allowance (gate an `approve` on it). - `getContractMeta(address, { proxy })` — contract/proxy introspection; and `getMaxVenueFeeBps()` — the protocol's hard fee-rate cap (bps). - Perp margin health — `getMarginAccount` (now including `imReq`/`mmReq`/`cmReq`/ `marginStatus`), `getAccountHealth`, and `getLiquidationPrice` (all `MarginBank` reads); see [perps](./PERPS.md). - `getVaultBalance(vault, owner, token)` — the LIVE claimable balance behind the append-only `getVaultPayoutFallbacks` credit log (vault credits emit no event, so the current balance must be read from chain). - [`getHeadBlock`](./api/index/interfaces/SomniaMarketsClient.md#getheadblock), [`getStopOrderSomiPayment`](./api/index/interfaces/SomniaMarketsClient.md#getstopordersomipayment), [`getSystemInfo`](./api/index/interfaces/SomniaMarketsClient.md#getsysteminfo). ## Indexer reads — history and aggregates One GraphQL round-trip; these are the only methods that touch the indexer (besides a watch's initial snapshot): - Markets: [`listMarkets`](./api/index/interfaces/SomniaMarketsClient.md#listmarkets), [`getMarket`](./api/index/interfaces/SomniaMarketsClient.md#getmarket), and the binary-narrowed [`listBinaryMarkets`](./api/index/interfaces/SomniaMarketsClient.md#listbinarymarkets) / [`listLiveBinaryMarkets`](./api/index/interfaces/SomniaMarketsClient.md#listlivebinarymarkets) / [`listPastBinaryMarkets`](./api/index/interfaces/SomniaMarketsClient.md#listpastbinarymarkets) / [`getBinaryMarket`](./api/index/interfaces/SomniaMarketsClient.md#getbinarymarket). - History: [`getCandles`](./api/index/interfaces/SomniaMarketsClient.md#getcandles) (OHLCV, chart-ready), [`getFills`](./api/index/interfaces/SomniaMarketsClient.md#getfills), and the account-scoped `getOrders(owner, opts)` (an owner's order history → `OrderRow[]`), `getUserFills(account, { pool })` (an account's fills → `FillRow[]`), and `getMarketStatusHistory(marketId)` (a market's lifecycle transitions). - Wallet views: [`getPortfolio`](./api/index/interfaces/SomniaMarketsClient.md#getportfolio) (binary positions + orders + trades in one round-trip), [`getSpotPortfolio`](./api/index/interfaces/SomniaMarketsClient.md#getspotportfolio), [`getSpotStopOrders`](./api/index/interfaces/SomniaMarketsClient.md#getspotstoporders), [`getOpenOrders`](./api/index/interfaces/SomniaMarketsClient.md#getopenorders), [`getOutcomeBalances`](./api/index/interfaces/SomniaMarketsClient.md#getoutcomebalances). - Control plane: [`listOperators`](./api/index/interfaces/SomniaMarketsClient.md#listoperators) / [`getOperator`](./api/index/interfaces/SomniaMarketsClient.md#getoperator) / [`listVenues`](./api/index/interfaces/SomniaMarketsClient.md#listvenues) / [`getVenue`](./api/index/interfaces/SomniaMarketsClient.md#getvenue) — the indexed MarketsCore operator/venue directory (venue ids are opaque bytes32; decode a BINARY_V1 venue's fee bytes with `decodeBinaryVenueFeeParams`). - Fee / resolution / router history (binary): `getMarketResolution`, `getRouterActions`, `listProtocolFees` / `listBuilderFees` / `listSettlementFees` (per-fill streams behind `getMarketFees`, filterable by `payer`), `listBuilderApprovals`, `getVaultPayoutFallbacks` — see [binary markets](./BINARY.md). - Perp account plane: `getFundingPayments`, `getMarginEvents`, `getLiquidations`, `getFundingRateHistory`, `getOpenInterestHistory` — the append-only history the chain doesn't expose; see [perps](./PERPS.md). - Lookups + totals: `getMarketByPool` (resolve a market by pool address), `countOrders` / `countUserFills` (history-page totals), and the board totals `countMarkets` / `countBinaryMarkets` / `countVenues` / `countOperators` (each takes the same filter as its `list*` sibling — use for pagination headers). `CANDLE_INTERVALS` is the exported bucket list `getCandles` accepts. - Ops: [`getSyncStatus`](./api/index/interfaces/SomniaMarketsClient.md#getsyncstatus) — how far behind the indexer itself is. Two of these have faster live twins a trading loop should prefer: `getOpenOrders` → `getLiveUserOrders`, `getFills` → `getLiveFills`. ## Writes — `createTrader` ```ts const trader = client.createTrader({ privateKey }); // or { walletClient } in the browser const { orderId, fills } = await trader.placeOrder({ pool, side: "BUY_YES", price, quantity }); ``` [`createTrader`](./api/index/interfaces/SomniaMarketsClient.md#createtrader) binds a signer to this client's chain, fees, and socket and returns a [`Trader`](./api/index/interfaces/Trader.md). The trader is **independent of the watches** — a pool's escrow tokens resolve from the pool contract itself (one cached read) when you don't pass them. With a local key the SDK signs locally — fixed fees, locally-tracked nonce, zero pre-send RPCs — and confirms in **one round-trip** via `realtime_sendRawTransaction`; every write resolves only once mined, with its receipt (and, for orders, the decoded `orderId` + `fills`). Market-kind specifics: [binary markets](./BINARY.md#trading), [spot](./SPOT.md#trading). For the MarketsCore control plane there is a second, low-frequency write tier: `client.createOperatorAdmin({ privateKey })` returns an `OperatorAdmin` with `registerOperator`, `updateOperator`, `createVenue` (venues are typed by a `bytes4` market-type id — `MARKET_TYPE_BINARY_V1` — and get a contract-generated `bytes32` venue id back), `updateVenue`, `setVenueEnabled`, and the two-step operator-ownership transfer. Build a BINARY_V1 venue's fee bytes with `client.encodeBinaryVenueFeeParams({...})`. ## Escape hatch [`publicClient`](./api/index/interfaces/SomniaMarketsClient.md#publicclient) exposes the underlying viem WebSocket client for any contract read the SDK doesn't cover — same socket, same pipelining. --- Next: [binary markets](./BINARY.md), [spot](./SPOT.md), [perps](./PERPS.md), and the [architecture guide](./ARCHITECTURE.md) for how the machine works inside. --- # /docs/architecture # Architecture How `@somnia-chain/markets-sdk` is put together, and why. The design goals: **minimum latency** — zero polling anywhere, one WebSocket as the only realtime transport, writes that confirm in a single round-trip — and **scoped cost**: live materialization is per-watch, so a client pays for the markets it actually renders or trades, not for the whole protocol, and the indexer is touched exactly once per watch (cold-start hydration) — after that, the chain itself is the data source. - [System overview](#system-overview) - [The client](#the-client) - [Watches: the snapshot seam + chain materialization](#watches) - [Event routing and the reducer](#event-routing-and-the-reducer) - [The local order book](#the-local-order-book) - [Connection lifecycle](#connection-lifecycle) - [The write path](#the-write-path) - [Choosing a read: the three tiers](#choosing-a-read) ## System overview One `SomniaMarketsClient` owns all protocol I/O. It talks to exactly two backends — the Envio/Hasura **indexer** (history + cold-start snapshot, HTTP GraphQL) and the **chain WebSocket** (everything realtime: log/head subscriptions, contract reads, transaction sends). All state lives in a per-client `MaterializerStore`; React hooks and the `getLive*` methods are synchronous views over it. ```mermaid flowchart LR subgraph app["Your app"] hooks["React hooks
useLiveFills, useLiveBinaryOrderBook, …"] node["Node / server code
bots, scripts, RSC"] end subgraph client["the engine (exchange.client)"] direction TB query["query.ts
one-shot indexer reads
listMarkets · getCandles · getPortfolio ·
getFills · getMarketResolution · getRouterActions ·
listProtocolFees · getFundingPayments · …"] reads["reads.ts / system.ts
one-shot chain reads
getBinaryOrderBook · getMarketOnchain ·
getAccountHealth · getLiquidationPrice ·
getVaultBalance · getErc20Balance · …"] subgraph live["live watches"] tail["liveTail.ts
watch registry + ingestion
ref-counted scopes · subscribe ·
backfill · seam"] reducer["reducer.ts
event → state
mirror of the indexer handlers"] store["store.ts
MaterializerStore
markets · orders · fills ·
book levels · status
versioned, memoized selectors"] end trader["trade.ts
writes
sign local · fixed fees ·
realtime send"] end subgraph backends["Backends"] indexer["Envio / Hasura indexer
HTTP GraphQL
history · aggregates ·
cold-start snapshot"] chain["Somnia chain
one WebSocket
eth_subscribe logs+heads ·
eth_call · getLogs ·
realtime_sendRawTransaction"] end hooks -- "useSyncExternalStore" --> store node -- "getLive* (sync)" --> store node -- "await client.*" --> query node -- "await client.*" --> reads node -- "createTrader(…)" --> trader query -- "POST /v1/graphql" --> indexer tail -- "one scope snapshot per
NEW watch — never again" --> indexer tail -- "watchEvent · watchBlocks ·
getLogs (seam backfill)" --> chain reads -- "eth_call (pipelined)" --> chain trader -- "realtime_sendRawTransaction
(send + receipt, 1 RTT)" --> chain tail --> reducer --> store ``` Key properties: - **Scoped.** Live materialization is opt-in per market via ref-counted watches. Cost — snapshot size, subscription filter width, event volume, reducer work — scales with what you watch, not with the protocol. Multi-chain is multiple clients, one per chain. - **Isolation.** Every exchange owns its own config, store, watches, and (lazily opened) socket. Two clients never share state — per-request watches, multi-chain bots, and parallel tests all just work. - **One socket.** Subscriptions, reads, backfills, and sends multiplex over the same WebSocket. Concurrent reads pipeline on the wire (`Promise.all` ≈ one round-trip), so there is no request batching layer and none is needed. - **Indexer only when necessary.** The indexer serves history and aggregates (candles, portfolios, old fills) and one consistent snapshot when a NEW watch scope opens. Everything that gates a trading decision — the book, market status, new-market discovery — is materialized from chain events, and even reconnects heal from chain alone. ## The client ```mermaid flowchart TB cc["new SomniaMarkets(config)"] --> ex["SomniaMarkets (exchange)"] -- ".client" --> pc["SomniaMarketsClient (engine)"] pc --> l1["live watches
watchMarket · watchMarkets · watchUser ·
getWatchStatus · stopLive · subscribeLive
getLiveStatus · getLiveMarkets · getLiveMarketByPool/ByAddress
getLiveFills · getLiveUserFills · getLiveUserOrders
getLiveBinaryOrderBook · getLiveSpotOrderBook"] pc --> l2["indexer reads (Promise, throw on failure)
listMarkets · getMarket · listBinaryMarkets · getBinaryMarket
getCandles · getFills · getOpenOrders · getOutcomeBalances
getPortfolio · getSpotPortfolio · getSpotStopOrders · getSyncStatus"] pc --> l3["chain reads (Promise)
getBinaryOrderBook · getSpotOrderBook · getMarketOnchain
getErc20Balance · getNativeBalance · getHeadBlock
getStopOrderSomiPayment · getSystemInfo"] pc --> l4["writes
createTrader({privateKey | account | walletClient})
→ placeOrder · cancelOrder · placeSpotOrder ·
placeSpotStopOrder · mintSet · burnSet · redeem · …"] ``` The socket opens lazily on first chain I/O, so an indexer-only client (e.g. server-side GraphQL reads) never opens one. ## Watches A watch turns the client into a **local indexer of its scope**: it hydrates a consistent snapshot of that scope from Envio up to block X, then materializes X+1.. directly from chain logs. Scopes are ref-counted (two watchers of one pool share everything) and torn down after a short linger when the last handle stops. The seam is gap-free and double-count-free: ```mermaid sequenceDiagram autonumber participant App participant Tail as LiveTail (watch registry) participant Idx as Indexer (GraphQL) participant WS as Chain WebSocket participant Store as MaterializerStore App->>Tail: watchMarket(pool) Tail->>WS: eth_subscribe logs (+ pool) · newHeads Note over Tail,WS: the scope's logs BUFFER from this instant —
nothing past the head can be missed Tail->>Idx: scope snapshot (ONE request) Note over Idx: the market row · recent fills ·
its full resting order set ·
chain_metadata.latest_processed_block = X Idx-->>Tail: rows consistent to block X Tail->>Store: mergeSnapshot (other scopes untouched) Tail->>WS: widen subscription (+ the market's
BinaryMarket address, now known) Tail->>WS: eth_getLogs [X+1 … head] for the scope WS-->>Tail: backfill logs Tail->>Store: decode → reduce → commit Tail->>Tail: replay the scope's buffered logs
(deduped by (block, logIndex)) Tail-->>App: watchMarket resolves — reads are live loop live — every block WS-->>Tail: pushed logs + head Tail->>Store: decode → reduce → commit (one notify per batch) Store-->>App: subscribers re-read (hooks re-render) end ``` `watchMarkets({ discover })` is the same seam with scope = every market (plus the creation-event sources — the MarketCreator factory AND the BinaryMarketsModule — when discovering); `watchUser(user)` is snapshot-only (the account's past orders/fills — live attribution needs no subscription of its own). Logs for a scope that is mid-hydration buffer in an inbox while other scopes keep applying live — one scope's seam never stalls another. Why this is safe on Somnia specifically: blocks have **instant BFT finality** — a delivered log is final, so there is no reorg handling. The dedupe set keyed by `(blockNumber, logIndex)` makes the buffer/backfill overlap harmless. Somnia logs carry no timestamp, so the `newHeads` stream doubles as the timestamp source (block number → timestamp map, pruned as the head advances). ## Event routing and the reducer One combined ABI (`liveEventsAbi`) decodes every watched log; the reducer routes by **event name + source address** and mutates the store exactly the way the Envio handlers mutate Postgres (`reducer.ts` mirrors `indexer/src/handlers/orderbook.ts` — keep them in lockstep): ```mermaid flowchart TB log["raw log from WS / backfill"] --> dec{"decodeEventLog
(liveEventsAbi)"} dec -- "source = a pool
(spot OR binary — byte-identical events)" --> ob["OrderBook events"] dec -- "source = a SpotPool" --> spot["spot-only events"] dec -- "source = MarketCreator /
BinaryMarketsModule" --> fac["MarketCreated"] dec -- "source = a BinaryMarket" --> bm["lifecycle events"] ob --> op["OrderPlaced → upsert order
(binary: side from isBid+userData, born Open;
spot: no side, born Closed)"] ob --> orst["OrderRested → rested=true
(spot: Closed → Open)"] ob --> ofill["OrderFilled → write LiveFill ·
patch maker order · bump market stats
(lastPrice, volumes, tradeCount)"] ob --> oc["OrderCancelled / OrderExpired /
OrderCancelledSelfMatch /
OrderReduced → patch order"] ob --> bk["SetMinted / SetBurned / Redeemed /
SettlementFeeCharged → market backing"] spot --> mp["MarkPriceUpdated → market.markPrice"] spot --> bp["OrderBookParametersUpdated →
tickSize · lotSize · minQuantity"] fac --> nm["build BinaryMarket row →
indexMarket → GROW the watch set →
catch-up getLogs for the creation range"] bm --> st["StatusChanged → status enum"] bm --> res["Resolved → status + winningOutcome"] bm --> vd["Voided → voided + status"] ``` Two ordering subtleties the reducer encodes: - **`OrderFilled` fires before the taker's `OrderPlaced`** in the same tx, so the taker is unknown at fill time. The fill stores `takerOrder_id` / `makerOrder_id` foreign keys; read-time selectors back-join owner + side from the order map (hydrated by the snapshot's open orders and live events). - **`MarketCreated` grows the discovery watch live.** Two creation events are watched. The `MarketCreator` factory rolls each series autonomously (a Somnia reactivity `Schedule` sub drains the due boundary's series in a gas-bounded loop, spilling to the next block when a batch is too large), emitting its 13-field `MarketCreated(marketId, market, pool, yesId, noId, collateral, asset, strike, tradingStart, expiry, oracleQuestionId, question, intervalSec)` — the trailing `intervalSec` is the series cadence (900 / 3600 / 14400 / 86400). The `BinaryMarketsModule` emits its own 19-field `MarketCreated` for EVERY market (rolled or created directly via `createMarket`) — the only creation event carrying the `(operatorId, venueId)` origin attribution — so module-created markets that never pass through a `MarketCreator` are discovered too. When an all-markets watch with `discover` is active, the tail re-subscribes with the new pool + market addresses and sweeps the creation range with a one-shot `getLogs`, so a market created seconds ago is fully tailed — the indexer is never asked again. ## The local order book The store *is* the book. Every resting order is tracked through its lifecycle, so depth is an in-memory aggregation — reading the book costs **zero round-trips** and is current to the last delivered block: ```mermaid flowchart LR subgraph store["MaterializerStore.orders"] o1["order: Open + rested
price 620000 · qty 50"] o2["order: Open + rested
price 620000 · qty 25"] o3["order: Open + rested
price 610000 · qty 10"] o4["order: Filled / Cancelled /
not rested → ignored"] end store --> agg["bookLevels(pool, depth)
group by (isBid, price) · sum qty ·
sort best-first · slice depth"] agg --> spotbook["getLiveSpotOrderBook
{ bids, asks }"] agg --> yes["YES-terms levels"] yes --> inv["toBinaryBook( )
NO side = 1 − yesPrice
(quantities carry over)"] inv --> binbook["getLiveBinaryOrderBook
{ yesBids, yesAsks, noBids, noAsks }"] ``` This matches the on-chain `getBookLevels` exactly because binary pools keep a *single* book in YES terms — a NO order is expressed as `isBid`/`userData` with a YES-terms price, which is also how orders arrive in `OrderPlaced` events. The one-shot chain reads (`getBinaryOrderBook`/`getSpotOrderBook`) remain available as a checksum, but nothing in a render or quoting path needs them. Completeness note: live-witnessed orders are always present; orders that rested *before* the watch opened come from the scope snapshot's open-order set — and because snapshots are per-scope, that set is the market's whole resting book, not a global cap's share of it. ## Connection lifecycle There is no polling fallback and no HTTP transport. With no active watches the client holds no subscriptions at all; with watches, it is either live or reconnecting: ```mermaid stateDiagram-v2 [*] --> idle idle --> hydrating: first watchMarket / watchMarkets hydrating --> live: scope snapshot + backfill + replay OK hydrating --> reconnect_wait: snapshot / backfill failed live --> hydrating: new watch opens (its scope only —
existing scopes keep streaming) live --> reconnect_wait: WS error (logs or heads) reconnect_wait --> live: resubscribe + getLogs
[lastBlock+1 … head] — CHAIN ONLY,
the indexer is not consulted note right of reconnect_wait exponential backoff 500ms → 1s → 2s → 4s → 8s (cap) reset to 500ms once live end note live --> idle: last watch released
(after a ~30s linger) live --> live: blocks stream in ``` Reconnects never re-snapshot: the store already holds state to block L, so the seam is simply `getLogs [L+1, head]` deduped against what's processed — chain truth heals chain gaps. The indexer is only ever consulted to hydrate a scope it hasn't seen. ## The write path Two signer modes, one rule: **nothing is estimated, nothing is polled.** ```mermaid sequenceDiagram autonumber participant Bot as Caller participant T as Trader (trade.ts) participant WS as Chain WebSocket rect rgb(235, 245, 235) Note over Bot,WS: LOCAL SIGNER (privateKey / account) — the fast path Bot->>T: placeOrder({pool, side, price, quantity}) Note over T: escrow token+amount computed locally
approval cache hit → no allowance read
pool tokens from the trader's own cache
(one-time chain read — no live-store dependency) Note over T: build tx with ZERO RPCs:
· fixed fees (config.fees, default 60 gwei / 0 tip)
· fixed gas ceiling (unused gas refunded)
· nonce from local NonceManager
then sign locally T->>WS: realtime_sendRawTransaction(signedTx) Note over WS: node executes, blocks server-side
until the receipt exists WS-->>T: receipt WITH logs — one round-trip (~480ms) Note over T: decode OrderPlaced → orderId
decode OrderFilled → fills[] T-->>Bot: { hash, receipt, orderId, fills } end rect rgb(240, 240, 250) Note over Bot,WS: BROWSER SIGNER (injected walletClient) Bot->>T: placeOrder(…) T->>WS: eth_sendTransaction (wallet signs, fixed fees pinned) WS-->>T: tx hash T->>WS: getTransactionReceipt (immediate check) Note over T,WS: on miss: eth_subscribe newHeads —
re-check on each pushed head, first hit wins.
No poll, no timeout — socket errors reject. WS-->>T: receipt T-->>Bot: { hash, receipt, orderId, fills } end ``` The first write of a (token, spender) pair does one `allowance` read and — if needed — one `approve(maxUint256)` tx; the pair is then cached for the trader's lifetime, so steady-state orders are exactly one round-trip. The one-time nonce fetch happens on the first write; broadcast errors `reset()` the local nonce so a failed send can't leave a gap. Measured on Somnia testnet (see `sdk-e2e/latency-report.md`): `placeOrder` confirm p50 ≈ **503ms**, within ~25ms of the raw transport floor. ## Choosing a read | You want | Use | Backed by | Freshness | |---|---|---|---| | The book, to render or quote against | `getLiveBinaryOrderBook` / `getLiveSpotOrderBook` / hooks | local store | last block, 0 RTT | | Trade tape / user orders / market stats, live | `getLive*` / hooks | local store | last block, 0 RTT | | Is this market tradable *right now* | `getLiveMarketByAddress(...).status` or `getMarketOnchain` | chain events / `eth_call` | last block | | Candles, portfolios, historical fills | `getCandles` / `getPortfolio` / `getFills` … | indexer | indexer lag (~200ms) | | A market list without opening watches | `listMarkets` / `listBinaryMarkets` | indexer | indexer lag | | Raw balances / wiring | `getErc20Balance` / `getMarketOnchain` … | `eth_call` | head | Rule of thumb: **anything that gates an action reads the store or the chain; the indexer is for history.** Indexer reads throw on failure — an empty result always means "no rows", never "request failed". --- # /docs/raw-integration # Raw Smart-Contract Integration Somnia Markets runs three market families on one on-chain order-book engine: **spot** pairs (`SpotPool`), **binary prediction markets** (`BinaryPool`), and **perps** (`PerpPool`). All three extend the same shared `OrderBook` core, so the placement surface, the order-lifecycle events, and the book-materialization technique are identical across every book; what differs per family is discovery, funding/escrow, and settlement. This guide is how to trade with nothing but an RPC node and the contract ABIs — any language, any stack. It covers the shared core first, then each family in turn, then [materializing a live local order book](#materialize-the-order-book-from-events) from the event stream. Pair it with [Market Making](./MarketMakingTips.md) if you are building a quoting system. (Building a JS/TypeScript app instead? The [SDK](../packages/sdk/README.md) wraps everything here.) What you need to start: contract addresses and signatures. Protocol contracts (the `BinaryMarketsModule` market registry, the `MarketsCore` control plane, the `OutcomeToken6909` singleton) are listed live per network on this explorer's [System page](/system); spot pairs and live prediction markets are listed on the [markets page](/); per-market prediction addresses are read from the module's registry on-chain ([below](#binary-prediction-markets)). The complete Solidity interfaces — everything needed to generate ABIs — are in the [interface reference](#interface-reference) at the end of this guide. ## The shared order-book core Every book — spot, binary, perp — exposes the same placement entrypoint, covering all order types (GTC / `NormalOrder`, `FillOrKill`, `ImmediateOrCancel`, `PostOnly`): ```solidity function placeOrder( bool isBid, uint64 userData, uint256 price, uint256 quantity, uint64 expireTimestampNs, OrderType orderType, SelfMatchingOption selfMatchingOption, address builder, uint96 builderFeeBpsTimes1k ) external payable returns (bool success, OrderId id); ``` - **`expireTimestampNs` is mandatory and nanoseconds** — a future unix-ns timestamp (`now_seconds * 1e9 + lifetime_ns`); zero or past values are rejected. There is no "no expiry" sentinel. - **`success == false` without a revert is a normal outcome** — a `PostOnly` that would cross, a `FillOrKill` that can't fully fill, an IOC that fills nothing. Always branch on it. - **Quantize in integers.** `getOrderBookParameters()` returns `tickSize`, `lotSize`, and `minQuantity` in raw token units; off-grid values revert `InvalidPrice` / `InvalidQuantity`. - **`builder` / `builderFeeBpsTimes1k`** attribute the order to a routing/builder frontend and pay it a per-order fee (basis-points × 1000). Pass `(address(0), 0)` for none. A non-zero fee requires the order owner to have opted the builder in first — `approveBuilder(builder, maxFeeBpsTimes1k)` on the pool (0 revokes) — and is capped by the pool's `getMaxBuilderFeeBpsTimes1k()`; charges emit `BuilderFeeCharged`. (Spot and binary pools; perp pools reject non-default builder values for now.) - `cancelOrder(id)` / `reduceOrder(id, newQty)` manage resting orders; both revert (rather than no-op) on already-terminal orders — check your local book or `getOrder(id)` first. `cancelExpiredOrders(ids)` and `sweepExpiredAtLevel(isBid, price, maxCount)` are permissionless cleanup. - `OrderId`s are unique **per pool** — always key by `(pool, orderId)`. Reading any book on demand, via `eth_call`: | View | Returns | |---|---| | `getBookLevels(isBid, numLevels)` | Aggregated `(price, quantity)` levels, best first | | `getAllOpenOrdersOffChain(isBid, maxCount, startCursor)` | Full `Order` structs, paginated (`msg.sender` must be `address(0)` — the `eth_call` default) | | `getOrder(orderId)` / `getOwnOpenOrders()` | Single order / caller's open ids | Polling these is fine for a dashboard; a trading system should take one snapshot and apply event deltas — see [materialization](#materialize-the-order-book-from-events). ## Spot markets Each trading pair is its own `SpotPool` — live pairs are listed on the [markets page](/). `getPoolParams()` returns everything static in one call: `(baseToken, quoteToken, makerFeeBpsTimes1k, takerFeeBpsTimes1k, tickSize, minQuantity, lotSize)`. A native-token side is reported as a sentinel token address (not `address(0)`) — resolve it from `getPoolParams` rather than assuming. Spot semantics are the conventional ones: `isBid = true` buys base with quote, a fill is a base ↔ quote swap at the **maker's** resting price, and `userData` is a free 64-bit tag echoed back on the order struct and its `OrderPlaced` event — use it for strategy/generation ids (this is *not* true on the binary books — see below). **Funding.** By default the pool **auto-pulls** the required input from your wallet at placement (ERC-20 `transferFrom` after a one-time approval, or `msg.value` on native pools) and **auto-delivers** proceeds back on fill, cancel, or expiry. Size the pull with `getAutoPullRequirement(owner, isBid, price, quantity, builderFeeBpsTimes1k)`. High-churn integrations should opt out with `setManualVaultMode(true)`: `deposit` once, quote against the vault balance with no per-order token transfers, `withdraw` when rebalancing — for a loop that places and cancels constantly the gas savings compound. **Mark price.** Spot pools push `MarkPriceUpdated(asset, markPrice, rawMidpoint)` whenever the book midpoint advances — an EMA-smoothed midpoint plus the raw `(bestBid + bestAsk) / 2`, an on-chain fair-price feed with no extra infrastructure. ## Binary prediction markets ### Discover markets `BinaryMarketsModule` is the market registry (the `MarketsCore` control plane holds only operators, venues, and module bindings — no markets). Each market is a `MarketRecord` (read via `module.markets(marketId)`): | Field | Use | |---|---| | `pool` | The `BinaryPool` — the order book you trade on | | `market` | The `BinaryMarket` — lifecycle + resolution state | | `collateral` | The ERC-20 quoted against (one per market) | | `originOperatorId` / `originVenueId` | Origin attribution: the uint32 operator id + opaque bytes32 venue id the market was created under | | `yesId` / `noId` | ERC-6909 ids of the outcome positions on the shared `OutcomeToken6909` singleton | | `tradingStart` / `expiry` | Trading window (unix seconds) | Watch the module's `MarketCreated` event to discover new markets — **every** market fires it, whether created directly via `createMarket` or rolled by a venue's `MarketCreator` (venues run rolling series — hourly up/down and similar — that create markets continuously), and it is the only creation event carrying the `(operatorId, venueId)` origin. `marketId` is a module-scoped counter (`bytes32(++marketSeq)`) that doubles as the CREATE2 salt — unique by construction, not precomputable before the create tx. `module.marketIdByAddress(addr)` is the reverse lookup. Every market carries an immutable kind tag, `IMarket.marketType()`. This section describes **`BINARY_SINGLE_BOOK`** — the only kind live today. Future kinds (dual-book, multi-outcome) will carry different tags and different book semantics: branch on the tag, never on assumptions. Lifecycle: `Listed → Trading → Locked → (Settling) → Resolved | Voided` (`BinaryMarket.StatusChanged`, plus `Resolved` / `Voided`). Orders are only accepted while the market reports Trading — placement reverts `TradingNotActive` otherwise. Cancellation stays open through `Locked`; `redeem` opens at `Resolved` / `Voided`. ### One book, two outcomes — the (isBid, userData) encoding Each `BinaryPool` runs a **single** order book. Unlike spot, `userData` is **not** a tag field — it selects the book half, and the four order kinds are encoded in the `(isBid, userData)` pair: | `userData` | `isBid = true` | `isBid = false` | |---|---|---| | `0` (YES book) | `BUY_YES` | `SELL_YES` | | `1` (NO book) | `SELL_NO` | `BUY_NO` | Any other `userData` value reverts `InvalidUserData`. The NO book is price-inverted so the base matcher can cross the two books without knowing about outcomes: a NO order is submitted at the YES-side complement, `price = oneCollateral − noPrice`, where `oneCollateral = 10 ** collateral.decimals()`. All prices must satisfy `0 < price < oneCollateral` (`PriceOutOfBounds`) — a share can never be worth more than one collateral unit. ### Escrow and funding Placement escrows worst-case value up front: - **BUY orders** (`BUY_YES`, `BUY_NO`) lock collateral (ceil-rounded `price × quantity` in the order's own frame). The pull is **vault-first**: free vault balance is consumed before `transferFrom` on your wallet — so `collateral.approve(pool, …)` once per pool. (There is no auto-pull/manual-vault toggle here; this is the only mode.) - **SELL orders** (`SELL_YES`, `SELL_NO`) lock the outcome tokens themselves, pulled from your ERC-6909 balance on the singleton — call `outcomeToken.setOperator(pool, true)` once; it covers every market, since ids are namespaced by pool. Money flows back through two channels worth knowing: - **Refunds land in your vault balance** — taker surplus (you locked at your limit price, filled at a better maker price) and cancel/reduce/expiry refunds credit the pool vault, not your wallet. Because placement is vault-first, a quoting loop recycles these automatically; `withdraw(collateral, amount)` only when rebalancing. Read it with `getWithdrawableBalance(owner, collateral)`. - **Fill proceeds deliver wallet-first with vault fallback** — if the wallet transfer fails the pool credits the vault and emits `PayoutFallbackToVault`. Inventory comes from complete sets: `module.mintCompleteSet(operatorId, venueId, marketId, amount)` turns `amount` collateral into `amount` YES + `amount` NO (`setOperator(module, true)` once for the merge/redeem directions; `operatorId`/`venueId` are routing attribution only — pass `0` / `bytes32(0)` for none); `mergeCompleteSet(operatorId, venueId, marketId, amount)` is the inverse; `redeem(operatorId, venueId, marketId, outcomeIdx, amount)` burns the winning side 1:1 after resolution (or either side at 1/2 on void). You can also call the pool's `mintSet` / `burnSet` / `redeem` directly. Note you often need **no inventory at all** to quote — see the fill paths below. On a **resolved** market (never a voided one), the pool skims the venue's frozen `settlementFeeBpsTimes1k` ONCE from the whole winning backing when the first winning redeem lands (emitting `SettlementFeeCharged(feeRecipient, winningBacking, fee)`); every winner then redeems for `1 − fee` per token. Per-fill maker/taker fees (`ProtocolFeeCharged`) and the per-order builder fee (`BuilderFeeCharged`) are the other two fee rails — all rates are frozen into the pool at creation from the origin venue's config and readable via `getBinaryPoolParams()`. ### The four fill paths Two opposite-kind orders crossing settle by one of four paths (dispatched on the unordered pair of order kinds): | Crossing pair | Path | Settlement | |---|---|---| | `BUY_YES × SELL_YES` | DIRECT_YES | YES ↔ collateral swap | | `SELL_NO × BUY_NO` | DIRECT_NO | NO ↔ collateral swap | | `BUY_YES × BUY_NO` | MINT_A_PAIR | Both pay collateral; pool mints a fresh pair, one side each (emits `SetMinted`) | | `SELL_YES × SELL_NO` | BURN_A_PAIR | Both escrows burned as a pair; each seller paid their share (emits `SetBurned`) | The fill price on `OrderFilled` is always the **maker's** resting price, in the YES frame; the NO-side display price is `oneCollateral − fillPrice`. There is no on-chain "fill kind" field — consumers derive it from the two orders' kinds — the SDK exports [`kindOf`](../packages/sdk/docs/api/index/functions/kindOf.md) and [`fillKind`](../packages/sdk/docs/api/index/functions/fillKind.md) for exactly this derivation. `getOrderInfo(orderId)` exposes the prediction-side escrow state per order (`lockedCollateral` / `lockedOutcome`, kind). ## Perps `PerpPool` extends the same `OrderBook` core, so everything in [the shared core](#the-shared-order-book-core) and [materialization](#materialize-the-order-book-from-events) carries over unchanged. On top it adds margin accounting, funding, and liquidations — with `FundingUpdated` / `OpenInterestUpdated` events, and a dedicated `MakerOrderCancelledExceedsPosition` removal event (a maker order erased pre-fill because it would breach the owner's position limit — treat it as a removal in a book reducer). BTC and ETH perps are live on testnet — see [Perps](../packages/sdk/docs/PERPS.md). ## Materialize the order book from events Every book mutation emits an event, so one pinned snapshot plus the log stream reproduces the full book — for **any** of the three families. This is exactly how the protocol's own indexer and the SDK's live watches work — the reducer below is the same one they run (see [Architecture](../packages/sdk/docs/ARCHITECTURE.md) for the SDK's implementation of it). ### Snapshot, then stream 1. Pin a block `N` (`eth_blockNumber`). 2. Snapshot both sides with `getAllOpenOrdersOffChain` **at block `N`** (pass the block tag explicitly so pagination pages are mutually consistent). Drop orders whose `expireTimestampNs` has already passed. 3. Stream the pool's logs from `N + 1` (`eth_subscribe("logs")` over WSS, or an `eth_getLogs` loop) and apply them strictly in `(blockNumber, logIndex)` order. ### The event reducer Keep a map `orderId → Order` plus per-side level aggregates: | Event | Action | |---|---| | `OrderPlaced(orderId, placedOrder)` | Cache the struct; do **not** insert. Fires for every accepted order — `placedOrder.quantityRemaining` is already the **post-match residual** (the matcher runs before the event), so zero remaining means it fully filled on entry. | | `OrderRested(orderId)` | Insert the cached order into the book. This is the **only** insert signal. | | `OrderFilled(takerId, makerId, qty, takerRem, makerRem, fillPrice)` | Patch the **maker**: remaining = `makerRem`, remove at zero. Ignore the taker leg — its state arrives on its own `OrderPlaced`/`OrderRested` later in the same tx. | | `OrderReduced(orderId, newQuantity)` | Set remaining = `newQuantity` (not a fill). | | `OrderCancelled(orderId)` / `OrderExpired(orderId)` | Remove (idempotently). | | `OrderCancelledSelfMatch(orderId)` | Remove — a same-owner resting maker erased by a `CancelMaker` self-match. | Family extras, none of which mutate book state: spot pools also emit `MarkPriceUpdated` (fair-price telemetry); binary pools emit `SetMinted` / `SetBurned` / `Redeemed` / `SettlementFeeCharged` (outcome-supply / settlement telemetry — mint-a-pair and burn-a-pair fills emit the first two alongside `OrderFilled`) and `BinaryMarket.StatusChanged` (leaves Trading → no new fills, only cancels from here); perp pools add `MakerOrderCancelledExceedsPosition`, which **does** mutate the book — treat it as a removal. Ordering inside a placement tx: settlement hooks and one `OrderFilled` per matched maker fire **first**, then the taker's `OrderPlaced` (already residual-adjusted), then `OrderRested` iff the residual rested. A reducer that only inserts on `OrderRested` handles this for free. ### The sharp edges - **Self-match removals have their own event.** With `SelfMatchingOption.CancelMaker`, the matcher erases the same-owner resting maker and emits `OrderCancelledSelfMatch(orderId)` (on every book — spot, binary, perp). Handle it as a removal or your reducer carries a phantom order whenever *any* trader self-crosses with `CancelMaker`. With `CancelTaker` the incoming order is rejected instead (`success == false`). - **Expiry is lazy.** Matching walks past expired makers without cleanup; `OrderExpired` only fires later (owner's next placement, or the permissionless sweeps). Prune locally the moment `expireTimestampNs` passes — an expired order can never fill — and treat the eventual event as a no-op. - **Make removals idempotent.** Between local pruning and the several removal paths, "remove an already-absent order" must be a no-op. - **Reorgs / stream gaps.** On WSS reconnect, backfill the missed range with `eth_getLogs` before resuming. Note Somnia's public RPC omits the `removed` field on logs, so don't rely on it to detect reorgs — on any parent-hash discontinuity, re-snapshot rather than trying to unwind. ## Track your own orders and fills Both order-id parameters on `OrderFilled` are indexed topics, so you can filter your fills by the ids your `placeOrder` calls returned (or `getOwnOpenOrders()` after a restart). Alert on `PayoutFallbackToVault` — a delivery to your wallet failed and the proceeds are parked in your vault balance. Reconcile funds with `getWithdrawableBalance(owner, token)` and, on binary markets, `outcomeToken.balanceOf(owner, yesId | noId)` for positions. ## Interface reference ABI-faithful excerpts of every function and event used in this guide, taken from the deployed contracts. Admin/venue-governance entrypoints are omitted; external interface types (`IERC20`, adapters) are shown as `address` — the ABI encoding is identical. ### Shared order-book core (every pool) ```solidity type OrderId is uint128; enum OrderType { NormalOrder, FillOrKill, ImmediateOrCancel, PostOnly } enum SelfMatchingOption { CancelTaker, CancelMaker } struct Order { OrderId orderId; bool isBid; address owner; uint64 userData; uint256 price; uint256 fullQuantity; uint256 quantityRemaining; uint64 expireTimestampNs; } struct OrderBookLevel { uint256 price; uint256 quantity; } struct OrderBookParameters { uint256 tickSize; // min price increment, raw quote/collateral units uint256 minQuantity; // min order quantity, raw base units uint256 lotSize; // min quantity increment, raw base units } interface IOrderBook { event OrderPlaced(OrderId indexed orderId, Order placedOrder); event OrderRested(OrderId indexed orderId); event OrderFilled( OrderId indexed takerOrderId, OrderId indexed makerOrderId, uint256 quantityFilled, uint256 takerRemainingQuantity, uint256 makerRemainingQuantity, uint256 fillPrice ); event OrderCancelled(OrderId indexed orderId); event OrderCancelledSelfMatch(OrderId indexed orderId); event OrderExpired(OrderId indexed orderId); event OrderReduced(OrderId indexed orderId, uint256 newQuantity); event OrderBookParametersUpdated(OrderBookParameters newParameters); function placeOrder( bool isBid, uint64 userData, uint256 price, uint256 quantity, uint64 expireTimestampNs, OrderType orderType, SelfMatchingOption selfMatchingOption, address builder, uint96 builderFeeBpsTimes1k ) external payable returns (bool success, OrderId id); function cancelOrder(OrderId orderId) external; function reduceOrder(OrderId orderId, uint256 newQuantityRemaining) external; function cancelExpiredOrders(OrderId[] calldata orderIds) external; function sweepExpiredAtLevel(bool isBid, uint256 price, uint256 maxCount) external returns (uint256 cleaned); function getOrder(OrderId orderId) external view returns (Order memory); function getOwnOpenOrders() external view returns (OrderId[] memory); function getBookLevels(bool isBid, uint64 numLevels) external view returns (OrderBookLevel[] memory); function getOrderBookParameters() external view returns (OrderBookParameters memory); // eth_call only — msg.sender must be address(0) function getAllOpenOrdersOffChain(bool isBid, uint256 maxCount, uint64 startCursor) external view returns (Order[] memory orders, bool hasMoreOrders, uint64 nextCursor); } // The per-user vault, inherited by every pool. interface IVault { function deposit(address token, uint256 amount) external; function depositNative() external payable; function withdraw(address token, uint256 amount) external; function getWithdrawableBalance(address owner, address token) external view returns (uint256); } ``` ### SpotPool additions ```solidity interface ISpotPool /* is IOrderBook, IVault */ { event MarkPriceUpdated(address indexed asset, uint256 markPrice, uint256 rawMidpoint); event ManualVaultModeUpdated(address indexed user, bool enabled); event PayoutFallbackToVault(address indexed owner, address indexed token, uint256 amount); function setManualVaultMode(bool enabled) external; function getPoolParams() external view returns ( address baseToken, address quoteToken, uint256 makerFeeBpsTimes1k, uint256 takerFeeBpsTimes1k, uint256 tickSize, uint256 minQuantity, uint256 lotSize ); function getManualVaultMode(address user) external view returns (bool enabled); function getAutoPullRequirement( address owner, bool isBid, uint256 price, uint256 quantity, uint96 builderFeeBpsTimes1k ) external view returns (address inputToken, uint256 requiredAmount, uint256 delta); function getMidpointEmaState() external view returns (uint256 emaValue, uint64 lastUpdateNs); } ``` ### BinaryPool additions ```solidity struct BinaryPoolOrderInfo { OrderId orderId; uint256 lockedCollateral; // BUY escrow (mutually exclusive with lockedOutcome) uint256 lockedOutcome; // SELL escrow uint8 outcomeIdx; // 0 = YES, 1 = NO bool isBuy; address builder; uint96 builderFeeBpsTimes1k; } struct BinaryPoolInfo { address collateralToken; address market; address outcomeToken; uint256 yesId; uint256 noId; uint256 oneCollateral; // 10 ** collateral.decimals() uint256 setBacking; address feeRecipient; uint256 makerFeeBpsTimes1k; uint256 takerFeeBpsTimes1k; uint256 maxBuilderFeeBpsTimes1k; uint256 settlementFeeBpsTimes1k; } interface IBinaryPool /* is IOrderBook, IVault */ { event SetMinted(address indexed payer, address indexed yesTo, address indexed noTo, uint256 amount); event SetBurned(address indexed holder, uint256 amount); event Redeemed( address indexed holder, address indexed to, uint8 outcomeIdx, uint256 amountBurned, uint256 collateralOut ); // Fee rail: per-fill protocol fees, per-order builder fees (opt-in via // approveBuilder), and the one-time settlement fee on the winning backing. event ProtocolFeeCharged( OrderId indexed orderId, address indexed recipient, address indexed token, uint256 amount, bool isTakerSide ); event BuilderApproved(address indexed user, address indexed builder, uint256 maxFeeBpsTimes1k); event BuilderFeeCharged(OrderId indexed orderId, address indexed builder, address indexed token, uint256 amount); event SettlementFeeCharged(address indexed feeRecipient, uint256 winningBacking, uint256 fee); event PayoutFallbackToVault(address indexed owner, address indexed token, uint256 amount); function approveBuilder(address builder, uint256 maxFeeBpsTimes1k) external; function getMaxBuilderFeeBpsTimes1k() external view returns (uint256 maxFeeBpsTimes1k); function getBuilderApproval(address user, address builder) external view returns (uint256 maxFeeBpsTimes1k); function getEffectiveBuilderApproval(address user, address builder) external view returns (uint256 maxFeeBpsTimes1k); function mintSet(address yesTo, address noTo, uint256 amount) external; function burnSet(uint256 amount) external; function redeem(uint256 amount, uint8 outcomeIdx, address to) external returns (uint256 collateralOut); function collateralToken() external view returns (address); function outcomeToken() external view returns (address); function outcomeId(uint8 outcomeIdx) external view returns (uint256); function market() external view returns (address); function setBacking() external view returns (uint256); function getBinaryPoolParams() external view returns (BinaryPoolInfo memory info); function getOrderInfo(OrderId orderId) external view returns (BinaryPoolOrderInfo memory info); } ``` ### BinaryMarketsModule (the market registry) ```solidity enum VoidPolicy { UNIFORM, AMM_SNAPSHOT } // AMM_SNAPSHOT is a dead legacy slot enum MarketType { BINARY_SINGLE_BOOK, BINARY_DUAL_BOOK, NATIVE_MULTI } interface IBinaryMarketsModule { event MarketCreated( bytes32 indexed marketId, address indexed market, address indexed pool, uint256 oracleQuestionId, uint32 operatorId, bytes32 venueId, address creator, address collateral, uint256 yesId, uint256 noId, uint8 outcomeSlotCount, MarketType marketType, uint64 tradingStart, uint64 expiry, VoidPolicy voidPolicy, string asset, uint256 strike, // 0 for reference-mode markets (no fixed strike) string question, bytes context ); function markets(bytes32 marketId) external view returns ( uint256 oracleQuestionId, uint8 outcomeSlotCount, VoidPolicy voidPolicy, address collateral, uint32 originOperatorId, bytes32 originVenueId, address oracleAdapter, address creator, address market, address pool, uint256 yesId, uint256 noId, uint64 tradingStart, uint64 expiry ); function marketIdByAddress(address market) external view returns (bytes32 marketId); // operatorId / venueId are routing attribution only (0 / bytes32(0) = none). function mintCompleteSet(uint32 operatorId, bytes32 venueId, bytes32 marketId, uint256 amount) external; function mergeCompleteSet(uint32 operatorId, bytes32 venueId, bytes32 marketId, uint256 amount) external; function redeem(uint32 operatorId, bytes32 venueId, bytes32 marketId, uint8 outcomeIdx, uint256 amount) external; } ``` ### BinaryMarket (lifecycle) and the outcome-token singleton ```solidity enum MarketStatus { Listed, Trading, Locked, Settling, Resolved, Voided } interface IBinaryMarket { event StatusChanged(MarketStatus indexed oldStatus, MarketStatus indexed newStatus); event Resolved(uint8 indexed winningOutcome); event Voided(); function marketType() external view returns (MarketType); function tradingActive() external view returns (bool); function isResolved() external view returns (bool); function isVoided() external view returns (bool); function winningOutcome() external view returns (uint8); } // ERC-6909 subset. One singleton for all markets; id = (uint160(pool) << 8) | outcomeIdx. interface IOutcomeToken6909 { event Transfer( address caller, address indexed sender, address indexed receiver, uint256 indexed id, uint256 amount ); function setOperator(address spender, bool approved) external returns (bool); function transferFrom(address from, address to, uint256 id, uint256 amount) external returns (bool); function balanceOf(address owner, uint256 id) external view returns (uint256); } ``` --- # /docs/market-making # Market Making on Somnia Markets What is different about quoting this venue. Somnia Markets runs **spot** order books, **binary** prediction markets, and **perps**, all on the same on-chain order-book engine; this guide covers quoting the **binary prediction markets**. It assumes you already run market-making systems and skips the generalities — only the mechanics that will surprise you or cost you money if learned in production. Everything below is specific to binary markets (`marketType() == BINARY_SINGLE_BOOK`), which is every prediction market live today; future kinds (multi-outcome, dual-book) carry a different `marketType()` and will not share these semantics — branch on the tag, never assume. Full contract mechanics are in [Raw Integration](./RawIntegration.md); the SDK (`@somnia-chain/markets-sdk`) wraps all of it if you're in a JS runtime. ## One book per binary market; `userData` selects the side, and NO is price-inverted Each binary market runs a **single** order book crossing all four order kinds. `userData` is not a client tag field — it selects the book half (`0` = YES, `1` = NO; anything else reverts `InvalidUserData`), so tag quote generations off `orderId` (unique per pool) instead. NO orders are submitted at the YES complement: `price = oneCollateral − noPrice`, with `oneCollateral = 10 ** collateral.decimals()`. All prices must sit strictly inside `(0, oneCollateral)`, tick/lot/min from `getOrderBookParameters()` at runtime. The kind matrix — note the inversion means `isBid` does **not** mean "buy" on the NO book: | `userData` | `isBid = true` | `isBid = false` | |---|---|---| | `0` | BUY_YES | SELL_YES | | `1` | SELL_NO | BUY_NO | ## You can quote two-sided with zero inventory A resting BUY_YES at *p* and BUY_NO at *1 − p* is a full two-sided quote: when either crosses an incoming opposite buyer the pool **mints a fresh pair** (`MINT_A_PAIR`) — collateral in, one side to each buyer, no inventory required. `SELL_YES × SELL_NO` burns a pair symmetrically. This changes the standard prediction-market bootstrap: you never need to pre-mint outcome tokens to open a market, and your quoting book can stay entirely collateral-denominated. Deliberate inventory moves go through `mintCompleteSet` / `mergeCompleteSet` (1 collateral ⇄ 1 YES + 1 NO, always), and `redeem` pays the winning side 1:1 at resolution, less the venue's frozen settlement fee if it configured one (0.5 each on void, never fee'd). Price the venue's fees into your spread: maker/taker rates are **per-venue** and frozen into the pool at market creation — read them once per market from `getBinaryPoolParams()` (`makerFeeBpsTimes1k` / `takerFeeBpsTimes1k` / `settlementFeeBpsTimes1k`; basis-points × 1000). The per-order builder fee only applies if you opt a builder in with `approveBuilder` — as an MM placing your own orders you simply pass `(address(0), 0)` and never pay it. ## Escrow: BUYs lock collateral, SELLs lock tokens, refunds recycle via the vault Placement escrows worst-case value up front: BUYs lock collateral (vault-balance-first, then wallet `transferFrom` — one approval per pool), SELLs lock the ERC-6909 outcome tokens themselves (one `setOperator(pool, true)` on the singleton covers every market). Two flows matter for float accounting: - **Taker surplus and cancel/reduce refunds credit your pool vault balance**, not your wallet — and since placement is vault-first, a quoting loop recycles them automatically. `withdraw` only when rebalancing across pools. - **Fill proceeds deliver wallet-first with vault fallback.** Alert on `PayoutFallbackToVault` or your reconciliation will drift. ## Expiry is mandatory — make it your dead man's switch Every order carries `expireTimestampNs` (future unix-ns; there is no "no expiry" sentinel). Set it just past your requote interval rather than far-future: a crashed or partitioned quoter's ladder then ages off the book on its own. Note expired orders are unfillable **immediately**, but the `OrderExpired` event is lazy (fires on later cleanup, not at expiry) — prune your own book model on the timestamp, not the event. ## Self-match: pick your side, and handle `OrderCancelledSelfMatch` With `SelfMatchingOption.CancelMaker`, the matcher erases your same-owner resting maker and emits `OrderCancelledSelfMatch(orderId)` — an event-materialized book (yours, and every other participant's) must treat it as a removal or it carries a phantom order afterward. With `CancelTaker` the incoming order is rejected instead (`success == false`, no revert). Details in [the sharp edges](./RawIntegration.md#the-sharp-edges). ## Rejections return `(false, 0)` — they don't revert A PostOnly that would cross, a FillOrKill that can't fill fully, and an IOC that fills nothing all return `success == false` from a *successful* transaction. A loop that only handles reverts will silently under-quote. Conversely `cancelOrder` / `reduceOrder` **do** revert on already-terminal orders — check state before cancelling or you're burning a tx slot in your re-center path. ## Markets die on schedule — and respawn Every market has a hard `expiry`; venue rolling series (e.g. hourly up/down) spawn a successor each interval. Placement reverts `TradingNotActive` the moment the market leaves Trading; cancels keep working through `Locked`. Anything resting at lock is free option value to whoever knows the outcome first — pull quotes ahead of expiry, sweep after resolution (`redeem` winners — note a resolved market's winning payout is net of the venue's frozen settlement fee, if any — `mergeCompleteSet` balanced pairs), and watch `BinaryMarketsModule`'s `MarketCreated` to be resting in the successor the moment it opens. ## Infrastructure and latency The public Somnia RPC nodes — `https://api.infra.mainnet.somnia.network/` (mainnet) and `https://api.infra.testnet.somnia.network/` (testnet) — are hosted in **GCP `europe-west4` (Netherlands)** and have **no rate limit**: host your quoting infrastructure in or near that region and submit transactions / read state as fast as your strategy requires. There is no separate market-data service to rate-limit you on this venue — market data *is* the chain, materialized from the event stream ([Raw Integration](./RawIntegration.md#materialize-the-order-book-from-events)). A 24/7 operation should keep backup RPCs configured (the authoritative provider list, including WSS endpoints, is at [Somnia network-info](https://docs.somnia.network/developer/network-info)), fail over on repeated errors, and backfill any missed log range before trusting its book model again. ## No session keys — atomicity comes from owning a contract `BinaryPool` has no per-user operator approvals (the `*For` entrypoints are admin-allowlist only), so the operator/fund key split you may run elsewhere doesn't apply. The equivalent isolation *and* atomic multi-order operations come from making your own contract the order owner: it places a full ladder or cancel-and-replaces both sides in one all-or-nothing transaction, and the book never sees a half-updated ladder. --- # /docs/api **@somnia-chain/markets-sdk** *** # @somnia-chain/markets-sdk ## Modules - [index](index/README.md) - [react](react/README.md) --- # /docs/api/index [**@somnia-chain/markets-sdk**](../README.md) *** [@somnia-chain/markets-sdk](../README.md) / index # index ## Classes - [SomniaMarkets](classes/SomniaMarkets.md) ## Interfaces - [SomniaMarketsAddresses](interfaces/SomniaMarketsAddresses.md) - [PriceFeedConfig](interfaces/PriceFeedConfig.md) - [FixedFees](interfaces/FixedFees.md) - [ClientConfig](interfaces/ClientConfig.md) - [BinaryOrderQuote](interfaces/BinaryOrderQuote.md) - [MarketStats24h](interfaces/MarketStats24h.md) - [BinaryPositionPnL](interfaces/BinaryPositionPnL.md) - [PnLEvent](interfaces/PnLEvent.md) - [ClaimablePosition](interfaces/ClaimablePosition.md) - [ClaimableInput](interfaces/ClaimableInput.md) - [SetAdapterApprovedParams](interfaces/SetAdapterApprovedParams.md) - [GovernanceAdmin](interfaces/GovernanceAdmin.md) - [DecodedOutcomeId](interfaces/DecodedOutcomeId.md) - [WatchHandle](interfaces/WatchHandle.md) - [OracleHubAdminConfig](interfaces/OracleHubAdminConfig.md) - [OrderBookParams](interfaces/OrderBookParams.md) - [CreateMarketCreatorParams](interfaces/CreateMarketCreatorParams.md) - [CreateMarketCreatorResult](interfaces/CreateMarketCreatorResult.md) - [FundMarketCreatorParams](interfaces/FundMarketCreatorParams.md) - [RegisterSeriesParams](interfaces/RegisterSeriesParams.md) - [TriggerRollParams](interfaces/TriggerRollParams.md) - [SetReactivityGasParamsParams](interfaces/SetReactivityGasParamsParams.md) - [ArmFirstRollParams](interfaces/ArmFirstRollParams.md) - [ReclaimOracleCreditParams](interfaces/ReclaimOracleCreditParams.md) - [MarketCreatorOnchain](interfaces/MarketCreatorOnchain.md) - [SeriesOnchain](interfaces/SeriesOnchain.md) - [MarketCreatorAdmin](interfaces/MarketCreatorAdmin.md) - [MachineryStep](interfaces/MachineryStep.md) - [MarketTypePlugin](interfaces/MarketTypePlugin.md) - [OperatorAdminConfig](interfaces/OperatorAdminConfig.md) - [VenueConfigInput](interfaces/VenueConfigInput.md) - [RegisterOperatorParams](interfaces/RegisterOperatorParams.md) - [RegisterOperatorResult](interfaces/RegisterOperatorResult.md) - [UpdateOperatorParams](interfaces/UpdateOperatorParams.md) - [SetOperatorEnabledParams](interfaces/SetOperatorEnabledParams.md) - [TransferOperatorOwnershipParams](interfaces/TransferOperatorOwnershipParams.md) - [AcceptOperatorOwnershipParams](interfaces/AcceptOperatorOwnershipParams.md) - [CreateVenueParams](interfaces/CreateVenueParams.md) - [CreateVenueResult](interfaces/CreateVenueResult.md) - [UpdateVenueParams](interfaces/UpdateVenueParams.md) - [SetVenueEnabledParams](interfaces/SetVenueEnabledParams.md) - [OperatorAdmin](interfaces/OperatorAdmin.md) - [BinaryVenueParams](interfaces/BinaryVenueParams.md) - [QuestionSourceInput](interfaces/QuestionSourceInput.md) - [QuestionIntervalInput](interfaces/QuestionIntervalInput.md) - [ValidAnswersInput](interfaces/ValidAnswersInput.md) - [QuestionDefinitionInput](interfaces/QuestionDefinitionInput.md) - [HubQuestionState](interfaces/HubQuestionState.md) - [HubStatus](interfaces/HubStatus.md) - [ScheduleQuestionParams](interfaces/ScheduleQuestionParams.md) - [ScheduleQuestionResult](interfaces/ScheduleQuestionResult.md) - [WithdrawParams](interfaces/WithdrawParams.md) - [WithdrawMyCreditParams](interfaces/WithdrawMyCreditParams.md) - [FundHubParams](interfaces/FundHubParams.md) - [SetHubGasParams](interfaces/SetHubGasParams.md) - [SetHubDrainParams](interfaces/SetHubDrainParams.md) - [EnableHubReactivityParams](interfaces/EnableHubReactivityParams.md) - [OracleHubAdmin](interfaces/OracleHubAdmin.md) - [PreflightResult](interfaces/PreflightResult.md) - [OperatorPreflightInput](interfaces/OperatorPreflightInput.md) - [VenuePreflightInput](interfaces/VenuePreflightInput.md) - [HubPreflightInput](interfaces/HubPreflightInput.md) - [CreateQuotePreflightInput](interfaces/CreateQuotePreflightInput.md) - [MarketCreatorPreflightInput](interfaces/MarketCreatorPreflightInput.md) - [SeriesPreflightInput](interfaces/SeriesPreflightInput.md) - [RollPreflightInput](interfaces/RollPreflightInput.md) - [PriceWatchHandle](interfaces/PriceWatchHandle.md) - [LivePrice](interfaces/LivePrice.md) - [PricePoint](interfaces/PricePoint.md) - [PriceCandle](interfaces/PriceCandle.md) - [PriceFeedInfo](interfaces/PriceFeedInfo.md) - [PoolBindingRecord](interfaces/PoolBindingRecord.md) - [IndexedPool](interfaces/IndexedPool.md) - [BinaryOrderBook](interfaces/BinaryOrderBook.md) - [SpotOrderBook](interfaces/SpotOrderBook.md) - [PerpStateOnchain](interfaces/PerpStateOnchain.md) - [PerpPosition](interfaces/PerpPosition.md) - [MarginAccount](interfaces/MarginAccount.md) - [AccountHealth](interfaces/AccountHealth.md) - [MarketOnchain](interfaces/MarketOnchain.md) - [MarketOnchainSources](interfaces/MarketOnchainSources.md) - [Erc20Metadata](interfaces/Erc20Metadata.md) - [BalanceQuery](interfaces/BalanceQuery.md) - [ContractMeta](interfaces/ContractMeta.md) - [SomniaMarketsClient](interfaces/SomniaMarketsClient.md) - [TailStatus](interfaces/TailStatus.md) - [LiveFill](interfaces/LiveFill.md) - [LiveOrder](interfaces/LiveOrder.md) - [BookLevel](interfaces/BookLevel.md) - [MarketCreatorInfo](interfaces/MarketCreatorInfo.md) - [SystemInfo](interfaces/SystemInfo.md) - [TraderConfig](interfaces/TraderConfig.md) - [TxResult](interfaces/TxResult.md) - [OrderFill](interfaces/OrderFill.md) - [PlaceOrderResult](interfaces/PlaceOrderResult.md) - [PlaceOrderParams](interfaces/PlaceOrderParams.md) - [ApproveBuilderParams](interfaces/ApproveBuilderParams.md) - [CancelOrderParams](interfaces/CancelOrderParams.md) - [ReduceOrderParams](interfaces/ReduceOrderParams.md) - [CancelExpiredOrdersParams](interfaces/CancelExpiredOrdersParams.md) - [SweepExpiredAtLevelParams](interfaces/SweepExpiredAtLevelParams.md) - [PlaceSpotOrderParams](interfaces/PlaceSpotOrderParams.md) - [PlacePerpOrderParams](interfaces/PlacePerpOrderParams.md) - [DepositMarginParams](interfaces/DepositMarginParams.md) - [WithdrawMarginParams](interfaces/WithdrawMarginParams.md) - [WithdrawVaultParams](interfaces/WithdrawVaultParams.md) - [SetPerpLeverageParams](interfaces/SetPerpLeverageParams.md) - [PlaceSpotStopOrderParams](interfaces/PlaceSpotStopOrderParams.md) - [CancelStopOrderParams](interfaces/CancelStopOrderParams.md) - [MintSetParams](interfaces/MintSetParams.md) - [BurnSetParams](interfaces/BurnSetParams.md) - [RedeemParams](interfaces/RedeemParams.md) - [RedeemAuthorization](interfaces/RedeemAuthorization.md) - [SignRedeemAuthParams](interfaces/SignRedeemAuthParams.md) - [RedeemForParams](interfaces/RedeemForParams.md) - [RedeemDirectParams](interfaces/RedeemDirectParams.md) - [ClaimOwedParams](interfaces/ClaimOwedParams.md) - [FinalizeMarketParams](interfaces/FinalizeMarketParams.md) - [ReleasePoolParams](interfaces/ReleasePoolParams.md) - [SettlementRecord](interfaces/SettlementRecord.md) - [Permit2TransferFrom](interfaces/Permit2TransferFrom.md) - [RouterMintBase](interfaces/RouterMintBase.md) - [MintSetNativeParams](interfaces/MintSetNativeParams.md) - [MintSetPermit2Params](interfaces/MintSetPermit2Params.md) - [RedeemNativeParams](interfaces/RedeemNativeParams.md) - [FaucetParams](interfaces/FaucetParams.md) - [ResolveParams](interfaces/ResolveParams.md) - [VoidMarketParams](interfaces/VoidMarketParams.md) - [Trader](interfaces/Trader.md) - [CreateOrderParams](interfaces/CreateOrderParams.md) - [UnifiedMarket](interfaces/UnifiedMarket.md) - [UnifiedOrderBook](interfaces/UnifiedOrderBook.md) - [UnifiedTrade](interfaces/UnifiedTrade.md) - [UnifiedOrder](interfaces/UnifiedOrder.md) - [UnifiedBalance](interfaces/UnifiedBalance.md) - [UnifiedBalances](interfaces/UnifiedBalances.md) - [UnifiedFundingRate](interfaces/UnifiedFundingRate.md) - [UnifiedPosition](interfaces/UnifiedPosition.md) - [UnifiedPrice](interfaces/UnifiedPrice.md) - [Tradable](interfaces/Tradable.md) - [BinaryPnl](interfaces/BinaryPnl.md) - [BinaryPnlFill](interfaces/BinaryPnlFill.md) ## Type Aliases - [OutcomeIdx](type-aliases/OutcomeIdx.md) - [WatchStatus](type-aliases/WatchStatus.md) - [PriceCandleResolution](type-aliases/PriceCandleResolution.md) - [PriceFeedStatus](type-aliases/PriceFeedStatus.md) - [MarketType](type-aliases/MarketType.md) - [BaseMarket](type-aliases/BaseMarket.md) - [SpotMarket](type-aliases/SpotMarket.md) - [PerpMarket](type-aliases/PerpMarket.md) - [BinaryMarket](type-aliases/BinaryMarket.md) - [Market](type-aliases/Market.md) - [BinaryMarketFilter](type-aliases/BinaryMarketFilter.md) - [BinaryMarketOrderBy](type-aliases/BinaryMarketOrderBy.md) - [MarketFees](type-aliases/MarketFees.md) - [SpotMarketFilter](type-aliases/SpotMarketFilter.md) - [MarketStatusUpdate](type-aliases/MarketStatusUpdate.md) - [PerpMarketFilter](type-aliases/PerpMarketFilter.md) - [LiveBinaryMarketsFilter](type-aliases/LiveBinaryMarketsFilter.md) - [PastBinaryMarketsOptions](type-aliases/PastBinaryMarketsOptions.md) - [Candle](type-aliases/Candle.md) - [OutcomeBalances](type-aliases/OutcomeBalances.md) - [OpenOrder](type-aliases/OpenOrder.md) - [OrdersOptions](type-aliases/OrdersOptions.md) - [OrderRow](type-aliases/OrderRow.md) - [PortfolioMarket](type-aliases/PortfolioMarket.md) - [PortfolioPosition](type-aliases/PortfolioPosition.md) - [PortfolioOrder](type-aliases/PortfolioOrder.md) - [PortfolioTrade](type-aliases/PortfolioTrade.md) - [Portfolio](type-aliases/Portfolio.md) - [PortfolioOptions](type-aliases/PortfolioOptions.md) - [FillRow](type-aliases/FillRow.md) - [FillsOptions](type-aliases/FillsOptions.md) - [IndexerSyncStatus](type-aliases/IndexerSyncStatus.md) - [SpotPortfolioMarket](type-aliases/SpotPortfolioMarket.md) - [SpotPortfolioOrder](type-aliases/SpotPortfolioOrder.md) - [SpotPortfolioTrade](type-aliases/SpotPortfolioTrade.md) - [StopOrderStatus](type-aliases/StopOrderStatus.md) - [SpotStopOrder](type-aliases/SpotStopOrder.md) - [SpotPortfolio](type-aliases/SpotPortfolio.md) - [PerpPortfolioMarket](type-aliases/PerpPortfolioMarket.md) - [PerpPortfolioOrder](type-aliases/PerpPortfolioOrder.md) - [PerpPortfolioTrade](type-aliases/PerpPortfolioTrade.md) - [PerpPortfolio](type-aliases/PerpPortfolio.md) - [IndexedOperator](type-aliases/IndexedOperator.md) - [IndexedVenue](type-aliases/IndexedVenue.md) - [OperatorFilter](type-aliases/OperatorFilter.md) - [IndexedSeries](type-aliases/IndexedSeries.md) - [IndexedMarketCreator](type-aliases/IndexedMarketCreator.md) - [IndexedOracleAdapter](type-aliases/IndexedOracleAdapter.md) - [IndexedMarketCreatorPolicy](type-aliases/IndexedMarketCreatorPolicy.md) - [MarketCreatorFilter](type-aliases/MarketCreatorFilter.md) - [RouterActionKind](type-aliases/RouterActionKind.md) - [RouterActionRecord](type-aliases/RouterActionRecord.md) - [MarketResolutionEvent](type-aliases/MarketResolutionEvent.md) - [MarketReferenceLink](type-aliases/MarketReferenceLink.md) - [OracleAnswer](type-aliases/OracleAnswer.md) - [OracleQuestionRecord](type-aliases/OracleQuestionRecord.md) - [OperatorHubAccountRecord](type-aliases/OperatorHubAccountRecord.md) - [OracleBindRecord](type-aliases/OracleBindRecord.md) - [OracleCallbackRecord](type-aliases/OracleCallbackRecord.md) - [ProtocolFeeRecord](type-aliases/ProtocolFeeRecord.md) - [BuilderFeeRecord](type-aliases/BuilderFeeRecord.md) - [SettlementFeeRecord](type-aliases/SettlementFeeRecord.md) - [BuilderApproval](type-aliases/BuilderApproval.md) - [VaultPayoutFallback](type-aliases/VaultPayoutFallback.md) - [FundingPayment](type-aliases/FundingPayment.md) - [MarginEvent](type-aliases/MarginEvent.md) - [LiquidationEvent](type-aliases/LiquidationEvent.md) - [FundingRateUpdate](type-aliases/FundingRateUpdate.md) - [OpenInterestSnapshot](type-aliases/OpenInterestSnapshot.md) - [MarginStatus](type-aliases/MarginStatus.md) - [TailMode](type-aliases/TailMode.md) - [BinarySide](type-aliases/BinarySide.md) - [BinaryFillKind](type-aliases/BinaryFillKind.md) - [OrderStatus](type-aliases/OrderStatus.md) - [BinaryMarketStatus](type-aliases/BinaryMarketStatus.md) - [LiveMarket](type-aliases/LiveMarket.md) - [SomniaMarketsConfig](type-aliases/SomniaMarketsConfig.md) - [UnifiedMarketType](type-aliases/UnifiedMarketType.md) - [UnifiedOrderStatus](type-aliases/UnifiedOrderStatus.md) - [UnifiedOHLCV](type-aliases/UnifiedOHLCV.md) ## Variables - [SOMNIA\_TESTNET\_PRICE\_FEED](variables/SOMNIA_TESTNET_PRICE_FEED.md) - [DEFAULT\_FEES](variables/DEFAULT_FEES.md) - [oracleHubAbi](variables/oracleHubAbi.md) - [oracleHubEventsAbi](variables/oracleHubEventsAbi.md) - [binaryMarketTypePlugin](variables/binaryMarketTypePlugin.md) - [MARKET\_TYPE\_PLUGINS](variables/MARKET_TYPE_PLUGINS.md) - [binaryModuleWriteAbi](variables/binaryModuleWriteAbi.md) - [binaryModuleReadAbi](variables/binaryModuleReadAbi.md) - [MARKET\_TYPE\_BINARY\_V1](variables/MARKET_TYPE_BINARY_V1.md) - [QUESTION\_SOURCE\_TYPE](variables/QUESTION_SOURCE_TYPE.md) - [ANSWER\_TYPE](variables/ANSWER_TYPE.md) - [ZERO\_ADDRESS](variables/ZERO_ADDRESS.md) - [HUB\_MIN\_FREE\_BALANCE\_WEI](variables/HUB_MIN_FREE_BALANCE_WEI.md) - [MIN\_SERIES\_INTERVAL\_SEC](variables/MIN_SERIES_INTERVAL_SEC.md) - [PRICE\_FEED\_DECIMALS](variables/PRICE_FEED_DECIMALS.md) - [PRICE\_RESOLUTION\_SECONDS](variables/PRICE_RESOLUTION_SECONDS.md) - [CANDLE\_INTERVALS](variables/CANDLE_INTERVALS.md) - [MARGIN\_STATUS](variables/MARGIN_STATUS.md) - [binarySettlementAbi](variables/binarySettlementAbi.md) - [erc6909Abi](variables/erc6909Abi.md) - [DECIMALS](variables/DECIMALS.md) - [ORDER\_KIND\_SIDE](variables/ORDER_KIND_SIDE.md) - [ORDER\_TYPE](variables/ORDER_TYPE.md) - [TIMEFRAMES](variables/TIMEFRAMES.md) ## Functions - [quoteBinaryOrderOverBook](functions/quoteBinaryOrderOverBook.md) - [marketStats24hFromCandles](functions/marketStats24hFromCandles.md) - [pnlEventsFor](functions/pnlEventsFor.md) - [computePositionPnL](functions/computePositionPnL.md) - [estPayoutFor](functions/estPayoutFor.md) - [claimableFrom](functions/claimableFrom.md) - [outcomeId](functions/outcomeId.md) - [decodeOutcomeId](functions/decodeOutcomeId.md) - [marketKey](functions/marketKey.md) - [getMarketTypePlugin](functions/getMarketTypePlugin.md) - [listMarketTypePlugins](functions/listMarketTypePlugins.md) - [decodeBinaryVenueFeeParams](functions/decodeBinaryVenueFeeParams.md) - [getSchedulingCost](functions/getSchedulingCost.md) - [earmarkedOf](functions/earmarkedOf.md) - [creditOf](functions/creditOf.md) - [outstandingOf](functions/outstandingOf.md) - [withdrawableOf](functions/withdrawableOf.md) - [resolveReserve](functions/resolveReserve.md) - [quoteCreateMarketValue](functions/quoteCreateMarketValue.md) - [preflightOperator](functions/preflightOperator.md) - [preflightVenue](functions/preflightVenue.md) - [preflightHub](functions/preflightHub.md) - [preflightCreateQuote](functions/preflightCreateQuote.md) - [preflightMarketCreator](functions/preflightMarketCreator.md) - [preflightSeries](functions/preflightSeries.md) - [preflightRoll](functions/preflightRoll.md) - [preflightChain](functions/preflightChain.md) - [isLocalPrecompileUnavailable](functions/isLocalPrecompileUnavailable.md) - [isBinaryMarket](functions/isBinaryMarket.md) - [isSpotMarket](functions/isSpotMarket.md) - [isPerpMarket](functions/isPerpMarket.md) - [countOrders](functions/countOrders.md) - [countUserFills](functions/countUserFills.md) - [listMarketCreators](functions/listMarketCreators.md) - [getMarketCreator](functions/getMarketCreator.md) - [listOracleAdapters](functions/listOracleAdapters.md) - [getOracleAdapter](functions/getOracleAdapter.md) - [listSeries](functions/listSeries.md) - [getRouterActions](functions/getRouterActions.md) - [getMarketResolution](functions/getMarketResolution.md) - [getOpeningPrices](functions/getOpeningPrices.md) - [getOracleQuestion](functions/getOracleQuestion.md) - [listOracleQuestions](functions/listOracleQuestions.md) - [getOperatorHubAccount](functions/getOperatorHubAccount.md) - [listOperatorHubAccounts](functions/listOperatorHubAccounts.md) - [listOracleBinds](functions/listOracleBinds.md) - [listOracleCallbacks](functions/listOracleCallbacks.md) - [listProtocolFees](functions/listProtocolFees.md) - [listBuilderFees](functions/listBuilderFees.md) - [listSettlementFees](functions/listSettlementFees.md) - [listBuilderApprovals](functions/listBuilderApprovals.md) - [getVaultPayoutFallbacks](functions/getVaultPayoutFallbacks.md) - [getFundingPayments](functions/getFundingPayments.md) - [getMarginEvents](functions/getMarginEvents.md) - [getLiquidations](functions/getLiquidations.md) - [getFundingRateHistory](functions/getFundingRateHistory.md) - [getOpenInterestHistory](functions/getOpenInterestHistory.md) - [getMarketByPool](functions/getMarketByPool.md) - [getPoolBindings](functions/getPoolBindings.md) - [getPool](functions/getPool.md) - [getAccountHealth](functions/getAccountHealth.md) - [getLiquidationPrice](functions/getLiquidationPrice.md) - [getVaultBalance](functions/getVaultBalance.md) - [getPoolCreator](functions/getPoolCreator.md) - [getFreePools](functions/getFreePools.md) - [sideOfKind](functions/sideOfKind.md) - [fillKind](functions/fillKind.md) - [toHuman](functions/toHuman.md) - [toHumanString](functions/toHumanString.md) - [fromHuman](functions/fromHuman.md) - [priceToProbability](functions/priceToProbability.md) - [probabilityToPrice](functions/probabilityToPrice.md) - [binaryFillsFor](functions/binaryFillsFor.md) - [computeBinaryPnl](functions/computeBinaryPnl.md) ## References ### GovernanceAdminConfig Renames and re-exports [OracleHubAdminConfig](interfaces/OracleHubAdminConfig.md) *** ### MarketCreatorAdminConfig Renames and re-exports [OracleHubAdminConfig](interfaces/OracleHubAdminConfig.md) --- # /docs/api/index/classes/SomniaMarkets [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SomniaMarkets # Class: SomniaMarkets Defined in: [unified/exchange.ts:100](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L100) ## Constructors ### Constructor > **new SomniaMarkets**(`config`): `SomniaMarkets` Defined in: [unified/exchange.ts:141](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L141) #### Parameters ##### config [`SomniaMarketsConfig`](../type-aliases/SomniaMarketsConfig.md) #### Returns `SomniaMarkets` ## Properties ### client > `readonly` **client**: [`SomniaMarketsClient`](../interfaces/SomniaMarketsClient.md) Defined in: [unified/exchange.ts:102](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L102) The native engine — bigint-exact, address-keyed. The escape hatch. *** ### markets > **markets**: `Record`\<`string`, [`UnifiedMarket`](../interfaces/UnifiedMarket.md)\> = `{}` Defined in: [unified/exchange.ts:104](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L104) Unified markets keyed by MARKET symbol (populated by loadMarkets). *** ### symbols > **symbols**: `string`[] = `[]` Defined in: [unified/exchange.ts:106](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L106) All market symbols (populated by loadMarkets). *** ### has > `readonly` **has**: `object` Defined in: [unified/exchange.ts:108](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L108) Capability map — which verbs this venue supports. #### fetchMarkets > `readonly` **fetchMarkets**: `true` = `true` #### fetchOrderBook > `readonly` **fetchOrderBook**: `true` = `true` #### fetchTrades > `readonly` **fetchTrades**: `true` = `true` #### fetchOHLCV > `readonly` **fetchOHLCV**: `true` = `true` #### fetchBalance > `readonly` **fetchBalance**: `true` = `true` #### fetchOpenOrders > `readonly` **fetchOpenOrders**: `true` = `true` #### fetchMyTrades > `readonly` **fetchMyTrades**: `true` = `true` #### fetchStatus > `readonly` **fetchStatus**: `true` = `true` #### createOrder > `readonly` **createOrder**: `true` = `true` #### cancelOrder > `readonly` **cancelOrder**: `true` = `true` #### watchOrderBook > `readonly` **watchOrderBook**: `true` = `true` #### watchTrades > `readonly` **watchTrades**: `true` = `true` #### watchOrders > `readonly` **watchOrders**: `true` = `true` #### watchMyTrades > `readonly` **watchMyTrades**: `true` = `true` #### fetchPositions > `readonly` **fetchPositions**: `true` = `true` #### fetchFundingRate > `readonly` **fetchFundingRate**: `true` = `true` #### watchPrice > `readonly` **watchPrice**: `true` = `true` #### fetchPrice > `readonly` **fetchPrice**: `true` = `true` #### fetchPriceOHLCV > `readonly` **fetchPriceOHLCV**: `true` = `true` ## Accessors ### trader #### Get Signature > **get** **trader**(): [`Trader`](../interfaces/Trader.md) Defined in: [unified/exchange.ts:152](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L152) The raw write tier bound to this exchange's signer — bigint-exact `placeOrder`/`mintSet`/`faucet`/… for anything the unified verbs don't cover. Built lazily; throws if no signer was configured. ##### Returns [`Trader`](../interfaces/Trader.md) *** ### walletAddress #### Get Signature > **get** **walletAddress**(): `` `0x${string}` `` \| `undefined` Defined in: [unified/exchange.ts:158](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L158) The authenticated wallet address, if a signer was configured. ##### Returns `` `0x${string}` `` \| `undefined` ## Methods ### loadMarkets() > **loadMarkets**(`reload?`): `Promise`\<`Record`\<`string`, [`UnifiedMarket`](../interfaces/UnifiedMarket.md)\>\> Defined in: [unified/exchange.ts:177](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L177) Load (or reload) the market registry: every market as a unified, symbol-keyed market object. Call once before anything symbol-based. #### Parameters ##### reload? `boolean` = `false` #### Returns `Promise`\<`Record`\<`string`, [`UnifiedMarket`](../interfaces/UnifiedMarket.md)\>\> *** ### market() > **market**(`ref`): [`Tradable`](../interfaces/Tradable.md) Defined in: [unified/exchange.ts:294](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L294) Resolve any handle (symbol, tradable symbol, pool/market address, market id) to its tradable. Requires loadMarkets(). #### Parameters ##### ref `string` #### Returns [`Tradable`](../interfaces/Tradable.md) *** ### priceToPrecision() > **priceToPrecision**(`ref`, `price`): `number` Defined in: [unified/exchange.ts:300](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L300) Snap a price to the market's tick grid (rounds down; binary prices are also clamped inside (0, 1)). Use before createOrder with computed prices. #### Parameters ##### ref `string` ##### price `number` #### Returns `number` *** ### amountToPrecision() > **amountToPrecision**(`ref`, `amount`): `number` Defined in: [unified/exchange.ts:312](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L312) Snap an amount to the market's lot grid (rounds down). #### Parameters ##### ref `string` ##### amount `number` #### Returns `number` *** ### fetchMarkets() > **fetchMarkets**(): `Promise`\<[`UnifiedMarket`](../interfaces/UnifiedMarket.md)[]\> Defined in: [unified/exchange.ts:321](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L321) #### Returns `Promise`\<[`UnifiedMarket`](../interfaces/UnifiedMarket.md)[]\> *** ### fetchOrderBook() > **fetchOrderBook**(`ref`, `limit?`): `Promise`\<[`UnifiedOrderBook`](../interfaces/UnifiedOrderBook.md)\> Defined in: [unified/exchange.ts:371](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L371) One-shot book read from the contract (head-fresh; no watch needed). For a continuously-current zero-round-trip book, use [watchOrderBook](#watchorderbook). #### Parameters ##### ref `string` ##### limit? `number` = `10` #### Returns `Promise`\<[`UnifiedOrderBook`](../interfaces/UnifiedOrderBook.md)\> *** ### fetchTrades() > **fetchTrades**(`ref`, `since?`, `limit?`): `Promise`\<[`UnifiedTrade`](../interfaces/UnifiedTrade.md)[]\> Defined in: [unified/exchange.ts:381](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L381) Recent public trades (indexer, newest first). #### Parameters ##### ref `string` ##### since? `number` ##### limit? `number` = `50` #### Returns `Promise`\<[`UnifiedTrade`](../interfaces/UnifiedTrade.md)[]\> *** ### fetchOHLCV() > **fetchOHLCV**(`ref`, `timeframe?`, `since?`, `limit?`): `Promise`\<[`UnifiedOHLCV`](../type-aliases/UnifiedOHLCV.md)[]\> Defined in: [unified/exchange.ts:400](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L400) OHLCV candles (indexer), oldest first as [ms,o,h,l,c,vol] rows. Timeframes: 1m 5m 15m 1h 4h 1d. #### Parameters ##### ref `string` ##### timeframe? `string` = `"5m"` ##### since? `number` ##### limit? `number` = `500` #### Returns `Promise`\<[`UnifiedOHLCV`](../type-aliases/UnifiedOHLCV.md)[]\> *** ### fetchBalance() > **fetchBalance**(): `Promise`\<[`UnifiedBalances`](../interfaces/UnifiedBalances.md)\> Defined in: [unified/exchange.ts:421](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L421) Wallet balances for every currency the loaded markets use (+ native). `free === total`: funds escrowed in resting orders live in the pools, not the wallet, so they simply don't appear here. #### Returns `Promise`\<[`UnifiedBalances`](../interfaces/UnifiedBalances.md)\> *** ### fetchOpenOrders() > **fetchOpenOrders**(`ref?`): `Promise`\<[`UnifiedOrder`](../interfaces/UnifiedOrder.md)[]\> Defined in: [unified/exchange.ts:459](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L459) Open orders (indexer view — lags the chain slightly; a trading loop should prefer [watchOrders](#watchorders)). #### Parameters ##### ref? `string` #### Returns `Promise`\<[`UnifiedOrder`](../interfaces/UnifiedOrder.md)[]\> *** ### fetchMyTrades() > **fetchMyTrades**(`ref?`, `since?`, `limit?`): `Promise`\<[`UnifiedTrade`](../interfaces/UnifiedTrade.md)[]\> Defined in: [unified/exchange.ts:530](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L530) My historical trades (indexer portfolios). #### Parameters ##### ref? `string` ##### since? `number` ##### limit? `number` = `50` #### Returns `Promise`\<[`UnifiedTrade`](../interfaces/UnifiedTrade.md)[]\> *** ### fetchStatus() > **fetchStatus**(): `Promise`\<\{ `status`: `"error"` \| `"ok"`; `updated`: `number`; `info`: [`TailStatus`](../interfaces/TailStatus.md); \}\> Defined in: [unified/exchange.ts:576](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L576) Exchange health: "ok" unless a live watch lost its socket. #### Returns `Promise`\<\{ `status`: `"error"` \| `"ok"`; `updated`: `number`; `info`: [`TailStatus`](../interfaces/TailStatus.md); \}\> *** ### watchOrderBook() > **watchOrderBook**(`ref`, `limit?`): `Promise`\<[`UnifiedOrderBook`](../interfaces/UnifiedOrderBook.md)\> Defined in: [unified/exchange.ts:657](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L657) Streaming book off the local store: zero round-trips, current to the last block; each await resolves on the next book change. #### Parameters ##### ref `string` ##### limit? `number` = `10` #### Returns `Promise`\<[`UnifiedOrderBook`](../interfaces/UnifiedOrderBook.md)\> *** ### watchTrades() > **watchTrades**(`ref`, `limit?`): `Promise`\<[`UnifiedTrade`](../interfaces/UnifiedTrade.md)[]\> Defined in: [unified/exchange.ts:671](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L671) Streaming public trades (the live tape). #### Parameters ##### ref `string` ##### limit? `number` = `50` #### Returns `Promise`\<[`UnifiedTrade`](../interfaces/UnifiedTrade.md)[]\> *** ### watchOrders() > **watchOrders**(`ref`, `limit?`): `Promise`\<[`UnifiedOrder`](../interfaces/UnifiedOrder.md)[]\> Defined in: [unified/exchange.ts:690](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L690) Streaming view of MY orders on this tradable (authenticated). This is how you learn a resting order filled: its status flips to "closed". #### Parameters ##### ref `string` ##### limit? `number` = `100` #### Returns `Promise`\<[`UnifiedOrder`](../interfaces/UnifiedOrder.md)[]\> *** ### watchMyTrades() > **watchMyTrades**(`ref`, `limit?`): `Promise`\<[`UnifiedTrade`](../interfaces/UnifiedTrade.md)[]\> Defined in: [unified/exchange.ts:727](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L727) Streaming view of MY fills on this tradable (authenticated). #### Parameters ##### ref `string` ##### limit? `number` = `50` #### Returns `Promise`\<[`UnifiedTrade`](../interfaces/UnifiedTrade.md)[]\> *** ### watchPrice() > **watchPrice**(`asset`): `Promise`\<[`UnifiedPrice`](../interfaces/UnifiedPrice.md)\> Defined in: [unified/exchange.ts:770](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L770) Streaming price off the local price store: zero round-trips, current to the last pushed tick; each await resolves on the next price change. First call hydrates the ref-counted feed watch. Requires `config.priceFeed` to be set. #### Parameters ##### asset `string` #### Returns `Promise`\<[`UnifiedPrice`](../interfaces/UnifiedPrice.md)\> *** ### fetchPrice() > **fetchPrice**(`asset`): `Promise`\<[`UnifiedPrice`](../interfaces/UnifiedPrice.md) \| `null`\> Defined in: [unified/exchange.ts:782](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L782) One-shot current price (indexer HTTP read; no watch needed), or null if the feed has no observations yet. #### Parameters ##### asset `string` #### Returns `Promise`\<[`UnifiedPrice`](../interfaces/UnifiedPrice.md) \| `null`\> *** ### fetchPriceOHLCV() > **fetchPriceOHLCV**(`asset`, `timeframe?`, `since?`, `limit?`): `Promise`\<[`UnifiedOHLCV`](../type-aliases/UnifiedOHLCV.md)[]\> Defined in: [unified/exchange.ts:790](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L790) OHLC price candles (EMA oracle), oldest first as [ms,o,h,l,c,vol] rows — `vol` is the oracle update count for the bucket (NOT trade volume). Timeframes: 1m 1h 1d (aliases for the feed's M1/H1/D1). #### Parameters ##### asset `string` ##### timeframe? `string` = `"1m"` ##### since? `number` ##### limit? `number` = `500` #### Returns `Promise`\<[`UnifiedOHLCV`](../type-aliases/UnifiedOHLCV.md)[]\> *** ### createOrder() > **createOrder**(`ref`, `type`, `side`, `amount`, `price?`, `params?`): `Promise`\<[`UnifiedOrder`](../interfaces/UnifiedOrder.md)\> Defined in: [unified/exchange.ts:811](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L811) Place an order. Works identically for every market kind: the tradable symbol carries the outcome, `side` is plain buy/sell, prices and amounts are human units in the tradable's own terms (a NO price is the NO probability — the YES-terms complement is handled internally). `type: "market"` computes a crossing limit from the best opposite level ± `params.slippage` (default 1%) and sends it IOC. Resolves once mined, with fills decoded from the same round-trip. #### Parameters ##### ref `string` ##### type `"market"` \| `"limit"` ##### side `"buy"` \| `"sell"` ##### amount `number` ##### price? `number` ##### params? [`CreateOrderParams`](../interfaces/CreateOrderParams.md) = `{}` #### Returns `Promise`\<[`UnifiedOrder`](../interfaces/UnifiedOrder.md)\> *** ### cancelOrder() > **cancelOrder**(`id`, `ref`): `Promise`\<\{ `id`: `string`; `symbol`: `string`; `status`: `"canceled"`; `info`: `unknown`; \}\> Defined in: [unified/exchange.ts:919](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L919) Cancel a resting order by id (from createOrder / watchOrders). #### Parameters ##### id `string` ##### ref `string` #### Returns `Promise`\<\{ `id`: `string`; `symbol`: `string`; `status`: `"canceled"`; `info`: `unknown`; \}\> *** ### fetchFundingRate() > **fetchFundingRate**(`ref`): `Promise`\<[`UnifiedFundingRate`](../interfaces/UnifiedFundingRate.md)\> Defined in: [unified/exchange.ts:928](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L928) Live funding-rate + mark/index snapshot for a perp market (chain read). #### Parameters ##### ref `string` #### Returns `Promise`\<[`UnifiedFundingRate`](../interfaces/UnifiedFundingRate.md)\> *** ### fetchPositions() > **fetchPositions**(`refs?`): `Promise`\<[`UnifiedPosition`](../interfaces/UnifiedPosition.md)[]\> Defined in: [unified/exchange.ts:948](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L948) Open perp positions (authenticated; on-chain MarginBank reads). Pass symbols to scope; defaults to every loaded perp market. #### Parameters ##### refs? `string`[] #### Returns `Promise`\<[`UnifiedPosition`](../interfaces/UnifiedPosition.md)[]\> *** ### depositMargin() > **depositMargin**(`ref`, `amount`): `Promise`\<\{ `hash`: `string`; `info`: `unknown`; \}\> Defined in: [unified/exchange.ts:993](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L993) Deposit collateral into the perp MarginBank (human quote units, e.g. USDso). One cross-margin balance covers every perp market. #### Parameters ##### ref `string` ##### amount `number` #### Returns `Promise`\<\{ `hash`: `string`; `info`: `unknown`; \}\> *** ### withdrawMargin() > **withdrawMargin**(`ref`, `amount`): `Promise`\<\{ `hash`: `string`; `info`: `unknown`; \}\> Defined in: [unified/exchange.ts:1004](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L1004) Withdraw free collateral from the perp MarginBank (human quote units). #### Parameters ##### ref `string` ##### amount `number` #### Returns `Promise`\<\{ `hash`: `string`; `info`: `unknown`; \}\> *** ### mintSet() > **mintSet**(`ref`, `amount`): `Promise`\<\{ `hash`: `string`; `info`: `unknown`; \}\> Defined in: [unified/exchange.ts:1025](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L1025) Mint complete sets: `amount` collateral → `amount` of EVERY outcome. #### Parameters ##### ref `string` ##### amount `number` #### Returns `Promise`\<\{ `hash`: `string`; `info`: `unknown`; \}\> *** ### burnSet() > **burnSet**(`ref`, `amount`): `Promise`\<\{ `hash`: `string`; `info`: `unknown`; \}\> Defined in: [unified/exchange.ts:1032](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L1032) Burn complete sets back to collateral. #### Parameters ##### ref `string` ##### amount `number` #### Returns `Promise`\<\{ `hash`: `string`; `info`: `unknown`; \}\> *** ### redeem() > **redeem**(`ref`, `amount`): `Promise`\<\{ `hash`: `string`; `info`: `unknown`; \}\> Defined in: [unified/exchange.ts:1041](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L1041) Redeem winning outcome tokens for collateral (post-resolution). Settlement- extraction v2: module-routed by `marketId` (the winning outcome is read off the BinaryMarket contract when not resolved yet in the indexed row). #### Parameters ##### ref `string` ##### amount `number` #### Returns `Promise`\<\{ `hash`: `string`; `info`: `unknown`; \}\> *** ### close() > **close**(): `Promise`\<`void`\> Defined in: [unified/exchange.ts:1066](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L1066) Release every watch + channel this exchange holds and stop the client's live machinery. The instance stays usable for one-shot fetch calls. #### Returns `Promise`\<`void`\> --- # /docs/api/index/functions/binaryFillsFor [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / binaryFillsFor # Function: binaryFillsFor() > **binaryFillsFor**(`account`, `fills`, `decimals?`): [`BinaryPnlFill`](../interfaces/BinaryPnlFill.md)[] Defined in: [units.ts:91](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L91) Derive per-account [BinaryPnlFill](../interfaces/BinaryPnlFill.md)s from the raw [FillRow](../type-aliases/FillRow.md)s the indexer returns (as from `getUserFills`), from `account`'s perspective. Skips fills whose side/kind the indexer hasn't fully bridged (unknown side), and re-expresses the fill's price into the outcome the account traded (the book is YES-terms; a NO trade prices at `1 − yesPrice`). ## Parameters ### account `string` ### fills [`FillRow`](../type-aliases/FillRow.md)[] ### decimals? `number` = `DECIMALS` ## Returns [`BinaryPnlFill`](../interfaces/BinaryPnlFill.md)[] --- # /docs/api/index/functions/claimableFrom [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / claimableFrom # Function: claimableFrom() > **claimableFrom**(`inputs`): [`ClaimablePosition`](../interfaces/ClaimablePosition.md)[] Defined in: [derivedReads.ts:396](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L396) Filter + shape settled positions into [ClaimablePosition](../interfaces/ClaimablePosition.md)s. A position is claimable when the market is voided (both sides redeem at half) OR the position holds the winning outcome (redeem at 1 − fee). Loser-side and still-trading positions are dropped (nothing to claim). ## Parameters ### inputs [`ClaimableInput`](../interfaces/ClaimableInput.md)[] ## Returns [`ClaimablePosition`](../interfaces/ClaimablePosition.md)[] --- # /docs/api/index/functions/computeBinaryPnl [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / computeBinaryPnl # Function: computeBinaryPnl() > **computeBinaryPnl**(`fills`, `balances`, `market`): [`BinaryPnl`](../interfaces/BinaryPnl.md) Defined in: [units.ts:124](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L124) Realized + unrealized binary PnL for one account, avg-cost basis — a PURE helper (no indexer/chain dependency). `fills` are the account's own trades (from [binaryFillsFor](binaryFillsFor.md)); `balances` its current YES/NO holdings (from `getOutcomeBalances`); `market` supplies decimals + resolution state. Realized PnL accrues on sells (proceeds − avg cost of the tokens sold). Unrealized marks the remaining position: to `lastPrice` while trading, and to the settlement payout (1 for the winning outcome, 0 for the loser, 0.5 each when voided) once resolved. ## Parameters ### fills [`BinaryPnlFill`](../interfaces/BinaryPnlFill.md)[] ### balances [`OutcomeBalances`](../type-aliases/OutcomeBalances.md) ### market `Pick`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md), `"quoteDecimals"` \| `"lastPrice"` \| `"winningOutcome"` \| `"voided"`\> ## Returns [`BinaryPnl`](../interfaces/BinaryPnl.md) --- # /docs/api/index/functions/computePositionPnL [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / computePositionPnL # Function: computePositionPnL() > **computePositionPnL**(`events`, `balances`, `market`, `oneCollateral`): [`BinaryPositionPnL`](../interfaces/BinaryPositionPnL.md) Defined in: [derivedReads.ts:264](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L264) Fold a [PnLEvent](../interfaces/PnLEvent.md) stream (oldest-first) + current balances into a [BinaryPositionPnL](../interfaces/BinaryPositionPnL.md), avg-cost basis, RAW units. `oneCollateral = 10^quoteDecimals`. Prices arrive in YES terms; a NO event is re-expressed to NO terms (`oneCollateral − yesPrice`) here so the two books stay separate. ## Parameters ### events [`PnLEvent`](../interfaces/PnLEvent.md)[] ### balances #### balanceYes `bigint` #### balanceNo `bigint` ### market `Pick`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md), `"quoteDecimals"` \| `"lastPrice"` \| `"winningOutcome"` \| `"voided"`\> ### oneCollateral `bigint` ## Returns [`BinaryPositionPnL`](../interfaces/BinaryPositionPnL.md) --- # /docs/api/index/functions/countOrders [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / countOrders # Function: countOrders() > **countOrders**(`owner`, `opts?`, `indexerUrl`, `headers?`): `Promise`\<`number`\> Defined in: [query.ts:1205](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1205) Server-side COUNT of `owner`'s orders matching an [OrdersOptions](../type-aliases/OrdersOptions.md) filter (Hasura `Order_aggregate`) — so an order-history page paginates against a real total without fetching every row. Privileged `_aggregate` role (server-only), with the bounded row-count fallback on the public role. ## Parameters ### owner `string` ### opts? [`OrdersOptions`](../type-aliases/OrdersOptions.md) = `{}` ### indexerUrl `string` ### headers? `Record`\<`string`, `string`\> ## Returns `Promise`\<`number`\> --- # /docs/api/index/functions/countUserFills [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / countUserFills # Function: countUserFills() > **countUserFills**(`account`, `opts?`, `indexerUrl`, `headers?`): `Promise`\<`number`\> Defined in: [query.ts:1218](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1218) Server-side COUNT of the fills `account` participated in (maker OR taker), optionally scoped to one pool + a `since`/`until` window — a history-page total without fetching rows (Hasura `Fill_aggregate`, bounded fallback on the public role). ## Parameters ### account `string` ### opts? [`FillsOptions`](../type-aliases/FillsOptions.md) & `object` = `{}` ### indexerUrl `string` ### headers? `Record`\<`string`, `string`\> ## Returns `Promise`\<`number`\> --- # /docs/api/index/functions/creditOf [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / creditOf # Function: creditOf() > **creditOf**(`operatorId`, `hub`, `client`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:143](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L143) An operator's accrued WITHDRAWABLE surplus credit on the hub (§8e): the Σ `reserve − charged` released when resolved markets metered under their earmark. The only balance `withdraw` may draw from. Pure chain read. ## Parameters ### operatorId `number` ### hub `` `0x${string}` `` ### client ## Returns `Promise`\<`bigint`\> --- # /docs/api/index/functions/decodeBinaryVenueFeeParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / decodeBinaryVenueFeeParams # Function: decodeBinaryVenueFeeParams() > **decodeBinaryVenueFeeParams**(`feeParams`): \{ `version`: `number`; `params`: [`BinaryVenueParams`](../interfaces/BinaryVenueParams.md); \} \| `null` Defined in: [operatorReads.ts:79](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorReads.ts#L79) Decode a BINARY_V1 venue's `feeParams` bytes back into (version, rates) for display — pure/local, mirrors BinaryMarketsModule's own `abi.decode(feeParams, (uint8, BinaryVenueParams))`. Returns null if the bytes aren't exactly one version-tagged, abi-encoded `BinaryVenueParams` (192 bytes / 6 static words), e.g. an empty or non-BINARY_V1 venue. ## Parameters ### feeParams `` `0x${string}` `` ## Returns \{ `version`: `number`; `params`: [`BinaryVenueParams`](../interfaces/BinaryVenueParams.md); \} \| `null` --- # /docs/api/index/functions/decodeOutcomeId [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / decodeOutcomeId # Function: decodeOutcomeId() > **decodeOutcomeId**(`id`): [`DecodedOutcomeId`](../interfaces/DecodedOutcomeId.md) Defined in: [ids.ts:56](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/ids.ts#L56) Split an outcome id back into `{ pool, nonce, idx }` — the inverse of [outcomeId](outcomeId.md). ## Parameters ### id `bigint` ## Returns [`DecodedOutcomeId`](../interfaces/DecodedOutcomeId.md) --- # /docs/api/index/functions/earmarkedOf [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / earmarkedOf # Function: earmarkedOf() > **earmarkedOf**(`operatorId`, `hub`, `client`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:127](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L127) Native LOCKED for an operator's outstanding (bound-but-unresolved) markets (§8e). Grows by `resolveReserve()` per market at onBind, released at resolution. NEVER withdrawable (`earmarked == outstandingOf × resolveReserve`). Pure chain read. ## Parameters ### operatorId `number` ### hub `` `0x${string}` `` ### client ## Returns `Promise`\<`bigint`\> --- # /docs/api/index/functions/estPayoutFor [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / estPayoutFor # Function: estPayoutFor() > **estPayoutFor**(`input`): `bigint` Defined in: [derivedReads.ts:383](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L383) Compute the estimated payout for one settled position (raw collateral). Winner: `amount × (10_000 − feeBps) / 10_000`; voided: `amount / 2`; loser: 0. ## Parameters ### input [`ClaimableInput`](../interfaces/ClaimableInput.md) ## Returns `bigint` --- # /docs/api/index/functions/fillKind [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / fillKind # Function: fillKind() > **fillKind**(`takerSide`, `makerSide`): [`BinaryFillKind`](../type-aliases/BinaryFillKind.md) Defined in: [store.ts:165](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L165) ## Parameters ### takerSide [`BinarySide`](../type-aliases/BinarySide.md) ### makerSide [`BinarySide`](../type-aliases/BinarySide.md) ## Returns [`BinaryFillKind`](../type-aliases/BinaryFillKind.md) --- # /docs/api/index/functions/fromHuman [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / fromHuman # Function: fromHuman() > **fromHuman**(`human`, `decimals?`): `bigint` Defined in: [units.ts:28](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L28) Human amount (number or decimal string) → raw bigint at `decimals`, for the write API (`placeOrder` price/quantity, `mintSet` amount, …). Accepts a string to avoid float rounding (`fromHuman("0.1")`), or a number for convenience. ## Parameters ### human `string` \| `number` ### decimals? `number` = `DECIMALS` ## Returns `bigint` --- # /docs/api/index/functions/getAccountHealth [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getAccountHealth # Function: getAccountHealth() > **getAccountHealth**(`marginBank`, `account`, `client`): `Promise`\<[`AccountHealth`](../interfaces/AccountHealth.md)\> Defined in: [reads.ts:286](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L286) Read an account's cross-margin health from the MarginBank (`getAccountHealth` + `getMarginStatus`) in one fan-out. ## Parameters ### marginBank `` `0x${string}` `` ### account `` `0x${string}` `` ### client ## Returns `Promise`\<[`AccountHealth`](../interfaces/AccountHealth.md)\> --- # /docs/api/index/functions/getFreePools [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getFreePools # Function: getFreePools() > **getFreePools**(`creator`, `collateral`, `module`, `client`): `Promise`\<`` `0x${string}` ``[]\> Defined in: [reads.ts:532](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L532) A creator's free (finalized + released, reusable) pools for `collateral`, LIFO order (the LAST entry is popped first on the creator's next createMarket). Pure chain read (no signer). ## Parameters ### creator `` `0x${string}` `` ### collateral `` `0x${string}` `` ### module `` `0x${string}` `` ### client ## Returns `Promise`\<`` `0x${string}` ``[]\> --- # /docs/api/index/functions/getFundingPayments [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getFundingPayments # Function: getFundingPayments() > **getFundingPayments**(`account`, `opts?`, `indexerUrl`): `Promise`\<[`FundingPayment`](../type-aliases/FundingPayment.md)[]\> Defined in: [query.ts:2708](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2708) An account's funding-payment history, newest first — optionally scoped to one pool, paginated. ## Parameters ### account `string` ### opts? #### pool? `string` #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`FundingPayment`](../type-aliases/FundingPayment.md)[]\> --- # /docs/api/index/functions/getFundingRateHistory [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getFundingRateHistory # Function: getFundingRateHistory() > **getFundingRateHistory**(`pool`, `opts?`, `indexerUrl`): `Promise`\<[`FundingRateUpdate`](../type-aliases/FundingRateUpdate.md)[]\> Defined in: [query.ts:2769](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2769) A perp pool's funding-rate history, newest first — paginated. The append-only counterpart to the overwrite-only `PerpMarket.fundingRate`. ## Parameters ### pool `string` ### opts? #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`FundingRateUpdate`](../type-aliases/FundingRateUpdate.md)[]\> --- # /docs/api/index/functions/getLiquidationPrice [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getLiquidationPrice # Function: getLiquidationPrice() > **getLiquidationPrice**(`marginBank`, `pool`, `account`, `client`): `Promise`\<`bigint` \| `null`\> Defined in: [reads.ts:310](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L310) Estimated liquidation price for an account's position in one perp pool (raw quote units per whole base), or null when the account is flat in that pool. Derivation (cross-margin maintenance basis): a long is liquidated when equity falls to the maintenance requirement, i.e. when the mark drops by the account's per-unit maintenance buffer `(equity − mmReq) / size`; a short when it rises by the same. This uses the WHOLE-account equity/mmReq, so with multiple open positions it is the price at which THIS pool's move alone would trip maintenance (a conservative single-pool estimate, not a full multi-pool solve). Returns 0-floored (a price can't go negative). ## Parameters ### marginBank `` `0x${string}` `` ### pool `` `0x${string}` `` ### account `` `0x${string}` `` ### client ## Returns `Promise`\<`bigint` \| `null`\> --- # /docs/api/index/functions/getLiquidations [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getLiquidations # Function: getLiquidations() > **getLiquidations**(`opts?`, `indexerUrl`): `Promise`\<[`LiquidationEvent`](../type-aliases/LiquidationEvent.md)[]\> Defined in: [query.ts:2748](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2748) Liquidation events, newest first — filter by `account` and/or `pool`, paginate. ## Parameters ### opts? #### account? `string` #### pool? `string` #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`LiquidationEvent`](../type-aliases/LiquidationEvent.md)[]\> --- # /docs/api/index/functions/getMarginEvents [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getMarginEvents # Function: getMarginEvents() > **getMarginEvents**(`account`, `opts?`, `indexerUrl`): `Promise`\<[`MarginEvent`](../type-aliases/MarginEvent.md)[]\> Defined in: [query.ts:2729](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2729) An account's margin-account movement history (deposits/withdraws/locks), newest first — paginated. ## Parameters ### account `string` ### opts? #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`MarginEvent`](../type-aliases/MarginEvent.md)[]\> --- # /docs/api/index/functions/getMarketByPool [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getMarketByPool # Function: getMarketByPool() > **getMarketByPool**(`pool`, `indexerUrl`): `Promise`\<[`Market`](../type-aliases/Market.md) \| `null`\> Defined in: [query.ts:2813](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2813) Resolve a market by its pool address (one query; no live watch), as the discriminated [Market](../type-aliases/Market.md) union — null if no market rests on that pool. For spot/perp the pool address IS the market id, but binary markets are keyed by bytes32 marketId, so this looks them up by the `poolAddress` column. RECYCLE CAVEAT (settlement-extraction v2): a binary pool serves SUCCESSIVE markets, so several binary rows can share one `poolAddress`. This returns the NEWEST (the pool's current/latest binding). To address a specific past market of a recycled pool, key by `marketId` (or match `nonce`) instead. ## Parameters ### pool `string` ### indexerUrl `string` ## Returns `Promise`\<[`Market`](../type-aliases/Market.md) \| `null`\> --- # /docs/api/index/functions/getMarketCreator [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getMarketCreator # Function: getMarketCreator() > **getMarketCreator**(`creator`, `indexerUrl`): `Promise`\<[`IndexedMarketCreator`](../type-aliases/IndexedMarketCreator.md) \| `null`\> Defined in: [query.ts:1930](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1930) Fetch one MarketCreator by its address (null if unknown), with its nested `series`. Indexer read. ## Parameters ### creator `string` ### indexerUrl `string` ## Returns `Promise`\<[`IndexedMarketCreator`](../type-aliases/IndexedMarketCreator.md) \| `null`\> --- # /docs/api/index/functions/getMarketResolution [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getMarketResolution # Function: getMarketResolution() > **getMarketResolution**(`marketId`, `indexerUrl`): `Promise`\<\{ `events`: [`MarketResolutionEvent`](../type-aliases/MarketResolutionEvent.md)[]; `reference`: [`MarketReferenceLink`](../type-aliases/MarketReferenceLink.md) \| `null`; `closingAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; `openingAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; `oracleAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; \}\> Defined in: [query.ts:2108](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2108) Everything the indexer knows about how a market resolves: the lifecycle events, the oracle reference link, and the posted oracle answer (joined by the market's `oracleQuestionId`). Any piece may be absent (`reference`/ `oracleAnswer` null; `events` []). One round-trip. ## Parameters ### marketId `string` ### indexerUrl `string` ## Returns `Promise`\<\{ `events`: [`MarketResolutionEvent`](../type-aliases/MarketResolutionEvent.md)[]; `reference`: [`MarketReferenceLink`](../type-aliases/MarketReferenceLink.md) \| `null`; `closingAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; `openingAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; `oracleAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; \}\> --- # /docs/api/index/functions/getMarketTypePlugin [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getMarketTypePlugin # Function: getMarketTypePlugin() > **getMarketTypePlugin**(`marketType`): [`MarketTypePlugin`](../interfaces/MarketTypePlugin.md)\<`unknown`\> \| `undefined` Defined in: [marketTypes/index.ts:21](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/index.ts#L21) Resolve a market-type plugin by its bytes4 id (case-insensitive), or undefined if unregistered. ## Parameters ### marketType `` `0x${string}` `` ## Returns [`MarketTypePlugin`](../interfaces/MarketTypePlugin.md)\<`unknown`\> \| `undefined` --- # /docs/api/index/functions/getOpenInterestHistory [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getOpenInterestHistory # Function: getOpenInterestHistory() > **getOpenInterestHistory**(`pool`, `opts?`, `indexerUrl`): `Promise`\<[`OpenInterestSnapshot`](../type-aliases/OpenInterestSnapshot.md)[]\> Defined in: [query.ts:2787](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2787) A perp pool's open-interest history, newest first — paginated. ## Parameters ### pool `string` ### opts? #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`OpenInterestSnapshot`](../type-aliases/OpenInterestSnapshot.md)[]\> --- # /docs/api/index/functions/getOpeningPrices [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getOpeningPrices # Function: getOpeningPrices() > **getOpeningPrices**(`marketIds`, `indexerUrl`): `Promise`\<`Record`\<`string`, `string` \| `null`\>\> Defined in: [query.ts:2170](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2170) Batch-fetch the OPENING price (the reference-question oracle answer) for many binary markets in ONE pair of round-trips — for list views that want to show each up/down market's opening price without an N+1 fan-out. Returns a map of lowercased marketId → raw `numericValue` (or `null` when the reference has no answer yet / the market has no reference question). Format with the market's oracle price scale (see the explorer's `fmtOraclePrice`). ## Parameters ### marketIds `string`[] ### indexerUrl `string` ## Returns `Promise`\<`Record`\<`string`, `string` \| `null`\>\> --- # /docs/api/index/functions/getOperatorHubAccount [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getOperatorHubAccount # Function: getOperatorHubAccount() > **getOperatorHubAccount**(`operatorId`, `indexerUrl`): `Promise`\<[`OperatorHubAccountRecord`](../type-aliases/OperatorHubAccountRecord.md) \| `null`\> Defined in: [query.ts:2368](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2368) One operator's hub account (earmarked / credit / outstanding) by operatorId, or null. Indexer read. ## Parameters ### operatorId `string` \| `number` ### indexerUrl `string` ## Returns `Promise`\<[`OperatorHubAccountRecord`](../type-aliases/OperatorHubAccountRecord.md) \| `null`\> --- # /docs/api/index/functions/getOracleAdapter [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getOracleAdapter # Function: getOracleAdapter() > **getOracleAdapter**(`adapter`, `indexerUrl`): `Promise`\<[`IndexedOracleAdapter`](../type-aliases/IndexedOracleAdapter.md) \| `null`\> Defined in: [query.ts:1964](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1964) Fetch one oracle adapter by its address (null if unknown). Indexer read. ## Parameters ### adapter `string` ### indexerUrl `string` ## Returns `Promise`\<[`IndexedOracleAdapter`](../type-aliases/IndexedOracleAdapter.md) \| `null`\> --- # /docs/api/index/functions/getOracleQuestion [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getOracleQuestion # Function: getOracleQuestion() > **getOracleQuestion**(`oracleQuestionId`, `indexerUrl`): `Promise`\<[`OracleQuestionRecord`](../type-aliases/OracleQuestionRecord.md) \| `null`\> Defined in: [query.ts:2333](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2333) One hub-scheduled question by its oracleQuestionId, or null. Indexer read. ## Parameters ### oracleQuestionId `string` ### indexerUrl `string` ## Returns `Promise`\<[`OracleQuestionRecord`](../type-aliases/OracleQuestionRecord.md) \| `null`\> --- # /docs/api/index/functions/getPool [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getPool # Function: getPool() > **getPool**(`address`, `indexerUrl`): `Promise`\<[`IndexedPool`](../interfaces/IndexedPool.md) \| `null`\> Defined in: [query.ts:2897](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2897) One pool's aggregate row by address — null if the indexer has never seen a MarketCreated on it. ## Parameters ### address `string` ### indexerUrl `string` ## Returns `Promise`\<[`IndexedPool`](../interfaces/IndexedPool.md) \| `null`\> --- # /docs/api/index/functions/getPoolBindings [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getPoolBindings # Function: getPoolBindings() > **getPoolBindings**(`pool`, `indexerUrl`): `Promise`\<[`PoolBindingRecord`](../interfaces/PoolBindingRecord.md)[]\> Defined in: [query.ts:2859](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2859) A pool's full binding history, newest (highest nonce) first — every market the pool has served. The first row with `toBlock === null` is the current binding; a fully-released pool has no open row. ## Parameters ### pool `string` ### indexerUrl `string` ## Returns `Promise`\<[`PoolBindingRecord`](../interfaces/PoolBindingRecord.md)[]\> --- # /docs/api/index/functions/getPoolCreator [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getPoolCreator # Function: getPoolCreator() > **getPoolCreator**(`pool`, `module`, `client`): `Promise`\<`` `0x${string}` ``\> Defined in: [reads.ts:516](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L516) A pool's creator — its first-deploy market creator, the only party that can reuse it (settlement-extraction v2 creator-scoped pool reuse). Zero address for a pool the module never deployed. Pure chain read (no signer) — the indexer-backed equivalent is `getPool(address)`'s `creator`. ## Parameters ### pool `` `0x${string}` `` ### module `` `0x${string}` `` ### client ## Returns `Promise`\<`` `0x${string}` ``\> --- # /docs/api/index/functions/getRouterActions [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getRouterActions # Function: getRouterActions() > **getRouterActions**(`account`, `opts?`, `indexerUrl`): `Promise`\<[`RouterActionRecord`](../type-aliases/RouterActionRecord.md)[]\> Defined in: [query.ts:2030](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2030) An account's RouterMinter action history (redeem / mint / merge), newest first — optionally scoped to one market and/or kind, paginated. ## Parameters ### account `string` ### opts? #### market? `string` #### kind? [`RouterActionKind`](../type-aliases/RouterActionKind.md) #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`RouterActionRecord`](../type-aliases/RouterActionRecord.md)[]\> --- # /docs/api/index/functions/getSchedulingCost [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getSchedulingCost # Function: getSchedulingCost() > **getSchedulingCost**(`def`, `hub`, `client`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:110](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L110) The MARGINAL scheduling cost for `def` (§8c dedup pricing): 0 when the definition's canonical key is already scheduled below the bind cap (the call would dedup onto the existing question), the full oracle submission cost otherwise (new question or cap-split). Pure chain read. ## Parameters ### def [`QuestionDefinitionInput`](../interfaces/QuestionDefinitionInput.md) ### hub `` `0x${string}` `` ### client ## Returns `Promise`\<`bigint`\> --- # /docs/api/index/functions/getVaultBalance [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getVaultBalance # Function: getVaultBalance() > **getVaultBalance**(`vault`, `owner`, `token`, `client`): `Promise`\<`bigint`\> Defined in: [reads.ts:342](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L342) LIVE claimable balance an owner can withdraw from an ERC20Vault (a pool's internal vault) for `token`, raw units — the current value behind the append-only `VaultPayoutFallback` history. `token` is the ERC-20 address (or the vault's native sentinel). ## Parameters ### vault `` `0x${string}` `` ### owner `` `0x${string}` `` ### token `` `0x${string}` `` ### client ## Returns `Promise`\<`bigint`\> --- # /docs/api/index/functions/getVaultPayoutFallbacks [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / getVaultPayoutFallbacks # Function: getVaultPayoutFallbacks() > **getVaultPayoutFallbacks**(`owner`, `opts?`, `indexerUrl`): `Promise`\<[`VaultPayoutFallback`](../type-aliases/VaultPayoutFallback.md)[]\> Defined in: [query.ts:2620](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2620) An owner's vault-credit fallback history, newest first — optionally scoped to one token, paginated. The live claimable balance is a chain read ([getVaultBalance](getVaultBalance.md)); this is the append-only credit log. ## Parameters ### owner `string` ### opts? #### token? `string` #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`VaultPayoutFallback`](../type-aliases/VaultPayoutFallback.md)[]\> --- # /docs/api/index/functions/isBinaryMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / isBinaryMarket # Function: isBinaryMarket() > **isBinaryMarket**(`m`): `m is BinaryMarket` Defined in: [query.ts:298](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L298) Narrow a [Market](../type-aliases/Market.md) to its binary variant. ## Parameters ### m [`Market`](../type-aliases/Market.md) ## Returns `m is BinaryMarket` --- # /docs/api/index/functions/isLocalPrecompileUnavailable [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / isLocalPrecompileUnavailable # Function: isLocalPrecompileUnavailable() > **isLocalPrecompileUnavailable**(`chainId`): `boolean` Defined in: [preflight.ts:280](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L280) True when a chain id belongs to a network WITHOUT the Somnia reactivity precompile — i.e. a local anvil/hardhat dev chain (31337 / 1337), where `enableReactivity` / `triggerRoll` cannot work. Somnia testnet/mainnet return false. Use to fill the `precompileAvailable` flag the validators take. ## Parameters ### chainId `number` ## Returns `boolean` --- # /docs/api/index/functions/isPerpMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / isPerpMarket # Function: isPerpMarket() > **isPerpMarket**(`m`): `m is PerpMarket` Defined in: [query.ts:306](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L306) Narrow a [Market](../type-aliases/Market.md) to its perp variant. ## Parameters ### m [`Market`](../type-aliases/Market.md) ## Returns `m is PerpMarket` --- # /docs/api/index/functions/isSpotMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / isSpotMarket # Function: isSpotMarket() > **isSpotMarket**(`m`): `m is SpotMarket` Defined in: [query.ts:302](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L302) Narrow a [Market](../type-aliases/Market.md) to its spot variant. ## Parameters ### m [`Market`](../type-aliases/Market.md) ## Returns `m is SpotMarket` --- # /docs/api/index/functions/listBuilderApprovals [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listBuilderApprovals # Function: listBuilderApprovals() > **listBuilderApprovals**(`opts?`, `indexerUrl`): `Promise`\<[`BuilderApproval`](../type-aliases/BuilderApproval.md)[]\> Defined in: [query.ts:2580](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2580) List builder approvals, newest-updated first — filter by `user` and/or `builder` (both indexed), paginate. The directory complement to the on-chain point read `getBuilderApproval` in reads.ts. ## Parameters ### opts? #### user? `string` #### builder? `string` #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`BuilderApproval`](../type-aliases/BuilderApproval.md)[]\> --- # /docs/api/index/functions/listBuilderFees [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listBuilderFees # Function: listBuilderFees() > **listBuilderFees**(`opts?`, `indexerUrl`): `Promise`\<[`BuilderFeeRecord`](../type-aliases/BuilderFeeRecord.md)[]\> Defined in: [query.ts:2524](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2524) Realized builder/routing-fee records, newest first — filter by `builder` / `market` / `payer`, paginate with `limit`/`offset`. ## Parameters ### opts? #### builder? `string` #### market? `string` #### payer? `string` #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`BuilderFeeRecord`](../type-aliases/BuilderFeeRecord.md)[]\> --- # /docs/api/index/functions/listMarketCreators [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listMarketCreators # Function: listMarketCreators() > **listMarketCreators**(`opts?`, `indexerUrl`): `Promise`\<[`IndexedMarketCreator`](../type-aliases/IndexedMarketCreator.md)[]\> Defined in: [query.ts:1911](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1911) List MarketCreators, newest-first, paginated. Pass `owner` to scope to one owner's machinery (the indexed "my creators", no log scan), `operatorId` / `venueId` to scope to one operator/venue. Each row carries its nested `series`. Indexer read. ## Parameters ### opts? [`MarketCreatorFilter`](../type-aliases/MarketCreatorFilter.md) & `object` = `{}` ### indexerUrl `string` ## Returns `Promise`\<[`IndexedMarketCreator`](../type-aliases/IndexedMarketCreator.md)[]\> --- # /docs/api/index/functions/listMarketTypePlugins [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listMarketTypePlugins # Function: listMarketTypePlugins() > **listMarketTypePlugins**(): [`MarketTypePlugin`](../interfaces/MarketTypePlugin.md)\<`unknown`\>[] Defined in: [marketTypes/index.ts:27](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/index.ts#L27) All registered market-type plugins (e.g. to render a "pick a market type" list in a venue-creation wizard). ## Returns [`MarketTypePlugin`](../interfaces/MarketTypePlugin.md)\<`unknown`\>[] --- # /docs/api/index/functions/listOperatorHubAccounts [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listOperatorHubAccounts # Function: listOperatorHubAccounts() > **listOperatorHubAccounts**(`opts?`, `indexerUrl`): `Promise`\<[`OperatorHubAccountRecord`](../type-aliases/OperatorHubAccountRecord.md)[]\> Defined in: [query.ts:2384](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2384) Operator hub-account records, most-recently-updated first, paginated. Indexer read. ## Parameters ### opts? #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`OperatorHubAccountRecord`](../type-aliases/OperatorHubAccountRecord.md)[]\> --- # /docs/api/index/functions/listOracleAdapters [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listOracleAdapters # Function: listOracleAdapters() > **listOracleAdapters**(`opts?`, `indexerUrl`): `Promise`\<[`IndexedOracleAdapter`](../type-aliases/IndexedOracleAdapter.md)[]\> Defined in: [query.ts:1946](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1946) List oracle adapters, newest-first, paginated. Pass `owner` to scope to one owner's adapters, `approved` to filter by the module-approval gate. Indexer read. ## Parameters ### opts? #### owner? `string` #### approved? `boolean` #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`IndexedOracleAdapter`](../type-aliases/IndexedOracleAdapter.md)[]\> --- # /docs/api/index/functions/listOracleBinds [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listOracleBinds # Function: listOracleBinds() > **listOracleBinds**(`opts?`, `indexerUrl`): `Promise`\<[`OracleBindRecord`](../type-aliases/OracleBindRecord.md)[]\> Defined in: [query.ts:2403](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2403) Bind records, newest first — filter by `operatorId` (an operator's bound markets + their exact resolve charges) and/or `oracleQuestionId`, optionally scope to `resolved` binds (`resolvedAt != null`), paginate. Oracle v2 §8e: no escrow — resolved rows carry the exact metered charge + subsidy. Indexer read. ## Parameters ### opts? #### operatorId? `number` #### oracleQuestionId? `string` #### resolved? `boolean` #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`OracleBindRecord`](../type-aliases/OracleBindRecord.md)[]\> --- # /docs/api/index/functions/listOracleCallbacks [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listOracleCallbacks # Function: listOracleCallbacks() > **listOracleCallbacks**(`opts?`, `indexerUrl`): `Promise`\<[`OracleCallbackRecord`](../type-aliases/OracleCallbackRecord.md)[]\> Defined in: [query.ts:2425](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2425) Resolution-callback conservation records, newest first, paginated. The audit trail an off-chain verifier reconciles the hub's exact-metering invariants against (a callback drains across many questions, so there is no per-question filter). Indexer read. ## Parameters ### opts? #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`OracleCallbackRecord`](../type-aliases/OracleCallbackRecord.md)[]\> --- # /docs/api/index/functions/listOracleQuestions [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listOracleQuestions # Function: listOracleQuestions() > **listOracleQuestions**(`opts?`, `indexerUrl`): `Promise`\<[`OracleQuestionRecord`](../type-aliases/OracleQuestionRecord.md)[]\> Defined in: [query.ts:2349](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2349) Hub-scheduled questions, newest first — filter by `scheduler` and/or `questionKey`, paginate. Indexer read. ## Parameters ### opts? #### scheduler? `string` #### questionKey? `string` #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`OracleQuestionRecord`](../type-aliases/OracleQuestionRecord.md)[]\> --- # /docs/api/index/functions/listProtocolFees [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listProtocolFees # Function: listProtocolFees() > **listProtocolFees**(`opts?`, `indexerUrl`): `Promise`\<[`ProtocolFeeRecord`](../type-aliases/ProtocolFeeRecord.md)[]\> Defined in: [query.ts:2503](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2503) Realized protocol-fee records, newest first — filter by `recipient` / `market` / `pool` / `payer`, paginate with `limit`/`offset`. Complements getMarketFees (frozen config + running total) with the per-fill stream. ## Parameters ### opts? #### recipient? `string` #### market? `string` #### pool? `string` #### payer? `string` #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`ProtocolFeeRecord`](../type-aliases/ProtocolFeeRecord.md)[]\> --- # /docs/api/index/functions/listSeries [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listSeries # Function: listSeries() > **listSeries**(`opts?`, `indexerUrl`): `Promise`\<[`IndexedSeries`](../type-aliases/IndexedSeries.md)[]\> Defined in: [query.ts:1974](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1974) List series, creation-order, optionally scoped to one creator. Indexer read. ## Parameters ### opts? #### creator? `string` #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`IndexedSeries`](../type-aliases/IndexedSeries.md)[]\> --- # /docs/api/index/functions/listSettlementFees [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / listSettlementFees # Function: listSettlementFees() > **listSettlementFees**(`opts?`, `indexerUrl`): `Promise`\<[`SettlementFeeRecord`](../type-aliases/SettlementFeeRecord.md)[]\> Defined in: [query.ts:2544](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2544) Realized settlement-fee records, newest first — filter by `market` / `recipient`, paginate with `limit`/`offset`. ## Parameters ### opts? #### market? `string` #### recipient? `string` #### limit? `number` #### offset? `number` ### indexerUrl `string` ## Returns `Promise`\<[`SettlementFeeRecord`](../type-aliases/SettlementFeeRecord.md)[]\> --- # /docs/api/index/functions/marketKey [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / marketKey # Function: marketKey() > **marketKey**(`outcomeId`): `bigint` Defined in: [ids.ts:70](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/ids.ts#L70) The settlement `marketKey` for any outcome id of a market: `id >> 8`. Both the YES id and the NO id of the same market map to the SAME key (they differ only in the low 8 idx bits), so this keys the per-market `BinarySettlement` record regardless of which side's id you pass. Named `marketKey(yesId)` for the canonical YES-id caller, but any outcome id of the market works. ## Parameters ### outcomeId `bigint` ## Returns `bigint` --- # /docs/api/index/functions/marketStats24hFromCandles [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / marketStats24hFromCandles # Function: marketStats24hFromCandles() > **marketStats24hFromCandles**(`candles`, `nowSec`): [`MarketStats24h`](../interfaces/MarketStats24h.md) Defined in: [derivedReads.ts:137](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L137) Fold candle buckets whose `bucketStart >= nowSec − 86400` into a [MarketStats24h](../interfaces/MarketStats24h.md). `candles` are oldest-first (as `getCandles` returns). Pure — the wiring in createClient just fetches the candles first. ## Parameters ### candles [`Candle`](../type-aliases/Candle.md)[] ### nowSec `number` ## Returns [`MarketStats24h`](../interfaces/MarketStats24h.md) --- # /docs/api/index/functions/outcomeId [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / outcomeId # Function: outcomeId() > **outcomeId**(`pool`, `nonce`, `idx`): `bigint` Defined in: [ids.ts:40](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/ids.ts#L40) The ERC-6909 outcome id for `pool`'s market at `nonce`, outcome `idx`. `id = (uint160(pool) << 72) | (nonce << 8) | idx`. Pool is a 0x-address; nonce is the pool's `marketNonce` for the target market (1 on a fresh pool, ++ on each recycle); idx is 0 (YES) or 1 (NO). ## Parameters ### pool `string` ### nonce `number` \| `bigint` ### idx [`OutcomeIdx`](../type-aliases/OutcomeIdx.md) ## Returns `bigint` --- # /docs/api/index/functions/outstandingOf [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / outstandingOf # Function: outstandingOf() > **outstandingOf**(`operatorId`, `hub`, `client`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:158](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L158) Count of an operator's bound-but-unresolved markets (§8e). Pure chain read. `earmarkedOf == outstandingOf × resolveReserve` at every quiescent point. ## Parameters ### operatorId `number` ### hub `` `0x${string}` `` ### client ## Returns `Promise`\<`bigint`\> --- # /docs/api/index/functions/pnlEventsFor [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / pnlEventsFor # Function: pnlEventsFor() > **pnlEventsFor**(`account`, `fills`, `routerActions`): [`PnLEvent`](../interfaces/PnLEvent.md)[] Defined in: [derivedReads.ts:224](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L224) Derive the [PnLEvent](../interfaces/PnLEvent.md) stream for `account` from raw [FillRow](../type-aliases/FillRow.md)s (order-book fills) + [RouterActionRecord](../type-aliases/RouterActionRecord.md)s (mint/merge complete sets), merged into ONE oldest-first timeline by timestamp (so the avg-cost roll sees mints and fills in the order they happened). Fills whose side isn't bridged yet are skipped (can't attribute an outcome). Mint/merge use the record's `amount` (each outcome's set size). Redeem actions are ignored (they settle the position at payout, they don't change cost basis of a still-open book). ## Parameters ### account `string` ### fills [`FillRow`](../type-aliases/FillRow.md)[] ### routerActions [`RouterActionRecord`](../type-aliases/RouterActionRecord.md)[] ## Returns [`PnLEvent`](../interfaces/PnLEvent.md)[] --- # /docs/api/index/functions/preflightChain [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / preflightChain # Function: preflightChain() > **preflightChain**(`connectedChainId`, `expectedChainId`): [`PreflightResult`](../interfaces/PreflightResult.md) Defined in: [preflight.ts:268](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L268) Validate the wallet is on the expected chain (a machinery write on the wrong chain either reverts or lands on the wrong deployment). A standalone gate the wizard runs before any step. ## Parameters ### connectedChainId `number` ### expectedChainId `number` ## Returns [`PreflightResult`](../interfaces/PreflightResult.md) --- # /docs/api/index/functions/preflightCreateQuote [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / preflightCreateQuote # Function: preflightCreateQuote() > **preflightCreateQuote**(`q`): [`PreflightResult`](../interfaces/PreflightResult.md) Defined in: [preflight.ts:172](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L172) Validate a create-market call can proceed under §8e: the payer's balance covers the FULL create value `getSchedulingCost(def) + resolveReserve()` — the reserve is attached to the create and earmarked at onBind (excess is refunded in-tx). No separate prepaid-balance gate. ## Parameters ### q [`CreateQuotePreflightInput`](../interfaces/CreateQuotePreflightInput.md) ## Returns [`PreflightResult`](../interfaces/PreflightResult.md) --- # /docs/api/index/functions/preflightHub [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / preflightHub # Function: preflightHub() > **preflightHub**(`h`): [`PreflightResult`](../interfaces/PreflightResult.md) Defined in: [preflight.ts:128](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L128) Validate the OracleHub is live: approved on the module, its balance above the reactivity-bond floor, and its subscription armed (where the precompile exists). Protocol-admin view — an operator can't fix these, but a panel surfaces them so a dead hub isn't debugged at the create-market step. ## Parameters ### h [`HubPreflightInput`](../interfaces/HubPreflightInput.md) ## Returns [`PreflightResult`](../interfaces/PreflightResult.md) --- # /docs/api/index/functions/preflightMarketCreator [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / preflightMarketCreator # Function: preflightMarketCreator() > **preflightMarketCreator**(`c`): [`PreflightResult`](../interfaces/PreflightResult.md) Defined in: [preflight.ts:199](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L199) Validate a MarketCreator is funded enough to roll (a warning, not a hard blocker — a creator with a series but no balance still exists, it just can't roll until funded). For the exact per-roll amount, run [preflightCreateQuote](preflightCreateQuote.md) with the live hub quote. ## Parameters ### c [`MarketCreatorPreflightInput`](../interfaces/MarketCreatorPreflightInput.md) ## Returns [`PreflightResult`](../interfaces/PreflightResult.md) --- # /docs/api/index/functions/preflightOperator [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / preflightOperator # Function: preflightOperator() > **preflightOperator**(`op`): [`PreflightResult`](../interfaces/PreflightResult.md) Defined in: [preflight.ts:66](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L66) Validate that an operator is a sound base for machinery: the caller owns it, it is enabled, and it has a non-zero fee recipient. ## Parameters ### op [`OperatorPreflightInput`](../interfaces/OperatorPreflightInput.md) ## Returns [`PreflightResult`](../interfaces/PreflightResult.md) --- # /docs/api/index/functions/preflightRoll [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / preflightRoll # Function: preflightRoll() > **preflightRoll**(`r`): [`PreflightResult`](../interfaces/PreflightResult.md) Defined in: [preflight.ts:250](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L250) Validate the preconditions for `triggerRoll`: the series is registered, the chain has the precompile, and the creator holds native to pay the roll. ## Parameters ### r [`RollPreflightInput`](../interfaces/RollPreflightInput.md) ## Returns [`PreflightResult`](../interfaces/PreflightResult.md) --- # /docs/api/index/functions/preflightSeries [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / preflightSeries # Function: preflightSeries() > **preflightSeries**(`s`): [`PreflightResult`](../interfaces/PreflightResult.md) Defined in: [preflight.ts:225](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L225) Validate a series config matches the module's constraints: non-zero `seriesId`, non-empty `asset`, `intervalSec >= 60`, non-zero collateral. ## Parameters ### s [`SeriesPreflightInput`](../interfaces/SeriesPreflightInput.md) ## Returns [`PreflightResult`](../interfaces/PreflightResult.md) --- # /docs/api/index/functions/preflightVenue [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / preflightVenue # Function: preflightVenue() > **preflightVenue**(`v`): [`PreflightResult`](../interfaces/PreflightResult.md) Defined in: [preflight.ts:96](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L96) Validate a venue is ready to host a market: the caller owns its operator, its creation flag is on, and its market type is bound to a module. ## Parameters ### v [`VenuePreflightInput`](../interfaces/VenuePreflightInput.md) ## Returns [`PreflightResult`](../interfaces/PreflightResult.md) --- # /docs/api/index/functions/priceToProbability [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / priceToProbability # Function: priceToProbability() > **priceToProbability**(`rawPrice`, `decimals?`): `number` Defined in: [units.ts:44](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L44) Raw YES price → YES probability in [0, 1]. ## Parameters ### rawPrice `string` \| `bigint` ### decimals? `number` = `DECIMALS` ## Returns `number` --- # /docs/api/index/functions/probabilityToPrice [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / probabilityToPrice # Function: probabilityToPrice() > **probabilityToPrice**(`probability`, `decimals?`): `bigint` Defined in: [units.ts:49](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L49) YES probability in [0, 1] → raw YES price (the `price` field of placeOrder). ## Parameters ### probability `number` ### decimals? `number` = `DECIMALS` ## Returns `bigint` --- # /docs/api/index/functions/quoteBinaryOrderOverBook [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / quoteBinaryOrderOverBook # Function: quoteBinaryOrderOverBook() > **quoteBinaryOrderOverBook**(`book`, `side`, `quantity`, `oneCollateral`): [`BinaryOrderQuote`](../interfaces/BinaryOrderQuote.md) Defined in: [derivedReads.ts:76](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L76) Walk the live book crossing the opposite side for a market order of `quantity` on `side` — the pure kernel behind `client.quoteBinaryOrder`. `oneCollateral = 10^quoteDecimals` (full collateral = a share worth 1). ## Parameters ### book [`BinaryOrderBook`](../interfaces/BinaryOrderBook.md) ### side [`BinarySide`](../type-aliases/BinarySide.md) ### quantity `bigint` ### oneCollateral `bigint` ## Returns [`BinaryOrderQuote`](../interfaces/BinaryOrderQuote.md) --- # /docs/api/index/functions/quoteCreateMarketValue [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / quoteCreateMarketValue # Function: quoteCreateMarketValue() > **quoteCreateMarketValue**(`def`, `hub`, `client`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:237](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L237) THE §8e user-side create-value rule: `quoteCreateMarketValue(def) = getSchedulingCost(def) + resolveReserve()`. This is the exact native value to attach to `BinaryMarketsModule.scheduleAndCreateMarket` (schedule + bind in one tx): the marginal scheduling cost PLUS the resolution reserve, which is ATTACHED to the create and LOCKED per-market at onBind (earmark-at-creation — there is NO standing prepaid pre-fund anymore). For `createMarket` against an ALREADY-scheduled question the scheduling cost is 0, so the value is just the reserve. Quote fresh per create — the scheduling cost is marginal (drops to 0 once the question exists). Excess is refunded in-tx. ## Parameters ### def [`QuestionDefinitionInput`](../interfaces/QuestionDefinitionInput.md) ### hub `` `0x${string}` `` ### client ## Returns `Promise`\<`bigint`\> --- # /docs/api/index/functions/resolveReserve [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / resolveReserve # Function: resolveReserve() > **resolveReserve**(`hub`, `client`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:218](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L218) The per-market resolution reserve (§8e): the exact wei ATTACHED to each `onBind` (the market-creation value) and LOCKED per-market — one worst-case resolve (`perMarketResolveGas × maxFeePerGas`). Pure chain read. ## Parameters ### hub `` `0x${string}` `` ### client ## Returns `Promise`\<`bigint`\> --- # /docs/api/index/functions/sideOfKind [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / sideOfKind # Function: sideOfKind() > **sideOfKind**(`kind`): [`BinarySide`](../type-aliases/BinarySide.md) Defined in: [store.ts:160](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L160) Map an on-chain `OrderKind` index (from `BinaryOrderPlaced.kind`) to a [BinarySide](../type-aliases/BinarySide.md). Replaces the v1 `(isBid, userData)` decode — the pool now states the kind explicitly, so the SDK/indexer join the `BinaryOrderPlaced` event (by orderId) instead of inferring the side from userData. ## Parameters ### kind `number` \| `bigint` ## Returns [`BinarySide`](../type-aliases/BinarySide.md) --- # /docs/api/index/functions/toHuman [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / toHuman # Function: toHuman() > **toHuman**(`raw`, `decimals?`): `number` Defined in: [units.ts:15](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L15) Raw integer (string or bigint) → human number for DISPLAY ONLY. Lossy past ~15 significant digits (it's an IEEE double) — never round-trip money through this; use it for labels/charts. `decimals` defaults to the demo's 6 (tUSDC), but pass the market's real `quoteDecimals`/`baseDecimals` when you have them. ## Parameters ### raw `string` \| `bigint` ### decimals? `number` = `DECIMALS` ## Returns `number` --- # /docs/api/index/functions/toHumanString [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / toHumanString # Function: toHumanString() > **toHumanString**(`raw`, `decimals?`): `string` Defined in: [units.ts:21](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L21) Raw integer → exact human STRING (no precision loss). For display where you want the full value, or to feed another decimal library. ## Parameters ### raw `string` \| `bigint` ### decimals? `number` = `DECIMALS` ## Returns `string` --- # /docs/api/index/functions/withdrawableOf [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / withdrawableOf # Function: withdrawableOf() > **withdrawableOf**(`operatorId`, `hub`, `client`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:173](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L173) Wei an operator's owner may withdraw right now (§8e) — equal to `creditOf`; the earmark backing live markets is never withdrawable. Pure chain read. ## Parameters ### operatorId `number` ### hub `` `0x${string}` `` ### client ## Returns `Promise`\<`bigint`\> --- # /docs/api/index/interfaces/AcceptOperatorOwnershipParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / AcceptOperatorOwnershipParams # Interface: AcceptOperatorOwnershipParams Defined in: [operatorAdmin.ts:95](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L95) ## Properties ### operatorId > **operatorId**: `number` Defined in: [operatorAdmin.ts:96](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L96) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [operatorAdmin.ts:97](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L97) --- # /docs/api/index/interfaces/AccountHealth [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / AccountHealth # Interface: AccountHealth Defined in: [reads.ts:275](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L275) An account's cross-margin health, standalone (equity vs the IM/MM/CM requirements + the derived status). A lighter read than getMarginAccount when only health matters. ## Properties ### equity > **equity**: `bigint` Defined in: [reads.ts:277](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L277) Account equity = unlockedCollateralBalance + Σ(uPnl) − Σ(fundingOwed) (signed). *** ### imReq > **imReq**: `bigint` Defined in: [reads.ts:278](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L278) *** ### mmReq > **mmReq**: `bigint` Defined in: [reads.ts:279](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L279) *** ### cmReq > **cmReq**: `bigint` Defined in: [reads.ts:280](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L280) *** ### marginStatus > **marginStatus**: [`MarginStatus`](../type-aliases/MarginStatus.md) Defined in: [reads.ts:281](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L281) --- # /docs/api/index/interfaces/ApproveBuilderParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ApproveBuilderParams # Interface: ApproveBuilderParams Defined in: [trade.ts:150](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L150) Opt a routing/builder frontend in to charge up to `maxFeeBpsTimes1k` (pool bps×1000 unit) per order the trader submits with that builder code. Set 0 to revoke. ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:152](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L152) BinaryPool address. *** ### builder > **builder**: `` `0x${string}` `` Defined in: [trade.ts:154](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L154) Builder/routing frontend address. *** ### maxFeeBpsTimes1k > **maxFeeBpsTimes1k**: `bigint` Defined in: [trade.ts:156](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L156) Max per-order builder fee to allow (pool bps×1000). 0 revokes. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:157](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L157) --- # /docs/api/index/interfaces/ArmFirstRollParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ArmFirstRollParams # Interface: ArmFirstRollParams Defined in: [marketCreatorAdmin.ts:88](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L88) ## Properties ### creator > **creator**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:89](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L89) *** ### seriesId > **seriesId**: `number` Defined in: [marketCreatorAdmin.ts:90](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L90) *** ### firesAtSec > **firesAtSec**: `bigint` Defined in: [marketCreatorAdmin.ts:94](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L94) Future, interval-aligned Unix-seconds boundary to arm the series' first roll at (typically the outgoing creator's current-market expiry for a seamless migration). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [marketCreatorAdmin.ts:95](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L95) --- # /docs/api/index/interfaces/BalanceQuery [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BalanceQuery # Interface: BalanceQuery Defined in: [reads.ts:619](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L619) A token to read a balance for in a `getBalances` batch. Omit `id` for a plain ERC-20 (`balanceOf(account)`); provide `id` to read an ERC-6909 outcome position (`balanceOf(account, id)`) on the outcome-token singleton `token`. ## Properties ### token > **token**: `` `0x${string}` `` Defined in: [reads.ts:621](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L621) ERC-20 token, or the ERC-6909 outcome-token singleton when `id` is set. *** ### id? > `optional` **id?**: `bigint` Defined in: [reads.ts:623](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L623) ERC-6909 position id (`yesId`/`noId`). Absent → read `token` as a plain ERC-20. --- # /docs/api/index/interfaces/BinaryOrderBook [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinaryOrderBook # Interface: BinaryOrderBook Defined in: [reads.ts:55](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L55) Both books for a market, 4-sided. NO levels are the YES book inverted into NO terms (price = 1 − yesPrice), matching BinaryPool's pricing. ## Properties ### yesBids > **yesBids**: [`BookLevel`](BookLevel.md)[] Defined in: [reads.ts:56](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L56) *** ### yesAsks > **yesAsks**: [`BookLevel`](BookLevel.md)[] Defined in: [reads.ts:57](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L57) *** ### noBids > **noBids**: [`BookLevel`](BookLevel.md)[] Defined in: [reads.ts:58](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L58) *** ### noAsks > **noAsks**: [`BookLevel`](BookLevel.md)[] Defined in: [reads.ts:59](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L59) --- # /docs/api/index/interfaces/BinaryOrderQuote [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinaryOrderQuote # Interface: BinaryOrderQuote Defined in: [derivedReads.ts:23](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L23) The result of quoting a market order against the live book — the "you'll pay ~$X, average Y, slippage Z" preview. All prices/amounts are RAW units in the OUTCOME's own terms (a BUY_NO quote is priced in NO terms). ## Properties ### avgPrice > **avgPrice**: `bigint` Defined in: [derivedReads.ts:26](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L26) Volume-weighted average fill price (raw units per whole outcome token), in the quoted outcome's terms. `0n` if nothing fills. *** ### cost > **cost**: `bigint` Defined in: [derivedReads.ts:29](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L29) Total cost for a BUY (raw collateral paid) / total proceeds for a SELL (raw collateral received) = Σ(levelQty × levelPrice) / oneCollateral. *** ### filledQuantity > **filledQuantity**: `bigint` Defined in: [derivedReads.ts:32](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L32) How much of `quantity` actually crosses the resting book (raw outcome units). Less than `quantity` when the book is too thin to fill it all. *** ### wouldRest > **wouldRest**: `bigint` Defined in: [derivedReads.ts:35](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L35) The unfilled remainder that would rest as a maker order (raw outcome units) — `quantity − filledQuantity`. *** ### levelsConsumed > **levelsConsumed**: `number` Defined in: [derivedReads.ts:37](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L37) Number of price levels the order consumed (partially or fully). *** ### slippageVsMid > **slippageVsMid**: `bigint` Defined in: [derivedReads.ts:41](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L41) Signed slippage of `avgPrice` vs the book mid, in raw price units (avgPrice − mid for a buy; mid − avgPrice for a sell — positive = worse than mid). `0n` if the book has no mid (a side is empty) or nothing fills. --- # /docs/api/index/interfaces/BinaryPnl [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinaryPnl # Interface: BinaryPnl Defined in: [units.ts:62](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L62) Realized + unrealized PnL for one account in one binary market, computed purely from its fills + current outcome balances + the market row. Returns HUMAN numbers (quote/collateral units), keyed per outcome (YES/NO) plus a combined total — display-grade, like [toHuman](../functions/toHuman.md). ## Properties ### yes > **yes**: `object` Defined in: [units.ts:63](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L63) #### realized > **realized**: `number` #### unrealized > **unrealized**: `number` *** ### no > **no**: `object` Defined in: [units.ts:64](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L64) #### realized > **realized**: `number` #### unrealized > **unrealized**: `number` *** ### realized > **realized**: `number` Defined in: [units.ts:66](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L66) yes.realized + no.realized. *** ### unrealized > **unrealized**: `number` Defined in: [units.ts:68](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L68) yes.unrealized + no.unrealized. *** ### total > **total**: `number` Defined in: [units.ts:70](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L70) realized + unrealized. --- # /docs/api/index/interfaces/BinaryPnlFill [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinaryPnlFill # Interface: BinaryPnlFill Defined in: [units.ts:75](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L75) One account-perspective fill for [computeBinaryPnl](../functions/computeBinaryPnl.md): which outcome, how many tokens, at what raw YES-terms price, and whether the account BOUGHT. ## Properties ### outcomeIndex > **outcomeIndex**: `number` Defined in: [units.ts:77](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L77) 0 = YES, 1 = NO. *** ### isBuy > **isBuy**: `boolean` Defined in: [units.ts:79](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L79) True = the account bought (added) this outcome; false = sold (reduced). *** ### quantity > **quantity**: `string` \| `bigint` Defined in: [units.ts:81](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L81) Fill quantity, raw outcome-token units (decimal string or bigint). *** ### price > **price**: `string` \| `bigint` Defined in: [units.ts:83](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/units.ts#L83) Fill price for the fill's own outcome, raw quote units (0..10^decimals). --- # /docs/api/index/interfaces/BinaryPositionPnL [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinaryPositionPnL # Interface: BinaryPositionPnL Defined in: [derivedReads.ts:186](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L186) An account's position + cost basis + PnL in one binary market, RAW units. ACCOUNTING ASSUMPTION: weighted-average cost. Cost basis is reconstructed from the account's order-book fills on the market (buys add cost at the fill's outcome price; sells realize against the running average) folded with mint/merge router actions (a complete-set mint adds one YES + one NO at the split cost `oneCollateral` total; a merge removes a pair at avg cost). `markValue`/`unrealizedPnl` mark the CURRENT balances to the market's `lastPrice` while trading, or to the settlement payout once resolved. ## Properties ### balanceYes > **balanceYes**: `bigint` Defined in: [derivedReads.ts:188](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L188) Current YES outcome-token balance (raw). *** ### balanceNo > **balanceNo**: `bigint` Defined in: [derivedReads.ts:190](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L190) Current NO outcome-token balance (raw). *** ### costBasis > **costBasis**: `bigint` Defined in: [derivedReads.ts:192](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L192) Total remaining cost basis across both outcomes (raw collateral). *** ### avgCost > **avgCost**: `bigint` Defined in: [derivedReads.ts:195](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L195) Blended average cost per whole outcome token held (raw collateral per token). `0n` when nothing is held. *** ### markValue > **markValue**: `bigint` Defined in: [derivedReads.ts:197](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L197) Mark value of the current balances (raw collateral). *** ### unrealizedPnl > **unrealizedPnl**: `bigint` Defined in: [derivedReads.ts:199](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L199) markValue − costBasis (raw, signed). *** ### realizedPnl > **realizedPnl**: `bigint` Defined in: [derivedReads.ts:202](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L202) Realized PnL from sells (proceeds − avg cost of tokens sold), raw signed. Best-effort over indexed order-book sell fills (see accounting note). --- # /docs/api/index/interfaces/BinaryVenueParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinaryVenueParams # Interface: BinaryVenueParams Defined in: [operatorReads.ts:25](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorReads.ts#L25) Plain-bps fee rates for a BINARY_V1 venue (see BinaryMarketsModule.BinaryVenueParams). Each rate is capped at the module's `MAX_FEE_BPS` (currently 1_000 = 10%). ## Properties ### makerFeeBps > **makerFeeBps**: `number` Defined in: [operatorReads.ts:26](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorReads.ts#L26) *** ### takerFeeBps > **takerFeeBps**: `number` Defined in: [operatorReads.ts:27](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorReads.ts#L27) *** ### maxBuilderFeeBps > **maxBuilderFeeBps**: `number` Defined in: [operatorReads.ts:28](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorReads.ts#L28) *** ### routingFeeBps > **routingFeeBps**: `number` Defined in: [operatorReads.ts:29](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorReads.ts#L29) *** ### settlementFeeBps > **settlementFeeBps**: `number` Defined in: [operatorReads.ts:30](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorReads.ts#L30) --- # /docs/api/index/interfaces/BookLevel [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BookLevel # Interface: BookLevel Defined in: [store.ts:138](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L138) One aggregated price level of a resting book (raw units). ## Properties ### price > **price**: `bigint` Defined in: [store.ts:139](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L139) *** ### quantity > **quantity**: `bigint` Defined in: [store.ts:140](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L140) --- # /docs/api/index/interfaces/BurnSetParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BurnSetParams # Interface: BurnSetParams Defined in: [trade.ts:360](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L360) ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:362](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L362) BinaryPool address — pool burns the caller's YES + NO and refunds collateral. *** ### amount > **amount**: `bigint` Defined in: [trade.ts:364](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L364) Outcome amount to burn (same for YES + NO). *** ### outcomeToken? > `optional` **outcomeToken?**: `` `0x${string}` `` Defined in: [trade.ts:367](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L367) Outcome-token singleton; resolved from the pool if omitted. Both YES + NO are covered by a single operator approval on it. *** ### autoApprove? > `optional` **autoApprove?**: `boolean` Defined in: [trade.ts:369](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L369) Ensure the pool is an operator on the outcome-token singleton (default true). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:370](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L370) --- # /docs/api/index/interfaces/CancelExpiredOrdersParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / CancelExpiredOrdersParams # Interface: CancelExpiredOrdersParams Defined in: [trade.ts:188](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L188) Permissionless keeper drain: clean an explicit list of EXPIRED resting orders on a pool, returning each order's locked escrow to its owner. Best-effort — non-expired or stale ids are silently skipped on-chain (no revert). ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:190](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L190) BinaryPool (or SpotPool) address whose expired orders to clean. *** ### orderIds > **orderIds**: (`string` \| `bigint`)[] Defined in: [trade.ts:192](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L192) uint128 OrderIds to attempt to clean (decimal strings or bigints). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:193](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L193) --- # /docs/api/index/interfaces/CancelOrderParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / CancelOrderParams # Interface: CancelOrderParams Defined in: [trade.ts:160](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L160) ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:161](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L161) *** ### orderId > **orderId**: `string` \| `bigint` Defined in: [trade.ts:163](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L163) uint128 OrderId (decimal string or bigint). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:164](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L164) --- # /docs/api/index/interfaces/CancelStopOrderParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / CancelStopOrderParams # Interface: CancelStopOrderParams Defined in: [trade.ts:342](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L342) ## Properties ### registry > **registry**: `` `0x${string}` `` Defined in: [trade.ts:343](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L343) *** ### orderId > **orderId**: `string` \| `bigint` Defined in: [trade.ts:344](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L344) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:345](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L345) --- # /docs/api/index/interfaces/ClaimOwedParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ClaimOwedParams # Interface: ClaimOwedParams Defined in: [trade.ts:512](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L512) Claim an accrued push-fallback balance on the settlement singleton (a payout that could not be pushed to a reverting recipient was booked to `owed`). ## Properties ### token > **token**: `` `0x${string}` `` Defined in: [trade.ts:514](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L514) The token to claim (the market's collateral token). *** ### settlement? > `optional` **settlement?**: `` `0x${string}` `` Defined in: [trade.ts:516](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L516) BinarySettlement address; resolved from `config.addresses.binarySettlement` when omitted. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:517](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L517) --- # /docs/api/index/interfaces/ClaimableInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ClaimableInput # Interface: ClaimableInput Defined in: [derivedReads.ts:368](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L368) A settled binary position to evaluate for claimability. ## Properties ### marketId > **marketId**: `string` Defined in: [derivedReads.ts:369](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L369) *** ### pool > **pool**: `string` Defined in: [derivedReads.ts:370](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L370) *** ### outcomeIdx > **outcomeIdx**: `0` \| `1` Defined in: [derivedReads.ts:371](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L371) *** ### amount > **amount**: `bigint` Defined in: [derivedReads.ts:372](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L372) *** ### winningOutcome > **winningOutcome**: `number` \| `null` Defined in: [derivedReads.ts:374](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L374) Winning outcome (0/1) when resolved; null when voided/unresolved. *** ### voided > **voided**: `boolean` Defined in: [derivedReads.ts:375](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L375) *** ### status > **status**: `string` Defined in: [derivedReads.ts:376](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L376) *** ### settlementFeeBps > **settlementFeeBps**: `bigint` Defined in: [derivedReads.ts:378](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L378) Settlement fee in bps (1 = 0.01%); the winner payout skims this. --- # /docs/api/index/interfaces/ClaimablePosition [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ClaimablePosition # Interface: ClaimablePosition Defined in: [derivedReads.ts:351](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L351) One redeemable outcome position in a settled market — shaped to feed straight into `trader.redeemMany({ entries: [...] })`. ## Properties ### marketId > **marketId**: `string` Defined in: [derivedReads.ts:353](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L353) Market id (bytes32 hex) — `entries[].marketId` for redeemMany. *** ### pool > **pool**: `string` Defined in: [derivedReads.ts:355](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L355) The market's pool address (lowercased). *** ### outcomeIdx > **outcomeIdx**: `0` \| `1` Defined in: [derivedReads.ts:357](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L357) 0 = YES, 1 = NO — `entries[].outcomeIdx` for redeemMany. *** ### amount > **amount**: `bigint` Defined in: [derivedReads.ts:359](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L359) Redeemable outcome-token balance (raw) — `entries[].amount` for redeemMany. *** ### estPayout > **estPayout**: `bigint` Defined in: [derivedReads.ts:362](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L362) Estimated collateral payout net of the settlement fee (raw). Winner: amount × (1 − fee); voided: amount / 2 (both sides). Loser side: 0. *** ### status > **status**: `string` Defined in: [derivedReads.ts:364](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L364) Market lifecycle status driving the claim ("Resolved" | "Voided" | …). --- # /docs/api/index/interfaces/ClientConfig [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ClientConfig # Interface: ClientConfig Defined in: [config.ts:105](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L105) Configuration for a [SomniaMarketsClient](SomniaMarketsClient.md). `indexerUrl` is always required. `chain` + `wsRpcUrl` power the live tail, on-chain reads, and writes — they're required by those features, but the WebSocket socket is opened lazily, so an indexer-only client (e.g. server-side GraphQL reads) that never touches the chain never opens one. ## Properties ### indexerUrl > **indexerUrl**: `string` Defined in: [config.ts:107](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L107) Envio/Hasura GraphQL endpoint (HTTP). Same-origin relative paths are fine. *** ### indexerHeaders? > `optional` **indexerHeaders?**: `Record`\<`string`, `string`\> Defined in: [config.ts:113](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L113) Extra headers sent with every indexer request — e.g. a Hasura role / admin-secret for SERVER-side reads that need privileges the public role lacks (notably `_aggregate` fields, which envio hides from the public role). MUST stay server-only; never construct a browser client with a secret here. *** ### chain > **chain**: `Chain` Defined in: [config.ts:115](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L115) viem chain the markets live on. *** ### wsRpcUrl > **wsRpcUrl**: `string` Defined in: [config.ts:119](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L119) Chain WebSocket RPC — the single chain transport. The live tail subscribes to logs + new heads over it, and all on-chain reads/writes use it too. There is no HTTP fallback: the SDK assumes a healthy WebSocket. *** ### fees? > `optional` **fees?**: [`FixedFees`](FixedFees.md) Defined in: [config.ts:122](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L122) Fixed fees for SDK-signed writes (default [DEFAULT\_FEES](../variables/DEFAULT_FEES.md)). Override for a chain whose base fee can exceed the default ceiling. *** ### addresses? > `optional` **addresses?**: [`SomniaMarketsAddresses`](SomniaMarketsAddresses.md) Defined in: [config.ts:125](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L125) Protocol contract addresses — used by the write client, the live tail's factory watch, and /system reads. *** ### priceFeed? > `optional` **priceFeed?**: [`PriceFeedConfig`](PriceFeedConfig.md) Defined in: [config.ts:130](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L130) The realtime price-feed endpoint (see [PriceFeedConfig](PriceFeedConfig.md)). One endpoint serves every asset; callers filter by asset. Required only for the price-feed methods (`watchPrice`, `getLivePrice`, `fetchPrices`, …); a client that never touches prices needs none. --- # /docs/api/index/interfaces/ContractMeta [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ContractMeta # Interface: ContractMeta Defined in: [reads.ts:727](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L727) owner / implementation / native balance for a deployed contract — the diagnostics the /system dashboard shows. `owner` is null when the contract isn't Ownable; `impl` is read from the EIP-1967 slot only when `proxy` is true (null otherwise, or when the slot is empty). Each sub-read degrades to null/0 independently so one missing getter never fails the whole card. ## Properties ### owner > **owner**: `` `0x${string}` `` \| `null` Defined in: [reads.ts:728](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L728) *** ### impl > **impl**: `` `0x${string}` `` \| `null` Defined in: [reads.ts:729](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L729) *** ### balance > **balance**: `bigint` Defined in: [reads.ts:730](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L730) --- # /docs/api/index/interfaces/CreateMarketCreatorParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / CreateMarketCreatorParams # Interface: CreateMarketCreatorParams Defined in: [marketCreatorAdmin.ts:30](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L30) ## Properties ### owner > **owner**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:32](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L32) Owner of the minted creator (can register series / trigger rolls). *** ### adapter? > `optional` **adapter?**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:36](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L36) Oracle adapter the creator's markets resolve against. Defaults to the protocol's OracleHub (`config.addresses.oracleHub`) — Oracle v2's ONE approved adapter; there is nothing to mint or arm per operator. *** ### operatorId > **operatorId**: `number` Defined in: [marketCreatorAdmin.ts:37](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L37) *** ### venueId > **venueId**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:38](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L38) *** ### defaultBookParams > **defaultBookParams**: [`OrderBookParams`](OrderBookParams.md) Defined in: [marketCreatorAdmin.ts:39](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L39) *** ### core? > `optional` **core?**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:42](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L42) Core BinaryMarketsModule the creator binds to. Defaults to `config.addresses.binaryModule`. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [marketCreatorAdmin.ts:43](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L43) --- # /docs/api/index/interfaces/CreateMarketCreatorResult [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / CreateMarketCreatorResult # Interface: CreateMarketCreatorResult Defined in: [marketCreatorAdmin.ts:45](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L45) Base result of a confirmed write — the SDK waits for the receipt before resolving. ## Extends - [`TxResult`](TxResult.md) ## Properties ### creator > **creator**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:47](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L47) The minted MarketCreator address (decoded from `MarketCreatorCreated`). *** ### policy > **policy**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:49](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L49) The minted MarketCreatorPolicy address (decoded from `MarketCreatorCreated`). *** ### hash > **hash**: `` `0x${string}` `` Defined in: [trade.ts:89](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L89) #### Inherited from [`TxResult`](TxResult.md).[`hash`](TxResult.md#hash) *** ### receipt > **receipt**: `TransactionReceipt` Defined in: [trade.ts:90](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L90) #### Inherited from [`TxResult`](TxResult.md).[`receipt`](TxResult.md#receipt) --- # /docs/api/index/interfaces/CreateOrderParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / CreateOrderParams # Interface: CreateOrderParams Defined in: [unified/exchange.ts:71](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L71) ## Properties ### timeInForce? > `optional` **timeInForce?**: `"GTC"` \| `"IOC"` \| `"FOK"` \| `"PO"` Defined in: [unified/exchange.ts:73](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L73) "IOC" | "FOK" | "PO" (post-only). Default GTC (rest). *** ### postOnly? > `optional` **postOnly?**: `boolean` Defined in: [unified/exchange.ts:75](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L75) Alias for timeInForce: "PO". *** ### slippage? > `optional` **slippage?**: `number` Defined in: [unified/exchange.ts:77](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L77) Market-order slippage bound vs the best opposite level (default 0.01 = 1%). *** ### builder? > `optional` **builder?**: `` `0x${string}` `` Defined in: [unified/exchange.ts:81](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L81) BINARY only — routing/builder frontend to attribute the order to. Requires a prior `client.createTrader().approveBuilder(...)` opt-in on the pool, else a non-zero `builderFeeBpsTimes1k` reverts. Ignored on spot/perp. *** ### builderFeeBpsTimes1k? > `optional` **builderFeeBpsTimes1k?**: `bigint` Defined in: [unified/exchange.ts:84](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L84) BINARY only — per-order builder/routing fee in the pool's native bps×1000 unit (must not exceed the effective approval / the pool's max builder fee). --- # /docs/api/index/interfaces/CreateQuotePreflightInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / CreateQuotePreflightInput # Interface: CreateQuotePreflightInput Defined in: [preflight.ts:157](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L157) Inputs for the create-quote preflight (§8e EARMARK-AT-CREATION): what the payer (the funding wallet or MarketCreator contract) holds vs the FULL create value — `getSchedulingCost(def) + resolveReserve()`. The reserve is attached to the create and LOCKED per-market at onBind; there is no separate prepaid gate. Fetch the total with `quoteCreateMarketValue(def)`, or fetch the two legs (`getSchedulingCost(def)` + `resolveReserve()`) separately. ## Properties ### balanceWei > **balanceWei**: `bigint` Defined in: [preflight.ts:159](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L159) Native balance (wei) of whoever pays the create (EOA or MarketCreator). *** ### schedulingCostWei > **schedulingCostWei**: `bigint` Defined in: [preflight.ts:161](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L161) The hub's marginal `getSchedulingCost(def)` quote (0 = dedup reuse). *** ### resolveReserveWei > **resolveReserveWei**: `bigint` Defined in: [preflight.ts:165](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L165) The hub's `resolveReserve()` — the reserve ATTACHED to the create and locked per-market at onBind (the bind reverts `WrongReserveAttached` if the attached value is not exactly this). --- # /docs/api/index/interfaces/CreateVenueParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / CreateVenueParams # Interface: CreateVenueParams Defined in: [operatorAdmin.ts:100](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L100) ## Properties ### operatorId > **operatorId**: `number` Defined in: [operatorAdmin.ts:101](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L101) *** ### marketType > **marketType**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:103](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L103) Market-type id (e.g. `MarketTypeIds.BINARY_V1`); immutable once set. *** ### config > **config**: [`VenueConfigInput`](VenueConfigInput.md) Defined in: [operatorAdmin.ts:104](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L104) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [operatorAdmin.ts:105](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L105) --- # /docs/api/index/interfaces/CreateVenueResult [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / CreateVenueResult # Interface: CreateVenueResult Defined in: [operatorAdmin.ts:107](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L107) Base result of a confirmed write — the SDK waits for the receipt before resolving. ## Extends - [`TxResult`](TxResult.md) ## Properties ### venueId > **venueId**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:108](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L108) *** ### hash > **hash**: `` `0x${string}` `` Defined in: [trade.ts:89](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L89) #### Inherited from [`TxResult`](TxResult.md).[`hash`](TxResult.md#hash) *** ### receipt > **receipt**: `TransactionReceipt` Defined in: [trade.ts:90](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L90) #### Inherited from [`TxResult`](TxResult.md).[`receipt`](TxResult.md#receipt) --- # /docs/api/index/interfaces/DecodedOutcomeId [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / DecodedOutcomeId # Interface: DecodedOutcomeId Defined in: [ids.ts:46](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/ids.ts#L46) The decoded components of an outcome id. ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [ids.ts:48](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/ids.ts#L48) The pool address (the encoded high 160 bits), lowercased 0x-hex. *** ### nonce > **nonce**: `bigint` Defined in: [ids.ts:50](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/ids.ts#L50) The pool's market nonce this id belongs to. *** ### idx > **idx**: `number` Defined in: [ids.ts:52](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/ids.ts#L52) The outcome index (0 = YES, 1 = NO). --- # /docs/api/index/interfaces/DepositMarginParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / DepositMarginParams # Interface: DepositMarginParams Defined in: [trade.ts:261](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L261) ## Properties ### marginBank? > `optional` **marginBank?**: `` `0x${string}` `` Defined in: [trade.ts:263](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L263) MarginBank address (from the PerpMarket row), or pass `pool` to resolve it. *** ### pool? > `optional` **pool?**: `` `0x${string}` `` Defined in: [trade.ts:265](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L265) A PerpPool — its `marginBank()` is read (and cached) when `marginBank` is omitted. *** ### amount > **amount**: `bigint` Defined in: [trade.ts:267](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L267) Collateral amount to deposit, raw units (e.g. USDso 18dp). *** ### collateral? > `optional` **collateral?**: `` `0x${string}` `` Defined in: [trade.ts:269](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L269) Collateral token; read from the bank's getSystemConfig (cached) if omitted. *** ### autoApprove? > `optional` **autoApprove?**: `boolean` Defined in: [trade.ts:271](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L271) Approve the collateral to the BANK if allowance is short (default true). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:272](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L272) --- # /docs/api/index/interfaces/EnableHubReactivityParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / EnableHubReactivityParams # Interface: EnableHubReactivityParams Defined in: [oracleHub.ts:351](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L351) ## Properties ### gas? > `optional` **gas?**: `bigint` Defined in: [oracleHub.ts:352](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L352) --- # /docs/api/index/interfaces/Erc20Metadata [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / Erc20Metadata # Interface: Erc20Metadata Defined in: [reads.ts:565](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L565) ERC-20 token metadata (`symbol`, `name`, `decimals`) read in one fan-out. Handy to label a collateral/base token the indexer hasn't denormalized. ## Properties ### symbol > **symbol**: `string` Defined in: [reads.ts:566](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L566) *** ### name > **name**: `string` Defined in: [reads.ts:567](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L567) *** ### decimals > **decimals**: `number` Defined in: [reads.ts:568](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L568) --- # /docs/api/index/interfaces/FaucetParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / FaucetParams # Interface: FaucetParams Defined in: [trade.ts:640](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L640) ## Properties ### amount? > `optional` **amount?**: `bigint` Defined in: [trade.ts:642](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L642) Amount to mint (default 10,000 × 10^decimals). *** ### testUsdc? > `optional` **testUsdc?**: `` `0x${string}` `` Defined in: [trade.ts:644](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L644) TestUSDC address; defaults to the configured one. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:645](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L645) --- # /docs/api/index/interfaces/FinalizeMarketParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / FinalizeMarketParams # Interface: FinalizeMarketParams Defined in: [trade.ts:522](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L522) Permissionless keeper entry: finalize a settled market (sweep its pool's backing + resolution snapshot to the settlement singleton). No-op-guarded. ## Properties ### marketId > **marketId**: `` `0x${string}` `` Defined in: [trade.ts:524](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L524) bytes32 marketId to finalize; the market must be resolved or voided. *** ### module? > `optional` **module?**: `` `0x${string}` `` Defined in: [trade.ts:526](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L526) BinaryMarketsModule address; resolved from `config.addresses.binaryModule` when omitted. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:527](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L527) --- # /docs/api/index/interfaces/FixedFees [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / FixedFees # Interface: FixedFees Defined in: [config.ts:88](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L88) Fixed EIP-1559 fees every SDK-signed write uses. The SDK never estimates fees — no per-order eth_gasPrice / fee-history round-trip. `maxFeePerGas` is a ceiling (the tx pays base fee + tip, the rest is refunded), so a generous fixed value costs nothing extra on Somnia's flat gas market. ## Properties ### maxFeePerGas > **maxFeePerGas**: `bigint` Defined in: [config.ts:89](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L89) *** ### maxPriorityFeePerGas > **maxPriorityFeePerGas**: `bigint` Defined in: [config.ts:90](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L90) --- # /docs/api/index/interfaces/FundHubParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / FundHubParams # Interface: FundHubParams Defined in: [oracleHub.ts:328](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L328) ## Properties ### amountWei > **amountWei**: `bigint` Defined in: [oracleHub.ts:332](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L332) Native amount (wei) sent to the hub's `receive()` — tops up the reactivity bond the precompile debits callbacks from. NOT credited to any operator (resolution funding is attached per-market at create/onBind). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [oracleHub.ts:333](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L333) --- # /docs/api/index/interfaces/FundMarketCreatorParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / FundMarketCreatorParams # Interface: FundMarketCreatorParams Defined in: [marketCreatorAdmin.ts:52](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L52) ## Properties ### creator > **creator**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:53](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L53) *** ### amountWei > **amountWei**: `bigint` Defined in: [marketCreatorAdmin.ts:55](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L55) Native amount (wei) to send to the creator's `receive()`. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [marketCreatorAdmin.ts:56](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L56) --- # /docs/api/index/interfaces/GovernanceAdmin [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / GovernanceAdmin # Interface: GovernanceAdmin Defined in: [governanceAdmin.ts:22](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/governanceAdmin.ts#L22) ## Methods ### setAdapterApproved() > **setAdapterApproved**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [governanceAdmin.ts:27](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/governanceAdmin.ts#L27) Approve (or revoke) an oracle adapter on the module — the inert→live gate for a factory-minted adapter. MODULE-OWNER ONLY: reverts for any other caller, so a UI shows this only to the protocol admin (see [GovernanceAdmin.isModuleOwner](#ismoduleowner)). #### Parameters ##### p [`SetAdapterApprovedParams`](SetAdapterApprovedParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### getModuleOwner() > **getModuleOwner**(): `Promise`\<`` `0x${string}` ``\> Defined in: [governanceAdmin.ts:29](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/governanceAdmin.ts#L29) The module owner (the protocol admin). Needs `config.addresses.binaryModule`. #### Returns `Promise`\<`` `0x${string}` ``\> *** ### isModuleOwner() > **isModuleOwner**(`addr`): `Promise`\<`boolean`\> Defined in: [governanceAdmin.ts:32](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/governanceAdmin.ts#L32) Whether `addr` is the module owner — gate the `setAdapterApproved` UI on this. Needs `config.addresses.binaryModule`. #### Parameters ##### addr `` `0x${string}` `` #### Returns `Promise`\<`boolean`\> --- # /docs/api/index/interfaces/HubPreflightInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / HubPreflightInput # Interface: HubPreflightInput Defined in: [preflight.ts:116](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L116) Inputs for the hub-step preflight: the hub's on-chain status (from `OracleHubAdmin.getHubStatus`, or the subset a caller already holds) and whether the connected chain supports the reactivity precompile (local anvil does NOT). Unlike the retired adapter step, the armed state IS cheaply readable on-chain (`subscriptionId != 0`). ## Properties ### status > **status**: `Pick`\<[`HubStatus`](HubStatus.md), `"approved"` \| `"subscriptionId"` \| `"balanceWei"`\> Defined in: [preflight.ts:118](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L118) The subset of [HubStatus](HubStatus.md) the check needs. *** ### precompileAvailable > **precompileAvailable**: `boolean` Defined in: [preflight.ts:121](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L121) Whether the connected chain has the Somnia reactivity precompile (false on local anvil). --- # /docs/api/index/interfaces/HubQuestionState [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / HubQuestionState # Interface: HubQuestionState Defined in: [oracleHub.ts:252](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L252) One question's live dedup state on the hub. ## Properties ### questionKey > **questionKey**: `` `0x${string}` `` Defined in: [oracleHub.ts:255](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L255) Canonical dedup key for the definition (zero for non-template definitions, which bypass dedup). *** ### oracleQuestionId > **oracleQuestionId**: `bigint` Defined in: [oracleHub.ts:257](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L257) The ACTIVE question id the key resolves to (0n = never scheduled). *** ### bindCount > **bindCount**: `number` Defined in: [oracleHub.ts:259](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L259) Lifetime bind count for that question (drives the cap-split). *** ### markets > **markets**: `` `0x${string}` ``[] Defined in: [oracleHub.ts:261](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L261) Every marketId bound to the question (the fan-out list the drain walks). --- # /docs/api/index/interfaces/HubStatus [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / HubStatus # Interface: HubStatus Defined in: [oracleHub.ts:265](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L265) Live on-chain status of the hub (the point read a panel confirms). ## Properties ### owner > **owner**: `` `0x${string}` `` Defined in: [oracleHub.ts:266](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L266) *** ### balanceWei > **balanceWei**: `bigint` Defined in: [oracleHub.ts:269](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L269) Total native balance (wei) the hub holds (Σ earmarked + accrued credit + reactivity bond float). *** ### approved > **approved**: `boolean` Defined in: [oracleHub.ts:272](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L272) Whether the module has the hub approved (`approvedAdapters(hub)`) — the wired/live gate. *** ### subscriptionId > **subscriptionId**: `bigint` Defined in: [oracleHub.ts:274](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L274) Reactivity subscription id; 0n until `enableReactivity` succeeds. *** ### priorityFeePerGas > **priorityFeePerGas**: `bigint` Defined in: [oracleHub.ts:275](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L275) *** ### maxFeePerGas > **maxFeePerGas**: `bigint` Defined in: [oracleHub.ts:276](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L276) *** ### gasLimit > **gasLimit**: `bigint` Defined in: [oracleHub.ts:277](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L277) *** ### perMarketResolveGas > **perMarketResolveGas**: `bigint` Defined in: [oracleHub.ts:279](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L279) Per-market resolve-slice gas constant (sizes `resolveReserve`). *** ### callbackBaseGas > **callbackBaseGas**: `bigint` Defined in: [oracleHub.ts:281](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L281) Explicitly-attributed callback overhead gas constant (metering). *** ### maxResolvesPerCallback > **maxResolvesPerCallback**: `bigint` Defined in: [oracleHub.ts:283](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L283) Belt-and-suspenders cap on markets resolved per callback. *** ### resolveGasReserve > **resolveGasReserve**: `bigint` Defined in: [oracleHub.ts:285](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L285) Gas reserve that breaks the drain loop to the next block. *** ### resolveReserveWei > **resolveReserveWei**: `bigint` Defined in: [oracleHub.ts:287](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L287) Per-market resolution reserve attached+locked at onBind (`resolveReserve()`, wei). *** ### pendingResolves > **pendingResolves**: `bigint` Defined in: [oracleHub.ts:289](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L289) Markets still queued for resolution across all pending qids. --- # /docs/api/index/interfaces/IndexedPool [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / IndexedPool # Interface: IndexedPool Defined in: [query.ts:2875](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2875) The indexer's per-pool aggregate (`Pool`; id = lowercased pool address) — the long-lived BinaryPool contract that outlives any single market. ## Properties ### id > **id**: `string` Defined in: [query.ts:2877](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2877) Lowercased pool address (== address). *** ### address > **address**: `string` Defined in: [query.ts:2878](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2878) *** ### collateral > **collateral**: `string` \| `null` Defined in: [query.ts:2880](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2880) Collateral token the pool is bound to for its whole life (lowercased). *** ### creator > **creator**: `string` \| `null` Defined in: [query.ts:2883](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2883) The pool's creator — its first-deploy market creator, the only party that can reuse it (lowercased). *** ### currentMarketId > **currentMarketId**: `string` \| `null` Defined in: [query.ts:2886](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2886) marketId of the pool's CURRENT binding; null when finalized + released and awaiting reuse. *** ### currentNonce > **currentNonce**: `string` \| `null` Defined in: [query.ts:2888](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2888) Pool market nonce of the current binding (decimal string). *** ### generationCount > **generationCount**: `number` Defined in: [query.ts:2890](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2890) Number of markets this pool has served (== the latest nonce). *** ### createdAtTimestamp > **createdAtTimestamp**: `string` Defined in: [query.ts:2891](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2891) *** ### updatedAtTimestamp > **updatedAtTimestamp**: `string` Defined in: [query.ts:2892](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2892) --- # /docs/api/index/interfaces/LiveFill [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / LiveFill # Interface: LiveFill Defined in: [store.ts:81](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L81) One executed fill (mirror of indexer Fill, plus the resolved pool address). ## Properties ### id > **id**: `string` Defined in: [store.ts:83](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L83) `${blockNumber}_${logIndex}` — matches the indexer Fill id *** ### market\_id > **market\_id**: `string` Defined in: [store.ts:84](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L84) *** ### pool > **pool**: `string` Defined in: [store.ts:86](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L86) lowercased pool address (the log source) *** ### taker > **taker**: `string` \| `undefined` Defined in: [store.ts:90](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L90) Taker info is unresolved at OrderFilled emission time (the taker's OrderPlaced fires AFTER the fill in the same tx). Resolved via the takerOrder_id foreign key — enrichFill back-joins to LiveOrder. *** ### maker > **maker**: `string` \| `undefined` Defined in: [store.ts:91](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L91) *** ### takerSide > **takerSide**: [`BinarySide`](../type-aliases/BinarySide.md) \| `undefined` Defined in: [store.ts:92](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L92) *** ### makerSide > **makerSide**: [`BinarySide`](../type-aliases/BinarySide.md) \| `undefined` Defined in: [store.ts:93](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L93) *** ### kind > **kind**: [`BinaryFillKind`](../type-aliases/BinaryFillKind.md) \| `undefined` Defined in: [store.ts:94](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L94) *** ### takerOrder\_id > **takerOrder\_id**: `string` Defined in: [store.ts:96](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L96) Foreign keys to LiveOrder rows for join-side recovery. *** ### makerOrder\_id > **makerOrder\_id**: `string` Defined in: [store.ts:97](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L97) *** ### fillPrice > **fillPrice**: `string` Defined in: [store.ts:99](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L99) Raw quote/collateral units per whole base/outcome token. *** ### quantity > **quantity**: `string` Defined in: [store.ts:100](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L100) *** ### quoteQuantity > **quoteQuantity**: `string` Defined in: [store.ts:102](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L102) quote value = quantity * fillPrice / 10^baseDecimals *** ### takerRemainingQuantity > **takerRemainingQuantity**: `string` Defined in: [store.ts:103](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L103) *** ### makerRemainingQuantity > **makerRemainingQuantity**: `string` Defined in: [store.ts:104](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L104) *** ### timestamp > **timestamp**: `string` Defined in: [store.ts:105](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L105) *** ### blockNumber > **blockNumber**: `number` Defined in: [store.ts:106](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L106) *** ### logIndex > **logIndex**: `number` Defined in: [store.ts:107](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L107) *** ### txHash > **txHash**: `string` Defined in: [store.ts:108](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L108) --- # /docs/api/index/interfaces/LiveOrder [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / LiveOrder # Interface: LiveOrder Defined in: [store.ts:112](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L112) A resting/closed order (mirror of indexer Order). ## Properties ### id > **id**: `string` Defined in: [store.ts:114](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L114) `${pool}_${orderId}` *** ### market\_id > **market\_id**: `string` Defined in: [store.ts:115](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L115) *** ### pool > **pool**: `string` Defined in: [store.ts:116](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L116) *** ### orderId > **orderId**: `string` Defined in: [store.ts:117](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L117) *** ### owner > **owner**: `string` Defined in: [store.ts:118](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L118) *** ### side > **side**: [`BinarySide`](../type-aliases/BinarySide.md) \| `undefined` Defined in: [store.ts:120](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L120) Binary outcome side. Undefined on spot orders (spot has no YES/NO). *** ### isBid > **isBid**: `boolean` Defined in: [store.ts:121](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L121) *** ### userData > **userData**: `string` Defined in: [store.ts:122](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L122) *** ### price > **price**: `string` Defined in: [store.ts:123](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L123) *** ### fullQuantity > **fullQuantity**: `string` Defined in: [store.ts:124](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L124) *** ### quantityRemaining > **quantityRemaining**: `string` Defined in: [store.ts:125](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L125) *** ### filledQuantity > **filledQuantity**: `string` Defined in: [store.ts:126](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L126) *** ### expireTimestampNs > **expireTimestampNs**: `string` Defined in: [store.ts:130](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L130) Order expiry as a uint64 nanosecond timestamp (decimal string). GTC orders carry type(uint64).max, so they never expire; the matcher rejects a 0/past expiry at placement, so a resting order always has a real future ns value. *** ### status > **status**: [`OrderStatus`](../type-aliases/OrderStatus.md) Defined in: [store.ts:131](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L131) *** ### rested > **rested**: `boolean` Defined in: [store.ts:132](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L132) *** ### createdAt > **createdAt**: `string` Defined in: [store.ts:133](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L133) *** ### txHash > **txHash**: `string` Defined in: [store.ts:134](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L134) --- # /docs/api/index/interfaces/LivePrice [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / LivePrice # Interface: LivePrice Defined in: [priceFeed/types.ts:36](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L36) The current price of one asset — the `Feed` singleton, parsed. This is what a live watch keeps current. ## Properties ### asset > **asset**: `string` Defined in: [priceFeed/types.ts:38](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L38) Asset symbol this feed tracks (e.g. "BTC", "ETH"), uppercased. *** ### price > **price**: `number` Defined in: [priceFeed/types.ts:41](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L41) Latest price, human units (raw / 1e18). Lossy past ~15 sig figs — use `raw` for exact math. *** ### ema > **ema**: `number` Defined in: [priceFeed/types.ts:43](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L43) Latest EMA-smoothed mark price, human units (the feed's `mark`). *** ### blockNumber > **blockNumber**: `number` Defined in: [priceFeed/types.ts:45](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L45) Block the latest tick landed in (chain time, monotonic). *** ### blockTimestamp > **blockTimestamp**: `number` Defined in: [priceFeed/types.ts:48](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L48) Block timestamp of the latest tick — unix seconds, chain time. Use this as a series x-axis; it never drifts. *** ### decimals > **decimals**: `number` Defined in: [priceFeed/types.ts:50](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L50) Price scale (Feed.decimals, always 18 today). *** ### raw > **raw**: `object` Defined in: [priceFeed/types.ts:53](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L53) Exact 1e18-scaled integer strings — never round-trip money through the `number` fields above. #### price > **price**: `string` #### ema > **ema**: `string` --- # /docs/api/index/interfaces/MachineryStep [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MachineryStep # Interface: MachineryStep Defined in: [marketTypes/types.ts:13](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/types.ts#L13) One type-specific machinery onboarding step (rendered by a wizard; the preflight validators key off `id`). Descriptive only — no logic here. ## Properties ### id > **id**: `string` Defined in: [marketTypes/types.ts:15](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/types.ts#L15) Stable step id (e.g. "market-creator", "funding", "series"). *** ### label > **label**: `string` Defined in: [marketTypes/types.ts:17](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/types.ts#L17) Short human label. *** ### description > **description**: `string` Defined in: [marketTypes/types.ts:19](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/types.ts#L19) One-line description of what the operator does in this step. --- # /docs/api/index/interfaces/MarginAccount [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarginAccount # Interface: MarginAccount Defined in: [reads.ts:217](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L217) An account's cross-margin state in the MarginBank (collateral is the bank's single collateral token, e.g. USDso — raw units). ## Properties ### unlockedCollateralBalance > **unlockedCollateralBalance**: `bigint` Defined in: [reads.ts:219](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L219) Free collateral after locks (signed — settlement can drive it negative). *** ### lockedCollateral > **lockedCollateral**: `bigint` Defined in: [reads.ts:221](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L221) Collateral reserved for pending orders. *** ### activePerpPools > **activePerpPools**: `` `0x${string}` ``[] Defined in: [reads.ts:223](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L223) Perp pools where the account holds an open position. *** ### equity > **equity**: `bigint` Defined in: [reads.ts:225](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L225) Equity = collateral + unrealized PnL − pending funding (signed). *** ### withdrawable > **withdrawable**: `bigint` Defined in: [reads.ts:227](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L227) Collateral withdrawable right now (respects margin requirements). *** ### imReq > **imReq**: `bigint` Defined in: [reads.ts:229](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L229) Sum of notional × initialMarginBps / 10000 across all markets (raw). *** ### mmReq > **mmReq**: `bigint` Defined in: [reads.ts:231](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L231) Sum of notional × maintenanceMarginBps / 10000 across all markets (raw). *** ### cmReq > **cmReq**: `bigint` Defined in: [reads.ts:233](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L233) Sum of notional × closeOutMarginBps / 10000 across all markets (raw). *** ### marginStatus > **marginStatus**: [`MarginStatus`](../type-aliases/MarginStatus.md) Defined in: [reads.ts:235](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L235) Health bucket derived from equity vs the requirements. --- # /docs/api/index/interfaces/MarketCreatorAdmin [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketCreatorAdmin # Interface: MarketCreatorAdmin Defined in: [marketCreatorAdmin.ts:122](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L122) ## Methods ### createMarketCreator() > **createMarketCreator**(`p`): `Promise`\<[`CreateMarketCreatorResult`](CreateMarketCreatorResult.md)\> Defined in: [marketCreatorAdmin.ts:126](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L126) Stamp out a new MarketCreator (+ its policy) from the factory, bound to `(operatorId, venueId, core, adapter)` + a default book config. Resolves with the minted `creator` + `policy` (decoded from `MarketCreatorCreated`). #### Parameters ##### p [`CreateMarketCreatorParams`](CreateMarketCreatorParams.md) #### Returns `Promise`\<[`CreateMarketCreatorResult`](CreateMarketCreatorResult.md)\> *** ### fundMarketCreator() > **fundMarketCreator**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [marketCreatorAdmin.ts:129](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L129) Send native currency to a creator's `receive()` — it pays for reactivity rolls, so it must hold a balance on testnet/mainnet. #### Parameters ##### p [`FundMarketCreatorParams`](FundMarketCreatorParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### registerSeries() > **registerSeries**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [marketCreatorAdmin.ts:133](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L133) Register (or overwrite) a rolling-market series under a creator. Owner-only. `intervalSec` must be >= 60 and `asset` non-empty (the module reverts otherwise). #### Parameters ##### p [`RegisterSeriesParams`](RegisterSeriesParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### updateSeries() > **updateSeries**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [marketCreatorAdmin.ts:136](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L136) Overwrite an existing series — alias of [registerSeries](#registerseries) (the module upserts by `seriesId`). Provided for wizard clarity. #### Parameters ##### p [`RegisterSeriesParams`](RegisterSeriesParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### triggerRoll() > **triggerRoll**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [marketCreatorAdmin.ts:139](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L139) Roll a series to its next market (owner-only). NOTE: calls the Somnia reactivity precompile — only succeeds on testnet/mainnet, not local anvil. #### Parameters ##### p [`TriggerRollParams`](TriggerRollParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### armFirstRoll() > **armFirstRoll**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [marketCreatorAdmin.ts:144](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L144) A1: arm a series' FIRST roll at a future boundary WITHOUT minting now (owner-only) — the seamless-migration tool: start a fresh MC's series exactly at the outgoing MC's expiry. NOTE: touches the reactivity precompile — testnet/mainnet only. #### Parameters ##### p [`ArmFirstRollParams`](ArmFirstRollParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### reclaimOracleCredit() > **reclaimOracleCredit**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [marketCreatorAdmin.ts:148](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L148) A1: pull the creator's own accrued oracle surplus (payer credit) out of the hub into its native float. Runs automatically each roll cycle; this is the manual sweep of any leftovers. Permissionless. #### Parameters ##### p [`ReclaimOracleCreditParams`](ReclaimOracleCreditParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### setReactivityGasParams() > **setReactivityGasParams**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [marketCreatorAdmin.ts:150](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L150) Update the creator's reactivity gas params (owner-only). #### Parameters ##### p [`SetReactivityGasParamsParams`](SetReactivityGasParamsParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### getMarketCreatorOnchain() > **getMarketCreatorOnchain**(`creator`): `Promise`\<[`MarketCreatorOnchain`](MarketCreatorOnchain.md)\> Defined in: [marketCreatorAdmin.ts:153](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L153) One creator's live binding (core/adapter/operatorId/venueId/owner + default book params). On-chain point read. #### Parameters ##### creator `` `0x${string}` `` #### Returns `Promise`\<[`MarketCreatorOnchain`](MarketCreatorOnchain.md)\> *** ### getSeriesOnchain() > **getSeriesOnchain**(`creator`, `seriesId`): `Promise`\<[`SeriesOnchain`](SeriesOnchain.md)\> Defined in: [marketCreatorAdmin.ts:156](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L156) One series' live config under a creator. On-chain point read; the returned `intervalSec === 0` means the series was never registered. #### Parameters ##### creator `` `0x${string}` `` ##### seriesId `number` #### Returns `Promise`\<[`SeriesOnchain`](SeriesOnchain.md)\> --- # /docs/api/index/interfaces/MarketCreatorInfo [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketCreatorInfo # Interface: MarketCreatorInfo Defined in: [system.ts:24](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L24) ## Properties ### marketCount > **marketCount**: `bigint` Defined in: [system.ts:25](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L25) *** ### owner > **owner**: `` `0x${string}` `` \| `null` Defined in: [system.ts:26](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L26) *** ### reactivityGasLimit > **reactivityGasLimit**: `bigint` Defined in: [system.ts:27](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L27) *** ### reactivityMaxFeePerGas > **reactivityMaxFeePerGas**: `bigint` Defined in: [system.ts:28](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L28) *** ### reactivityPriorityFeePerGas > **reactivityPriorityFeePerGas**: `bigint` Defined in: [system.ts:29](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L29) *** ### operatorId > **operatorId**: `number` Defined in: [system.ts:31](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L31) Origin operator id this creator's markets are attributed to. *** ### venueId > **venueId**: `string` Defined in: [system.ts:33](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L33) Origin venue id within the operator (bytes32 hex). --- # /docs/api/index/interfaces/MarketCreatorOnchain [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketCreatorOnchain # Interface: MarketCreatorOnchain Defined in: [marketCreatorAdmin.ts:104](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L104) One MarketCreator's live on-chain binding (the point read a wizard confirms). ## Properties ### core > **core**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:105](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L105) *** ### adapter > **adapter**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:106](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L106) *** ### operatorId > **operatorId**: `number` Defined in: [marketCreatorAdmin.ts:107](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L107) *** ### venueId > **venueId**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:108](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L108) *** ### owner > **owner**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:109](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L109) *** ### defaultBookParams > **defaultBookParams**: [`OrderBookParams`](OrderBookParams.md) Defined in: [marketCreatorAdmin.ts:110](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L110) --- # /docs/api/index/interfaces/MarketCreatorPreflightInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketCreatorPreflightInput # Interface: MarketCreatorPreflightInput Defined in: [preflight.ts:189](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L189) Inputs for the creator-step preflight: the creator's native balance and whether the connected chain supports rolls. ## Properties ### balanceWei > **balanceWei**: `bigint` Defined in: [preflight.ts:191](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L191) The creator's native balance (wei) — it pays for reactivity rolls. *** ### precompileAvailable > **precompileAvailable**: `boolean` Defined in: [preflight.ts:192](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L192) --- # /docs/api/index/interfaces/MarketOnchain [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketOnchain # Interface: MarketOnchain Defined in: [reads.ts:358](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L358) A BinaryMarket's wiring + live state, read straight from chain (works before the indexer has the market). ## Properties ### marketAddress > **marketAddress**: `` `0x${string}` `` Defined in: [reads.ts:360](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L360) The BinaryMarket contract address (resolved from the module record). *** ### outcomeToken > **outcomeToken**: `` `0x${string}` `` Defined in: [reads.ts:362](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L362) Protocol-level ERC-6909 outcome-token singleton (shared across all markets). *** ### yesId > **yesId**: `bigint` Defined in: [reads.ts:364](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L364) This market's YES position id on the singleton. *** ### noId > **noId**: `bigint` Defined in: [reads.ts:366](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L366) This market's NO position id on the singleton. *** ### pool > **pool**: `` `0x${string}` `` Defined in: [reads.ts:371](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L371) The pool hosting (or that hosted) this market's CLOB. Settlement-extraction v2: a pool address is a TIME-VARYING binding — the same pool serves successive markets, so never key a market by pool address; `(pool, nonce)` identifies this market's slice of the pool's history. *** ### nonce > **nonce**: `bigint` Defined in: [reads.ts:373](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L373) The pool's market nonce for THIS market (part of the outcome-id encoding). *** ### collateral > **collateral**: `` `0x${string}` `` Defined in: [reads.ts:374](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L374) *** ### status > **status**: `number` Defined in: [reads.ts:376](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L376) MarketStatus enum: 0 Listed · 1 Trading · 2 Locked · 3 Settling · 4 Resolved · 5 Voided *** ### backing > **backing**: `bigint` Defined in: [reads.ts:381](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L381) Live collateral backing. While trading this is the pool's `setBacking` (via `market.backing()`); once the market is FINALIZED onto the settlement singleton the pool reads 0, so this falls back to the settlement record's remaining NET backing (post fee-skim, decremented by each redemption). *** ### finalized > **finalized**: `boolean` Defined in: [reads.ts:384](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L384) True once the market's backing + resolution snapshot were swept to the BinarySettlement singleton (redemption is served there from then on). *** ### expiry > **expiry**: `bigint` Defined in: [reads.ts:386](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L386) Trading-close / settlement timestamp (seconds). *** ### decimals > **decimals**: `number` Defined in: [reads.ts:388](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L388) Collateral decimals (falls back to DECIMALS if the read reverts). *** ### winningOutcome > **winningOutcome**: `number` Defined in: [reads.ts:392](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L392) Winning outcome (0 = YES, 1 = NO). Only meaningful when `isResolved` — the contract returns 0 by default which would otherwise read as a YES win on a market that hasn't resolved yet. *** ### isResolved > **isResolved**: `boolean` Defined in: [reads.ts:394](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L394) Oracle has resolved the market to a concrete winning outcome. *** ### isVoided > **isVoided**: `boolean` Defined in: [reads.ts:396](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L396) Oracle has voided the market (no winner; both sides redeem 0.5:1). --- # /docs/api/index/interfaces/MarketOnchainSources [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketOnchainSources # Interface: MarketOnchainSources Defined in: [reads.ts:400](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L400) Module/settlement wiring `getMarketOnchain` resolves the market through. ## Properties ### module > **module**: `` `0x${string}` `` Defined in: [reads.ts:402](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L402) BinaryMarketsModule address (the on-chain market registry). *** ### settlement? > `optional` **settlement?**: `` `0x${string}` `` Defined in: [reads.ts:406](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L406) BinarySettlement singleton — enables the post-finalize backing fallback. Omit on pre-v2 deploys; `finalized` then stays false and `backing` is the raw `market.backing()` value. --- # /docs/api/index/interfaces/MarketStats24h [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketStats24h # Interface: MarketStats24h Defined in: [derivedReads.ts:118](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L118) A market's trailing-24h activity, derived from OHLCV candle buckets. Prices are RAW quote units; volume is RAW quote (collateral) units. ## Properties ### volume24h > **volume24h**: `bigint` Defined in: [derivedReads.ts:120](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L120) Σ quote volume over the window (raw collateral units). *** ### trades24h > **trades24h**: `number` Defined in: [derivedReads.ts:122](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L122) Σ trade count over the window. *** ### priceChange24h > **priceChange24h**: `bigint` Defined in: [derivedReads.ts:125](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L125) closePrice(last) − openPrice(first) over the window (raw, signed). `0n` if fewer than one candle in-window. *** ### high24h > **high24h**: `bigint` \| `null` Defined in: [derivedReads.ts:127](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L127) Max high across the window (raw). `null` if no candles in-window. *** ### low24h > **low24h**: `bigint` \| `null` Defined in: [derivedReads.ts:129](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L129) Min low across the window (raw). `null` if no candles in-window. *** ### openPrice24h > **openPrice24h**: `bigint` \| `null` Defined in: [derivedReads.ts:131](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L131) openPrice of the first in-window candle (raw). `null` if none. --- # /docs/api/index/interfaces/MarketTypePlugin [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketTypePlugin # Interface: MarketTypePlugin\ Defined in: [marketTypes/types.ts:27](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/types.ts#L27) A market-type plugin: the fee-param codec + machinery descriptor for one bytes4 `marketType`. `TParams` is the type's plain fee-param shape (e.g. [BinaryVenueParams](BinaryVenueParams.md) for BINARY_V1). ## Type Parameters ### TParams `TParams` = `unknown` ## Properties ### marketType > **marketType**: `` `0x${string}` `` Defined in: [marketTypes/types.ts:29](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/types.ts#L29) The bytes4 market-type id (e.g. `MARKET_TYPE_BINARY_V1`). *** ### label > **label**: `string` Defined in: [marketTypes/types.ts:31](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/types.ts#L31) Human label for the type. *** ### machinerySteps > **machinerySteps**: readonly [`MachineryStep`](MachineryStep.md)[] Defined in: [marketTypes/types.ts:33](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/types.ts#L33) The type-specific machinery onboarding steps, in order. ## Methods ### encodeVenueFeeParams() > **encodeVenueFeeParams**(`params`, `client`, `moduleAddress`): `Promise`\<`` `0x${string}` ``\> Defined in: [marketTypes/types.ts:37](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/types.ts#L37) Encode plain fee params into a venue's opaque `feeParams` bytes — for binary this defers to the module's on-chain encoder (needs a client + the module address), so it is async. #### Parameters ##### params `TParams` ##### client ##### moduleAddress `` `0x${string}` `` \| `undefined` #### Returns `Promise`\<`` `0x${string}` ``\> *** ### decodeVenueFeeParams() > **decodeVenueFeeParams**(`feeParams`): `TParams` \| `null` Defined in: [marketTypes/types.ts:40](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/types.ts#L40) Decode a venue's `feeParams` bytes back into plain params for display, or null if the bytes aren't this type's shape. Pure/local. #### Parameters ##### feeParams `` `0x${string}` `` #### Returns `TParams` \| `null` --- # /docs/api/index/interfaces/MintSetNativeParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MintSetNativeParams # Interface: MintSetNativeParams Defined in: [trade.ts:605](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L605) Shared inputs for the CollateralRouter complete-set entry points. ## Extends - [`RouterMintBase`](RouterMintBase.md) ## Properties ### marketId > **marketId**: `` `0x${string}` `` Defined in: [trade.ts:594](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L594) bytes32 market key the set is minted for (the market's `marketId`). #### Inherited from [`RouterMintBase`](RouterMintBase.md).[`marketId`](RouterMintBase.md#marketid) *** ### operatorId > **operatorId**: `number` Defined in: [trade.ts:596](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L596) Routing operator id (uint32) for attribution; 0 = none. #### Inherited from [`RouterMintBase`](RouterMintBase.md).[`operatorId`](RouterMintBase.md#operatorid) *** ### venueId > **venueId**: `` `0x${string}` `` Defined in: [trade.ts:598](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L598) Routing venue id (bytes32 hex); 32-byte zero = none. #### Inherited from [`RouterMintBase`](RouterMintBase.md).[`venueId`](RouterMintBase.md#venueid) *** ### router? > `optional` **router?**: `` `0x${string}` `` Defined in: [trade.ts:601](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L601) CollateralRouter address; resolved from `config.addresses.collateralRouter` if omitted. Throws if neither is set (never sends to the zero address). #### Inherited from [`RouterMintBase`](RouterMintBase.md).[`router`](RouterMintBase.md#router) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:602](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L602) #### Inherited from [`RouterMintBase`](RouterMintBase.md).[`gas`](RouterMintBase.md#gas) *** ### amount > **amount**: `bigint` Defined in: [trade.ts:608](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L608) Native (SOMI/STT) amount to wrap → wNative and mint as `amount` YES + NO. Sent as `msg.value`; the target market's collateral must be wNative. --- # /docs/api/index/interfaces/MintSetParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MintSetParams # Interface: MintSetParams Defined in: [trade.ts:348](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L348) ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:350](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L350) BinaryPool address — pool pulls collateral and mints YES+NO. *** ### amount > **amount**: `bigint` Defined in: [trade.ts:352](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L352) Collateral amount → mints `amount` YES + `amount` NO to the signer. *** ### collateral? > `optional` **collateral?**: `` `0x${string}` `` Defined in: [trade.ts:354](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L354) Collateral token; resolved from the live store (by pool) if omitted. *** ### autoApprove? > `optional` **autoApprove?**: `boolean` Defined in: [trade.ts:356](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L356) Approve collateral → pool if allowance is short (default true). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:357](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L357) --- # /docs/api/index/interfaces/MintSetPermit2Params [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MintSetPermit2Params # Interface: MintSetPermit2Params Defined in: [trade.ts:611](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L611) Shared inputs for the CollateralRouter complete-set entry points. ## Extends - [`RouterMintBase`](RouterMintBase.md) ## Properties ### marketId > **marketId**: `` `0x${string}` `` Defined in: [trade.ts:594](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L594) bytes32 market key the set is minted for (the market's `marketId`). #### Inherited from [`RouterMintBase`](RouterMintBase.md).[`marketId`](RouterMintBase.md#marketid) *** ### operatorId > **operatorId**: `number` Defined in: [trade.ts:596](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L596) Routing operator id (uint32) for attribution; 0 = none. #### Inherited from [`RouterMintBase`](RouterMintBase.md).[`operatorId`](RouterMintBase.md#operatorid) *** ### venueId > **venueId**: `` `0x${string}` `` Defined in: [trade.ts:598](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L598) Routing venue id (bytes32 hex); 32-byte zero = none. #### Inherited from [`RouterMintBase`](RouterMintBase.md).[`venueId`](RouterMintBase.md#venueid) *** ### router? > `optional` **router?**: `` `0x${string}` `` Defined in: [trade.ts:601](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L601) CollateralRouter address; resolved from `config.addresses.collateralRouter` if omitted. Throws if neither is set (never sends to the zero address). #### Inherited from [`RouterMintBase`](RouterMintBase.md).[`router`](RouterMintBase.md#router) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:602](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L602) #### Inherited from [`RouterMintBase`](RouterMintBase.md).[`gas`](RouterMintBase.md#gas) *** ### amount > **amount**: `bigint` Defined in: [trade.ts:614](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L614) Collateral amount to pull via Permit2 and mint as `amount` YES + NO. Must match `permit.permitted.amount` semantics on the app side. *** ### permit > **permit**: [`Permit2TransferFrom`](Permit2TransferFrom.md) Defined in: [trade.ts:616](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L616) Signed Permit2 permit whose `permitted.token` must equal the market collateral. *** ### signature > **signature**: `` `0x${string}` `` Defined in: [trade.ts:618](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L618) EIP-712 signature over `permit` by the signer. --- # /docs/api/index/interfaces/OperatorAdmin [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OperatorAdmin # Interface: OperatorAdmin Defined in: [operatorAdmin.ts:125](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L125) ## Methods ### registerOperator() > **registerOperator**(`p`): `Promise`\<[`RegisterOperatorResult`](RegisterOperatorResult.md)\> Defined in: [operatorAdmin.ts:128](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L128) Permissionlessly claim a new operator identity. Resolves with the auto-assigned `operatorId` (decoded from `OperatorRegistered`). #### Parameters ##### p [`RegisterOperatorParams`](RegisterOperatorParams.md) #### Returns `Promise`\<[`RegisterOperatorResult`](RegisterOperatorResult.md)\> *** ### updateOperator() > **updateOperator**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [operatorAdmin.ts:130](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L130) Update all mutable operator fields at once. Operator-owner only. #### Parameters ##### p [`UpdateOperatorParams`](UpdateOperatorParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### setOperatorEnabled() > **setOperatorEnabled**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [operatorAdmin.ts:132](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L132) Flip the operator's kill switch without touching other fields. #### Parameters ##### p [`SetOperatorEnabledParams`](SetOperatorEnabledParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### transferOperatorOwnership() > **transferOperatorOwnership**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [operatorAdmin.ts:135](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L135) Stage a two-step operator-ownership transfer (or cancel a pending one by re-staging the current owner). #### Parameters ##### p [`TransferOperatorOwnershipParams`](TransferOperatorOwnershipParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### acceptOperatorOwnership() > **acceptOperatorOwnership**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [operatorAdmin.ts:137](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L137) Complete a pending operator-ownership transfer. Caller must be the staged owner. #### Parameters ##### p [`AcceptOperatorOwnershipParams`](AcceptOperatorOwnershipParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### createVenue() > **createVenue**(`p`): `Promise`\<[`CreateVenueResult`](CreateVenueResult.md)\> Defined in: [operatorAdmin.ts:140](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L140) Create a venue under an operator. Resolves with the contract-generated `venueId` (decoded from `VenueCreated`). #### Parameters ##### p [`CreateVenueParams`](CreateVenueParams.md) #### Returns `Promise`\<[`CreateVenueResult`](CreateVenueResult.md)\> *** ### updateVenue() > **updateVenue**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [operatorAdmin.ts:142](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L142) Replace a venue's mutable config (`marketType` cannot change here). #### Parameters ##### p [`UpdateVenueParams`](UpdateVenueParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### setVenueEnabled() > **setVenueEnabled**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [operatorAdmin.ts:144](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L144) Flip a venue's creation flag without touching other fields. #### Parameters ##### p [`SetVenueEnabledParams`](SetVenueEnabledParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> --- # /docs/api/index/interfaces/OperatorAdminConfig [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OperatorAdminConfig # Interface: OperatorAdminConfig Defined in: [operatorAdmin.ts:25](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L25) ## Properties ### walletClient? > `optional` **walletClient?**: `object` Defined in: [operatorAdmin.ts:27](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L27) A pre-built signer (e.g. a browser/wagmi wallet over an injected provider). *** ### account? > `optional` **account?**: `` `0x${string}` `` \| `Account` Defined in: [operatorAdmin.ts:29](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L29) A local signing account (e.g. from viem's privateKeyToAccount). *** ### privateKey? > `optional` **privateKey?**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:31](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L31) Private key — the SDK derives the account. *** ### publicClient? > `optional` **publicClient?**: `object` Defined in: [operatorAdmin.ts:33](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L33) Read client for receipts. Defaults to the client's WebSocket client. *** ### marketsCore? > `optional` **marketsCore?**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:35](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L35) MarketsCore address override. Defaults to `config.addresses.marketsCore`. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [operatorAdmin.ts:37](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L37) Default gas ceiling per tx. --- # /docs/api/index/interfaces/OperatorPreflightInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OperatorPreflightInput # Interface: OperatorPreflightInput Defined in: [preflight.ts:56](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L56) The operator fields the operator-step preflight inspects (subset of [IndexedOperator](../type-aliases/IndexedOperator.md)). ## Properties ### caller > **caller**: `` `0x${string}` `` Defined in: [preflight.ts:58](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L58) The connected signer — must own the operator to run machinery under it. *** ### owner > **owner**: `string` Defined in: [preflight.ts:59](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L59) *** ### enabled > **enabled**: `boolean` Defined in: [preflight.ts:60](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L60) *** ### feeRecipient > **feeRecipient**: `string` Defined in: [preflight.ts:61](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L61) --- # /docs/api/index/interfaces/OracleHubAdmin [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OracleHubAdmin # Interface: OracleHubAdmin Defined in: [oracleHub.ts:355](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L355) ## Methods ### getSchedulingCost() > **getSchedulingCost**(`def`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:358](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L358) Marginal scheduling cost for `def` (0 = would dedup). #### Parameters ##### def [`QuestionDefinitionInput`](QuestionDefinitionInput.md) #### Returns `Promise`\<`bigint`\> *** ### earmarkedOf() > **earmarkedOf**(`operatorId`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:360](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L360) Native LOCKED for an operator's outstanding markets (wei; never withdrawable). #### Parameters ##### operatorId `number` #### Returns `Promise`\<`bigint`\> *** ### creditOf() > **creditOf**(`operatorId`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:362](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L362) An operator's accrued WITHDRAWABLE surplus credit on the hub (wei). #### Parameters ##### operatorId `number` #### Returns `Promise`\<`bigint`\> *** ### outstandingOf() > **outstandingOf**(`operatorId`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:364](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L364) Count of an operator's bound-but-unresolved markets. #### Parameters ##### operatorId `number` #### Returns `Promise`\<`bigint`\> *** ### withdrawableOf() > **withdrawableOf**(`operatorId`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:366](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L366) Wei an operator's owner may withdraw right now (== `creditOf`). #### Parameters ##### operatorId `number` #### Returns `Promise`\<`bigint`\> *** ### payerCreditOf() > **payerCreditOf**(`payer`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:369](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L369) A1: withdrawable surplus credited to a reserve-PAYER (open-venue creator or the autonomous MarketCreator), drawn by that account itself. #### Parameters ##### payer `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### payerOf() > **payerOf**(`marketId`): `Promise`\<`` `0x${string}` ``\> Defined in: [oracleHub.ts:372](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L372) A1: the reserve-payer recorded for a market at onBind (surplus recipient); zero-address once settled + swept. #### Parameters ##### marketId `` `0x${string}` `` #### Returns `Promise`\<`` `0x${string}` ``\> *** ### resolveReserve() > **resolveReserve**(): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:374](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L374) The per-market resolution reserve attached+locked at onBind (wei). #### Returns `Promise`\<`bigint`\> *** ### quoteCreateMarketValue() > **quoteCreateMarketValue**(`def`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:378](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L378) THE §8e create-market value rule: `getSchedulingCost(def) + resolveReserve()` (the reserve is attached to the create; attach exactly this to `scheduleAndCreateMarket`; excess refunds). #### Parameters ##### def [`QuestionDefinitionInput`](QuestionDefinitionInput.md) #### Returns `Promise`\<`bigint`\> *** ### getQuestionState() > **getQuestionState**(`def`): `Promise`\<[`HubQuestionState`](HubQuestionState.md)\> Defined in: [oracleHub.ts:381](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L381) One definition's full dedup state: canonical key, the active question id it resolves to (0n = none), bind count, and the bound-market fan-out list. #### Parameters ##### def [`QuestionDefinitionInput`](QuestionDefinitionInput.md) #### Returns `Promise`\<[`HubQuestionState`](HubQuestionState.md)\> *** ### getQuestionIdByKey() > **getQuestionIdByKey**(`questionKey`): `Promise`\<`bigint`\> Defined in: [oracleHub.ts:383](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L383) The ACTIVE question id for a canonical key (0n = never scheduled). #### Parameters ##### questionKey `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### getBindCount() > **getBindCount**(`oracleQuestionId`): `Promise`\<`number`\> Defined in: [oracleHub.ts:385](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L385) Lifetime bind count for a question id. #### Parameters ##### oracleQuestionId `bigint` #### Returns `Promise`\<`number`\> *** ### getMarketsForQuestion() > **getMarketsForQuestion**(`oracleQuestionId`): `Promise`\<`` `0x${string}` ``[]\> Defined in: [oracleHub.ts:387](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L387) Every marketId bound to a question id (the fan-out list). #### Parameters ##### oracleQuestionId `bigint` #### Returns `Promise`\<`` `0x${string}` ``[]\> *** ### isHubApproved() > **isHubApproved**(): `Promise`\<`boolean`\> Defined in: [oracleHub.ts:391](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L391) Whether the module has the hub approved (`approvedAdapters(hub)`) — the Oracle v2 equivalent of the old per-adapter `isAdapterApproved`. Needs `config.addresses.binaryModule`. #### Returns `Promise`\<`boolean`\> *** ### getHubStatus() > **getHubStatus**(): `Promise`\<[`HubStatus`](HubStatus.md)\> Defined in: [oracleHub.ts:394](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L394) The hub's full live status (owner / balance / approval / subscription / gas + drain params / resolveReserve + pending drain). #### Returns `Promise`\<[`HubStatus`](HubStatus.md)\> *** ### scheduleQuestion() > **scheduleQuestion**(`p`): `Promise`\<[`ScheduleQuestionResult`](ScheduleQuestionResult.md)\> Defined in: [oracleHub.ts:401](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L401) Schedule a question through the hub (content-addressed: an identical template definition returns the EXISTING id and refunds the value). Resolves with the question id decoded from `QuestionScheduled` / `QuestionReused` and whether it deduplicated. #### Parameters ##### p [`ScheduleQuestionParams`](ScheduleQuestionParams.md) #### Returns `Promise`\<[`ScheduleQuestionResult`](ScheduleQuestionResult.md)\> *** ### withdraw() > **withdraw**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [oracleHub.ts:406](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L406) Withdraw an operator's accrued WITHDRAWABLE surplus credit (credit-only; OWNER-gated on-chain: only the operator's owner, read from MarketsCore, may draw it, and only up to `withdrawableOf` — else `InsufficientCredit`). The earmark backing live markets is untouchable. #### Parameters ##### p [`WithdrawParams`](WithdrawParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### withdrawMyCredit() > **withdrawMyCredit**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [oracleHub.ts:411](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L411) A1: withdraw the CALLER's own accrued payer credit (msg.sender-gated — the connected signer draws only its own surplus, up to `payerCreditOf(caller)`). This is how an open-venue creator claims their refund, and how the autonomous MarketCreator self-reclaims (via its own on-chain call). #### Parameters ##### p [`WithdrawMyCreditParams`](WithdrawMyCreditParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### fundHub() > **fundHub**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [oracleHub.ts:414](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L414) Send native to the hub's `receive()` — funds the reactivity bond (hub float; NOT credited to any operator — resolution funding is per-market). #### Parameters ##### p [`FundHubParams`](FundHubParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### setGasParams() > **setGasParams**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [oracleHub.ts:417](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L417) Update the reactivity gas params (OWNER-only). `maxFeePerGas` also reprices `resolveReserve()` immediately. #### Parameters ##### p [`SetHubGasParams`](SetHubGasParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### setDrainParams() > **setDrainParams**(`p`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [oracleHub.ts:421](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L421) Update the bounded-drain metering params (OWNER-only): `perMarketResolveGas` sizes `resolveReserve`, `callbackBaseGas` is the attributed overhead term, `maxResolvesPerCallback` + `resolveGasReserve` bound one callback's work. #### Parameters ##### p [`SetHubDrainParams`](SetHubDrainParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### enableReactivity() > **enableReactivity**(`p?`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [oracleHub.ts:425](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L425) Register the Somnia reactivity subscription (OWNER-only, one-shot). NOTE: calls the reactivity precompile at 0x0100, which does NOT exist on local anvil — testnet/mainnet only. #### Parameters ##### p? [`EnableHubReactivityParams`](EnableHubReactivityParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### migrateSubscription() > **migrateSubscription**(`p?`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [oracleHub.ts:428](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L428) Unsubscribe + re-subscribe with the current topic/gas params (OWNER-only; for upstream event-signature changes). Precompile — testnet/mainnet only. #### Parameters ##### p? [`EnableHubReactivityParams`](EnableHubReactivityParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> --- # /docs/api/index/interfaces/OracleHubAdminConfig [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OracleHubAdminConfig # Interface: OracleHubAdminConfig Defined in: [machineryWriter.ts:32](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/machineryWriter.ts#L32) Signer + read-client config shared by every machinery admin. Mirrors [OperatorAdminConfig](OperatorAdminConfig.md) — pass a `walletClient`, a local `account`, or a `privateKey`. ## Properties ### walletClient? > `optional` **walletClient?**: `object` Defined in: [machineryWriter.ts:34](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/machineryWriter.ts#L34) A pre-built signer (e.g. a browser/wagmi wallet over an injected provider). *** ### account? > `optional` **account?**: `` `0x${string}` `` \| `Account` Defined in: [machineryWriter.ts:36](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/machineryWriter.ts#L36) A local signing account (e.g. from viem's privateKeyToAccount). *** ### privateKey? > `optional` **privateKey?**: `` `0x${string}` `` Defined in: [machineryWriter.ts:38](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/machineryWriter.ts#L38) Private key — the SDK derives the account. *** ### publicClient? > `optional` **publicClient?**: `object` Defined in: [machineryWriter.ts:40](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/machineryWriter.ts#L40) Read client for receipts. Defaults to the client's WebSocket client. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [machineryWriter.ts:42](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/machineryWriter.ts#L42) Default gas ceiling per tx. --- # /docs/api/index/interfaces/OrderBookParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OrderBookParams # Interface: OrderBookParams Defined in: [marketCreatorAdmin.ts:24](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L24) Default CLOB order-book parameters a MarketCreator stamps onto each market it creates (mirror of the on-chain `OrderBookParameters` struct). All raw. ## Properties ### tickSize > **tickSize**: `bigint` Defined in: [marketCreatorAdmin.ts:25](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L25) *** ### minQuantity > **minQuantity**: `bigint` Defined in: [marketCreatorAdmin.ts:26](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L26) *** ### lotSize > **lotSize**: `bigint` Defined in: [marketCreatorAdmin.ts:27](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L27) --- # /docs/api/index/interfaces/OrderFill [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OrderFill # Interface: OrderFill Defined in: [trade.ts:94](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L94) A single fill that occurred within a tx (decoded from the pool's OrderFilled). ## Properties ### takerOrderId > **takerOrderId**: `bigint` Defined in: [trade.ts:95](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L95) *** ### makerOrderId > **makerOrderId**: `bigint` Defined in: [trade.ts:96](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L96) *** ### quantityFilled > **quantityFilled**: `bigint` Defined in: [trade.ts:97](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L97) *** ### takerRemainingQuantity > **takerRemainingQuantity**: `bigint` Defined in: [trade.ts:98](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L98) *** ### makerRemainingQuantity > **makerRemainingQuantity**: `bigint` Defined in: [trade.ts:99](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L99) *** ### fillPrice > **fillPrice**: `bigint` Defined in: [trade.ts:101](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L101) YES price (raw collateral units per whole outcome token). --- # /docs/api/index/interfaces/Permit2TransferFrom [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / Permit2TransferFrom # Interface: Permit2TransferFrom Defined in: [trade.ts:582](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L582) A canonical Permit2 `PermitTransferFrom` — the signed authorization the Permit2 mint path forwards to the router (which relays it to Permit2). Build it (and the EIP-712 signature) with a Permit2 SDK on the app side. ## Properties ### permitted > **permitted**: `object` Defined in: [trade.ts:584](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L584) Token + amount the signature authorizes. `token` must equal the market collateral. #### token > **token**: `` `0x${string}` `` #### amount > **amount**: `bigint` *** ### nonce > **nonce**: `bigint` Defined in: [trade.ts:586](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L586) Unordered Permit2 nonce. *** ### deadline > **deadline**: `bigint` Defined in: [trade.ts:588](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L588) Signature deadline (unix seconds). --- # /docs/api/index/interfaces/PerpPosition [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PerpPosition # Interface: PerpPosition Defined in: [reads.ts:171](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L171) An account's position in one perp pool (from the MarginBank). `size` is signed base units: positive = long, negative = short, zero = flat. ## Properties ### size > **size**: `bigint` Defined in: [reads.ts:172](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L172) *** ### avgEntryPrice > **avgEntryPrice**: `bigint` Defined in: [reads.ts:174](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L174) Volume-weighted average entry price (raw quote units per whole base). *** ### entryFundingIndex > **entryFundingIndex**: `bigint` Defined in: [reads.ts:176](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L176) Cumulative funding index at open / last settlement (1e18-scaled, signed). *** ### lastUpdatedTimestampNs > **lastUpdatedTimestampNs**: `bigint` Defined in: [reads.ts:178](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L178) Last position update (nanoseconds). --- # /docs/api/index/interfaces/PerpStateOnchain [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PerpStateOnchain # Interface: PerpStateOnchain Defined in: [reads.ts:125](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L125) A perp pool's live pricing/funding state, read straight from chain in one pipelined fan-out. Fresher than the indexed Market row (funding fields there only update when FundingUpdated fires, i.e. per settlement window). ## Properties ### markPrice > **markPrice**: `bigint` Defined in: [reads.ts:127](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L127) EMA-smoothed oracle mark price (raw quote units per whole base). *** ### indexPrice > **indexPrice**: `bigint` Defined in: [reads.ts:129](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L129) Unsmoothed oracle index price (raw quote units per whole base). *** ### indexUpdatedAt > **indexUpdatedAt**: `bigint` Defined in: [reads.ts:131](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L131) Index price oracle timestamp (seconds). *** ### fundingRate > **fundingRate**: `bigint` Defined in: [reads.ts:133](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L133) Current funding rate per settlement window (1e18-scaled fraction, signed). *** ### cumulativeFundingPerUnit > **cumulativeFundingPerUnit**: `bigint` Defined in: [reads.ts:135](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L135) Settled cumulative funding per base unit (1e18-scaled, signed). *** ### projectedCumulativeFundingPerUnit > **projectedCumulativeFundingPerUnit**: `bigint` Defined in: [reads.ts:137](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L137) Cumulative funding projected to now (unsettled accrual included). *** ### longOpenInterest > **longOpenInterest**: `bigint` Defined in: [reads.ts:139](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L139) Total long open interest in base units. *** ### shortOpenInterest > **shortOpenInterest**: `bigint` Defined in: [reads.ts:141](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L141) Total short open interest in base units. --- # /docs/api/index/interfaces/PlaceOrderParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PlaceOrderParams # Interface: PlaceOrderParams Defined in: [trade.ts:112](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L112) ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:114](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L114) BinaryPool address. *** ### side > **side**: [`BinarySide`](../type-aliases/BinarySide.md) Defined in: [trade.ts:115](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L115) *** ### price > **price**: `bigint` Defined in: [trade.ts:117](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L117) YES limit price as raw collateral units per whole outcome token (price × 10^decimals). *** ### quantity > **quantity**: `bigint` Defined in: [trade.ts:119](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L119) Outcome-token quantity, raw units. *** ### outcomeToken? > `optional` **outcomeToken?**: `` `0x${string}` `` Defined in: [trade.ts:122](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L122) Outcome-token singleton + this pool's YES/NO ids. Resolved from the pool (IBinaryPool.outcomeToken/yesId/noId) if omitted. *** ### yesId? > `optional` **yesId?**: `bigint` Defined in: [trade.ts:123](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L123) *** ### noId? > `optional` **noId?**: `bigint` Defined in: [trade.ts:124](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L124) *** ### collateral? > `optional` **collateral?**: `` `0x${string}` `` Defined in: [trade.ts:125](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L125) *** ### expireTimestampNs? > `optional` **expireTimestampNs?**: `bigint` Defined in: [trade.ts:127](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L127) Order expiry in ns. Defaults to ~50y (GTC). *** ### orderType? > `optional` **orderType?**: `number` Defined in: [trade.ts:131](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L131) OrderBook OrderType (see [ORDER\_TYPE](../variables/ORDER_TYPE.md)): 0 NormalOrder (rest), 1 FillOrKill, 2 ImmediateOrCancel, 3 PostOnly. Defaults to 0. A market order is an IOC (2) placed at the price extreme so it crosses immediately and cancels the remainder. *** ### autoApprove? > `optional` **autoApprove?**: `boolean` Defined in: [trade.ts:133](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L133) Approve the escrow token to the pool if allowance is short (default true). *** ### builder? > `optional` **builder?**: `` `0x${string}` `` Defined in: [trade.ts:137](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L137) Routing/builder frontend address to attribute the order to. Requires the trader to have opted this builder in via [Trader.approveBuilder](Trader.md#approvebuilder). Omit (or zero) for no routing fee. *** ### builderFeeBpsTimes1k? > `optional` **builderFeeBpsTimes1k?**: `bigint` Defined in: [trade.ts:140](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L140) Per-order builder/routing fee in the pool's native bps×1000 unit (≤ the venue's frozen `maxBuilderFee` ceiling AND ≤ the trader's approval). 0 = none. *** ### userData? > `optional` **userData?**: `bigint` Defined in: [trade.ts:144](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L144) Opaque market-maker bookkeeping tag (v2). Forwarded verbatim to the pool (stored on the order + emitted in `OrderPlaced`); the SDK never interprets it and the pool no longer uses it for side derivation. Default 0. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:145](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L145) --- # /docs/api/index/interfaces/PlaceOrderResult [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PlaceOrderResult # Interface: PlaceOrderResult Defined in: [trade.ts:105](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L105) Result of placing an order: the confirmed tx plus what it did on the book. ## Extends - [`TxResult`](TxResult.md) ## Properties ### hash > **hash**: `` `0x${string}` `` Defined in: [trade.ts:89](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L89) #### Inherited from [`TxResult`](TxResult.md).[`hash`](TxResult.md#hash) *** ### receipt > **receipt**: `TransactionReceipt` Defined in: [trade.ts:90](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L90) #### Inherited from [`TxResult`](TxResult.md).[`receipt`](TxResult.md#receipt) *** ### orderId? > `optional` **orderId?**: `bigint` Defined in: [trade.ts:107](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L107) The resting order's on-chain id, if the order rested (OrderPlaced emitted). *** ### fills > **fills**: [`OrderFill`](OrderFill.md)[] Defined in: [trade.ts:109](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L109) Fills that executed in this tx (empty for a cleanly-resting limit order). --- # /docs/api/index/interfaces/PlacePerpOrderParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PlacePerpOrderParams # Interface: PlacePerpOrderParams Defined in: [trade.ts:244](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L244) ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:246](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L246) PerpPool address. *** ### isBid > **isBid**: `boolean` Defined in: [trade.ts:248](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L248) True = buy/long the synthetic base; false = sell/short. *** ### price > **price**: `bigint` Defined in: [trade.ts:251](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L251) Limit price — raw quote (collateral) units per whole base. For a MARKET order pass a crossing price; it bounds the margin lock. *** ### quantity > **quantity**: `bigint` Defined in: [trade.ts:253](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L253) Base quantity, raw base units. *** ### expireTimestampNs? > `optional` **expireTimestampNs?**: `bigint` Defined in: [trade.ts:255](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L255) Order expiry in ns. Defaults to ~50y (GTC). *** ### orderType? > `optional` **orderType?**: `number` Defined in: [trade.ts:257](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L257) 0 limit (default) or 2 market (IOC). See [ORDER\_TYPE](../variables/ORDER_TYPE.md). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:258](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L258) --- # /docs/api/index/interfaces/PlaceSpotOrderParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PlaceSpotOrderParams # Interface: PlaceSpotOrderParams Defined in: [trade.ts:219](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L219) ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:221](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L221) SpotPool address. *** ### isBid > **isBid**: `boolean` Defined in: [trade.ts:223](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L223) True = buy the base asset (pay quote); false = sell base (pay base/native). *** ### price > **price**: `bigint` Defined in: [trade.ts:226](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L226) Limit price — raw quote units per whole base token. For a MARKET order pass a crossing price (best opposite level ± slippage); it bounds the escrow. *** ### quantity > **quantity**: `bigint` Defined in: [trade.ts:228](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L228) Base quantity, raw base units. *** ### baseDecimals > **baseDecimals**: `number` Defined in: [trade.ts:230](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L230) Base-token decimals (for the buy-side escrow math). *** ### quoteToken > **quoteToken**: `` `0x${string}` `` Defined in: [trade.ts:232](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L232) Quote token (approved on a buy). *** ### baseToken > **baseToken**: `` `0x${string}` `` Defined in: [trade.ts:234](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L234) Base token (approved on a non-native sell). *** ### baseIsNative? > `optional` **baseIsNative?**: `boolean` Defined in: [trade.ts:236](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L236) True when the base asset is native SOMI (sell pays via msg.value). *** ### orderType? > `optional` **orderType?**: `number` Defined in: [trade.ts:238](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L238) 0 limit (default) or 2 market (IOC). See [ORDER\_TYPE](../variables/ORDER_TYPE.md). *** ### autoApprove? > `optional` **autoApprove?**: `boolean` Defined in: [trade.ts:240](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L240) Approve the escrow token if allowance is short (default true). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:241](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L241) --- # /docs/api/index/interfaces/PlaceSpotStopOrderParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PlaceSpotStopOrderParams # Interface: PlaceSpotStopOrderParams Defined in: [trade.ts:306](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L306) ## Properties ### registry > **registry**: `` `0x${string}` `` Defined in: [trade.ts:308](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L308) SpotStopOrderRegistry address (the per-pool registry). *** ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:311](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L311) The SpotPool the registry trades on — needed for the operator-auth check, the ERC-20 escrow approval, and the native vault pre-load math. *** ### operatorRegistry? > `optional` **operatorRegistry?**: `` `0x${string}` `` Defined in: [trade.ts:314](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L314) Shared OperatorPermissionsRegistry where the one-time global approval is granted. Resolved from the live config (addresses.operatorPermissionsRegistry) if omitted. *** ### isBid > **isBid**: `boolean` Defined in: [trade.ts:315](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L315) *** ### quantity > **quantity**: `bigint` Defined in: [trade.ts:316](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L316) *** ### triggerPrice > **triggerPrice**: `bigint` Defined in: [trade.ts:318](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L318) Mark price that arms the trigger (raw quote per whole base). *** ### triggerOperator > **triggerOperator**: `0` \| `1` Defined in: [trade.ts:320](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L320) 0 = GTE (trigger when mark ≥ triggerPrice), 1 = LTE (mark ≤ triggerPrice). *** ### stopOrderType > **stopOrderType**: `0` \| `1` Defined in: [trade.ts:322](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L322) 0 = LIMIT (uses limitPrice), 1 = MARKET (slippage-bounded). *** ### limitPrice? > `optional` **limitPrice?**: `bigint` Defined in: [trade.ts:324](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L324) Limit price for a LIMIT stop order (raw quote per whole base). *** ### quoteToken > **quoteToken**: `` `0x${string}` `` Defined in: [trade.ts:326](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L326) Quote token — the input escrow on a buy stop. *** ### baseToken > **baseToken**: `` `0x${string}` `` Defined in: [trade.ts:328](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L328) Base token — the input escrow on a (non-native) sell stop. *** ### baseIsNative? > `optional` **baseIsNative?**: `boolean` Defined in: [trade.ts:330](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L330) True when the base asset is native SOMI (sell stops pre-load the pool vault). *** ### somiPayment? > `optional` **somiPayment?**: `bigint` Defined in: [trade.ts:333](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L333) SOMI to fund the reactivity subscription gas. Read from registry.somiPaymentPerOrder() if omitted. *** ### skipOperatorApproval? > `optional` **skipOperatorApproval?**: `boolean` Defined in: [trade.ts:336](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L336) Skip the one-time operator-approval check/tx (default false). Set true if you know the registry is already operator-approved for this owner. *** ### autoApprove? > `optional` **autoApprove?**: `boolean` Defined in: [trade.ts:338](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L338) Approve the ERC-20 escrow token to the pool if allowance is short (default true). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:339](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L339) --- # /docs/api/index/interfaces/PnLEvent [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PnLEvent # Interface: PnLEvent Defined in: [derivedReads.ts:207](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L207) One position-affecting event for the PnL fold, in the account's perspective, RAW units. Buys/sells are per-outcome; a mint/merge touches BOTH outcomes. ## Properties ### kind > **kind**: `"buy"` \| `"sell"` \| `"mint"` \| `"merge"` Defined in: [derivedReads.ts:208](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L208) *** ### outcomeIndex > **outcomeIndex**: `0` \| `1` Defined in: [derivedReads.ts:210](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L210) 0 = YES, 1 = NO. Ignored for mint/merge (they touch both). *** ### quantity > **quantity**: `bigint` Defined in: [derivedReads.ts:212](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L212) Token quantity (raw). For mint/merge this is the pair (set) amount. *** ### price > **price**: `bigint` Defined in: [derivedReads.ts:214](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/derivedReads.ts#L214) Fill price for the fill's own outcome, raw. Ignored for mint/merge. --- # /docs/api/index/interfaces/PoolBindingRecord [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PoolBindingRecord # Interface: PoolBindingRecord Defined in: [query.ts:2835](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2835) One interval in a pool's life during which it was bound 1:1 to a single market (indexer `PoolBinding`; id = `${pool}_${nonce}`). `MarketCreated` OPENS a binding; `PoolReleased` or the next `MarketCreated` on the same pool CLOSES it. An open binding (`toBlock` null) is the pool's current market. ## Properties ### id > **id**: `string` Defined in: [query.ts:2837](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2837) `${poolAddress}_${nonce}` *** ### poolAddress > **poolAddress**: `string` Defined in: [query.ts:2839](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2839) Lowercased pool address. *** ### marketId > **marketId**: `string` Defined in: [query.ts:2841](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2841) Lowercased bytes32 marketId this binding served. *** ### nonce > **nonce**: `string` Defined in: [query.ts:2843](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2843) Pool market nonce for this binding (decimal string). *** ### fromBlock > **fromBlock**: `string` Defined in: [query.ts:2844](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2844) *** ### fromLogIndex > **fromLogIndex**: `number` Defined in: [query.ts:2845](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2845) *** ### fromTimestamp > **fromTimestamp**: `string` Defined in: [query.ts:2846](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2846) *** ### toBlock > **toBlock**: `string` \| `null` Defined in: [query.ts:2848](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2848) Null while the binding is open (the pool's current market). *** ### toLogIndex > **toLogIndex**: `number` \| `null` Defined in: [query.ts:2849](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2849) *** ### toTimestamp > **toTimestamp**: `string` \| `null` Defined in: [query.ts:2850](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2850) *** ### closedBy > **closedBy**: `"Released"` \| `"Rotated"` \| `null` Defined in: [query.ts:2853](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2853) How the binding closed: `"Released"` (PoolReleased) | `"Rotated"` (the next MarketCreated recycled the pool onward); null while open. --- # /docs/api/index/interfaces/PreflightResult [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PreflightResult # Interface: PreflightResult Defined in: [preflight.ts:27](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L27) The uniform result every validator returns. `ok` is `blockers.length === 0`. ## Properties ### ok > **ok**: `boolean` Defined in: [preflight.ts:28](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L28) *** ### blockers > **blockers**: `string`[] Defined in: [preflight.ts:29](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L29) *** ### warnings > **warnings**: `string`[] Defined in: [preflight.ts:30](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L30) --- # /docs/api/index/interfaces/PriceCandle [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PriceCandle # Interface: PriceCandle Defined in: [priceFeed/types.ts:75](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L75) One OHLC candle — a `Candle` row, parsed to human units. ## Properties ### asset > **asset**: `string` Defined in: [priceFeed/types.ts:76](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L76) *** ### resolution > **resolution**: [`PriceCandleResolution`](../type-aliases/PriceCandleResolution.md) Defined in: [priceFeed/types.ts:77](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L77) *** ### bucketStart > **bucketStart**: `number` Defined in: [priceFeed/types.ts:79](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L79) Bucket start — unix seconds, chain time. *** ### open > **open**: `number` Defined in: [priceFeed/types.ts:80](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L80) *** ### high > **high**: `number` Defined in: [priceFeed/types.ts:81](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L81) *** ### low > **low**: `number` Defined in: [priceFeed/types.ts:82](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L82) *** ### close > **close**: `number` Defined in: [priceFeed/types.ts:83](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L83) *** ### emaClose > **emaClose**: `number` Defined in: [priceFeed/types.ts:85](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L85) EMA mark at bucket close (the feed's `markClose`). *** ### count > **count**: `number` Defined in: [priceFeed/types.ts:87](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L87) Number of feed ticks in the bucket (update density — NOT trade volume). --- # /docs/api/index/interfaces/PriceFeedConfig [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PriceFeedConfig # Interface: PriceFeedConfig Defined in: [config.ts:70](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L70) The realtime price-feed endpoint — the standalone EMA price-feed indexer (Hasura GraphQL). ONE endpoint serves every tracked asset (BTC/USDT, ETH/USDT, …); callers select an asset by filter. Snapshot + history read over HTTP; live prices stream over a Hasura WebSocket subscription. ## Properties ### url > **url**: `string` Defined in: [config.ts:72](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L72) HTTP GraphQL endpoint (snapshot + history + candles, all assets). *** ### wsUrl? > `optional` **wsUrl?**: `string` Defined in: [config.ts:75](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L75) WebSocket GraphQL endpoint for live subscriptions. Derived from `url` (http→ws, https→wss) when omitted. --- # /docs/api/index/interfaces/PriceFeedInfo [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PriceFeedInfo # Interface: PriceFeedInfo Defined in: [priceFeed/types.ts:91](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L91) Feed metadata + current price for one asset — the `Feed` singleton, parsed. ## Properties ### asset > **asset**: `string` Defined in: [priceFeed/types.ts:93](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L93) Asset key (the pair's base, e.g. `BTC`), uppercased. *** ### decimals > **decimals**: `number` Defined in: [priceFeed/types.ts:94](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L94) *** ### symbol > **symbol**: `string` \| `null` Defined in: [priceFeed/types.ts:96](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L96) The feed's on-chain pair symbol, e.g. `BTC/USDT`. *** ### base > **base**: `string` \| `null` Defined in: [priceFeed/types.ts:98](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L98) Base asset, e.g. `BTC`. *** ### quote > **quote**: `string` \| `null` Defined in: [priceFeed/types.ts:100](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L100) Quote asset, e.g. `USDT`. *** ### description > **description**: `string` \| `null` Defined in: [priceFeed/types.ts:101](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L101) *** ### latest > **latest**: [`LivePrice`](LivePrice.md) \| `null` Defined in: [priceFeed/types.ts:104](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L104) Current price (same value a live watch keeps current), or null if the feed has no observations yet. --- # /docs/api/index/interfaces/PricePoint [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PricePoint # Interface: PricePoint Defined in: [priceFeed/types.ts:58](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L58) One raw tick — a `PricePoint` row (one feed tick: the spot median + its EMA mark), parsed. `price` is the spot index; `ema` is the EMA-smoothed mark. ## Properties ### id > **id**: `string` Defined in: [priceFeed/types.ts:60](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L60) Indexer row id (`-`). *** ### asset > **asset**: `string` Defined in: [priceFeed/types.ts:61](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L61) *** ### price > **price**: `number` Defined in: [priceFeed/types.ts:62](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L62) *** ### ema > **ema**: `number` Defined in: [priceFeed/types.ts:63](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L63) *** ### requestId > **requestId**: `string` Defined in: [priceFeed/types.ts:67](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L67) Somnia-Agents batch request that produced this tick (provenance). One request prices every symbol in the tick, so all of a tick's rows share it. Decimal string (uint256). *** ### blockNumber > **blockNumber**: `number` Defined in: [priceFeed/types.ts:68](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L68) *** ### blockTimestamp > **blockTimestamp**: `number` Defined in: [priceFeed/types.ts:69](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L69) *** ### txHash > **txHash**: `string` Defined in: [priceFeed/types.ts:70](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L70) *** ### raw > **raw**: `object` Defined in: [priceFeed/types.ts:71](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L71) #### price > **price**: `string` #### ema > **ema**: `string` --- # /docs/api/index/interfaces/PriceWatchHandle [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PriceWatchHandle # Interface: PriceWatchHandle Defined in: [priceFeed/priceFeed.ts:26](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/priceFeed.ts#L26) A live price watch. `stop()` releases it (idempotent); the underlying subscription is shared and torn down when the last handle stops. ## Methods ### stop() > **stop**(): `void` Defined in: [priceFeed/priceFeed.ts:27](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/priceFeed.ts#L27) #### Returns `void` --- # /docs/api/index/interfaces/QuestionDefinitionInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / QuestionDefinitionInput # Interface: QuestionDefinitionInput Defined in: [oracleHub.ts:73](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L73) Full question definition — the input to `scheduleQuestion` / `getSchedulingCost` / `questionKeyOf`. Mirrors the on-chain `QuestionDefinition` struct field-for-field. ## Properties ### questionText > **questionText**: `string` Defined in: [oracleHub.ts:76](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L76) Free-form question text. EXCLUDED from the dedup key for template (all-JSON-source) definitions — the sources determine the answer. *** ### sources > **sources**: [`QuestionSourceInput`](QuestionSourceInput.md)[] Defined in: [oracleHub.ts:77](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L77) *** ### validAnswers > **validAnswers**: [`ValidAnswersInput`](ValidAnswersInput.md) Defined in: [oracleHub.ts:78](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L78) *** ### resolutionTime > **resolutionTime**: `bigint` Defined in: [oracleHub.ts:80](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L80) Unix-seconds the oracle answers at. *** ### minAgreement > **minAgreement**: `bigint` Defined in: [oracleHub.ts:81](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L81) *** ### subcommitteeSize > **subcommitteeSize**: `bigint` Defined in: [oracleHub.ts:82](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L82) *** ### subcommitteeThreshold > **subcommitteeThreshold**: `bigint` Defined in: [oracleHub.ts:83](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L83) --- # /docs/api/index/interfaces/QuestionIntervalInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / QuestionIntervalInput # Interface: QuestionIntervalInput Defined in: [oracleHub.ts:56](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L56) Inclusive numeric interval (`low <= value <= high` matches the bucket). ## Properties ### low > **low**: `bigint` Defined in: [oracleHub.ts:57](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L57) *** ### high > **high**: `bigint` Defined in: [oracleHub.ts:58](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L58) --- # /docs/api/index/interfaces/QuestionSourceInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / QuestionSourceInput # Interface: QuestionSourceInput Defined in: [oracleHub.ts:48](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L48) One answer source (website URL / JSON URL / on-chain contract) with its encoded params. ## Properties ### sourceType > **sourceType**: `number` Defined in: [oracleHub.ts:50](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L50) [QUESTION\_SOURCE\_TYPE](../variables/QUESTION_SOURCE_TYPE.md) value (uint8 on the wire). *** ### params > **params**: `` `0x${string}` `` Defined in: [oracleHub.ts:52](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L52) Source-type-specific encoded params. --- # /docs/api/index/interfaces/ReclaimOracleCreditParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ReclaimOracleCreditParams # Interface: ReclaimOracleCreditParams Defined in: [marketCreatorAdmin.ts:98](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L98) ## Properties ### creator > **creator**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:99](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L99) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [marketCreatorAdmin.ts:100](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L100) --- # /docs/api/index/interfaces/RedeemAuthorization [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RedeemAuthorization # Interface: RedeemAuthorization Defined in: [trade.ts:426](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L426) A signed authorization the position OWNER produces so a relayer can call [Trader.redeemFor](Trader.md#redeemfor) on their behalf. The on-chain payout is hard-pinned to `owner` (never the relayer), so this is a pure gas sponsorship — the signer keeps every cent of the proceeds. Produced by [Trader.signRedeemAuth](Trader.md#signredeemauth), consumed by [Trader.redeemFor](Trader.md#redeemfor). ## Properties ### owner > **owner**: `` `0x${string}` `` Defined in: [trade.ts:428](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L428) The position owner (the signer). The payout is paid here on-chain. *** ### operatorId > **operatorId**: `number` Defined in: [trade.ts:430](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L430) Routing operator id (uint32) for attribution; part of the signed struct. *** ### venueId > **venueId**: `` `0x${string}` `` Defined in: [trade.ts:432](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L432) Routing venue id (bytes32 hex); part of the signed struct. *** ### marketId > **marketId**: `` `0x${string}` `` Defined in: [trade.ts:434](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L434) bytes32 marketId the redemption targets. *** ### outcomeIdx > **outcomeIdx**: `0` \| `1` Defined in: [trade.ts:436](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L436) Outcome the owner holds (0 = YES, 1 = NO). *** ### amount > **amount**: `bigint` Defined in: [trade.ts:438](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L438) Outcome-token amount to burn for collateral. *** ### nonce > **nonce**: `bigint` Defined in: [trade.ts:440](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L440) Per-owner replay nonce (module tracks `(owner, nonce)`); any unused value. *** ### deadline > **deadline**: `bigint` Defined in: [trade.ts:442](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L442) Signature deadline (unix seconds). The module rejects a stale authorization. *** ### signature > **signature**: `` `0x${string}` `` Defined in: [trade.ts:444](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L444) The EIP-712 signature over the authorization (65-byte r‖s‖v hex). --- # /docs/api/index/interfaces/RedeemDirectParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RedeemDirectParams # Interface: RedeemDirectParams Defined in: [trade.ts:492](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L492) Low-level direct redemption against the BinarySettlement singleton — bypasses the module (no operator attribution). Burns the caller's outcome tokens and pays `to`. Prefer the module-routed [RedeemParams](RedeemParams.md) for normal trading; use this for keeper/tooling paths that hold the raw outcome id. ## Properties ### outcomeId > **outcomeId**: `bigint` Defined in: [trade.ts:494](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L494) The ERC-6909 outcome id to redeem (encodes pool + nonce + index). *** ### amount > **amount**: `bigint` Defined in: [trade.ts:496](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L496) Outcome-token quantity to burn. *** ### to? > `optional` **to?**: `` `0x${string}` `` Defined in: [trade.ts:498](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L498) Recipient of the released collateral (default: the trader's own address). *** ### settlement? > `optional` **settlement?**: `` `0x${string}` `` Defined in: [trade.ts:501](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L501) BinarySettlement address; resolved from `config.addresses.binarySettlement` when omitted. Throws if neither is set. *** ### outcomeToken? > `optional` **outcomeToken?**: `` `0x${string}` `` Defined in: [trade.ts:504](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L504) Outcome-token singleton (for the operator grant). Resolved from the settlement's `outcomeToken()` when omitted. *** ### autoApprove? > `optional` **autoApprove?**: `boolean` Defined in: [trade.ts:506](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L506) Ensure the settlement is an operator on the outcome-token singleton (default true). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:507](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L507) --- # /docs/api/index/interfaces/RedeemForParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RedeemForParams # Interface: RedeemForParams Defined in: [trade.ts:478](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L478) Relayer path: submit a position owner's pre-signed [RedeemAuthorization](RedeemAuthorization.md) so THEY pay the gas while the OWNER receives the payout. The caller (relayer) need not be the owner; the module recovers the signature to `owner` and pays `owner` directly. ## Properties ### authorization > **authorization**: [`RedeemAuthorization`](RedeemAuthorization.md) Defined in: [trade.ts:480](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L480) The owner's signed authorization (from [Trader.signRedeemAuth](Trader.md#signredeemauth)). *** ### module? > `optional` **module?**: `` `0x${string}` `` Defined in: [trade.ts:484](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L484) BinaryMarketsModule address; resolved from `config.addresses.binaryModule` when omitted. Must match the `verifyingContract` the authorization was signed against. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:485](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L485) --- # /docs/api/index/interfaces/RedeemNativeParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RedeemNativeParams # Interface: RedeemNativeParams Defined in: [trade.ts:621](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L621) ## Properties ### marketId > **marketId**: `` `0x${string}` `` Defined in: [trade.ts:623](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L623) bytes32 market key redeemed against; its collateral must be wNative. *** ### outcomeIdx > **outcomeIdx**: `0` \| `1` Defined in: [trade.ts:627](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L627) Outcome the caller holds (0 = YES, 1 = NO). The router is type-blind — it forwards this to the core, which the pool prices (winner 1:1, void 1/N per side). *** ### amount > **amount**: `bigint` Defined in: [trade.ts:629](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L629) Amount of that outcome's tokens to redeem for a native payout. *** ### operatorId > **operatorId**: `number` Defined in: [trade.ts:631](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L631) Routing operator id (uint32) for attribution; 0 = none. *** ### venueId > **venueId**: `` `0x${string}` `` Defined in: [trade.ts:633](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L633) Routing venue id (bytes32 hex); 32-byte zero = none. *** ### router? > `optional` **router?**: `` `0x${string}` `` Defined in: [trade.ts:636](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L636) CollateralRouter address; resolved from `config.addresses.collateralRouter` if omitted. Throws if neither is set. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:637](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L637) --- # /docs/api/index/interfaces/RedeemParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RedeemParams # Interface: RedeemParams Defined in: [trade.ts:373](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L373) ## Properties ### marketId > **marketId**: `` `0x${string}` `` Defined in: [trade.ts:377](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L377) bytes32 marketId the module keys the redemption on (settlement-extraction v2: redemption is module-routed — the module pulls the caller's winning tokens, finalizes-if-needed, and redeems through the BinarySettlement singleton). *** ### amount > **amount**: `bigint` Defined in: [trade.ts:379](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L379) Outcome-token amount to burn for collateral. *** ### outcomeIdx? > `optional` **outcomeIdx?**: `0` \| `1` Defined in: [trade.ts:382](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L382) Winning outcome (0 = YES, 1 = NO). Looked up via `market.winningOutcome()` when omitted (needs `market` set, else pass `outcomeIdx` explicitly). *** ### market? > `optional` **market?**: `` `0x${string}` `` Defined in: [trade.ts:385](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L385) BinaryMarket address — only needed to auto-look-up `outcomeIdx` / `outcomeToken` when those are omitted. *** ### operatorId? > `optional` **operatorId?**: `number` Defined in: [trade.ts:387](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L387) Routing operator id (uint32) for attribution; 0 = none (default). *** ### venueId? > `optional` **venueId?**: `` `0x${string}` `` Defined in: [trade.ts:389](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L389) Routing venue id (bytes32 hex); 32-byte zero = none (default). *** ### outcomeToken? > `optional` **outcomeToken?**: `` `0x${string}` `` Defined in: [trade.ts:392](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L392) Outcome-token singleton the winning position lives on (for the operator grant). Looked up via `market.outcomeToken()` when omitted. *** ### module? > `optional` **module?**: `` `0x${string}` `` Defined in: [trade.ts:395](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L395) BinaryMarketsModule address; resolved from `config.addresses.binaryModule` when omitted. Throws if neither is set. *** ### autoApprove? > `optional` **autoApprove?**: `boolean` Defined in: [trade.ts:397](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L397) Ensure the module is an operator on the outcome-token singleton (default true). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:398](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L398) --- # /docs/api/index/interfaces/ReduceOrderParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ReduceOrderParams # Interface: ReduceOrderParams Defined in: [trade.ts:172](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L172) Shrink a resting order's remaining quantity IN PLACE — keeps its price-time queue priority (unlike [Trader.placeOrder](Trader.md#placeorder) + amend, which re-queues at the back). Works on spot AND binary pools: BinaryPool implements the reduce-refund hook, so the freed escrow (collateral for a buy, outcome tokens for a sell) is returned to the owner. ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:174](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L174) BinaryPool (or SpotPool) address hosting the resting order. *** ### orderId > **orderId**: `string` \| `bigint` Defined in: [trade.ts:176](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L176) uint128 OrderId of the resting order to shrink (decimal string or bigint). *** ### newQuantityRemaining > **newQuantityRemaining**: `bigint` Defined in: [trade.ts:181](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L181) The order's NEW remaining quantity. Must be a `lotSize` multiple, `>= minQuantity`, and strictly less than the current remaining. Reverts on-chain (`ExpiredOrderMustBeCancelled`) if the order has already expired — use [Trader.cancelOrder](Trader.md#cancelorder) to recover an expired order's funds. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:182](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L182) --- # /docs/api/index/interfaces/RegisterOperatorParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RegisterOperatorParams # Interface: RegisterOperatorParams Defined in: [operatorAdmin.ts:60](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L60) ## Properties ### feeRecipient > **feeRecipient**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:61](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L61) *** ### enabled > **enabled**: `boolean` Defined in: [operatorAdmin.ts:62](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L62) *** ### policy > **policy**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:64](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L64) IVenuePolicy address; zero for none (operator-wide gate is optional). *** ### context? > `optional` **context?**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:66](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L66) Opaque metadata bytes attached to the operator; empty (`0x`) by default. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [operatorAdmin.ts:67](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L67) --- # /docs/api/index/interfaces/RegisterOperatorResult [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RegisterOperatorResult # Interface: RegisterOperatorResult Defined in: [operatorAdmin.ts:69](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L69) Base result of a confirmed write — the SDK waits for the receipt before resolving. ## Extends - [`TxResult`](TxResult.md) ## Properties ### operatorId > **operatorId**: `number` Defined in: [operatorAdmin.ts:70](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L70) *** ### hash > **hash**: `` `0x${string}` `` Defined in: [trade.ts:89](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L89) #### Inherited from [`TxResult`](TxResult.md).[`hash`](TxResult.md#hash) *** ### receipt > **receipt**: `TransactionReceipt` Defined in: [trade.ts:90](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L90) #### Inherited from [`TxResult`](TxResult.md).[`receipt`](TxResult.md#receipt) --- # /docs/api/index/interfaces/RegisterSeriesParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RegisterSeriesParams # Interface: RegisterSeriesParams Defined in: [marketCreatorAdmin.ts:59](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L59) ## Properties ### creator > **creator**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:60](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L60) *** ### seriesId > **seriesId**: `number` Defined in: [marketCreatorAdmin.ts:61](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L61) *** ### collateral > **collateral**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:63](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L63) Per-series collateral ERC-20. *** ### asset > **asset**: `string` Defined in: [marketCreatorAdmin.ts:65](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L65) Underlying asset label (e.g. "BTC/USDT"). *** ### numericDecimals > **numericDecimals**: `number` Defined in: [marketCreatorAdmin.ts:66](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L66) *** ### intervalSec > **intervalSec**: `number` Defined in: [marketCreatorAdmin.ts:68](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L68) Roll interval in seconds; the module rejects < 60 (`InvalidSeriesConfig`). *** ### settlementWindow > **settlementWindow**: `number` Defined in: [marketCreatorAdmin.ts:70](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L70) Post-expiry settlement window in seconds. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [marketCreatorAdmin.ts:71](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L71) --- # /docs/api/index/interfaces/ReleasePoolParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ReleasePoolParams # Interface: ReleasePoolParams Defined in: [trade.ts:543](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L543) Permissionless keeper entry: release a finalized, drained pool back to its creator's free list for recycle onto the next market. ## Properties ### marketId > **marketId**: `` `0x${string}` `` Defined in: [trade.ts:545](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L545) bytes32 marketId whose (finalized, book-empty) pool to release. *** ### module? > `optional` **module?**: `` `0x${string}` `` Defined in: [trade.ts:547](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L547) BinaryMarketsModule address; resolved from `config.addresses.binaryModule` when omitted. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:548](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L548) --- # /docs/api/index/interfaces/ResolveParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ResolveParams # Interface: ResolveParams Defined in: [trade.ts:648](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L648) ## Properties ### market > **market**: `` `0x${string}` `` Defined in: [trade.ts:649](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L649) *** ### outcomeIdx > **outcomeIdx**: `0` \| `1` Defined in: [trade.ts:650](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L650) *** ### fakeOracle? > `optional` **fakeOracle?**: `` `0x${string}` `` Defined in: [trade.ts:652](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L652) FakeOracle address; defaults to the configured one. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:653](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L653) --- # /docs/api/index/interfaces/RollPreflightInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RollPreflightInput # Interface: RollPreflightInput Defined in: [preflight.ts:241](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L241) Inputs for the roll-step preflight: the series exists on-chain (its `intervalSec > 0`), the creator is funded, and the chain supports rolls. ## Properties ### seriesIntervalSec > **seriesIntervalSec**: `number` Defined in: [preflight.ts:243](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L243) The series' on-chain `intervalSec` (0 ⇒ never registered). *** ### creatorBalanceWei > **creatorBalanceWei**: `bigint` Defined in: [preflight.ts:244](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L244) *** ### precompileAvailable > **precompileAvailable**: `boolean` Defined in: [preflight.ts:245](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L245) --- # /docs/api/index/interfaces/RouterMintBase [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RouterMintBase # Interface: RouterMintBase Defined in: [trade.ts:592](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L592) Shared inputs for the CollateralRouter complete-set entry points. ## Extended by - [`MintSetNativeParams`](MintSetNativeParams.md) - [`MintSetPermit2Params`](MintSetPermit2Params.md) ## Properties ### marketId > **marketId**: `` `0x${string}` `` Defined in: [trade.ts:594](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L594) bytes32 market key the set is minted for (the market's `marketId`). *** ### operatorId > **operatorId**: `number` Defined in: [trade.ts:596](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L596) Routing operator id (uint32) for attribution; 0 = none. *** ### venueId > **venueId**: `` `0x${string}` `` Defined in: [trade.ts:598](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L598) Routing venue id (bytes32 hex); 32-byte zero = none. *** ### router? > `optional` **router?**: `` `0x${string}` `` Defined in: [trade.ts:601](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L601) CollateralRouter address; resolved from `config.addresses.collateralRouter` if omitted. Throws if neither is set (never sends to the zero address). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:602](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L602) --- # /docs/api/index/interfaces/ScheduleQuestionParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ScheduleQuestionParams # Interface: ScheduleQuestionParams Defined in: [oracleHub.ts:292](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L292) ## Properties ### def > **def**: [`QuestionDefinitionInput`](QuestionDefinitionInput.md) Defined in: [oracleHub.ts:293](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L293) *** ### valueWei? > `optional` **valueWei?**: `bigint` Defined in: [oracleHub.ts:296](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L296) Native value to attach. Defaults to the live `getSchedulingCost(def)` quote (the marginal price — 0 for a dedup reuse). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [oracleHub.ts:297](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L297) --- # /docs/api/index/interfaces/ScheduleQuestionResult [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ScheduleQuestionResult # Interface: ScheduleQuestionResult Defined in: [oracleHub.ts:299](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L299) Base result of a confirmed write — the SDK waits for the receipt before resolving. ## Extends - [`TxResult`](TxResult.md) ## Properties ### oracleQuestionId > **oracleQuestionId**: `bigint` Defined in: [oracleHub.ts:301](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L301) Oracle-assigned (or deduplicated) question id. *** ### reused > **reused**: `boolean` Defined in: [oracleHub.ts:304](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L304) True when the definition deduplicated onto an EXISTING question (`QuestionReused` — the caller was charged nothing). *** ### hash > **hash**: `` `0x${string}` `` Defined in: [trade.ts:89](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L89) #### Inherited from [`TxResult`](TxResult.md).[`hash`](TxResult.md#hash) *** ### receipt > **receipt**: `TransactionReceipt` Defined in: [trade.ts:90](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L90) #### Inherited from [`TxResult`](TxResult.md).[`receipt`](TxResult.md#receipt) --- # /docs/api/index/interfaces/SeriesOnchain [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SeriesOnchain # Interface: SeriesOnchain Defined in: [marketCreatorAdmin.ts:114](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L114) One Series' live on-chain config (mirror of the `Series` struct). ## Properties ### collateral > **collateral**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:115](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L115) *** ### asset > **asset**: `string` Defined in: [marketCreatorAdmin.ts:116](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L116) *** ### numericDecimals > **numericDecimals**: `number` Defined in: [marketCreatorAdmin.ts:117](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L117) *** ### intervalSec > **intervalSec**: `number` Defined in: [marketCreatorAdmin.ts:118](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L118) *** ### settlementWindow > **settlementWindow**: `number` Defined in: [marketCreatorAdmin.ts:119](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L119) --- # /docs/api/index/interfaces/SeriesPreflightInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SeriesPreflightInput # Interface: SeriesPreflightInput Defined in: [preflight.ts:216](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L216) The series fields the series-step preflight inspects. ## Properties ### seriesId > **seriesId**: `number` Defined in: [preflight.ts:217](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L217) *** ### asset > **asset**: `string` Defined in: [preflight.ts:218](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L218) *** ### intervalSec > **intervalSec**: `number` Defined in: [preflight.ts:219](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L219) *** ### collateral > **collateral**: `` `0x${string}` `` Defined in: [preflight.ts:220](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L220) --- # /docs/api/index/interfaces/SetAdapterApprovedParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SetAdapterApprovedParams # Interface: SetAdapterApprovedParams Defined in: [governanceAdmin.ts:16](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/governanceAdmin.ts#L16) ## Properties ### adapter > **adapter**: `` `0x${string}` `` Defined in: [governanceAdmin.ts:17](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/governanceAdmin.ts#L17) *** ### approved > **approved**: `boolean` Defined in: [governanceAdmin.ts:18](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/governanceAdmin.ts#L18) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [governanceAdmin.ts:19](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/governanceAdmin.ts#L19) --- # /docs/api/index/interfaces/SetHubDrainParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SetHubDrainParams # Interface: SetHubDrainParams Defined in: [oracleHub.ts:343](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L343) ## Properties ### perMarketResolveGas > **perMarketResolveGas**: `bigint` Defined in: [oracleHub.ts:344](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L344) *** ### callbackBaseGas > **callbackBaseGas**: `bigint` Defined in: [oracleHub.ts:345](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L345) *** ### maxResolvesPerCallback > **maxResolvesPerCallback**: `bigint` Defined in: [oracleHub.ts:346](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L346) *** ### resolveGasReserve > **resolveGasReserve**: `bigint` Defined in: [oracleHub.ts:347](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L347) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [oracleHub.ts:348](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L348) --- # /docs/api/index/interfaces/SetHubGasParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SetHubGasParams # Interface: SetHubGasParams Defined in: [oracleHub.ts:336](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L336) ## Properties ### priorityFeePerGas > **priorityFeePerGas**: `bigint` Defined in: [oracleHub.ts:337](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L337) *** ### maxFeePerGas > **maxFeePerGas**: `bigint` Defined in: [oracleHub.ts:338](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L338) *** ### gasLimit > **gasLimit**: `bigint` Defined in: [oracleHub.ts:339](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L339) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [oracleHub.ts:340](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L340) --- # /docs/api/index/interfaces/SetOperatorEnabledParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SetOperatorEnabledParams # Interface: SetOperatorEnabledParams Defined in: [operatorAdmin.ts:83](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L83) ## Properties ### operatorId > **operatorId**: `number` Defined in: [operatorAdmin.ts:84](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L84) *** ### enabled > **enabled**: `boolean` Defined in: [operatorAdmin.ts:85](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L85) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [operatorAdmin.ts:86](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L86) --- # /docs/api/index/interfaces/SetPerpLeverageParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SetPerpLeverageParams # Interface: SetPerpLeverageParams Defined in: [trade.ts:297](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L297) ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:299](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L299) PerpPool the leverage cap applies to. *** ### leverageX > **leverageX**: `number` Defined in: [trade.ts:301](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L301) Max leverage multiplier (e.g. 10 = 10x), bounded by the protocol limit. *** ### marginBank? > `optional` **marginBank?**: `` `0x${string}` `` Defined in: [trade.ts:302](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L302) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:303](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L303) --- # /docs/api/index/interfaces/SetReactivityGasParamsParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SetReactivityGasParamsParams # Interface: SetReactivityGasParamsParams Defined in: [marketCreatorAdmin.ts:80](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L80) ## Properties ### creator > **creator**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:81](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L81) *** ### priorityFeePerGas > **priorityFeePerGas**: `bigint` Defined in: [marketCreatorAdmin.ts:82](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L82) *** ### maxFeePerGas > **maxFeePerGas**: `bigint` Defined in: [marketCreatorAdmin.ts:83](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L83) *** ### gasLimit > **gasLimit**: `bigint` Defined in: [marketCreatorAdmin.ts:84](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L84) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [marketCreatorAdmin.ts:85](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L85) --- # /docs/api/index/interfaces/SetVenueEnabledParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SetVenueEnabledParams # Interface: SetVenueEnabledParams Defined in: [operatorAdmin.ts:118](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L118) ## Properties ### operatorId > **operatorId**: `number` Defined in: [operatorAdmin.ts:119](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L119) *** ### venueId > **venueId**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:120](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L120) *** ### creationEnabled > **creationEnabled**: `boolean` Defined in: [operatorAdmin.ts:121](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L121) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [operatorAdmin.ts:122](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L122) --- # /docs/api/index/interfaces/SettlementRecord [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SettlementRecord # Interface: SettlementRecord Defined in: [trade.ts:553](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L553) A market's settlement record on the BinarySettlement singleton (the permanent redemption home). Mirrors the on-chain `MarketSettlement` struct. ## Properties ### collateralToken > **collateralToken**: `` `0x${string}` `` Defined in: [trade.ts:555](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L555) The ERC-20 collateral the net backing is held in. *** ### backing > **backing**: `bigint` Defined in: [trade.ts:558](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L558) The NET collateral held for this market (post fee-skim on resolution), decremented by each redemption's payout. *** ### finalized > **finalized**: `boolean` Defined in: [trade.ts:560](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L560) True once the pool's backing + snapshot have been swept in. Gates redemption. *** ### voided > **voided**: `boolean` Defined in: [trade.ts:562](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L562) True if the market voided (both sides redeem at half; never a settlement fee). *** ### winningOutcome > **winningOutcome**: `number` Defined in: [trade.ts:565](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L565) The winning outcome index (0 = YES, 1 = NO); derived as argmax of `payoutNumerators`. Meaningful only when `!voided`. *** ### payoutNumerators > **payoutNumerators**: `bigint`[] Defined in: [trade.ts:568](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L568) Settlement v3 fee-scaled payout VECTOR (denominator 10_000_000). Redemption of outcome `i` pays `amount × payoutNumerators[i] / 10_000_000`. *** ### settlementFeeBpsTimes1k > **settlementFeeBpsTimes1k**: `bigint` Defined in: [trade.ts:570](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L570) The one-time settlement-fee rate skimmed at finalize (bps×1000; retained for audit). *** ### feeRecipient > **feeRecipient**: `` `0x${string}` `` Defined in: [trade.ts:572](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L572) The address the settlement fee was skimmed to at finalize. *** ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:574](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L574) The pool that finalized this market (the address encoded in the outcome ids). *** ### nonce > **nonce**: `bigint` Defined in: [trade.ts:576](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L576) The pool's market nonce for this record. --- # /docs/api/index/interfaces/SignRedeemAuthParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SignRedeemAuthParams # Interface: SignRedeemAuthParams Defined in: [trade.ts:451](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L451) Inputs to [Trader.signRedeemAuth](Trader.md#signredeemauth) — everything in the signed struct EXCEPT the signature (which the call produces). Signed by the connected signer (the position owner); the resulting [RedeemAuthorization](RedeemAuthorization.md) is handed to a relayer to submit via [Trader.redeemFor](Trader.md#redeemfor). ## Properties ### marketId > **marketId**: `` `0x${string}` `` Defined in: [trade.ts:453](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L453) bytes32 marketId the redemption targets. *** ### outcomeIdx > **outcomeIdx**: `0` \| `1` Defined in: [trade.ts:455](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L455) Outcome the owner holds (0 = YES, 1 = NO). *** ### amount > **amount**: `bigint` Defined in: [trade.ts:457](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L457) Outcome-token amount to burn for collateral. *** ### nonce > **nonce**: `bigint` Defined in: [trade.ts:459](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L459) Per-owner replay nonce; any value not yet consumed for this owner. *** ### deadline > **deadline**: `bigint` Defined in: [trade.ts:461](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L461) Signature deadline (unix seconds). *** ### operatorId? > `optional` **operatorId?**: `number` Defined in: [trade.ts:463](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L463) Routing operator id (uint32) for attribution; 0 = none (default). *** ### venueId? > `optional` **venueId?**: `` `0x${string}` `` Defined in: [trade.ts:465](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L465) Routing venue id (bytes32 hex); 32-byte zero = none (default). *** ### owner? > `optional` **owner?**: `` `0x${string}` `` Defined in: [trade.ts:468](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L468) Owner the payout is pinned to; defaults to the connected signer's address. Must be the address whose signer produces the signature. *** ### module? > `optional` **module?**: `` `0x${string}` `` Defined in: [trade.ts:471](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L471) BinaryMarketsModule address — the EIP-712 `verifyingContract`; resolved from `config.addresses.binaryModule` when omitted. --- # /docs/api/index/interfaces/SomniaMarketsAddresses [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SomniaMarketsAddresses # Interface: SomniaMarketsAddresses Defined in: [config.ts:9](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L9) Protocol contract addresses (all optional — features degrade if unset). ## Properties ### fakeOracle? > `optional` **fakeOracle?**: `` `0x${string}` `` Defined in: [config.ts:11](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L11) FakeOracle resolver (demo resolve/void). *** ### collateral? > `optional` **collateral?**: `` `0x${string}` `` Defined in: [config.ts:15](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L15) Per-venue collateral ERC-20 (the venue's quote/collateral token; on test environments this is the faucet-capable TestUSDC). Preferred over `testUsdc`, which remains as the legacy/fallback alias. *** ### testUsdc? > `optional` **testUsdc?**: `` `0x${string}` `` Defined in: [config.ts:18](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L18) TestUSDC collateral (faucet + balances). Legacy/fallback alias for [SomniaMarketsAddresses.collateral](#collateral). *** ### binaryModule? > `optional` **binaryModule?**: `` `0x${string}` `` Defined in: [config.ts:19](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L19) *** ### marketCreator? > `optional` **marketCreator?**: `` `0x${string}` `` Defined in: [config.ts:22](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L22) MarketCreator factory. When set, the live tail watches MarketCreated and picks up new binary markets the block they deploy — no indexer round-trip. *** ### clobFactory? > `optional` **clobFactory?**: `` `0x${string}` `` Defined in: [config.ts:23](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L23) *** ### binaryPoolImpl? > `optional` **binaryPoolImpl?**: `` `0x${string}` `` Defined in: [config.ts:24](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L24) *** ### binarySettlement? > `optional` **binarySettlement?**: `` `0x${string}` `` Defined in: [config.ts:30](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L30) The permanent BinarySettlement singleton (settlement-extraction v2). Every pool finalizes its markets into it and every redemption routes through it, so a pool can be recycled onto the next market. Needed by the low-level `redeemDirect` / `claimOwed` / `getSettlement` trader methods, which throw if it is unset. Absent on pre-v2 (pool-redeem) deploys. *** ### operatorPermissionsRegistry? > `optional` **operatorPermissionsRegistry?**: `` `0x${string}` `` Defined in: [config.ts:33](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L33) Shared OperatorPermissionsRegistry — users operator-approve a SpotStopOrderRegistry here (once, globally) so it can place their stop order via the pool at trigger time. *** ### marketsCore? > `optional` **marketsCore?**: `` `0x${string}` `` Defined in: [config.ts:37](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L37) MarketsCore — the control-plane registry of operators, typed venues, and the module binding per market type. Needed by the operator/venue admin reads + `createOperatorAdmin` writes. *** ### collateralRouter? > `optional` **collateralRouter?**: `` `0x${string}` `` Defined in: [config.ts:42](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L42) CollateralRouter periphery — the native-token (wrap/unwrap) + Permit2 entry over BinaryMarketsModule's complete-set flow. May be absent for an environment where only the plain-ERC-20 path is deployed; the router-based trader methods throw if it is unset rather than sending to the zero address. *** ### marketCreatorFactory? > `optional` **marketCreatorFactory?**: `` `0x${string}` `` Defined in: [config.ts:46](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L46) MarketCreatorFactory — stamps out per-operator/venue MarketCreator (+ its policy) instances, the operator "market machinery" layer. Needed by `createMarketCreatorAdmin` writes; the admin throws if it is unset. *** ### oracleHub? > `optional` **oracleHub?**: `` `0x${string}` `` Defined in: [config.ts:55](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L55) The OracleHub proxy (Oracle v2 §8e) — the protocol's ONE governance-approved oracle adapter. Every market creation binds through it (content-addressed `scheduleQuestion` dedup, earmark-at-creation resolution funding + bounded-drain exact metering, payout-vector delivery). Needed by the OracleHub reads (`quoteCreateMarketValue`, `getSchedulingCost`, `earmarkedOf`, `resolveReserve`) and the `createOracleHubAdmin` writes; those throw if it is unset. Also the default `adapter` for `createMarketCreatorAdmin.createMarketCreator`. *** ### ~~oracleAdapterFactory?~~ > `optional` **oracleAdapterFactory?**: `` `0x${string}` `` Defined in: [config.ts:59](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L59) #### Deprecated LEGACY (pre-oracle-v2): OracleAdapterFactory. The factory contract was deleted in Oracle v2 — use [SomniaMarketsAddresses.oracleHub](#oraclehub). Kept only so old configs keep type-checking; nothing in the SDK reads it. *** ### ~~sharedOracleAdapter?~~ > `optional` **sharedOracleAdapter?**: `` `0x${string}` `` Defined in: [config.ts:63](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L63) #### Deprecated LEGACY (pre-oracle-v2): the shared ProphecyOracleAdapter proxy. Replaced by [SomniaMarketsAddresses.oracleHub](#oraclehub). Kept only so old configs keep type-checking; nothing in the SDK reads it. --- # /docs/api/index/interfaces/SomniaMarketsClient [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SomniaMarketsClient # Interface: SomniaMarketsClient Defined in: [somniaMarketsClient.ts:131](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L131) An SDK client — the single handle for all protocol I/O. This is the raw engine tier, reached through the exchange (`new SomniaMarkets(config)` → `exchange.client`). Each exchange's engine is fully isolated: its own config, live store, and (lazily opened) chain WebSocket, so several can coexist in one process without sharing state. The read surface has three tiers — pick by freshness need: 1. **Live store** (`getLive*`, synchronous): zero round-trips, updates the moment an event lands on-chain. Requires a watch ([watchMarket](#watchmarket) / [watchMarkets](#watchmarkets)) covering the market you read. 2. **Chain** (`getBinaryOrderBook`, `getMarketOnchain`, …): one `eth_call` round-trip, current to head. Works without any watch. 3. **Indexer** (`listMarkets`, `getPortfolio`, …): history and aggregates; lags the chain slightly. Works without any watch or the socket. ## Properties ### config > `readonly` **config**: [`ClientConfig`](ClientConfig.md) Defined in: [somniaMarketsClient.ts:133](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L133) The config this client was built with. *** ### publicClient > `readonly` **publicClient**: `object` Defined in: [somniaMarketsClient.ts:137](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L137) This client's viem WebSocket public client — the escape hatch for custom contract reads. Accessing it opens the socket if it isn't open yet. ## Methods ### watchMarket() > **watchMarket**(`pool`): `Promise`\<[`WatchHandle`](WatchHandle.md)\> Defined in: [somniaMarketsClient.ts:163](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L163) Watch one market: hydrate a consistent snapshot of it (market row, recent fills, its full resting order book) and stream its events — order-book activity plus, for a binary market, its lifecycle/status events. While the watch is active, every `getLive*` read for this pool is current to the last block at zero round-trip cost. Watches are **ref-counted**: watching the same pool twice shares one subscription and one snapshot; each handle's `stop()` releases one reference, and the scope is torn down (subscription dropped, heavy rows purged) shortly after the last release — a brief linger absorbs quick re-watches (navigation, React remounts) without re-snapshotting. Resolves once the seam is sealed (snapshot + backfill + buffered replay) — i.e. once reads are live. Rejects (and releases the reference) if hydration fails; the socket dropping later is healed automatically by reconnect + chain backfill. The React data hooks call this automatically while mounted. #### Parameters ##### pool `string` #### Returns `Promise`\<[`WatchHandle`](WatchHandle.md)\> *** ### watchMarkets() > **watchMarkets**(`opts?`): `Promise`\<[`WatchHandle`](WatchHandle.md)\> Defined in: [somniaMarketsClient.ts:175](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L175) Watch every market the indexer currently knows — the whole-protocol tail for list views and multi-market bots. Prefer [watchMarket](#watchmarket) scoped to what you actually trade or render: this variant's cost grows with the protocol (snapshot size, subscription filter width, event volume). #### Parameters ##### opts? ###### discover? `boolean` Also watch the MarketCreator factory so markets created AFTER this call join the watch live, in their creation block (requires `config.addresses.marketCreator`). Off by default. #### Returns `Promise`\<[`WatchHandle`](WatchHandle.md)\> *** ### watchUser() > **watchUser**(`user`): `Promise`\<[`WatchHandle`](WatchHandle.md)\> Defined in: [somniaMarketsClient.ts:186](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L186) Hydrate one account's order/fill **history** (one indexer fetch) so [getLiveUserFills](#getliveuserfills) / [getLiveUserOrders](#getliveuserorders) have depth predating your watches. This does not subscribe to anything by itself: live events are attributed to every account automatically, but only within markets covered by an active [watchMarket](#watchmarket) / [watchMarkets](#watchmarkets) — an account's activity in unwatched markets stays at snapshot state. Ref-counted like market watches; supports multiple accounts at once. #### Parameters ##### user `string` #### Returns `Promise`\<[`WatchHandle`](WatchHandle.md)\> *** ### getWatchStatus() > **getWatchStatus**(`pool`): [`WatchStatus`](../type-aliases/WatchStatus.md) Defined in: [somniaMarketsClient.ts:194](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L194) Per-market watch state: `"unwatched"` (no active watch — `getLive*` reads return empty for this pool, which is how you distinguish "empty book" from "not watching"), `"hydrating"` (watch registered; snapshot, seam backfill, or reconnect in progress), or `"live"`. #### Parameters ##### pool `string` #### Returns [`WatchStatus`](../type-aliases/WatchStatus.md) *** ### stopLive() > **stopLive**(): `void` Defined in: [somniaMarketsClient.ts:198](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L198) Tear down every watch, subscription, and timer (tests, shutdown). The store keeps its last state; `getLive*` reads keep answering (stale). #### Returns `void` *** ### subscribeLive() > **subscribeLive**(`listener`): () => `void` Defined in: [somniaMarketsClient.ts:208](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L208) Fire `listener` after every batch of store changes — the "something changed, re-read" signal (the React hooks subscribe to exactly this). Re-read with any `getLive*` method; their results are memoized per store version, so re-reading without a change returns the same reference. #### Parameters ##### listener () => `void` #### Returns An unsubscribe function. () => `void` *** ### getLiveStatus() > **getLiveStatus**(): [`TailStatus`](TailStatus.md) Defined in: [somniaMarketsClient.ts:214](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L214) The tail's global health: mode (`"init"` until the first watch hydrates, then `"tailing"`), the last seam block, the last locally-materialized block, the chain head, socket state, and the active watch count. For one market's state, use [getWatchStatus](#getwatchstatus). #### Returns [`TailStatus`](TailStatus.md) *** ### isTailing() > **isTailing**(): `boolean` Defined in: [somniaMarketsClient.ts:217](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L217) True once at least one watch is live (`mode === "tailing"`). #### Returns `boolean` *** ### getLiveMarkets() > **getLiveMarkets**(): [`Market`](../type-aliases/Market.md)[] Defined in: [somniaMarketsClient.ts:223](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L223) Every market the store knows (spot + binary, as the discriminated [Market](../type-aliases/Market.md) union) — markets hydrated by any watch, past or present (market rows are kept as metadata after a watch is released). Synchronous, memoized. #### Returns [`Market`](../type-aliases/Market.md)[] *** ### getLiveMarketByPool() > **getLiveMarketByPool**(`pool`): [`Market`](../type-aliases/Market.md) \| `null` Defined in: [somniaMarketsClient.ts:226](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L226) One market by its pool address (either kind), or null if unknown. #### Parameters ##### pool `string` #### Returns [`Market`](../type-aliases/Market.md) \| `null` *** ### getLiveMarketByAddress() > **getLiveMarketByAddress**(`marketAddress`): [`BinaryMarket`](../type-aliases/BinaryMarket.md) \| `null` Defined in: [somniaMarketsClient.ts:230](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L230) One binary market by its BinaryMarket contract address, or null. (Spot markets have no market contract — they are identified by pool.) #### Parameters ##### marketAddress `string` #### Returns [`BinaryMarket`](../type-aliases/BinaryMarket.md) \| `null` *** ### getLiveFills() > **getLiveFills**(`pool`, `opts?`): [`LiveFill`](LiveFill.md)[] Defined in: [somniaMarketsClient.ts:238](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L238) The most recent fills on one pool, newest first — the live trade tape. Maker/taker owner + side are back-joined from the order map where known. #### Parameters ##### pool `string` ##### opts? ###### limit? `number` Max rows (default 40; the store retains ~400 per pool). #### Returns [`LiveFill`](LiveFill.md)[] *** ### getLiveUserFills() > **getLiveUserFills**(`pool`, `user`, `opts?`): [`LiveFill`](LiveFill.md)[] Defined in: [somniaMarketsClient.ts:246](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L246) Fills `user` participated in (as maker or taker), newest first. #### Parameters ##### pool `string` \| `null` Restrict to one pool, or null for all pools. ##### user `string` ##### opts? ###### limit? `number` Max rows (default 50). #### Returns [`LiveFill`](LiveFill.md)[] *** ### getLiveUserOrders() > **getLiveUserOrders**(`pool`, `user`, `opts?`): [`LiveOrder`](LiveOrder.md)[] Defined in: [somniaMarketsClient.ts:256](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L256) `user`'s orders on one pool, newest first — every lifecycle state (open, filled, cancelled, expired), so filter by `status === "Open"` for a working-orders view. Includes history hydrated by [watchUser](#watchuser) plus everything witnessed live on watched markets. #### Parameters ##### pool `string` ##### user `string` ##### opts? ###### limit? `number` Max rows (default 100). #### Returns [`LiveOrder`](LiveOrder.md)[] *** ### getLiveBinaryOrderBook() > **getLiveBinaryOrderBook**(`pool`, `opts?`): [`BinaryOrderBook`](BinaryOrderBook.md) Defined in: [somniaMarketsClient.ts:266](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L266) The locally-materialized resting book of a **binary** pool, 4-sided (`yesBids`/`yesAsks` plus the NO sides derived as `1 − yesPrice`) — the zero-round-trip mirror of [getBinaryOrderBook](#getbinaryorderbook), current to the last block. Synchronous; safe to call every render (memoized per store version). #### Parameters ##### pool `string` ##### opts? ###### depth? `number` Price levels per side (default 10). #### Returns [`BinaryOrderBook`](BinaryOrderBook.md) *** ### getLiveBinaryOrderBookByMarket() > **getLiveBinaryOrderBookByMarket**(`marketId`, `opts?`): [`BinaryOrderBook`](BinaryOrderBook.md) Defined in: [somniaMarketsClient.ts:281](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L281) The locally-materialized resting book of a **binary** market, resolved by its `marketId` rather than its pool address. Because a BinaryPool is RECYCLED across markets (one pool serves successive markets, never concurrently), a page keyed on a `marketId` must never render the pool's NEXT market's orders once its own market has ended. This read resolves the market's current pool and, if `marketId` is no longer the pool's current binding (stale/ended), returns an EMPTY book — so a stale page renders nothing rather than the successor market's liquidity. Prefer this over [getLiveBinaryOrderBook](#getlivebinaryorderbook) when you hold a `marketId` (not a live pool). #### Parameters ##### marketId `string` ##### opts? ###### depth? `number` Price levels per side (default 10). #### Returns [`BinaryOrderBook`](BinaryOrderBook.md) *** ### getLiveSpotOrderBook() > **getLiveSpotOrderBook**(`pool`, `opts?`): [`SpotOrderBook`](SpotOrderBook.md) Defined in: [somniaMarketsClient.ts:289](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L289) The locally-materialized resting book of a **spot** pool (`bids`/`asks`, best price first) — the zero-round-trip mirror of [getSpotOrderBook](#getspotorderbook). #### Parameters ##### pool `string` ##### opts? ###### depth? `number` Price levels per side (default 12). #### Returns [`SpotOrderBook`](SpotOrderBook.md) *** ### quoteBinaryOrder() > **quoteBinaryOrder**(`params`): [`BinaryOrderQuote`](BinaryOrderQuote.md) Defined in: [somniaMarketsClient.ts:309](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L309) Preview a MARKET order against the live binary book — "you'll pay ~$X, average Y, slippage Z". Pure over the live store (synchronous); key it by `pool` (a live pool) or `marketId` (recycle-safe — a stale market quotes against an empty book). Crossing side: BUY_YES/BUY_NO consume the asks, SELL_YES/SELL_NO the bids; NO prices are the YES book inverted (`oneCollateral − yesPrice`). `cost` is raw collateral paid (buy) / received (sell); `avgPrice` the volume-weighted fill price; `wouldRest` the unfilled remainder that would rest as a maker order. #### Parameters ##### params ###### pool? `string` ###### marketId? `string` ###### side [`BinarySide`](../type-aliases/BinarySide.md) ###### quantity `bigint` Order size in raw outcome-token units. ###### depth? `number` Book levels to walk per side (default 10). #### Returns [`BinaryOrderQuote`](BinaryOrderQuote.md) *** ### getMarketStats24h() > **getMarketStats24h**(`target`): `Promise`\<[`MarketStats24h`](MarketStats24h.md)\> Defined in: [somniaMarketsClient.ts:323](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L323) A market's trailing-24h stats (volume, trades, price change, high/low/open), summed from 1h OHLCV candle buckets — cheaper than scanning fills. Key it by `pool` or `marketId`. Prices are raw quote units; volume is raw collateral. One indexer round-trip. #### Parameters ##### target ###### pool? `string` ###### marketId? `string` #### Returns `Promise`\<[`MarketStats24h`](MarketStats24h.md)\> *** ### getBinaryPositionPnL() > **getBinaryPositionPnL**(`account`, `marketId`): `Promise`\<[`BinaryPositionPnL`](BinaryPositionPnL.md)\> Defined in: [somniaMarketsClient.ts:334](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L334) An account's position + cost basis + PnL in one binary market, RAW units. Reconstructs cost basis (weighted-average) from the account's order-book fills on the market folded with complete-set mints/merges, marks the CURRENT balances to `lastPrice` (or the settlement payout once resolved), and realizes sells against the running average. Best-effort over indexed fills; see [BinaryPositionPnL](BinaryPositionPnL.md) for the accounting assumptions. One fan-out of indexer reads. #### Parameters ##### account `string` ##### marketId `string` #### Returns `Promise`\<[`BinaryPositionPnL`](BinaryPositionPnL.md)\> *** ### getClaimable() > **getClaimable**(`account`): `Promise`\<[`ClaimablePosition`](ClaimablePosition.md)[]\> Defined in: [somniaMarketsClient.ts:344](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L344) An account's redeemable positions across all SETTLED (resolved/voided) binary markets, each shaped to feed straight into `trader.redeemMany({ entries })`. Winners get `amount × (1 − settlementFee)`; both sides of a voided market get `amount / 2`; loser-side and still-trading positions are omitted. One portfolio read plus one fee read per winning market. #### Parameters ##### account `string` #### Returns `Promise`\<[`ClaimablePosition`](ClaimablePosition.md)[]\> *** ### watchPrice() > **watchPrice**(`asset`): `Promise`\<[`PriceWatchHandle`](PriceWatchHandle.md)\> Defined in: [somniaMarketsClient.ts:362](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L362) Watch one asset's price (e.g. `"BTC"`, `"ETH"`): hydrate a snapshot (feed metadata + current price + recent ticks) to get roughly up to speed, then stream live over a Hasura WebSocket subscription. While active, every `getLivePrice`/`getLivePriceTicks` read for this asset is current to the last pushed tick at zero round-trip cost. Ref-counted like [watchMarket](#watchmarket): watching the same asset twice shares one subscription and one snapshot; each handle's `stop()` releases one reference, and a brief linger absorbs quick re-watches. Requires `config.priceFeed` to be set; rejects (and releases) otherwise. #### Parameters ##### asset `string` #### Returns `Promise`\<[`PriceWatchHandle`](PriceWatchHandle.md)\> *** ### watchPrices() > **watchPrices**(`assets`): `Promise`\<[`PriceWatchHandle`](PriceWatchHandle.md)\> Defined in: [somniaMarketsClient.ts:367](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L367) Watch a batch of assets at once (e.g. `["BTC", "ETH"]`). Returns a single handle whose `stop()` releases all of them; each asset is independently ref-counted, so this composes with per-asset [watchPrice](#watchprice) calls. #### Parameters ##### assets `string`[] #### Returns `Promise`\<[`PriceWatchHandle`](PriceWatchHandle.md)\> *** ### getPriceStatus() > **getPriceStatus**(`asset`): [`PriceFeedStatus`](../type-aliases/PriceFeedStatus.md) Defined in: [somniaMarketsClient.ts:370](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L370) Per-asset price-watch state: `"unwatched"`, `"hydrating"`, or `"live"`. #### Parameters ##### asset `string` #### Returns [`PriceFeedStatus`](../type-aliases/PriceFeedStatus.md) *** ### subscribePrices() > **subscribePrices**(`listener`): () => `void` Defined in: [somniaMarketsClient.ts:380](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L380) Fire `listener` after every batch of price-store changes (React hooks subscribe to exactly this). Re-read with `getLivePrice`/`getLivePriceTicks`; results are memoized per store version. Independent of [subscribeLive](#subscribelive) (prices are a separate store/service). #### Parameters ##### listener () => `void` #### Returns An unsubscribe function. () => `void` *** ### getLivePrice() > **getLivePrice**(`asset`): [`LivePrice`](LivePrice.md) \| `null` Defined in: [somniaMarketsClient.ts:384](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L384) The current price of a watched asset (from the live store), or null if unwatched / not yet hydrated. Synchronous, memoized. #### Parameters ##### asset `string` #### Returns [`LivePrice`](LivePrice.md) \| `null` *** ### getLivePrices() > **getLivePrices**(`assets`): ([`LivePrice`](LivePrice.md) \| `null`)[] Defined in: [somniaMarketsClient.ts:388](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L388) Current prices for a batch of watched assets, aligned to `assets` (each entry null if that asset is unwatched / not yet hydrated). Synchronous. #### Parameters ##### assets `string`[] #### Returns ([`LivePrice`](LivePrice.md) \| `null`)[] *** ### getLivePriceTicks() > **getLivePriceTicks**(`asset`, `opts?`): [`PricePoint`](PricePoint.md)[] Defined in: [somniaMarketsClient.ts:392](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L392) The recent tick tape of a watched asset, newest first. Synchronous, memoized. #### Parameters ##### asset `string` ##### opts? ###### limit? `number` Max ticks (default 100; the store retains ~1000). #### Returns [`PricePoint`](PricePoint.md)[] *** ### getLivePriceFeedInfo() > **getLivePriceFeedInfo**(`asset`): [`PriceFeedInfo`](PriceFeedInfo.md) \| `null` Defined in: [somniaMarketsClient.ts:396](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L396) Feed metadata + current price for a watched asset (from the live store), or null if unwatched. For a one-shot read without a watch use [fetchPriceFeedInfo](#fetchpricefeedinfo). #### Parameters ##### asset `string` #### Returns [`PriceFeedInfo`](PriceFeedInfo.md) \| `null` *** ### fetchPriceFeedInfo() > **fetchPriceFeedInfo**(`asset`): `Promise`\<[`PriceFeedInfo`](PriceFeedInfo.md)\> Defined in: [somniaMarketsClient.ts:399](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L399) One-shot feed metadata + current price (one HTTP round-trip; no watch needed). #### Parameters ##### asset `string` #### Returns `Promise`\<[`PriceFeedInfo`](PriceFeedInfo.md)\> *** ### fetchPrice() > **fetchPrice**(`asset`): `Promise`\<[`LivePrice`](LivePrice.md) \| `null`\> Defined in: [somniaMarketsClient.ts:403](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L403) One-shot current price (one HTTP round-trip), or null if the feed has no observations yet. #### Parameters ##### asset `string` #### Returns `Promise`\<[`LivePrice`](LivePrice.md) \| `null`\> *** ### fetchPrices() > **fetchPrices**(`assets?`): `Promise`\<[`LivePrice`](LivePrice.md)[]\> Defined in: [somniaMarketsClient.ts:408](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L408) One-shot current prices for a batch of assets, or ALL tracked assets when `assets` is omitted — the multi-asset "price wall" in one request. Assets with no observations yet are omitted from the result. #### Parameters ##### assets? `string`[] #### Returns `Promise`\<[`LivePrice`](LivePrice.md)[]\> *** ### listPriceFeeds() > **listPriceFeeds**(): `Promise`\<[`PriceFeedInfo`](PriceFeedInfo.md)[]\> Defined in: [somniaMarketsClient.ts:412](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L412) One-shot feed catalog — metadata + current price for every tracked asset (discovery). One HTTP round-trip; no watch needed. #### Returns `Promise`\<[`PriceFeedInfo`](PriceFeedInfo.md)[]\> *** ### fetchPriceHistory() > **fetchPriceHistory**(`asset`, `opts?`): `Promise`\<[`PricePoint`](PricePoint.md)[]\> Defined in: [somniaMarketsClient.ts:416](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L416) Historic ticks for one asset, newest first — window with `from`/`to` (unix seconds, chain time), page with `limit` (default 500). #### Parameters ##### asset `string` ##### opts? ###### limit? `number` ###### from? `number` ###### to? `number` #### Returns `Promise`\<[`PricePoint`](PricePoint.md)[]\> *** ### fetchPriceCandles() > **fetchPriceCandles**(`asset`, `resolution`, `opts?`): `Promise`\<[`PriceCandle`](PriceCandle.md)[]\> Defined in: [somniaMarketsClient.ts:423](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L423) OHLC candles for one asset + resolution (`"M1"`/`"H1"`/`"D1"`), oldest first (chart-ready). Window with `from`/`to` (unix seconds); page with `limit`. #### Parameters ##### asset `string` ##### resolution [`PriceCandleResolution`](../type-aliases/PriceCandleResolution.md) ##### opts? ###### limit? `number` ###### from? `number` ###### to? `number` #### Returns `Promise`\<[`PriceCandle`](PriceCandle.md)[]\> *** ### listMarkets() > **listMarkets**(`opts?`): `Promise`\<[`Market`](../type-aliases/Market.md)[]\> Defined in: [somniaMarketsClient.ts:441](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L441) List markets, newest first, as the discriminated `Market = SpotMarket | BinaryMarket` union. #### Parameters ##### opts? ###### marketType? [`MarketType`](../type-aliases/MarketType.md) Filter to `"SPOT"` or `"BINARY"`; omit for both. ###### limit? `number` Max rows (default 50). ###### offset? `number` Row offset for pagination (default 0). #### Returns `Promise`\<[`Market`](../type-aliases/Market.md)[]\> *** ### countMarkets() > **countMarkets**(`opts?`): `Promise`\<`number`\> Defined in: [somniaMarketsClient.ts:445](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L445) Server-side COUNT of markets (optionally one type) for pagination totals. Needs the privileged `_aggregate` role (server-only), like [countBinaryMarkets](#countbinarymarkets). #### Parameters ##### opts? ###### marketType? [`MarketType`](../type-aliases/MarketType.md) #### Returns `Promise`\<`number`\> *** ### getMarket() > **getMarket**(`id`): `Promise`\<[`Market`](../type-aliases/Market.md) \| `null`\> Defined in: [somniaMarketsClient.ts:449](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L449) One market by primary key (bytes32 marketId for binary, pool address for spot), or null if the indexer doesn't have it. #### Parameters ##### id `string` #### Returns `Promise`\<[`Market`](../type-aliases/Market.md) \| `null`\> *** ### listBinaryMarkets() > **listBinaryMarkets**(`opts?`): `Promise`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md)[]\> Defined in: [somniaMarketsClient.ts:452](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L452) [listMarkets](#listmarkets) pre-narrowed to binary markets. #### Parameters ##### opts? [`BinaryMarketFilter`](../type-aliases/BinaryMarketFilter.md) & `object` #### Returns `Promise`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md)[]\> *** ### listLiveBinaryMarkets() > **listLiveBinaryMarkets**(`filter?`): `Promise`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md)[]\> Defined in: [somniaMarketsClient.ts:458](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L458) Currently-live binary markets (`expiry > now`), soonest-to-expire first. Call with no argument for all live markets, or pass a [LiveBinaryMarketsFilter](../type-aliases/LiveBinaryMarketsFilter.md) to narrow by `operatorId` / `venueId` / `asset` / `intervalSec` / `status` (e.g. `{ venueId: "0x4d41494e" }`). #### Parameters ##### filter? [`LiveBinaryMarketsFilter`](../type-aliases/LiveBinaryMarketsFilter.md) #### Returns `Promise`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md)[]\> *** ### listBinaryVenueIds() > **listBinaryVenueIds**(): `Promise`\<`object`[]\> Defined in: [somniaMarketsClient.ts:463](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L463) Distinct (operatorId, venueId) pairs across binary markets — the cheap server-side source for operator/venue filter options (so a UI never fetches every market just to enumerate origins). Excludes null attribution. #### Returns `Promise`\<`object`[]\> *** ### listBinaryAssets() > **listBinaryAssets**(): `Promise`\<`string`[]\> Defined in: [somniaMarketsClient.ts:467](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L467) Distinct asset symbols across binary markets — the cheap server-side source for an asset filter's options. #### Returns `Promise`\<`string`[]\> *** ### countBinaryMarkets() > **countBinaryMarkets**(`opts`): `Promise`\<`number`\> Defined in: [somniaMarketsClient.ts:471](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L471) Server-side COUNT of binary markets matching a filter, split by lifecycle phase — a total without fetching rows (Hasura `_aggregate`). #### Parameters ##### opts [`BinaryMarketFilter`](../type-aliases/BinaryMarketFilter.md) & `object` #### Returns `Promise`\<`number`\> *** ### listPastBinaryMarkets() > **listPastBinaryMarkets**(`opts?`): `Promise`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md)[]\> Defined in: [somniaMarketsClient.ts:477](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L477) Past binary markets (`expiry ≤ now`), most-recently-expired first, paginated with `limit` + `offset`. #### Parameters ##### opts? [`PastBinaryMarketsOptions`](../type-aliases/PastBinaryMarketsOptions.md) #### Returns `Promise`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md)[]\> *** ### getBinaryMarket() > **getBinaryMarket**(`id`): `Promise`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md) \| `null`\> Defined in: [somniaMarketsClient.ts:481](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L481) One binary market by bytes32 marketId, or null (also null if the id resolves to a spot market). #### Parameters ##### id `string` #### Returns `Promise`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md) \| `null`\> *** ### getBinaryMarketByAddress() > **getBinaryMarketByAddress**(`marketAddress`): `Promise`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md) \| `null`\> Defined in: [somniaMarketsClient.ts:485](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L485) One binary market by its on-chain BinaryMarket ADDRESS (the Market PK is the bytes32 marketId, so an address-keyed caller must resolve through this). Newest first for recycled/rebound addresses; null if not yet indexed. #### Parameters ##### marketAddress `string` #### Returns `Promise`\<[`BinaryMarket`](../type-aliases/BinaryMarket.md) \| `null`\> *** ### getMarketFees() > **getMarketFees**(`id`): `Promise`\<[`MarketFees`](../type-aliases/MarketFees.md) \| `null`\> Defined in: [somniaMarketsClient.ts:488](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L488) Fee config frozen into the market's pool at creation (origin venue attribution + rates in bpsTimes1k), or null without attribution. #### Parameters ##### id `string` #### Returns `Promise`\<[`MarketFees`](../type-aliases/MarketFees.md) \| `null`\> *** ### listSpotMarkets() > **listSpotMarkets**(`opts?`): `Promise`\<[`SpotMarket`](../type-aliases/SpotMarket.md)[]\> Defined in: [somniaMarketsClient.ts:492](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L492) [listMarkets](#listmarkets) pre-narrowed to spot markets. Pass a [SpotMarketFilter](../type-aliases/SpotMarketFilter.md) (+ `limit`) to narrow by base/quote symbol. #### Parameters ##### opts? [`SpotMarketFilter`](../type-aliases/SpotMarketFilter.md) & `object` #### Returns `Promise`\<[`SpotMarket`](../type-aliases/SpotMarket.md)[]\> *** ### getSpotMarket() > **getSpotMarket**(`id`): `Promise`\<[`SpotMarket`](../type-aliases/SpotMarket.md) \| `null`\> Defined in: [somniaMarketsClient.ts:495](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L495) One spot market by pool address, or null (also null if not spot). #### Parameters ##### id `string` #### Returns `Promise`\<[`SpotMarket`](../type-aliases/SpotMarket.md) \| `null`\> *** ### getMarketStatusHistory() > **getMarketStatusHistory**(`marketId`): `Promise`\<[`MarketStatusUpdate`](../type-aliases/MarketStatusUpdate.md)[]\> Defined in: [somniaMarketsClient.ts:499](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L499) A market's status-transition history (Trading→Locked→Settling→Resolved…), oldest-first — the resolution/lock timeline for a market page. #### Parameters ##### marketId `string` #### Returns `Promise`\<[`MarketStatusUpdate`](../type-aliases/MarketStatusUpdate.md)[]\> *** ### listPerpMarkets() > **listPerpMarkets**(`opts?`): `Promise`\<[`PerpMarket`](../type-aliases/PerpMarket.md)[]\> Defined in: [somniaMarketsClient.ts:503](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L503) [listMarkets](#listmarkets) pre-narrowed to perp markets. Pass a [PerpMarketFilter](../type-aliases/PerpMarketFilter.md) (+ `limit`) to narrow by base/quote symbol. #### Parameters ##### opts? [`PerpMarketFilter`](../type-aliases/PerpMarketFilter.md) & `object` #### Returns `Promise`\<[`PerpMarket`](../type-aliases/PerpMarket.md)[]\> *** ### getPerpMarket() > **getPerpMarket**(`id`): `Promise`\<[`PerpMarket`](../type-aliases/PerpMarket.md) \| `null`\> Defined in: [somniaMarketsClient.ts:507](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L507) One perp market by pool address, or null (also null if the id resolves to another market kind). #### Parameters ##### id `string` #### Returns `Promise`\<[`PerpMarket`](../type-aliases/PerpMarket.md) \| `null`\> *** ### getCandles() > **getCandles**(`poolAddress`, `intervalSeconds`, `opts?`): `Promise`\<[`Candle`](../type-aliases/Candle.md)[]\> Defined in: [somniaMarketsClient.ts:517](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L517) OHLCV candles for one pool + interval, oldest first (chart-ready). #### Parameters ##### poolAddress `string` ##### intervalSeconds `number` Bucket size — one of the indexer's rollup intervals. ##### opts? ###### limit? `number` Max buckets (default 500). ###### from? `number` Only buckets at/after this unix-seconds timestamp. ###### to? `number` Only buckets at/before this unix-seconds timestamp. #### Returns `Promise`\<[`Candle`](../type-aliases/Candle.md)[]\> *** ### getFills() > **getFills**(`pool`, `opts?`): `Promise`\<[`FillRow`](../type-aliases/FillRow.md)[]\> Defined in: [somniaMarketsClient.ts:525](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L525) Recent fills for one pool (either kind), newest first — the one-shot cousin of [getLiveFills](#getlivefills) for when the tail isn't running. #### Parameters ##### pool `string` ##### opts? [`FillsOptions`](../type-aliases/FillsOptions.md) #### Returns `Promise`\<[`FillRow`](../type-aliases/FillRow.md)[]\> *** ### getUserFills() > **getUserFills**(`account`, `opts?`): `Promise`\<[`FillRow`](../type-aliases/FillRow.md)[]\> Defined in: [somniaMarketsClient.ts:530](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L530) Fills a user participated in (maker OR taker), newest first — the one-shot indexer counterpart to [getLiveUserFills](#getliveuserfills). Optionally scope to one pool and/or a `since`/`until` window. #### Parameters ##### account `string` ##### opts? [`FillsOptions`](../type-aliases/FillsOptions.md) & `object` #### Returns `Promise`\<[`FillRow`](../type-aliases/FillRow.md)[]\> *** ### getOpenOrders() > **getOpenOrders**(`owner`, `opts?`): `Promise`\<[`OpenOrder`](../type-aliases/OpenOrder.md)[]\> Defined in: [somniaMarketsClient.ts:539](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L539) `owner`'s currently-OPEN orders, newest first. Pass [OrdersOptions](../type-aliases/OrdersOptions.md) (minus `status` — always "Open" here) to scope by `pool`/`side` and page. NOTE: this lags the chain — for a trading loop prefer [getLiveUserOrders](#getliveuserorders) (or track the `orderId`s your own `placeOrder` calls return). For non-open history use [getOrders](#getorders). #### Parameters ##### owner `string` ##### opts? `Omit`\<[`OrdersOptions`](../type-aliases/OrdersOptions.md), `"status"`\> #### Returns `Promise`\<[`OpenOrder`](../type-aliases/OpenOrder.md)[]\> *** ### getOrders() > **getOrders**(`owner`, `opts?`): `Promise`\<[`OrderRow`](../type-aliases/OrderRow.md)[]\> Defined in: [somniaMarketsClient.ts:545](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L545) `owner`'s orders across ALL statuses (Open/Filled/Cancelled/Expired/Closed), newest first — the order-history counterpart to [getOpenOrders](#getopenorders). Each row carries its lifecycle `status` + fill progress. Filter by `status`/`side`/`pool` and page via [OrdersOptions](../type-aliases/OrdersOptions.md). #### Parameters ##### owner `string` ##### opts? [`OrdersOptions`](../type-aliases/OrdersOptions.md) #### Returns `Promise`\<[`OrderRow`](../type-aliases/OrderRow.md)[]\> *** ### getOutcomeBalances() > **getOutcomeBalances**(`account`, `marketAddress`): `Promise`\<[`OutcomeBalances`](../type-aliases/OutcomeBalances.md)\> Defined in: [somniaMarketsClient.ts:550](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L550) Indexed YES/NO outcome-token balances of `account` in one binary market ("0" when unseen). Display-grade: to gate a write, read the tokens' on-chain balances via [getErc20Balance](#geterc20balance) instead. #### Parameters ##### account `string` ##### marketAddress `string` #### Returns `Promise`\<[`OutcomeBalances`](../type-aliases/OutcomeBalances.md)\> *** ### getPortfolio() > **getPortfolio**(`account`, `opts?`): `Promise`\<[`Portfolio`](../type-aliases/Portfolio.md)\> Defined in: [somniaMarketsClient.ts:555](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L555) A wallet's whole binary portfolio in one round-trip: non-zero outcome positions, open orders, and recent trades (each with market context). Pass [PortfolioOptions](../type-aliases/PortfolioOptions.md) to page orders/trades or window trades. #### Parameters ##### account `string` ##### opts? [`PortfolioOptions`](../type-aliases/PortfolioOptions.md) #### Returns `Promise`\<[`Portfolio`](../type-aliases/Portfolio.md)\> *** ### getSpotPortfolio() > **getSpotPortfolio**(`account`, `opts?`): `Promise`\<[`SpotPortfolio`](../type-aliases/SpotPortfolio.md)\> Defined in: [somniaMarketsClient.ts:560](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L560) A wallet's spot activity: open orders, pending stop orders, and recent trades. Token holdings are NOT here — spot balances are plain ERC-20 / native balances; read them on-chain. Pass [PortfolioOptions](../type-aliases/PortfolioOptions.md) to page. #### Parameters ##### account `string` ##### opts? [`PortfolioOptions`](../type-aliases/PortfolioOptions.md) #### Returns `Promise`\<[`SpotPortfolio`](../type-aliases/SpotPortfolio.md)\> *** ### getSpotStopOrders() > **getSpotStopOrders**(`account`, `opts?`): `Promise`\<[`SpotStopOrder`](../type-aliases/SpotStopOrder.md)[]\> Defined in: [somniaMarketsClient.ts:565](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L565) A wallet's spot stop orders — PENDING by default (list + cancel via `trader.cancelStopOrder`). Pass `status` to see triggered/failed/cancelled history, `pool` to scope to one market, `limit` to page. #### Parameters ##### account `string` ##### opts? ###### pool? `string` ###### status? [`StopOrderStatus`](../type-aliases/StopOrderStatus.md) ###### limit? `number` #### Returns `Promise`\<[`SpotStopOrder`](../type-aliases/SpotStopOrder.md)[]\> *** ### getPerpPortfolio() > **getPerpPortfolio**(`account`, `opts?`): `Promise`\<[`PerpPortfolio`](../type-aliases/PerpPortfolio.md)\> Defined in: [somniaMarketsClient.ts:574](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L574) A wallet's perp activity as indexed: open perp orders + recent perp trades. Positions/collateral live in the MarginBank — read them on-chain with [getPerpPosition](#getperpposition) / [getMarginAccount](#getmarginaccount). Pass [PortfolioOptions](../type-aliases/PortfolioOptions.md) to page. #### Parameters ##### account `string` ##### opts? [`PortfolioOptions`](../type-aliases/PortfolioOptions.md) #### Returns `Promise`\<[`PerpPortfolio`](../type-aliases/PerpPortfolio.md)\> *** ### getSyncStatus() > **getSyncStatus**(`chainId`): `Promise`\<[`IndexerSyncStatus`](../type-aliases/IndexerSyncStatus.md) \| `null`\> Defined in: [somniaMarketsClient.ts:578](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L578) The indexer's own sync state (latest processed block vs chain height) for `chainId`, or null if it has no row for that chain. #### Parameters ##### chainId `number` #### Returns `Promise`\<[`IndexerSyncStatus`](../type-aliases/IndexerSyncStatus.md) \| `null`\> *** ### getMarketByPool() > **getMarketByPool**(`pool`): `Promise`\<[`Market`](../type-aliases/Market.md) \| `null`\> Defined in: [somniaMarketsClient.ts:582](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L582) Resolve a market by its pool address (one query; no live watch), or null. Binary markets are keyed by bytes32 marketId, so this is the by-pool lookup. #### Parameters ##### pool `string` #### Returns `Promise`\<[`Market`](../type-aliases/Market.md) \| `null`\> *** ### countOrders() > **countOrders**(`owner`, `opts?`): `Promise`\<`number`\> Defined in: [somniaMarketsClient.ts:587](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L587) Server-side COUNT of `owner`'s orders matching an [OrdersOptions](../type-aliases/OrdersOptions.md) filter — the total for an order-history page. Privileged `_aggregate` role (server-only), with a bounded row-count fallback on the public role. #### Parameters ##### owner `string` ##### opts? [`OrdersOptions`](../type-aliases/OrdersOptions.md) #### Returns `Promise`\<`number`\> *** ### countUserFills() > **countUserFills**(`account`, `opts?`): `Promise`\<`number`\> Defined in: [somniaMarketsClient.ts:591](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L591) Server-side COUNT of the fills `account` participated in (maker OR taker), optionally scoped by pool + a `since`/`until` window — a history-page total. #### Parameters ##### account `string` ##### opts? [`FillsOptions`](../type-aliases/FillsOptions.md) & `object` #### Returns `Promise`\<`number`\> *** ### getRouterActions() > **getRouterActions**(`account`, `opts?`): `Promise`\<[`RouterActionRecord`](../type-aliases/RouterActionRecord.md)[]\> Defined in: [somniaMarketsClient.ts:595](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L595) An account's RouterMinter action history (redeem / mint / merge), newest first — optionally scoped to one `market` and/or `kind`, paginated. #### Parameters ##### account `string` ##### opts? ###### market? `string` ###### kind? [`RouterActionKind`](../type-aliases/RouterActionKind.md) ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`RouterActionRecord`](../type-aliases/RouterActionRecord.md)[]\> *** ### getMarketResolution() > **getMarketResolution**(`marketId`): `Promise`\<\{ `events`: [`MarketResolutionEvent`](../type-aliases/MarketResolutionEvent.md)[]; `reference`: [`MarketReferenceLink`](../type-aliases/MarketReferenceLink.md) \| `null`; `closingAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; `openingAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; `oracleAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; \}\> Defined in: [somniaMarketsClient.ts:606](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L606) Everything the indexer knows about how a market resolves: lifecycle events, the oracle reference link, and the posted oracle answers. `closingAnswer` is the market's own resolution answer (the CLOSING price for a reference-mode up/down market); `openingAnswer` is the reference-question answer (the OPENING price it resolves against, null for fixed-strike markets). Any piece may be absent. `oracleAnswer` is a deprecated alias of `closingAnswer`. #### Parameters ##### marketId `string` #### Returns `Promise`\<\{ `events`: [`MarketResolutionEvent`](../type-aliases/MarketResolutionEvent.md)[]; `reference`: [`MarketReferenceLink`](../type-aliases/MarketReferenceLink.md) \| `null`; `closingAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; `openingAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; `oracleAnswer`: [`OracleAnswer`](../type-aliases/OracleAnswer.md) \| `null`; \}\> *** ### getOpeningPrices() > **getOpeningPrices**(`marketIds`): `Promise`\<`Record`\<`string`, `string` \| `null`\>\> Defined in: [somniaMarketsClient.ts:620](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L620) Batch opening (reference-question) prices for many markets in one pair of round-trips — for list views. Map of lowercased marketId → raw oracle `numericValue` (null when no reference answer yet). Format with the market's oracle price scale. #### Parameters ##### marketIds `string`[] #### Returns `Promise`\<`Record`\<`string`, `string` \| `null`\>\> *** ### listProtocolFees() > **listProtocolFees**(`opts?`): `Promise`\<[`ProtocolFeeRecord`](../type-aliases/ProtocolFeeRecord.md)[]\> Defined in: [somniaMarketsClient.ts:625](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L625) Realized protocol-fee records, newest first — filter by `recipient` / `market` / `pool` / `payer`, paginate. The per-fill stream behind [getMarketFees](#getmarketfees)'s running total. #### Parameters ##### opts? ###### recipient? `string` ###### market? `string` ###### pool? `string` ###### payer? `string` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`ProtocolFeeRecord`](../type-aliases/ProtocolFeeRecord.md)[]\> *** ### listBuilderFees() > **listBuilderFees**(`opts?`): `Promise`\<[`BuilderFeeRecord`](../type-aliases/BuilderFeeRecord.md)[]\> Defined in: [somniaMarketsClient.ts:631](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L631) Realized builder/routing-fee records, newest first — filter by `builder` / `market` / `payer`, paginate. #### Parameters ##### opts? ###### builder? `string` ###### market? `string` ###### payer? `string` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`BuilderFeeRecord`](../type-aliases/BuilderFeeRecord.md)[]\> *** ### listSettlementFees() > **listSettlementFees**(`opts?`): `Promise`\<[`SettlementFeeRecord`](../type-aliases/SettlementFeeRecord.md)[]\> Defined in: [somniaMarketsClient.ts:637](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L637) Realized settlement-fee records, newest first — filter by `market` / `recipient`, paginate. #### Parameters ##### opts? ###### market? `string` ###### recipient? `string` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`SettlementFeeRecord`](../type-aliases/SettlementFeeRecord.md)[]\> *** ### listBuilderApprovals() > **listBuilderApprovals**(`opts?`): `Promise`\<[`BuilderApproval`](../type-aliases/BuilderApproval.md)[]\> Defined in: [somniaMarketsClient.ts:642](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L642) Builder-approval directory, newest-updated first — filter by `user` and/or `builder`, paginate. The directory complement to the on-chain point read [getBuilderApproval](#getbuilderapproval). #### Parameters ##### opts? ###### user? `string` ###### builder? `string` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`BuilderApproval`](../type-aliases/BuilderApproval.md)[]\> *** ### getVaultPayoutFallbacks() > **getVaultPayoutFallbacks**(`owner`, `opts?`): `Promise`\<[`VaultPayoutFallback`](../type-aliases/VaultPayoutFallback.md)[]\> Defined in: [somniaMarketsClient.ts:647](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L647) An owner's vault-credit fallback history (append-only), newest first — optionally scoped to one `token`, paginated. The live claimable balance is the chain read [getVaultBalance](#getvaultbalance). #### Parameters ##### owner `string` ##### opts? ###### token? `string` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`VaultPayoutFallback`](../type-aliases/VaultPayoutFallback.md)[]\> *** ### getFundingPayments() > **getFundingPayments**(`account`, `opts?`): `Promise`\<[`FundingPayment`](../type-aliases/FundingPayment.md)[]\> Defined in: [somniaMarketsClient.ts:651](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L651) An account's funding-payment history, newest first — optionally scoped to one `pool`, paginated. #### Parameters ##### account `string` ##### opts? ###### pool? `string` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`FundingPayment`](../type-aliases/FundingPayment.md)[]\> *** ### getMarginEvents() > **getMarginEvents**(`account`, `opts?`): `Promise`\<[`MarginEvent`](../type-aliases/MarginEvent.md)[]\> Defined in: [somniaMarketsClient.ts:655](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L655) An account's margin-account movement history (deposits/withdraws/locks), newest first — paginated. #### Parameters ##### account `string` ##### opts? ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`MarginEvent`](../type-aliases/MarginEvent.md)[]\> *** ### getLiquidations() > **getLiquidations**(`opts?`): `Promise`\<[`LiquidationEvent`](../type-aliases/LiquidationEvent.md)[]\> Defined in: [somniaMarketsClient.ts:658](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L658) Liquidation events, newest first — filter by `account` and/or `pool`, paginate. #### Parameters ##### opts? ###### account? `string` ###### pool? `string` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`LiquidationEvent`](../type-aliases/LiquidationEvent.md)[]\> *** ### getFundingRateHistory() > **getFundingRateHistory**(`pool`, `opts?`): `Promise`\<[`FundingRateUpdate`](../type-aliases/FundingRateUpdate.md)[]\> Defined in: [somniaMarketsClient.ts:661](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L661) A perp pool's funding-rate history, newest first — paginated. #### Parameters ##### pool `string` ##### opts? ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`FundingRateUpdate`](../type-aliases/FundingRateUpdate.md)[]\> *** ### getOpenInterestHistory() > **getOpenInterestHistory**(`pool`, `opts?`): `Promise`\<[`OpenInterestSnapshot`](../type-aliases/OpenInterestSnapshot.md)[]\> Defined in: [somniaMarketsClient.ts:664](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L664) A perp pool's open-interest history, newest first — paginated. #### Parameters ##### pool `string` ##### opts? ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`OpenInterestSnapshot`](../type-aliases/OpenInterestSnapshot.md)[]\> *** ### getBinaryOrderBook() > **getBinaryOrderBook**(`pool`, `opts?`): `Promise`\<[`BinaryOrderBook`](BinaryOrderBook.md)\> Defined in: [somniaMarketsClient.ts:680](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L680) Read a binary pool's resting book from the contract (`getBookLevels`, both sides in one pipelined round-trip), 4-sided like the live variant. Use when the tail isn't running or as a checksum; in a render/quote path prefer [getLiveBinaryOrderBook](#getlivebinaryorderbook). #### Parameters ##### pool `` `0x${string}` `` ##### opts? ###### depth? `number` Price levels per side (default 10). ###### decimals? `number` Price scale decimals for the NO-side inversion (default 6). #### Returns `Promise`\<[`BinaryOrderBook`](BinaryOrderBook.md)\> *** ### getSpotOrderBook() > **getSpotOrderBook**(`pool`, `opts?`): `Promise`\<[`SpotOrderBook`](SpotOrderBook.md)\> Defined in: [somniaMarketsClient.ts:685](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L685) Read a spot OR perp pool's resting book from the contract (both ride the shared OrderBook base). Live variant: [getLiveSpotOrderBook](#getlivespotorderbook). #### Parameters ##### pool `` `0x${string}` `` ##### opts? ###### depth? `number` Levels per side (default 12). #### Returns `Promise`\<[`SpotOrderBook`](SpotOrderBook.md)\> *** ### getPerpState() > **getPerpState**(`pool`): `Promise`\<[`PerpStateOnchain`](PerpStateOnchain.md)\> Defined in: [somniaMarketsClient.ts:690](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L690) A perp pool's live mark/index price, funding rate + cumulative index, and open interest in one pipelined fan-out — fresher than the indexed row (which only updates on funding settlements). #### Parameters ##### pool `` `0x${string}` `` #### Returns `Promise`\<[`PerpStateOnchain`](PerpStateOnchain.md)\> *** ### getPerpPosition() > **getPerpPosition**(`marginBank`, `account`, `pool`): `Promise`\<[`PerpPosition`](PerpPosition.md)\> Defined in: [somniaMarketsClient.ts:694](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L694) An account's position in one perp pool, from the MarginBank (signed size: positive = long). `marginBank` comes off the [PerpMarket](../type-aliases/PerpMarket.md) row. #### Parameters ##### marginBank `` `0x${string}` `` ##### account `` `0x${string}` `` ##### pool `` `0x${string}` `` #### Returns `Promise`\<[`PerpPosition`](PerpPosition.md)\> *** ### getMarginAccount() > **getMarginAccount**(`marginBank`, `account`): `Promise`\<[`MarginAccount`](MarginAccount.md)\> Defined in: [somniaMarketsClient.ts:699](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L699) An account's cross-margin state (free/locked collateral, equity, withdrawable, active pools) from the MarginBank — now including the account health (`imReq`/`mmReq`/`cmReq`) and `marginStatus`. #### Parameters ##### marginBank `` `0x${string}` `` ##### account `` `0x${string}` `` #### Returns `Promise`\<[`MarginAccount`](MarginAccount.md)\> *** ### getAccountHealth() > **getAccountHealth**(`marginBank`, `account`): `Promise`\<[`AccountHealth`](AccountHealth.md)\> Defined in: [somniaMarketsClient.ts:703](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L703) An account's cross-margin health alone (equity vs IM/MM/CM + the derived status) — a lighter read than [getMarginAccount](#getmarginaccount) when only health matters. #### Parameters ##### marginBank `` `0x${string}` `` ##### account `` `0x${string}` `` #### Returns `Promise`\<[`AccountHealth`](AccountHealth.md)\> *** ### getLiquidationPrice() > **getLiquidationPrice**(`marginBank`, `pool`, `account`): `Promise`\<`bigint` \| `null`\> Defined in: [somniaMarketsClient.ts:708](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L708) Estimated liquidation price for an account's position in one perp pool (raw quote units per whole base), or null when flat. A conservative single-pool maintenance-basis estimate off the cross-margin equity/mmReq. #### Parameters ##### marginBank `` `0x${string}` `` ##### pool `` `0x${string}` `` ##### account `` `0x${string}` `` #### Returns `Promise`\<`bigint` \| `null`\> *** ### getVaultBalance() > **getVaultBalance**(`vault`, `owner`, `token`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:713](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L713) LIVE claimable balance an owner can withdraw from a pool's internal ERC20Vault for `token`, raw units — the value behind the append-only [getVaultPayoutFallbacks](#getvaultpayoutfallbacks) history. `vault` is the pool address. #### Parameters ##### vault `` `0x${string}` `` ##### owner `` `0x${string}` `` ##### token `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### getMarketOnchain() > **getMarketOnchain**(`marketId`): `Promise`\<[`MarketOnchain`](MarketOnchain.md)\> Defined in: [somniaMarketsClient.ts:724](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L724) A binary market's full wiring + state (tokens, pool + nonce, status, expiry, resolution, finalized, decimals) straight from chain — authoritative for write eligibility, and works before the indexer has seen the market. BREAKING (0.13.0): takes the bytes32 `marketId` (resolved through the BinaryMarketsModule), NOT the BinaryMarket contract address — pools are recycled across successive markets in v2, so market identity is the module id. Post-finalize, `backing` falls back to the settlement record's net backing. Requires `addresses.binaryModule` in the config. #### Parameters ##### marketId `` `0x${string}` `` #### Returns `Promise`\<[`MarketOnchain`](MarketOnchain.md)\> *** ### getPoolCreator() > **getPoolCreator**(`pool`): `Promise`\<`` `0x${string}` ``\> Defined in: [somniaMarketsClient.ts:730](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L730) A pool's creator — its first-deploy market creator, the only party that can reuse it — straight from chain (`BinaryMarketsModule.poolCreator`). Zero address for a pool the module never deployed. No signer needed; requires `addresses.binaryModule`. #### Parameters ##### pool `` `0x${string}` `` #### Returns `Promise`\<`` `0x${string}` ``\> *** ### getFreePools() > **getFreePools**(`creator`, `collateral`): `Promise`\<`` `0x${string}` ``[]\> Defined in: [somniaMarketsClient.ts:736](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L736) A creator's free (finalized + released, reusable) pools for `collateral`, LIFO order (the LAST entry is popped first on the creator's next createMarket), straight from chain (`BinaryMarketsModule.getFreePools`). No signer needed; requires `addresses.binaryModule`. #### Parameters ##### creator `` `0x${string}` `` ##### collateral `` `0x${string}` `` #### Returns `Promise`\<`` `0x${string}` ``[]\> *** ### getPoolBindings() > **getPoolBindings**(`pool`): `Promise`\<[`PoolBindingRecord`](PoolBindingRecord.md)[]\> Defined in: [somniaMarketsClient.ts:743](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L743) A pool's full pool→market binding history from the indexer, newest (highest nonce) first — every market the pool has served. A row with `toBlock === null` is the pool's CURRENT binding; `closedBy` says whether a past binding ended by `PoolReleased` ("Released") or by the next `MarketCreated` recycling the pool onward ("Rotated"). #### Parameters ##### pool `string` #### Returns `Promise`\<[`PoolBindingRecord`](PoolBindingRecord.md)[]\> *** ### getPool() > **getPool**(`address`): `Promise`\<[`IndexedPool`](IndexedPool.md) \| `null`\> Defined in: [somniaMarketsClient.ts:748](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L748) The indexer's per-pool aggregate (creator, collateral, current binding, generation count) for a long-lived, recycled BinaryPool — null if the indexer has never seen a `MarketCreated` on that address. #### Parameters ##### address `string` #### Returns `Promise`\<[`IndexedPool`](IndexedPool.md) \| `null`\> *** ### getErc20Balance() > **getErc20Balance**(`token`, `account`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:752](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L752) ERC-20 `balanceOf(account)`, raw units. For outcome positions use [getOutcomeBalance](#getoutcomebalance) (ERC-6909), not this. #### Parameters ##### token `` `0x${string}` `` ##### account `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### getErc20Metadata() > **getErc20Metadata**(`token`): `Promise`\<[`Erc20Metadata`](Erc20Metadata.md)\> Defined in: [somniaMarketsClient.ts:756](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L756) ERC-20 `symbol`/`name`/`decimals` in one fan-out — label a token the indexer hasn't denormalized. #### Parameters ##### token `` `0x${string}` `` #### Returns `Promise`\<[`Erc20Metadata`](Erc20Metadata.md)\> *** ### getErc20Allowance() > **getErc20Allowance**(`token`, `owner`, `spender`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:760](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L760) ERC-20 `allowance(owner, spender)`, raw units — gate a write that pulls ERC-20 collateral (outcome tokens use per-operator approval instead). #### Parameters ##### token `` `0x${string}` `` ##### owner `` `0x${string}` `` ##### spender `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### getOutcomeBalance() > **getOutcomeBalance**(`outcomeToken`, `account`, `id`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:765](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L765) ERC-6909 `balanceOf(account, id)` on the outcome-token singleton, raw units. `outcomeToken` is the singleton (from [getMarketOnchain](#getmarketonchain)); `id` is the market's `yesId`/`noId`. #### Parameters ##### outcomeToken `` `0x${string}` `` ##### account `` `0x${string}` `` ##### id `bigint` #### Returns `Promise`\<`bigint`\> *** ### getBalances() > **getBalances**(`tokens`, `account`): `Promise`\<`bigint`[]\> Defined in: [somniaMarketsClient.ts:773](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L773) Batch-read many balances for one `account` in a single fan-out. Each entry is read as a plain ERC-20 `balanceOf(account)` when `id` is omitted, or as an ERC-6909 outcome position `balanceOf(account, id)` on the singleton `token` when `id` is set. Results are returned positionally, aligned to `tokens`. The explorer uses this to read a portfolio's collateral + outcome positions in one round-trip instead of N calls. #### Parameters ##### tokens readonly [`BalanceQuery`](BalanceQuery.md)[] ##### account `` `0x${string}` `` #### Returns `Promise`\<`bigint`[]\> *** ### getStopOrderSomiPayment() > **getStopOrderSomiPayment**(`registry`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:777](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L777) SOMI a SpotStopOrderRegistry charges per pending stop order (funds the trigger gas; refunded on cancel). Raw wei. #### Parameters ##### registry `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### getMaxBuilderFeeBpsTimes1k() > **getMaxBuilderFeeBpsTimes1k**(`pool`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:781](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L781) A BinaryPool's protocol-wide per-order builder-fee ceiling (pool bps×1000). Read-only — no signer — for the order form's routing-fee ceiling hint. #### Parameters ##### pool `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### getBuilderApproval() > **getBuilderApproval**(`pool`, `user`, `builder`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:784](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L784) A user's raw per-builder approval cap on a BinaryPool (pool bps×1000; 0 = none). #### Parameters ##### pool `` `0x${string}` `` ##### user `` `0x${string}` `` ##### builder `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### getEffectiveBuilderApproval() > **getEffectiveBuilderApproval**(`pool`, `user`, `builder`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:789](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L789) The ENFORCED per-builder approval on a BinaryPool: the user's raw cap clamped by the pool's protocol-wide ceiling — the limit a `builderFeeBpsTimes1k` must not exceed. Drives the order form's "approve builder first" gate. #### Parameters ##### pool `` `0x${string}` `` ##### user `` `0x${string}` `` ##### builder `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### getContractMeta() > **getContractMeta**(`address`, `opts?`): `Promise`\<[`ContractMeta`](ContractMeta.md)\> Defined in: [somniaMarketsClient.ts:793](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L793) owner / EIP-1967 implementation / native balance for a deployed contract — the /system dashboard diagnostics. `proxy: true` reads the impl slot. #### Parameters ##### address `` `0x${string}` `` ##### opts? ###### proxy? `boolean` #### Returns `Promise`\<[`ContractMeta`](ContractMeta.md)\> *** ### getNativeBalance() > **getNativeBalance**(`address`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:796](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L796) Native (SOMI/STT) balance, raw wei. #### Parameters ##### address `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### getHeadBlock() > **getHeadBlock**(): `Promise`\<`number`\> Defined in: [somniaMarketsClient.ts:799](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L799) Latest block number as the RPC sees it. #### Returns `Promise`\<`number`\> *** ### getSystemInfo() > **getSystemInfo**(): `Promise`\<[`SystemInfo`](SystemInfo.md)\> Defined in: [somniaMarketsClient.ts:803](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L803) Deployed protocol state (impl pointers, oracle, collateral) for ops dashboards. Needs `config.addresses`. #### Returns `Promise`\<[`SystemInfo`](SystemInfo.md)\> *** ### listOperators() > **listOperators**(`opts?`): `Promise`\<[`IndexedOperator`](../type-aliases/IndexedOperator.md)[]\> Defined in: [somniaMarketsClient.ts:812](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L812) List operators, newest-first by id, paginated. Pass `owner` to scope to one owner's operators (the indexed "my operators", no log scan), `enabled` to filter by the kill switch, `limit`/`offset` to page. Indexer read. #### Parameters ##### opts? [`OperatorFilter`](../type-aliases/OperatorFilter.md) & `object` #### Returns `Promise`\<[`IndexedOperator`](../type-aliases/IndexedOperator.md)[]\> *** ### countOperators() > **countOperators**(`opts?`): `Promise`\<`number`\> Defined in: [somniaMarketsClient.ts:816](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L816) Server-side COUNT of operators matching a filter (for directory pagination). Needs the privileged `_aggregate` role (server-only), like [countBinaryMarkets](#countbinarymarkets). #### Parameters ##### opts? [`OperatorFilter`](../type-aliases/OperatorFilter.md) #### Returns `Promise`\<`number`\> *** ### getOperator() > **getOperator**(`operatorId`): `Promise`\<[`IndexedOperator`](../type-aliases/IndexedOperator.md) \| `null`\> Defined in: [somniaMarketsClient.ts:818](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L818) One operator by id, or null if never registered. Indexer read. #### Parameters ##### operatorId `number` #### Returns `Promise`\<[`IndexedOperator`](../type-aliases/IndexedOperator.md) \| `null`\> *** ### listVenues() > **listVenues**(`opts?`): `Promise`\<[`IndexedVenue`](../type-aliases/IndexedVenue.md)[]\> Defined in: [somniaMarketsClient.ts:821](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L821) List venues, creation-order, optionally scoped to one operator and/or market type and/or the venue-level creation flag. Paginated. Indexer read. #### Parameters ##### opts? ###### operatorId? `number` ###### marketType? `string` ###### creationEnabled? `boolean` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`IndexedVenue`](../type-aliases/IndexedVenue.md)[]\> *** ### countVenues() > **countVenues**(`opts?`): `Promise`\<`number`\> Defined in: [somniaMarketsClient.ts:830](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L830) Server-side COUNT of venues matching a filter (for per-operator venue pagination). Needs the privileged `_aggregate` role (server-only). #### Parameters ##### opts? ###### operatorId? `number` ###### marketType? `string` #### Returns `Promise`\<`number`\> *** ### getVenue() > **getVenue**(`venueId`): `Promise`\<[`IndexedVenue`](../type-aliases/IndexedVenue.md) \| `null`\> Defined in: [somniaMarketsClient.ts:832](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L832) One venue by its opaque bytes32 id, or null. Indexer read. #### Parameters ##### venueId `string` #### Returns `Promise`\<[`IndexedVenue`](../type-aliases/IndexedVenue.md) \| `null`\> *** ### encodeBinaryVenueFeeParams() > **encodeBinaryVenueFeeParams**(`vp`): `Promise`\<`` `0x${string}` ``\> Defined in: [somniaMarketsClient.ts:837](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L837) Build a BINARY_V1 venue's `feeParams` bytes from plain-bps rates via the deployed BinaryMarketsModule's `encodeVenueFeeParams` — the on-chain ground truth for the version tag + struct shape (used by the create/edit venue forms). Needs `config.addresses.binaryModule`. #### Parameters ##### vp [`BinaryVenueParams`](BinaryVenueParams.md) #### Returns `Promise`\<`` `0x${string}` ``\> *** ### getMaxVenueFeeBps() > **getMaxVenueFeeBps**(): `Promise`\<`number`\> Defined in: [somniaMarketsClient.ts:840](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L840) The module's protocol-level ceiling on any single venue fee rate, in plain bps (e.g. 1_000 = 10%). Needs `config.addresses.binaryModule`. #### Returns `Promise`\<`number`\> *** ### listMarketCreators() > **listMarketCreators**(`opts?`): `Promise`\<[`IndexedMarketCreator`](../type-aliases/IndexedMarketCreator.md)[]\> Defined in: [somniaMarketsClient.ts:852](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L852) List MarketCreators, newest-first, paginated. Pass `owner` for "my machinery", `operatorId`/`venueId` to scope. Each row carries its nested `series`. Indexer read. #### Parameters ##### opts? [`MarketCreatorFilter`](../type-aliases/MarketCreatorFilter.md) & `object` #### Returns `Promise`\<[`IndexedMarketCreator`](../type-aliases/IndexedMarketCreator.md)[]\> *** ### getMarketCreator() > **getMarketCreator**(`creator`): `Promise`\<[`IndexedMarketCreator`](../type-aliases/IndexedMarketCreator.md) \| `null`\> Defined in: [somniaMarketsClient.ts:854](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L854) One MarketCreator by address (with its series), or null. Indexer read. #### Parameters ##### creator `string` #### Returns `Promise`\<[`IndexedMarketCreator`](../type-aliases/IndexedMarketCreator.md) \| `null`\> *** ### listOracleAdapters() > **listOracleAdapters**(`opts?`): `Promise`\<[`IndexedOracleAdapter`](../type-aliases/IndexedOracleAdapter.md)[]\> Defined in: [somniaMarketsClient.ts:859](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L859) List oracle adapters, newest-first, paginated. Pass `owner` to scope, `approved` to filter by the module-approval gate. Oracle v2: the one approved adapter is the OracleHub — this directory tracks `AdapterApproved` history. Indexer read. #### Parameters ##### opts? ###### owner? `string` ###### approved? `boolean` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`IndexedOracleAdapter`](../type-aliases/IndexedOracleAdapter.md)[]\> *** ### getOracleAdapter() > **getOracleAdapter**(`adapter`): `Promise`\<[`IndexedOracleAdapter`](../type-aliases/IndexedOracleAdapter.md) \| `null`\> Defined in: [somniaMarketsClient.ts:861](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L861) One oracle adapter by address, or null. Indexer read. #### Parameters ##### adapter `string` #### Returns `Promise`\<[`IndexedOracleAdapter`](../type-aliases/IndexedOracleAdapter.md) \| `null`\> *** ### listSeries() > **listSeries**(`opts?`): `Promise`\<[`IndexedSeries`](../type-aliases/IndexedSeries.md)[]\> Defined in: [somniaMarketsClient.ts:863](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L863) List series, creation-order, optionally scoped to one creator. Indexer read. #### Parameters ##### opts? ###### creator? `string` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`IndexedSeries`](../type-aliases/IndexedSeries.md)[]\> *** ### getSchedulingCost() > **getSchedulingCost**(`def`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:877](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L877) The hub's MARGINAL scheduling cost for `def` — 0 when an identical template definition is already scheduled (the call would dedup), the full oracle submission cost otherwise. Chain read; needs `config.addresses.oracleHub`. #### Parameters ##### def [`QuestionDefinitionInput`](QuestionDefinitionInput.md) #### Returns `Promise`\<`bigint`\> *** ### earmarkedOf() > **earmarkedOf**(`operatorId`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:880](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L880) Native LOCKED for an operator's outstanding markets (wei; never withdrawable). Chain read; needs `config.addresses.oracleHub`. #### Parameters ##### operatorId `number` #### Returns `Promise`\<`bigint`\> *** ### creditOf() > **creditOf**(`operatorId`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:883](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L883) An operator's accrued WITHDRAWABLE surplus credit on the hub (wei). Chain read; needs `config.addresses.oracleHub`. #### Parameters ##### operatorId `number` #### Returns `Promise`\<`bigint`\> *** ### outstandingOf() > **outstandingOf**(`operatorId`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:886](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L886) Count of an operator's bound-but-unresolved markets. Chain read; needs `config.addresses.oracleHub`. #### Parameters ##### operatorId `number` #### Returns `Promise`\<`bigint`\> *** ### withdrawableOf() > **withdrawableOf**(`operatorId`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:889](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L889) Wei an operator's owner may withdraw right now (== `creditOf`). Chain read; needs `config.addresses.oracleHub`. #### Parameters ##### operatorId `number` #### Returns `Promise`\<`bigint`\> *** ### payerCreditOf() > **payerCreditOf**(`payer`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:894](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L894) A1: the withdrawable surplus credited to a reserve-PAYER (an open-venue creator, or the autonomous MarketCreator on its rolls) rather than the operator; drawn by that account via `createOracleHubAdmin().withdrawMyCredit`. Chain read; needs `config.addresses.oracleHub`. #### Parameters ##### payer `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### payerOf() > **payerOf**(`marketId`): `Promise`\<`` `0x${string}` ``\> Defined in: [somniaMarketsClient.ts:897](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L897) A1: the reserve-payer recorded for a market at onBind (surplus recipient); zero-address once settled + swept. Chain read; needs `config.addresses.oracleHub`. #### Parameters ##### marketId `` `0x${string}` `` #### Returns `Promise`\<`` `0x${string}` ``\> *** ### resolveReserve() > **resolveReserve**(): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:900](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L900) The hub's `resolveReserve()` — the per-market reserve attached+locked at onBind (wei). Chain read; needs `config.addresses.oracleHub`. #### Returns `Promise`\<`bigint`\> *** ### quoteCreateMarketValue() > **quoteCreateMarketValue**(`def`): `Promise`\<`bigint`\> Defined in: [somniaMarketsClient.ts:905](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L905) THE §8e create-market value quote: `getSchedulingCost(def) + resolveReserve()` (the reserve is attached to the create). Attach exactly this to `scheduleAndCreateMarket` (excess refunds). Chain read; needs `config.addresses.oracleHub`. #### Parameters ##### def [`QuestionDefinitionInput`](QuestionDefinitionInput.md) #### Returns `Promise`\<`bigint`\> *** ### getOracleQuestion() > **getOracleQuestion**(`oracleQuestionId`): `Promise`\<[`OracleQuestionRecord`](../type-aliases/OracleQuestionRecord.md) \| `null`\> Defined in: [somniaMarketsClient.ts:908](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L908) One hub-scheduled oracle question (dedup key, scheduler, bind count) by its oracleQuestionId, or null. Indexer read. #### Parameters ##### oracleQuestionId `string` #### Returns `Promise`\<[`OracleQuestionRecord`](../type-aliases/OracleQuestionRecord.md) \| `null`\> *** ### listOracleQuestions() > **listOracleQuestions**(`opts?`): `Promise`\<[`OracleQuestionRecord`](../type-aliases/OracleQuestionRecord.md)[]\> Defined in: [somniaMarketsClient.ts:911](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L911) Hub-scheduled questions, newest first — filter by `scheduler` / `questionKey`, paginate. Indexer read. #### Parameters ##### opts? ###### scheduler? `string` ###### questionKey? `string` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`OracleQuestionRecord`](../type-aliases/OracleQuestionRecord.md)[]\> *** ### getOperatorHubAccount() > **getOperatorHubAccount**(`operatorId`): `Promise`\<[`OperatorHubAccountRecord`](../type-aliases/OperatorHubAccountRecord.md) \| `null`\> Defined in: [somniaMarketsClient.ts:916](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L916) One operator's hub account (earmarked / credit / outstanding) by operatorId, or null. Indexer read. #### Parameters ##### operatorId `string` \| `number` #### Returns `Promise`\<[`OperatorHubAccountRecord`](../type-aliases/OperatorHubAccountRecord.md) \| `null`\> *** ### listOperatorHubAccounts() > **listOperatorHubAccounts**(`opts?`): `Promise`\<[`OperatorHubAccountRecord`](../type-aliases/OperatorHubAccountRecord.md)[]\> Defined in: [somniaMarketsClient.ts:919](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L919) Operator hub-account records, most-recently-updated first, paginated. Indexer read. #### Parameters ##### opts? ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`OperatorHubAccountRecord`](../type-aliases/OperatorHubAccountRecord.md)[]\> *** ### listOracleBinds() > **listOracleBinds**(`opts?`): `Promise`\<[`OracleBindRecord`](../type-aliases/OracleBindRecord.md)[]\> Defined in: [somniaMarketsClient.ts:925](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L925) Bind records (operator attribution → exact metered resolve charge + subsidy per market, §8e), newest first — filter by `operatorId` / `oracleQuestionId` / `resolved`, paginate. Indexer read. #### Parameters ##### opts? ###### operatorId? `number` ###### oracleQuestionId? `string` ###### resolved? `boolean` ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`OracleBindRecord`](../type-aliases/OracleBindRecord.md)[]\> *** ### listOracleCallbacks() > **listOracleCallbacks**(`opts?`): `Promise`\<[`OracleCallbackRecord`](../type-aliases/OracleCallbackRecord.md)[]\> Defined in: [somniaMarketsClient.ts:931](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L931) Resolution-callback conservation records (`CallbackAccounted`), newest first, paginated (a callback drains across many questions, so no per-question filter). Indexer read. #### Parameters ##### opts? ###### limit? `number` ###### offset? `number` #### Returns `Promise`\<[`OracleCallbackRecord`](../type-aliases/OracleCallbackRecord.md)[]\> *** ### createTrader() > **createTrader**(`traderConfig`): [`Trader`](Trader.md) Defined in: [somniaMarketsClient.ts:947](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L947) Build a [Trader](Trader.md) bound to a signer and this client's chain, store, and socket. With a `privateKey`/local `account` the trader signs locally (fixed fees, locally-tracked nonce — zero pre-send RPCs) and confirms in one round-trip via `realtime_sendRawTransaction`; with a browser `walletClient` it sends through the wallet and confirms off the newHeads subscription. Every write resolves only once mined, with its receipt. #### Parameters ##### traderConfig [`TraderConfig`](TraderConfig.md) #### Returns [`Trader`](Trader.md) *** ### createOperatorAdmin() > **createOperatorAdmin**(`config`): [`OperatorAdmin`](OperatorAdmin.md) Defined in: [somniaMarketsClient.ts:954](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L954) Build an [OperatorAdmin](OperatorAdmin.md) bound to a signer — registers/updates operators and creates/updates venues on MarketsCore. Same signer doctrine as [createTrader](#createtrader) (privateKey/local account, or a browser walletClient). #### Parameters ##### config [`OperatorAdminConfig`](OperatorAdminConfig.md) #### Returns [`OperatorAdmin`](OperatorAdmin.md) *** ### createOracleHubAdmin() > **createOracleHubAdmin**(`config`): [`OracleHubAdmin`](OracleHubAdmin.md) Defined in: [somniaMarketsClient.ts:965](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L965) Build an [OracleHubAdmin](OracleHubAdmin.md) bound to a signer — the OracleHub surface (Oracle v2 §8e): quote reads (`quoteCreateMarketValue` = the §8e create value = scheduling cost + resolveReserve), the credit-only `withdraw` (owner-gated — draws accrued surplus credit only), and the protocol-admin writes (fundHub, gas + drain params, enableReactivity/migrateSubscription — precompile, testnet/mainnet only). Same signer doctrine as [createOperatorAdmin](#createoperatoradmin). Needs `config.addresses.oracleHub`. #### Parameters ##### config [`OracleHubAdminConfig`](OracleHubAdminConfig.md) #### Returns [`OracleHubAdmin`](OracleHubAdmin.md) *** ### createGovernanceAdmin() > **createGovernanceAdmin**(`config`): [`GovernanceAdmin`](GovernanceAdmin.md) Defined in: [somniaMarketsClient.ts:973](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L973) Build a [GovernanceAdmin](GovernanceAdmin.md) bound to a signer — the protocol-admin-only surface that approves oracle adapters on the module (`setAdapterApproved`; in Oracle v2 the ONE approved adapter is the OracleHub — deploy wiring + emergency revoke). Gate its UI on [GovernanceAdmin.isModuleOwner](GovernanceAdmin.md#ismoduleowner). #### Parameters ##### config [`OracleHubAdminConfig`](OracleHubAdminConfig.md) #### Returns [`GovernanceAdmin`](GovernanceAdmin.md) *** ### createMarketCreatorAdmin() > **createMarketCreatorAdmin**(`config`): [`MarketCreatorAdmin`](MarketCreatorAdmin.md) Defined in: [somniaMarketsClient.ts:980](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/somniaMarketsClient.ts#L980) Build a [MarketCreatorAdmin](MarketCreatorAdmin.md) bound to a signer — stamps MarketCreators (+ policies) from the factory, registers rolling series under them, funds them, and triggers rolls. Same signer doctrine as [createOperatorAdmin](#createoperatoradmin). #### Parameters ##### config [`OracleHubAdminConfig`](OracleHubAdminConfig.md) #### Returns [`MarketCreatorAdmin`](MarketCreatorAdmin.md) --- # /docs/api/index/interfaces/SpotOrderBook [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SpotOrderBook # Interface: SpotOrderBook Defined in: [reads.ts:107](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L107) A plain two-sided spot order book (no YES/NO inversion). Prices are raw quote units per whole base; quantities are raw base units. ## Properties ### bids > **bids**: [`BookLevel`](BookLevel.md)[] Defined in: [reads.ts:108](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L108) *** ### asks > **asks**: [`BookLevel`](BookLevel.md)[] Defined in: [reads.ts:109](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L109) --- # /docs/api/index/interfaces/SweepExpiredAtLevelParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SweepExpiredAtLevelParams # Interface: SweepExpiredAtLevelParams Defined in: [trade.ts:201](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L201) Permissionless keeper drain: walk ONE price level from the best order on a side, cleaning up to `maxCount` expired orders. The complement of [CancelExpiredOrdersParams](CancelExpiredOrdersParams.md) when you have a price level rather than a list of ids (e.g. draining a locked market's book so its pool can be released). Each cleaned order's escrow returns to its owner. ## Properties ### pool > **pool**: `` `0x${string}` `` Defined in: [trade.ts:203](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L203) BinaryPool (or SpotPool) address to sweep. *** ### isBid > **isBid**: `boolean` Defined in: [trade.ts:205](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L205) True to sweep the bid side, false the ask side. *** ### price > **price**: `bigint` Defined in: [trade.ts:207](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L207) The exact price level to sweep (raw pool price units). *** ### maxCount > **maxCount**: `bigint` Defined in: [trade.ts:209](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L209) Max number of expired orders to clean in this call. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:210](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L210) --- # /docs/api/index/interfaces/SystemInfo [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SystemInfo # Interface: SystemInfo Defined in: [system.ts:36](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L36) ## Properties ### clobFactory > **clobFactory**: `` `0x${string}` `` \| `null` Defined in: [system.ts:38](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L38) BinaryMarketsModule.clobFactory() (authoritative) or the configured fallback. *** ### binaryMarketImpl > **binaryMarketImpl**: `` `0x${string}` `` \| `null` Defined in: [system.ts:41](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L41) ClobFactory.binaryMarketImpl(), or null when the live read fails (there is no configured market-impl fallback; `binaryPoolImpl` is a different contract). *** ### factoryMismatch > **factoryMismatch**: `boolean` Defined in: [system.ts:43](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L43) True when the live ClobFactory differs from the configured one. *** ### settlement > **settlement**: `` `0x${string}` `` \| `null` Defined in: [system.ts:47](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L47) The BinarySettlement singleton the module is wired to (live `BinaryMarketsModule.settlement()`, falling back to the configured `addresses.binarySettlement`). Null pre-wire / on pre-v2 deploys. *** ### settlementMismatch > **settlementMismatch**: `boolean` Defined in: [system.ts:49](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L49) True when the module's live settlement differs from the configured one. *** ### marketCreator > **marketCreator**: [`MarketCreatorInfo`](MarketCreatorInfo.md) \| `null` Defined in: [system.ts:50](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L50) *** ### oracle > **oracle**: \{ `owner`: `` `0x${string}` `` \| `null`; `binaryModule`: `` `0x${string}` `` \| `null`; \} \| `null` Defined in: [system.ts:51](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L51) *** ### usdc > **usdc**: \{ `symbol`: `string` \| `null`; `decimals`: `number` \| `null`; \} \| `null` Defined in: [system.ts:52](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/system.ts#L52) --- # /docs/api/index/interfaces/TailStatus [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / TailStatus # Interface: TailStatus Defined in: [store.ts:59](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L59) ## Properties ### mode > **mode**: [`TailMode`](../type-aliases/TailMode.md) Defined in: [store.ts:61](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L61) Current data-source mode ("init" until the first watch is hydrated). *** ### snapshotBlock > **snapshotBlock**: `number` Defined in: [store.ts:64](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L64) Block the most recent indexer snapshot was consistent to (a watch's seam covers snapshotBlock+1..) *** ### lastBlock > **lastBlock**: `number` Defined in: [store.ts:66](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L66) Highest block the local tail has materialized *** ### headBlock > **headBlock**: `number` Defined in: [store.ts:68](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L68) Latest chain head observed over the WS *** ### wsConnected > **wsConnected**: `boolean` Defined in: [store.ts:70](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L70) Whether the chain WS subscriptions are currently delivering *** ### watchCount > **watchCount**: `number` Defined in: [store.ts:73](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L73) Active market watches (pools currently subscribed, incl. an all-markets watch's set). 0 → the tail is idle and no socket is held for it. --- # /docs/api/index/interfaces/Tradable [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / Tradable # Interface: Tradable Defined in: [unified/symbols.ts:21](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/symbols.ts#L21) A parsed + resolved tradable: the market it lives on, and (for outcome markets) which outcome book it addresses. ## Properties ### market > **market**: [`Market`](../type-aliases/Market.md) Defined in: [unified/symbols.ts:22](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/symbols.ts#L22) *** ### marketSymbol > **marketSymbol**: `string` Defined in: [unified/symbols.ts:24](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/symbols.ts#L24) Canonical MARKET symbol (no outcome suffix). *** ### symbol > **symbol**: `string` Defined in: [unified/symbols.ts:26](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/symbols.ts#L26) Canonical tradable symbol (with outcome suffix where applicable). *** ### outcome? > `optional` **outcome?**: `string` Defined in: [unified/symbols.ts:28](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/symbols.ts#L28) Outcome label (binary: "YES" | "NO"); undefined for spot. *** ### outcomeIndex? > `optional` **outcomeIndex?**: `number` Defined in: [unified/symbols.ts:30](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/symbols.ts#L30) Outcome index (binary: 0 = YES, 1 = NO); undefined for spot. *** ### pool > **pool**: `string` Defined in: [unified/symbols.ts:32](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/symbols.ts#L32) The pool the tradable's orders go to. --- # /docs/api/index/interfaces/Trader [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / Trader # Interface: Trader Defined in: [trade.ts:664](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L664) ## Methods ### placeOrder() > **placeOrder**(`params`): `Promise`\<[`PlaceOrderResult`](PlaceOrderResult.md)\> Defined in: [trade.ts:667](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L667) Place a limit order (auto-approving the escrow token by default). Resolves once mined, with the resting order id and any fills. #### Parameters ##### params [`PlaceOrderParams`](PlaceOrderParams.md) #### Returns `Promise`\<[`PlaceOrderResult`](PlaceOrderResult.md)\> *** ### cancelOrder() > **cancelOrder**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:669](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L669) Cancel a resting order on its pool (works for spot + binary). #### Parameters ##### params [`CancelOrderParams`](CancelOrderParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### reduceOrder() > **reduceOrder**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:673](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L673) Shrink a resting order's remaining quantity in place, keeping its price-time queue priority (works for spot + binary). Reverts on-chain for an expired order — use [Trader.cancelOrder](#cancelorder) there. #### Parameters ##### params [`ReduceOrderParams`](ReduceOrderParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### cancelExpiredOrders() > **cancelExpiredOrders**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:677](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L677) Permissionless keeper drain: clean an explicit list of expired resting orders on a pool, returning each order's escrow to its owner (best-effort; skips non-expired / stale ids). #### Parameters ##### params [`CancelExpiredOrdersParams`](CancelExpiredOrdersParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### sweepExpiredAtLevel() > **sweepExpiredAtLevel**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:680](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L680) Permissionless keeper drain: clean up to `maxCount` expired orders at one price level on a side. #### Parameters ##### params [`SweepExpiredAtLevelParams`](SweepExpiredAtLevelParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### approveBuilder() > **approveBuilder**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:684](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L684) Opt a routing/builder frontend in on a BinaryPool so orders the trader places with that builder code may charge up to `maxFeeBpsTimes1k` (0 revokes). Required before a non-zero `builder`/`builderFeeBpsTimes1k` on [Trader.placeOrder](#placeorder). #### Parameters ##### params [`ApproveBuilderParams`](ApproveBuilderParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### getBuilderApproval() > **getBuilderApproval**(`pool`, `user`, `builder`): `Promise`\<`bigint`\> Defined in: [trade.ts:686](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L686) Read a trader's per-builder approval cap on a BinaryPool (pool bps×1000; 0 = none). #### Parameters ##### pool `` `0x${string}` `` ##### user `` `0x${string}` `` ##### builder `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### getEffectiveBuilderApproval() > **getEffectiveBuilderApproval**(`pool`, `user`, `builder`): `Promise`\<`bigint`\> Defined in: [trade.ts:690](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L690) Effective builder approval on a BinaryPool: the trader's raw cap clamped by the pool's protocol-wide `getMaxBuilderFeeBpsTimes1k` ceiling — the actual enforced limit a `builderFeeBpsTimes1k` on [Trader.placeOrder](#placeorder) must not exceed. #### Parameters ##### pool `` `0x${string}` `` ##### user `` `0x${string}` `` ##### builder `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### getMaxBuilderFeeBpsTimes1k() > **getMaxBuilderFeeBpsTimes1k**(`pool`): `Promise`\<`bigint`\> Defined in: [trade.ts:692](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L692) Read a BinaryPool's protocol-wide builder-fee ceiling (bps×1000). #### Parameters ##### pool `` `0x${string}` `` #### Returns `Promise`\<`bigint`\> *** ### placeSpotOrder() > **placeSpotOrder**(`params`): `Promise`\<[`PlaceOrderResult`](PlaceOrderResult.md)\> Defined in: [trade.ts:695](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L695) Place a spot limit/market order on a SpotPool (auto-approves the escrow token, or sends native msg.value on a native-base sell). #### Parameters ##### params [`PlaceSpotOrderParams`](PlaceSpotOrderParams.md) #### Returns `Promise`\<[`PlaceOrderResult`](PlaceOrderResult.md)\> *** ### placePerpOrder() > **placePerpOrder**(`params`): `Promise`\<[`PlaceOrderResult`](PlaceOrderResult.md)\> Defined in: [trade.ts:698](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L698) Place a perp limit/market order on a PerpPool. Margin is locked from the signer's MarginBank balance — [Trader.depositMargin](#depositmargin) first. #### Parameters ##### params [`PlacePerpOrderParams`](PlacePerpOrderParams.md) #### Returns `Promise`\<[`PlaceOrderResult`](PlaceOrderResult.md)\> *** ### depositMargin() > **depositMargin**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:701](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L701) Deposit collateral into the MarginBank (auto-approving the collateral token to the bank by default). One cross-margin balance covers every perp pool. #### Parameters ##### params [`DepositMarginParams`](DepositMarginParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### withdrawMargin() > **withdrawMargin**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:703](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L703) Withdraw free collateral from the MarginBank (margin-checked on-chain). #### Parameters ##### params [`WithdrawMarginParams`](WithdrawMarginParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### withdrawVault() > **withdrawVault**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:707](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L707) Claim a payout that fell back to a pool's internal ERC20Vault (a `PayoutFallbackToVault` credit) back to the wallet. Read the claimable amount first with `client.getVaultBalance(vault, owner, token)`. #### Parameters ##### params [`WithdrawVaultParams`](WithdrawVaultParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### setPerpLeverage() > **setPerpLeverage**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:709](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L709) Set the signer's max leverage for one perp pool (caps position size vs margin). #### Parameters ##### params [`SetPerpLeverageParams`](SetPerpLeverageParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### pokeFunding() > **pokeFunding**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:711](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L711) Permissionlessly poke a perp pool's funding settlement (updateFunding). #### Parameters ##### params ###### pool `` `0x${string}` `` ###### gas? `bigint` #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### placeSpotStopOrder() > **placeSpotStopOrder**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:714](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L714) Place a spot stop-loss / take-profit pending order on a SpotStopOrderRegistry (funds the trigger via SOMI msg.value). #### Parameters ##### params [`PlaceSpotStopOrderParams`](PlaceSpotStopOrderParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### cancelStopOrder() > **cancelStopOrder**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:716](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L716) Cancel a pending stop order on its registry. #### Parameters ##### params [`CancelStopOrderParams`](CancelStopOrderParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### mintSet() > **mintSet**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:718](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L718) Mint a YES+NO set: deposit collateral, receive equal YES + NO. #### Parameters ##### params [`MintSetParams`](MintSetParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### burnSet() > **burnSet**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:720](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L720) Burn a YES+NO set: surrender both halves, receive collateral back. #### Parameters ##### params [`BurnSetParams`](BurnSetParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### redeem() > **redeem**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:725](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L725) Burn winning outcome tokens for collateral (resolved/voided markets). Settlement-extraction v2: module-routed — the module pulls the caller's winning tokens, finalizes-if-needed, and redeems through BinarySettlement. Takes `marketId` (not a pool address — a pool serves successive markets). #### Parameters ##### params [`RedeemParams`](RedeemParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### signRedeemAuth() > **signRedeemAuth**(`params`): `Promise`\<[`RedeemAuthorization`](RedeemAuthorization.md)\> Defined in: [trade.ts:731](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L731) Produce an EIP-712 [RedeemAuthorization](RedeemAuthorization.md) the connected signer (the position owner) hands to a relayer, so the relayer can call [Trader.redeemFor](#redeemfor) and pay the gas while the OWNER receives the payout. Signs over the module's `REDEEM_AUTH_TYPEHASH` in the `SomniaMarkets` domain; no transaction is sent. #### Parameters ##### params [`SignRedeemAuthParams`](SignRedeemAuthParams.md) #### Returns `Promise`\<[`RedeemAuthorization`](RedeemAuthorization.md)\> *** ### redeemFor() > **redeemFor**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:735](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L735) Relayer path: submit a position owner's pre-signed [RedeemAuthorization](RedeemAuthorization.md) (from [Trader.signRedeemAuth](#signredeemauth)). The caller pays gas; the module pays the OWNER the collateral (payout is hard-pinned to `owner`, never the relayer). #### Parameters ##### params [`RedeemForParams`](RedeemForParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### redeemMany() > **redeemMany**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:737](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L737) Claim winnings from many settled markets in one transaction (batch redeem). #### Parameters ##### params `RedeemManyParams` #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### redeemDirect() > **redeemDirect**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:740](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L740) Low-level direct redemption against the BinarySettlement singleton (bypasses the module; no operator attribution). Takes the raw ERC-6909 `outcomeId`. #### Parameters ##### params [`RedeemDirectParams`](RedeemDirectParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### claimOwed() > **claimOwed**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:742](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L742) Claim an accrued push-fallback (`owed`) balance on the settlement singleton. #### Parameters ##### params [`ClaimOwedParams`](ClaimOwedParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### finalizeMarket() > **finalizeMarket**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:745](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L745) Permissionless keeper: finalize a settled market (sweep its pool's backing + resolution snapshot to the settlement singleton). No-op-guarded on repeat. #### Parameters ##### params [`FinalizeMarketParams`](FinalizeMarketParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### syncSettlement() > **syncSettlement**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:749](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L749) Permissionless earmark reconcile: release the oracle earmark of a market voided via `BinaryMarket.voidExpired()` (which bypasses the module, so the hub's earmark release never fired). Idempotent; reverts `MarketNotSettled` while still live. #### Parameters ##### params `SyncSettlementParams` #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### releasePool() > **releasePool**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:752](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L752) Permissionless keeper: release a finalized, drained pool back to its creator's free list for recycle onto the next market. #### Parameters ##### params [`ReleasePoolParams`](ReleasePoolParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### getSettlement() > **getSettlement**(`marketId`, `opts?`): `Promise`\<[`SettlementRecord`](SettlementRecord.md) \| `null`\> Defined in: [trade.ts:756](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L756) Read a market's settlement record from the BinarySettlement singleton (by bytes32 marketId — resolves the marketKey via the module's yesId). Returns null when the market has never been finalized. #### Parameters ##### marketId `` `0x${string}` `` ##### opts? ###### module? `` `0x${string}` `` ###### settlement? `` `0x${string}` `` #### Returns `Promise`\<[`SettlementRecord`](SettlementRecord.md) \| `null`\> *** ### getFreePools() > **getFreePools**(`creator`, `collateral`, `opts?`): `Promise`\<`` `0x${string}` ``[]\> Defined in: [trade.ts:758](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L758) Read a creator's free (finalized + released, reusable) pools for a collateral. #### Parameters ##### creator `` `0x${string}` `` ##### collateral `` `0x${string}` `` ##### opts? ###### module? `` `0x${string}` `` #### Returns `Promise`\<`` `0x${string}` ``[]\> *** ### poolCreator() > **poolCreator**(`pool`, `opts?`): `Promise`\<`` `0x${string}` ``\> Defined in: [trade.ts:760](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L760) Read a pool's creator (its first-deploy creator — the only party that can reuse it). #### Parameters ##### pool `` `0x${string}` `` ##### opts? ###### module? `` `0x${string}` `` #### Returns `Promise`\<`` `0x${string}` ``\> *** ### mintSetNative() > **mintSetNative**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:763](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L763) Mint a complete YES+NO set paying with NATIVE token via the CollateralRouter (wraps `msg.value` → wNative). The market's collateral must be wNative. #### Parameters ##### params [`MintSetNativeParams`](MintSetNativeParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### mintSetPermit2() > **mintSetPermit2**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:766](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L766) Mint a complete YES+NO set pulling collateral via a Permit2 signature through the CollateralRouter (no prior ERC-20 `approve`). #### Parameters ##### params [`MintSetPermit2Params`](MintSetPermit2Params.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### redeemNative() > **redeemNative**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:769](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L769) Redeem winning outcome tokens for a NATIVE payout via the CollateralRouter (unwraps wNative → native). Approve the router for the winning outcome first. #### Parameters ##### params [`RedeemNativeParams`](RedeemNativeParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### faucet() > **faucet**(`params?`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:771](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L771) Mint TestUSDC from the faucet to the signer. #### Parameters ##### params? [`FaucetParams`](FaucetParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### resolve() > **resolve**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:773](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L773) Resolve a market via the FakeOracle (demo resolver). #### Parameters ##### params [`ResolveParams`](ResolveParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### voidMarket() > **voidMarket**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:775](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L775) Void a market via the FakeOracle (demo resolver). #### Parameters ##### params [`VoidMarketParams`](VoidMarketParams.md) #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### poke() > **poke**(`params`): `Promise`\<[`TxResult`](TxResult.md)\> Defined in: [trade.ts:777](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L777) Poke a market to advance its lifecycle. No-op since status is derived; kept for ABI stability. #### Parameters ##### params ###### market `` `0x${string}` `` ###### gas? `bigint` #### Returns `Promise`\<[`TxResult`](TxResult.md)\> *** ### clearApprovalCache() > **clearApprovalCache**(`token?`, `spender?`): `void` Defined in: [trade.ts:781](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L781) Forget cached token approvals so the next escrowing write re-checks allowance. Pass a (token, spender) to clear one pair, or nothing to clear all. Rarely needed — maxUint256 approvals don't decrement. #### Parameters ##### token? `` `0x${string}` `` ##### spender? `` `0x${string}` `` #### Returns `void` --- # /docs/api/index/interfaces/TraderConfig [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / TraderConfig # Interface: TraderConfig Defined in: [trade.ts:69](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L69) ## Properties ### walletClient? > `optional` **walletClient?**: `object` Defined in: [trade.ts:74](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L74) A pre-built signer (e.g. a browser/wagmi wallet over an injected provider). Only needed when the SDK can't sign locally — with `privateKey` / a local `account`, the SDK signs itself and sends over the client's WebSocket via realtime_sendRawTransaction (send + confirm in one round-trip). *** ### account? > `optional` **account?**: `` `0x${string}` `` \| `Account` Defined in: [trade.ts:76](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L76) A local signing account (e.g. from viem's privateKeyToAccount). *** ### privateKey? > `optional` **privateKey?**: `` `0x${string}` `` Defined in: [trade.ts:78](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L78) Private key — the SDK derives the account. *** ### publicClient? > `optional` **publicClient?**: `object` Defined in: [trade.ts:80](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L80) Read client for allowance/receipts. Defaults to the client's WebSocket client. *** ### decimals? > `optional` **decimals?**: `number` Defined in: [trade.ts:82](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L82) Outcome/collateral decimals (default 6). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:84](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L84) Default gas ceiling per tx. --- # /docs/api/index/interfaces/TransferOperatorOwnershipParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / TransferOperatorOwnershipParams # Interface: TransferOperatorOwnershipParams Defined in: [operatorAdmin.ts:89](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L89) ## Properties ### operatorId > **operatorId**: `number` Defined in: [operatorAdmin.ts:90](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L90) *** ### newOwner > **newOwner**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:91](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L91) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [operatorAdmin.ts:92](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L92) --- # /docs/api/index/interfaces/TriggerRollParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / TriggerRollParams # Interface: TriggerRollParams Defined in: [marketCreatorAdmin.ts:74](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L74) ## Properties ### creator > **creator**: `` `0x${string}` `` Defined in: [marketCreatorAdmin.ts:75](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L75) *** ### seriesId > **seriesId**: `number` Defined in: [marketCreatorAdmin.ts:76](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L76) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [marketCreatorAdmin.ts:77](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketCreatorAdmin.ts#L77) --- # /docs/api/index/interfaces/TxResult [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / TxResult # Interface: TxResult Defined in: [trade.ts:88](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L88) Base result of a confirmed write — the SDK waits for the receipt before resolving. ## Extended by - [`PlaceOrderResult`](PlaceOrderResult.md) - [`RegisterOperatorResult`](RegisterOperatorResult.md) - [`CreateVenueResult`](CreateVenueResult.md) - [`ScheduleQuestionResult`](ScheduleQuestionResult.md) - [`CreateMarketCreatorResult`](CreateMarketCreatorResult.md) ## Properties ### hash > **hash**: `` `0x${string}` `` Defined in: [trade.ts:89](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L89) *** ### receipt > **receipt**: `TransactionReceipt` Defined in: [trade.ts:90](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L90) --- # /docs/api/index/interfaces/UnifiedBalance [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedBalance # Interface: UnifiedBalance Defined in: [unified/structs.ts:74](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L74) ## Properties ### free > **free**: `number` Defined in: [unified/structs.ts:75](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L75) *** ### used > **used**: `number` Defined in: [unified/structs.ts:76](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L76) *** ### total > **total**: `number` Defined in: [unified/structs.ts:77](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L77) --- # /docs/api/index/interfaces/UnifiedBalances [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedBalances # Interface: UnifiedBalances Defined in: [unified/structs.ts:81](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L81) Balances keyed by currency code, plus the raw reads under `info`. ## Indexable > \[`code`: `string`\]: [`UnifiedBalance`](UnifiedBalance.md) --- # /docs/api/index/interfaces/UnifiedFundingRate [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedFundingRate # Interface: UnifiedFundingRate Defined in: [unified/structs.ts:89](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L89) A perp funding-rate snapshot (live chain read; rates are fractions, not %). ## Properties ### symbol > **symbol**: `string` Defined in: [unified/structs.ts:90](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L90) *** ### markPrice > **markPrice**: `number` Defined in: [unified/structs.ts:92](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L92) EMA-smoothed oracle mark price, human quote units. *** ### indexPrice > **indexPrice**: `number` Defined in: [unified/structs.ts:94](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L94) Oracle index price, human quote units. *** ### fundingRate > **fundingRate**: `number` Defined in: [unified/structs.ts:96](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L96) Funding rate per settlement window as a plain fraction (0.0001 = 0.01%). *** ### fundingTimestamp? > `optional` **fundingTimestamp?**: `number` Defined in: [unified/structs.ts:98](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L98) Oracle timestamp of the index price (ms). *** ### timestamp > **timestamp**: `number` Defined in: [unified/structs.ts:99](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L99) *** ### datetime > **datetime**: `string` Defined in: [unified/structs.ts:100](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L100) *** ### info > **info**: `unknown` Defined in: [unified/structs.ts:101](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L101) --- # /docs/api/index/interfaces/UnifiedMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedMarket # Interface: UnifiedMarket Defined in: [unified/structs.ts:16](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L16) A unified market object. `info` is the native `Market` union row. ## Properties ### id > **id**: `string` Defined in: [unified/structs.ts:18](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L18) Venue-internal id (the native market id: bytes32 for binary, pool for spot). *** ### symbol > **symbol**: `string` Defined in: [unified/structs.ts:19](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L19) *** ### type > **type**: [`UnifiedMarketType`](../type-aliases/UnifiedMarketType.md) Defined in: [unified/structs.ts:20](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L20) *** ### base > **base**: `string` Defined in: [unified/structs.ts:21](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L21) *** ### quote > **quote**: `string` Defined in: [unified/structs.ts:22](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L22) *** ### settle? > `optional` **settle?**: `string` Defined in: [unified/structs.ts:23](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L23) *** ### active > **active**: `boolean` Defined in: [unified/structs.ts:25](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L25) Derived from live/indexed lifecycle — false once trading is impossible. *** ### contract > **contract**: `boolean` Defined in: [unified/structs.ts:26](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L26) *** ### precision > **precision**: `object` Defined in: [unified/structs.ts:27](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L27) #### price > **price**: `number` #### amount > **amount**: `number` *** ### limits > **limits**: `object` Defined in: [unified/structs.ts:28](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L28) #### amount > **amount**: `object` ##### amount.min? > `optional` **min?**: `number` *** ### outcomes? > `optional` **outcomes?**: `object`[] Defined in: [unified/structs.ts:30](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L30) Outcome tradables (binary/categorical). Absent on spot/swap. #### symbol > **symbol**: `string` #### label > **label**: `string` #### index > **index**: `number` *** ### info > **info**: [`Market`](../type-aliases/Market.md) Defined in: [unified/structs.ts:31](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L31) --- # /docs/api/index/interfaces/UnifiedOrder [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedOrder # Interface: UnifiedOrder Defined in: [unified/structs.ts:59](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L59) ## Properties ### id > **id**: `string` Defined in: [unified/structs.ts:60](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L60) *** ### symbol > **symbol**: `string` Defined in: [unified/structs.ts:61](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L61) *** ### type > **type**: `"market"` \| `"limit"` Defined in: [unified/structs.ts:62](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L62) *** ### side > **side**: `"buy"` \| `"sell"` Defined in: [unified/structs.ts:63](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L63) *** ### price? > `optional` **price?**: `number` Defined in: [unified/structs.ts:64](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L64) *** ### amount > **amount**: `number` Defined in: [unified/structs.ts:65](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L65) *** ### filled > **filled**: `number` Defined in: [unified/structs.ts:66](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L66) *** ### remaining > **remaining**: `number` Defined in: [unified/structs.ts:67](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L67) *** ### status > **status**: [`UnifiedOrderStatus`](../type-aliases/UnifiedOrderStatus.md) Defined in: [unified/structs.ts:68](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L68) *** ### timestamp? > `optional` **timestamp?**: `number` Defined in: [unified/structs.ts:69](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L69) *** ### datetime? > `optional` **datetime?**: `string` Defined in: [unified/structs.ts:70](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L70) *** ### info > **info**: `unknown` Defined in: [unified/structs.ts:71](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L71) --- # /docs/api/index/interfaces/UnifiedOrderBook [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedOrderBook # Interface: UnifiedOrderBook Defined in: [unified/structs.ts:35](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L35) An L2 book: [price, amount] pairs, best first, human units. ## Properties ### symbol > **symbol**: `string` Defined in: [unified/structs.ts:36](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L36) *** ### bids > **bids**: \[`number`, `number`\][] Defined in: [unified/structs.ts:37](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L37) *** ### asks > **asks**: \[`number`, `number`\][] Defined in: [unified/structs.ts:38](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L38) *** ### timestamp? > `optional` **timestamp?**: `number` Defined in: [unified/structs.ts:39](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L39) *** ### info? > `optional` **info?**: `unknown` Defined in: [unified/structs.ts:40](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L40) --- # /docs/api/index/interfaces/UnifiedPosition [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedPosition # Interface: UnifiedPosition Defined in: [unified/structs.ts:105](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L105) An open perp position, human units. ## Properties ### symbol > **symbol**: `string` Defined in: [unified/structs.ts:106](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L106) *** ### side > **side**: `"long"` \| `"short"` Defined in: [unified/structs.ts:107](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L107) *** ### contracts > **contracts**: `number` Defined in: [unified/structs.ts:109](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L109) Absolute position size in base units. *** ### entryPrice > **entryPrice**: `number` Defined in: [unified/structs.ts:110](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L110) *** ### markPrice? > `optional` **markPrice?**: `number` Defined in: [unified/structs.ts:111](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L111) *** ### unrealizedPnl? > `optional` **unrealizedPnl?**: `number` Defined in: [unified/structs.ts:113](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L113) (mark − entry) × signed size, human quote units. Excludes pending funding. *** ### liquidationPrice? > `optional` **liquidationPrice?**: `number` Defined in: [unified/structs.ts:116](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L116) Estimated liquidation price, human quote units (conservative single-pool maintenance estimate); undefined when it can't be derived. *** ### timestamp? > `optional` **timestamp?**: `number` Defined in: [unified/structs.ts:117](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L117) *** ### datetime? > `optional` **datetime?**: `string` Defined in: [unified/structs.ts:118](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L118) *** ### info > **info**: `unknown` Defined in: [unified/structs.ts:119](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L119) --- # /docs/api/index/interfaces/UnifiedPrice [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedPrice # Interface: UnifiedPrice Defined in: [unified/structs.ts:123](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L123) A realtime price snapshot for one asset (the on-chain EMA oracle feed). ## Properties ### symbol > **symbol**: `string` Defined in: [unified/structs.ts:125](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L125) Asset symbol, e.g. "BTC", "ETH". *** ### price > **price**: `number` Defined in: [unified/structs.ts:127](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L127) Latest price, human units. *** ### ema > **ema**: `number` Defined in: [unified/structs.ts:129](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L129) Latest EMA (exponential moving average) price, human units. *** ### timestamp > **timestamp**: `number` Defined in: [unified/structs.ts:131](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L131) Block timestamp of the latest observation (ms). *** ### datetime > **datetime**: `string` Defined in: [unified/structs.ts:132](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L132) *** ### info > **info**: `unknown` Defined in: [unified/structs.ts:134](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L134) The native [LivePrice](LivePrice.md) row (raw 1e18 strings + block metadata). --- # /docs/api/index/interfaces/UnifiedTrade [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedTrade # Interface: UnifiedTrade Defined in: [unified/structs.ts:43](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L43) ## Properties ### id > **id**: `string` Defined in: [unified/structs.ts:44](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L44) *** ### symbol > **symbol**: `string` Defined in: [unified/structs.ts:45](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L45) *** ### price > **price**: `number` Defined in: [unified/structs.ts:46](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L46) *** ### amount > **amount**: `number` Defined in: [unified/structs.ts:47](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L47) *** ### cost > **cost**: `number` Defined in: [unified/structs.ts:49](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L49) price × amount, in quote units. *** ### side? > `optional` **side?**: `"buy"` \| `"sell"` Defined in: [unified/structs.ts:51](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L51) Taker direction on this tradable's book; undefined when unresolved. *** ### timestamp > **timestamp**: `number` Defined in: [unified/structs.ts:52](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L52) *** ### datetime > **datetime**: `string` Defined in: [unified/structs.ts:53](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L53) *** ### info > **info**: `unknown` Defined in: [unified/structs.ts:54](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L54) --- # /docs/api/index/interfaces/UpdateOperatorParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UpdateOperatorParams # Interface: UpdateOperatorParams Defined in: [operatorAdmin.ts:73](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L73) ## Properties ### operatorId > **operatorId**: `number` Defined in: [operatorAdmin.ts:74](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L74) *** ### feeRecipient > **feeRecipient**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:75](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L75) *** ### enabled > **enabled**: `boolean` Defined in: [operatorAdmin.ts:76](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L76) *** ### policy > **policy**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:77](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L77) *** ### context? > `optional` **context?**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:79](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L79) Opaque metadata bytes; replaces the prior value (empty `0x` clears it). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [operatorAdmin.ts:80](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L80) --- # /docs/api/index/interfaces/UpdateVenueParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UpdateVenueParams # Interface: UpdateVenueParams Defined in: [operatorAdmin.ts:111](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L111) ## Properties ### operatorId > **operatorId**: `number` Defined in: [operatorAdmin.ts:112](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L112) *** ### venueId > **venueId**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:113](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L113) *** ### config > **config**: [`VenueConfigInput`](VenueConfigInput.md) Defined in: [operatorAdmin.ts:114](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L114) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [operatorAdmin.ts:115](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L115) --- # /docs/api/index/interfaces/ValidAnswersInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ValidAnswersInput # Interface: ValidAnswersInput Defined in: [oracleHub.ts:62](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L62) The set of valid answers a question may resolve to. ## Properties ### answerType > **answerType**: `number` Defined in: [oracleHub.ts:64](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L64) [ANSWER\_TYPE](../variables/ANSWER_TYPE.md) value (uint8 on the wire). *** ### discreteOutcomes > **discreteOutcomes**: `string`[] Defined in: [oracleHub.ts:65](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L65) *** ### numericIntervals > **numericIntervals**: [`QuestionIntervalInput`](QuestionIntervalInput.md)[] Defined in: [oracleHub.ts:66](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L66) *** ### numericDecimals > **numericDecimals**: `bigint` Defined in: [oracleHub.ts:67](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L67) --- # /docs/api/index/interfaces/VenueConfigInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / VenueConfigInput # Interface: VenueConfigInput Defined in: [operatorAdmin.ts:42](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L42) ## Properties ### feeParams > **feeParams**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:45](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L45) Type-specific fee parameters, abi-encoded (see `encodeBinaryVenueFeeParams` for BINARY_V1). Opaque to the registry. *** ### feeRecipientOverride > **feeRecipientOverride**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:47](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L47) Per-venue fee recipient; zero falls back to the operator's default. *** ### policy > **policy**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:51](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L51) IVenuePolicy address; zero means no per-venue gate (the operator-wide policy still applies). Creation needs SOME create-side policy set — point this at the deployed OpenPolicy to make the venue open. *** ### signer > **signer**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:53](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L53) EIP-712 signer; non-zero requires a venue-signed authorization to create. *** ### creationEnabled > **creationEnabled**: `boolean` Defined in: [operatorAdmin.ts:54](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L54) *** ### context? > `optional` **context?**: `` `0x${string}` `` Defined in: [operatorAdmin.ts:57](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorAdmin.ts#L57) Opaque metadata bytes attached to the venue; the registry attaches no semantics (indexed as-is). Defaults to `0x` (empty). Capped at 4 KiB. --- # /docs/api/index/interfaces/VenuePreflightInput [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / VenuePreflightInput # Interface: VenuePreflightInput Defined in: [preflight.ts:84](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L84) The venue fields the venue-step preflight inspects (subset of [IndexedVenue](../type-aliases/IndexedVenue.md)) plus whether the venue's market type is bound to a module in MarketsCore. ## Properties ### caller > **caller**: `` `0x${string}` `` Defined in: [preflight.ts:85](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L85) *** ### operatorOwner > **operatorOwner**: `string` Defined in: [preflight.ts:87](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L87) The owner of the operator the venue belongs to. *** ### creationEnabled > **creationEnabled**: `boolean` Defined in: [preflight.ts:88](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L88) *** ### moduleBound > **moduleBound**: `boolean` Defined in: [preflight.ts:91](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L91) Whether MarketsCore has a module bound for the venue's market type (`moduleOf(marketType) != 0`). --- # /docs/api/index/interfaces/VoidMarketParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / VoidMarketParams # Interface: VoidMarketParams Defined in: [trade.ts:656](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L656) ## Properties ### market > **market**: `` `0x${string}` `` Defined in: [trade.ts:657](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L657) *** ### fakeOracle? > `optional` **fakeOracle?**: `` `0x${string}` `` Defined in: [trade.ts:658](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L658) *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:659](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L659) --- # /docs/api/index/interfaces/WatchHandle [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / WatchHandle # Interface: WatchHandle Defined in: [liveTail.ts:37](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/liveTail.ts#L37) A live watch. `stop()` releases it (idempotent); the underlying subscription is shared and torn down when the last handle stops. ## Methods ### stop() > **stop**(): `void` Defined in: [liveTail.ts:38](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/liveTail.ts#L38) #### Returns `void` --- # /docs/api/index/interfaces/WithdrawMarginParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / WithdrawMarginParams # Interface: WithdrawMarginParams Defined in: [trade.ts:275](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L275) ## Properties ### marginBank? > `optional` **marginBank?**: `` `0x${string}` `` Defined in: [trade.ts:276](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L276) *** ### pool? > `optional` **pool?**: `` `0x${string}` `` Defined in: [trade.ts:277](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L277) *** ### amount > **amount**: `bigint` Defined in: [trade.ts:279](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L279) Collateral amount to withdraw, raw units. Must be ≤ withdrawable (margin-checked on-chain). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:280](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L280) --- # /docs/api/index/interfaces/WithdrawMyCreditParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / WithdrawMyCreditParams # Interface: WithdrawMyCreditParams Defined in: [oracleHub.ts:318](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L318) ## Properties ### amountWei > **amountWei**: `bigint` Defined in: [oracleHub.ts:322](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L322) Wei to withdraw from the CALLER's own accrued A1 payer credit (must be ≤ `payerCreditOf(caller)`, else the hub reverts). msg.sender-gated — the connected signer draws only its own credit. *** ### to > **to**: `` `0x${string}` `` Defined in: [oracleHub.ts:324](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L324) Recipient of the native transfer. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [oracleHub.ts:325](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L325) --- # /docs/api/index/interfaces/WithdrawParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / WithdrawParams # Interface: WithdrawParams Defined in: [oracleHub.ts:307](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L307) ## Properties ### operatorId > **operatorId**: `number` Defined in: [oracleHub.ts:309](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L309) Operator whose WITHDRAWABLE credit to draw down. OWNER-gated on-chain. *** ### amountWei > **amountWei**: `bigint` Defined in: [oracleHub.ts:312](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L312) Wei to withdraw from the operator's accrued surplus credit (must be ≤ `withdrawableOf(operatorId)`, else the hub reverts `InsufficientCredit`). *** ### to > **to**: `` `0x${string}` `` Defined in: [oracleHub.ts:314](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L314) Recipient of the native transfer. *** ### gas? > `optional` **gas?**: `bigint` Defined in: [oracleHub.ts:315](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L315) --- # /docs/api/index/interfaces/WithdrawVaultParams [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / WithdrawVaultParams # Interface: WithdrawVaultParams Defined in: [trade.ts:285](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L285) Claim a payout that fell back to a pool's internal ERC20Vault (a `PayoutFallbackToVault` credit) back to the caller's wallet. ## Properties ### vault > **vault**: `` `0x${string}` `` Defined in: [trade.ts:288](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L288) The ERC20Vault to withdraw from — the pool address (BinaryPool/SpotPool ARE ERC20Vaults). *** ### token > **token**: `` `0x${string}` `` Defined in: [trade.ts:290](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L290) Token to withdraw (ERC-20 address, or the vault's native sentinel). *** ### amount > **amount**: `bigint` Defined in: [trade.ts:293](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L293) Amount to withdraw, raw units. Must be ≤ the vault's withdrawable balance (read it with `client.getVaultBalance`). *** ### gas? > `optional` **gas?**: `bigint` Defined in: [trade.ts:294](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L294) --- # /docs/api/index/type-aliases/BaseMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BaseMarket # Type Alias: BaseMarket > **BaseMarket** = `object` Defined in: [query.ts:132](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L132) Fields every market has, regardless of type. ## Properties ### id > **id**: `string` Defined in: [query.ts:134](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L134) Primary key (lowercased): bytes32 marketId for binary, pool address for spot. *** ### marketType > **marketType**: [`MarketType`](MarketType.md) Defined in: [query.ts:135](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L135) *** ### poolAddress > **poolAddress**: `string` Defined in: [query.ts:136](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L136) *** ### lastPrice > **lastPrice**: `string` \| `null` Defined in: [query.ts:138](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L138) Last fill price (raw). For binary, ≈ YES probability × 10^decimals. Null until first fill. *** ### lastTradeAt > **lastTradeAt**: `string` \| `null` Defined in: [query.ts:139](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L139) *** ### cumulativeBaseVolume > **cumulativeBaseVolume**: `string` Defined in: [query.ts:140](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L140) *** ### cumulativeQuoteVolume > **cumulativeQuoteVolume**: `string` Defined in: [query.ts:141](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L141) *** ### tradeCount > **tradeCount**: `string` Defined in: [query.ts:142](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L142) *** ### baseDecimals > **baseDecimals**: `number` Defined in: [query.ts:143](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L143) *** ### quoteDecimals > **quoteDecimals**: `number` Defined in: [query.ts:144](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L144) *** ### createdAtTimestamp > **createdAtTimestamp**: `string` Defined in: [query.ts:145](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L145) --- # /docs/api/index/type-aliases/BinaryFillKind [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinaryFillKind # Type Alias: BinaryFillKind > **BinaryFillKind** = `"DIRECT_YES"` \| `"DIRECT_NO"` \| `"MINT_A_PAIR"` \| `"BURN_A_PAIR"` Defined in: [store.ts:28](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L28) How a binary fill settled: direct outcome trade, or a mint/burn of a YES+NO pair. --- # /docs/api/index/type-aliases/BinaryMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinaryMarket # Type Alias: BinaryMarket > **BinaryMarket** = [`BaseMarket`](BaseMarket.md) & `object` Defined in: [query.ts:206](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L206) A binary (YES/NO outcome) order-book market — the binary CLOB. ## Type Declaration ### marketType > **marketType**: `"BINARY"` ### marketId > **marketId**: `string` bytes32 marketId (== id). ### marketAddress > **marketAddress**: `string` ### yesTokenId > **yesTokenId**: `string` This market's YES/NO position ids on the ERC-6909 outcome-token singleton, as decimal strings (the indexer stores uint256 ids as strings). ### noTokenId > **noTokenId**: `string` ### collateral > **collateral**: `string` ### asset > **asset**: `string` ### question > **question**: `string` ### status > **status**: [`BinaryMarketStatus`](BinaryMarketStatus.md) ### oracleQuestion > **oracleQuestion**: `string` \| `null` The canonical oracle question string (as registered on-chain); may differ from the display `question`. Null on markets indexed before this field. ### oracleQuestionId? > `optional` **oracleQuestionId?**: `string` \| `null` Oracle question id the market binds to (uint256 as a decimal string, from `BinaryMarketsModule.MarketCreated`). `null` when discovered via the realtime tail or indexed before this field (filled on the next snapshot). ### strike > **strike**: `string` ### tradingStart > **tradingStart**: `string` ### expiry > **expiry**: `string` ### winningOutcome > **winningOutcome**: `number` \| `null` Winning outcome (0 = YES, 1 = NO) — DERIVED by the indexer from a one-hot payout vector (Oracle v2 resolves with vectors; a one-hot vector has a unique winner). Null until Resolved and on non-one-hot (void/partial) vectors — the binary-compat field, kept alongside the vector below. ### payoutNumerators? > `optional` **payoutNumerators?**: `string`[] \| `null` Per-outcome payout numerators the market settled to (Oracle v2 vector resolution; uint256s as decimal strings — one-hot on a win, uniform on a void; raw Σ == payoutDenominator). Null until Resolved / on markets indexed before the vector fields existed. ### payoutDenominator? > `optional` **payoutDenominator?**: `string` \| `null` Denominator the numerators are scaled against (`PAYOUT_VECTOR_DENOMINATOR` = 10_000_000; decimal string). Null until Resolved. ### resolvedAtBlock > **resolvedAtBlock**: `string` \| `null` Block the market resolved at; null until Resolved. ### resolvedAtTimestamp > **resolvedAtTimestamp**: `string` \| `null` Timestamp (unix seconds) the market resolved at; null until Resolved. ### createdByTx > **createdByTx**: `string` \| `null` Tx hash the market was created in; null on markets indexed before this field. ### creator? > `optional` **creator?**: `string` \| `null` Wallet that invoked createMarket (lowercased, from `BinaryMarketsModule.MarketCreated`). `null` when discovered via the realtime tail or indexed before this field (filled on the next snapshot). ### voided > **voided**: `boolean` ### backing > **backing**: `string` ### nonce? > `optional` **nonce?**: `string` \| `null` The pool's market nonce this market is bound to (settlement-extraction v2). A pool serves successive markets; `(poolAddress, nonce)` disambiguates them and encodes the outcome ids. `null` on markets indexed before v2 / discovered via a live event that doesn't carry it (filled on the next snapshot). RECYCLE CAVEAT: `poolAddress` is a TIME-VARYING 1:1 binding — the same pool address serves different markets over time (never concurrently). Always key a market by `marketId`, never by `poolAddress` alone; use `nonce` to tell which of a pool's markets a given outcome id belongs to. ### finalized? > `optional` **finalized?**: `boolean` \| `null` Whether this market's backing has been finalized onto the BinarySettlement singleton (settlement-extraction v2). True once `finalizeMarket` swept the pool's backing over; redemption is served by settlement thereafter. `null` when unknown (pre-v2 / not yet snapshotted). ### netBacking? > `optional` **netBacking?**: `string` \| `null` The NET collateral backing recorded on the settlement singleton after finalize (post fee-skim on resolution; gross on void), decimal string. This is the authoritative post-finalize backing: `BinaryMarket.backing()` reads 0 once finalized, so redemption UIs should prefer `netBacking` when set. `null` until finalize / on pre-v2 markets. ### context? > `optional` **context?**: `string` \| `null` Opaque creator-supplied metadata bytes (hex, 0x-prefixed; '0x' when empty). The chain attaches no semantics — off-chain data only. Set once at creation. `null` on non-binary markets / markets indexed before this field existed. ### intervalSec? > `optional` **intervalSec?**: `string` \| `null` Series cadence in seconds (900=15m, 3600=1h, 14400=4h, 86400=24h). DERIVED by the indexer from the market's own window (`expiry − tradingStart`) — a series' FIRST market is a bootstrap partial whose window is shorter than the steady-state cadence. `null` on SPOT / PERP. ### operatorId? > `optional` **operatorId?**: `number` \| `null` Origin operator id the market was created under (from `BinaryMarketsModule.MarketCreated`). `null` when discovered via the realtime tail (filled on the next snapshot). ### venueId? > `optional` **venueId?**: `string` \| `null` Origin venue id within the operator, contract-generated opaque bytes32 hex. `null` when discovered via the realtime tail (filled on the next snapshot — the live `MarketCreator.MarketCreated` event doesn't carry it). --- # /docs/api/index/type-aliases/BinaryMarketFilter [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinaryMarketFilter # Type Alias: BinaryMarketFilter > **BinaryMarketFilter** = `object` Defined in: [query.ts:336](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L336) Filters shared by the binary-market list queries (`listBinaryMarkets`, `listLiveBinaryMarkets`, `listPastBinaryMarkets`). Every field is optional; an omitted field does NOT constrain the query. Applied server-side (Hasura `where`), so `venueId` / `intervalSec` hit their indexes. ## Properties ### operatorId? > `optional` **operatorId?**: `number` Defined in: [query.ts:338](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L338) Origin operator id (from `BinaryMarketsModule.MarketCreated`). *** ### venueId? > `optional` **venueId?**: `string` Defined in: [query.ts:340](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L340) Origin venue id within the operator (contract-generated bytes32 hex). *** ### asset? > `optional` **asset?**: `string` Defined in: [query.ts:342](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L342) Underlying asset symbol, e.g. `"BTC"` | `"ETH"`. *** ### intervalSec? > `optional` **intervalSec?**: `number` Defined in: [query.ts:344](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L344) Series cadence in seconds: `900` (15m) | `3600` (1h) | `14400` (4h) | `86400` (24h). *** ### status? > `optional` **status?**: [`BinaryMarketStatus`](BinaryMarketStatus.md) Defined in: [query.ts:347](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L347) Lifecycle status — `"Trading"` is active; `"Locked"` / `"Settling"` / `"Resolved"` / `"Voided"` are the not-active states. *** ### search? > `optional` **search?**: `string` Defined in: [query.ts:351](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L351) Free-text needle matched (case-insensitive) against the asset symbol and the question text. Server-side (`_ilike`), AND-combined with the other facets so it narrows within them. *** ### creator? > `optional` **creator?**: `string` Defined in: [query.ts:354](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L354) Wallet that invoked createMarket (from `BinaryMarketsModule.MarketCreated`). Case-insensitive (lowercased server-side). *** ### orderBy? > `optional` **orderBy?**: [`BinaryMarketOrderBy`](BinaryMarketOrderBy.md) Defined in: [query.ts:359](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L359) Server-side sort (Hasura `order_by`). `"newest"` → createdAtTimestamp desc; `"closingSoon"` → expiry asc; `"volume"` → cumulativeQuoteVolume desc; `"tradeCount"` → tradeCount desc. Omitted → each list keeps its own default (`listBinaryMarkets` newest-first; `listLiveBinaryMarkets` closingSoon). --- # /docs/api/index/type-aliases/BinaryMarketOrderBy [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinaryMarketOrderBy # Type Alias: BinaryMarketOrderBy > **BinaryMarketOrderBy** = `"newest"` \| `"closingSoon"` \| `"volume"` \| `"tradeCount"` Defined in: [query.ts:363](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L363) Sort keys for the binary-market list queries — see [BinaryMarketFilter.orderBy](BinaryMarketFilter.md#orderby). --- # /docs/api/index/type-aliases/BinaryMarketStatus [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinaryMarketStatus # Type Alias: BinaryMarketStatus > **BinaryMarketStatus** = `"Listed"` \| `"Trading"` \| `"Locked"` \| `"Settling"` \| `"Resolved"` \| `"Voided"` \| `"Finalized"` Defined in: [store.ts:38](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L38) Binary-market lifecycle (mirror of the indexer's `ClobMarketStatus` enum). The first six mirror the on-chain `MarketStatus` enum; `"Finalized"` is an INDEXER-DERIVED terminal state (no on-chain enum member) set when the market's backing + resolution snapshot are swept to the BinarySettlement singleton — it supersedes Resolved/Voided once finalize lands, and redemptions are served by settlement thereafter. --- # /docs/api/index/type-aliases/BinarySide [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BinarySide # Type Alias: BinarySide > **BinarySide** = `"BUY_YES"` \| `"SELL_YES"` \| `"BUY_NO"` \| `"SELL_NO"` Defined in: [store.ts:26](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L26) A side on a binary book: buy/sell the YES or NO outcome token. --- # /docs/api/index/type-aliases/BuilderApproval [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BuilderApproval # Type Alias: BuilderApproval > **BuilderApproval** = `object` Defined in: [query.ts:2564](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2564) A user→builder fee approval (mirror of the indexer `BuilderApproval` entity) — the directory counterpart to the on-chain point read `getBuilderApproval`. `maxFeeBpsTimes1k` is the pool bps×1000 cap. ## Properties ### id > **id**: `string` Defined in: [query.ts:2565](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2565) *** ### user > **user**: `string` Defined in: [query.ts:2567](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2567) Granting user (lowercased). *** ### builder > **builder**: `string` Defined in: [query.ts:2569](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2569) Approved builder/routing frontend (lowercased). *** ### pool > **pool**: `string` Defined in: [query.ts:2571](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2571) The pool the approval applies to (lowercased). *** ### maxFeeBpsTimes1k > **maxFeeBpsTimes1k**: `string` Defined in: [query.ts:2573](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2573) Max per-order builder fee the user approved (pool bps×1000; 0 = revoked). *** ### updatedAt > **updatedAt**: `string` Defined in: [query.ts:2574](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2574) --- # /docs/api/index/type-aliases/BuilderFeeRecord [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / BuilderFeeRecord # Type Alias: BuilderFeeRecord > **BuilderFeeRecord** = `object` Defined in: [query.ts:2464](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2464) A realized builder/routing-fee record (mirror of the indexer `BuilderFeeRecord` entity). Amounts are raw collateral units. ## Properties ### id > **id**: `string` Defined in: [query.ts:2465](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2465) *** ### orderId > **orderId**: `string` Defined in: [query.ts:2466](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2466) *** ### builder > **builder**: `string` Defined in: [query.ts:2468](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2468) Builder/routing frontend that received the fee (lowercased). *** ### payer > **payer**: `string` \| `null` Defined in: [query.ts:2470](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2470) Order owner who paid the fee (lowercased); null on pre-payer records. *** ### token > **token**: `string` Defined in: [query.ts:2471](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2471) *** ### amount > **amount**: `string` Defined in: [query.ts:2472](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2472) *** ### market > **market**: `string` \| `null` Defined in: [query.ts:2473](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2473) *** ### pool > **pool**: `string` Defined in: [query.ts:2474](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2474) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2475](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2475) *** ### txHash > **txHash**: `string` Defined in: [query.ts:2476](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2476) --- # /docs/api/index/type-aliases/Candle [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / Candle # Type Alias: Candle > **Candle** = `object` Defined in: [query.ts:776](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L776) ## Properties ### bucketStart > **bucketStart**: `string` Defined in: [query.ts:777](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L777) *** ### openPrice > **openPrice**: `string` Defined in: [query.ts:778](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L778) *** ### high > **high**: `string` Defined in: [query.ts:779](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L779) *** ### low > **low**: `string` Defined in: [query.ts:780](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L780) *** ### closePrice > **closePrice**: `string` Defined in: [query.ts:781](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L781) *** ### baseVolume > **baseVolume**: `string` Defined in: [query.ts:782](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L782) *** ### quoteVolume > **quoteVolume**: `string` Defined in: [query.ts:783](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L783) *** ### tradeCount > **tradeCount**: `number` Defined in: [query.ts:784](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L784) --- # /docs/api/index/type-aliases/FillRow [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / FillRow # Type Alias: FillRow > **FillRow** = `object` Defined in: [query.ts:1116](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1116) ## Properties ### id > **id**: `string` Defined in: [query.ts:1117](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1117) *** ### fillPrice > **fillPrice**: `string` Defined in: [query.ts:1118](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1118) *** ### quantity > **quantity**: `string` Defined in: [query.ts:1119](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1119) *** ### quoteQuantity > **quoteQuantity**: `string` Defined in: [query.ts:1120](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1120) *** ### maker > **maker**: `string` \| `null` Defined in: [query.ts:1121](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1121) *** ### makerSide > **makerSide**: [`BinarySide`](BinarySide.md) \| `null` Defined in: [query.ts:1123](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1123) BINARY only — the maker's YES/NO side; null on SPOT/PERP. *** ### taker > **taker**: `string` \| `null` Defined in: [query.ts:1124](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1124) *** ### takerSide > **takerSide**: [`BinarySide`](BinarySide.md) \| `null` Defined in: [query.ts:1127](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1127) BINARY only — the taker's YES/NO side; null on SPOT/PERP or until the taker's OrderPlaced is bridged. *** ### kind > **kind**: [`BinaryFillKind`](BinaryFillKind.md) \| `null` Defined in: [query.ts:1130](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1130) BINARY only — how the fill settled (direct trade vs mint/burn of a pair); null on SPOT/PERP or until the taker side is known. *** ### takerIsBid > **takerIsBid**: `boolean` \| `null` Defined in: [query.ts:1131](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1131) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:1132](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1132) *** ### txHash > **txHash**: `string` Defined in: [query.ts:1133](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1133) --- # /docs/api/index/type-aliases/FillsOptions [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / FillsOptions # Type Alias: FillsOptions > **FillsOptions** = `object` Defined in: [query.ts:1140](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1140) Options for getFills / getUserFills. All optional. ## Properties ### limit? > `optional` **limit?**: `number` Defined in: [query.ts:1142](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1142) Max rows (default 50). *** ### offset? > `optional` **offset?**: `number` Defined in: [query.ts:1144](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1144) Row offset for paging the tape (default 0). *** ### since? > `optional` **since?**: `number` Defined in: [query.ts:1146](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1146) Only fills at/after this unix-seconds timestamp. *** ### until? > `optional` **until?**: `number` Defined in: [query.ts:1148](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1148) Only fills at/before this unix-seconds timestamp. --- # /docs/api/index/type-aliases/FundingPayment [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / FundingPayment # Type Alias: FundingPayment > **FundingPayment** = `object` Defined in: [query.ts:2647](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2647) A signed funding payment (mirror of the indexer `FundingPayment` entity). `amount` is signed raw collateral (negative = paid, positive = received). ## Properties ### id > **id**: `string` Defined in: [query.ts:2648](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2648) *** ### account > **account**: `string` Defined in: [query.ts:2650](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2650) Account (lowercased). *** ### pool > **pool**: `string` \| `null` Defined in: [query.ts:2652](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2652) Perp pool (lowercased); null when unlinked. *** ### amount > **amount**: `string` Defined in: [query.ts:2653](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2653) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2654](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2654) *** ### txHash > **txHash**: `string` Defined in: [query.ts:2655](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2655) --- # /docs/api/index/type-aliases/FundingRateUpdate [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / FundingRateUpdate # Type Alias: FundingRateUpdate > **FundingRateUpdate** = `object` Defined in: [query.ts:2687](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2687) A funding-rate history point (mirror of the indexer `FundingRateUpdate` entity) — the append-only counterpart to the market row's overwrite-only funding fields. ## Properties ### id > **id**: `string` Defined in: [query.ts:2688](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2688) *** ### pool > **pool**: `string` Defined in: [query.ts:2689](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2689) *** ### fundingRate > **fundingRate**: `string` \| `null` Defined in: [query.ts:2690](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2690) *** ### cumulativeFundingPerUnit > **cumulativeFundingPerUnit**: `string` \| `null` Defined in: [query.ts:2691](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2691) *** ### indexPrice > **indexPrice**: `string` \| `null` Defined in: [query.ts:2692](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2692) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2693](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2693) --- # /docs/api/index/type-aliases/IndexedMarketCreator [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / IndexedMarketCreator # Type Alias: IndexedMarketCreator > **IndexedMarketCreator** = `object` Defined in: [query.ts:1827](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1827) A MarketCreator as the indexer sees it (mirror of the `MarketCreator` entity) — one per (operator, venue) machinery instance. ## Properties ### id > **id**: `string` Defined in: [query.ts:1829](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1829) MarketCreator address (== entity id, lowercased). *** ### owner > **owner**: `string` Defined in: [query.ts:1831](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1831) Owner address (lowercased). *** ### policy > **policy**: `string` Defined in: [query.ts:1833](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1833) The creator's MarketCreatorPolicy address (lowercased). *** ### core > **core**: `string` Defined in: [query.ts:1835](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1835) The core BinaryMarketsModule the creator binds to (lowercased). *** ### adapter > **adapter**: `string` Defined in: [query.ts:1837](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1837) The oracle adapter the creator's markets resolve against (lowercased). *** ### operatorId > **operatorId**: `number` Defined in: [query.ts:1838](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1838) *** ### venueId > **venueId**: `string` Defined in: [query.ts:1840](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1840) Opaque bytes32 venue id the creator is bound to. *** ### factory > **factory**: `string` Defined in: [query.ts:1842](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1842) The MarketCreatorFactory that minted this creator (lowercased). *** ### createdAtBlock > **createdAtBlock**: `string` Defined in: [query.ts:1843](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1843) *** ### createdAtTimestamp > **createdAtTimestamp**: `string` Defined in: [query.ts:1844](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1844) *** ### series > **series**: [`IndexedSeries`](IndexedSeries.md)[] Defined in: [query.ts:1846](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1846) The series registered under this creator (nested relationship). --- # /docs/api/index/type-aliases/IndexedMarketCreatorPolicy [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / IndexedMarketCreatorPolicy # Type Alias: IndexedMarketCreatorPolicy > **IndexedMarketCreatorPolicy** = `object` Defined in: [query.ts:1867](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1867) A MarketCreatorPolicy as the indexer sees it (mirror of the `MarketCreatorPolicy` entity). ## Properties ### id > **id**: `string` Defined in: [query.ts:1869](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1869) Policy address (== entity id, lowercased). *** ### owner > **owner**: `string` Defined in: [query.ts:1871](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1871) Owner address (lowercased). *** ### creator > **creator**: `string` Defined in: [query.ts:1873](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1873) The MarketCreator this policy gates (lowercased). *** ### createdAtTimestamp > **createdAtTimestamp**: `string` Defined in: [query.ts:1874](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1874) --- # /docs/api/index/type-aliases/IndexedOperator [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / IndexedOperator # Type Alias: IndexedOperator > **IndexedOperator** = `object` Defined in: [query.ts:1602](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1602) An operator as the indexer sees it (mirror of the `Operator` entity). ## Properties ### operatorId > **operatorId**: `number` Defined in: [query.ts:1604](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1604) operatorId (uint32) as a number — the on-chain id AND the entity primary key. *** ### owner > **owner**: `string` Defined in: [query.ts:1606](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1606) Owner address (lowercased). *** ### feeRecipient > **feeRecipient**: `string` Defined in: [query.ts:1608](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1608) Default fee recipient for the operator's venues (lowercased). *** ### enabled > **enabled**: `boolean` Defined in: [query.ts:1609](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1609) *** ### policy > **policy**: `string` Defined in: [query.ts:1611](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1611) Operator-wide IVenuePolicy (lowercased); zero-address = none. *** ### context > **context**: `string` Defined in: [query.ts:1614](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1614) Opaque operator-supplied metadata bytes (hex, 0x-prefixed; '0x' when empty). The chain attaches no semantics — off-chain data only. *** ### pendingOwner > **pendingOwner**: `string` \| `null` Defined in: [query.ts:1616](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1616) Pending incoming owner staged by a two-step transfer (lowercased); null if none in flight. *** ### createdAtTimestamp > **createdAtTimestamp**: `string` Defined in: [query.ts:1617](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1617) *** ### updatedAtTimestamp > **updatedAtTimestamp**: `string` Defined in: [query.ts:1618](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1618) *** ### venueCount > **venueCount**: `number` Defined in: [query.ts:1620](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1620) Number of venues created under the operator (soft-disabled included). *** ### marketCount > **marketCount**: `number` Defined in: [query.ts:1622](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1622) Number of markets created under the operator. *** ### cumulativeQuoteVolume > **cumulativeQuoteVolume**: `string` Defined in: [query.ts:1624](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1624) Cumulative binary quote/collateral volume across the operator's markets (raw). *** ### protocolFeesCollected > **protocolFeesCollected**: `string` Defined in: [query.ts:1626](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1626) Cumulative protocol fees collected across the operator's markets (raw). *** ### settlementFeesCollected > **settlementFeesCollected**: `string` Defined in: [query.ts:1628](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1628) Cumulative settlement fees collected across the operator's markets (raw). *** ### builderFeesCollected > **builderFeesCollected**: `string` Defined in: [query.ts:1630](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1630) Cumulative builder fees routed across the operator's markets (raw). --- # /docs/api/index/type-aliases/IndexedOracleAdapter [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / IndexedOracleAdapter # Type Alias: IndexedOracleAdapter > **IndexedOracleAdapter** = `object` Defined in: [query.ts:1850](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1850) An OracleAdapter as the indexer sees it (mirror of the `OracleAdapter` entity). ## Properties ### id > **id**: `string` Defined in: [query.ts:1852](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1852) Adapter address (== entity id, lowercased). *** ### owner > **owner**: `string` Defined in: [query.ts:1854](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1854) Owner address (lowercased). *** ### factory > **factory**: `string` \| `null` Defined in: [query.ts:1857](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1857) The OracleAdapterFactory that minted it (lowercased); null for the protocol's shared adapter (deployed outside the factory). *** ### approved > **approved**: `boolean` Defined in: [query.ts:1859](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1859) Whether the module has approved the adapter (the inert→live gate). *** ### approvedAtTimestamp > **approvedAtTimestamp**: `string` \| `null` Defined in: [query.ts:1861](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1861) Timestamp the adapter was approved (null if never approved). *** ### createdAtTimestamp > **createdAtTimestamp**: `string` Defined in: [query.ts:1862](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1862) --- # /docs/api/index/type-aliases/IndexedSeries [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / IndexedSeries # Type Alias: IndexedSeries > **IndexedSeries** = `object` Defined in: [query.ts:1808](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1808) A Series as the indexer sees it (mirror of the `Series` entity) — one rolling up/down market spec registered under a creator. ## Properties ### id > **id**: `string` Defined in: [query.ts:1810](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1810) Entity id: `${creatorLower}_${seriesId}`. *** ### creatorAddress > **creatorAddress**: `string` Defined in: [query.ts:1812](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1812) The MarketCreator this series belongs to (lowercased). *** ### seriesId > **seriesId**: `number` Defined in: [query.ts:1814](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1814) Per-creator series id (uint32). *** ### collateral > **collateral**: `string` Defined in: [query.ts:1816](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1816) Per-series collateral ERC-20 (lowercased). *** ### asset > **asset**: `string` Defined in: [query.ts:1818](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1818) Underlying asset label (e.g. "BTC/USDT"). *** ### intervalSec > **intervalSec**: `string` Defined in: [query.ts:1820](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1820) Roll interval in seconds (raw bigint as string). *** ### createdAtTimestamp > **createdAtTimestamp**: `string` Defined in: [query.ts:1821](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1821) *** ### updatedAtTimestamp > **updatedAtTimestamp**: `string` Defined in: [query.ts:1822](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1822) --- # /docs/api/index/type-aliases/IndexedVenue [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / IndexedVenue # Type Alias: IndexedVenue > **IndexedVenue** = `object` Defined in: [query.ts:1634](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1634) A venue as the indexer sees it (mirror of the `Venue` entity). ## Properties ### venueId > **venueId**: `string` Defined in: [query.ts:1636](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1636) Opaque bytes32 venue id (== entity id); NOT a human label. *** ### operatorId > **operatorId**: `number` Defined in: [query.ts:1637](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1637) *** ### marketType > **marketType**: `string` Defined in: [query.ts:1639](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1639) bytes4 market-type id the venue is pinned to, forever (hex). *** ### feeParams > **feeParams**: `string` Defined in: [query.ts:1641](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1641) Type-specific fee params, opaque to the registry (bytes hex). *** ### feeRecipientOverride > **feeRecipientOverride**: `string` Defined in: [query.ts:1643](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1643) Per-venue fee recipient override (lowercased); zero-address falls back to the operator's. *** ### policy > **policy**: `string` Defined in: [query.ts:1645](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1645) Per-venue IVenuePolicy (lowercased); zero-address = none. *** ### signer > **signer**: `string` Defined in: [query.ts:1647](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1647) Per-venue EIP-712 signer (lowercased); non-zero ⇒ creation requires a venue sig. *** ### creationEnabled > **creationEnabled**: `boolean` Defined in: [query.ts:1648](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1648) *** ### context > **context**: `string` Defined in: [query.ts:1651](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1651) Opaque venue-supplied metadata bytes (hex, 0x-prefixed; '0x' when empty). The chain attaches no semantics — off-chain data only. *** ### createdAtTimestamp > **createdAtTimestamp**: `string` Defined in: [query.ts:1652](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1652) *** ### updatedAtTimestamp > **updatedAtTimestamp**: `string` Defined in: [query.ts:1653](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1653) *** ### marketCount > **marketCount**: `number` Defined in: [query.ts:1655](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1655) Number of markets created under the venue. *** ### cumulativeQuoteVolume > **cumulativeQuoteVolume**: `string` Defined in: [query.ts:1657](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1657) Cumulative binary quote/collateral volume across the venue's markets (raw). *** ### protocolFeesCollected > **protocolFeesCollected**: `string` Defined in: [query.ts:1659](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1659) Cumulative protocol fees collected across the venue's markets (raw). *** ### settlementFeesCollected > **settlementFeesCollected**: `string` Defined in: [query.ts:1661](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1661) Cumulative settlement fees collected across the venue's markets (raw). *** ### builderFeesCollected > **builderFeesCollected**: `string` Defined in: [query.ts:1663](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1663) Cumulative builder fees routed across the venue's markets (raw). --- # /docs/api/index/type-aliases/IndexerSyncStatus [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / IndexerSyncStatus # Type Alias: IndexerSyncStatus > **IndexerSyncStatus** = `object` Defined in: [query.ts:1231](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1231) ## Properties ### chainId > **chainId**: `number` Defined in: [query.ts:1232](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1232) *** ### latestProcessedBlock > **latestProcessedBlock**: `number` \| `null` Defined in: [query.ts:1233](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1233) *** ### blockHeight > **blockHeight**: `number` \| `null` Defined in: [query.ts:1234](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1234) *** ### numEventsProcessed > **numEventsProcessed**: `number` Defined in: [query.ts:1235](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1235) --- # /docs/api/index/type-aliases/LiquidationEvent [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / LiquidationEvent # Type Alias: LiquidationEvent > **LiquidationEvent** = `object` Defined in: [query.ts:2672](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2672) A liquidation event (mirror of the indexer `LiquidationEvent` entity). All numeric fields are raw units; any may be null when the source event didn't carry it. ## Properties ### id > **id**: `string` Defined in: [query.ts:2673](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2673) *** ### account > **account**: `string` Defined in: [query.ts:2674](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2674) *** ### pool > **pool**: `string` \| `null` Defined in: [query.ts:2675](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2675) *** ### size > **size**: `string` \| `null` Defined in: [query.ts:2676](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2676) *** ### price > **price**: `string` \| `null` Defined in: [query.ts:2677](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2677) *** ### penalty > **penalty**: `string` \| `null` Defined in: [query.ts:2678](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2678) *** ### badDebt > **badDebt**: `string` \| `null` Defined in: [query.ts:2679](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2679) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2680](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2680) *** ### txHash > **txHash**: `string` Defined in: [query.ts:2681](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2681) --- # /docs/api/index/type-aliases/LiveBinaryMarketsFilter [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / LiveBinaryMarketsFilter # Type Alias: LiveBinaryMarketsFilter > **LiveBinaryMarketsFilter** = [`BinaryMarketFilter`](BinaryMarketFilter.md) & `object` Defined in: [query.ts:706](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L706) Filters for `listLiveBinaryMarkets`. Every field is optional; an omitted field does NOT constrain the query. Applied server-side (Hasura `where`), so `venueId` / `intervalSec` hit their indexes. ## Type Declaration ### limit? > `optional` **limit?**: `number` Page size (default 50). Live is unbounded at scale (thousands of venues × cadences), so it is ALWAYS paginated — never fetch the whole live set. ### offset? > `optional` **offset?**: `number` Row offset for cursoring the live board (default 0). ### nowSec? > `optional` **nowSec?**: `number` Override "now" (unix seconds); defaults to `Date.now()`. Mostly for tests. --- # /docs/api/index/type-aliases/LiveMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / LiveMarket # Type Alias: LiveMarket > **LiveMarket** = [`Market`](Market.md) Defined in: [store.ts:78](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L78) The live market shape IS the read-surface market union — spot and binary rows materialize into the exact shape `client.listMarkets` serves. --- # /docs/api/index/type-aliases/MarginEvent [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarginEvent # Type Alias: MarginEvent > **MarginEvent** = `object` Defined in: [query.ts:2659](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2659) A margin-account movement (mirror of the indexer `MarginEvent` entity). ## Properties ### id > **id**: `string` Defined in: [query.ts:2660](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2660) *** ### account > **account**: `string` Defined in: [query.ts:2661](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2661) *** ### kind > **kind**: `string` Defined in: [query.ts:2663](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2663) Deposit | Withdraw | Locked | Unlocked. *** ### amount > **amount**: `string` Defined in: [query.ts:2664](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2664) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2665](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2665) *** ### txHash > **txHash**: `string` Defined in: [query.ts:2666](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2666) --- # /docs/api/index/type-aliases/MarginStatus [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarginStatus # Type Alias: MarginStatus > **MarginStatus** = `"Healthy"` \| `"MarginCall"` \| `"PartialLiquidation"` \| `"CloseOut"` Defined in: [reads.ts:205](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L205) Cross-margin health status (mirror of the on-chain `MarginStatus` enum): `"Healthy"` (equity ≥ IM) · `"MarginCall"` (IM > equity ≥ MM) · `"PartialLiquidation"` (MM > equity ≥ CM) · `"CloseOut"` (equity < CM). --- # /docs/api/index/type-aliases/Market [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / Market # Type Alias: Market > **Market** = [`SpotMarket`](SpotMarket.md) \| [`PerpMarket`](PerpMarket.md) \| [`BinaryMarket`](BinaryMarket.md) Defined in: [query.ts:295](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L295) A market of any type, discriminated by `marketType`. --- # /docs/api/index/type-aliases/MarketCreatorFilter [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketCreatorFilter # Type Alias: MarketCreatorFilter > **MarketCreatorFilter** = `object` Defined in: [query.ts:1890](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1890) Server-side filter for the MarketCreator directory. Every field optional. ## Properties ### owner? > `optional` **owner?**: `string` Defined in: [query.ts:1892](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1892) Restrict to creators owned by this address (case-insensitive). *** ### operatorId? > `optional` **operatorId?**: `number` Defined in: [query.ts:1894](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1894) Restrict to one operator id. *** ### venueId? > `optional` **venueId?**: `string` Defined in: [query.ts:1896](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1896) Restrict to one bytes32 venue id (case-insensitive). --- # /docs/api/index/type-aliases/MarketFees [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketFees # Type Alias: MarketFees > **MarketFees** = `object` Defined in: [query.ts:576](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L576) The origin attribution + fee config frozen into a market at creation, mirrored from `BinaryMarketsModule.MarketCreated` / `MarketFeeConfig` into the indexer's `MarketVenue` entity. Rates are standard basis points (1 = 0.01%, 100 = 1%, 10_000 = 100%). Fee fields are null for markets indexed before the fee plumbing existed. ## Properties ### operatorId > **operatorId**: `number` Defined in: [query.ts:577](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L577) *** ### venueId > **venueId**: `string` Defined in: [query.ts:579](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L579) Origin venue id within the operator (bytes32 hex). *** ### feeRecipient > **feeRecipient**: `string` \| `null` Defined in: [query.ts:580](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L580) *** ### makerFeeBps > **makerFeeBps**: `string` \| `null` Defined in: [query.ts:581](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L581) *** ### takerFeeBps > **takerFeeBps**: `string` \| `null` Defined in: [query.ts:582](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L582) *** ### maxBuilderFeeBps > **maxBuilderFeeBps**: `string` \| `null` Defined in: [query.ts:583](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L583) *** ### routingFeeBps > **routingFeeBps**: `string` \| `null` Defined in: [query.ts:584](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L584) *** ### settlementFeeBps > **settlementFeeBps**: `string` \| `null` Defined in: [query.ts:586](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L586) Settlement fee skimmed from the winning payout at redeem (bps). *** ### settlementFeesCollected > **settlementFeesCollected**: `string` \| `null` Defined in: [query.ts:588](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L588) Realized settlement fee collected on winning redemptions so far (raw collateral). --- # /docs/api/index/type-aliases/MarketReferenceLink [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketReferenceLink # Type Alias: MarketReferenceLink > **MarketReferenceLink** = `object` Defined in: [query.ts:2078](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2078) The oracle reference a market binds to (mirror of the indexer `MarketReferenceLink` entity). ## Properties ### id > **id**: `string` Defined in: [query.ts:2079](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2079) *** ### market > **market**: `string` Defined in: [query.ts:2081](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2081) Market id (lowercased bytes32). *** ### oracleQuestionId > **oracleQuestionId**: `string` Defined in: [query.ts:2083](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2083) Reference question id the market resolves against (decimal string). *** ### pending > **pending**: `boolean` Defined in: [query.ts:2086](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2086) True once the market has its own answer but the reference question is not yet final (resolution still pending on the reference). --- # /docs/api/index/type-aliases/MarketResolutionEvent [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketResolutionEvent # Type Alias: MarketResolutionEvent > **MarketResolutionEvent** = `object` Defined in: [query.ts:2053](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2053) One market-resolution lifecycle event (mirror of the indexer `MarketResolutionEvent` entity). Oracle v2: resolution is delivered as a payout VECTOR (`MarketResolved(marketId, qid, payoutDenominator, payoutNumerators, voided)`); `winningOutcome` stays as the binary-compat derivation of a one-hot vector. ## Properties ### id > **id**: `string` Defined in: [query.ts:2054](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2054) *** ### market > **market**: `string` Defined in: [query.ts:2056](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2056) Market id (lowercased bytes32). *** ### kind > **kind**: `string` Defined in: [query.ts:2058](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2058) Resolution kind, e.g. "Resolved" | "Skipped" | "Failed" (indexer-defined). *** ### winningOutcome > **winningOutcome**: `number` \| `null` Defined in: [query.ts:2061](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2061) Winning outcome (0 = YES, 1 = NO), derived from a one-hot payout vector; null on void / skip / non-one-hot vectors. *** ### payoutNumerators? > `optional` **payoutNumerators?**: `string`[] \| `null` Defined in: [query.ts:2065](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2065) Per-outcome payout numerators delivered with the event (decimal strings; raw Σ == payoutDenominator). Null on events indexed before the vector wire / kinds that carry none. *** ### payoutDenominator? > `optional` **payoutDenominator?**: `string` \| `null` Defined in: [query.ts:2068](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2068) Vector denominator (`PAYOUT_VECTOR_DENOMINATOR` = 10_000_000; decimal string). Null when no vector was carried. *** ### voided? > `optional` **voided?**: `boolean` \| `null` Defined in: [query.ts:2070](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2070) True when the market was voided (uniform vector) rather than resolved. *** ### blockNumber > **blockNumber**: `string` Defined in: [query.ts:2071](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2071) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2072](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2072) *** ### txHash > **txHash**: `string` Defined in: [query.ts:2073](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2073) --- # /docs/api/index/type-aliases/MarketStatusUpdate [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketStatusUpdate # Type Alias: MarketStatusUpdate > **MarketStatusUpdate** = `object` Defined in: [query.ts:643](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L643) One entry in a market's lifecycle audit trail (from the indexer's MarketStatusUpdate entity). ## Properties ### oldStatus > **oldStatus**: [`BinaryMarketStatus`](BinaryMarketStatus.md) Defined in: [query.ts:644](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L644) *** ### newStatus > **newStatus**: [`BinaryMarketStatus`](BinaryMarketStatus.md) Defined in: [query.ts:645](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L645) *** ### blockNumber > **blockNumber**: `string` Defined in: [query.ts:646](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L646) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:647](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L647) *** ### txHash > **txHash**: `string` Defined in: [query.ts:648](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L648) --- # /docs/api/index/type-aliases/MarketType [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MarketType # Type Alias: MarketType > **MarketType** = `"SPOT"` \| `"PERP"` \| `"BINARY"` Defined in: [query.ts:116](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L116) --- # /docs/api/index/type-aliases/OpenInterestSnapshot [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OpenInterestSnapshot # Type Alias: OpenInterestSnapshot > **OpenInterestSnapshot** = `object` Defined in: [query.ts:2698](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2698) An open-interest snapshot (mirror of the indexer `OpenInterestSnapshot` entity). ## Properties ### id > **id**: `string` Defined in: [query.ts:2699](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2699) *** ### pool > **pool**: `string` Defined in: [query.ts:2700](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2700) *** ### longOpenInterest > **longOpenInterest**: `string` \| `null` Defined in: [query.ts:2701](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2701) *** ### shortOpenInterest > **shortOpenInterest**: `string` \| `null` Defined in: [query.ts:2702](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2702) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2703](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2703) --- # /docs/api/index/type-aliases/OpenOrder [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OpenOrder # Type Alias: OpenOrder > **OpenOrder** = `object` Defined in: [query.ts:838](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L838) ## Properties ### id > **id**: `string` Defined in: [query.ts:840](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L840) Order id (`${pool}_${orderId}`). *** ### orderId > **orderId**: `string` Defined in: [query.ts:842](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L842) uint128 OrderId as a decimal string (pass to trader.cancelOrder). *** ### pool > **pool**: `string` Defined in: [query.ts:844](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L844) Lower-cased pool address the order rests on. *** ### side > **side**: [`BinarySide`](BinarySide.md) \| `null` Defined in: [query.ts:847](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L847) BINARY YES/NO classification; NULL on spot orders (the indexer only sets it for binary). For a buy/sell distinction that works on BOTH kinds use `isBid`. *** ### isBid > **isBid**: `boolean` Defined in: [query.ts:850](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L850) True = bid (buy), false = ask (sell). The canonical buy/sell flag — set for spot AND binary, unlike `side` which is null on spot. Colour/label off this. *** ### price > **price**: `string` Defined in: [query.ts:851](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L851) *** ### quantityRemaining > **quantityRemaining**: `string` Defined in: [query.ts:852](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L852) --- # /docs/api/index/type-aliases/OperatorFilter [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OperatorFilter # Type Alias: OperatorFilter > **OperatorFilter** = `object` Defined in: [query.ts:1668](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1668) Server-side filter for the operator directory. Every field optional (an omitted field does not constrain). Applied as a Hasura `where`. ## Properties ### owner? > `optional` **owner?**: `string` Defined in: [query.ts:1670](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1670) Restrict to operators owned by this address (case-insensitive). *** ### enabled? > `optional` **enabled?**: `boolean` Defined in: [query.ts:1672](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1672) Restrict to enabled (true) / disabled (false) operators. --- # /docs/api/index/type-aliases/OperatorHubAccountRecord [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OperatorHubAccountRecord # Type Alias: OperatorHubAccountRecord > **OperatorHubAccountRecord** = `object` Defined in: [query.ts:2244](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2244) An operator's hub account (mirror of the indexer `OperatorHubAccount` entity; id = operatorId decimal string) — the earmark-at-creation surface. Running totals derived from the hub events: `earmarked` (LOCKED, never withdrawable; == `outstanding × resolveReserve`), `credit` (WITHDRAWABLE surplus), and `outstanding` (bound-but-unresolved market count). Live/authoritative figures are the chain reads `earmarkedOf`/`creditOf`/`outstandingOf`. ## Properties ### id > **id**: `string` Defined in: [query.ts:2246](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2246) operatorId (decimal string == entity id). *** ### operatorId > **operatorId**: `number` Defined in: [query.ts:2247](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2247) *** ### earmarked > **earmarked**: `string` Defined in: [query.ts:2249](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2249) Native LOCKED for outstanding markets (wei); Σ ReserveEarmarked − Σ released. *** ### credit > **credit**: `string` Defined in: [query.ts:2251](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2251) Withdrawable surplus (wei): Σ SurplusCredited − Σ CreditWithdrawn. *** ### outstanding > **outstanding**: `string` Defined in: [query.ts:2253](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2253) Bound-but-unresolved market count (binds − resolutions). *** ### createdAtBlock > **createdAtBlock**: `string` Defined in: [query.ts:2254](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2254) *** ### createdAtTimestamp > **createdAtTimestamp**: `string` Defined in: [query.ts:2255](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2255) *** ### updatedAtBlock > **updatedAtBlock**: `string` Defined in: [query.ts:2256](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2256) *** ### updatedAtTimestamp > **updatedAtTimestamp**: `string` Defined in: [query.ts:2257](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2257) --- # /docs/api/index/type-aliases/OracleAnswer [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OracleAnswer # Type Alias: OracleAnswer > **OracleAnswer** = `object` Defined in: [query.ts:2091](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2091) The numeric answer the oracle posted for a question (mirror of the indexer `OracleAnswer` entity). ## Properties ### oracleQuestionId > **oracleQuestionId**: `string` Defined in: [query.ts:2093](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2093) oracleQuestionId (decimal string == entity id). *** ### numericValue > **numericValue**: `string` \| `null` Defined in: [query.ts:2095](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2095) Numeric answer the oracle posted (raw; interpretation is question-specific). *** ### outcomeLabel > **outcomeLabel**: `string` \| `null` Defined in: [query.ts:2097](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2097) Human outcome label the oracle posted, if any. *** ### voidReason > **voidReason**: `number` \| `null` Defined in: [query.ts:2099](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2099) Void reason code (non-null only on a voided answer). *** ### resolvedAt > **resolvedAt**: `string` \| `null` Defined in: [query.ts:2100](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2100) *** ### txHash > **txHash**: `string` \| `null` Defined in: [query.ts:2101](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2101) --- # /docs/api/index/type-aliases/OracleBindRecord [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OracleBindRecord # Type Alias: OracleBindRecord > **OracleBindRecord** = `object` Defined in: [query.ts:2265](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2265) One market's bind on a question (mirror of the indexer `OracleBind` entity, Oracle v2 §8e). Opens with `MarketBound` (operator attribution; the paired `ReserveEarmarked` locks the reserve), stamped at resolution with `MarketResolveCharged` (exact metered charge + subsidy; a surplus is credited via `SurplusCredited`). Per-market conservation: `charged + subsidy == cost`. ## Properties ### id > **id**: `string` Defined in: [query.ts:2266](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2266) *** ### oracleQuestionId > **oracleQuestionId**: `string` Defined in: [query.ts:2268](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2268) Question the bind belongs to (decimal string). *** ### bindIndex > **bindIndex**: `number` Defined in: [query.ts:2270](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2270) 1-based lifetime bind sequence on the question. *** ### operatorId > **operatorId**: `number` Defined in: [query.ts:2272](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2272) Operator whose earmark funds this market's resolve. *** ### measuredGas > **measuredGas**: `string` \| `null` Defined in: [query.ts:2274](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2274) gasleft()-wrapped measured gas of the resolve slice; null until resolved. *** ### overheadShare > **overheadShare**: `string` \| `null` Defined in: [query.ts:2276](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2276) Pro-rata share of the callback overhead gas; null until resolved. *** ### cost > **cost**: `string` \| `null` Defined in: [query.ts:2278](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2278) Exact wei the resolve cost worked out to; null until resolved. *** ### charged > **charged**: `string` \| `null` Defined in: [query.ts:2281](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2281) Wei actually charged against this market's earmark; null until resolved (== min(cost, reserve)). *** ### subsidy > **subsidy**: `string` \| `null` Defined in: [query.ts:2284](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2284) cost − charged: the reserve-capped shortfall the hub subsidised; null until resolved. *** ### resolvedAt > **resolvedAt**: `string` \| `null` Defined in: [query.ts:2287](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2287) Timestamp the resolve cost was charged (`MarketResolveCharged`); null until resolved — the resolved flag is simply `resolvedAt != null`. *** ### boundAtBlock > **boundAtBlock**: `string` Defined in: [query.ts:2288](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2288) *** ### boundAtTimestamp > **boundAtTimestamp**: `string` Defined in: [query.ts:2289](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2289) *** ### txHash > **txHash**: `string` Defined in: [query.ts:2290](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2290) --- # /docs/api/index/type-aliases/OracleCallbackRecord [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OracleCallbackRecord # Type Alias: OracleCallbackRecord > **OracleCallbackRecord** = `object` Defined in: [query.ts:2300](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2300) One resolution callback's conservation record (mirror of the indexer `OracleCallback` entity ← the hub's `CallbackAccounted` event). NOT per-question (a callback drains across many qids). Invariants: `totalCost == (measuredGas + overheadGasAttributed) * gasPrice`; Σ of the callback's `OracleBindRecord.charged == totalCharged`; `totalCharged + subsidy == totalCost` (the subsidy is the hub's explicit reserve-capped shortfall). ## Properties ### id > **id**: `string` Defined in: [query.ts:2301](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2301) *** ### marketsResolved > **marketsResolved**: `string` Defined in: [query.ts:2303](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2303) Number of markets resolved in this callback. *** ### gasPrice > **gasPrice**: `string` Defined in: [query.ts:2305](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2305) `tx.gasprice` of the callback (wei). *** ### measuredGas > **measuredGas**: `string` Defined in: [query.ts:2307](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2307) Σ `gasleft()`-wrapped measured gas across the resolved markets. *** ### overheadGasAttributed > **overheadGasAttributed**: `string` Defined in: [query.ts:2309](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2309) The governance-calibrated `callbackBaseGas` term attributed on top. *** ### totalCost > **totalCost**: `string` Defined in: [query.ts:2311](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2311) Exact wei distributed: `(measuredGas + overhead) * gasPrice`. *** ### totalCharged > **totalCharged**: `string` Defined in: [query.ts:2313](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2313) Σ wei actually charged against market earmarks. *** ### subsidy > **subsidy**: `string` Defined in: [query.ts:2315](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2315) `totalCost − totalCharged`: the hub's explicit reserve-capped subsidy. *** ### pendingRemaining > **pendingRemaining**: `string` Defined in: [query.ts:2317](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2317) Markets still queued after this callback (0 = drain complete). *** ### blockNumber > **blockNumber**: `string` Defined in: [query.ts:2318](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2318) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2319](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2319) *** ### txHash > **txHash**: `string` Defined in: [query.ts:2320](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2320) --- # /docs/api/index/type-aliases/OracleQuestionRecord [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OracleQuestionRecord # Type Alias: OracleQuestionRecord > **OracleQuestionRecord** = `object` Defined in: [query.ts:2219](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2219) A hub-scheduled oracle question (mirror of the indexer `OracleQuestion` entity; id = oracleQuestionId as a decimal string). Tracks the content-addressed dedup state: the canonical key, who paid the oracle submission, and how many markets bound to it. ## Properties ### id > **id**: `string` Defined in: [query.ts:2221](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2221) oracleQuestionId (decimal string == entity id). *** ### questionKey > **questionKey**: `string` \| `null` Defined in: [query.ts:2224](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2224) Canonical dedup key (bytes32 hex); zero/null for non-template definitions that bypassed dedup. *** ### scheduler > **scheduler**: `string` Defined in: [query.ts:2226](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2226) Caller that paid the oracle submission cost (lowercased). *** ### oracleCost > **oracleCost**: `string` Defined in: [query.ts:2228](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2228) Native wei forwarded to the oracle for this submission. *** ### bindCount > **bindCount**: `number` Defined in: [query.ts:2230](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2230) Lifetime bind count (from `MarketBound.bindCount`, monotonic). *** ### reuseCount > **reuseCount**: `number` Defined in: [query.ts:2233](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2233) Times an identical definition deduplicated onto this question (`QuestionReused` count). *** ### createdAtBlock > **createdAtBlock**: `string` Defined in: [query.ts:2234](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2234) *** ### createdAtTimestamp > **createdAtTimestamp**: `string` Defined in: [query.ts:2235](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2235) --- # /docs/api/index/type-aliases/OrderRow [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OrderRow # Type Alias: OrderRow > **OrderRow** = [`OpenOrder`](OpenOrder.md) & `object` Defined in: [query.ts:914](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L914) An order row with its lifecycle status + fill progress (from getOrders). ## Type Declaration ### status > **status**: [`OrderStatus`](OrderStatus.md) ### fullQuantity > **fullQuantity**: `string` ### filledQuantity > **filledQuantity**: `string` ### rested > **rested**: `boolean` Whether the order ever rested on the book (an `OrderRested` fired). ### expireTimestampNs > **expireTimestampNs**: `string` Order expiry as a uint64 nanosecond timestamp (decimal string). GTC orders carry type(uint64).max; the matcher rejects a 0/past expiry at placement, so "0" is never a live value (it is not a GTC sentinel). ### placedTxHash > **placedTxHash**: `string` Tx hash the order was placed in. --- # /docs/api/index/type-aliases/OrderStatus [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OrderStatus # Type Alias: OrderStatus > **OrderStatus** = `"Open"` \| `"Closed"` \| `"Filled"` \| `"Cancelled"` \| `"Expired"` Defined in: [store.ts:31](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L31) Order lifecycle — shared by spot and binary orders. Spot orders are born "Closed" and promoted to "Open" by OrderRested (mirror of the indexer). --- # /docs/api/index/type-aliases/OrdersOptions [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OrdersOptions # Type Alias: OrdersOptions > **OrdersOptions** = `object` Defined in: [query.ts:858](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L858) Options for getOpenOrders / getOrders. All optional. ## Properties ### pool? > `optional` **pool?**: `string` Defined in: [query.ts:860](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L860) Restrict to one pool. *** ### status? > `optional` **status?**: [`OrderStatus`](OrderStatus.md) Defined in: [query.ts:862](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L862) Order status. getOrders only — getOpenOrders is always "Open". *** ### side? > `optional` **side?**: [`OpenOrder`](OpenOrder.md)\[`"side"`\] Defined in: [query.ts:864](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L864) Restrict to one side. *** ### limit? > `optional` **limit?**: `number` Defined in: [query.ts:866](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L866) Max rows. *** ### offset? > `optional` **offset?**: `number` Defined in: [query.ts:868](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L868) Row offset (default 0). --- # /docs/api/index/type-aliases/OutcomeBalances [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OutcomeBalances # Type Alias: OutcomeBalances > **OutcomeBalances** = `object` Defined in: [query.ts:815](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L815) ## Properties ### yes > **yes**: `string` Defined in: [query.ts:815](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L815) *** ### no > **no**: `string` Defined in: [query.ts:815](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L815) --- # /docs/api/index/type-aliases/OutcomeIdx [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / OutcomeIdx # Type Alias: OutcomeIdx > **OutcomeIdx** = `0` \| `1` Defined in: [ids.ts:32](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/ids.ts#L32) A binary outcome index: 0 = YES, 1 = NO. --- # /docs/api/index/type-aliases/PastBinaryMarketsOptions [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PastBinaryMarketsOptions # Type Alias: PastBinaryMarketsOptions > **PastBinaryMarketsOptions** = [`BinaryMarketFilter`](BinaryMarketFilter.md) & `object` Defined in: [query.ts:742](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L742) Options for `listPastBinaryMarkets` — the [BinaryMarketFilter](BinaryMarketFilter.md) plus pagination + a `now` override. ## Type Declaration ### limit? > `optional` **limit?**: `number` Page size (default 50). ### offset? > `optional` **offset?**: `number` Row offset for cursoring the historical tail (default 0). ### nowSec? > `optional` **nowSec?**: `number` Override "now" (unix seconds); defaults to `Date.now()`. --- # /docs/api/index/type-aliases/PerpMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PerpMarket # Type Alias: PerpMarket > **PerpMarket** = [`BaseMarket`](BaseMarket.md) & `object` Defined in: [query.ts:172](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L172) A perpetual-futures order-book market. Rides the same OrderBook core as spot (base/quote book, raw quote units per whole base), with a synthetic base: positions + collateral live cross-margin in the MarginBank, and the pool tracks funding against an oracle index price. ## Type Declaration ### marketType > **marketType**: `"PERP"` ### baseToken > **baseToken**: `string` Wrapper token standing in for the synthetic base (e.g. WBTC). ### quoteToken > **quoteToken**: `string` The MarginBank collateral token (e.g. USDso). ### baseSymbol > **baseSymbol**: `string` \| `null` ### quoteSymbol > **quoteSymbol**: `string` \| `null` ### baseIsNative > **baseIsNative**: `boolean` Always false — the perp base is synthetic, never native. Kept so spot-shaped base/quote code paths can treat SPOT and PERP uniformly. ### tickSize > **tickSize**: `string` ### lotSize > **lotSize**: `string` ### minQuantity > **minQuantity**: `string` ### marginBank > **marginBank**: `string` Cross-margin MarginBank holding collateral + positions (lowercased). ### initialMarginBps > **initialMarginBps**: `number` Initial margin requirement in bps (500 = 5% = 20x max leverage). ### fundingRate > **fundingRate**: `string` \| `null` Funding rate for the last settlement window (1e18-scaled fraction, signed). Null until the first FundingUpdated is indexed. ### cumulativeFundingPerUnit > **cumulativeFundingPerUnit**: `string` \| `null` Cumulative funding per base unit since inception (1e18-scaled, signed). ### indexPrice > **indexPrice**: `string` \| `null` Oracle index price at the last funding update (raw quote per whole base). ### fundingUpdatedAt > **fundingUpdatedAt**: `string` \| `null` ### longOpenInterest > **longOpenInterest**: `string` \| `null` Total long open interest in base units. ### shortOpenInterest > **shortOpenInterest**: `string` \| `null` Total short open interest in base units. ### openInterestUpdatedAt > **openInterestUpdatedAt**: `string` \| `null` --- # /docs/api/index/type-aliases/PerpMarketFilter [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PerpMarketFilter # Type Alias: PerpMarketFilter > **PerpMarketFilter** = `object` Defined in: [query.ts:672](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L672) Filters for listPerpMarkets. All optional; applied server-side. ## Properties ### baseSymbol? > `optional` **baseSymbol?**: `string` Defined in: [query.ts:674](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L674) Synthetic-base token symbol, e.g. `"WBTC"`. *** ### quoteSymbol? > `optional` **quoteSymbol?**: `string` Defined in: [query.ts:676](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L676) Collateral (quote) token symbol, e.g. `"USDso"`. --- # /docs/api/index/type-aliases/PerpPortfolio [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PerpPortfolio # Type Alias: PerpPortfolio > **PerpPortfolio** = `object` Defined in: [query.ts:1485](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1485) ## Properties ### account > **account**: `string` Defined in: [query.ts:1486](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1486) *** ### openOrders > **openOrders**: [`PerpPortfolioOrder`](PerpPortfolioOrder.md)[] Defined in: [query.ts:1487](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1487) *** ### trades > **trades**: [`PerpPortfolioTrade`](PerpPortfolioTrade.md)[] Defined in: [query.ts:1488](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1488) --- # /docs/api/index/type-aliases/PerpPortfolioMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PerpPortfolioMarket # Type Alias: PerpPortfolioMarket > **PerpPortfolioMarket** = `object` Defined in: [query.ts:1442](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1442) Perp market context attached to perp portfolio rows. id == poolAddress. ## Properties ### poolAddress > **poolAddress**: `string` Defined in: [query.ts:1443](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1443) *** ### baseSymbol > **baseSymbol**: `string` \| `null` Defined in: [query.ts:1444](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1444) *** ### quoteSymbol > **quoteSymbol**: `string` \| `null` Defined in: [query.ts:1445](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1445) *** ### baseDecimals > **baseDecimals**: `number` Defined in: [query.ts:1446](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1446) *** ### quoteDecimals > **quoteDecimals**: `number` Defined in: [query.ts:1447](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1447) *** ### tickSize > **tickSize**: `string` \| `null` Defined in: [query.ts:1448](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1448) *** ### lotSize > **lotSize**: `string` \| `null` Defined in: [query.ts:1449](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1449) *** ### minQuantity > **minQuantity**: `string` \| `null` Defined in: [query.ts:1450](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1450) *** ### lastPrice > **lastPrice**: `string` \| `null` Defined in: [query.ts:1451](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1451) *** ### marginBank > **marginBank**: `string` \| `null` Defined in: [query.ts:1452](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1452) *** ### initialMarginBps > **initialMarginBps**: `number` \| `null` Defined in: [query.ts:1453](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1453) *** ### fundingRate > **fundingRate**: `string` \| `null` Defined in: [query.ts:1454](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1454) *** ### indexPrice > **indexPrice**: `string` \| `null` Defined in: [query.ts:1455](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1455) --- # /docs/api/index/type-aliases/PerpPortfolioOrder [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PerpPortfolioOrder # Type Alias: PerpPortfolioOrder > **PerpPortfolioOrder** = `object` Defined in: [query.ts:1458](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1458) ## Properties ### id > **id**: `string` Defined in: [query.ts:1459](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1459) *** ### orderId > **orderId**: `string` Defined in: [query.ts:1460](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1460) *** ### isBid > **isBid**: `boolean` Defined in: [query.ts:1461](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1461) *** ### price > **price**: `string` Defined in: [query.ts:1462](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1462) *** ### quantityRemaining > **quantityRemaining**: `string` Defined in: [query.ts:1463](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1463) *** ### filledQuantity > **filledQuantity**: `string` Defined in: [query.ts:1464](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1464) *** ### fullQuantity > **fullQuantity**: `string` Defined in: [query.ts:1465](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1465) *** ### placedAtTimestamp > **placedAtTimestamp**: `string` Defined in: [query.ts:1466](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1466) *** ### market > **market**: [`PerpPortfolioMarket`](PerpPortfolioMarket.md) Defined in: [query.ts:1467](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1467) --- # /docs/api/index/type-aliases/PerpPortfolioTrade [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PerpPortfolioTrade # Type Alias: PerpPortfolioTrade > **PerpPortfolioTrade** = `object` Defined in: [query.ts:1470](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1470) ## Properties ### id > **id**: `string` Defined in: [query.ts:1471](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1471) *** ### fillPrice > **fillPrice**: `string` Defined in: [query.ts:1472](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1472) *** ### quantity > **quantity**: `string` Defined in: [query.ts:1473](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1473) *** ### quoteQuantity > **quoteQuantity**: `string` Defined in: [query.ts:1474](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1474) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:1475](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1475) *** ### txHash > **txHash**: `string` Defined in: [query.ts:1476](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1476) *** ### isBid > **isBid**: `boolean` Defined in: [query.ts:1478](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1478) Whether the account bought (went long) on this fill. *** ### asMaker > **asMaker**: `boolean` Defined in: [query.ts:1480](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1480) Whether the account was the maker (resting) on this fill. *** ### counterparty > **counterparty**: `string` \| `null` Defined in: [query.ts:1481](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1481) *** ### market > **market**: [`PerpPortfolioMarket`](PerpPortfolioMarket.md) Defined in: [query.ts:1482](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1482) --- # /docs/api/index/type-aliases/Portfolio [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / Portfolio # Type Alias: Portfolio > **Portfolio** = `object` Defined in: [query.ts:1029](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1029) ## Properties ### account > **account**: `string` Defined in: [query.ts:1030](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1030) *** ### positions > **positions**: [`PortfolioPosition`](PortfolioPosition.md)[] Defined in: [query.ts:1031](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1031) *** ### openOrders > **openOrders**: [`PortfolioOrder`](PortfolioOrder.md)[] Defined in: [query.ts:1032](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1032) *** ### trades > **trades**: [`PortfolioTrade`](PortfolioTrade.md)[] Defined in: [query.ts:1033](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1033) --- # /docs/api/index/type-aliases/PortfolioMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PortfolioMarket # Type Alias: PortfolioMarket > **PortfolioMarket** = `object` Defined in: [query.ts:972](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L972) A market context attached to portfolio rows (subset of [BinaryMarket](BinaryMarket.md)). ## Properties ### id > **id**: `string` Defined in: [query.ts:975](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L975) The market's bytes32 marketId (== `BinaryMarket.id`). Key positions by this, never by `poolAddress` alone (a pool is recycled across markets). *** ### marketAddress > **marketAddress**: `string` Defined in: [query.ts:976](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L976) *** ### poolAddress > **poolAddress**: `string` Defined in: [query.ts:977](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L977) *** ### asset > **asset**: `string` Defined in: [query.ts:978](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L978) *** ### question > **question**: `string` Defined in: [query.ts:979](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L979) *** ### status > **status**: [`BinaryMarketStatus`](BinaryMarketStatus.md) Defined in: [query.ts:980](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L980) *** ### lastPrice > **lastPrice**: `string` \| `null` Defined in: [query.ts:981](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L981) *** ### strike > **strike**: `string` Defined in: [query.ts:982](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L982) *** ### expiry > **expiry**: `string` Defined in: [query.ts:983](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L983) *** ### winningOutcome? > `optional` **winningOutcome?**: `number` \| `null` Defined in: [query.ts:984](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L984) *** ### voided > **voided**: `boolean` Defined in: [query.ts:985](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L985) *** ### quoteDecimals > **quoteDecimals**: `number` Defined in: [query.ts:989](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L989) Collateral decimals (per-market — collateral is per-venue, e.g. 6dp TestUSDC vs 18dp USDso). Format prices/balances with this, never a hard-coded 6. Outcome-token amounts mirror the same decimals. --- # /docs/api/index/type-aliases/PortfolioOptions [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PortfolioOptions # Type Alias: PortfolioOptions > **PortfolioOptions** = `object` Defined in: [query.ts:1039](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1039) Paging/window options shared by the portfolio queries (getPortfolio / getSpotPortfolio / getPerpPortfolio). All optional. ## Properties ### ordersLimit? > `optional` **ordersLimit?**: `number` Defined in: [query.ts:1041](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1041) Max open orders to fetch (default 200). *** ### tradesLimit? > `optional` **tradesLimit?**: `number` Defined in: [query.ts:1043](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1043) Max recent trades to fetch (default 50). *** ### since? > `optional` **since?**: `number` Defined in: [query.ts:1045](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1045) Only trades at/after this unix-seconds timestamp. --- # /docs/api/index/type-aliases/PortfolioOrder [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PortfolioOrder # Type Alias: PortfolioOrder > **PortfolioOrder** = `object` Defined in: [query.ts:1002](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1002) ## Properties ### id > **id**: `string` Defined in: [query.ts:1003](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1003) *** ### orderId > **orderId**: `string` Defined in: [query.ts:1004](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1004) *** ### side > **side**: [`OpenOrder`](OpenOrder.md)\[`"side"`\] Defined in: [query.ts:1005](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1005) *** ### price > **price**: `string` Defined in: [query.ts:1006](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1006) *** ### quantityRemaining > **quantityRemaining**: `string` Defined in: [query.ts:1007](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1007) *** ### filledQuantity > **filledQuantity**: `string` Defined in: [query.ts:1008](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1008) *** ### fullQuantity > **fullQuantity**: `string` Defined in: [query.ts:1009](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1009) *** ### placedAtTimestamp > **placedAtTimestamp**: `string` Defined in: [query.ts:1010](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1010) *** ### market > **market**: [`PortfolioMarket`](PortfolioMarket.md) Defined in: [query.ts:1011](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1011) --- # /docs/api/index/type-aliases/PortfolioPosition [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PortfolioPosition # Type Alias: PortfolioPosition > **PortfolioPosition** = `object` Defined in: [query.ts:992](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L992) ## Properties ### market > **market**: [`PortfolioMarket`](PortfolioMarket.md) Defined in: [query.ts:993](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L993) *** ### outcomeIndex > **outcomeIndex**: `number` Defined in: [query.ts:995](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L995) 0 = YES, 1 = NO. *** ### tokenId > **tokenId**: `string` Defined in: [query.ts:997](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L997) ERC-6909 position id on the outcome-token singleton (decimal string). *** ### balance > **balance**: `string` Defined in: [query.ts:999](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L999) Raw outcome-token balance. --- # /docs/api/index/type-aliases/PortfolioTrade [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PortfolioTrade # Type Alias: PortfolioTrade > **PortfolioTrade** = `object` Defined in: [query.ts:1014](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1014) ## Properties ### id > **id**: `string` Defined in: [query.ts:1015](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1015) *** ### fillPrice > **fillPrice**: `string` Defined in: [query.ts:1016](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1016) *** ### quantity > **quantity**: `string` Defined in: [query.ts:1017](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1017) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:1018](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1018) *** ### txHash > **txHash**: `string` Defined in: [query.ts:1019](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1019) *** ### side > **side**: [`OpenOrder`](OpenOrder.md)\[`"side"`\] \| `null` Defined in: [query.ts:1021](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1021) The queried account's side on this fill (maker or taker side), if known. *** ### asMaker > **asMaker**: `boolean` Defined in: [query.ts:1023](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1023) Whether the account was the maker (resting) on this fill. *** ### counterparty > **counterparty**: `string` \| `null` Defined in: [query.ts:1025](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1025) The other party's address, if known. *** ### market > **market**: `object` Defined in: [query.ts:1026](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1026) #### marketAddress > **marketAddress**: `string` #### asset > **asset**: `string` #### quoteDecimals > **quoteDecimals**: `number` --- # /docs/api/index/type-aliases/PriceCandleResolution [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PriceCandleResolution # Type Alias: PriceCandleResolution > **PriceCandleResolution** = `"M1"` \| `"H1"` \| `"D1"` Defined in: [priceFeed/types.ts:25](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L25) Candle rollup resolutions the price-feed indexer maintains (60s / 3600s / 86400s). --- # /docs/api/index/type-aliases/PriceFeedStatus [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PriceFeedStatus # Type Alias: PriceFeedStatus > **PriceFeedStatus** = `"unwatched"` \| `"hydrating"` \| `"live"` Defined in: [priceFeed/types.ts:110](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L110) Per-asset watch state: `"unwatched"` (no active watch — live reads return null/empty), `"hydrating"` (snapshot/subscribe in progress), `"live"` (streaming; reads are current to the last pushed tick). --- # /docs/api/index/type-aliases/ProtocolFeeRecord [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ProtocolFeeRecord # Type Alias: ProtocolFeeRecord > **ProtocolFeeRecord** = `object` Defined in: [query.ts:2441](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2441) A realized protocol-fee record (mirror of the indexer `ProtocolFeeRecord` entity). Amounts are raw collateral units. ## Properties ### id > **id**: `string` Defined in: [query.ts:2442](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2442) *** ### orderId > **orderId**: `string` Defined in: [query.ts:2444](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2444) uint128 OrderId the fee was charged on (decimal string). *** ### recipient > **recipient**: `string` Defined in: [query.ts:2446](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2446) Fee recipient (lowercased). *** ### payer > **payer**: `string` \| `null` Defined in: [query.ts:2449](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2449) Order owner who paid the fee (lowercased); null on records indexed before the payer field existed. *** ### token > **token**: `string` Defined in: [query.ts:2451](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2451) Fee token (lowercased). *** ### amount > **amount**: `string` Defined in: [query.ts:2452](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2452) *** ### isTakerSide > **isTakerSide**: `boolean` Defined in: [query.ts:2454](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2454) true = taker rate (direct fill); false = maker rate (burn-a-pair leg). *** ### market > **market**: `string` \| `null` Defined in: [query.ts:2456](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2456) Market id the fee's pool belongs to (lowercased); null when unlinked. *** ### pool > **pool**: `string` Defined in: [query.ts:2457](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2457) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2458](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2458) *** ### txHash > **txHash**: `string` Defined in: [query.ts:2459](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2459) --- # /docs/api/index/type-aliases/RouterActionKind [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RouterActionKind # Type Alias: RouterActionKind > **RouterActionKind** = `"Redeem"` \| `"MintCompleteSet"` \| `"MergeCompleteSet"` Defined in: [query.ts:2002](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2002) Kinds of `RouterMinter` action the indexer records (mirror of the indexer RouterActionRecord.kind enum). --- # /docs/api/index/type-aliases/RouterActionRecord [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / RouterActionRecord # Type Alias: RouterActionRecord > **RouterActionRecord** = `object` Defined in: [query.ts:2006](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2006) One RouterMinter action for an account (mirror of the indexer `RouterActionRecord` entity). Amounts are raw collateral/outcome units. ## Properties ### id > **id**: `string` Defined in: [query.ts:2007](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2007) *** ### kind > **kind**: [`RouterActionKind`](RouterActionKind.md) Defined in: [query.ts:2009](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2009) Redeem | MintCompleteSet | MergeCompleteSet. *** ### account > **account**: `string` Defined in: [query.ts:2011](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2011) Acting wallet (lowercased). *** ### market > **market**: `string` \| `null` Defined in: [query.ts:2013](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2013) Binary market id the action targeted (lowercased bytes32); null if unlinked. *** ### amount > **amount**: `string` Defined in: [query.ts:2016](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2016) Redeem: winning tokens burned; Mint/Merge: amount of EACH outcome minted / merged (a complete set). Raw outcome-token units. *** ### payout > **payout**: `string` \| `null` Defined in: [query.ts:2018](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2018) Collateral paid out (Redeem); null on Mint/Merge. Raw units. *** ### routedVia > **routedVia**: `string` \| `null` Defined in: [query.ts:2021](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2021) Periphery entry the flow routed through (NativeMint | Permit2Mint | NativeRedeem); null on a direct module call. *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2022](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2022) *** ### txHash > **txHash**: `string` Defined in: [query.ts:2023](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2023) --- # /docs/api/index/type-aliases/SettlementFeeRecord [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SettlementFeeRecord # Type Alias: SettlementFeeRecord > **SettlementFeeRecord** = `object` Defined in: [query.ts:2482](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2482) A realized settlement-fee record (mirror of the indexer `SettlementFeeRecord` entity) — the fee skimmed from a winning payout at redeem. Amounts are raw collateral units. ## Properties ### id > **id**: `string` Defined in: [query.ts:2483](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2483) *** ### recipient > **recipient**: `string` Defined in: [query.ts:2485](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2485) Fee recipient (lowercased). *** ### amount > **amount**: `string` Defined in: [query.ts:2487](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2487) Settlement fee skimmed from the winning backing (raw). *** ### winningBacking > **winningBacking**: `string` Defined in: [query.ts:2489](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2489) Winning backing at charge time, before the fee (raw). *** ### market > **market**: `string` \| `null` Defined in: [query.ts:2491](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2491) Market id the settlement fee belongs to (lowercased); null when unlinked. *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2492](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2492) *** ### txHash > **txHash**: `string` Defined in: [query.ts:2493](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2493) --- # /docs/api/index/type-aliases/SomniaMarketsConfig [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SomniaMarketsConfig # Type Alias: SomniaMarketsConfig > **SomniaMarketsConfig** = [`ClientConfig`](../interfaces/ClientConfig.md) & `Pick`\<[`TraderConfig`](../interfaces/TraderConfig.md), `"privateKey"` \| `"account"` \| `"walletClient"`\> Defined in: [unified/exchange.ts:69](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/exchange.ts#L69) Config for [SomniaMarkets](../classes/SomniaMarkets.md): the native client config plus (optionally) a signer — authenticated methods throw without one. --- # /docs/api/index/type-aliases/SpotMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SpotMarket # Type Alias: SpotMarket > **SpotMarket** = [`BaseMarket`](BaseMarket.md) & `object` Defined in: [query.ts:149](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L149) A spot (base/quote) order-book market. ## Type Declaration ### marketType > **marketType**: `"SPOT"` ### baseToken > **baseToken**: `string` ### quoteToken > **quoteToken**: `string` ### baseSymbol > **baseSymbol**: `string` \| `null` ### quoteSymbol > **quoteSymbol**: `string` \| `null` ### baseIsNative > **baseIsNative**: `boolean` ### tickSize > **tickSize**: `string` ### lotSize > **lotSize**: `string` ### minQuantity > **minQuantity**: `string` ### markPrice > **markPrice**: `string` \| `null` ### rawMidpoint > **rawMidpoint**: `string` \| `null` Unsmoothed book midpoint feeding the mark-price EMA; null until first set. ### markPriceUpdatedAt > **markPriceUpdatedAt**: `string` \| `null` Timestamp (unix seconds) the mark price last advanced; null until first set. ### stopRegistry > **stopRegistry**: `string` \| `null` Per-pool SpotStopOrderRegistry (lowercased); null on pools without one. --- # /docs/api/index/type-aliases/SpotMarketFilter [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SpotMarketFilter # Type Alias: SpotMarketFilter > **SpotMarketFilter** = `object` Defined in: [query.ts:608](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L608) Filters for listSpotMarkets. All optional; applied server-side. ## Properties ### baseSymbol? > `optional` **baseSymbol?**: `string` Defined in: [query.ts:610](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L610) Base token symbol, e.g. `"SOMI"` | `"WBTC"`. *** ### quoteSymbol? > `optional` **quoteSymbol?**: `string` Defined in: [query.ts:612](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L612) Quote token symbol, e.g. `"USDso"`. --- # /docs/api/index/type-aliases/SpotPortfolio [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SpotPortfolio # Type Alias: SpotPortfolio > **SpotPortfolio** = `object` Defined in: [query.ts:1348](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1348) ## Properties ### account > **account**: `string` Defined in: [query.ts:1349](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1349) *** ### openOrders > **openOrders**: [`SpotPortfolioOrder`](SpotPortfolioOrder.md)[] Defined in: [query.ts:1350](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1350) *** ### stopOrders > **stopOrders**: [`SpotStopOrder`](SpotStopOrder.md)[] Defined in: [query.ts:1352](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1352) Currently-PENDING stop orders across the wallet's spot markets. *** ### trades > **trades**: [`SpotPortfolioTrade`](SpotPortfolioTrade.md)[] Defined in: [query.ts:1353](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1353) --- # /docs/api/index/type-aliases/SpotPortfolioMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SpotPortfolioMarket # Type Alias: SpotPortfolioMarket > **SpotPortfolioMarket** = `object` Defined in: [query.ts:1275](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1275) Spot market context attached to spot portfolio rows. id == poolAddress. ## Properties ### poolAddress > **poolAddress**: `string` Defined in: [query.ts:1276](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1276) *** ### baseSymbol > **baseSymbol**: `string` \| `null` Defined in: [query.ts:1277](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1277) *** ### quoteSymbol > **quoteSymbol**: `string` \| `null` Defined in: [query.ts:1278](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1278) *** ### baseToken > **baseToken**: `string` \| `null` Defined in: [query.ts:1279](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1279) *** ### quoteToken > **quoteToken**: `string` \| `null` Defined in: [query.ts:1280](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1280) *** ### baseDecimals > **baseDecimals**: `number` Defined in: [query.ts:1281](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1281) *** ### quoteDecimals > **quoteDecimals**: `number` Defined in: [query.ts:1282](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1282) *** ### baseIsNative > **baseIsNative**: `boolean` \| `null` Defined in: [query.ts:1283](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1283) *** ### tickSize > **tickSize**: `string` \| `null` Defined in: [query.ts:1284](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1284) *** ### lotSize > **lotSize**: `string` \| `null` Defined in: [query.ts:1285](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1285) *** ### minQuantity > **minQuantity**: `string` \| `null` Defined in: [query.ts:1286](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1286) *** ### lastPrice > **lastPrice**: `string` \| `null` Defined in: [query.ts:1287](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1287) *** ### markPrice > **markPrice**: `string` \| `null` Defined in: [query.ts:1288](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1288) *** ### stopRegistry > **stopRegistry**: `string` \| `null` Defined in: [query.ts:1290](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1290) Per-pool SpotStopOrderRegistry address (lowercased); null if the pool has none. --- # /docs/api/index/type-aliases/SpotPortfolioOrder [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SpotPortfolioOrder # Type Alias: SpotPortfolioOrder > **SpotPortfolioOrder** = `object` Defined in: [query.ts:1293](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1293) ## Properties ### id > **id**: `string` Defined in: [query.ts:1294](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1294) *** ### orderId > **orderId**: `string` Defined in: [query.ts:1295](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1295) *** ### isBid > **isBid**: `boolean` Defined in: [query.ts:1296](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1296) *** ### price > **price**: `string` Defined in: [query.ts:1297](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1297) *** ### quantityRemaining > **quantityRemaining**: `string` Defined in: [query.ts:1298](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1298) *** ### filledQuantity > **filledQuantity**: `string` Defined in: [query.ts:1299](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1299) *** ### fullQuantity > **fullQuantity**: `string` Defined in: [query.ts:1300](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1300) *** ### placedAtTimestamp > **placedAtTimestamp**: `string` Defined in: [query.ts:1301](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1301) *** ### market > **market**: [`SpotPortfolioMarket`](SpotPortfolioMarket.md) Defined in: [query.ts:1302](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1302) --- # /docs/api/index/type-aliases/SpotPortfolioTrade [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SpotPortfolioTrade # Type Alias: SpotPortfolioTrade > **SpotPortfolioTrade** = `object` Defined in: [query.ts:1305](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1305) ## Properties ### id > **id**: `string` Defined in: [query.ts:1306](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1306) *** ### fillPrice > **fillPrice**: `string` Defined in: [query.ts:1307](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1307) *** ### quantity > **quantity**: `string` Defined in: [query.ts:1308](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1308) *** ### quoteQuantity > **quoteQuantity**: `string` Defined in: [query.ts:1309](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1309) *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:1310](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1310) *** ### txHash > **txHash**: `string` Defined in: [query.ts:1311](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1311) *** ### isBid > **isBid**: `boolean` Defined in: [query.ts:1313](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1313) Whether the account bought the base asset on this fill. *** ### asMaker > **asMaker**: `boolean` Defined in: [query.ts:1315](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1315) Whether the account was the maker (resting) on this fill. *** ### counterparty > **counterparty**: `string` \| `null` Defined in: [query.ts:1316](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1316) *** ### market > **market**: [`SpotPortfolioMarket`](SpotPortfolioMarket.md) Defined in: [query.ts:1317](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1317) --- # /docs/api/index/type-aliases/SpotStopOrder [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SpotStopOrder # Type Alias: SpotStopOrder > **SpotStopOrder** = `object` Defined in: [query.ts:1324](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1324) A pending/historical spot stop order (mirror of the indexer StopOrder entity). ## Properties ### id > **id**: `string` Defined in: [query.ts:1326](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1326) StopOrder id (`${registry}_${orderId}`). *** ### registry > **registry**: `string` Defined in: [query.ts:1328](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1328) SpotStopOrderRegistry the order lives on (lowercased). *** ### orderId > **orderId**: `string` Defined in: [query.ts:1330](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1330) uint128 pending-order id as a decimal string (pass to trader.cancelStopOrder). *** ### isBid > **isBid**: `boolean` Defined in: [query.ts:1332](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1332) True = buy base (pay quote), false = sell base. *** ### quantity > **quantity**: `string` Defined in: [query.ts:1334](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1334) Base quantity, raw units. *** ### triggerPrice > **triggerPrice**: `string` Defined in: [query.ts:1336](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1336) Mark price that arms the trigger (raw quote per whole base). *** ### triggerOperator > **triggerOperator**: `number` Defined in: [query.ts:1338](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1338) 0 = GTE (trigger when mark ≥ trigger), 1 = LTE (mark ≤ trigger). *** ### orderType > **orderType**: `number` Defined in: [query.ts:1340](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1340) 0 = LIMIT, 1 = MARKET. *** ### status > **status**: [`StopOrderStatus`](StopOrderStatus.md) Defined in: [query.ts:1341](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1341) *** ### spotOrderId > **spotOrderId**: `string` \| `null` Defined in: [query.ts:1343](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1343) Resulting spot order id once successfully triggered, else null. *** ### createdAt > **createdAt**: `string` Defined in: [query.ts:1344](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1344) *** ### market > **market**: [`SpotPortfolioMarket`](SpotPortfolioMarket.md) Defined in: [query.ts:1345](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1345) --- # /docs/api/index/type-aliases/StopOrderStatus [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / StopOrderStatus # Type Alias: StopOrderStatus > **StopOrderStatus** = `"PENDING"` \| `"TRIGGERED"` \| `"TRIGGER_FAILED"` \| `"CANCELLED"` Defined in: [query.ts:1321](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L1321) Spot stop-order lifecycle (mirror of the indexer StopOrderStatus enum). --- # /docs/api/index/type-aliases/TailMode [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / TailMode # Type Alias: TailMode > **TailMode** = `"init"` \| `"tailing"` Defined in: [store.ts:19](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L19) --- # /docs/api/index/type-aliases/UnifiedMarketType [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedMarketType # Type Alias: UnifiedMarketType > **UnifiedMarketType** = `"spot"` \| `"swap"` \| `"binary"` \| `"categorical"` Defined in: [unified/structs.ts:13](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L13) --- # /docs/api/index/type-aliases/UnifiedOHLCV [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedOHLCV # Type Alias: UnifiedOHLCV > **UnifiedOHLCV** = \[`number`, `number`, `number`, `number`, `number`, `number`\] Defined in: [unified/structs.ts:86](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L86) An OHLCV row: [timestampMs, open, high, low, close, volume(base)]. --- # /docs/api/index/type-aliases/UnifiedOrderStatus [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / UnifiedOrderStatus # Type Alias: UnifiedOrderStatus > **UnifiedOrderStatus** = `"open"` \| `"closed"` \| `"canceled"` \| `"expired"` Defined in: [unified/structs.ts:57](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L57) --- # /docs/api/index/type-aliases/VaultPayoutFallback [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / VaultPayoutFallback # Type Alias: VaultPayoutFallback > **VaultPayoutFallback** = `object` Defined in: [query.ts:2604](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2604) A vault-credit fallback record (mirror of the indexer `VaultPayoutFallback` entity) — an append-only history of payouts that could not be delivered to the wallet and were credited to the owner's ERC20Vault balance instead. This is the HISTORY layer; for the live claimable amount read [getVaultBalance](../functions/getVaultBalance.md) in reads.ts. Amounts are raw token units. ## Properties ### id > **id**: `string` Defined in: [query.ts:2605](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2605) *** ### owner > **owner**: `string` Defined in: [query.ts:2607](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2607) Credited owner (lowercased). *** ### token > **token**: `string` Defined in: [query.ts:2609](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2609) Credited token (lowercased). *** ### amount > **amount**: `string` Defined in: [query.ts:2610](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2610) *** ### market > **market**: `string` Defined in: [query.ts:2612](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2612) Market id the fallback was emitted for (lowercased). *** ### timestamp > **timestamp**: `string` Defined in: [query.ts:2613](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2613) *** ### txHash > **txHash**: `string` Defined in: [query.ts:2614](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2614) --- # /docs/api/index/type-aliases/WatchStatus [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / WatchStatus # Type Alias: WatchStatus > **WatchStatus** = `"unwatched"` \| `"hydrating"` \| `"live"` Defined in: [liveTail.ts:44](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/liveTail.ts#L44) Per-market watch state: `"unwatched"` (no active watch — `getLive*` reads return empty), `"hydrating"` (watch registered; snapshot/backfill/reconnect in progress), `"live"` (streaming; reads are current to the last block). --- # /docs/api/index/variables/ANSWER_TYPE [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ANSWER\_TYPE # Variable: ANSWER\_TYPE > `const` **ANSWER\_TYPE**: `object` Defined in: [oracleHub.ts:44](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L44) `AnswerType` enum values (OracleTypes.sol). ## Type Declaration ### Numeric > `readonly` **Numeric**: `0` = `0` ### Discrete > `readonly` **Discrete**: `1` = `1` --- # /docs/api/index/variables/CANDLE_INTERVALS [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / CANDLE\_INTERVALS # Variable: CANDLE\_INTERVALS > `const` **CANDLE\_INTERVALS**: readonly \[`60`, `300`, `900`, `3600`, `14400`, `86400`\] Defined in: [query.ts:2915](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/query.ts#L2915) Candle bucket sizes (seconds): 1m, 5m, 15m, 1h, 4h, 1d — the intervals the indexer rolls up. Keep in lockstep with `indexer/src/intervals.ts` (CANDLE_INTERVALS) so getCandles is only ever asked for a bucket the indexer actually materializes. --- # /docs/api/index/variables/DECIMALS [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / DECIMALS # Variable: DECIMALS > `const` **DECIMALS**: `6` = `6` Defined in: [store.ts:145](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L145) Fallback outcome-token / collateral decimals (tUSDC 6dp demo stack). Real math uses the per-market baseDecimals/quoteDecimals off the Market row. --- # /docs/api/index/variables/DEFAULT_FEES [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / DEFAULT\_FEES # Variable: DEFAULT\_FEES > `const` **DEFAULT\_FEES**: [`FixedFees`](../interfaces/FixedFees.md) Defined in: [config.ts:95](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L95) SDK default for [ClientConfig.fees](../interfaces/ClientConfig.md#fees): 60 gwei ceiling (~10× the observed Somnia base fee of 6 gwei), zero tip — instant BFT inclusion needs no bribe. --- # /docs/api/index/variables/HUB_MIN_FREE_BALANCE_WEI [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / HUB\_MIN\_FREE\_BALANCE\_WEI # Variable: HUB\_MIN\_FREE\_BALANCE\_WEI > `const` **HUB\_MIN\_FREE\_BALANCE\_WEI**: `bigint` Defined in: [preflight.ts:47](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L47) The minimum native balance (wei) the OracleHub should hold to fund its reactivity bond — 32 STT, mirrors the deploy-runbook's funding floor. In Oracle v2 the hub holds Σ operator earmarks + accrued credit + its own reactivity-bond float in one balance; a rough floor check is the hub's total balance clearing this floor (a precise free-float split is no longer separately tracked on-chain). --- # /docs/api/index/variables/MARGIN_STATUS [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MARGIN\_STATUS # Variable: MARGIN\_STATUS > `const` **MARGIN\_STATUS**: readonly [`MarginStatus`](../type-aliases/MarginStatus.md)[] Defined in: [reads.ts:208](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/reads.ts#L208) Ordered so index == on-chain enum value (0 Healthy … 3 CloseOut). --- # /docs/api/index/variables/MARKET_TYPE_BINARY_V1 [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MARKET\_TYPE\_BINARY\_V1 # Variable: MARKET\_TYPE\_BINARY\_V1 > `const` **MARKET\_TYPE\_BINARY\_V1**: `Hex` = `"0x06c65d9f"` Defined in: [operatorReads.ts:16](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/operatorReads.ts#L16) `MarketTypeIds.BINARY_V1` (`bytes4(keccak256("BINARY_V1"))`) — the only market type registered today. A venue is pinned to one type forever at `createVenue`. --- # /docs/api/index/variables/MARKET_TYPE_PLUGINS [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MARKET\_TYPE\_PLUGINS # Variable: MARKET\_TYPE\_PLUGINS > `const` **MARKET\_TYPE\_PLUGINS**: `Readonly`\<`Record`\<`string`, [`MarketTypePlugin`](../interfaces/MarketTypePlugin.md)\>\> Defined in: [marketTypes/index.ts:15](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/index.ts#L15) Every registered market-type plugin, keyed by its bytes4 `marketType` (lowercased). Frozen — the registry is a static seam, not mutated at runtime. --- # /docs/api/index/variables/MIN_SERIES_INTERVAL_SEC [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / MIN\_SERIES\_INTERVAL\_SEC # Variable: MIN\_SERIES\_INTERVAL\_SEC > `const` **MIN\_SERIES\_INTERVAL\_SEC**: `60` = `60` Defined in: [preflight.ts:50](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L50) The minimum roll interval the module enforces (`InvalidSeriesConfig` below). --- # /docs/api/index/variables/ORDER_KIND_SIDE [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ORDER\_KIND\_SIDE # Variable: ORDER\_KIND\_SIDE > `const` **ORDER\_KIND\_SIDE**: readonly [`BinarySide`](../type-aliases/BinarySide.md)[] Defined in: [store.ts:154](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/store.ts#L154) Index → BinarySide for the on-chain `OrderKind` enum carried by the `BinaryOrderPlaced` event (settlement-extraction v2): 0 BUY_YES, 1 SELL_YES, 2 BUY_NO, 3 SELL_NO. This is the ONLY authoritative side-attribution source — v2 no longer encodes the side in `userData` (now opaque MM bookkeeping). --- # /docs/api/index/variables/ORDER_TYPE [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ORDER\_TYPE # Variable: ORDER\_TYPE > `const` **ORDER\_TYPE**: `object` Defined in: [trade.ts:216](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/trade.ts#L216) OrderBook OrderType — shared by binary `placeOrder` and spot `placeSpotOrder` (both ride the same OrderBook core): 0 NormalOrder (limit), 1 FillOrKill, 2 ImmediateOrCancel (market), 3 PostOnly. Pass to either call's `orderType`. ## Type Declaration ### LIMIT > `readonly` **LIMIT**: `0` = `0` ### FILL\_OR\_KILL > `readonly` **FILL\_OR\_KILL**: `1` = `1` ### MARKET > `readonly` **MARKET**: `2` = `2` ### POST\_ONLY > `readonly` **POST\_ONLY**: `3` = `3` --- # /docs/api/index/variables/PRICE_FEED_DECIMALS [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PRICE\_FEED\_DECIMALS # Variable: PRICE\_FEED\_DECIMALS > `const` **PRICE\_FEED\_DECIMALS**: `18` = `18` Defined in: [priceFeed/types.ts:22](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L22) Price scale of the on-chain EMA oracle: prices are 1e18-scaled integers. --- # /docs/api/index/variables/PRICE_RESOLUTION_SECONDS [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / PRICE\_RESOLUTION\_SECONDS # Variable: PRICE\_RESOLUTION\_SECONDS > `const` **PRICE\_RESOLUTION\_SECONDS**: `Record`\<[`PriceCandleResolution`](../type-aliases/PriceCandleResolution.md), `number`\> Defined in: [priceFeed/types.ts:28](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/priceFeed/types.ts#L28) Seconds per [PriceCandleResolution](../type-aliases/PriceCandleResolution.md). --- # /docs/api/index/variables/QUESTION_SOURCE_TYPE [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / QUESTION\_SOURCE\_TYPE # Variable: QUESTION\_SOURCE\_TYPE > `const` **QUESTION\_SOURCE\_TYPE**: `object` Defined in: [oracleHub.ts:41](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/oracleHub.ts#L41) `QuestionSourceType` enum values (OracleTypes.sol). Only all-JSON definitions participate in the hub's content-addressed dedup. ## Type Declaration ### Website > `readonly` **Website**: `0` = `0` ### JSON > `readonly` **JSON**: `1` = `1` ### Contract > `readonly` **Contract**: `2` = `2` --- # /docs/api/index/variables/SOMNIA_TESTNET_PRICE_FEED [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / SOMNIA\_TESTNET\_PRICE\_FEED # Variable: SOMNIA\_TESTNET\_PRICE\_FEED > `const` **SOMNIA\_TESTNET\_PRICE\_FEED**: [`PriceFeedConfig`](../interfaces/PriceFeedConfig.md) Defined in: [config.ts:80](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/config.ts#L80) The known Somnia-testnet price feed (dev) — one endpoint serving every asset. Wire it up with `priceFeed: SOMNIA_TESTNET_PRICE_FEED`. --- # /docs/api/index/variables/TIMEFRAMES [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / TIMEFRAMES # Variable: TIMEFRAMES > `const` **TIMEFRAMES**: `Record`\<`string`, `number`\> Defined in: [unified/structs.ts:138](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/unified/structs.ts#L138) Timeframe string → seconds, matching the indexer's candle intervals. --- # /docs/api/index/variables/ZERO_ADDRESS [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / ZERO\_ADDRESS # Variable: ZERO\_ADDRESS > `const` **ZERO\_ADDRESS**: `"0x0000000000000000000000000000000000000000"` = `"0x0000000000000000000000000000000000000000"` Defined in: [preflight.ts:33](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/preflight.ts#L33) --- # /docs/api/index/variables/binaryMarketTypePlugin [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / binaryMarketTypePlugin # Variable: binaryMarketTypePlugin > `const` **binaryMarketTypePlugin**: [`MarketTypePlugin`](../interfaces/MarketTypePlugin.md)\<[`BinaryVenueParams`](../interfaces/BinaryVenueParams.md)\> Defined in: [marketTypes/binary.ts:46](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/marketTypes/binary.ts#L46) BINARY_V1 plugin. `encodeVenueFeeParams` / `decodeVenueFeeParams` delegate to the existing operatorReads helpers (the on-chain-backed encoder + the local decoder); `decode` is pure so it needs no client. --- # /docs/api/index/variables/binaryModuleReadAbi [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / binaryModuleReadAbi # Variable: binaryModuleReadAbi > `const` **binaryModuleReadAbi**: readonly \[\{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}\] Defined in: [moduleAbi.ts:34](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/moduleAbi.ts#L34) --- # /docs/api/index/variables/binaryModuleWriteAbi [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / binaryModuleWriteAbi # Variable: binaryModuleWriteAbi > `const` **binaryModuleWriteAbi**: readonly \[\{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}\] Defined in: [moduleAbi.ts:10](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/moduleAbi.ts#L10) --- # /docs/api/index/variables/binarySettlementAbi [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / binarySettlementAbi # Variable: binarySettlementAbi > `const` **binarySettlementAbi**: readonly \[\{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}\] Defined in: [readsAbi.ts:46](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/readsAbi.ts#L46) --- # /docs/api/index/variables/erc6909Abi [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / erc6909Abi # Variable: erc6909Abi > `const` **erc6909Abi**: readonly \[\{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}\] Defined in: [readsAbi.ts:92](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/readsAbi.ts#L92) --- # /docs/api/index/variables/oracleHubAbi [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / oracleHubAbi # Variable: oracleHubAbi > `const` **oracleHubAbi**: readonly \[\{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}\] Defined in: [machineryAbi.ts:25](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/machineryAbi.ts#L25) --- # /docs/api/index/variables/oracleHubEventsAbi [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [index](../README.md) / oracleHubEventsAbi # Variable: oracleHubEventsAbi > `const` **oracleHubEventsAbi**: readonly \[\{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}, \{ \}\] Defined in: [machineryAbi.ts:89](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/machineryAbi.ts#L89) --- # /docs/api/react [**@somnia-chain/markets-sdk**](../README.md) *** [@somnia-chain/markets-sdk](../README.md) / react # react ## Interfaces - [IndexerQueryState](interfaces/IndexerQueryState.md) ## Functions - [SomniaMarketsProvider](functions/SomniaMarketsProvider.md) - [useSomniaMarketsClient](functions/useSomniaMarketsClient.md) - [useWatchMarket](functions/useWatchMarket.md) - [useWatchUser](functions/useWatchUser.md) - [useLiveStatus](functions/useLiveStatus.md) - [useIsTailing](functions/useIsTailing.md) - [useLiveFills](functions/useLiveFills.md) - [useLiveUserFills](functions/useLiveUserFills.md) - [useLiveMarketByPool](functions/useLiveMarketByPool.md) - [useLiveMarketByAddress](functions/useLiveMarketByAddress.md) - [useLiveUserOrders](functions/useLiveUserOrders.md) - [useLiveBinaryOrderBook](functions/useLiveBinaryOrderBook.md) - [useLiveBinaryOrderBookByMarket](functions/useLiveBinaryOrderBookByMarket.md) - [useLiveSpotOrderBook](functions/useLiveSpotOrderBook.md) - [useIndexerQuery](functions/useIndexerQuery.md) - [usePortfolio](functions/usePortfolio.md) - [useMarkets](functions/useMarkets.md) - [useCandles](functions/useCandles.md) - [useMarketFees](functions/useMarketFees.md) - [useOperators](functions/useOperators.md) - [useMarketCreators](functions/useMarketCreators.md) - [useOracleAdapters](functions/useOracleAdapters.md) - [useLiveMarkets](functions/useLiveMarkets.md) - [useWatchPrice](functions/useWatchPrice.md) - [useLivePrice](functions/useLivePrice.md) - [useLivePriceTicks](functions/useLivePriceTicks.md) --- # /docs/api/react/functions/SomniaMarketsProvider [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / SomniaMarketsProvider # Function: SomniaMarketsProvider() > **SomniaMarketsProvider**(`__namedParameters`): `ReactNode` Defined in: [hooks.ts:52](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L52) Provide the SDK's engine tier to the hooks below. Build one exchange (`new SomniaMarkets(...)`) and pass its `.client` here near the root of your app. ## Parameters ### \_\_namedParameters #### client [`SomniaMarketsClient`](../../index/interfaces/SomniaMarketsClient.md) #### children `ReactNode` ## Returns `ReactNode` --- # /docs/api/react/functions/useCandles [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useCandles # Function: useCandles() > **useCandles**(`pool`, `intervalSeconds`, `opts?`): [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`Candle`](../../index/type-aliases/Candle.md)[]\> Defined in: [hooks.ts:327](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L327) OHLCV candles for one pool + interval (indexer read), oldest first. ## Parameters ### pool `string` \| `undefined` ### intervalSeconds `number` ### opts? #### limit? `number` #### from? `number` #### to? `number` ## Returns [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`Candle`](../../index/type-aliases/Candle.md)[]\> --- # /docs/api/react/functions/useIndexerQuery [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useIndexerQuery # Function: useIndexerQuery() > **useIndexerQuery**\<`T`\>(`fn`, `deps`): [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<`T`\> Defined in: [hooks.ts:269](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L269) Run an async indexer read against the context client, re-running when `deps` change. Errors are captured (not thrown) so a failed indexer read renders as `error`, not a crash. Stale responses (a slow request that resolves after a newer one) are discarded. ```ts const { data: markets } = useIndexerQuery((c) => c.listBinaryMarkets({ limit: 20 }), []); ``` ## Type Parameters ### T `T` ## Parameters ### fn (`client`) => `Promise`\<`T`\> ### deps readonly `unknown`[] ## Returns [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<`T`\> --- # /docs/api/react/functions/useIsTailing [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useIsTailing # Function: useIsTailing() > **useIsTailing**(): `boolean` Defined in: [hooks.ts:121](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L121) True when at least one watch is live (vs idle / hydrating / reconnecting). ## Returns `boolean` --- # /docs/api/react/functions/useLiveBinaryOrderBook [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLiveBinaryOrderBook # Function: useLiveBinaryOrderBook() > **useLiveBinaryOrderBook**(`pool`, `depth?`): [`BinaryOrderBook`](../../index/interfaces/BinaryOrderBook.md) Defined in: [hooks.ts:200](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L200) The locally-materialized resting book of a binary pool (4-sided), updating the moment an order event lands — no round-trips, no refetch interval. Watches the pool while mounted. ## Parameters ### pool `string` \| `undefined` ### depth? `number` = `10` ## Returns [`BinaryOrderBook`](../../index/interfaces/BinaryOrderBook.md) --- # /docs/api/react/functions/useLiveBinaryOrderBookByMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLiveBinaryOrderBookByMarket # Function: useLiveBinaryOrderBookByMarket() > **useLiveBinaryOrderBookByMarket**(`marketId`, `depth?`): [`BinaryOrderBook`](../../index/interfaces/BinaryOrderBook.md) Defined in: [hooks.ts:217](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L217) The locally-materialized resting book of a binary MARKET, resolved by its `marketId` (4-sided) — mirrors [useLiveBinaryOrderBook](useLiveBinaryOrderBook.md) but keyed on the market rather than the pool. Because a BinaryPool is recycled across markets, this returns an EMPTY book once the given market is no longer the pool's current binding, so a stale page never shows the successor market's orders. Watches the market's pool while mounted (once the market is known to the live store). ## Parameters ### marketId `string` \| `undefined` ### depth? `number` = `10` ## Returns [`BinaryOrderBook`](../../index/interfaces/BinaryOrderBook.md) --- # /docs/api/react/functions/useLiveFills [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLiveFills # Function: useLiveFills() > **useLiveFills**(`pool`, `limit?`): [`LiveFill`](../../index/interfaces/LiveFill.md)[] Defined in: [hooks.ts:129](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L129) Live trade tape for one pool. Watches the pool while mounted. ## Parameters ### pool `string` \| `undefined` ### limit? `number` = `40` ## Returns [`LiveFill`](../../index/interfaces/LiveFill.md)[] --- # /docs/api/react/functions/useLiveMarketByAddress [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLiveMarketByAddress # Function: useLiveMarketByAddress() > **useLiveMarketByAddress**(`addr`): [`BinaryMarket`](../../index/type-aliases/BinaryMarket.md) \| `null` Defined in: [hooks.ts:170](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L170) One binary market by its BinaryMarket contract address. NOTE: watches are pool-keyed, so this hook does not open one — it reads whatever a pool-keyed hook (or explicit watchMarket) on the same page has hydrated. ## Parameters ### addr `string` \| `undefined` ## Returns [`BinaryMarket`](../../index/type-aliases/BinaryMarket.md) \| `null` --- # /docs/api/react/functions/useLiveMarketByPool [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLiveMarketByPool # Function: useLiveMarketByPool() > **useLiveMarketByPool**(`pool`): [`Market`](../../index/type-aliases/Market.md) \| `null` Defined in: [hooks.ts:157](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L157) One market by pool address (either kind). Watches the pool while mounted. ## Parameters ### pool `string` \| `undefined` ## Returns [`Market`](../../index/type-aliases/Market.md) \| `null` --- # /docs/api/react/functions/useLiveMarkets [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLiveMarkets # Function: useLiveMarkets() > **useLiveMarkets**(): [`Market`](../../index/type-aliases/Market.md)[] Defined in: [hooks.ts:384](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L384) ## Returns [`Market`](../../index/type-aliases/Market.md)[] --- # /docs/api/react/functions/useLivePrice [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLivePrice # Function: useLivePrice() > **useLivePrice**(`asset`): [`LivePrice`](../../index/interfaces/LivePrice.md) \| `null` Defined in: [hooks.ts:415](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L415) The live current price of one asset, updating the moment a new tick is pushed — no round-trips, no refetch interval. Watches the feed while mounted. ## Parameters ### asset `string` \| `undefined` ## Returns [`LivePrice`](../../index/interfaces/LivePrice.md) \| `null` --- # /docs/api/react/functions/useLivePriceTicks [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLivePriceTicks # Function: useLivePriceTicks() > **useLivePriceTicks**(`asset`, `limit?`): [`PricePoint`](../../index/interfaces/PricePoint.md)[] Defined in: [hooks.ts:427](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L427) The live tick tape of one asset, newest first. Watches the feed while mounted. ## Parameters ### asset `string` \| `undefined` ### limit? `number` = `100` ## Returns [`PricePoint`](../../index/interfaces/PricePoint.md)[] --- # /docs/api/react/functions/useLiveSpotOrderBook [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLiveSpotOrderBook # Function: useLiveSpotOrderBook() > **useLiveSpotOrderBook**(`pool`, `depth?`): [`SpotOrderBook`](../../index/interfaces/SpotOrderBook.md) Defined in: [hooks.ts:234](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L234) The locally-materialized resting book of a spot pool, updating the moment an order event lands — no round-trips, no refetch interval. Watches the pool while mounted. ## Parameters ### pool `string` \| `undefined` ### depth? `number` = `12` ## Returns [`SpotOrderBook`](../../index/interfaces/SpotOrderBook.md) --- # /docs/api/react/functions/useLiveStatus [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLiveStatus # Function: useLiveStatus() > **useLiveStatus**(): [`TailStatus`](../../index/interfaces/TailStatus.md) Defined in: [hooks.ts:115](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L115) ## Returns [`TailStatus`](../../index/interfaces/TailStatus.md) --- # /docs/api/react/functions/useLiveUserFills [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLiveUserFills # Function: useLiveUserFills() > **useLiveUserFills**(`pool`, `user`, `limit?`): [`LiveFill`](../../index/interfaces/LiveFill.md)[] Defined in: [hooks.ts:142](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L142) Fills `user` participated in. Watches `pool` while mounted when given; with `pool === null` it reads across whatever markets other hooks are watching (pair with useWatchUser for history). ## Parameters ### pool `string` \| `null` ### user `string` \| `undefined` ### limit? `number` = `50` ## Returns [`LiveFill`](../../index/interfaces/LiveFill.md)[] --- # /docs/api/react/functions/useLiveUserOrders [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useLiveUserOrders # Function: useLiveUserOrders() > **useLiveUserOrders**(`pool`, `user`, `limit?`): [`LiveOrder`](../../index/interfaces/LiveOrder.md)[] Defined in: [hooks.ts:180](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L180) `user`'s orders on one pool. Watches the pool while mounted. ## Parameters ### pool `string` \| `undefined` ### user `string` \| `undefined` ### limit? `number` = `100` ## Returns [`LiveOrder`](../../index/interfaces/LiveOrder.md)[] --- # /docs/api/react/functions/useMarketCreators [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useMarketCreators # Function: useMarketCreators() > **useMarketCreators**(`opts?`): [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`IndexedMarketCreator`](../../index/type-aliases/IndexedMarketCreator.md)[]\> Defined in: [hooks.ts:359](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L359) MarketCreator directory (indexer read) — the operator machinery list. Pass `owner`/`operatorId`/`venueId` to filter, page with `limit`/`offset`. Each row carries its nested `series`. ## Parameters ### opts? [`MarketCreatorFilter`](../../index/type-aliases/MarketCreatorFilter.md) & `object` ## Returns [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`IndexedMarketCreator`](../../index/type-aliases/IndexedMarketCreator.md)[]\> --- # /docs/api/react/functions/useMarketFees [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useMarketFees # Function: useMarketFees() > **useMarketFees**(`marketId`): [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`MarketFees`](../../index/type-aliases/MarketFees.md) \| `null` \| `undefined`\> Defined in: [hooks.ts:339](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L339) A market's frozen fee config + running total (indexer read), or null. ## Parameters ### marketId `string` \| `undefined` ## Returns [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`MarketFees`](../../index/type-aliases/MarketFees.md) \| `null` \| `undefined`\> --- # /docs/api/react/functions/useMarkets [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useMarkets # Function: useMarkets() > **useMarkets**(`opts?`): [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`Market`](../../index/type-aliases/Market.md)[]\> Defined in: [hooks.ts:318](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L318) Markets, newest first (indexer read). Pass `marketType` to narrow. ## Parameters ### opts? #### marketType? [`MarketType`](../../index/type-aliases/MarketType.md) #### limit? `number` #### offset? `number` ## Returns [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`Market`](../../index/type-aliases/Market.md)[]\> --- # /docs/api/react/functions/useOperators [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useOperators # Function: useOperators() > **useOperators**(`opts?`): [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`IndexedOperator`](../../index/type-aliases/IndexedOperator.md)[]\> Defined in: [hooks.ts:347](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L347) Operator directory (indexer read). Pass `owner`/`enabled` to filter, page with `limit`/`offset`. ## Parameters ### opts? [`OperatorFilter`](../../index/type-aliases/OperatorFilter.md) & `object` ## Returns [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`IndexedOperator`](../../index/type-aliases/IndexedOperator.md)[]\> --- # /docs/api/react/functions/useOracleAdapters [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useOracleAdapters # Function: useOracleAdapters() > **useOracleAdapters**(`opts?`): [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`IndexedOracleAdapter`](../../index/type-aliases/IndexedOracleAdapter.md)[]\> Defined in: [hooks.ts:370](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L370) Oracle-adapter directory (indexer read). Pass `owner`/`approved` to filter, page with `limit`/`offset`. ## Parameters ### opts? #### owner? `string` #### approved? `boolean` #### limit? `number` #### offset? `number` ## Returns [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`IndexedOracleAdapter`](../../index/type-aliases/IndexedOracleAdapter.md)[]\> --- # /docs/api/react/functions/usePortfolio [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / usePortfolio # Function: usePortfolio() > **usePortfolio**(`account`, `opts?`): [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`Portfolio`](../../index/type-aliases/Portfolio.md) \| `undefined`\> Defined in: [hooks.ts:307](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L307) A wallet's binary portfolio (indexer read). Re-runs when `account`/`opts` change. ## Parameters ### account `string` \| `undefined` ### opts? [`PortfolioOptions`](../../index/type-aliases/PortfolioOptions.md) ## Returns [`IndexerQueryState`](../interfaces/IndexerQueryState.md)\<[`Portfolio`](../../index/type-aliases/Portfolio.md) \| `undefined`\> --- # /docs/api/react/functions/useSomniaMarketsClient [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useSomniaMarketsClient # Function: useSomniaMarketsClient() > **useSomniaMarketsClient**(): [`SomniaMarketsClient`](../../index/interfaces/SomniaMarketsClient.md) Defined in: [hooks.ts:63](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L63) The SomniaMarketsClient from the nearest provider. Throws if there isn't one. ## Returns [`SomniaMarketsClient`](../../index/interfaces/SomniaMarketsClient.md) --- # /docs/api/react/functions/useWatchMarket [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useWatchMarket # Function: useWatchMarket() > **useWatchMarket**(`pool`): [`WatchStatus`](../../index/type-aliases/WatchStatus.md) Defined in: [hooks.ts:98](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L98) Watch one market while mounted (ref-counted; shared with the data hooks) and report its watch state — render loading UI off `"hydrating"`. ## Parameters ### pool `string` \| `undefined` ## Returns [`WatchStatus`](../../index/type-aliases/WatchStatus.md) --- # /docs/api/react/functions/useWatchPrice [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useWatchPrice # Function: useWatchPrice() > **useWatchPrice**(`asset`): [`PriceFeedStatus`](../../index/type-aliases/PriceFeedStatus.md) Defined in: [hooks.ts:402](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L402) Watch one asset's price feed (e.g. `"BTC"`, `"ETH"`) while mounted (ref-counted; shared with the price data hooks) and report its watch state. ## Parameters ### asset `string` \| `undefined` ## Returns [`PriceFeedStatus`](../../index/type-aliases/PriceFeedStatus.md) --- # /docs/api/react/functions/useWatchUser [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / useWatchUser # Function: useWatchUser() > **useWatchUser**(`user`): `void` Defined in: [hooks.ts:110](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L110) Hydrate + hold `user`'s order/fill history while mounted, so the user-scoped live reads have depth predating the market watches. ## Parameters ### user `string` \| `null` \| `undefined` ## Returns `void` --- # /docs/api/react/interfaces/IndexerQueryState [**@somnia-chain/markets-sdk**](../../README.md) *** [@somnia-chain/markets-sdk](../../README.md) / [react](../README.md) / IndexerQueryState # Interface: IndexerQueryState\ Defined in: [hooks.ts:251](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L251) The state one [useIndexerQuery](../functions/useIndexerQuery.md) exposes. ## Type Parameters ### T `T` ## Properties ### data > **data**: `T` \| `undefined` Defined in: [hooks.ts:252](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L252) *** ### loading > **loading**: `boolean` Defined in: [hooks.ts:253](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L253) *** ### error > **error**: `Error` \| `null` Defined in: [hooks.ts:254](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L254) *** ### refetch > **refetch**: () => `void` Defined in: [hooks.ts:256](https://github.com/somnia-chain/somnia-markets/blob/main/packages/sdk/src/hooks.ts#L256) Re-run the query imperatively (e.g. a manual refresh button). #### Returns `void`