GraphQL
GMX provides GraphQL endpoints powered by Subsquid for querying indexed on-chain data.
| Network | URL |
|---|---|
| Arbitrum One | https://gmx.squids.live/gmx-synthetics-arbitrum:prod/api/graphql |
| Avalanche C-Chain | https://gmx.squids.live/gmx-synthetics-avalanche:prod/api/graphql |
| Botanix | https://gmx.squids.live/gmx-synthetics-botanix:prod/api/graphql |
| MegaETH | https://gmx.squids.live/gmx-synthetics-megaeth:prod/api/graphql |
Schema changes
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.
| Entity | What it provides |
|---|---|
ReferralCodeOwner | Maps a referral code to its owner address, with updatedAtTimestamp, updatedAtBlock, and updatedTxnHash |
TraderReferral | Records which referralCode and affiliate a trader is associated with, plus update metadata |
AffiliateReferralTradeStatsByHour | Hourly trade stats for an affiliate: volumeUsd, tradesCount, and rebatesUsd |
TraderReferralTradeStatsByHour | Hourly trade stats for a trader using a referral code: volumeUsd and discountsUsd |
AffiliateTraderStatsByHour | Hourly 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:
| Resolver | Input fields | What it returns |
|---|---|---|
affiliateStats | affiliate (required), from?, to? | Time-windowed volume, trade count, rebates, and trader flow for an affiliate, with optional period comparison |
traderReferralStats | trader (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.
| Entity | What it provides |
|---|---|
StakingPower | Per-account staking power state, including accumulatedPower, currentStakedBalance, historicalMaxStaked, lastPowerResetAt, and powerResetCount |
NetworkStakingPower | Network-wide staking power totals through totalAccumulatedPower, totalCurrentStaked, and lastUpdateTimestamp |
Expanded analytics fields.
| Entity | Added fields |
|---|---|
AccountStat | account, period, dayTimestamp, netCapitalDelta, maxNetCapitalRunningDelta |
Position | maxCapital |
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.
| Entity | Old field | New field |
|---|---|---|
TradeAction | transaction: Transaction! | transactionHash: String! |
ClaimAction | transaction: Transaction! | transactionHash: String! |
Order | createdTxn: Transaction! | createdTxnHash: String! |
Order | cancelledTxn: Transaction | cancelledTxnHash: String |
Order | executedTxn: Transaction | executedTxnHash: String |
SwapFeesInfo | transaction: Transaction! | transactionHash: String! |
SwapInfo | transaction: Transaction! | transactionHash: String! |
PositionFeesEntity | transaction: Transaction! | transactionHash: String! |
Distribution | transaction: Transaction! | transactionHash: String! |
Sort field changes. Sort values that referenced the transaction relation are replaced with direct field sorts:
| Old sort value | New sort value |
|---|---|
transaction_timestamp_DESC | timestamp_DESC |
transaction_timestamp_ASC | timestamp_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
}