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 VaultRow entries for the VaultDatabase pickle

  • Raw 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_raw_prices_dataframe(db)

Build a raw prices DataFrame from the Hibachi DuckDB.

create_hibachi_vault_row(vault_id, symbol, ...)

Create a synthetic VaultRow for a Hibachi native vault.

merge_into_uncleaned_parquet(db, parquet_path)

Merge Hibachi daily prices into the uncleaned Parquet file.

merge_into_vault_database(db, vault_db_path)

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 timestamp as 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

pandas.DataFrame

create_hibachi_vault_row(vault_id, symbol, name, description, tvl)

Create a synthetic VaultRow for a Hibachi native vault.

Builds a VaultRow that matches what calculate_vault_record() expects, using the Hibachi synthetic chain ID.

All Hibachi vault-level fees are zero. vault_pub_key and vault_asset_id are stored only in the DuckDB metadata table for traceability; they are not surfaced in VaultRow.

Parameters
  • vault_id (int) – Vault ID on the Hibachi platform (e.g. 2, 3).

  • symbol (str) – Short ticker symbol (e.g. GAV).

  • name (str) – Vault display name.

  • description (Optional[str]) – Vault description text.

  • tvl (float) – Current TVL in USDT.

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
Returns

The combined DataFrame.

Return type

pandas.DataFrame

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
Returns

The updated VaultDatabase.

Return type

eth_defi.vault.vaultdb.VaultDatabase