gmx.vault_sync

Documentation for eth_defi.gmx.vault_sync Python module.

Synchronise the onchain GMX V2 catalogue into the common vault database.

Module Attributes

GMX_DISABLED_DEPOSIT_REASON

Deposit-closure reason exported for disabled GMX products.

GMX_PRODUCT_FEATURES

Features that identify GMX products in persisted metadata.

GMX_NAME_COLLISION_SIZE

Number of equal candidate names required before adding an address suffix.

GMX_ZERO_ADDRESS

GMX Reader uses this value for the absent index token of a swap-only pool.

GMX_INDEX_MARKET_LABEL_OVERRIDES

Special GMX index labels whose market identity differs from the token-registry symbol.

GMX_TRADFI_INDEX_MARKETS

GMX index markets tracking a real-world commodity, equity or financial index.

Functions

fetch_and_sync_gmx_vault_catalogue(*, web3, ...)

Upsert GM and GLV products without disturbing unrelated vault rows.

mark_gmx_vault_rows_amm_pool_like(vault_db, ...)

Add the AMM-pool marker to every persisted GMX vault in selected chains.

Classes

GMXVaultCatalogueSyncResult

Summarise one GMX metadata reconciliation.

GMX_DISABLED_DEPOSIT_REASON: str = 'GMX product disabled'

Deposit-closure reason exported for disabled GMX products.

GMX_PRODUCT_FEATURES: frozenset[eth_defi.erc_4626.core.ERC4626Feature] = frozenset({<ERC4626Feature.gmx_gm: 'gmx_gm'>, <ERC4626Feature.gmx_glv: 'gmx_glv'>})

Features that identify GMX products in persisted metadata.

GMX_NAME_COLLISION_SIZE: int = 2

Number of equal candidate names required before adding an address suffix.

GMX_ZERO_ADDRESS: eth_typing.evm.HexAddress = '0x0000000000000000000000000000000000000000'

GMX Reader uses this value for the absent index token of a swap-only pool.

GMX_INDEX_MARKET_LABEL_OVERRIDES: dict[str, str] = {'0x0cf1fb4d1ff67a3d8ca92c9d6643f8f9be8e03e5': 'wstETH/USD'}

Special GMX index labels whose market identity differs from the token-registry symbol.

GMX_TRADFI_INDEX_MARKETS: frozenset[str] = frozenset({'BRENTOIL/USD', 'GOLD/USD', 'NATGAS/USD', 'QQQ/USD', 'SILVER/USD', 'SPCX/USD', 'SPY/USD', 'WTIOIL/USD'})

GMX index markets tracking a real-world commodity, equity or financial index.

class GMXVaultCatalogueSyncResult

Bases: object

Summarise one GMX metadata reconciliation.

Separates the complete current catalogue size from newly inserted and refreshed rows for scanner diagnostics.

products: int

Number of GM and GLV products returned by GMX.

inserted: int

Number of products newly inserted into the common vault database.

updated: int

Number of existing products refreshed in the common vault database.

__init__(products, inserted, updated)
Parameters
  • products (int) –

  • inserted (int) –

  • updated (int) –

Return type

None

mark_gmx_vault_rows_amm_pool_like(vault_db, *, chain_ids)

Add the AMM-pool marker to every persisted GMX vault in selected chains.

The onchain catalogue can no longer return delisted GMX products, while their historical rows remain in the common database. This metadata-only repair therefore examines all retained rows rather than only the current catalogue and preserves the top-level and detection feature copies in lockstep.

Parameters
Returns

Number of stored GMX rows changed.

Return type

int

fetch_and_sync_gmx_vault_catalogue(*, web3, vault_db, token_cache, block_number=None, max_workers=8)

Upsert GM and GLV products without disturbing unrelated vault rows.

New products record the block at which this catalogue first observes them.

Parameters
  • web3 (web3.main.Web3) – Arbitrum One or Avalanche connection.

  • vault_db (eth_defi.vault.vaultdb.VaultDatabase) – Existing common metadata database to update in memory.

  • token_cache (eth_defi.token.TokenDiskCache) – Shared ERC-20 metadata cache.

  • block_number (Optional[int]) – Optional fixed catalogue block; defaults to the latest head.

  • max_workers (int) – Maximum metadata-read worker threads.

Returns

Product, insertion and update counts.

Return type

eth_defi.gmx.vault_sync.GMXVaultCatalogueSyncResult