gmx.constants

Documentation for eth_defi.gmx.constants Python module.

GMX Constants Module

This module serves as the central registry for all GMX protocol infrastructure constants, including contract addresses, API endpoints, ABIs, and event signatures. It provides a single source of truth for network-specific configuration data that enables the GMX library to operate across multiple blockchain networks.

The constants are organized into several categories:

API Endpoints: Primary and backup URLs for GMX’s REST API services, which provide market data, price feeds, and other off-chain information.

Contract Addresses: On-chain smart contract addresses for core GMX protocol components, organized by blockchain network (Arbitrum and Avalanche).

ABIs (Application Binary Interfaces): Contract interface definitions that enable Python code to interact with deployed smart contracts.

Event Signatures: Cryptographic signatures for important contract events that allow efficient filtering and monitoring of on-chain activity.

This architectural approach allows the same codebase to work across multiple networks by simply selecting the appropriate constants for the target blockchain. The constants are loaded at module import time to ensure consistent configuration throughout the application lifecycle.

Example:

# Access API endpoints for different networks
arbitrum_api = GMX_API_URLS["arbitrum"]
avalanche_api = GMX_API_URLS["avalanche"]

# Get contract addresses for specific operations
reader_address = GMX_READER_ADDRESS["arbitrum"]
exchange_router = GMX_EXCHANGE_ROUTER_ADDRESS["avalanche"]

# Use event signatures for blockchain monitoring
position_event = EVENT_SIGNATURES["IncreasePosition"]

# Load ABI for contract interaction
event_emitter_abi = GMX_EVENT_EMITTER_ABI
Note:

GMX maintains the API endpoints and official documentation can be found at: https://gmx-docs.io/docs/api/rest-v2

Module Attributes

GMX_API_URLS

GMX Is maintaining these APIs and the official documentation can be found here: https://gmx-docs.io/docs/api/rest-v2

GMX_READER_ADDRESS

Smart contract addresses for GMX Reader contracts by network.

GMX_EVENT_EMITTER_ABI

Application Binary Interface (ABI) for the GMX Event Emitter contract.

ETH_ZERO_ADDRESS

Ethereum zero address - used as a placeholder for native token (ETH/AVAX) in GMX protocol

DEFAULT_GAS_WARNING_THRESHOLD_USD

Default warning threshold for low gas balance in USD When balance drops below this value, a warning is logged

DEFAULT_GAS_CRITICAL_THRESHOLD_USD

Default critical threshold for gas balance in USD When balance drops below this value, a critical warning is logged

DEFAULT_GAS_ESTIMATE_BUFFER

Default safety buffer multiplier for gas estimates Applied to raw gas estimate to account for estimation variance

DEFAULT_GAS_MONITOR_ENABLED

Default setting for whether gas monitoring is enabled

DEFAULT_GAS_RAISE_ON_CRITICAL

Default setting for whether to raise an exception on critical gas balance If False, only logs warning instead of raising InsufficientGasError

GMX_MIN_COST_USD

Minimum cost (USD) for GMX orders - GMX protocol minimum is $2 It's not mentioned in the docs but observed from the web UI.

GMX_MIN_DISPLAY_STAKE

Minimum display stake (USD) for leverage tier calculations Used to ensure minimum position sizes in leverage tier max notional calculations

DISK_CACHE_MARKETS_TTL_SECONDS

Disk cache TTL for market metadata - persists across restarts

DISK_CACHE_APY_TTL_SECONDS

Disk cache TTL for APY data - moderate freshness

DEFAULT_MARKET_CACHE_DIR

Default cache directory for market data

Classes

OrderType

GMX order types as IntEnum for type-safe order creation.

GMX_API_URLS: dict = {'arbitrum': 'https://arbitrum-api.gmxinfra.io', 'arbitrum_sepolia': 'https://dolphin-app-a2dup.ondigitalocean.app', 'avalanche': 'https://avalanche-api.gmxinfra.io'}

GMX Is maintaining these APIs and the official documentation can be found here: https://gmx-docs.io/docs/api/rest-v2

GMX_READER_ADDRESS = {'arbitrum': '0x5Ca84c34a381434786738735265b9f3FD814b824', 'avalanche': '0xBAD04dDcc5CC284A86493aFA75D2BEb970C72216'}

