Skip to Content
Symmio Trading-SDK — the SDK surface for builders on Arbitrum
CoreSubgraphOverview

Subgraph

Historical on-chain data — quote history, funding, balance history, transfers, margin moves, liquidations — lives in GraphQL subgraphs synced to the SYMMIO contracts. Each chain has two subgraphs, each indexing a different subset of contracts and events:

  • analytics — aggregated / derived data. Balance changes over time, quote-level events keyed by quote id, funding accruals, position snapshots. This is what a trading UI usually wants: pre-shaped rows ready to render.
  • events — raw on-chain event log. internalTransfers, deposit / withdraw / allocate events straight from the contract. Use when you need untouched provenance (audit trails, custom analytics, reconciliation against on-chain reads).

@symmio/trading-core ships the queries most consumers reach for as typed actions; each is a thin wrapper that supplies filters and paging, issues the GraphQL request, and returns strongly-typed rows. For anything the SDK doesn’t wrap, querySubgraph is the raw escape hatch.

Balance & transfers

Margin & liquidation

Quotes & events

Funding

Raw query

Filters and paging

The reads share one set of rules for filters, paging, and missing values.

A filter is applied only when you pass it. Leave a filter out and the read covers everything it would have narrowed — every account, every market, every deployment. Pass an empty array to a list filter and the read matches nothing: it returns an empty result without issuing a request, and its query options stay enabled: false. A few filters are required (quoteIds on the funding totals, accounts on balance history); each page marks them.

An omitted filter is left out of the GraphQL where object entirely, not sent as null — graph-node rejects a null filter (symbolId_in: null fails with “Non-list value passed to _in filter”). Addresses and hashes are lowercased before they are sent, because the subgraph stores Bytes lowercase; pass checksummed values freely.

source — the deployment

Most reads take an optional source: the diamond address the subgraph indexed the row from. One subgraph can index several diamonds, and their quote ids can collide. Pass source to scope a read to one deployment; omit it to read every deployment the subgraph indexes. Rows carry their own source, checksummed.

Entity reads return one page

getMarginTransfers, getLiquidationDetails, getSubgraphQuotes, getQuoteFundingSettlements, and getFundingIndexCheckpoints each return one SubgraphPage<TRow> per call — { rows, hasMore } — and share the paging parameters of SubgraphPageParameters:

firstnumberdefault 1000

Page size, an integer from 1 to 1000 (SUBGRAPH_MAX_PAGE_SIZE). Anything else throws a SymmError (kind: "validation", code: "INVALID_SUBGRAPH_PAGE_SIZE") before any request.

skipnumberdefault 0

Rows to skip. A negative value throws INVALID_SUBGRAPH_SKIP. The Graph rejects values above 5000, so page deep reads by cursor instead.

orderBy"timestamp" | "id"default timestamp

Sort field. Defaults to "id" when idGt is set.

orderDirection"asc" | "desc"default desc

Sort direction. Defaults to "asc" when idGt is set.

idGtstringoptional

Cursor filter (id_gt): only entities whose id sorts after this one. Pages correctly only in ascending id order, so it switches the default sort to id ascending; passing any other orderBy / orderDirection with it throws INVALID_SUBGRAPH_CURSOR before any request.

hasMore is true when the page came back full (rows.length === first), so another page may exist — the next one can still be empty. The SDK never loops for you.

Paging by cursor

For a read longer than a few pages, page by cursor: sort by id ascending and pass the last row’s id as idGt. A cursor has no ceiling; skip stops at 5000.

The cursor only works in ascending id order. Ids are built from transaction hashes, so they do not follow time: under a timestamp sort an id_gt cursor silently skips every later page’s rows whose id happens to sort lower, and under a descending id sort it returns the same top rows forever. The SDK therefore sorts by id ascending whenever idGt is set and you pass no sort, and throws a SymmError (kind: "validation", code: "INVALID_SUBGRAPH_CURSOR") if you pass any other sort with it.

import { getQuoteFundingSettlements, type QuoteFundingSettlementRow } from "@symmio/trading-core"; const settlements: QuoteFundingSettlementRow[] = []; let idGt: string | undefined; for (;;) { const { rows, hasMore } = await getQuoteFundingSettlements(config, { partyAs: [subAccount], orderBy: "id", orderDirection: "asc", idGt, }); settlements.push(...rows); if (!hasMore) break; idGt = rows.at(-1)?.id; }

Cursor pages come back in id order. Sort by timestamp yourself once the rows are in if you need a timeline.

Missing values are null

A field the subgraph has not indexed for a row — an older deployment, an entity written before the field existed — decodes to null, never to 0n or 0. Treat null as “not recorded” and render it that way: a zero would claim a value the subgraph never had.

Endpoints

Endpoints live in the chain-config registry (Config.getChainConfig(chainId).subgraphs). Override via createConfig({ symmioConfig }) when pointing at a custom deployment or a staging index.

const chain = config.getChainConfig(); chain.subgraphs.analytics; // https://.../subgraphs/arbitrum-vibe-mainnet-analytics/latest/gn chain.subgraphs.events; // https://.../subgraphs/arbitrum-vibe-mainnet-events/stage/gn

GraphQL error handling

The subgraph client normalizes:

  • Transport failures — surface as SymmApiError with the request URL and status.
  • GraphQL errors payload — surfaces as SymmError (kind: "api") with the concatenated messages.
  • Empty data — surfaces as SymmError (kind: "api") with "Subgraph query returned no data." so an action never silently returns undefined.

Query options

Every action ships a matching …QueryOptions factory and …QueryKey builder — same shape as the on-chain reads. See each method’s page for the exact call, and Query options for the shared pattern.

  • SYMMIO Contract — live on-chain state; pair with the subgraph for history.
  • Unified quotes — getQuoteHistory / getQuoteFunding decorate the reconciled row.
  • Funding — which funding number each read returns, and how it is signed.
  • Errors — subgraph failures surface as SymmApiError / SymmError.
Last updated on