GMX 백서

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 45쪽 중 34쪽

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.** ```graphql 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: ```graphql # Before tradeActions(limit: 50, orderBy: transaction_timestamp_DESC) { eventName transaction { timestamp hash } } # After tradeActions(limit: 50, orderBy: timestamp_DESC) { eventName timestamp transactionHash } ``` --- ## Fallback URLs This page covers **Oracle API** fallback URLs. The GMX API uses a different redundancy model — see [GMX API peer deployments](#gmx-api-peer-deployments) below. ## Oracle API Fallbacks The Oracle API uses chain-specific primary endpoints such as `https://arbitrum-api.gmxinfra.io`. When the primary Oracle API endpoint is unavailable for a chain, use the corresponding fallback endpoint below. | Network | Fallback 1 | Fallback 2 | | --------- | ------------------------------------------------ | ------------------------------------------------- | | Arbitrum | <CopyUrl url="https://arbitrum-api-fallback.gmxinfra.io" /> | <CopyUrl url="https://arbitrum-api-fallback.gmxinfra2.io" /> | | Avalanche | <CopyUrl url="https://avalanche-api-fallback.gmxinfra.io" /> | <CopyUrl url="https://avalanche-api-fallback.gmxinfra2.io" /> | ## GMX API peer deployments The GMX API does not use a primary-plus-fallback pattern. It is deployed per chain across **two independent peer base URLs**, both user-facing: | Network | Peer A (`.io`) | Peer B (`.ai`) | |---------|----------------|----------------| | Arbitrum | `https://arbitrum.gmxapi.io/v1` | `https://arbitrum.gmxapi.ai/v1` | | Avalanche | `https://avalanche.gmxapi.io/v1` | `https://avalanche.gmxapi.ai/v1` | | MegaETH | `https://megaeth.gmxapi.io/v1` | `https://megaeth.gmxapi.ai/v1` | Both peers receive the same data and accept the same requests. Either base URL can be used on its own, and direct integrators are encouraged to rotate across both for reads rather than hard-coding a single peer. The peers don't share order-transaction records. Keep an express order's prepare, submit, and status calls on the peer that served prepare, and prepare again instead of failing over to the other peer mid-chain. The generic `/relay/*` routes are stateless and aren't affected. See [Idempotency and race conditions](../integration-guide.md#idempotency-and-race-conditions). Protocol stats under `/v1/stats` are computed only by the Arbitrum deployment. The `gmxapi.io` hosts of the other chains forward these requests to it, while the `gmxapi.ai` hosts of the other chains answer with a `308` redirect to `https://arbitrum.gmxapi.ai`, so clients of those hosts must follow redirects. These URLs describe direct HTTP deployments. SDK clients use the fallback hosts configured by the installed package or supplied by the application. In the current published `latest`, `@gmx-io/sdk` `2.2.1`, `getApiFallbackUrls()` returns an empty array for every chain, so an SDK integration that needs peer rotation must supply the second host itself. With a second host configured, SDK `2.1.1` and later keep each express order chain on the host that served its prepare. GMX no longer supports Botanix. Its GMX API, Oracle API, and GraphQL endpoints are no longer available. --- ## Liquidity Oracle API endpoints for APY, performance, and GLV information. Use this page for public liquidity and yield reads. For a broader comparison with SDK and GraphQL surfaces, start with the [API integration guide](../integration-guide.md). ## Fee APYs To retrieve fee APYs for GM pools and GLV vaults: | Network | URL | | --------- | ---------------------------------------------------- | | Arbitrum | <CopyUrl url="https://arbitrum-api.gmxinfra.io/apy?period=total" /> | | Avalanche | <CopyUrl url="https://avalanche-api.gmxinfra.io/apy?period=total" /> | Accepted query parameters: - `period`: `1d`, `7d`, `30d`, `90d`, `180d`, `1y`, `total`. Defaults to `7d`. ## Performance To retrieve annualized performance for GM pools and GLV vaults: | Network | URL | | --------- | -------------------------------------------------------------------- | | Arbitrum | <CopyUrl url="https://arbitrum-api.gmxinfra.io/performance/annualized?period=total" /> | | Avalanche | <CopyUrl url="https://avalanche-api.gmxinfra.io/performance/annualized?period=total" /> | Accepted query parameters: - `period`: `7d`, `30d`, `90d`, `180d`, `1y`, `total`. Defaults to `90d`. The `1d` period is not supported and returns a 400 error. - `address`: Address of a specific GM pool or GLV vault to retrieve data for only that entity. ## GLV tokens To retrieve a list of GMX Liquidity Vault (GLV) tokens: | Network | URL | | --------- | ---------------------------------------- | | Arbitrum | <CopyUrl url="https://arbitrum-api.gmxinfra.io/glvs/" /> | | Avalanche | <CopyUrl url="https://avalanche-api.gmxinfra.io/glvs/" /> | ## GLV info To retrieve extended information for GLV vaults, including market exposure, GM pool balances in USD, `isDisabled` status, and listing date: | Network | URL | | --------- | --------------------------------------------- | | Arbitrum | <CopyUrl url="https://arbitrum-api.gmxinfra.io/glvs/info" /> | | Avalanche | <CopyUrl url="https://avalanche-api.gmxinfra.io/glvs/info" /> | :::note GLV token prices `/glvs/info` is a GLV composition endpoint: it returns vault metadata, market exposure, GM balances, and GM balance values, but not a `glvPrice` field. The Oracle API exposes current off-chain GLV ticker prices separately through [`/prices/tickers`](./oracle-prices.mdx#tickers); use [`/tokens`](./oracle-prices.mdx#tokens) to get the exact GLV symbol. Use Chainlink Data Feeds where available for external on-chain integrations, or call `GlvReader.getGlvTokenPrice` for direct GMX valuation. See [Getting GM and GLV token prices](../gm-glv-prices.md). ::: ## Operational notes - `/apy` currently caches responses for `1800` seconds and returns `400` for an invalid `period`. - `/performance/annualized` and `/performance/snapshots` currently cache by day and return `400` for unsupported periods such as `1d`. - Use these routes for yield and performance reporting, not for near-live position or order state. - If you need write-path status after a transaction, use [SDK v1](../../sdk/v1/readme.mdx) or direct contracts and then poll the relevant read surface. --- ## Markets(Rest-api) Oracle API endpoints for trading market information. Use this page when you need public market reads from the Oracle API. For exact “which surface should I use” guidance, start with the [API integration guide](../integration-guide.md). ## Trading markets and GM tokens To retrieve a market list and its associated tokens, use the endpoint for the relevant network. Arbitrum and Avalanche return active trading markets. | Network | Availability | URL | | --------- | ---------------------------------- | ------------------------------------------------------------ | | Arbitrum | ✅ Active trading | <CopyUrl url="https://arbitrum-api.gmxinfra.io/markets" /> | | Avalanche | ✅ Active trading | <CopyUrl url="https://avalanche-api.gmxinfra.io/markets" /> | This endpoint caches responses for 10 seconds. ## Trading markets and GM info To retrieve detailed information about markets and their tokens — including liquidity, open interest, token amounts, funding, borrowing, net rates, the `isListed` flag, and listing date — use the corresponding endpoint: | Network | Availability | URL | | --------- | ---------------------------------- | ----------------------------------------------------------------- | | Arbitrum | ✅ Active trading | <CopyUrl url="https://arbitrum-api.gmxinfra.io/markets/info" /> | | Avalanche | ✅ Active trading | <CopyUrl url="https://avalanche-api.gmxinfra.io/markets/info" /> | The `/markets/info` endpoint caches responses for 10 seconds. Treat it as a near-live snapshot, not as same-block state. :::note GM token prices Oracle API `/markets/info` exposes GM market state such as liquidity, open interest, token amounts, rates, listing date, and the GM market token address. It does not expose GM token prices as first-class fields, and GM market tokens are not exposed as `GM [...]` tickers in `/prices/tickers`. Use Chainlink Data Feeds where available, or call `Reader.getMarketTokenPrice` for direct GMX valuation. See [Getting GM and GLV token prices](../gm-glv-prices.md). ::: ## Operational notes - Use `/markets` for a market catalog or configuration view. The current implementation caches this route for `10` seconds. - Use `/markets/info` for near-live liquidity, open interest, funding, borrowing, token amounts, and the `isListed` flag. The current implementation caches this route for `10` seconds. - Use `/markets/state` when you only need market status values such as open, closed, or unknown state, `closingPrice`, and `latestMarketStatusTransitionTimestamp`. The current implementation caches this route for `5` seconds. - Use `/markets/tickers` when you need filtered ticker reads. Invalid `addresses` or `symbols` query values return `400`. - If you need fallback behavior, use the alternate public URLs documented on [Fallback URLs](./fallback-urls.mdx). ## Funding rate data freshness The `/rates` endpoint returns **hourly snapshots** produced by the Squid indexer — it is not realtime data. Each snapshot is timestamped at the start of the hour. Funding values are replayed from indexed market state, including `MarketInfo`, `savedFundingFactorPerSecond`, `fundingUpdatedAt`, open interest, and relevant `DataStore` settings. Use `/rates` for historical rate analysis, averages, and trend charts. For **near-live funding rates**, use `/markets/info` instead. It includes current funding and borrowing rates alongside liquidity and open interest. --- ## Oracle Prices Oracle API endpoints for oracle information. Use this page for public price and token reads. For workflow guidance across the GMX API, Oracle API, GraphQL, and SDK surfaces, start with the [API integration guide](../integration-guide.md). ## Ping Use the ping endpoint to check whether the oracle API is healthy. The endpoint verifies database connectivity and returns a JSON response. | Network | URL | | --------- | ---------------------------------------- | | Arbitrum | <CopyUrl url="https://arbitrum-api.gmxinfra.io/ping" /> | | Avalanche | <CopyUrl url="https://avalanche-api.gmxinfra.io/ping" /> | **Success response** (`200 OK`): ```json { "ok": true } ``` **Error response** (`500 Internal Server Error`): ```json { "errors": ["db is unavailable"] } ``` ## Tickers The tickers endpoint returns the latest price data for all supported tokens. Use this endpoint for real-time price display in your application. | Network | URL | | --------- | -------------------------------------------------- | | Arbitrum | <CopyUrl url="https://arbitrum-api.gmxinfra.io/prices/tickers" /> | | Avalanche | <CopyUrl url="https://avalanche-api.gmxinfra.io/prices/tickers" /> | **Response** — an array of ticker objects: ```json [ { "tokenSymbol": "ETH", "tokenAddress": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", "minPrice": "1799910000000000000000000000000000", "maxPrice": "1800090000000000000000000000000000", "medianPrice": "1800000000000000000000000000000000", "oracleDecimals": 8, "updatedAt": 1708956120 } ] ``` Prices are represented as strings scaled to 30 decimal places. Divide by `10^(30 - tokenDecimals - oracleDecimals)` to get the USD price. GLV ticker symbols are network-specific, for example `GLV [ETH-USDC]`. Use the `/tokens` endpoint to get the exact GLV symbol and address for the network before requesting ticker or candle data. For GM and GLV integration guidance across Chainlink feeds, API data, and Reader calls, see [Getting GM and GLV token prices](../gm-glv-prices.md). ## Signed prices The signed prices endpoint returns the latest oracle-signed price data for each supported token. Include these signed prices in your transaction payloads when interacting with GMX contracts on-chain. | Network | URL | | --------- | -------------------------------------------------------- | | Arbitrum | <CopyUrl url="https://arbitrum-api.gmxinfra.io/signed_prices/latest" /> | | Avalanche | <CopyUrl url="https://avalanche-api.gmxinfra.io/signed_prices/latest" /> | **Response**: ```json { "signedPrices": [ { "tokenSymbol": "ETH", "tokenAddress": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", "minPrice": "1799910000000000000000000000000000", "maxPrice": "1800090000000000000000000000000000", "medianPrice": "1800000000000000000000000000000000", "oracleDecimals": 8, "signer": "0xabc...def", "signature": "0x...", "signatureWithoutBlockHash": "0x...", "tokenOracleType": 0, "salt": "0x...", "minBlockNumber": 123456789, "minBlockTimestamp": 1708956000, "minBlockHash": "0x...", "maxBlockNumber": 123456799, "maxBlockTimestamp": 1708956120, "maxBlockHash": "0x...", "createdAt": 1708956120.5 } ] } ``` ## Candlesticks The candlesticks endpoint returns OHLC price data for a given token and time period. Candles are returned in descending order (most recent first). | Network | Base URL | | --------- | -------------------------------------------------- | | Arbitrum | <CopyUrl url="https://arbitrum-api.gmxinfra.io/prices/candles" /> | | Avalanche | <CopyUrl url="https://avalanche-api.gmxinfra.io/prices/candles" /> | **Required query parameters:** - `tokenSymbol` — the token symbol, for example `ETH` or `BTC` - `period` — one of `1m`, `5m`, `15m`, `1h`, `4h`, or `1d` **Optional query parameters:** - `limit` — maximum number of candles to return. Defaults to `1000`. Minimum: `1`. Maximum: `10000`. **Example request:** ```bash GET https://arbitrum-api.gmxinfra.io/prices/candles?tokenSymbol=ETH&period=1d&limit=2 ``` **Response:** ```json { "period": "1d", "candles": [ [1701388800, 2150.25, 2180.5, 2145.0, 2175.3], [1701302400, 2120.1, 2155.0, 2110.0, 2150.25] ] } ``` Each candle is an array of five values in this order: 1. `timestamp` — Unix timestamp (seconds) of the candle period start 2. `open` — opening price 3. `high` — highest price during the period 4. `low` — lowest price during the period 5. `close` — closing price ## Tokens The tokens endpoint returns a list of all tokens supported by the oracle on a given network. | Network | URL | | --------- | ------------------------------------------ | | Arbitrum | <CopyUrl url="https://arbitrum-api.gmxinfra.io/tokens" /> | | Avalanche | <CopyUrl url="https://avalanche-api.gmxinfra.io/tokens" /> | ## Operational notes - `/prices/tickers`, `/signed_prices/latest`, and `/prices/candles` use a `10` second route timeout in the current oracle-keeper implementation. - `/prices/tickers` uses a short in-process cache of `0.3` seconds in the current implementation. - `/signed_prices/latest` is cached for `1` second in the current implementation. - `/prices/candles` is cached for `15` seconds for `1m` and `5m` periods, and `60` seconds for larger periods. - `/tokens` returns the configured token list for the network. If you need richer token data with current prices, use the GMX API or SDK v2, which read from `/tokens/info`. - If you need retries or fallback behavior, implement that in your app. These docs do not publish a public SLA. --- ## Contracts for V1 Docs for the GMX V1 contracts. ## Important Notes :::danger Important GMX V1 contracts have been sunset, and trading or providing liquidity is no longer supported. ::: :::info Important Please note that these docs are meant just as an overview, please check the actual contract code for the exact implementation and for any possible edge cases if building an application, integration or similar using the contracts. Please subscribe to the channels in the [Updates and Support](../api/updates-support.md) page for important contract update notifications. ::: ## Overview A technical overview of GMX V1 can be found in this [Notion Doc](https://gmx-io.notion.site/GMX-Technical-Overview-47fc5ed832e243afb9e97e8a4a036353). ## Arbitrum - GMX: [0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a](https://arbiscan.io/address/0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a) - Vault: [0x489ee077994B6658eAfA855C308275EAd8097C4A](https://arbiscan.io/address/0x489ee077994B6658eAfA855C308275EAd8097C4A) - Router: [0xaBBc5F99639c9B6bCb58544ddf04EFA6802F4064](https://arbiscan.io/address/0xaBBc5F99639c9B6bCb58544ddf04EFA6802F4064) - PositionRouter: [0xb87a436B93fFE9D75c5cFA7bAcFff96430b09868](https://arbiscan.io/address/0xb87a436B93fFE9D75c5cFA7bAcFff96430b09868) - OrderBook: [0x09f77e8a13de9a35a7231028187e9fd5db8a2acb](https://arbiscan.io/address/0x09f77e8a13de9a35a7231028187e9fd5db8a2acb) - Reader: [0x22199a49A999c351eF7927602CFB187ec3cae489](https://arbiscan.io/address/0x22199a49A999c351eF7927602CFB187ec3cae489) - RewardReader: [0x8BFb8e82Ee4569aee78D03235ff465Bd436D40E0](https://arbiscan.io/address/0x8BFb8e82Ee4569aee78D03235ff465Bd436D40E0) - OrderBookReader: [0xa27C20A7CF0e1C68C0460706bB674f98F362Bc21](https://arbiscan.io/address/0xa27C20A7CF0e1C68C0460706bB674f98F362Bc21) - StakedGmx: [0xd2D11625
프로젝트로 돌아가기