/gmx-io:gmx-tradingfrom gmx-io
Trades GMX perpetuals and swaps using GmxApiSdk. Supports market, limit, stop, TP/SL, TWAP orders, position management, and account reads on Arbitrum, Avalanche, and MegaETH.
Ships in gmx-io. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Use GmxApiSdk from @gmx-io/sdk/v2 for new integrations. It reads the GMX API and prepares trading transactions; Express orders use EIP-712 signatures and GMX Relay, while Classic orders are sent by the user's wallet. SDK v1 (GmxSdk) is in maintenance and is not the default for this skill.
Validated against published @gmx-io/[email protected] on 2026-10-13, and moved to @gmx-io/[email protected] (the v2.2.1 contracts) on 2026-11-25. Install the package, not the /v2 import subpath:
npm install --save-exact --ignore-scripts --legacy-peer-deps @gmx-io/[email protected] [email protected]
npm ls @gmx-io/sdk viem
--legacy-peer-deps keeps npm 7+ from auto-installing the unused react-native peer tree (SDK -> isomorphic-performance -> react-native-performance), which adds high-severity npm audit findings. Keep the generated lockfile and use npm ci --ignore-scripts --legacy-peer-deps for repeat installs; plain npm ci rejects that lockfile. Review npm audit findings before enabling signing; a pinned version is not proof of safe dependencies. Upgrade deliberately after reviewing package changes. Recheck the installed types and SDK docs when using a newer version. The SDK requires Node.js >=18. Through 2.9.1, native Node ESM encounters extensionless internal imports; use .cjs for plain Node scripts, or compile TypeScript to CommonJS. TypeScript examples in the references use that compilation model.
No wallet, RPC, oracle URL, or Subsquid URL is required:
// Save as markets.cjs and run: node markets.cjs
const { GmxApiSdk } = require("@gmx-io/sdk/v2");
async function main() {
const sdk = new GmxApiSdk({ chainId: 42161 });
const markets = await sdk.fetchMarkets();
console.table(markets.map((m) => ({
symbol: m.symbol,
address: m.marketTokenAddress,
spotOnly: m.isSpotOnly,
})));
}
main().catch((error) => { console.error(error); process.exitCode = 1; });
| Network | Chain ID | Native gas token | API host |
|---|---|---|---|
| Arbitrum | 42161 | ETH | https://arbitrum.gmxapi.io |
| Avalanche | 43114 | AVAX | https://avalanche.gmxapi.io |
| MegaETH | 4326 | ETH | https://megaeth.gmxapi.io |
fetchMarkets() and tokens with fetchTokens(). Use the returned full market symbol, including its pool suffix; the same index can have multiple pools. Anchor market/token addresses and decimals to the installed SDK registry, and compare addresses with viem isAddressEqual after an isAddress guard (fetchTokens() includes placeholders such as <GM-ADDRESS>), never ===.getTradingCapacity({ symbol, direction }) and its freshness/JIT flags; legacy availableLiquidityLong/Short fields exclude JIT capacity.fetchAllowances({ address, spender: "router" }). buildApproveTransaction() builds approval calldata for SyntheticsRouter; submitting it requires a wallet and a confirmed receipt. When the input token also pays the Express relay fee (USDC by default on Arbitrum and Avalanche), approve the input plus the authorized fee cap. Allowance, spend balance, and gas payment balance are separate checks.prepareOrder() (or the edit, cancel, or collateral preparation method). Review size, fee and price-impact estimates, warnings, expiry, account, chain, and transaction/signing payload against the requested action. Preparation does not execute a trade. Honor the user's existing authorization; preparation alone grants no permission to sign or submit.batchParams/relayParams, check every action and relay field against the authorization, sign the rebuilt copy, and submitOrder() on the same SDK instance, preserving the request ID. Do not sign the API's typed data as-is or use executeExpressOrder(). For Classic, allowlist the decoded calls and send through a wallet client with explicit fee fields. See SDK reference for both flows.created; market orders require executed; relay_unknown is unresolved. Take TP/SL and TWAP order keys from the creation receipt's OrderCreated logs, track each, then refresh account state.Do not prepare a replacement trade just because submission timed out. Reconcile the original request/transaction first. Report an unresolved timeout as pending, not failed or completed.
size and API triggerPrice use 30-decimal USD bigint; prices returned by fetchOrders() are contract prices and need parseContractPrice() before reuse. size is not token quantity or leverage. Derive the notional from the user's collateral/leverage request and inspect the prepared result, including fees and any existing position.collateralToPay.amount (also the swap input) and collateral deposit/withdrawal amount use the relevant token's decimals. slippage is a number in basis points: 30 means 0.3%.bigint, numbers, strings and nullable analytics. Use each method's declared type. Never run large amounts through JavaScript Number; stringify bigint explicitly when logging JSON.sizeInUsd; partial close must respect remaining-position minimums.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
2 skills in this plugin
npx claudepluginhub gmx-io/gmx-ai --plugin gmx-ioOther plugins' skills for the same job