@somnia-chain/markets-sdk


@somnia-chain/markets-sdk / index / BinaryMarket

Type Alias: BinaryMarket

BinaryMarket = BaseMarket & object

Defined in: packages/sdk/src/markets.ts:237

A binary (YES/NO outcome) order-book market — the binary CLOB.

Type Declaration

marketType

marketType: "BINARY"

Discriminator (narrowed).

marketId

marketId: Hex

bytes32 marketId (== id).

marketAddress

marketAddress: Address

The BinaryMarket clone contract's address (lowercased).

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

The NO position id — see BinaryMarket.yesTokenId.

collateral

collateral: Address

Collateral ERC-20 backing the market (lowercased; per-venue).

asset

asset: string

Underlying asset symbol (e.g. "BTC").

question

question: string

Display question text. May differ from BinaryMarket.oracleQuestion.

status

status: BinaryMarketStatus

Lifecycle status (aliased from the indexer's clobStatus). Derived from lifecycle EVENTS only — the timestamp-implicit Listed→Trading→Settling transitions emit none, so derive the live trading state from tradingStart/expiry between events rather than trusting this alone.

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

Strike the question resolves against (raw, in the oracle's price scale).

mode

mode: BinaryResolutionMode

How this market's threshold is established — the distinction every consumer of a binary market eventually needs, served rather than sniffed.

  • "reference" — an up/down market. strike is 0 because the threshold IS another question's answer ("ETH closes at or above its opening price"), reached through MarketReferenceLinkOracleAnswer. Read it with getOpeningPrices / getMarketResolution().openingAnswer.
  • "fixed" — the threshold was set at creation ("at or above 77036.65") and is strike itself. There is no reference question, so an opening price does not exist and never will.

Derived from strike alone (see binaryResolutionMode), so it costs no extra query. Before it existed consumers inferred the mode from a LOOKUP MISS — "no opening answer, so it must be fixed-strike" — which conflates "no reference question" with "the reference question has not been answered yet". That reads as working code right up until an oracle is slow.

tradingStart

tradingStart: string

Timestamp (unix seconds) trading opens.

expiry

expiry: string

Timestamp (unix seconds) trading ends and the outcome is decided.

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; on a void, the vector the frozen void policy produced: uniform under UNIFORM, and [p, D−p] at the closing YES price on a CLOB_SNAPSHOT void that captured a two-sided close. Raw Σ == payoutDenominator). This vector, not BinaryMarket.voidPolicy, is what a void actually pays: every snapshot fallback stores the uniform vector. 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: Hex | null

Tx hash the market was created in; null on markets indexed before this field.

creator?

optional creator?: Address | 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

True once the market voided (payout per the frozen void policy; payoutNumerators carries the actual vector).

voidPolicy?

optional voidPolicy?: number | null

Void payout policy frozen at creation (from BinaryMarketsModule.MarketCreated): 0 UNIFORM (both sides redeem 1/N on a void), 2 CLOB_SNAPSHOT (a void pays [p, D-p] at the market's closing YES price; falls back to uniform when no two-sided close exists). null on pre-policy markets or tail-discovered rows.

backing

backing: string

Collateral backing complete sets on the LIVE pool (raw). Reads 0 once finalized — prefer BinaryMarket.netBacking after finalize.

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?: Hex | 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 (60=1m, 300=5m, 900=15m, 3600=1h, 14400=4h, 86400=24h) — APPROXIMATE, see BinaryMarketFilter.intervalSec. 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.

interval?

optional interval?: string | null

Human timeframe label for this series — "1m" / "5m" / "15m" / "1h" / "4h" / "24h" — DERIVED by the SDK from BinaryMarket.intervalSec (falling back to expiry − tradingStart) and snapped to its CADENCE_LADDER_SEC rung, so a roll that opened late reads as the cadence it belongs to rather than as its own (56"1m", not "56s"). A window matching no rung keeps its own value. Served ready-to-render so consumers stop re-deriving it; see marketIntervalLabel. null on SPOT / PERP or when no cadence is determinable.

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?: Hex | 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).