@somnia-chain/markets-sdk


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

Function: binaryFillsFromPortfolio()

binaryFillsFromPortfolio(trades, decimals?): BinaryPnlFill[]

Defined in: packages/sdk/src/units.ts:366

Derive BinaryPnlFills from one market's slice of a portfolio's trades (as from getPortfolio). The portfolio view already resolves the account's own side per fill, so this only re-expresses the YES-terms fillPrice into the traded outcome (a NO trade prices at 1 − yesPrice) and skips fills whose side the indexer hasn't bridged yet.

Gotchas

The portfolio reads cut trades two ways, and BOTH have to be checked before a total derived from them means anything — this function reports no warning of its own.

They cap the page (default 50) and page newest-first: tradesTruncated says whether that cap was hit. They also WINDOW the leg — by default to the last seven days — and tradesSince is the bound that was applied. A wallet whose fills predate the window comes back with tradesTruncated: false and an incomplete trades, so the flag alone is not enough. For a whole-history PnL ask for the history first: since: 0 (with a tradesLimit to match), then check tradesTruncated.

Parameters

trades

PortfolioTrade[]

decimals?

number = Store.DECIMALS

Returns

BinaryPnlFill[]