getPoolTradeHistory
Read a pool’s realized trade history from the analytics subgraph.
import { getPoolTradeHistory } from "@symmio/trading-core";
const { rows } = await getPoolTradeHistory(config, { symbolId: 1, first: 25 });Pool-wide, not account-scoped: no partyA filter, so these are every trader’s closes on the market. The
account-scoped counterpart is getQuoteHistory, which filters by the accounts you
pass. Reaching for the wrong one gives an empty table or someone else’s trades.
One row per close event, not per quote
Rows come from the immutable quoteEvents collection with each event’s frozen metadata snapshot overlaid. A quote closed across three partial closes therefore yields three rows, each showing the size and price of that close rather than the quote’s final state.
Use the event metric fields for history totals; full-quote fields remain repeated context, not values to sum across events.
Parameters
chainIdnumberoptionalTarget chain id. Defaults to the config’s defaultChainId.
symbolIdnumber | null | undefinedrequiredThe pool’s solver market id. Absent means the pool is not tradable, so the action returns an empty result without
issuing a request and the query factory stays enabled: false.
closeTypeQuoteCloseTypeoptionalClose-type filter. Defaults to QuoteCloseType.All.
firstnumberoptionalPage size. Defaults to 50.
skipnumberoptionalPage offset. Defaults to 0.
orderDirection"asc" | "desc"optionalSort direction on the event timestamp. Defaults to "desc".
Returns
{ rows: PoolTradeHistoryRow[], quotes: PoolQuote[] }. Each row retains the QuoteHistoryRow fields returned by getQuoteHistory, including per-event solver fees, except that closeFee is the derived event fee amount below. The raw closing-fee rate remains available on the aligned quotes entry. Pool rows contain these flat bigint | null fields, at 18 decimals:
| Field | Meaning |
|---|---|
| closeQuantity, closePrice | Event close/liquidation size and execution price |
| tradeValue | Event quantity times price, scaled to 18 decimals |
| openFee | Opening-fee share attributed to this event’s closed quantity |
| closeFee | Event close fee; zero for liquidation |
| platformFee | openFee + closeFee, excluding solver, funding and liquidation fees |
| realizedPnl | Gross realized PnL before fees, from the shared quote primitive |
Missing required inputs yield null. Explicit zero snapshots stay zero. Normal-close quantity falls back from event/closed amount to full quantity; price falls back from average closed price to closed price. Liquidations use liquidation quantity and price; an unknown liquidation price never falls back to an earlier close’s average.
The opening fee uses the event quantity and positive initial fill price, otherwise opened price. Two one-token closes of a two-token position therefore allocate half the opening fee to each row. Independently floored shares may sum to less than the full fee by fewer raw wei than the number of rows. This is an attribution of an already-paid opening fee, not a new charge at close.
Normal, force, emergency and ADL closes include closing fees. All three liquidation event types omit them. The immutable snapshot is applied before deriving metrics; consumers do not need a separate selector call.
Rows also retain the quote’s indexed fields — source, fees, CVA / LF, leverage, open timestamps, sendQuoteTransaction, and the raw openPositionMetadata — listed under the quote, as indexed.
Throws
UNSUPPORTED_CHAIN/ no analytics subgraph — aSymmError(kind: "config").- A
SymmApiErrorwhen the subgraph request itself fails.
Related
- Pool detail tables — the other four reads.
- React:
usePoolTradeHistory.
Complete event quote snapshots
The result also includes quotes: PoolQuote[], aligned with rows. Each quote includes full fee/owner/lock fields, overlaid with that close event’s immutable amount, entry/close price, liquidation values and status. Pair a quote with its corresponding row’s eventId, closedAt and solver fees; never replace those with the current quote’s cumulative close state.
The quote’s tradingFee and closeFee are fee rates at 18 decimals, not cumulative charged amounts. The row’s openFee and closeFee are derived amounts. Keep these distinct when pairing a row and quote.
import { getPoolTradeHistory, type Config } from "@symmio/trading-core";
export async function historyFees(config: Config) {
const { rows } = await getPoolTradeHistory(config, { symbolId: 1, first: 25 });
return rows.map(({ eventId, openFee, closeFee, platformFee }) => ({ eventId, openFee, closeFee, platformFee }));
}