@somnia-chain/markets-sdk


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

Interface: BinaryPositionPnL

Defined in: packages/sdk/src/derivedReads.ts:301

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 book-clamped last price while trading (see markYesPrice), or to the settlement payout once resolved.

Properties

balanceYes

balanceYes: bigint

Defined in: packages/sdk/src/derivedReads.ts:303

Current YES outcome-token balance (raw).


balanceNo

balanceNo: bigint

Defined in: packages/sdk/src/derivedReads.ts:305

Current NO outcome-token balance (raw).


costBasis

costBasis: bigint

Defined in: packages/sdk/src/derivedReads.ts:307

Total remaining cost basis across both outcomes (raw collateral).


avgCost

avgCost: bigint

Defined in: packages/sdk/src/derivedReads.ts:312

Blended average cost per whole outcome token held (raw collateral per token). 0n when nothing is held.


markValue

markValue: bigint | null

Defined in: packages/sdk/src/derivedReads.ts:318

Mark value of the current balances (raw collateral). null when the market has no price to mark against — see BinaryOutcomePositionPnL.markPrice.


unrealizedPnl

unrealizedPnl: bigint | null

Defined in: packages/sdk/src/derivedReads.ts:323

markValue − costBasis (raw, signed). null when the market has no price to mark against — see BinaryOutcomePositionPnL.markPrice.


realizedPnl

realizedPnl: bigint

Defined in: packages/sdk/src/derivedReads.ts:328

Realized PnL from sells (proceeds − avg cost of tokens sold), raw signed. Best-effort over indexed order-book sell fills (see accounting note).


outcomes

outcomes: object

Defined in: packages/sdk/src/derivedReads.ts:338

The same position split into its YES and NO books — see BinaryOutcomePositionPnL for why every field above is unusable to a wallet holding both outcomes.

Always present, both legs, even when one holds nothing (a zero-balance leg can still carry realizedPnl from earlier sells). Filter on balance > 0n to list only open legs.

yes

yes: BinaryOutcomePositionPnL

no

no: BinaryOutcomePositionPnL