AI Agents
GMX is built for both humans and AI agents. The protocol's oracle-based pricing, deterministic execution, and comprehensive APIs make it the ideal venue for autonomous on-chain perpetual and spot trading.
Why GMX for AI agents
Centralized exchanges require API keys, KYC approvals, and custodial trust. GMX combines self-custody with oracle-based pricing and purpose-built primitives for autonomous trading:
- Non-custodial — Agents hold their own keys. No exchange custody, no counterparty risk, no account freezes.
- Permissionless — No KYC, no API key provisioning, no rate limit negotiations. Any wallet can trade immediately.
- Oracle-based pricing — Execution happens at Chainlink oracle prices rather than against an internal pool curve. Price impact is determined by open interest imbalance and is predictable before submission.
- Gasless execution — Express orders use EIP-712 typed data signing with Gelato Relay. Agents sign off-chain and pay relay fees in tokens (USDC, WETH) instead of managing native gas tokens.
- MEV protection — Two-phase order execution (create then execute via keeper) prevents frontrunning and sandwich attacks. The user's intent is committed on-chain before oracle prices are included.
- Subaccounts — Agents operate with scoped on-chain permissions via subaccounts, never exposing the master private key.
- Up to 100x leverage — Trade perpetuals across major assets on Arbitrum, Avalanche, and Botanix. Arbitrum has the deepest liquidity and most complete feature set.
- Multichain trading — Agents can trade from any chain by depositing into a GMX account, which routes funds to the destination chain without manual bridging. For direct non-custodial trading without account deposits, agents interact with GMX markets on the chains where they are deployed (Arbitrum, Avalanche, and Botanix).
- Structured data APIs — REST, GraphQL, on-chain contract reads, and an MCP server (coming soon) provide every data point an agent needs: prices, positions, orders, market conditions, fees, and trade history.
- TypeScript SDK — The
@gmx-io/sdkpackage wraps all protocol operations into typed methods. Agents can fetch markets, calculate fees, open positions, and manage orders programmatically. - LLM-optimized docs — This documentation site generates
llms.txtandllms-full.txtbundles for direct model consumption.
Integration paths
GMX offers multiple integration paths depending on the level of control your agent needs.
| Path | Best for | Capabilities |
|---|---|---|
| Agent plugins and skills | AI coding agents (Claude Code, Codex, Cursor, Copilot, Windsurf, and others) | Pre-built trading skill with SDK and API references bundled |
| TypeScript SDK | Custom agents and bots | Full read + write access: markets, orders, positions, fees |
| REST API | Lightweight data access | Oracle prices, markets, positions, orders, rates |
| MCP server (coming soon) | Any MCP-compatible client (Claude, ChatGPT, Codex, Cursor, Copilot, Windsurf, and others) | Market data, positions, orders, pools; trade execution via prepare/confirm |
| Smart contracts | Direct on-chain interaction | Full protocol access via ExchangeRouter, Reader, GlvReader |
| GraphQL | Historical data queries | Trade history, position events, indexed on-chain data |
Agent plugins and skills
The gmx-io/gmx-ai repository provides ready-to-use agent skills for AI frameworks. These skills bundle trading capabilities with SDK references, API endpoint documentation, contract addresses, and order type specifications so agents can trade on GMX without manual setup. See Plugins and skills for installation and usage.
SDK for autonomous agents
The SDK v1 (GmxSdk) is the recommended integration for agents that need full trading capabilities. It provides:
- Market discovery and price feeds
- Order creation (market, limit, stop-loss, take-profit)
- Position monitoring and management
- Fee estimation and execution cost calculation
- Automatic RPC batching for efficient data fetching
const { GmxSdk } = require("@gmx-io/sdk");
const sdk = new GmxSdk({
chainId: 42161,
rpcUrl: "https://arb1.arbitrum.io/rpc",
oracleUrl: "https://arbitrum-api.gmxinfra.io",
subsquidUrl: "https://gmx.squids.live/gmx-synthetics-arbitrum:prod/api/graphql",
account: walletAddress,
walletClient,
});
// Fetch markets and open a position
const { marketsInfoData, tokensData } = await sdk.markets.getMarketsInfo();
await sdk.orders.long({
marketAddress,
payTokenAddress: usdcAddress,
collateralTokenAddress: longToken,
payAmount: 100_000000n,
leverage: 50000n,
});
See the SDK examples for complete agent workflows including position monitoring and closing.
REST API for lightweight agents
For read-only agents or those that submit transactions separately, the REST API provides oracle prices, market data, and position information over HTTP. No RPC connection or SDK installation needed.
MCP server
The MCP server is under development and not yet available.
An MCP (Model Context Protocol) server is being added as a transport layer to the GMX API. MCP is an open standard supported by 70+ AI clients — including Claude, ChatGPT, OpenAI Codex, Cursor, GitHub Copilot, Windsurf, JetBrains, Gemini CLI, Amazon Q, and Cline. Any MCP-compatible client can query GMX data and execute trades directly through the protocol.
The server uses SSE transport mounted alongside the existing REST API, sharing the same domain layer with no separate infrastructure required.
The MCP server ships in two phases:
- Read-only tools — Market data, positions, orders, pool information, and account summaries
- Read-write tools — Trade execution using a prepare/confirm pattern where the server returns human-readable previews and unsigned transactions, and all signing happens client-side
Supported chains
| Chain | Chain ID | Native token |
|---|---|---|
| Arbitrum | 42161 | ETH |
| Avalanche | 43114 | AVAX |
| Botanix | 3637 | BTC |