GMX API
This module contains GMX support for Python.
# Functionality
The functions connect directly to JSON-RPC instance and interact with GMX smart contracts
Open and close GMX positions
Read historical and current market data, including onchain data like open interest and volume
Tutorials
GMX: swap tokens - Execute swaps on GMX
Lagoon vault, GMX and CCXT integration - Trade GMX perpetuals from a Lagoon vault
GMX, CCXT and FreqTrade - Algorithmic trading on GMX using FreqTrade and CCXT
What Is GMX?
GMX is a perpetual future (“perp”) DEX for EVM blockchains.
GMX offers dozens of perp trading pairs for popular cryptocurrencies like BTC, ETH and SOL. GMX is so-called pure onchain market with high degree of decentralisation. Thus, GMX has high composability with other decentralised finance protocols. This allows users longing and shorting different asset prices with leverage onchain.
GMX is one of the oldest pure onchain perpetual future market places still running. GMX mainly operates on Arbitrum, but has expanded to include cross-chain functionality. GMX saw a hacking incident in July 2025 from which it recovered.
GMX has its own pools for market making where pools users can provide liquidity and take the other side of the trade. There are GLP vaults in GMX v2 and older GLP vaults in GMX v1. GLV is the index pool of GMX’s markets, rebalancing liquidity to its best-performing GM pools and generating fees from them. As a result, GLV offers liquidity providers a balanced instrument with stable risk-adjusted returns and high capital efficiency.
There are multiple third-party DeFi vaults built on the top of GMX, like Umami’s GM vaults following ERC-4626 standard.
GMX price formation relies on its multi-asset liquidity pool (GLP) and a “virtual” AMM (vAMM) model that uses Chainlink oracles for price data instead of a traditional order book. When users trade, the vAMM calculates the price based on the ratio of assets in the GLP pool, and price feeds from Chainlink ensure accurate pricing for fixed-price trades.
Unlike standard AMMs, GMX’s vAMM shifts risk to liquidity providers (LPs) in the GLP pool, with traders paying a fee that is split between the GMX token holders and the GLP LPs.
More info
GMX Freqtrade and CCXT integration - trade GMX perpetuals using Freqtrade and CCXT
GMX API Module |
|
GMX Core Module |
|
GMX Configuration Module. |
|
GMX Constants Module |
|
GMX Market Depth and Price Impact Analysis Module. |
|
GMX Protocol Contract Infrastructure |
|
GMX Market Data Module |
|
GMX event log decoding and parsing. |
|
GMX Gas Utilities |
|
GMX Protocol Key Generation Functions |
|
GMX order module. |
|
GMX API Retry and Failover Logic |
|
GMX Synthetic token details fetching and caching. |
|
Fork testing helpers for GMX. |
|
GMX Trading Module |
|
GMX protocol type definitions. |
|
GMX Utilities Module. |
|
GMX market data disk cache. |
|
GMX Gas Monitoring Module. |
|
GMX order status tracking. |
|
GMX Price Sanity Check Module. |
|
GMX order execution verification. |
|
GMX market whitelisting for Lagoon vaults. |
|
CCXT-compatible exchange adapter for GMX protocol. |
|
GMX Core Package |
|
GMX GraphQL integration for Subsquid indexer. |
|
GMX trading integration for Lagoon vaults. |
|
GMX onchain data reading. |