create_gmx_config_with_fallback

Documentation for eth_defi.gmx.config.create_gmx_config_with_fallback function.

create_gmx_config_with_fallback(rpc_configuration, user_wallet_address=None, wallet=None, fallback_sleep=5.0, fallback_backoff=1.25, retries=6, require_multiple_providers=False)

Create a GMXConfig with multi-provider fallback support.

This factory function creates a GMXConfig instance backed by a MultiProviderWeb3 connection, providing automatic failover between multiple RPC endpoints for improved reliability in production.

The configuration line supports multiple RPC URLs separated by spaces or newlines. URLs prefixed with mev+ are used for transaction broadcasting (MEV protection).

Example:

from eth_defi.gmx.config import create_gmx_config_with_fallback

# Multiple providers for resilience
config = create_gmx_config_with_fallback(
    rpc_configuration="https://arb1.arbitrum.io/rpc https://arbitrum-one-rpc.publicnode.com",
    user_wallet_address="0x...",
    require_multiple_providers=True,
)
Parameters
  • rpc_configuration (str) – Space or newline separated list of RPC URLs. URLs prefixed with mev+ are used for MEV-protected transaction broadcasting.

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

  • wallet – Optional HotWallet instance for transaction signing.

  • fallback_sleep (float) – Seconds between JSON-RPC call retries.

  • fallback_backoff (float) – Sleep increase multiplier for retries.

  • retries (int) – Number of retry attempts before failing.

  • require_multiple_providers (bool) – If True, raises ValueError when fewer than 2 providers configured.

Returns

GMXConfig instance backed by MultiProviderWeb3.

Raises

ValueError – If require_multiple_providers is True and fewer than 2 providers are configured.

Return type

eth_defi.gmx.config.GMXConfig