@somnia-chain/markets-sdk / index / computeBinaryPnl
Function: computeBinaryPnl()
computeBinaryPnl(
fills,balances,market):BinaryPnl
Defined in: units.ts:124
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); 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
balances
market
Pick<BinaryMarket, "quoteDecimals" | "lastPrice" | "winningOutcome" | "voided">