Smart contract addresses for GMX Reader contracts by network.

The Reader contract provides optimized read-only access to protocol data, offering batch queries and computed values that would be expensive to calculate on-demand. It acts as a view layer that aggregates information from multiple protocol contracts, providing convenient interfaces for common data access patterns.

Reader contracts are particularly important for user interfaces and analytics systems that need to efficiently query large amounts of protocol data. They implement gas-optimized functions that can return complex data structures in single calls, reducing the number of RPC requests needed for comprehensive protocol state queries.

GMX_EVENT_EMITTER_ABI = [{'inputs': [{'internalType': 'contract RoleStore', 'name': '_roleStore', 'type': 'address'}], 'stateMutability': 'nonpayable', 'type': 'constructor'}, {'inputs': [{'internalType': 'address', 'name': 'msgSender', 'type': 'address'}, {'internalType': 'string', 'name': 'role', 'type': 'string'}], 'name': 'Unauthorized', 'type': 'error'}, {'anonymous': False, 'inputs': [{'indexed': False, 'internalType': 'address', 'name': 'msgSender', 'type': 'address'}, {'indexed': False, 'internalType': 'string', 'name': 'eventName', 'type': 'string'}, {'indexed': True, 'internalType': 'string', 'name': 'eventNameHash', 'type': 'string'}, {'components': [{'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address', 'name': 'value', 'type': 'address'}], 'internalType': 'struct EventUtils.AddressKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address[]', 'name': 'value', 'type': 'address[]'}], 'internalType': 'struct EventUtils.AddressArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.AddressItems', 'name': 'addressItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256', 'name': 'value', 'type': 'uint256'}], 'internalType': 'struct EventUtils.UintKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256[]', 'name': 'value', 'type': 'uint256[]'}], 'internalType': 'struct EventUtils.UintArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.UintItems', 'name': 'uintItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256', 'name': 'value', 'type': 'int256'}], 'internalType': 'struct EventUtils.IntKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256[]', 'name': 'value', 'type': 'int256[]'}], 'internalType': 'struct EventUtils.IntArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.IntItems', 'name': 'intItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool', 'name': 'value', 'type': 'bool'}], 'internalType': 'struct EventUtils.BoolKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool[]', 'name': 'value', 'type': 'bool[]'}], 'internalType': 'struct EventUtils.BoolArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BoolItems', 'name': 'boolItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32', 'name': 'value', 'type': 'bytes32'}], 'internalType': 'struct EventUtils.Bytes32KeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32[]', 'name': 'value', 'type': 'bytes32[]'}], 'internalType': 'struct EventUtils.Bytes32ArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.Bytes32Items', 'name': 'bytes32Items', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes', 'name': 'value', 'type': 'bytes'}], 'internalType': 'struct EventUtils.BytesKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes[]', 'name': 'value', 'type': 'bytes[]'}], 'internalType': 'struct EventUtils.BytesArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BytesItems', 'name': 'bytesItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string', 'name': 'value', 'type': 'string'}], 'internalType': 'struct EventUtils.StringKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string[]', 'name': 'value', 'type': 'string[]'}], 'internalType': 'struct EventUtils.StringArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.StringItems', 'name': 'stringItems', 'type': 'tuple'}], 'indexed': False, 'internalType': 'struct EventUtils.EventLogData', 'name': 'eventData', 'type': 'tuple'}], 'name': 'EventLog', 'type': 'event'}, {'anonymous': False, 'inputs': [{'indexed': False, 'internalType': 'address', 'name': 'msgSender', 'type': 'address'}, {'indexed': False, 'internalType': 'string', 'name': 'eventName', 'type': 'string'}, {'indexed': True, 'internalType': 'string', 'name': 'eventNameHash', 'type': 'string'}, {'indexed': True, 'internalType': 'bytes32', 'name': 'topic1', 'type': 'bytes32'}, {'components': [{'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address', 'name': 'value', 'type': 'address'}], 'internalType': 'struct EventUtils.AddressKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address[]', 'name': 'value', 'type': 'address[]'}], 'internalType': 'struct EventUtils.AddressArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.AddressItems', 'name': 'addressItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256', 'name': 'value', 'type': 'uint256'}], 'internalType': 'struct EventUtils.UintKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256[]', 'name': 'value', 'type': 'uint256[]'}], 'internalType': 'struct EventUtils.UintArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.UintItems', 'name': 'uintItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256', 'name': 'value', 'type': 'int256'}], 'internalType': 'struct EventUtils.IntKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256[]', 'name': 'value', 'type': 'int256[]'}], 'internalType': 'struct EventUtils.IntArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.IntItems', 'name': 'intItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool', 'name': 'value', 'type': 'bool'}], 'internalType': 'struct EventUtils.BoolKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool[]', 'name': 'value', 'type': 'bool[]'}], 'internalType': 'struct EventUtils.BoolArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BoolItems', 'name': 'boolItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32', 'name': 'value', 'type': 'bytes32'}], 'internalType': 'struct EventUtils.Bytes32KeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32[]', 'name': 'value', 'type': 'bytes32[]'}], 'internalType': 'struct EventUtils.Bytes32ArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.Bytes32Items', 'name': 'bytes32Items', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes', 'name': 'value', 'type': 'bytes'}], 'internalType': 'struct EventUtils.BytesKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes[]', 'name': 'value', 'type': 'bytes[]'}], 'internalType': 'struct EventUtils.BytesArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BytesItems', 'name': 'bytesItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string', 'name': 'value', 'type': 'string'}], 'internalType': 'struct EventUtils.StringKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string[]', 'name': 'value', 'type': 'string[]'}], 'internalType': 'struct EventUtils.StringArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.StringItems', 'name': 'stringItems', 'type': 'tuple'}], 'indexed': False, 'internalType': 'struct EventUtils.EventLogData', 'name': 'eventData', 'type': 'tuple'}], 'name': 'EventLog1', 'type': 'event'}, {'anonymous': False, 'inputs': [{'indexed': False, 'internalType': 'address', 'name': 'msgSender', 'type': 'address'}, {'indexed': False, 'internalType': 'string', 'name': 'eventName', 'type': 'string'}, {'indexed': True, 'internalType': 'string', 'name': 'eventNameHash', 'type': 'string'}, {'indexed': True, 'internalType': 'bytes32', 'name': 'topic1', 'type': 'bytes32'}, {'indexed': True, 'internalType': 'bytes32', 'name': 'topic2', 'type': 'bytes32'}, {'components': [{'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address', 'name': 'value', 'type': 'address'}], 'internalType': 'struct EventUtils.AddressKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address[]', 'name': 'value', 'type': 'address[]'}], 'internalType': 'struct EventUtils.AddressArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.AddressItems', 'name': 'addressItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256', 'name': 'value', 'type': 'uint256'}], 'internalType': 'struct EventUtils.UintKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256[]', 'name': 'value', 'type': 'uint256[]'}], 'internalType': 'struct EventUtils.UintArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.UintItems', 'name': 'uintItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256', 'name': 'value', 'type': 'int256'}], 'internalType': 'struct EventUtils.IntKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256[]', 'name': 'value', 'type': 'int256[]'}], 'internalType': 'struct EventUtils.IntArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.IntItems', 'name': 'intItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool', 'name': 'value', 'type': 'bool'}], 'internalType': 'struct EventUtils.BoolKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool[]', 'name': 'value', 'type': 'bool[]'}], 'internalType': 'struct EventUtils.BoolArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BoolItems', 'name': 'boolItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32', 'name': 'value', 'type': 'bytes32'}], 'internalType': 'struct EventUtils.Bytes32KeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32[]', 'name': 'value', 'type': 'bytes32[]'}], 'internalType': 'struct EventUtils.Bytes32ArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.Bytes32Items', 'name': 'bytes32Items', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes', 'name': 'value', 'type': 'bytes'}], 'internalType': 'struct EventUtils.BytesKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes[]', 'name': 'value', 'type': 'bytes[]'}], 'internalType': 'struct EventUtils.BytesArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BytesItems', 'name': 'bytesItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string', 'name': 'value', 'type': 'string'}], 'internalType': 'struct EventUtils.StringKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string[]', 'name': 'value', 'type': 'string[]'}], 'internalType': 'struct EventUtils.StringArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.StringItems', 'name': 'stringItems', 'type': 'tuple'}], 'indexed': False, 'internalType': 'struct EventUtils.EventLogData', 'name': 'eventData', 'type': 'tuple'}], 'name': 'EventLog2', 'type': 'event'}, {'inputs': [{'internalType': 'bytes32', 'name': 'topic1', 'type': 'bytes32'}, {'internalType': 'bytes', 'name': 'data', 'type': 'bytes'}], 'name': 'emitDataLog1', 'outputs': [], 'stateMutability': 'nonpayable', 'type': 'function'}, {'inputs': [{'internalType': 'bytes32', 'name': 'topic1', 'type': 'bytes32'}, {'internalType': 'bytes32', 'name': 'topic2', 'type': 'bytes32'}, {'internalType': 'bytes', 'name': 'data', 'type': 'bytes'}], 'name': 'emitDataLog2', 'outputs': [], 'stateMutability': 'nonpayable', 'type': 'function'}, {'inputs': [{'internalType': 'bytes32', 'name': 'topic1', 'type': 'bytes32'}, {'internalType': 'bytes32', 'name': 'topic2', 'type': 'bytes32'}, {'internalType': 'bytes32', 'name': 'topic3', 'type': 'bytes32'}, {'internalType': 'bytes', 'name': 'data', 'type': 'bytes'}], 'name': 'emitDataLog3', 'outputs': [], 'stateMutability': 'nonpayable', 'type': 'function'}, {'inputs': [{'internalType': 'bytes32', 'name': 'topic1', 'type': 'bytes32'}, {'internalType': 'bytes32', 'name': 'topic2', 'type': 'bytes32'}, {'internalType': 'bytes32', 'name': 'topic3', 'type': 'bytes32'}, {'internalType': 'bytes32', 'name': 'topic4', 'type': 'bytes32'}, {'internalType': 'bytes', 'name': 'data', 'type': 'bytes'}], 'name': 'emitDataLog4', 'outputs': [], 'stateMutability': 'nonpayable', 'type': 'function'}, {'inputs': [{'internalType': 'string', 'name': 'eventName', 'type': 'string'}, {'components': [{'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address', 'name': 'value', 'type': 'address'}], 'internalType': 'struct EventUtils.AddressKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address[]', 'name': 'value', 'type': 'address[]'}], 'internalType': 'struct EventUtils.AddressArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.AddressItems', 'name': 'addressItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256', 'name': 'value', 'type': 'uint256'}], 'internalType': 'struct EventUtils.UintKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256[]', 'name': 'value', 'type': 'uint256[]'}], 'internalType': 'struct EventUtils.UintArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.UintItems', 'name': 'uintItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256', 'name': 'value', 'type': 'int256'}], 'internalType': 'struct EventUtils.IntKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256[]', 'name': 'value', 'type': 'int256[]'}], 'internalType': 'struct EventUtils.IntArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.IntItems', 'name': 'intItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool', 'name': 'value', 'type': 'bool'}], 'internalType': 'struct EventUtils.BoolKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool[]', 'name': 'value', 'type': 'bool[]'}], 'internalType': 'struct EventUtils.BoolArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BoolItems', 'name': 'boolItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32', 'name': 'value', 'type': 'bytes32'}], 'internalType': 'struct EventUtils.Bytes32KeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32[]', 'name': 'value', 'type': 'bytes32[]'}], 'internalType': 'struct EventUtils.Bytes32ArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.Bytes32Items', 'name': 'bytes32Items', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes', 'name': 'value', 'type': 'bytes'}], 'internalType': 'struct EventUtils.BytesKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes[]', 'name': 'value', 'type': 'bytes[]'}], 'internalType': 'struct EventUtils.BytesArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BytesItems', 'name': 'bytesItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string', 'name': 'value', 'type': 'string'}], 'internalType': 'struct EventUtils.StringKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string[]', 'name': 'value', 'type': 'string[]'}], 'internalType': 'struct EventUtils.StringArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.StringItems', 'name': 'stringItems', 'type': 'tuple'}], 'internalType': 'struct EventUtils.EventLogData', 'name': 'eventData', 'type': 'tuple'}], 'name': 'emitEventLog', 'outputs': [], 'stateMutability': 'nonpayable', 'type': 'function'}, {'inputs': [{'internalType': 'string', 'name': 'eventName', 'type': 'string'}, {'internalType': 'bytes32', 'name': 'topic1', 'type': 'bytes32'}, {'components': [{'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address', 'name': 'value', 'type': 'address'}], 'internalType': 'struct EventUtils.AddressKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address[]', 'name': 'value', 'type': 'address[]'}], 'internalType': 'struct EventUtils.AddressArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.AddressItems', 'name': 'addressItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256', 'name': 'value', 'type': 'uint256'}], 'internalType': 'struct EventUtils.UintKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256[]', 'name': 'value', 'type': 'uint256[]'}], 'internalType': 'struct EventUtils.UintArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.UintItems', 'name': 'uintItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256', 'name': 'value', 'type': 'int256'}], 'internalType': 'struct EventUtils.IntKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256[]', 'name': 'value', 'type': 'int256[]'}], 'internalType': 'struct EventUtils.IntArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.IntItems', 'name': 'intItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool', 'name': 'value', 'type': 'bool'}], 'internalType': 'struct EventUtils.BoolKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool[]', 'name': 'value', 'type': 'bool[]'}], 'internalType': 'struct EventUtils.BoolArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BoolItems', 'name': 'boolItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32', 'name': 'value', 'type': 'bytes32'}], 'internalType': 'struct EventUtils.Bytes32KeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32[]', 'name': 'value', 'type': 'bytes32[]'}], 'internalType': 'struct EventUtils.Bytes32ArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.Bytes32Items', 'name': 'bytes32Items', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes', 'name': 'value', 'type': 'bytes'}], 'internalType': 'struct EventUtils.BytesKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes[]', 'name': 'value', 'type': 'bytes[]'}], 'internalType': 'struct EventUtils.BytesArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BytesItems', 'name': 'bytesItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string', 'name': 'value', 'type': 'string'}], 'internalType': 'struct EventUtils.StringKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string[]', 'name': 'value', 'type': 'string[]'}], 'internalType': 'struct EventUtils.StringArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.StringItems', 'name': 'stringItems', 'type': 'tuple'}], 'internalType': 'struct EventUtils.EventLogData', 'name': 'eventData', 'type': 'tuple'}], 'name': 'emitEventLog1', 'outputs': [], 'stateMutability': 'nonpayable', 'type': 'function'}, {'inputs': [{'internalType': 'string', 'name': 'eventName', 'type': 'string'}, {'internalType': 'bytes32', 'name': 'topic1', 'type': 'bytes32'}, {'internalType': 'bytes32', 'name': 'topic2', 'type': 'bytes32'}, {'components': [{'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address', 'name': 'value', 'type': 'address'}], 'internalType': 'struct EventUtils.AddressKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'address[]', 'name': 'value', 'type': 'address[]'}], 'internalType': 'struct EventUtils.AddressArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.AddressItems', 'name': 'addressItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256', 'name': 'value', 'type': 'uint256'}], 'internalType': 'struct EventUtils.UintKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'uint256[]', 'name': 'value', 'type': 'uint256[]'}], 'internalType': 'struct EventUtils.UintArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.UintItems', 'name': 'uintItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256', 'name': 'value', 'type': 'int256'}], 'internalType': 'struct EventUtils.IntKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'int256[]', 'name': 'value', 'type': 'int256[]'}], 'internalType': 'struct EventUtils.IntArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.IntItems', 'name': 'intItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool', 'name': 'value', 'type': 'bool'}], 'internalType': 'struct EventUtils.BoolKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bool[]', 'name': 'value', 'type': 'bool[]'}], 'internalType': 'struct EventUtils.BoolArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BoolItems', 'name': 'boolItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32', 'name': 'value', 'type': 'bytes32'}], 'internalType': 'struct EventUtils.Bytes32KeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes32[]', 'name': 'value', 'type': 'bytes32[]'}], 'internalType': 'struct EventUtils.Bytes32ArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.Bytes32Items', 'name': 'bytes32Items', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes', 'name': 'value', 'type': 'bytes'}], 'internalType': 'struct EventUtils.BytesKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'bytes[]', 'name': 'value', 'type': 'bytes[]'}], 'internalType': 'struct EventUtils.BytesArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.BytesItems', 'name': 'bytesItems', 'type': 'tuple'}, {'components': [{'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string', 'name': 'value', 'type': 'string'}], 'internalType': 'struct EventUtils.StringKeyValue[]', 'name': 'items', 'type': 'tuple[]'}, {'components': [{'internalType': 'string', 'name': 'key', 'type': 'string'}, {'internalType': 'string[]', 'name': 'value', 'type': 'string[]'}], 'internalType': 'struct EventUtils.StringArrayKeyValue[]', 'name': 'arrayItems', 'type': 'tuple[]'}], 'internalType': 'struct EventUtils.StringItems', 'name': 'stringItems', 'type': 'tuple'}], 'internalType': 'struct EventUtils.EventLogData', 'name': 'eventData', 'type': 'tuple'}], 'name': 'emitEventLog2', 'outputs': [], 'stateMutability': 'nonpayable', 'type': 'function'}, {'inputs': [], 'name': 'roleStore', 'outputs': [{'internalType': 'contract RoleStore', 'name': '', 'type': 'address'}], 'stateMutability': 'view', 'type': 'function'}]

