@somnia-chain/markets-sdk / index / SomniaMarketsClient
Interface: SomniaMarketsClient
Defined in: somniaMarketsClient.ts:131
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:
- Live store (
getLive*, synchronous): zero round-trips, updates the moment an event lands on-chain. Requires a watch (watchMarket / watchMarkets) covering the market you read. - Chain (
getBinaryOrderBook,getMarketOnchain, …): oneeth_callround-trip, current to head. Works without any watch. - Indexer (
listMarkets,getPortfolio, …): history and aggregates; lags the chain slightly. Works without any watch or the socket.
Properties
config
readonlyconfig:ClientConfig
Defined in: somniaMarketsClient.ts:133
The config this client was built with.
publicClient
readonlypublicClient:object
Defined in: somniaMarketsClient.ts:137
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>
Defined in: somniaMarketsClient.ts:163
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>
watchMarkets()
watchMarkets(
opts?):Promise<WatchHandle>
Defined in: somniaMarketsClient.ts:175
Watch every market the indexer currently knows — the whole-protocol tail for list views and multi-market bots. Prefer 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>
watchUser()
watchUser(
user):Promise<WatchHandle>
Defined in: somniaMarketsClient.ts:186
Hydrate one account's order/fill history (one indexer fetch) so getLiveUserFills / 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 / 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>
getWatchStatus()
getWatchStatus(
pool):WatchStatus
Defined in: somniaMarketsClient.ts:194
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
stopLive()
stopLive():
void
Defined in: somniaMarketsClient.ts:198
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
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
Defined in: somniaMarketsClient.ts:214
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.
Returns
isTailing()
isTailing():
boolean
Defined in: somniaMarketsClient.ts:217
True once at least one watch is live (mode === "tailing").
Returns
boolean
getLiveMarkets()
getLiveMarkets():
Market[]
Defined in: somniaMarketsClient.ts:223
Every market the store knows (spot + binary, as the discriminated Market union) — markets hydrated by any watch, past or present (market rows are kept as metadata after a watch is released). Synchronous, memoized.
Returns
Market[]
getLiveMarketByPool()
getLiveMarketByPool(
pool):Market|null
Defined in: somniaMarketsClient.ts:226
One market by its pool address (either kind), or null if unknown.
Parameters
pool
string
Returns
Market | null
getLiveMarketByAddress()
getLiveMarketByAddress(
marketAddress):BinaryMarket|null
Defined in: somniaMarketsClient.ts:230
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 | null
getLiveFills()
getLiveFills(
pool,opts?):LiveFill[]
Defined in: somniaMarketsClient.ts:238
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[]
getLiveUserFills()
getLiveUserFills(
pool,user,opts?):LiveFill[]
Defined in: somniaMarketsClient.ts:246
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[]
getLiveUserOrders()
getLiveUserOrders(
pool,user,opts?):LiveOrder[]
Defined in: somniaMarketsClient.ts:256
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 plus
everything witnessed live on watched markets.
Parameters
pool
string
user
string
opts?
limit?
number
Max rows (default 100).
Returns
getLiveBinaryOrderBook()
getLiveBinaryOrderBook(
pool,opts?):BinaryOrderBook
Defined in: somniaMarketsClient.ts:266
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, 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
getLiveBinaryOrderBookByMarket()
getLiveBinaryOrderBookByMarket(
marketId,opts?):BinaryOrderBook
Defined in: somniaMarketsClient.ts:281
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 when you hold a marketId (not a live pool).
Parameters
marketId
string
opts?
depth?
number
Price levels per side (default 10).
Returns
getLiveSpotOrderBook()
getLiveSpotOrderBook(
pool,opts?):SpotOrderBook
Defined in: somniaMarketsClient.ts:289
The locally-materialized resting book of a spot pool (bids/asks,
best price first) — the zero-round-trip mirror of getSpotOrderBook.
Parameters
pool
string
opts?
depth?
number
Price levels per side (default 12).
Returns
quoteBinaryOrder()
quoteBinaryOrder(
params):BinaryOrderQuote
Defined in: somniaMarketsClient.ts:309
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
quantity
bigint
Order size in raw outcome-token units.
depth?
number
Book levels to walk per side (default 10).
Returns
getMarketStats24h()
getMarketStats24h(
target):Promise<MarketStats24h>
Defined in: somniaMarketsClient.ts:323
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>
getBinaryPositionPnL()
getBinaryPositionPnL(
account,marketId):Promise<BinaryPositionPnL>
Defined in: somniaMarketsClient.ts:334
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 for the accounting assumptions. One fan-out of
indexer reads.
Parameters
account
string
marketId
string
Returns
Promise<BinaryPositionPnL>
getClaimable()
getClaimable(
account):Promise<ClaimablePosition[]>
Defined in: somniaMarketsClient.ts:344
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[]>
watchPrice()
watchPrice(
asset):Promise<PriceWatchHandle>
Defined in: somniaMarketsClient.ts:362
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: 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>
watchPrices()
watchPrices(
assets):Promise<PriceWatchHandle>
Defined in: somniaMarketsClient.ts:367
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 calls.
Parameters
assets
string[]
Returns
Promise<PriceWatchHandle>
getPriceStatus()
getPriceStatus(
asset):PriceFeedStatus
Defined in: somniaMarketsClient.ts:370
Per-asset price-watch state: "unwatched", "hydrating", or "live".
Parameters
asset
string
Returns
subscribePrices()
subscribePrices(
listener): () =>void
Defined in: somniaMarketsClient.ts:380
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
(prices are a separate store/service).
Parameters
listener
() => void
Returns
An unsubscribe function.
() => void
getLivePrice()
getLivePrice(
asset):LivePrice|null
Defined in: somniaMarketsClient.ts:384
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 | null
getLivePrices()
getLivePrices(
assets): (LivePrice|null)[]
Defined in: somniaMarketsClient.ts:388
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 | null)[]
getLivePriceTicks()
getLivePriceTicks(
asset,opts?):PricePoint[]
Defined in: somniaMarketsClient.ts:392
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
getLivePriceFeedInfo()
getLivePriceFeedInfo(
asset):PriceFeedInfo|null
Defined in: somniaMarketsClient.ts:396
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.
Parameters
asset
string
Returns
PriceFeedInfo | null
fetchPriceFeedInfo()
fetchPriceFeedInfo(
asset):Promise<PriceFeedInfo>
Defined in: somniaMarketsClient.ts:399
One-shot feed metadata + current price (one HTTP round-trip; no watch needed).
Parameters
asset
string
Returns
Promise<PriceFeedInfo>
fetchPrice()
fetchPrice(
asset):Promise<LivePrice|null>
Defined in: somniaMarketsClient.ts:403
One-shot current price (one HTTP round-trip), or null if the feed has no observations yet.
Parameters
asset
string
Returns
Promise<LivePrice | null>
fetchPrices()
fetchPrices(
assets?):Promise<LivePrice[]>
Defined in: somniaMarketsClient.ts:408
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[]>
listPriceFeeds()
listPriceFeeds():
Promise<PriceFeedInfo[]>
Defined in: somniaMarketsClient.ts:412
One-shot feed catalog — metadata + current price for every tracked asset (discovery). One HTTP round-trip; no watch needed.
Returns
Promise<PriceFeedInfo[]>
fetchPriceHistory()
fetchPriceHistory(
asset,opts?):Promise<PricePoint[]>
Defined in: somniaMarketsClient.ts:416
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[]>
fetchPriceCandles()
fetchPriceCandles(
asset,resolution,opts?):Promise<PriceCandle[]>
Defined in: somniaMarketsClient.ts:423
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
opts?
limit?
number
from?
number
to?
number
Returns
Promise<PriceCandle[]>
listMarkets()
listMarkets(
opts?):Promise<Market[]>
Defined in: somniaMarketsClient.ts:441
List markets, newest first, as the discriminated
Market = SpotMarket | BinaryMarket union.
Parameters
opts?
marketType?
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[]>
countMarkets()
countMarkets(
opts?):Promise<number>
Defined in: somniaMarketsClient.ts:445
Server-side COUNT of markets (optionally one type) for pagination totals.
Needs the privileged _aggregate role (server-only), like countBinaryMarkets.
Parameters
opts?
marketType?
Returns
Promise<number>
getMarket()
getMarket(
id):Promise<Market|null>
Defined in: somniaMarketsClient.ts:449
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 | null>
listBinaryMarkets()
listBinaryMarkets(
opts?):Promise<BinaryMarket[]>
Defined in: somniaMarketsClient.ts:452
listMarkets pre-narrowed to binary markets.
Parameters
opts?
BinaryMarketFilter & object
Returns
Promise<BinaryMarket[]>
listLiveBinaryMarkets()
listLiveBinaryMarkets(
filter?):Promise<BinaryMarket[]>
Defined in: somniaMarketsClient.ts:458
Currently-live binary markets (expiry > now), soonest-to-expire first.
Call with no argument for all live markets, or pass a
LiveBinaryMarketsFilter to narrow by operatorId / venueId /
asset / intervalSec / status (e.g. { venueId: "0x4d41494e" }).
Parameters
filter?
Returns
Promise<BinaryMarket[]>
listBinaryVenueIds()
listBinaryVenueIds():
Promise<object[]>
Defined in: somniaMarketsClient.ts:463
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
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
Server-side COUNT of binary markets matching a filter, split by lifecycle
phase — a total without fetching rows (Hasura _aggregate).
Parameters
opts
BinaryMarketFilter & object
Returns
Promise<number>
listPastBinaryMarkets()
listPastBinaryMarkets(
opts?):Promise<BinaryMarket[]>
Defined in: somniaMarketsClient.ts:477
Past binary markets (expiry ≤ now), most-recently-expired first,
paginated with limit + offset.
Parameters
opts?
Returns
Promise<BinaryMarket[]>
getBinaryMarket()
getBinaryMarket(
id):Promise<BinaryMarket|null>
Defined in: somniaMarketsClient.ts:481
One binary market by bytes32 marketId, or null (also null if the id resolves to a spot market).
Parameters
id
string
Returns
Promise<BinaryMarket | null>
getBinaryMarketByAddress()
getBinaryMarketByAddress(
marketAddress):Promise<BinaryMarket|null>
Defined in: somniaMarketsClient.ts:485
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 | null>
getMarketFees()
getMarketFees(
id):Promise<MarketFees|null>
Defined in: somniaMarketsClient.ts:488
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 | null>
listSpotMarkets()
listSpotMarkets(
opts?):Promise<SpotMarket[]>
Defined in: somniaMarketsClient.ts:492
listMarkets pre-narrowed to spot markets. Pass a
SpotMarketFilter (+ limit) to narrow by base/quote symbol.
Parameters
opts?
SpotMarketFilter & object
Returns
Promise<SpotMarket[]>
getSpotMarket()
getSpotMarket(
id):Promise<SpotMarket|null>
Defined in: somniaMarketsClient.ts:495
One spot market by pool address, or null (also null if not spot).
Parameters
id
string
Returns
Promise<SpotMarket | null>
getMarketStatusHistory()
getMarketStatusHistory(
marketId):Promise<MarketStatusUpdate[]>
Defined in: somniaMarketsClient.ts:499
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[]>
listPerpMarkets()
listPerpMarkets(
opts?):Promise<PerpMarket[]>
Defined in: somniaMarketsClient.ts:503
listMarkets pre-narrowed to perp markets. Pass a
PerpMarketFilter (+ limit) to narrow by base/quote symbol.
Parameters
opts?
PerpMarketFilter & object
Returns
Promise<PerpMarket[]>
getPerpMarket()
getPerpMarket(
id):Promise<PerpMarket|null>
Defined in: somniaMarketsClient.ts:507
One perp market by pool address, or null (also null if the id resolves to another market kind).
Parameters
id
string
Returns
Promise<PerpMarket | null>
getCandles()
getCandles(
poolAddress,intervalSeconds,opts?):Promise<Candle[]>
Defined in: somniaMarketsClient.ts:517
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[]>
getFills()
getFills(
pool,opts?):Promise<FillRow[]>
Defined in: somniaMarketsClient.ts:525
Recent fills for one pool (either kind), newest first — the one-shot cousin of getLiveFills for when the tail isn't running.
Parameters
pool
string
opts?
Returns
Promise<FillRow[]>
getUserFills()
getUserFills(
account,opts?):Promise<FillRow[]>
Defined in: somniaMarketsClient.ts:530
Fills a user participated in (maker OR taker), newest first — the one-shot
indexer counterpart to getLiveUserFills. Optionally scope to one
pool and/or a since/until window.
Parameters
account
string
opts?
FillsOptions & object
Returns
Promise<FillRow[]>
getOpenOrders()
getOpenOrders(
owner,opts?):Promise<OpenOrder[]>
Defined in: somniaMarketsClient.ts:539
owner's currently-OPEN orders, newest first. Pass OrdersOptions
(minus status — always "Open" here) to scope by pool/side and page.
NOTE: this lags the chain — for a trading loop prefer
getLiveUserOrders (or track the orderIds your own
placeOrder calls return). For non-open history use getOrders.
Parameters
owner
string
opts?
Omit<OrdersOptions, "status">
Returns
Promise<OpenOrder[]>
getOrders()
getOrders(
owner,opts?):Promise<OrderRow[]>
Defined in: somniaMarketsClient.ts:545
owner's orders across ALL statuses (Open/Filled/Cancelled/Expired/Closed),
newest first — the order-history counterpart to getOpenOrders. Each
row carries its lifecycle status + fill progress. Filter by
status/side/pool and page via OrdersOptions.
Parameters
owner
string
opts?
Returns
Promise<OrderRow[]>
getOutcomeBalances()
getOutcomeBalances(
account,marketAddress):Promise<OutcomeBalances>
Defined in: somniaMarketsClient.ts:550
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 instead.
Parameters
account
string
marketAddress
string
Returns
Promise<OutcomeBalances>
getPortfolio()
getPortfolio(
account,opts?):Promise<Portfolio>
Defined in: somniaMarketsClient.ts:555
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 to page orders/trades or window trades.
Parameters
account
string
opts?
Returns
Promise<Portfolio>
getSpotPortfolio()
getSpotPortfolio(
account,opts?):Promise<SpotPortfolio>
Defined in: somniaMarketsClient.ts:560
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 to page.
Parameters
account
string
opts?
Returns
Promise<SpotPortfolio>
getSpotStopOrders()
getSpotStopOrders(
account,opts?):Promise<SpotStopOrder[]>
Defined in: somniaMarketsClient.ts:565
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?
limit?
number
Returns
Promise<SpotStopOrder[]>
getPerpPortfolio()
getPerpPortfolio(
account,opts?):Promise<PerpPortfolio>
Defined in: somniaMarketsClient.ts:574
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 / getMarginAccount. Pass PortfolioOptions to page.
Parameters
account
string
opts?
Returns
Promise<PerpPortfolio>
getSyncStatus()
getSyncStatus(
chainId):Promise<IndexerSyncStatus|null>
Defined in: somniaMarketsClient.ts:578
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 | null>
getMarketByPool()
getMarketByPool(
pool):Promise<Market|null>
Defined in: somniaMarketsClient.ts:582
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 | null>
countOrders()
countOrders(
owner,opts?):Promise<number>
Defined in: somniaMarketsClient.ts:587
Server-side COUNT of owner's orders matching an OrdersOptions
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?
Returns
Promise<number>
countUserFills()
countUserFills(
account,opts?):Promise<number>
Defined in: somniaMarketsClient.ts:591
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 & object
Returns
Promise<number>
getRouterActions()
getRouterActions(
account,opts?):Promise<RouterActionRecord[]>
Defined in: somniaMarketsClient.ts:595
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?
limit?
number
offset?
number
Returns
Promise<RouterActionRecord[]>
getMarketResolution()
getMarketResolution(
marketId):Promise<{events:MarketResolutionEvent[];reference:MarketReferenceLink|null;closingAnswer:OracleAnswer|null;openingAnswer:OracleAnswer|null;oracleAnswer:OracleAnswer|null; }>
Defined in: somniaMarketsClient.ts:606
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[]; reference: MarketReferenceLink | null; closingAnswer: OracleAnswer | null; openingAnswer: OracleAnswer | null; oracleAnswer: OracleAnswer | null; }>
getOpeningPrices()
getOpeningPrices(
marketIds):Promise<Record<string,string|null>>
Defined in: somniaMarketsClient.ts:620
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[]>
Defined in: somniaMarketsClient.ts:625
Realized protocol-fee records, newest first — filter by recipient /
market / pool / payer, paginate. The per-fill stream behind
getMarketFees's running total.
Parameters
opts?
recipient?
string
market?
string
pool?
string
payer?
string
limit?
number
offset?
number
Returns
Promise<ProtocolFeeRecord[]>
listBuilderFees()
listBuilderFees(
opts?):Promise<BuilderFeeRecord[]>
Defined in: somniaMarketsClient.ts:631
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[]>
listSettlementFees()
listSettlementFees(
opts?):Promise<SettlementFeeRecord[]>
Defined in: somniaMarketsClient.ts:637
Realized settlement-fee records, newest first — filter by market /
recipient, paginate.
Parameters
opts?
market?
string
recipient?
string
limit?
number
offset?
number
Returns
Promise<SettlementFeeRecord[]>
listBuilderApprovals()
listBuilderApprovals(
opts?):Promise<BuilderApproval[]>
Defined in: somniaMarketsClient.ts:642
Builder-approval directory, newest-updated first — filter by user and/or
builder, paginate. The directory complement to the on-chain point read
getBuilderApproval.
Parameters
opts?
user?
string
builder?
string
limit?
number
offset?
number
Returns
Promise<BuilderApproval[]>
getVaultPayoutFallbacks()
getVaultPayoutFallbacks(
owner,opts?):Promise<VaultPayoutFallback[]>
Defined in: somniaMarketsClient.ts:647
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.
Parameters
owner
string
opts?
token?
string
limit?
number
offset?
number
Returns
Promise<VaultPayoutFallback[]>
getFundingPayments()
getFundingPayments(
account,opts?):Promise<FundingPayment[]>
Defined in: somniaMarketsClient.ts:651
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[]>
getMarginEvents()
getMarginEvents(
account,opts?):Promise<MarginEvent[]>
Defined in: somniaMarketsClient.ts:655
An account's margin-account movement history (deposits/withdraws/locks), newest first — paginated.
Parameters
account
string
opts?
limit?
number
offset?
number
Returns
Promise<MarginEvent[]>
getLiquidations()
getLiquidations(
opts?):Promise<LiquidationEvent[]>
Defined in: somniaMarketsClient.ts:658
Liquidation events, newest first — filter by account and/or pool, paginate.
Parameters
opts?
account?
string
pool?
string
limit?
number
offset?
number
Returns
Promise<LiquidationEvent[]>
getFundingRateHistory()
getFundingRateHistory(
pool,opts?):Promise<FundingRateUpdate[]>
Defined in: somniaMarketsClient.ts:661
A perp pool's funding-rate history, newest first — paginated.
Parameters
pool
string
opts?
limit?
number
offset?
number
Returns
Promise<FundingRateUpdate[]>
getOpenInterestHistory()
getOpenInterestHistory(
pool,opts?):Promise<OpenInterestSnapshot[]>
Defined in: somniaMarketsClient.ts:664
A perp pool's open-interest history, newest first — paginated.
Parameters
pool
string
opts?
limit?
number
offset?
number
Returns
Promise<OpenInterestSnapshot[]>
getBinaryOrderBook()
getBinaryOrderBook(
pool,opts?):Promise<BinaryOrderBook>
Defined in: somniaMarketsClient.ts:680
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.
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>
getSpotOrderBook()
getSpotOrderBook(
pool,opts?):Promise<SpotOrderBook>
Defined in: somniaMarketsClient.ts:685
Read a spot OR perp pool's resting book from the contract (both ride the shared OrderBook base). Live variant: getLiveSpotOrderBook.
Parameters
pool
`0x${string}`
opts?
depth?
number
Levels per side (default 12).
Returns
Promise<SpotOrderBook>
getPerpState()
getPerpState(
pool):Promise<PerpStateOnchain>
Defined in: somniaMarketsClient.ts:690
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>
getPerpPosition()
getPerpPosition(
marginBank,account,pool):Promise<PerpPosition>
Defined in: somniaMarketsClient.ts:694
An account's position in one perp pool, from the MarginBank (signed size:
positive = long). marginBank comes off the PerpMarket row.
Parameters
marginBank
`0x${string}`
account
`0x${string}`
pool
`0x${string}`
Returns
Promise<PerpPosition>
getMarginAccount()
getMarginAccount(
marginBank,account):Promise<MarginAccount>
Defined in: somniaMarketsClient.ts:699
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>
getAccountHealth()
getAccountHealth(
marginBank,account):Promise<AccountHealth>
Defined in: somniaMarketsClient.ts:703
An account's cross-margin health alone (equity vs IM/MM/CM + the derived status) — a lighter read than getMarginAccount when only health matters.
Parameters
marginBank
`0x${string}`
account
`0x${string}`
Returns
Promise<AccountHealth>
getLiquidationPrice()
getLiquidationPrice(
marginBank,pool,account):Promise<bigint|null>
Defined in: somniaMarketsClient.ts:708
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
LIVE claimable balance an owner can withdraw from a pool's internal
ERC20Vault for token, raw units — the value behind the append-only
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>
Defined in: somniaMarketsClient.ts:724
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>
getPoolCreator()
getPoolCreator(
pool):Promise<`0x${string}`>
Defined in: somniaMarketsClient.ts:730
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
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[]>
Defined in: somniaMarketsClient.ts:743
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[]>
getPool()
getPool(
address):Promise<IndexedPool|null>
Defined in: somniaMarketsClient.ts:748
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 | null>
getErc20Balance()
getErc20Balance(
token,account):Promise<bigint>
Defined in: somniaMarketsClient.ts:752
ERC-20 balanceOf(account), raw units. For outcome positions use
getOutcomeBalance (ERC-6909), not this.
Parameters
token
`0x${string}`
account
`0x${string}`
Returns
Promise<bigint>
getErc20Metadata()
getErc20Metadata(
token):Promise<Erc20Metadata>
Defined in: somniaMarketsClient.ts:756
ERC-20 symbol/name/decimals in one fan-out — label a token the
indexer hasn't denormalized.
Parameters
token
`0x${string}`
Returns
Promise<Erc20Metadata>
getErc20Allowance()
getErc20Allowance(
token,owner,spender):Promise<bigint>
Defined in: somniaMarketsClient.ts:760
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
ERC-6909 balanceOf(account, id) on the outcome-token singleton, raw
units. outcomeToken is the singleton (from 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
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[]
account
`0x${string}`
Returns
Promise<bigint[]>
getStopOrderSomiPayment()
getStopOrderSomiPayment(
registry):Promise<bigint>
Defined in: somniaMarketsClient.ts:777
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
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
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
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>
Defined in: somniaMarketsClient.ts:793
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>
getNativeBalance()
getNativeBalance(
address):Promise<bigint>
Defined in: somniaMarketsClient.ts:796
Native (SOMI/STT) balance, raw wei.
Parameters
address
`0x${string}`
Returns
Promise<bigint>
getHeadBlock()
getHeadBlock():
Promise<number>
Defined in: somniaMarketsClient.ts:799
Latest block number as the RPC sees it.
Returns
Promise<number>
getSystemInfo()
getSystemInfo():
Promise<SystemInfo>
Defined in: somniaMarketsClient.ts:803
Deployed protocol state (impl pointers, oracle, collateral) for ops
dashboards. Needs config.addresses.
Returns
Promise<SystemInfo>
listOperators()
listOperators(
opts?):Promise<IndexedOperator[]>
Defined in: somniaMarketsClient.ts:812
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 & object
Returns
Promise<IndexedOperator[]>
countOperators()
countOperators(
opts?):Promise<number>
Defined in: somniaMarketsClient.ts:816
Server-side COUNT of operators matching a filter (for directory
pagination). Needs the privileged _aggregate role (server-only), like
countBinaryMarkets.
Parameters
opts?
Returns
Promise<number>
getOperator()
getOperator(
operatorId):Promise<IndexedOperator|null>
Defined in: somniaMarketsClient.ts:818
One operator by id, or null if never registered. Indexer read.
Parameters
operatorId
number
Returns
Promise<IndexedOperator | null>
listVenues()
listVenues(
opts?):Promise<IndexedVenue[]>
Defined in: somniaMarketsClient.ts:821
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[]>
countVenues()
countVenues(
opts?):Promise<number>
Defined in: somniaMarketsClient.ts:830
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|null>
Defined in: somniaMarketsClient.ts:832
One venue by its opaque bytes32 id, or null. Indexer read.
Parameters
venueId
string
Returns
Promise<IndexedVenue | null>
encodeBinaryVenueFeeParams()
encodeBinaryVenueFeeParams(
vp):Promise<`0x${string}`>
Defined in: somniaMarketsClient.ts:837
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
Returns
Promise<`0x${string}`>
getMaxVenueFeeBps()
getMaxVenueFeeBps():
Promise<number>
Defined in: somniaMarketsClient.ts:840
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[]>
Defined in: somniaMarketsClient.ts:852
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 & object
Returns
Promise<IndexedMarketCreator[]>
getMarketCreator()
getMarketCreator(
creator):Promise<IndexedMarketCreator|null>
Defined in: somniaMarketsClient.ts:854
One MarketCreator by address (with its series), or null. Indexer read.
Parameters
creator
string
Returns
Promise<IndexedMarketCreator | null>
listOracleAdapters()
listOracleAdapters(
opts?):Promise<IndexedOracleAdapter[]>
Defined in: somniaMarketsClient.ts:859
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[]>
getOracleAdapter()
getOracleAdapter(
adapter):Promise<IndexedOracleAdapter|null>
Defined in: somniaMarketsClient.ts:861
One oracle adapter by address, or null. Indexer read.
Parameters
adapter
string
Returns
Promise<IndexedOracleAdapter | null>
listSeries()
listSeries(
opts?):Promise<IndexedSeries[]>
Defined in: somniaMarketsClient.ts:863
List series, creation-order, optionally scoped to one creator. Indexer read.
Parameters
opts?
creator?
string
limit?
number
offset?
number
Returns
Promise<IndexedSeries[]>
getSchedulingCost()
getSchedulingCost(
def):Promise<bigint>
Defined in: somniaMarketsClient.ts:877
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
Returns
Promise<bigint>
earmarkedOf()
earmarkedOf(
operatorId):Promise<bigint>
Defined in: somniaMarketsClient.ts:880
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
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
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
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
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
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
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
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
Returns
Promise<bigint>
getOracleQuestion()
getOracleQuestion(
oracleQuestionId):Promise<OracleQuestionRecord|null>
Defined in: somniaMarketsClient.ts:908
One hub-scheduled oracle question (dedup key, scheduler, bind count) by its oracleQuestionId, or null. Indexer read.
Parameters
oracleQuestionId
string
Returns
Promise<OracleQuestionRecord | null>
listOracleQuestions()
listOracleQuestions(
opts?):Promise<OracleQuestionRecord[]>
Defined in: somniaMarketsClient.ts:911
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[]>
getOperatorHubAccount()
getOperatorHubAccount(
operatorId):Promise<OperatorHubAccountRecord|null>
Defined in: somniaMarketsClient.ts:916
One operator's hub account (earmarked / credit / outstanding) by operatorId, or null. Indexer read.
Parameters
operatorId
string | number
Returns
Promise<OperatorHubAccountRecord | null>
listOperatorHubAccounts()
listOperatorHubAccounts(
opts?):Promise<OperatorHubAccountRecord[]>
Defined in: somniaMarketsClient.ts:919
Operator hub-account records, most-recently-updated first, paginated. Indexer read.
Parameters
opts?
limit?
number
offset?
number
Returns
Promise<OperatorHubAccountRecord[]>
listOracleBinds()
listOracleBinds(
opts?):Promise<OracleBindRecord[]>
Defined in: somniaMarketsClient.ts:925
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[]>
listOracleCallbacks()
listOracleCallbacks(
opts?):Promise<OracleCallbackRecord[]>
Defined in: somniaMarketsClient.ts:931
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[]>
createTrader()
createTrader(
traderConfig):Trader
Defined in: somniaMarketsClient.ts:947
Build a Trader 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
Returns
createOperatorAdmin()
createOperatorAdmin(
config):OperatorAdmin
Defined in: somniaMarketsClient.ts:954
Build an OperatorAdmin bound to a signer — registers/updates operators and creates/updates venues on MarketsCore. Same signer doctrine as createTrader (privateKey/local account, or a browser walletClient).
Parameters
config
Returns
createOracleHubAdmin()
createOracleHubAdmin(
config):OracleHubAdmin
Defined in: somniaMarketsClient.ts:965
Build an OracleHubAdmin 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. Needs config.addresses.oracleHub.
Parameters
config
Returns
createGovernanceAdmin()
createGovernanceAdmin(
config):GovernanceAdmin
Defined in: somniaMarketsClient.ts:973
Build a GovernanceAdmin 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.
Parameters
config
Returns
createMarketCreatorAdmin()
createMarketCreatorAdmin(
config):MarketCreatorAdmin
Defined in: somniaMarketsClient.ts:980
Build a MarketCreatorAdmin 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.