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_API_V2_URLS

REST API v2 endpoint URLs for GMX protocol services by blockchain network.

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.

PRECISION

GMX uses 30-decimal fixed-point arithmetic throughout the protocol.

WEI_PER_ETH

Wei per ETH — used to convert raw Wei balances to ETH floats.

GMX_DEFAULT_SEARCH_MAX_USD

Default upper bound for the binary-search in find_max_position_size().

ETH_ZERO_ADDRESS

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

GMX_MAINNET_CHAINS

Production (mainnet) chain names supported by the GMX protocol integration.

GMX_TESTNET_CHAINS

Testnet chain names supported by the GMX protocol integration.

GMX_SUPPORTED_CHAINS

All chain names supported by the GMX protocol integration (mainnet + testnet).

CANCEL_ORDER_GAS_LIMIT

Gas limit per cancel order call.

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 order/position size (USD) on GMX — the protocol rejects orders below this.

GMX_MIN_LIQUIDATION_COLLATERAL_USD

Minimum liquidation collateral threshold (USD) used by the GMX protocol.

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

SUBSQUID_ORDER_TRACKING_TIMEOUT

Subsquid retry configuration for order tracking

DEFAULT_EXECUTION_BUFFER

Default execution-fee buffer multiplier for standard orders (increase, decrease, swap).

DEFAULT_SLTP_EXECUTION_BUFFER

Default execution-fee buffer for bundled SL/TP multicall transactions, which include multiple sub-orders and therefore need a higher margin.

DEFAULT_SLTP_EXECUTION_FEE_BUFFER

Additional fee-buffer multiplier applied to the individual SL/TP sub-orders within a bundled multicall on top of DEFAULT_SLTP_EXECUTION_BUFFER.

EXECUTION_BUFFER_CRITICAL_THRESHOLD

Execution buffer below this value triggers a critical error log.

EXECUTION_BUFFER_WARNING_THRESHOLD

Execution buffer below this value triggers a warning log.

EXECUTION_BUFFER_RECOMMENDED_MIN

Lower bound of the recommended execution-buffer range for standard orders.

EXECUTION_BUFFER_RECOMMENDED_MAX

Upper bound of the recommended execution-buffer range for standard orders.

EXECUTION_BUFFER_TESTNET

Execution-fee buffer multiplier for testnet (Arbitrum Sepolia).

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_API_V2_URLS: dict[str, str] = {'arbitrum': 'https://gmx-api-arbitrum-2nlbk.ondigitalocean.app/api/v1', 'avalanche': 'https://gmx-api-avalanche-vxjas.ondigitalocean.app/api/v1'}

REST API v2 endpoint URLs for GMX protocol services by blockchain network.

These endpoints provide access to newer GMX REST API v2 services hosted on DigitalOcean, including positions, orders, funding/borrowing rates, OHLCV candles with flexible since parameter, token info, and trading pairs.

The v2 base URL path includes /api/v1 as part of the base — endpoint paths are appended directly (e.g. /positions, /orders).

Note

v1 endpoints (GMX_API_URLS) remain the primary source for tickers, signed prices, markets, and APY data. v2 endpoints expose additional surfaces not available in v1.

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.

PRECISION = 30

GMX uses 30-decimal fixed-point arithmetic throughout the protocol. All OI, liquidity, rate, and price-impact values returned by the REST API and DataStore contract are integers scaled by 10 ** PRECISION. Divide by 10 ** PRECISION to convert to plain USD / dimensionless floats.

Reference: https://github.com/gmx-io/gmx-synthetics/blob/main/contracts/utils/Precision.sol

WEI_PER_ETH: int = 1000000000000000000

Wei per ETH — used to convert raw Wei balances to ETH floats.

GMX_DEFAULT_SEARCH_MAX_USD: float = 100000000.0

Default upper bound for the binary-search in find_max_position_size(). Covers typical GMX market sizes; overridden by max_oi_available_usd when provided.

ETH_ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'

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

GMX_MAINNET_CHAINS: tuple[str, ...] = ('arbitrum', 'avalanche')

Production (mainnet) chain names supported by the GMX protocol integration.

