getQuoteEventsByType
Decoded subgraph events for one quote, optionally filtered to specific event types — useful for building per-quote timelines that pull out just funding ticks or settle-uPnL events, or for reading any other event the subgraph records on the quote (OPEN_POSITION, QUOTE_ADJUSTED, …). Paged.
import { getQuoteEventsByType, QuoteEventType } from "@symmio/trading-core";
const { rows, hasMore } = await getQuoteEventsByType(config, {
quoteId: 42n,
types: [QuoteEventType.ChargeFundingRate],
first: 20,
});Event types
types takes any QuoteSubgraphEventType — the known QuoteEventType and QuoteCloseEventType values autocomplete, and every other type the subgraph emits passes through as a plain string, so a read is never limited to the types this release names. Omit types to read every event on the quote; an empty array reads nothing and returns an empty page without a request.
Each row’s type narrows to the types you pass:
import { getQuoteEventsByType, QuoteCloseEventType } from "@symmio/trading-core";
const { rows } = await getQuoteEventsByType(config, {
quoteId: 42n,
types: ["OPEN_POSITION", QuoteCloseEventType.FillClose],
});
// rows[i].type: "OPEN_POSITION" | QuoteCloseEventType.FillCloseThe decoded fields (newPrice, fundingPaid, rate, …) are set only when the event’s metadata carries them. For other event types, read rawMetadata.
Parameters
quoteIdbigintrequiredOn-chain quote id to read events for.
typesreadonly QuoteSubgraphEventType[]optionalEvent types to include — QuoteEventType values (SettleUpnl, ChargeFundingRate, ChargeAccumulatedFundingFee),
QuoteCloseEventType values, a preset such as PRICE_HISTORY_EVENT_TYPES, or any other subgraph type string. Omit
to read every type; an empty array reads nothing.
sourceAddressoptionalThe deployment’s diamond address (the subgraph’s source). Omit to match the quote id on any deployment the
subgraph indexes; pass it when one subgraph indexes several diamonds, whose quote ids can collide.
firstnumberdefault 50Page size.
skipnumberdefault 0Page offset.
orderDirection"asc" | "desc"default descSort direction on the event timestamp (newest first).
chainIdnumberoptionalOptional chain override.
Returns
GetQuoteEventsByTypeReturnType<TType>rowsQuoteEventRow<TType>[]The decoded event rows, type narrowed to the requested types. Each carries eventId, quoteId, type,
timestamp, blockNumber, transaction, the decoded metadata fields (newPrice, prevPrice, openQuantity,
fundingPaid, fundingReceived, rate — 18-decimal wei bigint, present when the metadata held them), and the
raw rawMetadata JSON.
hasMorebooleantrue when the page came back full (rows.length === first) — fetch the next page by advancing skip.
Query options
import { getQuoteEventsByTypeQueryOptions, QuoteEventType } from "@symmio/trading-core";
import { useQuery } from "@tanstack/react-query";
useQuery(
getQuoteEventsByTypeQueryOptions(config, {
quoteId: 42n,
types: [QuoteEventType.ChargeFundingRate],
}),
);The query is disabled while types is an empty array; omitting types reads every type.
The React useQuoteEventsByType still requires types and takes only
QuoteEventType values — it reads price and funding events. For any other event type, or every type at once, use this
core action or its query options.
Related
getQuotesEventsByType— the batched form for many quotes.getQuoteHistory— terminal events with the quote’s fields overlaid.