@somnia-chain/markets-sdk


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

Function: averageEntryPrice()

averageEntryPrice(input): bigint | null

Defined in: packages/sdk/src/derivedReads.ts:849

Average entry price for a YES/NO position, in the outcome's OWN terms (raw), derived from the wallet's BUY fills on that outcome. A binary fill's fillPrice is always YES-terms, so the NO leg enters at the complement. Only buys are averaged — this is the cost basis an unrealized-PnL display compares the live mark against. Returns null when there are no matching buys (show a dash, not a bogus 0 that reads as +100%). NOTE: complete-set mints don't appear in fills; positions built by mint+sell carry a fills-only basis here, same as computePositionPnL without router actions.

Parameters

input

trades

readonly EntryTrade[]

outcomeIndex

number

0 = YES, 1 = NO.

oneShare

bigint

10 ** decimals — one whole outcome share in raw terms.

Returns

bigint | null