Skip to main content

GraphQL

GMX provides GraphQL endpoints powered by Subsquid for querying indexed on-chain data on Arbitrum, Avalanche, and MegaETH.

NetworkStatusURL
Arbitrum One✅ Activehttps://gmx.squids.live/gmx-synthetics-arbitrum:prod/api/graphql
Avalanche C-Chain✅ Activehttps://gmx.squids.live/gmx-synthetics-avalanche:prod/api/graphql
MegaETH✅ Activehttps://gmx.squids.live/gmx-synthetics-megaeth:prod/api/graphql

The Botanix endpoint is no longer available because GMX no longer supports Botanix.

Schema changes​

2026-09-01 — GLV market allocation snapshots added​

The indexed schema now records how each GLV vault's value is split across its GM markets, once per hour. Query the new GlvMarketAllocationSnapshot entity through glvMarketAllocationSnapshots, glvMarketAllocationSnapshotById, and glvMarketAllocationSnapshotsConnection. Each row covers one GLV vault and one of its markets for one hour, with the id glvAddress:marketAddress:snapshotTimestamp.

FieldWhat it holds
snapshotTimestampStart of the hour, in Unix seconds
glvAddress, marketAddressThe GLV vault and the GM market
blockNumber, blockTimestampBlock the values were read at
marketTokenBalanceAmountGM tokens of the market held by the GLV vault (18 decimals)
marketTokenBalanceUsdThat balance valued at the GM token's max price, as GMX values a GLV vault (30 decimals)
glvValueSum of marketTokenBalanceUsd across the markets valued in that hour (30 decimals)
marketTokenBalancePerGlvValueThe market's share of glvValue: marketTokenBalanceUsd / glvValue, scaled by 1e30
marketTokenMaxPrice, marketTokenMinPriceGM token prices used for the snapshot
marketTokenSupply, marketPoolValueTotal GM token supply of the market (18 decimals) and that supply valued at the max price, that is, the whole market in USD (30 decimals)

When an hour has no indexed events, the indexer repeats the previous hour's rows under the new snapshotTimestamp but keeps their original blockNumber and blockTimestamp. Compare blockTimestamp with snapshotTimestamp to tell a carried-over row from a fresh read. A market without a price or market info at snapshot time is skipped, so glvValue covers only the markets valued in that hour.

2026-08-18 — Funding history and trade-action coverage expanded​

The indexed schema now exposes additional hourly funding inputs and identifies funding-fee settlement executions in trade history.

SurfaceChange
FundingBalanceOiSnapshotNew hourly entity available through fundingBalanceOiSnapshots and fundingBalanceOiSnapshotById. It shares its id with the corresponding FundingRateSnapshot and exposes raw USD and token open interest, collateral-token splits, index-token price inputs, the open interest used for funding balance, and signed and absolute net exposure.
Pure-swap TradeAction fieldsswapImpactUsd and swapFeeUsd now aggregate the complete swap path. executionAmountOut is populated from the final swap event. If a required swap event is missing, the affected fields remain null; a genuine zero remains 0.
FundingRateSnapshot and marketsNetRatesByPeriodPre-v2.2c history now falls back to the legacy single min/max funding-factor keys when both per-side keys are unset. Legacy configuration events apply the value to both sides.
TradeAction.isFundingFeeSettleNew indexed boolean. Funding-fee settlement executions now create TradeAction rows with this field set to true; older rows can be null.

2026-07-21 — Referral flow and positive funding PnL clarified​

Affiliate analytics now distinguish traders who leave an affiliate because they graduated to a GMX direct-discount code from traders who were otherwise lost.

SurfaceChange
AffiliateTraderStatsByHourAdded tradersGraduated
affiliateStats pointsAdded tradersGraduated
affiliateStats summaryAdded tradersGraduated and tradersGraduatedDelta

tradersNet is calculated as tradersGained - tradersGraduated - tradersLost. The AccountStat.positiveFundingFeesUsd field is the signed PnL contribution from funding received through ClaimableFundingUpdated, whether claimed or not. It is excluded from realizedFees, so add it to PnL once rather than treating it as another realized fee.

2026-07-17 — TWAP grouping metadata migrated​

