gmx

Executes GMX V2 spot swaps, perpetual orders, and GM liquidity operations on Arbitrum and Avalanche.

6|20|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/andresdefi/cryptoskills --skill gmx-andresdefi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gmx
Source: https://github.com/andresdefi/cryptoskills/tree/main/skills/gmx
Command: npx skills add https://github.com/andresdefi/cryptoskills --skill gmx-andresdefi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires viem, @gmx-io/sdk, and includes references (resource) components.

What problem does it solve? LLMs frequently confuse GMX V1 (GLP) with V2 (isolated GM pools), use deprecated contract addresses, and miss critical mechanics like asynchronous keeper execution, mandatory multicall batching, and 30-decimal USD precision — mistakes that cause failed transactions or lost funds. ## Core Features & Use Cases - Order Execution Patterns: Complete viem-based code for spot swaps, market increase/decrease orders, take-profit and stop-loss orders via the ExchangeRouter multicall pattern. - GM Liquidity Operations: Deposit and withdrawal flows for buying and selling GM tokens with correct vault routing (OrderVault, DepositVault, WithdrawalVault). - Reference Data: Verified contract addresses for Arbitrum and Avalanche, market configurations, error code explanations, and troubleshooting guides. - Use Case: An agent asked to "open a 10x long ETH position on GMX" can use the provided multicall pattern to correctly batch sendWnt (execution fee plus collateral) with createOrder, using 30-decimal sizeDeltaUsd and the current ExchangeRouter address. ## Quick Start Ask the agent to open a leveraged long ETH position on GMX using the ExchangeRouter multicall pattern with the provided viem code.

Frequently Asked Questions about gmx

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I open a leveraged position on GMX V2?

Create a MarketIncrease order by batching sendWnt (execution fee plus collateral) and createOrder into a single multicall on the ExchangeRouter. Leverage is implicit: it equals sizeDeltaUsd divided by collateral value, with sizeDeltaUsd using 30-decimal precision.

What is the difference between GMX V1 and V2?

V1 used a single shared GLP pool for all markets, while V2 uses isolated pools per market with separate GM tokens. GLP is deprecated on V2, and each market like ETH/USD has its own pool with distinct long and short collateral tokens.

Why was my GMX order created but never executed?

GMX orders are asynchronous: keepers execute them in a separate transaction using Chainlink Data Streams prices. Common causes are insufficient execution fee, keeper backlog during volatility, or the price moving past your acceptablePrice causing auto-cancellation.

Which contract should I approve tokens to on GMX?

Approve ERC-20 tokens to the Router contract (0x7452c558d45f8afC8c83dAe62C3f8A5BE19c71f6 on Arbitrum), not the ExchangeRouter. The ExchangeRouter calls the Router internally to transfer tokens, so approving the wrong contract causes TokenTransferError.

Does GMX V2 support chains other than Arbitrum?

Yes, GMX V2 is also deployed on Avalanche with its own ExchangeRouter, Reader, and DataStore addresses. Avalanche has fewer markets than Arbitrum, and all addresses should be verified against the official docs before use.

Why is my GMX position size wrong by orders of magnitude?

GMX uses 30-decimal precision for USD values, not the standard 18 decimals. A $5,000 position must be encoded as 5000 * 10^30; using 18 decimals creates positions orders of magnitude off and can trigger MaxLeverageExceeded errors.