GainsHistoricalReader

Documentation for eth_defi.erc_4626.vault_protocol.gains.vault.GainsHistoricalReader Python class.

class GainsHistoricalReader

Bases: eth_defi.erc_4626.vault.ERC4626HistoricalReader

Read Gains/Ostium vault core data + epoch-based deposit/redemption state.

  • Deposits are always open for Gains/Ostium vaults

  • Redemptions are open only when nextEpochValuesRequestCount() == 0 on the open PnL contract (first 2 days of 3-day epoch)

  • Trading state is not tracked (always None)

Attributes summary

address

first_block

one_raw_share

Methods summary

__init__(vault, stateful)

construct_core_erc_4626_multicall()

Polling endpoints defined in ERC-4626 spec.

construct_gains_epoch_calls()

Add epoch state calls for deposit/redemption window detection.

construct_multicalls()

Get the onchain calls that are needed to read the share price.

dictify_multicall_results(block_number, ...)

Convert batch of multicalls made for this vault to more digestible dict.

process_core_erc_4626_result(call_by_name)

Decode common ERC-4626 calls.

process_result(block_number, timestamp, ...)

Process the result of mult

construct_multicalls()

Get the onchain calls that are needed to read the share price.

Return type

Iterable[eth_defi.event_reader.multicall_batcher.EncodedCall]

construct_gains_epoch_calls()

Add epoch state calls for deposit/redemption window detection.

  • Uses accPnlPerTokenUsed() and currentMaxSupply() for deposit state

  • Uses nextEpochValuesRequestCount() for redemption state

  • Works for both Gains (via openTradesPnlFeed()) and Ostium (via registry)

Return type

Iterable[eth_defi.event_reader.multicall_batcher.EncodedCall]

process_result(block_number, timestamp, call_results)

Process the result of mult

  • Calls are created in construct_multicalls()

  • This method combines result of this calls to a easy to manage historical record VaultHistoricalRead

Parameters
Return type

eth_defi.vault.base.VaultHistoricalRead

__init__(vault, stateful)
Parameters
construct_core_erc_4626_multicall()

Polling endpoints defined in ERC-4626 spec.

  • Does not include fee calls which do not have standard

Return type

Iterable[eth_defi.event_reader.multicall_batcher.EncodedCall]

dictify_multicall_results(block_number, call_results, allow_failure=True)

Convert batch of multicalls made for this vault to more digestible dict.

  • Assert that all multicalls succeed

Returns

Dictionary where each multicall is keyed by its EncodedCall.extra_data["function"]

Parameters
Return type

dict[str, eth_defi.event_reader.multicall_batcher.EncodedCallResult]

process_core_erc_4626_result(call_by_name)

Decode common ERC-4626 calls.

Parameters

call_by_name (dict[str, eth_defi.event_reader.multicall_batcher.EncodedCallResult]) –

Return type

tuple