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

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

eth_defi.gmx.api

GMX API Module

eth_defi.gmx.base

GMX Core Module

eth_defi.gmx.config

GMX Configuration Module.

eth_defi.gmx.constants

GMX Constants Module

eth_defi.gmx.contracts

GMX Protocol Contract Infrastructure

eth_defi.gmx.data

GMX Market Data Module

eth_defi.gmx.events

GMX event log decoding and parsing.

eth_defi.gmx.gas_utils

GMX Gas Utilities

eth_defi.gmx.keys

GMX Protocol Key Generation Functions

eth_defi.gmx.order

GMX Order Module

eth_defi.gmx.retry

GMX API Retry and Failover Logic

eth_defi.gmx.synthetic_tokens

GMX Synthetic token details fetching and caching.

eth_defi.gmx.testing

eth_defi.gmx.trading

GMX Trading Module

eth_defi.gmx.types

GMX protocol type definitions.

eth_defi.gmx.utils

GMX Utilities Module.