getQuotesEventsByType
Batched sibling of getQuoteEventsByType: decoded subgraph events for many quotes in one round-trip, filtered to specific event types. This is what a grouped position reaches for — one request covers every child quote instead of one request per leg.
import { FUNDING_HISTORY_EVENT_TYPES, getQuotesEventsByType } from "@symmio/trading-core";
const { rows, hasMore } = await getQuotesEventsByType(config, {
quoteIds: [7334n, 7335n],
types: FUNDING_HISTORY_EVENT_TYPES,
first: 100,
});The merge happens server-side
The subgraph filters on quoteId_in and sorts by timestamp, so rows for every requested id come back already interleaved and time-ordered — newest first unless orderDirection: "asc" is passed. There is no client-side re-sort, and no per-quote fan-out.
Two consequences for paging:
first/skippage over the merged stream, not per quote id. Afirst: 50page can be 50 rows from a single busy quote.- The subgraph caps
firstat 1000 — do not ask for more than that. Page withskipwhilehasMoreistrueinstead. Omittingfirstasks for that ceiling, so an un-paged call returns as much as a single request can serve.
Each row carries its own quoteId, so a caller that wants a per-position breakdown groups by that field client-side.
Event-type presets
types takes any subset of QuoteEventType. Two presets ship with the SDK:
PRICE_HISTORY_EVENT_TYPES— everything that moves a quote’s open price:SettleUpnl,ChargeFundingRate,ChargeAccumulatedFundingFee.FUNDING_HISTORY_EVENT_TYPES— the funding subset:ChargeFundingRateandChargeAccumulatedFundingFee. It dropsSettleUpnl(an open-price recompute that settles no funding) and keeps exactly the two events that carryfundingPaid/fundingReceived/ratein their metadata.
Which of the two a quote produces depends on its pair: CHARGE_ACCUMULATED_FUNDING_FEE rows appear only for pairs on accumulated funding, and legacy pairs produce CHARGE_FUNDING_RATE rows. Whether a pair accrues accumulated funding is a per-pair deployment fact — see Funding › Pair states — so do not assume every row is one type.
Parameters
quoteIdsreadonly bigint[]requiredOn-chain quote ids to read events for. Order is irrelevant — rows come back merged. An empty array returns an empty page without issuing a request.
typesreadonly QuoteEventType[]requiredEvent types to include — SettleUpnl (SETTLE_UPNL), ChargeFundingRate (CHARGE_FUNDING_RATE),
ChargeAccumulatedFundingFee (CHARGE_ACCUMULATED_FUNDING_FEE), or one of the presets above. An empty array
returns an empty page without issuing a request.
firstnumberdefault 1000Page size across the whole batch, not per quote id. The subgraph caps it at 1000, and omitting it asks for that
ceiling.
skipnumberdefault 0Page offset into the merged stream.
orderDirection"asc" | "desc"default descSort direction on the event timestamp (newest first by default).
chainIdnumberoptionalOptional chain override.
Returns
GetQuotesEventsByTypeReturnTyperowsQuoteEventRow[]The decoded event rows for every requested quote id, merged and sorted by timestamp server-side. Same row shape as
the single-quote action — each carries quoteId, type, timestamp, and the decoded metadata fields
(fundingPaid, fundingReceived, rate, newPrice, prevPrice, …) whenever the underlying JSON held them. All
amounts are 18-decimal wei bigint.
hasMorebooleantrue when the page came back full (rows.length === first) — fetch the next page by advancing skip.
Funding semantics
The metadata carries the raw on-chain amounts. Net a row the way the rest of the SDK does — fundingReceived − fundingPaid, so a positive net means the position earned funding on that tick, matching QuoteFundingData.netReceived. The raw fundingPaid / fundingReceived fields are verbatim from the subgraph and are never re-signed.
These are the charges settled to date, i.e. what the analytics subgraph has indexed. Funding that has accrued since a quote’s last on-chain charge is not in the subgraph and is therefore absent from the timeline — read it on-chain with getQuotePendingFunding.
The action does no event-type interpretation beyond decoding the metadata JSON.
Query options
import { FUNDING_HISTORY_EVENT_TYPES, getQuotesEventsByTypeQueryOptions } from "@symmio/trading-core";
import { useQuery } from "@tanstack/react-query";
useQuery(
getQuotesEventsByTypeQueryOptions(config, {
quoteIds: [7334n, 7335n],
types: FUNDING_HISTORY_EVENT_TYPES,
}),
);The query is disabled until at least one quote id and one event type are supplied. getQuotesEventsByTypeQueryKey stringifies the bigint ids and sorts them ascending, so passing the same ids in a different order shares one cache entry (the caller’s array is never mutated).
Related
getQuoteEventsByType— the single-quote form.getQuoteFunding— already-summed funding totals per quote, when the per-tick timeline is not needed.aggregateGroupFunding— folds those totals into one group-level number.- React
useQuoteGroupFundingHistory— the hook that wires this action to aQuoteGroup.