{s}omniamarkets

@somnia-chain/markets-sdk


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

Function: pnlEventsFor()

pnlEventsFor(account, fills, routerActions): PnLEvent[]

Defined in: derivedReads.ts:224

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).

Parameters

account

string

fills

FillRow[]

routerActions

RouterActionRecord[]

Returns

PnLEvent[]