Recurring price backfill API

The manual price-backfill entrypoint uses the same address-scoped historical scan as the recurring all-chain scheduler. It is intended for already registered products and does not change vault metadata or reader state. Operator settings and targeted repair examples are documented in scripts/erc-4626/README-vault-scripts.md.

Run targeted tokenised-fund price backfills through the recurring scanner.

The legacy protocol backfills may refresh metadata, lead discovery and prices with protocol-specific implementations. This module is intentionally limited to raw price history already owned by eth_defi.tokenised_fund.scan, so a manual repair exercises the same address-scoped write path as the scheduler.

class TokenisedFundPriceBackfillConfig

Bases: object

Operator configuration for one recurring-path price backfill.

vault_db_path: pathlib.Path

Shared reviewed vault metadata database.

raw_price_path: pathlib.Path

Shared raw vault-price Parquet file.

scanners: tuple[eth_defi.tokenised_fund.scan.TokenisedFundPriceScanSpec, ...]

Selected recurring price-feed definitions.

vault_addresses: Optional[frozenset[str]]

Optional lowercase token-address restriction.

max_workers: int

Historical reader worker count.

hypersync_concurrency: int

Shared Hypersync stream concurrency.

dry_run: bool

Whether to print the target plan without writing prices.

__init__(vault_db_path, raw_price_path, scanners, vault_addresses, max_workers, hypersync_concurrency, dry_run)
Parameters
Return type

None

parse_bool_env(name, default)

Read a strict boolean environment variable.

Empty values use default. Explicit values must be true or false so a typo cannot accidentally start a production rewrite.

Parameters
  • name (str) – Environment variable name.

  • default (bool) – Value used when the variable is absent or empty.

Returns

Parsed boolean value.

Raises

ValueError – If a configured value is not a boolean.

Return type

bool

parse_path_env(name, default)

Read an optional path environment variable.

Parameters
  • name (str) – Environment variable name.

  • default (pathlib.Path) – Path used when the variable is absent or empty.

Returns

Expanded configured or default path.

Return type

pathlib.Path

parse_vault_addresses(value)

Parse an optional comma-separated lowercase token-address filter.

The recurring scanner stores and compares lowercase addresses, so this parser normalises operator input at the boundary.

Parameters

value (Optional[str]) – Raw TOKENISED_FUND_PRODUCTS environment value.

Returns

Lowercase address set, or None when no filter was supplied.

Raises

ValueError – If an entry is not a 20-byte hexadecimal EVM address.

Return type

Optional[frozenset[str]]

resolve_configured_chain_ids(target_specs, vault_addresses)

Return target chains that have a configured JSON-RPC URL.

Missing RPC URLs remain visible in the scan result diagnostics. Filtering them here prevents a targeted manual run from treating unrelated chains as operator-enabled.

Parameters
Returns

Chain ids with a configured RPC URL.

Return type

frozenset[int]

build_price_backfill_plan(config)

Build the exact target and continuation plan without modifying state.

The plan deliberately resolves starts through the same helper as the recurring scanner. It therefore exposes the exact address-scoped rewrite boundary that an execution would use.

Parameters

config (eth_defi.tokenised_fund.price_backfill.TokenisedFundPriceBackfillConfig) – Manual backfill configuration.

Returns

One plan row per selected registered product.

Raises

RuntimeError – If the shared metadata database does not exist.

Return type

list[dict[str, str | int]]

run_price_backfill(config)

Run selected recurring price feeds as a manual backfill.

Each selected feed retains its independent address-scoped Parquet rewrite semantics. The function makes no metadata or reader-state changes.

Parameters

config (eth_defi.tokenised_fund.price_backfill.TokenisedFundPriceBackfillConfig) – Manual backfill configuration.

Returns

Results keyed by dashboard name.

Return type

dict[str, eth_defi.tokenised_fund.scan.TokenisedFundPriceScanResult]

create_config_from_environment()

Build manual backfill configuration from environment variables.

DRY_RUN defaults to true because an execution rewrites the shared raw Parquet file. Set it to false only after reviewing the printed plan.

Returns

Validated manual backfill configuration.

Return type

eth_defi.tokenised_fund.price_backfill.TokenisedFundPriceBackfillConfig

main()

Print or execute a tokenised-fund price backfill from environment.

Returns

None.

Return type

None