erc_4626.discovery_base

Documentation for eth_defi.erc_4626.discovery_base Python module.

Events we use in the vault discovery.

  • Shared across RPC/Hypersync discovery

  • Supports standard ERC-4626 Deposit/Withdraw events

  • Supports BrinkVault DepositFunds/WithdrawFunds events

Functions

get_brink_vault_contract(web3)

Get IBrinkVault interface for BrinkVault events.

get_brink_vault_discovery_events(web3)

Get list of BrinkVault events we use in vault discovery.

get_standard_erc_4626_vault_discovery_events(web3)

Get list of standard ERC-4626 events we use in vault discovery.

get_vault_discovery_events(web3)

Get all events used in vault discovery, including protocol-specific ones.

get_vault_event_topic_map(web3)

Build a mapping from topic0 signature to event kind.

is_deposit_event(event_kind)

Check if the event kind represents a deposit.

is_withdraw_event(event_kind)

Check if the event kind represents a withdrawal.

Classes

LeadScanReport

ERC-4626 vault detection data we extract in one duty cycle.

PotentialVaultMatch

Categorise contracts that emit ERC-4626 like events.

VaultDiscoveryBase

VaultEventKind

Classify vault discovery events by their type.

class VaultEventKind

Bases: enum.Enum

Classify vault discovery events by their type.

deposit = 'deposit'

Deposit-like event (ERC-4626 Deposit or BrinkVault DepositFunds)

withdraw = 'withdraw'

Withdraw-like event (ERC-4626 Withdraw or BrinkVault WithdrawFunds)

class PotentialVaultMatch

Bases: object

Categorise contracts that emit ERC-4626 like events.

__init__(chain, address, first_seen_at_block, first_seen_at, deposit_count=0, withdrawal_count=0)
Parameters
Return type

None

get_brink_vault_contract(web3)

Get IBrinkVault interface for BrinkVault events.

get_standard_erc_4626_vault_discovery_events(web3)

Get list of standard ERC-4626 events we use in vault discovery.

Note

This returns only standard ERC-4626 events. For all vault events including protocol-specific ones, use get_vault_discovery_events().

Return type

list[Type[web3.contract.contract.ContractEvent]]

get_brink_vault_discovery_events(web3)

Get list of BrinkVault events we use in vault discovery.

BrinkVault uses custom events instead of standard ERC-4626 Deposit/Withdraw:

  • Deposited(address caller, address recipient, uint256 assets, uint256 shares)

  • Withdrawal(address caller, address recipient, uint256 received, uint256 shares)

Return type

list[Type[web3.contract.contract.ContractEvent]]

get_vault_discovery_events(web3)

Get all events used in vault discovery, including protocol-specific ones.

This includes: - Standard ERC-4626 Deposit/Withdraw events - BrinkVault DepositFunds/WithdrawFunds events

Returns

List of contract event types in order: [ERC4626.Deposit, ERC4626.Withdraw, BrinkVault.DepositFunds, BrinkVault.WithdrawFunds]

Return type

list[Type[web3.contract.contract.ContractEvent]]

get_vault_event_topic_map(web3)

Build a mapping from topic0 signature to event kind.

Used by discovery implementations to classify events.

Returns

Dict mapping topic0 hex string to VaultEventKind

Return type

dict[str, eth_defi.erc_4626.discovery_base.VaultEventKind]

is_deposit_event(event_kind)

Check if the event kind represents a deposit.

Parameters

event_kind (eth_defi.erc_4626.discovery_base.VaultEventKind) –

Return type

bool

is_withdraw_event(event_kind)

Check if the event kind represents a withdrawal.

Parameters

event_kind (eth_defi.erc_4626.discovery_base.VaultEventKind) –

Return type

bool

class LeadScanReport

Bases: object

ERC-4626 vault detection data we extract in one duty cycle.

leads: dict[eth_typing.evm.HexAddress, eth_defi.erc_4626.discovery_base.PotentialVaultMatch]

Any vault-like smart contracts

detections: dict[eth_typing.evm.HexAddress, eth_defi.erc_4626.core.ERC4262VaultDetection]

Confirmed ERC-4626 vaults by smart contract probing calls

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

Exported vault-data as rows

old_leads: int

Accounting / diagnostics

new_leads: int

Accounting / diagnostics

deposits: int

Accounting / diagnostics

withdrawals: int

Accounting / diagnostics

backend: eth_defi.erc_4626.discovery_base.VaultDiscoveryBase | None

Accounting / diagnostics

start_block: int

Accounting / diagnostics

end_block: int

Accounting / diagnostics

__init__(leads=<factory>, detections=<factory>, rows=<factory>, old_leads=0, new_leads=0, deposits=0, withdrawals=0, backend=None, start_block=0, end_block=0)
Parameters
Return type

None

class VaultDiscoveryBase

Bases: abc.ABC

__init__(max_workers)
Parameters

max_workers (int) –

seed_existing_leads(leads)

Seed existing leads to continue the scan where we were left last time.

Parameters

leads (dict[eth_typing.evm.HexAddress, eth_defi.erc_4626.discovery_base.PotentialVaultMatch]) –

scan_vaults(start_block, end_block, display_progress=True)

Scan vaults.

  • Detect vault leads by events using scan_potential_vaults()

  • Then perform multicall probing for each vault smart contract to detect protocol

Parameters
  • start_block (int) –

  • end_block (int) –

Return type

eth_defi.erc_4626.discovery_base.LeadScanReport