VaultHistoricalRead

Documentation for eth_defi.vault.base.VaultHistoricalRead Python class.

class VaultHistoricalRead

Bases: object

Vault share price and fee structure at the point of time.

Attributes summary

vault

block_number

timestamp

share_price

total_assets

total_supply

performance_fee

management_fee

errors

vault_poll_frequency

max_deposit

max_redeem

deposits_open

redemption_open

trading

available_liquidity

utilisation

Methods 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.

to_pyarrow_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
Return type

None

export()

Convert historical read for a Parquet/DataFrame export.

The returned dict conforms to RawVaultPriceRow.

Return type

eth_defi.vault.base.RawVaultPriceRow

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
Return type

bool

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_fraction added 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 breaks migrate_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.