hibachi.vault_data_export
Documentation for eth_defi.hibachi.vault_data_export Python module.
Export Hibachi vault data into the ERC-4626 pipeline format.
This module bridges the Hibachi-specific DuckDB data into the formats consumed by the existing ERC-4626 vault metrics pipeline:
Synthetic
VaultRowentries for theVaultDatabasepickleRaw price DataFrames matching the uncleaned Parquet schema, so that Hibachi data goes through the same cleaning pipeline as EVM vaults
Merge functions to append Hibachi data into existing files
Example:
from pathlib import Path
from eth_defi.hibachi.daily_metrics import HibachiDailyMetricsDatabase
from eth_defi.hibachi.vault_data_export import merge_into_vault_database, merge_into_uncleaned_parquet
db = HibachiDailyMetricsDatabase(Path("daily-metrics.duckdb"))
merge_into_vault_database(db, vault_db_path)
merge_into_uncleaned_parquet(db, uncleaned_parquet_path)
db.close()
Functions
Build a raw prices DataFrame from the Hibachi DuckDB. |
|
|
Create a synthetic VaultRow for a Hibachi native vault. |
|
Merge Hibachi daily prices into the uncleaned Parquet file. |
|
Merge Hibachi vault metadata into an existing VaultDatabase pickle. |
- build_raw_prices_dataframe(db)
Build a raw prices DataFrame from the Hibachi DuckDB.
Produces rows matching the schema of the EVM vault scanner (
export()), so Hibachi data can go through the same cleaning pipeline (process_raw_vault_scan_data()) as ERC-4626 vaults.The output has
timestampas a column (not index), matching the raw uncleaned Parquet format.- Parameters
db (eth_defi.hibachi.daily_metrics.HibachiDailyMetricsDatabase) – The Hibachi daily metrics database.
- Returns
DataFrame with columns matching the uncleaned Parquet schema.
- Return type
- create_hibachi_vault_row(vault_id, symbol, name, description, tvl)
Create a synthetic VaultRow for a Hibachi native vault.
Builds a
VaultRowthat matches whatcalculate_vault_record()expects, using the Hibachi synthetic chain ID.All Hibachi vault-level fees are zero.
vault_pub_keyandvault_asset_idare stored only in the DuckDB metadata table for traceability; they are not surfaced inVaultRow.- Parameters
- Returns
Tuple of (VaultSpec, VaultRow).
- Return type
tuple[eth_defi.vault.base.VaultSpec, eth_defi.vault.vaultdb.VaultRow]
- merge_into_uncleaned_parquet(db, parquet_path)
Merge Hibachi daily prices into the uncleaned Parquet file.
Writes Hibachi raw data in the same format as the EVM vault scanner, so the standard cleaning pipeline (
process_raw_vault_scan_data()) can process all vaults together.Reads the existing Parquet, removes any prior Hibachi rows (chain == 9997), appends fresh Hibachi daily price rows, and writes back. Idempotent: running twice produces the same result.
If the Parquet file does not exist, creates a new one.
- Parameters
db (eth_defi.hibachi.daily_metrics.HibachiDailyMetricsDatabase) – The Hibachi daily metrics database.
parquet_path (pathlib.Path) – Path to the uncleaned Parquet file (typically
vault-prices-1h.parquet).
- Returns
The combined DataFrame.
- Return type
- merge_into_vault_database(db, vault_db_path)
Merge Hibachi vault metadata into an existing VaultDatabase pickle.
Reads the existing pickle, upserts Hibachi VaultRow entries (keyed by VaultSpec), and writes back. Idempotent: running twice produces the same result.
If the pickle file does not exist, creates a new VaultDatabase.
- Parameters
db (eth_defi.hibachi.daily_metrics.HibachiDailyMetricsDatabase) – The Hibachi daily metrics database.
vault_db_path (pathlib.Path) – Path to the VaultDatabase pickle file.
- Returns
The updated VaultDatabase.
- Return type