vault.rpc_batch

Documentation for eth_defi.vault.rpc_batch Python module.

Current-state batches for ordinary ERC-4626 admission and metadata reads.

Specialised adapters retain their protocol paths. HyperEVM is deliberately excluded from these shared batches because HyperCore reads can poison a batch. See https://eips.ethereum.org/EIPS/eip-4626 for the ordinary method semantics.

Functions

fetch_batched_tvl_probes(vaults, ...[, ...])

Batch canonical total assets and preserve specialised NAV conversions.

fetch_current_vault_tvl_usd(vault)

Probe a discovered vault's current TVL using its existing USD conversion.

fetch_metadata_snapshots(detections, ...[, ...])

Read ordinary metadata inputs in shared batches at one source block.

fetch_metadata_snapshots(detections, web3factory, block_identifier, max_workers, *, batch_size=40)

Read ordinary metadata inputs in shared batches at one source block.

Only generic ERC-4626, Morpho v1 and IPOR are enabled initially. Adapter consumers additionally verify method identity and the source block. HyperEVM and custom share-token paths keep their specialised reads.

Called by lead discovery and pending-metadata recovery after scheduling has selected candidates. These are raw inputs, not final metadata records: adapters remain responsible for token decoding and protocol economics. Pinning the inputs to one block lets those adapters reject a snapshot from a different observation rather than silently mixing old and new values.

Parameters
  • detections (list[eth_defi.erc_4626.core.ERC4262VaultDetection]) – Metadata candidates already selected as due.

  • web3factory (eth_defi.provider.multi_provider.MultiProviderWeb3Factory) – Factory with phase accounting and verified chain ID.

  • block_identifier (int) – Common numeric block for this bounded batch.

  • max_workers (int) – Maximum threaded read concurrency.

  • batch_size (int) – Positive maximum encoded subcalls per chunk, default 40. Each vault contributes four subcalls, so this counts calls rather than vaults. Discovery and pending-metadata recovery use the default; direct callers can pass a smaller limit for a constrained provider. Existing Multicall chain limits and failure handling may further split a chunk.

Returns

Lower-case address to successful raw inputs and source block.

Raises

ValueError – If batch_size is not positive.

Return type

dict[str, dict]

fetch_current_vault_tvl_usd(vault)

Probe a discovered vault’s current TVL using its existing USD conversion.

The probe lets a live scan include a meaningful vault even when it has fewer than the normal number of deposit events. The vault’s own reader state supplies protocol-specific exchange-rate overrides. An unknown conversion is reported separately and never treated as verified USD TVL.

Specialised admission batches and direct callers share this path. The adapter owns the timing and composition of its NAV, including live HyperCore values; forcing the ordinary batch block onto these reads could make them unavailable.

Parameters

vault (eth_defi.vault.base.VaultBase) – Vault adapter to read at the provider’s current state.

Returns

(tvl_usd, unsupported_conversion). The first member is a Decimal USD estimate or None; the second is True when the denomination rate is unknown or unavailable. A failed read returns (None, False) so it is distinguishable from an unsupported conversion returning (None, True).

Return type

tuple[decimal.Decimal | None, bool]

fetch_batched_tvl_probes(vaults, web3factory, block_identifier, max_workers, *, batch_size=40)

Batch canonical total assets and preserve specialised NAV conversions.

Method-identity checks keep adapters with overridden NAV/assets paths on individual reads. Failed subcalls produce explicit unavailable outcomes. Returned values carry no synthetic source timestamp.

The all-chain price selector uses these observations to admit low-activity candidates. Admission is provisional: it does not advance historical reader progress or replace previously verified qualification. Unavailable reads therefore produce deferred candidates while existing readers keep scanning.

Parameters
  • vaults (list[eth_defi.vault.base.VaultBase]) – Due, already instantiated admission candidates.

  • web3factory (eth_defi.provider.multi_provider.MultiProviderWeb3Factory) – Verified-chain factory with physical request accounting.

  • block_identifier (int) – Numeric source block for ordinary batched reads.

  • max_workers (int) – Maximum threaded read concurrency.

  • batch_size (int) – Positive maximum encoded subcalls per chunk, default 40. Each ordinary vault contributes one totalAssets subcall. The all-chain admission selector uses the default; direct callers can pass a smaller limit for a constrained provider. Existing Multicall chain limits and failure handling may further split a chunk. Specialised reads are unaffected.

Returns

Iterator of (vault, tvl_usd, unsupported_conversion) tuples. tvl_usd is a Decimal estimate or None when unavailable. unsupported_conversion is True only when the denomination rate is unknown or unavailable; a failed RPC read yields (vault, None, False).

Raises

ValueError – If batch_size is not positive, when iteration begins.

Return type

Iterator[tuple[eth_defi.vault.base.VaultBase, decimal.Decimal | None, bool]]