The indexer now reads TWAP grouping metadata from the first valid gmxo entry in Order.dataList. It falls back to decoding the legacy synthetic uiFeeReceiver format for older orders. The public numberOfParts and twapGroupId fields remain the integration surface; you don't need to decode either metadata format yourself.

2026-07-15 — Order UI fee snapshots added​

Order and TradeAction now expose uiFeeFactor, the factor snapshotted when the order was created. The field is nullable because historical rows created before the snapshot was added don't contain it. Treat null as unavailable historical data, not as a zero factor.

2026-07-14 — GLV user earnings added​

The schema now tracks GLV fee earnings by account and exposes a public glvUserEarnings(account: String!) resolver.

Entity or resolverAdded surface
GlvglvTokenSupply, cumulativeFeeUsdPerGlvToken
CollectedFeesInfocumulativeFeeUsdPerGlvToken
GlvTokenBalanceCurrent balance, realized cumulative income, and entry snapshot for one account and GLV
GlvTokenBalanceChangeOrdered balance-change history used to reconstruct the 7-day window
glvUserEarningsglvAddress, lifetimeFeeUsd, and recent7dFeeUsd for each GLV held by an account

The resolver calculates lifetime earnings from realized income plus the account's unrealized share of the current fee accumulator. Its 7-day value uses hourly snapshots at the window edge and clamps a negative result to zero.

2026-06-23 — Referral code update support​

The GraphQL schema now includes the referral entities needed to evaluate GMX-managed protocol referral code updates. These additions support the backend workflow that moves eligible traders to organic volume-discount codes or graduated direct-discount codes.

Expanded referral fields.

EntityAdded fields
TraderReferralTradeStatsByHouraffiliateRewardsUsd

Additional referral entities.

EntityWhat it provides
TraderFirstReferralFirst-assignment timestamp for a trader and referral code pair
ReferralTierTier configuration with totalRebate and discountShare
ReferrerTierCurrent tier id for a referrer address

The private referralCodeUpdates resolver is used by GMX-maintained services and is not a public integration surface. Public referral dashboards should continue to use affiliateStats, traderReferralStats, and the referral entities described below.

2026-05-28 — Trade PnL, market info, and funding snapshots expanded​

The GraphQL schema and indexer-derived analytics now expose a more detailed split between realized PnL, swap fees, discounts, market funding state, and hourly rate snapshots.

Expanded fields.

EntityAdded fields
AccountStatrealizedSwapFees, realizedSwapImpact
PositionChangeswapFeeUsd
TradeActionswapFeeUsd, traderDiscountAmount
PositionFeesEntitytraderDiscountAmount
MarketInfominCollateralFactorForLiquidation, savedFundingFactorPerSecond, fundingUpdatedAt, useOpenInterestInTokensForBalance

The account PnL summary server extension also includes a fuller debug breakdown for fees, price impact, discounts, and swap impact. Use these fields when you need to distinguish base realized PnL from fee and impact components instead of treating trade-history PnL as one all-in number.

Hourly rate snapshots now replay the funding formula from indexed market state, including MarketInfo, savedFundingFactorPerSecond, fundingUpdatedAt, open interest, and relevant DataStore settings. They are still historical indexer snapshots, not realtime market state.

2026-03-31 — Referral analytics added​

The GraphQL schema now exposes referral analytics for both affiliates and traders. Five new entities track referral code ownership and hourly trade statistics, and two new query resolvers aggregate that data into time-windowed summaries with period-over-period comparisons.

New entities.

EntityWhat it provides
ReferralCodeOwnerMaps a referral code to its owner address, with updatedAtTimestamp, updatedAtBlock, and updatedTxnHash
TraderReferralRecords which referralCode and affiliate a trader is associated with, plus update metadata
AffiliateReferralTradeStatsByHourHourly trade stats for an affiliate: volumeUsd, tradesCount, and rebatesUsd
TraderReferralTradeStatsByHourHourly trade stats for a trader using a referral code: volumeUsd, discountsUsd, and affiliateRewardsUsd
AffiliateTraderStatsByHourHourly net trader flow for an affiliate: tradersGained, tradersLost, and tradersNet

New query resolvers.

These are custom server-extension resolvers, not standard entity queries. Call them by name with a where argument:

