tokenised_fund.superstate.backfill
Documentation for eth_defi.tokenised_fund.superstate.backfill Python module.
Backfill the reviewed Superstate USTB lead and its NAV history.
This migration is intentionally address-scoped. It upserts only the Ethereum USTB lead and metadata row, removes only that reader state, and passes only USTB to the historical scanner. It never resets a chain cursor, re-discovers all Ethereum vaults, or deletes unrelated Parquet rows.
Run with:
source .local-test.env && PROTOCOLS=superstate poetry run python scripts/backfill-tokenised-funds.py
Environment variables:
DRY_RUNShow the migration plan without writing files. Default:
false.SCAN_PRICESRebuild USTB’s daily NAV/share history. Default:
true.FREQUENCY1d(default) or1hhistorical sampling interval.START_BLOCK/END_BLOCKOptional inclusive bounds for a controlled repair.
VAULT_DB_PATH, UNCLEANED_PRICE_DATABASE, CLEANED_PRICE_DATABASE
and READER_STATE_DATABASE
Optional state-path overrides for an isolated or production run.
Functions
Create the reviewed USTB scanner detection. |
|
Create the USTB lead without scanning unrelated Ethereum events. |
|
|
Run the USTB-only lead and NAV-history migration. |
|
Read a conventional Boolean environment setting. |
|
Read a local state-path override. |
|
Load trusted state while retaining every unrelated vault entry. |
Validate the requested historical sample interval. |
|
|
Upsert only USTB metadata without changing shared discovery cursors. |
|
Atomically persist the complete retained reader-state map. |
- parse_bool_env(name, *, default)
Read a conventional Boolean environment setting.
- parse_path_env(name, default)
Read a local state-path override.
- Parameters
name (str) – Environment variable name.
default (pathlib.Path) – Normal production location.
- Returns
Expanded configured path.
- Return type
- resolve_frequency()
Validate the requested historical sample interval.
- Returns
Scanner frequency.
- Raises
ValueError – If the requested frequency is unsupported.
- Return type
Literal[‘1h’, ‘1d’]
- create_detection()
Create the reviewed USTB scanner detection.
- Returns
Hardcoded, non-event-derived USTB detection.
- Return type
- create_lead()
Create the USTB lead without scanning unrelated Ethereum events.
- Returns
Reviewed USTB lead.
- Return type
- read_reader_states(path)
Load trusted state while retaining every unrelated vault entry.
- Parameters
path (pathlib.Path) – Reader-state pickle location.
- Returns
Current state map or an empty map.
- Return type
- write_reader_states(path, reader_states)
Atomically persist the complete retained reader-state map.
- Parameters
path (pathlib.Path) – Reader-state pickle location.
reader_states (dict[eth_defi.vault.base.VaultSpec, dict]) – Complete state map from the scanner.
- Returns
None.
- Return type
None
- upsert_ustb_metadata(vault_db, row, end_block)
Upsert only USTB metadata without changing shared discovery cursors.
VaultDatabase.update_leads_and_rows()is the shared merge path, but it also advances the chain-wide discovery cursor. A targeted migration must not make unrelated Ethereum discovery skip blocks, so retain the exact pre-existing cursor value, including the case where no cursor was present, around this single-address upsert.- Parameters
vault_db (eth_defi.vault.vaultdb.VaultDatabase) – Existing shared vault database.
row (dict) – Fresh USTB scanner metadata row.
end_block (int) – Metadata read block supplied to the underlying merge operation.
- Returns
None.
- Return type
None
- main()
Run the USTB-only lead and NAV-history migration.
- Returns
None.
- Return type
None