erc_4626.vault_protocol.antarctic.historical_context
Documentation for eth_defi.erc_4626.vault_protocol.antarctic.historical_context Python module.
Read Antarctic settlements through Hypersync and persist replayable context.
Only subscriptions supply canonical prices. Redemptions retain their execution amounts for diagnostics. Source interfaces: https://arbiscan.io/address/0x98a6aEE58699e4f4E13D8d8d0800e4e9cbBcf8dD#code
Functions
|
Decode a Hypersync log with its verified manager interface. |
|
Prefill selected pools before any common price writer replacement. |
|
Fetch exact settlement observations, with cached source timestamps. |
Return Antarctic's shared historical context path. |
Classes
Persist exact settlement history and successful range cursors. |
|
Summarise a completed context refresh, including pending price repairs. |
|
One settlement with exact execution amounts and source provenance. |
- get_antarctic_historical_context_path()
Return Antarctic’s shared historical context path.
Other protocols retain their own tables in this file.
- Returns
Pipeline context DuckDB path.
- Return type
- class AntarcticSettlement
Bases:
objectOne settlement with exact execution amounts and source provenance.
- pool_address: eth_typing.evm.HexAddress
LP token identity, not the manager.
- account: eth_typing.evm.HexAddress
Investor whose settlement was processed.
Raw LP shares; serialised as decimal text in DuckDB.
- property source_id: str
Identify a log across replay and database imports.
Block hash is compared separately so a reorg can replace a location.
- Returns
Chain, LP token, transaction and log index identity.
- __init__(chain_id, pool_address, block_number, block_hash, block_timestamp, transaction_hash, log_index, kind, account, raw_usdt, raw_shares, raw_tvl, data)
- Parameters
- Return type
None
- class AntarcticPrefillResult
Bases:
objectSummarise a completed context refresh, including pending price repairs.
- repair_from_blocks: collections.abc.Mapping[eth_typing.evm.HexAddress, int]
Earliest outstanding canonical rewrite per selected pool.
- __init__(observations_fetched, observations_inserted, repair_from_blocks)
- Parameters
observations_fetched (int) –
observations_inserted (int) –
repair_from_blocks (collections.abc.Mapping[eth_typing.evm.HexAddress, int]) –
- Return type
None
- decode_antarctic_settlement(log, deployment)
Decode a Hypersync log with its verified manager interface.
Reject source mismatches and non-positive subscription denominators. Request events are deliberately excluded by the query and are rejected here too.
- Parameters
log (object) – Hypersync log with source fields selected by the collector.
deployment (eth_defi.erc_4626.vault_protocol.antarctic.constants.AntarcticDeployment) – Reviewed manager and LP token routing.
- Returns
Exact settlement, awaiting cached block timestamp resolution.
- Return type
eth_defi.erc_4626.vault_protocol.antarctic.historical_context.AntarcticSettlement
- class AntarcticHistoricalContextStore
Bases:
contextlib.AbstractContextManagerPersist exact settlement history and successful range cursors.
File-backed bulk tables intentionally have no ART primary/unique indexes. A complete overlap replacement removes orphaned logs, including removed-only reorgs. Pending price repairs survive a subsequent writer failure.
Open the shared store without altering foreign protocol tables.
- Parameters
path – Shared context DuckDB path.
- Returns
None.
- __init__(path)
Open the shared store without altering foreign protocol tables.
- Parameters
path (pathlib.Path) – Shared context DuckDB path.
- Returns
None.
- Return type
None
- fetch_cursor(address)
Read successful range coverage and outstanding price repair.
Empty successful ranges have cursors too, avoiding repeated full scans.
- Parameters
address (eth_typing.evm.HexAddress) – Reviewed LP token address.
- Returns
Exclusive completed block and earliest pending price repair.
- Return type
- replace_range(address, start_block, end_block, observations)
Commit a complete source range and cursor transactionally.
Hash joins compare exact staged records before replacing the target interval. All validation completes before changing persistent tables.
- Parameters
address (eth_typing.evm.HexAddress) – LP identity to replace, never a chain-wide scope.
start_block (int) – Inclusive complete source boundary.
end_block (int) – Exclusive complete source boundary.
observations (collections.abc.Iterator[eth_defi.erc_4626.vault_protocol.antarctic.historical_context.AntarcticSettlement]) – Decoded, timestamp-resolved settlements.
- Returns
Fetched and inserted/replaced counts.
- Return type
- acknowledge_repair(address, end_block)
Clear a pending repair after a successful complete price rewrite.
The caller must have written the pool through its completed source end.
- Parameters
address (eth_typing.evm.HexAddress) – LP token whose price rewrite succeeded.
end_block (int) – Exclusive successful price writer boundary.
- Returns
None.
- Return type
None
- iter_settlements(address, start_block, end_block, *, canonical_only=False)
Yield exact source records or one canonical subscription per block.
Raw context retains every event; common price storage collapses a block to the last canonical log, deterministically.
- Parameters
address (eth_typing.evm.HexAddress) – LP token identity.
start_block (int) – Inclusive range boundary.
end_block (int) – Exclusive range boundary.
canonical_only (bool) – Select last AddLiquidity per block when true.
- Returns
Ordered immutable source records.
- Return type
collections.abc.Iterator[eth_defi.erc_4626.vault_protocol.antarctic.historical_context.AntarcticSettlement]
- fetch_antarctic_settlements(*, hypersync_client, deployment, start_block, end_block, timestamp_cache_path=PosixPath('/home/runner/.tradingstrategy/block-timestamp'))
Fetch exact settlement observations, with cached source timestamps.
Uses indexed Hypersync logs, never eth_getLogs. Event timestamps go through the shared dense timestamp cache, which fills every header between the first and last event block; with a prepared production cache this fetches little, but against an empty cache it downloads the whole span. Reorg block hashes come from the source logs.
- Parameters
hypersync_client (eth_defi.hypersync.session.ThrottledHypersyncClient) – Configured Arbitrum client.
deployment (eth_defi.erc_4626.vault_protocol.antarctic.constants.AntarcticDeployment) – Reviewed manager/token routing.
start_block (int) – Inclusive source boundary.
end_block (int) – Exclusive source boundary.
timestamp_cache_path (pathlib.Path) – Persistent per-chain timestamp cache root.
- Returns
Source observations in block/log order.
- Return type
collections.abc.Iterator[eth_defi.erc_4626.vault_protocol.antarctic.historical_context.AntarcticSettlement]
- fetch_and_store_antarctic_history(*, web3, hypersync_client, pool_start_blocks, end_block, context_path, timestamp_cache_path=PosixPath('/home/runner/.tradingstrategy/block-timestamp'), force_backfill=False)
Prefill selected pools before any common price writer replacement.
Successful quiet ranges advance independent per-pool cursors. A bounded replay replaces orphaned logs and records repairs until the writer succeeds.
- Parameters
web3 (web3.main.Web3) – Connection used for chain identity only.
hypersync_client (eth_defi.hypersync.session.ThrottledHypersyncClient) – Configured indexed event client.
pool_start_blocks (collections.abc.Mapping[eth_typing.evm.HexAddress, int]) – Selected LP tokens and inclusive source bounds.
end_block (int) – Exclusive reorg-safe scan boundary.
context_path (pathlib.Path) – Shared historical context database.
timestamp_cache_path (pathlib.Path) – Exact-block timestamp cache root.
force_backfill (bool) – Re-read the full requested range regardless of cursor, for an explicit operator migration or a deeper historical repair.
- Returns
Read/write counts and persistent pending repairs.
- Return type
eth_defi.erc_4626.vault_protocol.antarctic.historical_context.AntarcticPrefillResult