Pool open positions
getPoolOpenPositions(config, parameters) reads the open book and deduplicates account-balance reads before applying shared quote calculations.
import { getPoolOpenPositions, type Config } from "@symmio/trading-core";
export function positions(config: Config, symbolId: number, priceUsd: number) {
return getPoolOpenPositions(config, { chainId: 42161, symbolId, priceUsd });
}Parameters and result
GetPoolOpenPositionsParameters requires symbolId (null/undefined means no book). chainId, orderDirection and priceUsd are optional. It reads at most ten 100-row pages, then consumers filter/page the entries.
PoolOpenPositions / GetPoolOpenPositionsReturnType returns entries and gaps. Each entry retains PoolQuote fields and adds remainingQuantity, entryPrice, positionValueUsd, leverageMultiplier, upnlUsd, priceChangePercent, liquidationPrice and openedAt.
priceChangePercent is the unleveraged directional price move, preserving the pool-table meaning. It is not leveraged return on margin. Quote PnL/leverage and account liquidation reuse the SDK’s existing primitives. calculateLiquidationPrice accepts optional pendingLockedCVA/pendingLockedLF (default 0n), so pending collateral reservations reduce available margin.
An explicitly reported leverage wins. When it is absent, the pool table retains its legacy integer inference: use 100 × initialLf / initialMargin when LF is known and positive; otherwise use the shared leverage primitive for settled/requested price candidates and choose the candidate closest to an integer before rounding. Missing margin inputs produce null. openedAt uses the first positive open, send, or quote timestamp.
Unknown marks produce null PnL and position value. entryValueUsd separately values the remaining quantity at its entry price. By default, a missing balance, incomplete book or mixed-side account produces null liquidationPrice. This pool-level estimate assumes the account’s positions are isolated to this market; it is not a general cross-market account risk calculation.
An explicit zero mark is a known price: remaining position value is zero and directional PnL is still calculated. A partial quote without a valid long/short side keeps PnL, directional percentage and both liquidation estimates null; its non-directional value can still be calculated.
Set allowQuoteLockEstimate: true on the calculator, read or hook to retain the historical quote-lock fallback. liquidationSource identifies "account", "quote-lock", or null. A valid live-account result always wins. The fallback uses initial party-A maintenance margin per original token quantity; if absent, it uses entry price and inferred leverage. Long prices are clamped at zero. It never constructs a fictitious account balance and is not an account-wide liquidation guarantee.
Projection and queries
calculatePoolOpenPositions(input: CalculatePoolOpenPositionsParameters) accepts PoolQuote[] and normalized AccountBalanceInfo by lowercase account address, plus price, completeness and gaps. getPoolOpenPositionsQueryOptions(config, options: GetPoolOpenPositionsOptions) and getPoolOpenPositionsQueryKey supply the core query contract.
The pure calculator also accepts partial normalized quote snapshots and preserves their input fields. Missing calculation inputs produce null metrics. Network reads continue returning complete normalized quotes. Compute the full quote set before consumer pagination so live account calculations include all known positions.
Units and ownership
Token, collateral and LP amounts are bigint at 18 decimals. USD and percentage projections are unformatted numbers. Unknown values are null. The SDK does not contact third-party token-data providers; pass an external price when available. Keep formatting, filtering and sorting in the consumer.
The corresponding React hook composes existing SDK queries; it does not cache the aggregate separately. Core query factories are available for non-React consumers. Do not mount both a composed core query and its React hook for the same screen.