VaultHistoricalRead
Documentation for eth_defi.vault.base.VaultHistoricalRead Python class.
- class VaultHistoricalRead
Bases:
objectVault share price and fee structure at the point of time.
Attributes summary
vaultblock_numbertimestampshare_pricetotal_assetstotal_supplyperformance_feemanagement_feeerrorsvault_poll_frequencymax_depositmax_redeemdeposits_openredemption_opentradingavailable_liquidityutilisationMethods summary
__init__(vault, block_number, timestamp, ...)export()Convert historical read for a Parquet/DataFrame export.
is_almost_equal(other[, epsilon])Check if the read statistics match.
migrate_parquet_schema(existing_table)Migrate an existing Parquet table to the current schema.
Get parquet schema for writing this data.
write_uncleaned_parquet(df, path[, compression])Write a DataFrame to the uncleaned parquet using proper PyArrow types.
- __init__(vault, block_number, timestamp, share_price, total_assets, total_supply, performance_fee, management_fee, errors, vault_poll_frequency=None, max_deposit=None, max_redeem=None, deposits_open=None, redemption_open=None, trading=None, available_liquidity=None, utilisation=None)
- Parameters
vault (eth_defi.vault.base.VaultBase) –
block_number (int) –
timestamp (datetime.datetime) –
share_price (Optional[decimal.Decimal]) –
total_assets (Optional[decimal.Decimal]) –
total_supply (Optional[decimal.Decimal]) –
max_deposit (Optional[decimal.Decimal]) –
max_redeem (Optional[decimal.Decimal]) –
available_liquidity (Optional[decimal.Decimal]) –
- Return type
None
- export()
Convert historical read for a Parquet/DataFrame export.
The returned dict conforms to
RawVaultPriceRow.- Return type
- is_almost_equal(other, epsilon=0.001)
Check if the read statistics match.
Throttle with epsilon relative difference to get rid of small increment rows
- Parameters
epsilon (float) – Write changes with 10 BPS granularity
other (Optional[eth_defi.vault.base.VaultHistoricalRead]) –
- Return type
- static migrate_parquet_schema(existing_table)
Migrate an existing Parquet table to the current schema.
When new columns are added to
to_pyarrow_schema(), existing parquet files still have the old schema. This function adds missing columns as null arrays so incremental scans can write new data without losing columns.Non-canonical columns (e.g.
account_pnl,leader_fractionadded by native protocol merges) are preserved so that the EVM scanner does not destroy data written by Hyperliquid/GRVT/Lighter.- Parameters
existing_table (pyarrow.Table) – Table read from an older parquet file.
- Returns
Table with all canonical columns present (missing ones filled with nulls), legacy columns removed, extra columns preserved.
- Return type
pyarrow.Table
- classmethod to_pyarrow_schema()
Get parquet schema for writing this data.
Write multiple chains, multiple vaults, to a single Parquet file
Column semantics are documented in
RawVaultPriceRow
- Return type
pyarrow.Schema
- static write_uncleaned_parquet(df, path, compression='zstd')
Write a DataFrame to the uncleaned parquet using proper PyArrow types.
Native protocol merge functions (Hyperliquid, GRVT, Lighter) must use this instead of
pandas.DataFrame.to_parquet()to avoid type promotion (e.g.timestamp[ms]→timestamp[us]) that breaksmigrate_parquet_schema()on the next EVM scan run.Columns present in the canonical schema are cast to their canonical types. Extra columns (from native protocols) are kept with their pandas-inferred types. No pandas index is written.
- Parameters
df (pandas.DataFrame) – Combined DataFrame to write.
path (pathlib.Path) – Output parquet file path.
compression (str) – Parquet compression codec.