DeFi DEX

GMX Setup Guide

Time: 15 minutes | Difficulty: Advanced | Market: DeFi DEX Mode: Full automation | API: Smart contract interaction | Docs: docs.gmx.io

This guide wires a GMX trading bot to the GMX V2 smart contracts using the botwir3 runtime. Configure a wallet, connect to decentralized perpetual futures markets, and run automated DeFi trading strategies locally.


Before you start

Verify that automated operation is permitted under GMX's current terms of service before deploying. GMX is a permissionless protocol — interaction is through smart contracts on Arbitrum and Avalanche. botwir3 provides tools for building structured automation. The user is responsible for compliance with all applicable regulations.

GMX Terms of Use | Last verified: May 2026

What you need

  • A wallet with ETH (on Arbitrum) or AVAX (on Avalanche) for gas, plus USDC or other collateral
  • A private key or keystore file for the wallet (stored locally — never shared)
  • The botwir3 runtime downloaded and unzipped
  • A strategy config file from the builder
  • An RPC endpoint for Arbitrum or Avalanche

Step 1: Configure wallet credentials

GMX is a permissionless protocol. There are no API keys — the bot interacts with smart contracts using a wallet private key.

🔒 Security. The wallet private key controls all funds in the wallet. Use a dedicated wallet for bot operations with only the funds allocated to the strategy. The private key is stored in a local config file and is not transmitted to botwir3 or any third party.

Step 2: Configure the adapter

Create adapter.json in the bot directory:

{
  "adapter": "gmx",
  "credentials": {
    "private_key": "paste-wallet-private-key-here",
    "rpc_url": "https://arb-mainnet.g.alchemy.com/v2/paste-key-here"
  },
  "market": "ETH-USD",
  "chain": "arbitrum",
  "leverage": 5,
  "environment": "live",
  "rate_limit_ms": 5000
}

market: GMX V2 supports perpetual futures on ETH, BTC, SOL, ARB, AVAX, and other assets. Markets are denominated in USD.

chain: "arbitrum" or "avalanche". Most liquidity is on Arbitrum.

leverage: GMX supports up to 100x leverage. Leverage amplifies both gains and losses. The user is responsible for configuring leverage and position sizing.

API keys (RPC endpoint credentials) are stored in a local config file on the machine running the bot. They are not transmitted to botwir3 or any third party. botwir3 never sees, stores, or has access to wallet credentials.

Step 3: Test the connection

botwir3 test --adapter gmx

Expected output:

[botwir3] Adapter: gmx
[botwir3] Connection: OK (Arbitrum via Alchemy)
[botwir3] Wallet: 0x1234...abcd
[botwir3] Chain: arbitrum
[botwir3] Rate limit: gas-limited

Step 4: Start the bot

botwir3 start --config my-strategy.json

The runtime loads the strategy, computes the spec hash, connects to the GMX smart contracts via the configured RPC endpoint, and begins evaluating signals. The gate function compares proposed actions against the configured spec. The user is responsible for monitoring the bot and verifying execution outcomes.

Rate limits and considerations

ComponentLimitNotes
RPC endpointProvider-dependentAlchemy, Infura, or public Arbitrum RPC.
Transaction throughput~0.25 seconds/block (Arbitrum)Significantly faster than Ethereum mainnet.
Gas costsLow on ArbitrumFractions of a cent per transaction. Higher on Avalanche.

Execution price. GMX uses oracle-based pricing (Chainlink) rather than an order book. Positions open and close at the oracle price, reducing slippage. Execution fees apply to each position change.

Common GMX bot configurations include momentum strategies on perpetual futures (long/short based on trend signals), delta-neutral strategies combining long and short positions, and automated position management (take-profit, stop-loss, trailing stops). All actions and decisions are recorded in the local ledger.

Troubleshooting

ErrorCauseFix
CONNECTION_REFUSEDRPC endpoint unreachableVerify rpc_url in adapter config
INSUFFICIENT_FUNDSWallet balance too low for collateral + gasFund the wallet with ETH (gas) and USDC (collateral)
TRANSACTION_REVERTEDInsufficient collateral, market paused, or max leverage exceededCheck collateral ratio and market status on app.gmx.io
MANDATE_INTEGRITY_VIOLATIONConfig file modified while bot is runningStop the bot, verify config, restart

Related guides


One bot. $129. No subscription. No $749/mo platform. → Build for GMX


Build your GMX bot

Ready to build?