GMX_TESTNET_CHAINS: tuple[str, ...] = ('arbitrum_sepolia', 'avalanche_fuji')

Testnet chain names supported by the GMX protocol integration.

These chains use elevated execution-fee buffers and alternative API endpoints.

GMX_SUPPORTED_CHAINS: tuple[str, ...] = ('arbitrum', 'avalanche', 'arbitrum_sepolia', 'avalanche_fuji')

All chain names supported by the GMX protocol integration (mainnet + testnet).

Used for validation in the CCXT adapter, Freqtrade exchange class, and other entry points that accept a chain name string.

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.

CANCEL_ORDER_GAS_LIMIT: int = 2000000

Gas limit per cancel order call.

GMX’s OrderUtils.cancelOrder checks gasleft() >= minHandleExecutionErrorGas at the start of execution. On Arbitrum mainnet, minHandleExecutionErrorGas is stored in the DataStore at 1,200,000 gas. With multicall overhead and the EVM’s 63/64 gas-forwarding rule, the transaction must provide enough gas that at least 1,200,000 gas units remain when the check runs. Empirically, a 700,000 gas limit leaves only ~438,308 gas at the check point, triggering InsufficientGasForCancellation(438308, 1200000).

Applied per order in both single and batch cancellations; for a batch of N orders the total gas is CANCEL_ORDER_GAS_LIMIT * N.

Reference: https://github.com/gmx-io/gmx-synthetics/blob/main/contracts/order/OrderUtils.sol

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 order/position size (USD) on GMX — the protocol rejects orders below this. Observed from the GMX web UI: https://app.gmx.io/#/trade

GMX_MIN_LIQUIDATION_COLLATERAL_USD = 5.0

Minimum liquidation collateral threshold (USD) used by the GMX protocol. GMX liquidates a position when remaining collateral falls below max(position_size_usd * 0.005, GMX_MIN_LIQUIDATION_COLLATERAL_USD). This is a separate protocol constant from the minimum position size (GMX_MIN_COST_USD). For positions smaller than ~$1000, this $5 floor dominates the 0.5% term.

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 = '~/.tradingstrategy/cache/gmx'

Default cache directory for market data

SUBSQUID_ORDER_TRACKING_TIMEOUT = 10

Subsquid retry configuration for order tracking

DEFAULT_EXECUTION_BUFFER: float = 2.2

Default execution-fee buffer multiplier for standard orders (increase, decrease, swap). The estimated fee is multiplied by this value so that keepers are covered even during gas-price spikes. Any excess is refunded by GMX.

DEFAULT_SLTP_EXECUTION_BUFFER: float = 2.5

Default execution-fee buffer for bundled SL/TP multicall transactions, which include multiple sub-orders and therefore need a higher margin.

DEFAULT_SLTP_EXECUTION_FEE_BUFFER: float = 1.0

Additional fee-buffer multiplier applied to the individual SL/TP sub-orders within a bundled multicall on top of DEFAULT_SLTP_EXECUTION_BUFFER. Set to 1.0 (no compounding) to match GMX interface behaviour — the UI applies a single executionFeeBufferBps (30 %) to all order types uniformly.

EXECUTION_BUFFER_CRITICAL_THRESHOLD: float = 1.2

Execution buffer below this value triggers a critical error log. GMX keepers will very likely reject orders with a buffer this low.

EXECUTION_BUFFER_WARNING_THRESHOLD: float = 1.5

Execution buffer below this value triggers a warning log. Orders may fail during gas-price spikes.

Lower bound of the recommended execution-buffer range for standard orders.

Upper bound of the recommended execution-buffer range for standard orders. Equals DEFAULT_EXECUTION_BUFFER.

EXECUTION_BUFFER_TESTNET: float = 5.0

Execution-fee buffer multiplier for testnet (Arbitrum Sepolia).

Testnet gas estimation is less reliable than mainnet, requiring a higher buffer to avoid reverts. The standard DEFAULT_EXECUTION_BUFFER (2.2×) is insufficient — observed reverts on Arbitrum Sepolia. 5× ensures reliable execution; GMX refunds any excess.