GMXConfig

Documentation for eth_defi.gmx.config.GMXConfig Python class.

class GMXConfig

Bases: object

Production-grade configuration management system for secure GMX protocol integration.

This class provides the stable, production-ready implementation of configuration management that powers real trading systems and financial applications. It implements automatic network detection, universal wallet compatibility, and comprehensive security controls while maintaining the simplicity and reliability required for production deployment.

The production implementation prioritizes operational reliability, security isolation, and automatic error prevention. Network parameters are detected automatically to eliminate configuration errors, wallet integration uses secure adapter patterns to preserve individual security models, and comprehensive validation prevents common operational pitfalls.

The configuration system implements strict security boundaries between read and write operations. Read configurations provide safe data access without any exposure to sensitive credentials, while write configurations implement secure credential delegation through validated adapter interfaces.

Production systems require configuration management that operates predictably under all conditions. This implementation includes comprehensive error handling, automatic parameter validation, and clear diagnostic information to enable rapid troubleshooting and reliable operation.

Modern financial applications must support diverse wallet implementations to accommodate different security requirements and operational preferences. The configuration system provides seamless integration with any BaseWallet- compatible implementation while preserving the unique capabilities of each wallet type.

Variables
  • web3 (Web3) – Web3 instance providing blockchain connectivity and network context

  • chain (str) – Automatically detected blockchain network identifier

Initialize GMX configuration with automatic network detection.

Automatically detects blockchain network parameters from Web3 connections. Follows the transaction-building pattern where transactions are prepared separately from signing.

Parameters
  • web3 – Web3 instance connected to the target blockchain network

  • user_wallet_address – Optional wallet address for operations

  • wallet – Optional HotWallet instance for transaction signing (used by CCXT wrapper)

Raises

AssertionError – When the Web3 connection targets an unsupported blockchain network or automatic network detection fails due to connectivity issues

Methods summary

__init__(web3[, user_wallet_address, wallet])

Initialize GMX configuration with automatic network detection.

get_chain()

Retrieve the automatically detected blockchain network identifier.

get_config()

Get the configuration manager for GMX operations.

get_network_info()

Provide comprehensive network configuration information for operational monitoring.

get_wallet_address()

Retrieve the wallet address associated with this configuration.

has_write_capability()

Check if a wallet address is configured.

__init__(web3, user_wallet_address=None, wallet=None)

Initialize GMX configuration with automatic network detection.

Automatically detects blockchain network parameters from Web3 connections. Follows the transaction-building pattern where transactions are prepared separately from signing.

Parameters
  • web3 (web3.main.Web3) – Web3 instance connected to the target blockchain network

  • user_wallet_address (Optional[str]) – Optional wallet address for operations

  • wallet – Optional HotWallet instance for transaction signing (used by CCXT wrapper)

Raises

AssertionError – When the Web3 connection targets an unsupported blockchain network or automatic network detection fails due to connectivity issues

get_config()

Get the configuration manager for GMX operations.

Returns the configuration manager that can be used with GMX protocol classes for transaction preparation and data access.

Returns

GMXConfigManager instance configured for the current chain

Return type

eth_defi.gmx.config.GMXConfigManager

has_write_capability()

Check if a wallet address is configured.

Since transaction signing is handled separately, this simply checks if a user wallet address has been provided for transaction building.

Returns

True if wallet address is configured, False otherwise

Return type

bool

get_chain()

Retrieve the automatically detected blockchain network identifier.

This method returns the network name that was automatically detected from the Web3 connection during configuration initialization. Automatic detection ensures operational consistency and eliminates network configuration errors in production deployments.

Automatic network detection prevents configuration mismatches that could cause operational failures or financial losses in production trading systems and financial applications.

Returns

Blockchain network identifier automatically detected from Web3 connection, ensuring operational consistency and reliability

Return type

str

get_wallet_address()

Retrieve the wallet address associated with this configuration.

This method returns the Ethereum address that will be used for transaction operations when write capabilities are available. The address may be explicitly specified or automatically derived from wallet implementations using production-tested resolution logic.

The configuration system implements reliable address resolution that prioritizes explicit specifications while providing secure fallbacks to wallet-derived addresses when appropriate for production operation.

Returns

Ethereum wallet address in standard format, or None when the configuration operates in read-only mode without transaction capabilities

Return type

Optional[str]

get_network_info()

Provide comprehensive network configuration information for operational monitoring.

This method returns detailed information about blockchain network configuration including automatically detected parameters, connectivity details, and validation status. The information supports operational monitoring, debugging, and validation in production environments.

The network information includes all parameters necessary for operational monitoring systems to validate connectivity, track network status, and diagnose operational issues in production deployments.

Returns

Dictionary containing comprehensive network configuration including automatically detected chain identifier, RPC endpoint information, and blockchain-specific parameters

Return type

dict[str, Any]