tokenised_fund.franklin.backfill
Documentation for eth_defi.tokenised_fund.franklin.backfill Python module.
Backfill reviewed Franklin Templeton Benji Ethereum fund-token history.
The migration only touches the two addresses in FRANKLIN_PRODUCTS. It
retains unrelated vault metadata, raw and cleaned Parquet rows, and reader
states. The targeted scanner deletes and regenerates history for those token
addresses from their known deployment blocks, so it must also remove only
their saved reader states before scanning.
Run with:
source .local-test.env && PROTOCOLS=franklin poetry run python scripts/backfill-tokenised-funds.py
Set DRY_RUN=false to apply changes. Optional environment variables are
FRANKLIN_SCAN_PRICES (default true), FRANKLIN_CLEAN_PRICES
(default true), FREQUENCY (1h or 1d), START_BLOCK,
END_BLOCK, MAX_WORKERS, VAULT_DB_PATH,
UNCLEANED_PRICE_DATABASE, CLEANED_PRICE_DATABASE and
READER_STATE_DATABASE.
Functions
|
Create a shared scanner detection for a registered product. |
|
Create a non-ERC-4626 hardcoded lead. |
|
Run a scoped Benji metadata and historical-price migration. |
|
Parse an environment boolean. |
|
Read an optional path override. |
|
Load saved reader states without altering unrelated entries. |
|
Remove only reviewed Benji states while retaining cross-chain matches. |
Upsert reviewed Benji metadata without changing discovery state. |
|
|
Write complete reader state atomically. |
- parse_bool_env(name, *, default)
Parse an environment boolean.
- parse_path_env(name, default)
Read an optional path override.
- Parameters
name (str) – Environment variable name.
default (pathlib.Path) – Production default path.
- Returns
Selected path.
- Return type
- create_detection(product)
Create a shared scanner detection for a registered product.
- Parameters
product (eth_defi.tokenised_fund.franklin.constants.FranklinProduct) – Reviewed Benji Ethereum product.
- Returns
Hardcoded feature detection.
- Return type
- create_lead(product)
Create a non-ERC-4626 hardcoded lead.
- Parameters
product (eth_defi.tokenised_fund.franklin.constants.FranklinProduct) – Reviewed Benji Ethereum product.
- Returns
Shared discovery lead.
- Return type
- upsert_franklin_metadata_preserving_discovery_cursor(vault_db, leads, rows)
Upsert reviewed Benji metadata without changing discovery state.
A targeted migration must preserve both an existing Ethereum discovery cursor and the absence of one. Advancing or initialising that chain-wide cursor could skip unrelated contracts that have not yet been discovered.
- Parameters
vault_db (eth_defi.vault.vaultdb.VaultDatabase) – Existing vault metadata database.
leads (dict[eth_typing.evm.HexAddress, eth_defi.erc_4626.discovery_base.PotentialVaultMatch]) – Reviewed Benji leads keyed by token address.
rows (dict[eth_defi.vault.base.VaultSpec, eth_defi.vault.vaultdb.VaultRow]) – Fresh Benji scan rows keyed by
VaultSpec.
- Returns
None.
- Return type
None
- read_reader_states(path)
Load saved reader states without altering unrelated entries.
- Parameters
path (pathlib.Path) – Reader-state pickle path.
- Returns
Complete existing mapping, or an empty mapping.
- Return type
- remove_franklin_reader_states(states)
Remove only reviewed Benji states while retaining cross-chain matches.
- Parameters
states (dict[eth_defi.vault.base.VaultSpec, dict]) – Complete shared reader-state mapping.
- Returns
Mapping without the exact reviewed Franklin vault specs.
- Return type
- write_reader_states(path, states)
Write complete reader state atomically.
- Parameters
path (pathlib.Path) – Reader-state pickle destination.
states (dict[eth_defi.vault.base.VaultSpec, dict]) – Complete scanner-produced state mapping.
- Returns
None.
- Return type
None
- main()
Run a scoped Benji metadata and historical-price migration.
- Returns
None.
- Return type
None