@somnia-chain/markets-sdk


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

Interface: BinaryPositionPnL

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

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:229

Current YES outcome-token balance (raw).


balanceNo

balanceNo: bigint

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

Current NO outcome-token balance (raw).


costBasis

costBasis: bigint

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

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


avgCost

avgCost: bigint

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

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


markValue

markValue: bigint

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

Mark value of the current balances (raw collateral).


unrealizedPnl

unrealizedPnl: bigint

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

markValue − costBasis (raw, signed).


realizedPnl

realizedPnl: bigint

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

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