erc_4626.vault_protocol.rysk.historical_context
Documentation for eth_defi.erc_4626.vault_protocol.rysk.historical_context Python module.
Collect final Rysk Premium epoch prices from onchain events.
Rysk first emits EpochPriceSet and may replace the proposal with
EpochPriceDisputed during the dispute window. epochExecuted is the
finalisation boundary. Only the latest price update preceding that execution
is exposed as a share-price-equivalent observation.
Functions
Incrementally collect final onchain epochs for selected Rysk pools. |
|
|
Reconstruct final Rysk prices from proposed, disputed and executed events. |
Return the shared contextual-history database path. |
Classes
Represent one proposed or disputed onchain epoch price. |
|
Summarise one onchain Rysk history refresh. |
|
Persist final Rysk epoch observations without DuckDB ART indexes. |
|
Represent one price made final by |
- get_rysk_historical_context_path()
Return the shared contextual-history database path.
Rysk owns one table in the pipeline-wide DuckDB context file. Other protocol tables and their rows are not modified.
- Returns
Pipeline
vault-historical-context.duckdblocation.- Return type
Bases:
objectRepresent one price made final by
epochExecuted.EVM chain containing the pool.
Pool and ERC-20 LP share-token address.
Epoch finalised by the execution.
Execution block, which is the finalisation boundary.
Unix timestamp of the execution block.
Execution transaction hash.
Execution event position within the transaction.
Final raw subscription price retained for auditing.
Final raw redemption price retained for scaling.
Collateral-denominated final redemption price for one share.
- class RyskHistoricalContextStore
Bases:
contextlib.AbstractContextManagerPersist 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.
- __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
- 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
- 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
Yield final execution prices in chronological order.
raw_withdrawal_ppsis 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]
- fetch_rysk_finalised_epoch_prices(*, hypersync_client, chain_id, pool_address, start_block, end_block, source_chunk_size=10000000, timestamp_cache_path=PosixPath('/home/runner/.tradingstrategy/block-timestamp'), known_execution_source_ids=())
Reconstruct final Rysk prices from proposed, disputed and executed events.
Price updates are ordered by block and log index. An execution selects the greatest update for its processed epoch that precedes the execution event.
- Parameters
hypersync_client (eth_defi.hypersync.session.ThrottledHypersyncClient) – Configured throttle-aware Hypersync client.
chain_id (int) – EVM chain identifier.
pool_address (eth_typing.evm.HexAddress) – Rysk pool to scan.
start_block (int) – Inclusive source boundary.
end_block (int) – Exclusive source boundary.
source_chunk_size (int) – Maximum blocks per observable Hypersync request.
timestamp_cache_path (pathlib.Path) – Persistent cache directory for execution-block timestamps.
known_execution_source_ids (collections.abc.Collection[str]) – Stored execution rows at an inclusive replay boundary. A known row may have its price update before the requested range and is skipped instead of being treated as corrupt source history.
- Returns
Final epoch observations ordered by execution location.
- Return type
tuple[eth_defi.erc_4626.vault_protocol.rysk.historical_context.RyskHistoricalSharePriceObservation, …]
Incrementally collect final onchain epochs for selected Rysk pools.
Each pool resumes from its last stored execution block, or its own supplied discovery block when no history exists. Rysk event and timestamp reads use Hypersync; JSON-RPC
eth_getLogsis never used.- Parameters
web3 (web3.main.Web3) – RPC connection used only for chain identity.
hypersync_client (eth_defi.hypersync.session.ThrottledHypersyncClient) – Configured client for the same chain.
pool_start_blocks (collections.abc.Mapping[eth_typing.evm.HexAddress, int]) – Rysk pool addresses mapped to their individual inclusive discovery boundaries.
end_block (int) – Exclusive safe source head.
context_path (pathlib.Path) – Shared contextual-history DuckDB path.
timestamp_cache_path (pathlib.Path) – Persistent per-chain timestamp-cache directory.
- Returns
Aggregate fetched and inserted observation counts.
- Return type
eth_defi.erc_4626.vault_protocol.rysk.historical_context.RyskHistoricalContextPrefillResult