Application Binary Interface (ABI) for the GMX Event Emitter contract.

The ABI defines the contract’s interface, including function signatures, event definitions, and data types. This allows Python code to properly encode function calls and decode contract responses when interacting with the deployed Event Emitter contracts on different blockchain networks.

The Event Emitter ABI includes definitions for all events that the contract can emit, such as position updates, liquidations, and funding rate changes. This information is essential for parsing event logs and building event monitoring systems that react to protocol state changes.

ETH_ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'

Ethereum zero address - used as a placeholder for native token (ETH/AVAX) in GMX protocol

class OrderType

Bases: enum.IntEnum

GMX order types as IntEnum for type-safe order creation.

  • MARKET_SWAP (0): Immediate token swap at market price

  • LIMIT_SWAP (1): Token swap at specified limit price

  • MARKET_INCREASE (2): Open/increase position at market price

  • LIMIT_INCREASE (3): Open/increase position at limit price

  • MARKET_DECREASE (4): Close/decrease position at market price

  • LIMIT_DECREASE (5): Take Profit - triggers when price reaches target

  • STOP_LOSS_DECREASE (6): Stop Loss - triggers when price hits stop level

  • LIQUIDATION (7): Forced position liquidation

__init__(*args, **kwds)
__new__(value)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

denominator

