GMXSyntheticTokenDetails
Documentation for eth_defi.gmx.synthetic_tokens.GMXSyntheticTokenDetails Python class.
- class GMXSyntheticTokenDetails
Bases:
objectGMX Synthetic token Python representation.
A helper class to work with GMX synthetic tokens from their API. Similar to TokenDetails but designed for GMX API data structure.
Example usage:
# Fetch all GMX tokens for Arbitrum tokens = fetch_gmx_synthetic_tokens(chain_id=42161) usdc_token = next(t for t in tokens if t.symbol == "USDC") print(f"USDC address on Arbitrum: {usdc_token.address}")
Key differences from ERC-20 TokenDetails: - No web3 contract instance needed - Data comes from API, not blockchain calls - Simpler structure (no name or total_supply from API)
Attributes summary
Token symbol e.g.
Token contract address
Number of decimals for the token
Chain ID where this token exists
Extra metadata for caching and other purposes
Get the lowercase version of the address.
Methods summary
__init__(symbol, address, decimals, chain_id)convert_to_decimals(raw_amount)Convert raw token units to decimal representation.
convert_to_raw(decimal_amount)Convert decimal token amount to raw integer units.
export()Export token details as serializable dictionary.
generate_cache_key(chain_id, symbol)Generate cache key for GMX token.
- symbol: str
Token symbol e.g. “USDC”, “ETH”
- address: eth_typing.evm.HexAddress
Token contract address
- decimals: int
Number of decimals for the token
- chain_id: int
Chain ID where this token exists
- property address_lower: str
Get the lowercase version of the address.
- convert_to_decimals(raw_amount)
Convert raw token units to decimal representation.
- Parameters
raw_amount (int) – Raw token amount as integer
- Returns
Decimal representation of the amount
- Return type
- Example:
If token has 6 decimals, converts 1000000 -> 1.0
- convert_to_raw(decimal_amount)
Convert decimal token amount to raw integer units.
- Parameters
decimal_amount (decimal.Decimal) – Decimal amount
- Returns
Raw token amount as integer
- Return type
- Example:
If token has 6 decimals, converts 1.0 -> 1000000
- static generate_cache_key(chain_id, symbol)
Generate cache key for GMX token.
We cache by (chain_id, symbol) since GMX API gives us symbol-based data. This is different from ERC-20 caching which uses address.
- export()
Export token details as serializable dictionary.
Useful for saving to disk cache or API responses.