fetch_gmx_synthetic_tokens
Documentation for eth_defi.gmx.synthetic_tokens.fetch_gmx_synthetic_tokens function.
- fetch_gmx_synthetic_tokens(chain_id, cache=LRUCache({}, maxsize=512, currsize=0), timeout=10.0, force_refresh=False, max_retries=2, retry_delay=0.1)
Fetch GMX synthetic token details from API with caching and retry logic.
This function fetches all available GMX synthetic tokens for a given chain and caches the results to avoid repeated API calls. It implements retry logic with exponential backoff and automatic failover to backup API endpoints.
- Parameters
chain_id (int) – Blockchain chain ID (42161 for Arbitrum, 43114 for Avalanche)
cache (Optional[cachetools.Cache]) – Cache instance to use. Set to None to disable caching
timeout (float) – HTTP request timeout in seconds
force_refresh (bool) – If True, bypass cache and fetch fresh data
max_retries (int) – Maximum number of retry attempts per endpoint (default: 2)
retry_delay (float) – Initial delay between retries in seconds with exponential backoff (default: 0.1s, resulting in 0.1s, 0.2s delays)
- Returns
list of GMXSyntheticTokenDetails objects
- Raises
GMXTokenFetchError – If API request fails on both primary and backup
ValueError – If chain_id is not supported
- Return type
list[eth_defi.gmx.synthetic_tokens.GMXSyntheticTokenDetails]
Example:
# Fetch Arbitrum GMX tokens with automatic retry and failover tokens = fetch_gmx_synthetic_tokens(chain_id=42161)