hyperliquid.vault_data_export
Documentation for eth_defi.hyperliquid.vault_data_export Python module.
Export Hyperliquid vault data into the ERC-4626 pipeline format.
This module bridges the Hyperliquid-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 Hypercore data goes through the same cleaning pipeline as EVM vaults
Merge functions to append Hyperliquid data into existing files
Example:
from pathlib import Path
from eth_defi.hyperliquid.daily_metrics import HyperliquidDailyMetricsDatabase
from eth_defi.hyperliquid.vault_data_export import merge_into_vault_database, merge_into_uncleaned_parquet
db = HyperliquidDailyMetricsDatabase(Path("daily-metrics.duckdb"))
merge_into_vault_database(db, vault_db_path)
merge_into_uncleaned_parquet(db, uncleaned_parquet_path)
db.close()
Module Attributes
If the leader's share of vault capital drops below this threshold, we warn that new deposits may not be accepted because the leader must maintain at least 5% of total vault capital. |
Functions
Build a raw prices DataFrame from the Hyperliquid DuckDB. |
|
|
Create a synthetic VaultRow for a Hyperliquid native vault. |
|
Merge Hyperliquid daily prices into the uncleaned Parquet file. |
|
Merge Hyperliquid vault metadata into an existing VaultDatabase pickle. |
- LEADER_FRACTION_WARNING_THRESHOLD: float = 0.055
If the leader’s share of vault capital drops below this threshold, we warn that new deposits may not be accepted because the leader must maintain at least 5% of total vault capital.
The threshold is set 0.5% above the Hyperliquid minimum (5%) to give an early warning before deposits are actually blocked.
Source: https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/vaults/for-vault-leaders-legacy Verified: 2026-03-09
- create_hyperliquid_vault_row(vault_address, name, description, tvl, create_time, follower_count=None, is_closed=False, allow_deposits=True, relationship_type='normal', leader_fraction=None)
Create a synthetic VaultRow for a Hyperliquid native vault.
Builds a
VaultRowthat matches whatcalculate_vault_record()expects, using the Hypercore synthetic chain ID.User-created vaults (
relationship_type="normal") use the fixed platform performance feeHYPERLIQUID_VAULT_PERFORMANCE_FEE. Protocol vaults (HLP and its children withrelationship_type="parent"or"child") have zero fees.- Parameters
vault_address (eth_typing.evm.HexAddress) – Vault hex address (will be lowercased).
name (str) – Vault display name.
description (str | None) – Vault description text.
tvl (float) – Current TVL in USD.
create_time (datetime.datetime | None) – Vault creation timestamp.
follower_count (int | None) – Number of vault depositors.
is_closed (bool) – Whether the vault is closed for new deposits.
allow_deposits (bool) – Whether the vault allows deposits. A vault can have
is_closed=Falsebutallow_deposits=False.relationship_type (str) – Vault relationship type from the API:
"normal"for user-created vaults,"parent"for HLP,"child"for HLP sub-vaults.leader_fraction (float | None) – Leader’s fraction of total vault capital (e.g. 0.10 = 10%). Used for
_get_deposit_closed_reason()to warn when close to the Hyperliquid 5% minimum.
- Returns
Tuple of (VaultSpec, VaultRow).
- Return type
tuple[eth_defi.vault.base.VaultSpec, eth_defi.vault.vaultdb.VaultRow]
- build_raw_prices_dataframe(db)
Build a raw prices DataFrame from the Hyperliquid DuckDB.
Produces rows matching the schema of the EVM vault scanner (
export()), so Hypercore 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.Includes per-row
deposit_closed_reason(str or None) anddeposits_open(str “true”/”false” or None) columns derived from forward-filledis_closed,allow_deposits, andleader_fractionstate columns in the DuckDB.Also exposes Hyperliquid’s raw cumulative account PnL as
account_pnlso downstream consumers can compare the website-style account PnL against the cleaned share-price based return series.follower_countandcumulative_volumeare exported as scalar historical fields when available.- Parameters
db (eth_defi.hyperliquid.daily_metrics.HyperliquidDailyMetricsDatabase) – The Hyperliquid daily metrics database.
- Returns
DataFrame with columns matching the uncleaned Parquet schema.
- Return type
- merge_into_vault_database(db, vault_db_path)
Merge Hyperliquid vault metadata into an existing VaultDatabase pickle.
Reads the existing pickle, upserts Hyperliquid 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.hyperliquid.daily_metrics.HyperliquidDailyMetricsDatabase) – The Hyperliquid daily metrics database.
vault_db_path (pathlib.Path) – Path to the VaultDatabase pickle file.
- Returns
The updated VaultDatabase.
- Return type
- merge_into_uncleaned_parquet(db, parquet_path)
Merge Hyperliquid daily prices into the uncleaned Parquet file.
Writes Hypercore 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 Hypercore rows (chain == 9999), appends fresh Hyperliquid 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.hyperliquid.daily_metrics.HyperliquidDailyMetricsDatabase) – The Hyperliquid daily metrics database.
parquet_path (pathlib.Path) – Path to the uncleaned Parquet file (typically
vault-prices-1h.parquet).
- Returns
The combined DataFrame.
- Return type