YieldBasisHistoricalContextStore
Documentation for eth_defi.yield_basis.historical_context.YieldBasisHistoricalContextStore Python class.
- class YieldBasisHistoricalContextStore
Bases:
contextlib.AbstractContextManagerManage YieldBasis observations without DuckDB ART keys.
Open or create the protocol-owned tables.
Methods summary
__init__([path])Open or create the protocol-owned tables.
Flush the deliberately large DuckDB WAL checkpoint.
close()Checkpoint and close the database connection.
count_observations(*, chain_id, lt_address)Return the number of stored observations for one LT.
insert_observations(observations)Insert observations idempotently and reject conflicting blocks.
iter_observations(*, chain_id, lt_address, ...)Yield the latest observation inside each requested block bucket.
- __init__(path=None)
Open or create the protocol-owned tables.
- Parameters
path (Optional[pathlib.Path]) –
- Return type
None
- insert_observations(observations)
Insert observations idempotently and reject conflicting blocks.
One unconstrained temporary table supports both conflict detection and deduplication without the DuckDB ART indexes avoided by this pipeline. Every source value is immutable for a logical block, so one comparison covers fundamental accounting, the redemption preview and token scale.
- Parameters
observations (collections.abc.Iterable[eth_defi.yield_basis.historical_context.YieldBasisHistoricalObservation]) – Source observations to insert as one batch.
- Returns
Number of new logical rows inserted.
- Return type
- iter_observations(*, chain_id, lt_address, start_block, end_block, step)
Yield the latest observation inside each requested block bucket.
The common writer requests a regular block grid. When more than one exact observation falls into a bucket, only the newest one is exposed.
- Parameters
chain_id (int) – Chain to query.
lt_address (eth_typing.evm.HexAddress) – LT share token to query.
start_block (int) – Inclusive range boundary.
end_block (int) – Exclusive range boundary.
step (int) – Bucket width in blocks.
- Returns
Iterator of bucketed source observations.
- Return type
collections.abc.Iterator[eth_defi.yield_basis.historical_context.YieldBasisHistoricalObservation]
- count_observations(*, chain_id, lt_address)
Return the number of stored observations for one LT.
- Parameters
chain_id (int) – Chain to query.
lt_address (eth_typing.evm.HexAddress) – LT share-token address to query.
- Returns
Number of matching context rows.
- Return type
- checkpoint()
Flush the deliberately large DuckDB WAL checkpoint.
- Return type
None
- close()
Checkpoint and close the database connection.
- Return type
None