bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 45쪽 중 5쪽
bmission fails before returning a `taskId`, capture the `X-Trace-Id` response header; it may be the only support identifier.
Don't assume the first follow-up HTTP or GraphQL read will reflect final state. Relay processing, transaction inclusion, keeper execution, and indexing can complete at different times.
## Positions and orders do not line up
If your UI shows position state together with linked orders, fetch them from the same logical snapshot.
Recommended pattern:
```typescript
const apiSdk = new GmxApiSdk({ chainId: 42161 });
const positions = await apiSdk.fetchPositionsInfo({
address: "0x9f7198eb1b9Ccc0Eb7A07eD228d8FbC12963ea33",
includeRelatedOrders: true,
});
```
Use a separate account-wide orders read only when you need a dedicated orders screen.
## There is no documented public SLA
The current manual docs do not publish a public SLA for these surfaces. Build your client as if network errors, timeouts, or stale snapshots can happen.
Recommended client behavior:
1. Use endpoint-specific fallback URLs where they are documented.
2. Add retries with backoff for safe read operations.
3. Keep write confirmation logic separate from read polling logic.
4. Log the exact surface you queried so you can distinguish GMX API, Oracle API, GraphQL, and SDK-backed reads during incident review.
5. Capture the `X-Trace-Id` response header for GMX API failures. It is exposed to browser clients through CORS; include it with any `requestId` or `taskId` in support reports.
## Next steps
- Use the [Integration guide](./integration-guide.md) for workflow selection.
- Use [Fallback URLs](./rest-api/fallback-urls.mdx) for Oracle API public read failover.
---
## Updates and Support
For contract and API updates, subscribe to the [@GMX_Technical_Announcements](https://t.me/GMX_Technical_Announcements) Telegram channel.
Important changes will likely be posted there, but that channel may not cover all updates. Other channels worth monitoring:
- [GMX Substack](https://gmxio.substack.com/)
- [GMX Repositories](https://github.com/gmx-io)
- [@GMX_Announcements](https://t.me/GMX_Announcements)
For API or SDK support, join the [GMX Discord](https://discord.com/invite/H5PeQru3Aa) to create a support ticket.
---
## @gmx-io/gmx-public-api
GMX API overview with Swagger/OpenAPI links and base URLs.
## GMX API (Swagger)
- Swagger/OpenAPI spec: [GMX API Swagger](https://arbitrum.gmxapi.io/swagger.json)
- Human-readable API docs: [GMX API Docs](/docs/api/gmx-api/gmx-io-gmx-public-api/)
## Base URLs
The GMX API is deployed per chain across two independent peer base URLs (`.io` and `.ai`). Neither is primary; both receive the same data and accept the same requests. Integrations that hit the API directly should use either base URL, or rotate across both.
| 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` |
The `/v1/stats` endpoints are protocol-wide: they cover every GMX network, including GMX on Solana, and every base URL serves them. Some base URLs answer them with a redirect, so let your HTTP client follow redirects.
---
## Changelog
## 2.2.1 — October 6, 2026
This release adds the USDG markets on Arbitrum and SDK v2 reads for USDC and USDG conversion, deposit whitelists, and the USDG launch boost rate.
- Added four Arbitrum markets to the packaged configs: BTC/USD [USDG-USDG], ETH/USD [USDG-USDG], SOL/USD [USDG-USDG], and SWAP-ONLY [USDC-USDG], together with the Global Dollar (USDG) token issued by Paxos (`0x004B506865409877C9fA29bfb1ebA929984B9bbC`, 6 decimals). The `@gmx-io/sdk/prebuilt` market key files (`hashedMarketConfigKeys`, `hashedMarketValuesKeys`, and `hashedKinkModelMarketRatesKeys`) are regenerated with these markets. `getContract(ARBITRUM, "USDG")` still returns the legacy V1 USDG contract, which is a different token.
- Added six `GmxApiSdk` methods that read the Paxos conversion between USDC and USDG: `fetchTransitRoutes(params?)`, `fetchTransitFeeTier({ userAddress })`, `fetchTransitAuthorization(params)`, `fetchTransitQuote(params)`, `fetchTransitOrder({ orderId })`, and `fetchTransitOrders(params)`. They call `/paxos/transit/routes`, `/paxos/transit/fee-tier`, `/paxos/transit/authorization`, `/paxos/transit/orders/quote`, `/paxos/transit/orders/{orderId}`, and `/paxos/transit/orders`. All of them except `fetchTransitAuthorization()` return token amounts as `bigint`; `fetchTransitAuthorization()` returns the Paxos response unchanged, with the permit `value` as a string. Only the Arbitrum API serves these routes.
- Added `fetchWhitelists({ address })` to `GmxApiSdk`. It returns `AccountWhitelists` from `/whitelists`: for each GM pool and GLV vault that limits deposits to whitelisted addresses, whether the address can deposit.
- Added `fetchUsdgBoostApr()` to `GmxApiSdk`. It returns `UsdgBoostAprResponse` from `/incentives/usdg/boost-apr`: `{ status: "not_started" }`, or `{ status: "active", pools, glv }` with the boost rate of each pool and of the GLV (`glv` is `null` until the GLV has a paid round). See [USDG launch boost](../usdg-launch-boost.md#boost-rates).
- `@gmx-io/sdk/v2` exports the matching types: `AccountWhitelists`, `UsdgBoostAprResponse`, `UsdgPoolBoostApr`, `UsdgGlvBoostApr`, and the `Transit*` types, including `TransitRoute`, `TransitFeeTierResponse`, `TransitAuthorizationResponse`, `TransitQuote`, and `TransitOrder`.
- Added the `TransitStation` ABI to `abis`.
- `DepositAmounts` from `@gmx-io/sdk/types/trade` gains the optional `initialShortTokenAmount` and `shortTokenSwapPathStats` fields.
## 2.2.0 — October 1, 2026
This release adds number-format parts and helpers for the Arbitrum priority-fee allowance in execution fees.
- Added number-format parts to `@gmx-io/sdk/utils/numbers`: `formatUsdParts()`, `formatBigUsdParts()`, `formatDeltaUsdParts()`, `formatTokenAmountWithUsdParts()`, `formatUsdPriceParts()`, `formatNumberHumanParts()`, `formatAmountHumanParts()`, and `numberWithCommasParts()` return the formatted value as `NumberPart[]`, with the currency symbol in its own `"currency"` part. The matching string formatters return the same strings as before. Added the `NumberPart`, `NumberPartKind`, and `NumberPartInput` types, the `USD_SYMBOL` and `USD_PART` constants, the `numberParts()`, `joinNumberParts()`, `multiplierPart()`, and `isNumberParts()` helpers, and the `FormatUsdOptions`, `FormatDeltaUsdOptions`, and `FormatTokenAmountWithUsdOptions` option types.
- Added `getExecutionFeePriorityFeeAllowance(chainId)` to `@gmx-io/sdk/configs/chains`: the priority fee per gas a wallet may add to a transaction. It returns `30000000n` (0.03 gwei) on Arbitrum, which has charged priority fees since September 23, 2026, and `0n` on other chains. The contracts reject an execution fee below the gas limit times the transaction's gas price with `InsufficientExecutionFee`, so the execution fee must cover any priority fee the wallet adds.
- Added `getExpressBatchOrderParams(chainId, batchParams)` to `@gmx-io/sdk/utils/orderTransactions`. Express transactions are relayed without a priority fee, so it takes the allowance times the gas limit out of each created order's execution fee and its native-token transfer to the `OrderVault`, and out of each update's execution-fee top-up. Apply it once to wallet-priced batch params, right before you estimate or sign them for the relay. On chains without an allowance it returns the params unchanged.
- Added `getBatchExecutionFeeEstimates(batchParams)` to `@gmx-io/sdk/utils/orderTransactions`, which returns an `ExecutionFeeEstimate` (`{ executionFee, gasLimit }`) for each created order, and an optional `executionGasLimit` to `UpdateOrderParams`. Without `executionGasLimit`, `getExpressBatchOrderParams()` leaves an update's top-up unchanged.
- The SDK doesn't add the allowance to execution fees for you: SDK v1 (`GmxSdk`) still prices them at the network gas price plus the chain's gas price premium. If you sign Arbitrum transactions from a wallet that adds a priority fee, add `getExecutionFeePriorityFeeAllowance(chainId)` to the gas price you use for the execution fee.
## 2.1.2 — September 30, 2026
This release removes delisted markets from the packaged configs.
- Breaking: Removed delisted markets and their unused tokens from the packaged configs: SATS, BOME, MEME, MEW, and BRETT on Arbitrum, and MELANIA on Avalanche. Remove references to these markets and tokens when upgrading from 2.1.1.
- Removed the `SATS` entry from `TOKEN_COLOR_MAP` and regenerated the `@gmx-io/sdk/prebuilt` market key files (`hashedMarketConfigKeys`, `hashedMarketValuesKeys`, and `hashedKinkModelMarketRatesKeys`) without the removed markets.
## 2.1.1 — September 21, 2026
This release keeps an express order on the API host that prepared it and fixes compact-number rounding.
- An express order now stays on the API host that served its `prepare`: `submit` and `status` go to that host without falling back to another one. This covers the express functions of `@gmx-io/sdk/utils/orderTransactions` (`prepareOrder()`, `prepareEditOrder()`, `prepareCancelOrder()`, `prepareCollateral()`, `submitOrder()`, `fetchOrderStatus()`) and cross-chain withdrawals from the GMX Account. A prepared request exists only on the host that prepared it, so a fallback to another host used to end in `NOT_FOUND`; now a failure on that host reaches the caller, who prepares again. It applies only to a client with fallback hosts; the default client has none.
- `IHttp` (exported from `@gmx-io/sdk/v2`) gains an optional `postJsonWith(path, body, opts)` that returns `{ result, client }`: the parsed result and the client that served it. A custom `IHttp` without it keeps working, without the pinning above.
- The fallback HTTP client no longer re-sends a request to the next host when a response fails to parse.
- `formatNumberHuman()` and `formatAmountHuman()` from `@gmx-io/sdk/utils/numbers` switch to the larger suffix when a value rounds up to 1,000 of the smaller one: `999_960` now formats as `1.0m` instead of `1000.0k`.
- Version 2.1.0 was not published to npm; its changes ship in this release.
## 2.0.0 — September 18, 2026
This major release removes the Gelato relay surface. Gelato shut its relay services down on September 1, 2026, and the GMX Relay helpers added in 1.8.2 replace it.
- Breaking: Removed the `@gmx-io/sdk/utils/gelatoRelay` subpath: `getGelatoRelayerClient()`, the `Status`, `TerminalStatus`, and `GelatoEvmRelayerClient` types, and the `StatusCode` re-export from `@gelatocloud/gasless`. `StatusCode` is now exported from `@gmx-io/sdk/utils/express` with the same values.
- Breaking: Removed `sendToGelatoRelay()`, `waitForGelatoTask()`, `GelatoRelayError`, `GelatoRelayResult`, and `fetchGelatoGasTankBalance()` from `@gmx-io/sdk/utils/express`. Use `sendToGmxRelay()`, `getGmxRelayTaskStatus()`, `waitForGmxRelayTask()`, `GmxRelayError`, and `isPermanentRelayError()`, or the express order methods of the SDK v2 client, which submit through the GMX API.
- Breaking: Removed `GELATO_API_KEYS` and `MIN_RELAYER_FEE_USD` from `@gmx-io/sdk/configs/express`, and the `GelatoRelayAddress` entries from `@gmx-io/sdk/configs/contracts`.
- Breaking: Removed `gelatoStatusCode` from `CrossChainWithdrawStatusResponse`. The GMX API no longer returns it.
- Removed the `@gelatocloud/gasless` dependency.
- The relay router contract names (`GelatoRelayRouter`, `SubaccountGelatoRelayRouter`), the EIP-712 domain name `GmxBaseGelatoRelayRouter` returned by `getGelatoRelayRouterDomain()`, and `GELATO_RELAY_FEE_MULTIPLIER_FACTOR_KEY` keep their names: they identify deployed contracts and on-chain keys.
## 1.9.1 — September 17, 2026
This release adds GM LP earnings and protocol stats reads, ports the contracts' resulting-position margin check for increase orders, and removes delisted markets from the packaged configs.
- Breaking: Removed delisted markets and their unused tokens from the packaged configs: TON, MELANIA, AI16Z, MKR, OM, PI, WELL, KTA, and IP, plus the SWAP-ONLY [USDC-DAI] market, on Arbitrum, and the SWAP-ONLY [USDC-DAI.e] market and DAI.E token on Avalanche. Remove references to these markets and tokens when upgrading from 1.8.2.
- Added `fetchGmUserEarnings({ account })` to the SDK v2 client for `GET /v1/yield/gm-user-earnings`: lifetime and 7-day fee earnings (`lifetimeFeeUsd`, `recent7dFeeUsd`) per GM pool for an LP account. Added the matching `@gmx-io/sdk/v2` type exports: `GmUserEarningsParams`, `GmUserEarningsResponse`, `GmUserEarningEntry`, and `GmUserEarningsWindow`.
- Added protocol stats reads to `@gmx-io/sdk/v2`: `fetchApiProtocolStatsSummary()`, `fetchApiProtocolStatsTimeseries()`, and `fetchApiProtocolStatsSources()` wrap `/v1/stats/summary`, `/v1/stats/timeseries`, and `/v1/stats/sources` and take an `{ api }` HTTP client context. Added the matching `ProtocolStats*` type exports and `getStatsApiUrl(environment)` to `@gmx-io/sdk/configs/api`. Stats are chain-agnostic and served by the Arbitrum API deployment.
- Added monthly buyback buckets: `BuybackWeeklyStatsResponse` now includes `months`, typed as the new `BuybackMonthData[]`.
- Added the contracts' resulting-position margin check for increase orders to `@gmx-io/sdk/utils/trade`: `getIncreaseResultingPositionMarginState()`, `getResultingPositionMarginState()`, `PositionMarginFailureReason`, and `getIsMaxLeverageMarginReason()`, plus `getLimitOrderTypeByTradeMode()`. Added the supporting `getIncreaseEvaluationIndexPrice()` and `getIsIncreaseOrderExecutableNow()` to `@gmx-io/sdk/utils/prices`, and `getMarketInfoWithOpenInterestDelta()` to `@gmx-io/sdk/utils/markets`.
- `getIncreasePositionAmounts()` now evaluates resting limit and stop increase orders at the trigger price, charges a size-only increase's fees to the position, and accepts an optional `proDiscountFactor`. `getIncreasePositionPrices()` returns the `evaluationPrice` it used, and `getNextPositionValuesForIncreaseTrade()` accepts an optional `collateralPrice` to value the existing collateral.
- Added pro-tier fee discounts: `getPositionFee()` accepts an optional `proDiscountFactor` and applies the larger of the referral and pro-tier discounts. Added `PRO_TRADER_TIER_KEY`, `PRO_DISCOUNT_FACTOR_KEY`, `proTraderTierKey(account)`, and `proDiscountFactorKey(proTier)` to `@gmx-io/sdk/configs/dataStore`.
- Price impact now uses exact integer exponentiation instead of floating-point math, matching the contracts. The new helpers `applyExponentFactor()` and `prbPow()` are exported from `@gmx-io/sdk/utils/numbers`.
- `getPositionPnlUsd()` now takes the pool PnL for the traders' PnL cap from the same side as the deployed contracts and no longer truncates the capped PnL to 18 decimals.
- Added `getIsPositionBelowMinCollateralForLeverage()` and `getLiquidationPriceImpactDeltaUsd()` to `@gmx-io/sdk/utils/positions`.
- Added the `ArbSys` precompile address to the Arbitrum and Arbitrum Sepolia contract configs, and the `ArbSys` ABI to `abis`.
- Version 1.9.0 was not published to npm; its changes ship in this release.
## 1.8.2 — August 25, 2026
This release adds the GMX Relay helpers ahead of the Gelato shutdown and lists the QQQ and SPY equity index markets.
- Added GMX Relay helpers to `@gmx-io/sdk/utils/express`. `sendToGmxRelay({ chainId, txnData, apiUrl? })` submits bare relay-router calldata through the GMX API (`POST /v1/relay/submit`) and returns `{ taskId, status }`. `getGmxRelayTaskStatus()` reads a task through `POST /v1/relay/status`, and `waitForGmxRelayTask({ chainId, taskId, apiUrl?, timeout?, pollingInterval? })` polls it to a final result. `GmxRelayError` carries the API `traceId` in `data`, and `isPermanentRelayError()` separates permanent failures from retryable ones.
- Added the matching types: `GmxRelayStatus` (`pending`, `executed`, `reverted`, `failed`, `unknown`), `GmxRelayResult`, `GmxRelayStatusView`, `GmxRelayDebugView`, and `GmxRelayTaskResult`.
- Deprecated `GELATO_API_KEYS`, `sendToGelatoRelay()`, and `waitForGelatoTask()`: Gelato shuts its relay services down on September 1, 2026. Migrate to the GMX Relay helpers.
- Added Arbitrum market and token config entries for the QQQ/USD [WETH-USDC] and SPY/USD [WETH-USDC] equity index markets.
- Added `decreasePositionSwapType` to transformed trade actions from `@gmx-io/sdk/utils/tradeHistory`.
- Version 1.8.1 was not published to npm; its changes ship in this release.
## 1.8.0 — August 19, 2026
This release adds the combined GM pool yield/PnL read for integrators.
- Added `fetchGmPoolYieldPnl(params?)` to the SDK v2 client for `GET /v1/yield/gm-pools`: fee-only APY (same composition as `/apy` `baseApy`) plus trader-perspective PnL (`tradersPnlUsd`, `tradersPnlApr`, optional realized/unrealized components) per GM market token, filterable by pool addresses over the standard periods. Positive trader PnL means traders gained against the pool.
- Added the matching `@gmx-io/sdk/v2` type exports: `GmPoolsYieldPnlParams`, `GmPoolsYieldPnlResponse`, `GmPoolYieldPnlEntry`, `GmPoolYieldPnlComponents`, and `GmPoolYieldPnlWindow`.
## 1.7.0 — August 13, 2026
This release adds JIT-aware trading capacity and aligns SDK calculations, parsing, and trade-history data with current API responses.
- `fetchMarketsTickers()` now returns `MarketTickerWithCapacity[]`: each ticker optionally carries `capacityLong` and `capacityShort` — JIT-aware trading capacity with a `jitDataStatus` freshness flag (`available`/`stale`/`unavailable`) and the limiting factor (`reserve`/`openInterest`/`both`/`notApplicable`).
- Added `getTradingCapacity({ symbol, direction })` and the matching `@gmx-io/sdk/v2` type exports: `TradingCapacity`, `MarketTickerWithCapacity`, `TradingCapacityLimitingFactor`, `JitDataStatus`, `MarketDataStatus`, and `GetTradingCapacityParams`.
- Added prepare-order capacity estimates, structured validation warnings, and `parsePrepareOrderError()` / `isPrepareOrderError()`.
- Added collateral-split open-interest fields and `getPositiveMarketPnl()` so profitable position PnL caps match the v2.2c positive-PnL calculation.
- Added `parseUint256DecimalString()` and `isUint256()`, and changed `removeTrailingZeros()` to trim numeric strings without converting them to JavaScript numbers.
- Added `swapFeeUsd` and `swapImpactUsd` to transformed swap trade actions from `@gmx-io/sdk/utils/tradeHistory`.
## 1.6.4 — July 31, 2026
This release prepares the SDK for v2.2c market and position API responses, and removes Botanix chain support.
- Breaking: Removed Botanix chain support, including the Botanix staking swap helpers re-exported from `@gmx-io/sdk/utils/swap`. Remove Botanix chain, token, market, contract, and staking references when upgrading from 1.6.3.
- Added the v2.2c market and position response fields.
- Matched position impact calculations to token-denominated open interest and virtual inventory.
- Added runtime validation for v2.2c API responses.
- Removed Botanix from the packaged chain and token configuration, together with Botanix-only swap helpers.
- Removed `CombinedSwapStrategy`, `ExternalSwapPath`, and the `BotanixStaking` external-swap aggregator from the public type surface.
## 1.6.3 — June 10, 2026
This release improves SDK v2 One-Click Trading subaccount state handling.
- Added the `subaccountStatus` getter to `GmxApiSdk`, exposing parsed on-chain subaccount status with `bigint` fields.
- Added `refreshSubaccountState(account)` to refresh and reconcile the SDK's stored subaccount state against `/subaccounts/status`.
- `activateSubaccount(mainSigner)` now signs owner approvals only when needed; once the approval is synced on-chain, SDK-managed orders use an empty subaccount approval with `signature: "0x"` and sign order typed data with the generated suba프로젝트로 돌아가기