{s}omniamarkets

@somnia-chain/markets-sdk


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

Function: computePositionPnL()

computePositionPnL(events, balances, market, oneCollateral): BinaryPositionPnL

Defined in: derivedReads.ts:264

Fold a PnLEvent stream (oldest-first) + current balances into a BinaryPositionPnL, avg-cost basis, RAW units. oneCollateral = 10^quoteDecimals. Prices arrive in YES terms; a NO event is re-expressed to NO terms (oneCollateral − yesPrice) here so the two books stay separate.

Parameters

events

PnLEvent[]

balances

balanceYes

bigint

balanceNo

bigint

market

Pick<BinaryMarket, "quoteDecimals" | "lastPrice" | "winningOutcome" | "voided">

oneCollateral

bigint

Returns

BinaryPositionPnL