gmx.historical_oracle
Documentation for eth_defi.gmx.historical_oracle Python module.
Read GMX V2 liquidity-provider value-and-supply events.
The ratio of value to corresponding supply provides a sparse USD share-price
equivalent without treating a change in TVL or share count as profit. GM emits
MarketPoolValueUpdated after a deposit and GLV emits GlvValueUpdated
after execution. GM withdrawal observations are deliberately excluded because
GMX values deposits and withdrawals with different PnL-factor contexts. The
common vault scanner later applies its normal change threshold.
Module Attributes
GMX EventEmitter event names containing matched value and supply. |
|
|
|
Non-indexed |
Functions
Decode the GMX |
|
|
Encode an EVM address as a GMX |
Convert a GMX value event into a share-price observation. |
|
Fetch GM and GLV value-and-supply observations. |
Classes
One GM or GLV value-and-supply observation. |
- GMX_SHARE_PRICE_EVENT_NAMES: tuple[str, ...] = ('MarketPoolValueUpdated', 'GlvValueUpdated')
GMX EventEmitter event names containing matched value and supply.
- GMX_DEPOSIT_ACTION_TYPE: bytes = b'`y\x91\xfcYc\xe2d\xf1\xa9O\xaa\x12lcH/\xdcZ\xf1Jeo\x08u\x1d\xc8\xb0\xc5\xd4v0'
actionTypeemitted by GMX after a deposit execution.
- GMX_EVENT_LOG1_DATA_TYPES: tuple[str, str, str] = ('address', 'string', '(((string,address)[],(string,address[])[]),((string,uint256)[],(string,uint256[])[]),((string,int256)[],(string,int256[])[]),((string,bool)[],(string,bool[])[]),((string,bytes32)[],(string,bytes32[])[]),((string,bytes)[],(string,bytes[])[]),((string,string)[],(string,string[])[]))')
Non-indexed
EventLog1inputs. Direct decoding avoids materialising all seven generic GMX key/value families through Web3’s event wrapper.
- encode_address_as_event_topic(address)
Encode an EVM address as a GMX
EventLog1topic.- Parameters
address (eth_typing.evm.HexAddress) – GM or GLV product address.
- Returns
Lower-case, zero-padded 32-byte topic.
- Return type
Decode the GMX
EventLog1fields needed for LP valuation.
Bases:
objectOne GM or GLV value-and-supply observation.
MarketPoolValueUpdatedcontains GM value and supply after a deposit. Withdrawal-context observations are excluded because GMX uses different valuation parameters for withdrawals.GlvValueUpdatedcontains GLV value and supply after execution; GLV minting and burning use the pre-flow ratio, so updating both numerator and denominator does not mechanically rebase the existing holders’ claim.EVM chain where GMX emitted the observation.
Block containing the valuation event.
Unix timestamp of the valuation block.
Emitting transaction hash.
Log position inside its block.
GM market token or GLV share token.
USD GM market or GLV value using GMX’s 30-decimal precision.
ERC-20 share supply using 18-decimal precision.
MarketPoolValueUpdatedorGlvValueUpdated.
Return the USD product value in decimal units.
Return the ERC-20 share supply in decimal units.
Return the supply-normalised USD value per share.
Convert a GMX value event into a share-price observation.
The canonical event definitions are in GMX’s MarketEventUtils.sol and GlvEventUtils.sol.
- Parameters
event (eth_defi.gmx.events.GMXEventData) – Decoded GMX EventEmitter payload.
chain_id (int) – Chain represented by the source stream.
block_number (int) – Emitting block number.
block_timestamp (int) – Unix timestamp of the emitting block.
transaction_hash (str) – Emitting transaction hash.
log_index (int) – Log position inside its block.
- Returns
Complete value-and-supply observation, or
Nonefor another event or a non-positive value/supply pair.- Return type
Optional[eth_defi.gmx.historical_oracle.GMXHistoricalSharePriceObservation]
Fetch GM and GLV value-and-supply observations.
- Parameters
hypersync_client (eth_defi.hypersync.session.ThrottledHypersyncClient) – Configured throttle-aware Hypersync client for the chain.
web3 (web3.main.Web3) – Web3 instance used to decode GMX EventEmitter payloads.
chain_id (int) – Chain represented by the query.
event_emitter_address (eth_typing.evm.HexAddress) – GMX EventEmitter deployment.
start_block (int) – Inclusive block boundary.
end_block (int) – Exclusive block boundary.
product_addresses (Optional[collections.abc.Iterable[eth_typing.evm.HexAddress]]) – Optional GM and GLV addresses selected at the indexed-log level.
event_loop_runner (Optional[asyncio.runners.Runner]) – Optional long-lived event-loop runner. Full-chain backfills must reuse one runner across chunks so the native Hypersync client’s asynchronous resources stay on their creating loop.
- Returns
Chronologically ordered observations.
- Return type
list[eth_defi.gmx.historical_oracle.GMXHistoricalSharePriceObservation]