merge_into_vault_database
Documentation for eth_defi.hyperliquid.vault_data_export.merge_into_vault_database function.
- merge_into_vault_database(db, vault_db_path, review_statuses=None)
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.
The
review_statusesargument is how the Hyperliquid review Google Sheet feeds human-enteredOK/Avoiddecisions into the pickle so downstream consumers (calculate_vault_record→ JSON export) can surface them without re-reading the sheet on every invocation.Behaviour:
review_statusesisNone(sheet unreachable, credentials missing, or the caller explicitly opted out): the existing_manual_review_statusvalue is carried forward from the previous pickle entry for each vault. This is the “persist if Google Sheets is down” contract — the last known manual review survives an outage.review_statusesis a mapping: the mapped value (including an explicitNonefor “no review”) is written for every address present in the mapping. Addresses absent from the mapping fall back to the carry-forward path above.
- Parameters
db (eth_defi.hyperliquid.daily_metrics.HyperliquidDailyMetricsDatabase) – The Hyperliquid daily metrics database.
vault_db_path (pathlib.Path) – Path to the VaultDatabase pickle file.
review_statuses (Optional[collections.abc.Mapping[eth_typing.evm.HexAddress, Optional[eth_defi.hyperliquid.vault_review_sync.ReviewStatus]]]) – Optional mapping from lowercased vault address to the latest manual review decision read from the Google Sheet.
- Returns
The updated VaultDatabase.
- Return type