ResolverInput fieldsWhat it returns
affiliateStatsaffiliate (required), from?, to?Time-windowed volume, trade count, rebates, and trader flow for an affiliate, with optional period comparison
traderReferralStatstrader (required), from?, to?Time-windowed volume and discounts for a trader using a referral code, with optional period comparison

Both resolvers align timestamps to hourly buckets and choose a bucket size automatically based on the requested window length.

Example queries.

# Affiliate dashboard: volume, rebates, and trader flow for a 7-day window
query AffiliateStats($affiliate: String!) {
affiliateStats(where: { affiliate: $affiliate, from: 1743292800, to: 1743897600 }) {
affiliate
from
to
bucketSizeSeconds
hasComparison
summary {
volumeUsd
volumeUsdDelta
rebatesUsd
rebatesUsdDelta
tradersNet
tradersNetDelta
}
points {
timestamp
volumeUsd
rebatesUsd
tradersGained
tradersLost
tradersNet
}
}
}
# Trader dashboard: volume and discounts earned through a referral code
query TraderReferralStats($trader: String!) {
traderReferralStats(where: { trader: $trader, from: 1743292800, to: 1743897600 }) {
trader
from
to
bucketSizeSeconds
summary {
volumeUsd
discountsUsd
}
points {
timestamp
volumeUsd
discountsUsd
}
}
}

2026-03-10 - Staking power and account analytics added​

The GraphQL schema now exposes staking power analytics plus expanded daily account aggregates for PnL and capital-tracking queries.

New entities.

EntityWhat it provides
StakingPowerPer-account staking power state, including accumulatedPower, currentStakedBalance, historicalMaxStaked, lastPowerResetAt, and powerResetCount
NetworkStakingPowerNetwork-wide staking power totals through totalAccumulatedPower, totalCurrentStaked, and lastUpdateTimestamp

Expanded analytics fields.

EntityAdded fields
AccountStataccount, period, dayTimestamp, netCapitalDelta, maxNetCapitalRunningDelta
PositionmaxCapital

These additions let you query staking-power history and daily account-level capital changes without replaying raw position-change events yourself.

Example query.

query AccountAnalytics($account: String!) {
stakingPower(id: $account) {
accumulatedPower
currentStakedBalance
historicalMaxStaked
lastPowerResetAt
powerResetCount
}

accountStats(
where: { account_eq: $account, period_eq: "1d" }
orderBy: dayTimestamp_DESC
limit: 7
) {
dayTimestamp
netCapitalDelta
maxNetCapitalRunningDelta
volume
realizedPnl
}
}

2026-02-24 — Transaction entity removed​

The Transaction entity type has been removed from the GraphQL schema. This change is live on all main endpoints. A backward-compatible endpoint is available until March 1, 2026:

https://gmx.squids.live/gmx-synthetics-arbitrum@786bd0/api/graphql

Field changes. Entities that previously referenced transaction: Transaction! now expose a flat transactionHash: String! field. The timestamp field that was nested inside Transaction is now a top-level field on each entity.

EntityOld fieldNew field
TradeActiontransaction: Transaction!transactionHash: String!
ClaimActiontransaction: Transaction!transactionHash: String!
OrdercreatedTxn: Transaction!createdTxnHash: String!
OrdercancelledTxn: TransactioncancelledTxnHash: String
OrderexecutedTxn: TransactionexecutedTxnHash: String
SwapFeesInfotransaction: Transaction!transactionHash: String!
SwapInfotransaction: Transaction!transactionHash: String!
PositionFeesEntitytransaction: Transaction!transactionHash: String!
Distributiontransaction: Transaction!transactionHash: String!

Sort field changes. Sort values that referenced the transaction relation are replaced with direct field sorts:

Old sort valueNew sort value
transaction_timestamp_DESCtimestamp_DESC
transaction_timestamp_ASCtimestamp_ASC

Example migration. A TradeAction query before and after:

# Before
tradeActions(limit: 50, orderBy: transaction_timestamp_DESC) {
eventName
transaction {
timestamp
hash
}
}

# After
tradeActions(limit: 50, orderBy: timestamp_DESC) {
eventName
timestamp
transactionHash
}