gmx
Installation
SKILL.md
GMX
GMX V2 is a decentralized perpetual and spot exchange deployed on Arbitrum and Avalanche. It uses isolated synthetic markets where each market has its own pool of long/short collateral tokens. Orders are created on-chain and executed asynchronously by keeper networks using Chainlink Data Streams for pricing. Supports up to 100x leverage on perpetual positions, spot swaps, and GM token liquidity provision.
What You Probably Got Wrong
LLMs trained before late 2024 confuse V1 (GLP) with V2 (GM tokens, isolated pools). These are the critical corrections.
- V2 is NOT V1 — V1 used a single shared GLP pool for all markets. V2 uses isolated pools per market (e.g., ETH/USD has its own pool with ETH long collateral and USDC short collateral). GLP is deprecated on V2. Do not reference GLP when working with V2.
- Orders are asynchronous, not atomic — Unlike Uniswap, GMX orders are two-step: (1) user creates an order on-chain, (2) a keeper executes it using Chainlink Data Stream prices. Your transaction creates the order; execution happens in a separate transaction. You must pay an execution fee (ETH) upfront to compensate keepers.
multicallis mandatory for order creation — You cannot callcreateOrderalone. You must batchsendWnt(execution fee) +sendTokens(collateral) +createOrderinto a singlemulticallcall on the ExchangeRouter. Calling them separately will fail because the vault expects tokens in the same transaction.sizeDeltaUsduses 30 decimals, not 18 — GMX uses 30 decimal precision for USD values internally. A $1000 position is1000n * 10n**30n, not1000n * 10n**18n. Getting this wrong creates positions orders of magnitude off.- Execution fee is ETH, not a token — The execution fee sent via
sendWntis native ETH (wrapped as WETH internally). It compensates keepers for gas. Excess is refunded. Underpaying causes order rejection. - GM tokens are NOT fungible across markets — Each market has its own GM token. The ETH/USD GM token is different from the BTC/USD GM token. They are separate ERC-20 contracts.
- ExchangeRouter has been upgraded — The current ExchangeRouter on Arbitrum is
0x69C527fC77291722b52649E45c838e41be8Bf5d5(V2.1+). Older addresses like0x7C68C7866A64FA2160F78EEaE12217FFbf871FA8are deprecated. Always verify the active router on the official docs. - Order types are enums, not strings —
OrderType.MarketSwap = 0,MarketIncrease = 2,MarketDecrease = 4, etc. Passing the wrong enum value creates a completely different order type. - Leverage is implicit — There is no "leverage" parameter. Leverage =
sizeDeltaUsd / collateralAmount. A $10,000 position with $1,000 collateral is 10x leverage. The protocol enforces min/max leverage per market.