@somnia-chain/markets-sdk / index / pnlEventsFor
Function: pnlEventsFor()
pnlEventsFor(
account,fills,routerActions):PnLEvent[]
Defined in: packages/sdk/src/derivedReads.ts:372
Derive the PnLEvent stream for account from raw FillRows
(order-book fills) + RouterActionRecords (mint/merge complete sets),
merged into ONE oldest-first timeline by timestamp (so the avg-cost roll sees
mints and fills in the order they happened). Fills whose side isn't bridged
yet are skipped (can't attribute an outcome). Mint/merge use the record's
amount (each outcome's set size). Redeem actions are ignored (they settle
the position at payout, they don't change cost basis of a still-open book).
SCOPE IS THE CALLER'S JOB: no market filter is applied here, so pass ONE
market's fills, selected by FillRow.market (never by pool — see there).
Parameters
account
string
fills
FillRow[]
routerActions
Returns
PnLEvent[]