RyskHistoricalContextStore

Documentation for eth_defi.erc_4626.vault_protocol.rysk.historical_context.RyskHistoricalContextStore Python class.

class RyskHistoricalContextStore

Bases: contextlib.AbstractContextManager

Persist final Rysk epoch observations without DuckDB ART indexes.

Open the shared cache and create the Rysk event table.

Parameters

path – Shared contextual-history DuckDB path.

Returns

None.

Methods summary

__init__(path)

Open the shared cache and create the Rysk event table.

fetch_next_source_block(chain_id, ...)

Return an inclusive restart block for one pool.

fetch_source_ids_at_block(chain_id, ...)

Return stored execution identities at one replay boundary.

insert_observations(observations)

Insert final epoch observations transactionally and idempotently.

iter_finalised_share_prices(*, chain_id, ...)

Yield final execution prices in chronological order.

__init__(path)

Open the shared cache and create the Rysk event table.

Parameters

path (pathlib.Path) – Shared contextual-history DuckDB path.

Returns

None.

Return type

None

fetch_next_source_block(chain_id, pool_address, default_start_block)

Return an inclusive restart block for one pool.

The last finalisation block is intentionally replayed so a price update for the next epoch in the same block cannot be skipped. Exact execution rows are deduplicated when inserted.

Parameters
  • chain_id (int) – EVM chain identifier.

  • pool_address (eth_typing.evm.HexAddress) – Pool whose cursor is requested.

  • default_start_block (int) – First discovery block when no context exists.

Returns

Inclusive source restart block.

Return type

int

fetch_source_ids_at_block(chain_id, pool_address, block_number)

Return stored execution identities at one replay boundary.

The incremental collector replays the last finalisation block so it cannot miss a next-epoch price update emitted later in that block. Stored executions at the boundary may refer to a price proposal before the replay window and are therefore supplied to the join as known rows.

Parameters
  • chain_id (int) – EVM chain identifier.

  • pool_address (eth_typing.evm.HexAddress) – Pool whose execution rows are inspected.

  • block_number (int) – Inclusive replay block.

Returns

Stored source identities at the boundary.

Return type

frozenset[str]

insert_observations(observations)

Insert final epoch observations transactionally and idempotently.

Source identities use the execution log location. No uniqueness index is created because large file-backed ART indexes are unsafe with the repository’s supported DuckDB and Python versions.

Parameters

observations (collections.abc.Iterable[eth_defi.erc_4626.vault_protocol.rysk.historical_context.RyskHistoricalSharePriceObservation]) – Finite stream reconstructed from Rysk events.

Returns

(fetched, inserted) counts.

Return type

tuple[int, int]

iter_finalised_share_prices(*, chain_id, pool_address, start_block, end_block, collateral_decimals)

Yield final execution prices in chronological order.

raw_withdrawal_pps is encoded using the pool collateral token’s precision. No total-assets or supply value is fabricated.

Parameters
  • chain_id (int) – EVM chain identifier.

  • pool_address (eth_typing.evm.HexAddress) – Pool and share-token address.

  • start_block (int) – Inclusive execution block boundary.

  • end_block (int) – Exclusive execution block boundary.

  • collateral_decimals (int) – Native precision of the collateral token.

Returns

Final collateral-denominated exit prices.

Return type

collections.abc.Iterable[eth_defi.erc_4626.vault_protocol.rysk.historical_context.RyskHistoricalSharePriceObservation]