GMX 백서

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

her chains and tokens, so filter it by chain ID and token address. `minOrderSize` depends on `feeTier`, which defaults to `"standardFee"`. Only the Arbitrum API serves the `/paxos/transit` routes | | `fetchTransitFeeTier(params)` | `userAddress: string` | `TransitFeeTierResponse` | The address's fee tier (`"zeroFee"` or `"standardFee"`) and `zeroFeeCapacity`, the USDC amount that can still convert to USDG at zero fee, from `/paxos/transit/fee-tier`. All zero-fee addresses share this capacity, and it's `0n` for a `"standardFee"` address | | `fetchTransitAuthorization(params)` | `userAddress: string`, `tokenAddress: string`, `spenderAddress: string`, `amount: bigint`, `chainId: number` | `TransitAuthorizationResponse` | Whether the spender is already approved (`alreadyApproved`) and the available approval methods, an EIP-2612 permit or an ERC-20 approval transaction, from `/paxos/transit/authorization` | | `fetchTransitQuote(params)` | `userAddress: string`, `offerAsset: string`, `wantAsset: string`, `offerAmount: bigint`, `sourceChainId: number`, `destinationChainId: number`, `permitSignature?: string`, `permitDeadline?: number`, `responseFormat?: TransitResponseFormat`, `feeTier?: TransitFeeTier` | `TransitQuote` | Conversion quote with `amountOut`, the fee breakdown, and the `transaction` to send, from `/paxos/transit/orders/quote`. `feeTier` defaults to `"standardFee"`. A `"zeroFee"` quote fails with `403` for an address outside the zero-fee tier, `409` when `offerAmount` is above `zeroFeeCapacity`, and `400` for any route other than USDC and USDG on Arbitrum; request the quote again with `"standardFee"` | | `fetchTransitOrder(params)` | `orderId: string` | `TransitOrder` | One conversion order and its `status` from `/paxos/transit/orders/{orderId}` | | `fetchTransitOrders(params)` | `userAddress: string`, `pageSize?: number`, `pageToken?: string`, `filter?: string` | `TransitOrdersResponse` | An address's conversion orders from `/paxos/transit/orders`. Pass the returned `nextPageToken` as `pageToken` to read the next page | | `fetchWhitelists(params)` | `address: string` | `AccountWhitelists` | For each GM pool (`deposit.markets`) and GLV vault (`deposit.glvs`) that limits deposits to whitelisted addresses, whether the address can deposit, from `/whitelists` | | `fetchUsdgBoostApr()` | -- | `UsdgBoostAprResponse` | [USDG launch boost](../../usdg-launch-boost.md#boost-rates) rate of each pool and of the GLV from `/incentives/usdg/boost-apr`: `{ status: "not_started" }`, or `{ status: "active", pools, glv }`. `boostApr` is a fraction (`0.05` is 5%), and `glv` is `null` until the GLV has a paid round | ### Protocol stats helpers Protocol-wide stats aren't `GmxApiSdk` methods. `@gmx-io/sdk/v2` exports them as standalone functions that take an `{ api }` HTTP client context as the first argument. Stats are chain-agnostic and served by the Arbitrum API deployment, so build the client from `getStatsApiUrl()` in `@gmx-io/sdk/configs/api` instead of your chain's API host. | Function | Parameters | Returns | Notes | | -------- | ---------- | ------- | ----- | | `fetchApiProtocolStatsSummary(ctx, params?)` | `networks?: ProtocolStatsNetwork[]`, `versions?: ProtocolStatsVersion[]` | `ProtocolStatsSummaryResponse` | Totals plus per-network (`byNetwork`) and per-version (`byVersion`) metrics from `/stats/summary` | | `fetchApiProtocolStatsTimeseries(ctx, params)` | `metric: ProtocolStatsTimeseriesMetric`, `groupBy?: "network" \| "version" \| "none"`, `networks?`, `versions?`, `from?: number`, `to?: number` | `ProtocolStatsTimeseriesResponse` | Daily points for one metric from `/stats/timeseries`. `from` and `to` are Unix timestamps in seconds, floored to the UTC day. `groupBy` defaults to `"network"` | | `fetchApiProtocolStatsSources(ctx)` | -- | `ProtocolStatsSourceStatus[]` | Freshness of each data source (`health`, `lagSeconds`, `lastError`) from `/stats/sources` | `networks` accepts `"arbitrum"`, `"avalanche"`, `"megaeth"`, and `"solana"`, and `versions` accepts `"v1"` and `"v2"`. ```typescript fetchApiProtocolStatsSummary, fetchApiProtocolStatsTimeseries, HttpClientWithFallback, } from "@gmx-io/sdk/v2"; const statsApiUrl = getStatsApiUrl(); if (!statsApiUrl) { throw new Error("Protocol stats API is not configured"); } const statsApi = new HttpClientWithFallback([statsApiUrl]); const summary = await fetchApiProtocolStatsSummary( { api: statsApi }, { networks: ["arbitrum", "avalanche"] } ); const dailyVolume = await fetchApiProtocolStatsTimeseries( { api: statsApi }, { metric: "volume.total", groupBy: "network" } ); ``` ### Account and order methods These methods cover wallet data, approval calldata, API-relayed order workflows, and one-click-trading subaccounts. - `fetchWalletBalances({ address })` returns wallet balances from `/balances/wallet`. - `fetchAllowances({ address, spender })` returns token allowances from `/allowances`. `spender` is `"router"`. - `buildApproveTransaction(params)` builds ERC-20 approval calldata for the selected chain. - `buildErc20ApproveTxn(params)` builds ERC-20 approval calldata for any caller-supplied spender address, and `executeErc20Approve(signer, params)` sends that approval through a signer that supports `sendTransaction`. - `buildSameChainDepositTxn(params)`, `buildSameChainWithdrawTxn(params)`, `executeSameChainDeposit(signer, params)`, and `executeSameChainWithdraw(signer, params)` cover GMX Account funding on the settlement chain. - `buildSameChainWithdrawBridgeOutParams(params)` and `buildCrossChainWithdrawBridgeOutParams(params)` build bridge-out params used by GMX Account withdrawals. - `prepareCrossChainDeposit(request)` and `executeCrossChainDeposit(signer, request)` cover cross-chain GMX Account deposits. - `prepareCrossChainWithdraw(request)`, `signCrossChainWithdraw(prepared, signer)`, `submitCrossChainWithdraw(request)`, `executeCrossChainWithdraw(signer, request)`, and `getCrossChainWithdrawStatus(requestId)` cover cross-chain GMX Account withdrawals. - `prepareOrder(request)` prepares a swap, increase, or decrease order and returns either typed data for express mode or transaction calldata for classic mode. See [Order Examples](./examples.md) for full usage. - `signOrder(prepared, signer)` signs a prepared express order with an `IAbstractSigner`. - `submitOrder(request)` submits a signed express order intent to `/orders/txns/submit`. - `executeExpressOrder(request, signer)` runs the common prepare, sign, and submit flow in one call. - `fetchOrderStatus({ requestId })` returns relay, creation, execution, cancellation, and error state for an API-relayed order request. - `prepareEditOrder(request)`, `prepareCancelOrder(request)`, and `prepareCollateral(request)` prepare edit, cancel, collateral deposit, or collateral withdrawal order intents. - `fetchSubaccountStatus(request)`, `prepareSubaccountApproval(request)`, and `signSubaccountApproval(prepared, signer)` support one-click-trading authorization flows. - `generateSubaccount(mainSigner)`, `activateSubaccount(mainSigner, options?)`, `refreshSubaccountState(account)`, and `clearSubaccount()` manage the SDK's local subaccount state. `subaccountAddress`, `subaccountStatus`, `hasActiveSubaccount`, and `subaccountApprovalMessage` expose the current state. - When an active subaccount exists, `prepareOrder()`, `prepareEditOrder()`, `prepareCancelOrder()`, `prepareCollateral()`, and `executeExpressOrder()` attach the current subaccount approval automatically. `signOrder()` signs prepared subaccount orders with the generated subaccount key. - Use the `subaccountStatus` getter to read the parsed on-chain status after `refreshSubaccountState(account)`. `PrivateKeySigner` and the `IAbstractSigner` type are exported from `@gmx-io/sdk/v2`. Lower-level signer helpers are also available from `@gmx-io/sdk/utils/signer`. ### One-click trading lifecycle One-click trading uses three signing steps: | Signature | Signer | When it is needed | | --------- | ------ | ----------------- | | Subaccount key derivation | Main wallet | When `generateSubaccount()` or `activateSubaccount()` creates the local subaccount signer | | Subaccount approval | Main wallet | Only when the subaccount is not active on-chain, or when the requested expiry/action limit needs to be extended | | Order signature | Subaccount signer | For each prepared subaccount order | `activateSubaccount(mainSigner, options?)` refreshes the current on-chain subaccount status, generates the local subaccount signer if needed, and signs a new approval only when the existing on-chain authorization is not enough for the requested expiry and `maxAllowedCount`. The signed approval is kept in SDK memory and submitted with the next subaccount order. After an approval-bearing order is created or executed and the on-chain status is usable, `refreshSubaccountState(account)` updates `subaccountStatus` and `subaccountApprovalMessage` becomes an empty approval whose `signature` is `"0x"`. The empty approval tells the relay to use the already-active on-chain authorization, so the main wallet does not sign every trade. Per-order signatures are produced by the generated subaccount key. Use one `GmxApiSdk` instance per active wallet account, or call `clearSubaccount()` when the wallet account changes. The SDK rejects subaccount order preparation if the stored subaccount belongs to a different account. ### Staking power timestamps `StakingPowerResponse` includes two protocol-level timestamps that are constant across all addresses: | Field | Type | Description | | ----- | ---- | ----------- | | `powerAccrualStart` | unix seconds | The moment power began accumulating for staked GMX. Set to `1772582400` (March 4, 2026 00:00:00 UTC). | | `loyaltyTrackingStart` | unix seconds | The moment loyalty tracking became active. Before this time, unstaking did not affect the historical peak used for loyalty enforcement. Set to `1774396800` (March 25, 2026 00:00:00 UTC). | After `loyaltyTrackingStart`, if an account's staked balance drops below 80% of its historical peak, accumulated power resets to zero. See [Rewards](../../tokenomics/rewards.md#loyalty-threshold) for the user-facing description of how the loyalty threshold works. ## When to use SDK v2 Use `GmxApiSdk` for API integrations that need market configuration and values, tickers, JIT-aware trading capacity, token, pair, rate, APY, GM-pool yield and trader PnL, GM LP fee earnings, performance, position, order, trade-history, JIT-liquidity, OHLCV, wallet-balance, allowance, buyback, or staking-power data, or API-relayed order submission, edit, cancellation, GMX Account, and subaccount flows. Use the full [`GmxSdk` (SDK v1)](../v1/readme.mdx) when you need direct RPC-backed transaction ownership. :::note `GmxApiSdk` is under active development and covers an expanding share of the full SDK surface, replacing the need for direct RPC, oracle, and Subsquid connections. Order submission runs through GMX Relay, the self-hosted relay behind the GMX API. The [GMX API OpenAPI Reference](/docs/category/gmx-api-openapi-reference) documents the underlying HTTP endpoints, while this page documents the typed SDK method names and signing helpers. ::: --- ## Contract addresses This page lists the key contract addresses for each supported chain. For the complete list of all deployed contracts (100+ per chain), see the [gmx-synthetics deployments folder](https://github.com/gmx-io/gmx-synthetics/tree/bf30ebb4cff17b7f92f8c738f145e75b871a1576/docs). The machine-readable `contracts.json` in that folder covers mainnet deployments, while testnet deployments are published in the per-network markdown files. The deployment links on this page are pinned to the commit these tables were generated from, so they keep resolving to the matching manifests. For the current deployment files, browse the same paths on the repository's default branch. :::warning Contract addresses change when logic contracts are upgraded. Subscribe to the [Updates and support](../updates-support.md) channels for upgrade notifications. `DataStore` and `RoleStore` addresses are permanent and don't change across upgrades. ::: ## Mainnet The tables below list the key integrator-facing contracts for each mainnet chain. For the full list of all deployed contracts on each chain, see the deployment files linked from each section. ### Arbitrum (Chain ID: 42161) Explorer: [arbiscan.io](https://arbiscan.io) | [Full deployment list](https://github.com/gmx-io/gmx-synthetics/blob/bf30ebb4cff17b7f92f8c738f145e75b871a1576/docs/arbitrum-deployments.md) | Contract | Address | | --------------------- | -------------------------------------------- | | DataStore | `0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8` | | RoleStore | `0x3c3d99FD298f679DBC2CEcd132b4eC4d0F5e6e72` | | Reader | `0xfA26cBb46e2614609406de08CA1Dc7f70a684184` | | ExchangeRouter | `0x7dE39FF2e232A2203196788d37e234cF8F1b83f1` | | SimulationRouter | `0xaD3051cB1aE3a86b335f12A9a41BD4d995a137ea` | | Router | `0x7452c558d45f8afC8c83dAe62C3f8A5BE19c71f6` | | Oracle | `0x26C02F221e8dB5A821e12347C7eA8a6b6E10842f` | | OrderVault | `0x31eF83a530Fde1B38EE9A18093A333D8Bbbc40D5` | | DepositVault | `0xF89e77e8Dc11691C9e8757e84aaFbCD8A67d7A55` | | WithdrawalVault | `0x0628D46b5D145f183AdB6Ef1f2c97eD1C4701C55` | | ShiftVault | `0xfe99609C4AA83ff6816b64563Bdffd7fa68753Ab` | | OrderHandler | `0xa5D2d45228ee2E3A18AB122B2cE84997d008f4Eb` | | DepositHandler | `0x2c60a1890E24a727ccF504A9dA9912ace58b2EAD` | | WithdrawalHandler | `0xB25dDF7dE751e5c8bFa85c815d1b379732cF4925` | | AdlHandler | `0xC8470eBBb6960FD00Db7D4C9f71CAda27e8f6Bfa` | | LiquidationHandler | `0x01B85C1e0682418f59C4fe37A2cC56c1213C1fa8` | | ShiftHandler | `0xfC260B96E1f80D446bB75785bdDe065Feb1FcEA9` | | GlvHandler | `0x3f6dF0c3A7221BA1375E87e7097885a601B41Afc` | | GlvVault | `0x393053B58f9678C9c28c2cE941fF6cac49C3F8f9` | | EventEmitter | `0xC8ee91A54287DB53897056e12D9819156D3822Fb` | | MarketFactory | `0xf5F30B10141E1F63FC11eD772931A8294a591996` | | GlvRouter | `0x167540D2DFF14120365CfDDF2F86e3045D4fa712` | | GlvReader | `0x85fcBD684D08053f1efAB302dCb04F22E20E65B1` | | SubaccountRouter | `0x9c05880A2AaD7530c69e18e342eDC9E06cc757db` | | Multicall3 | `0xe79118d6D92a4b23369ba356C90b9A7ABf1CB961` | | Config | `0x233720Ccdec5514e2f5b68500C27A3e17571eF86` | | ConfigTimelockController | `0x2Dd99f39f58445CDDC57AA5E0DB2C367335BBD44` | | GovTimelockController | `0xFBEff82f2DD5E51B8AF34b57cf788b4b09d466F9` | | Timelock | `0x7A967D114B8676874FA2cFC1C14F3095C88418Eb` | | TimelockConfig | `0xE7706986A8cec50a2BB8d42D34f8a0404106d4F5` | #### Multichain contracts (Arbitrum) | Contract | Address | | -------------------------- | -------------------------------------------- | | MultichainOrderRouter | `0xABFC734f7CFc9352AED7a97b1F6a236eae831e8A` | | MultichainGmRouter | `0xFd26a7E3c4A9b75Bd0dce495290Fa33af2bb4b00` | | MultichainGlvRouter | `0xA0Ef0Ace6E437458BB4b5F72A7c7bB43a1CdDa8d` | | MultichainClaimsRouter | `0x946CC490DFedd6016645F5ce555E0036D116f50e` | | MultichainTransferRouter | `0x3f6772B95423fC03264adf90Efb8A9922B6C8c6e` | | MultichainSubaccountRouter | `0xAb3EDf0f3eed6804BAe1bD9bF90109ccadFD262e` | | MultichainReader | `0xD9d0e72f53dA0D2aeeDfe02B365CC09b52efc55a` | | MultichainVault | `0xCeaadFAf6A8C489B250e407987877c5fDfcDBE6E` | #### Relay and oracle provider contracts (Arbitrum) | Contract | Address | | --------------------------- | -------------------------------------------- | | GelatoRelayRouter | `0x5503b99308dB6923758F9A22d118207D633c4e87` | | SubaccountGelatoRelayRouter | `0xfD0596f708d9D950E0eF7b5d191e5F8e55b8a67f` | | ChainlinkDataStreamProvider | `0x7BA7Ae61887F1aca28E0FE5aB1434ce85b6606aa` | | ChainlinkPriceFeedProvider | `0x90218fbb064b1475E4382b041Cc7ccF08AF718B0` | | EdgeDataStreamProvider | `0xf2969FF27b3862cD3207a607c8B6BF37585D3068` | | StaticOracleProvider | `0x5dc2fD8a21E77A4C678959CdB384791a2Ef481c3` | | LayerZeroProvider | `0x0B33EBA531e5a5A331a3Ff9F418B8205F01C2869` | ### Avalanche (Chain ID: 43114) Explorer: [snowtrace.io](https://snowtrace.io) | [Full deployment list](https://github.com/gmx-io/gmx-synthetics/blob/bf30ebb4cff17b7f92f8c738f145e75b871a1576/docs/avalanche-deployments.md) | Contract | Address | | --------------------- | -------------------------------------------- | | DataStore | `0x2F0b22339414ADeD7D5F06f9D604c7fF5b2fe3f6` | | RoleStore | `0xA44F830B6a2B6fa76657a3B92C1fe74fcB7C6AfD` | | Reader | `0xa34320a507493C71Fe35E982e496F7C5d1a7fa02` | | ExchangeRouter | `0xc002Db96E682FFF6675966F959677285a0C45Efa` | | SimulationRouter | `0xaB409fCaCc14Dd4234f6f86a2547f04ACC90a55e` | | Router | `0x820F5FfC5b525cD4d88Cd91aCf2c28F16530Cc68` | | Oracle | `0x29220fA3b24279279C211701DE4a7b035122B911` | | OrderVault | `0xD3D60D22d415aD43b7e64b510D86A30f19B1B12C` | | DepositVault | `0x90c670825d0C62ede1c5ee9571d6d9a17A722DFF` | | WithdrawalVault | `0xf5F30B10141E1F63FC11eD772931A8294a591996` | | ShiftVault | `0x7fC46CCb386e9bbBFB49A2639002734C3Ec52b39` | | OrderHandler | `0xC993eF170859DAE0241a3c12B8186e456Fa1c1B0` | | DepositHandler | `0xe93fA5956199d1e395885AB10BBE45b0Bd04F0F2` | | WithdrawalHandler | `0xa334b4e3f92a91e927f061494A95d84B7F0D134d` | | AdlHandler | `0xF68560cA917717639be497BF6283aC08C9Bf0264` | | LiquidationHandler | `0x1eAa0E46a40CB7D6F656193d053493658548114e` | | ShiftHandler | `0x5F65a3B91923840cD5254489A57c873427bA3A91` | | GlvHandler | `0x48486CaF8851ed0085432789D28A8820bEcbfd45` | | GlvVault | `0x527FB0bCfF63C47761039bB386cFE181A92a4701` | | EventEmitter | `0xDb17B211c34240B014ab6d61d4A31FA0C0e20c26` | | MarketFactory | `0xc57C155FacCd93F62546F329D1483E0E5b9C1241` | | GlvRouter | `0x603B3D3aB077CA433b888c05fa59c777d5b6dCAD` | | GlvReader | `0x321EB66dD95ad33715ee615AAb8dAC6394E7b3F9` | | SubaccountRouter | `0xAda708aFf0f1D784D28cd8Ff4d6D977fF9599e5D` | | Multicall3 | `0x50474CAe810B316c294111807F94F9f48527e7F8` | | Config | `0x3002cA0dC434823272062f055D2999293392878e` | | ConfigTimelockController | `0x854a176289958DD875b0a256FF0dd47f747e39B0` | | GovTimelockController | `0xA2aAaa1CbBd4B4f1Fd548f0a3f58B924EE36f266` | | Timelock | `0xdF23692341538340db0ff04C65017F51b69a29f6` | | TimelockConfig | `0xE8505736A5631e036b84b946e56B56D25F28b68E` | #### Multichain contracts (Avalanche) | Contract | Address | | -------------------------- | -------------------------------------------- | | MultichainOrderRouter | `0x204CC947Fddd11c90e302db2A5ac3865021D1618` | | MultichainGmRouter | `0x00205f26BCc52537D12fA9b0eFA5Fcc58F03ab76` | | MultichainGlvRouter | `0x206B582F309724dAd259058Bc3289Ca3519F34B1` | | MultichainClaimsRouter | `0xa664B7E894ad5777f3419C2883911Af3692a4569` | | MultichainTransferRouter | `0xd4F6C2332b36D1Ccb22C7ac479b270fa0cA26a41` | | MultichainSubaccountRouter | `0x4A2826cAee8FF70d9392B171eaF398E0a2B55047` | | MultichainReader | `0xc2e2FA13E005DF61A51C660bc6CceD589eA44E7B` | | MultichainVault | `0x6D5F3c723002847B009D07Fe8e17d6958F153E4e` | #### Relay and oracle provider contracts (Avalanche) | Contract | Address | | --------------------------- | -------------------------------------------- | | GelatoRelayRouter | `0x51fe0b7919e1208a717E9B16a097C1C3D70eFbf6` | | SubaccountGelatoRelayRouter | `0xa62BD1cFE2066c5bF4180b4125BBb5116eEA26c9` | | ChainlinkDataStreamProvider | `0xc581aF9d20b1d95e456e4Bb9E3039aa0d48F9891` | | ChainlinkPriceFeedProvider | `0x86E284921273E1442f32ebd1b567Ce988Cf50dfE` | | EdgeDataStreamProvider | `0x4421E804896Caa8383e7239D87637eb4644BF40E` | | StaticOracleProvider | `0x58Cd772bc32887B1926acb79f5e996e615126E33` | | LayerZeroProvider | `0x74eECe8cC29b3d549db97F566a4445F48ed62a0d` | ### Botanix (Chain ID: 3637) ⚠️ Legacy. GMX no longer supports Botanix: the app, the SDK, the GMX API, the Oracle API, and GraphQL no longer cover it. These addresses are kept for reference. Explorer: [botanixscan.io](https://botanixscan.io) | [Full deployment list](https://github.com/gmx-io/gmx-synthetics/blob/bf30ebb4cff17b7f92f8c738f1
프로젝트로 돌아가기