GMXSyntheticTokenDetails

Documentation for eth_defi.gmx.synthetic_tokens.GMXSyntheticTokenDetails Python class.

class GMXSyntheticTokenDetails

Bases: object

GMX 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

symbol

Token symbol e.g.

address

Token contract address

decimals

Number of decimals for the token

chain_id

Chain ID where this token exists

extra_data

Extra metadata for caching and other purposes

address_lower

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

extra_data: dict[str, Any]

Extra metadata for caching and other purposes

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

decimal.Decimal

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

int

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.

Parameters
  • chain_id (int) – Blockchain chain ID

  • symbol (str) – Token symbol

Returns

Cache key string in format “gmx-{chain_id}-{symbol_lower}”

Return type

str

export()

Export token details as serializable dictionary.

Useful for saving to disk cache or API responses.

Returns

dictionary with all token information

Return type

dict[str, Any]

__init__(symbol, address, decimals, chain_id, extra_data=<factory>)
Parameters
Return type

None