tokenised_fund.ondo.backfill

Documentation for eth_defi.tokenised_fund.ondo.backfill Python module.

Backfill reviewed Ondo tokenised-fund leads and NAV history.

This is a targeted migration for the reviewed Ethereum USDY and OUSG tokens. It upserts only those two leads and rewrites only their raw and cleaned price histories. Existing vault database rows and reader states belonging to other protocols are retained.

Run with source .local-test.env && PROTOCOLS=ondo poetry run python scripts/backfill-tokenised-funds.py. Set DRY_RUN=true to print the plan without writes. ONDO_SCAN_PRICES=false updates metadata only; ONDO_CLEAN_PRICES=false skips the selected cleaned-history replacement. START_BLOCK, END_BLOCK, MAX_WORKERS, FREQUENCY and the normal vault database path environment variables use the same semantics as other targeted vault migrations.

Functions

create_detection(product)

Create a scanner detection from the reviewed deployment registry.

create_lead(product)

Create a hardcoded lead without re-discovering the whole chain.

main()

Run the safe, address-scoped Ondo lead and price-history migration.

parse_bool_env(name, default)

Read a conventional boolean environment variable.

parse_path_env(name, default)

Read an optional database-path environment override.

read_reader_states(path)

Load existing reader state without discarding unrelated vaults.

remove_ondo_reader_states(states)

Remove only reviewed Ondo states while retaining cross-chain matches.

upsert_ondo_metadata_preserving_discovery_cursor(...)

Upsert reviewed Ondo metadata without changing discovery state.

write_reader_states(path, states)

Atomically persist the complete post-scan reader-state mapping.

parse_bool_env(name, default)

Read a conventional boolean environment variable.

Parameters
  • name (str) –

  • default (bool) –

Return type

bool

parse_path_env(name, default)

Read an optional database-path environment override.

Parameters
Return type

pathlib.Path

read_reader_states(path)

Load existing reader state without discarding unrelated vaults.

Parameters

path (pathlib.Path) –

Return type

dict[eth_defi.vault.base.VaultSpec, dict]

write_reader_states(path, states)

Atomically persist the complete post-scan reader-state mapping.

Parameters
Return type

None

remove_ondo_reader_states(states)

Remove only reviewed Ondo 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 Ondo vault specs.

Return type

dict[eth_defi.vault.base.VaultSpec, dict]

create_detection(product)

Create a scanner detection from the reviewed deployment registry.

Parameters

product (eth_defi.tokenised_fund.ondo.constants.OndoProduct) –

Return type

eth_defi.erc_4626.core.ERC4262VaultDetection

create_lead(product)

Create a hardcoded lead without re-discovering the whole chain.

Parameters

product (eth_defi.tokenised_fund.ondo.constants.OndoProduct) –

Return type

eth_defi.erc_4626.discovery_base.PotentialVaultMatch

upsert_ondo_metadata_preserving_discovery_cursor(vault_db, leads, rows)

Upsert reviewed Ondo 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
Returns

None.

Return type

None

main()

Run the safe, address-scoped Ondo lead and price-history migration.

Return type

None