build_depegged_stablecoin_lookups

Documentation for eth_defi.feed.stablecoin_rate.build_depegged_stablecoin_lookups function.

build_depegged_stablecoin_lookups(data_dir=PosixPath('/home/runner/work/web3-ethereum-defi/web3-ethereum-defi/eth_defi/data/stablecoins'))

Build contract and unambiguous symbol lookups for depegged stablecoins.

Determine which denomination tokens should be treated as depegged for vault blacklisting. Two independent lookups are returned:

  • A set of (chain_id, lowercased_address) contract keys for every entry that carries a depegged_at marker, regardless of whether the entry lives in a single- or multi-entry YAML file. This is the precise path: it pins the dead token by address and never blacklists an unrelated token that merely reuses the same ticker.

  • A set of normalised symbols that are unambiguously depegged. A symbol is only eligible here when a single flat (single-entry) YAML file owns it and that file is marked depegged_at.

Symbol matching is deliberately not used for multi-entry tokens. Tickers such as USDX are reused by several unrelated tokens in the wild — e.g. the dead Stables Labs USDX (0xf3527ef8…) versus the live Axis USD (USDx) on Plasma — so matching by ticker would blacklist healthy vaults. Multi-entry depegged tokens must therefore be pinned by contract_addresses in their YAML entry. A warning is logged for any depegged entry that has no contract address and is not covered by an unambiguous symbol, because such a depeg silently fails to blacklist anything (this is the gap that previously let USDX-denominated vaults stay listed).

Parameters

data_dir (pathlib.Path) – Directory of stablecoin metadata YAML files.

Returns

Tuple of (depegged_contract_keys, depegged_symbols).

Return type

tuple[set[tuple[int, str]], set[str]]