the denominator of a rational number in lowest terms

from_bytes(byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

imag

the imaginary part of a complex number

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

DEFAULT_GAS_WARNING_THRESHOLD_USD = 1.0

Default warning threshold for low gas balance in USD When balance drops below this value, a warning is logged

DEFAULT_GAS_CRITICAL_THRESHOLD_USD = 0.5

Default critical threshold for gas balance in USD When balance drops below this value, a critical warning is logged

DEFAULT_GAS_ESTIMATE_BUFFER = 1.2

Default safety buffer multiplier for gas estimates Applied to raw gas estimate to account for estimation variance

DEFAULT_GAS_MONITOR_ENABLED = True

Default setting for whether gas monitoring is enabled

DEFAULT_GAS_RAISE_ON_CRITICAL = False

Default setting for whether to raise an exception on critical gas balance If False, only logs warning instead of raising InsufficientGasError

GMX_MIN_COST_USD = 2

Minimum cost (USD) for GMX orders - GMX protocol minimum is $2 It’s not mentioned in the docs but observed from the web UI. https://app.gmx.io/#/trade

GMX_MIN_DISPLAY_STAKE = 20.0

Minimum display stake (USD) for leverage tier calculations Used to ensure minimum position sizes in leverage tier max notional calculations

DISK_CACHE_MARKETS_TTL_SECONDS = 3600

Disk cache TTL for market metadata - persists across restarts

DISK_CACHE_APY_TTL_SECONDS = 300

Disk cache TTL for APY data - moderate freshness

DEFAULT_MARKET_CACHE_DIR = '~/.cache/web3-ethereum-defi/gmx'

Default cache directory for market data