erc_4626.hypersync_discovery
Documentation for eth_defi.erc_4626.hypersync_discovery Python module.
Find ERC-4626 vaults onchain using HyperSync.
Use HyperSync’s index to quickly get ERC-4626 identification events from the chain
We do not use raw JSON-RPC, because Etheruem JSON-RPC is badly designed piece of crap for reading data
Use tons of heurestics to figure out what’s going on with vaults
This is because ERC-4626, like many other ERC standards, are very poorly designed, lacking proper identification events and interface introspection
Classes
Autoscan the chain for 4626 vaults. |
Exceptions
- exception HypersyncCrappedOut
Bases:
Exception- __init__(*args, **kwargs)
- __new__(**kwargs)
- add_note()
Exception.add_note(note) – add a note to the exception
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class HypersyncVaultDiscover
Bases:
eth_defi.erc_4626.discovery_base.VaultDiscoveryBaseAutoscan the chain for 4626 vaults.
First build map of potential contracts using
scan_potential_vaults()Then probe given contracts and determine their ERC-4626 vault properties
See scan-erc_4626_vaults for usage.
Create vault discover.
- Parameters
web3 – Current process web3 connection
web3factory – Used to initialise connection in created worker threads/processes
client – HyperSync client used to scan lead event data
max_workers – How many worker processes use in multicall probing
- Parma recv_timeout
Hypersync core reading loop timeout.
- __init__(web3, web3factory, client, max_workers=8, recv_timeout=90.0)
Create vault discover.
- Parameters
web3 (web3.main.Web3) – Current process web3 connection
web3factory (eth_defi.event_reader.web3factory.Web3Factory) – Used to initialise connection in created worker threads/processes
client (hypersync.HypersyncClient) – HyperSync client used to scan lead event data
max_workers (int) – How many worker processes use in multicall probing
recv_timeout (float) –
- Parma recv_timeout
Hypersync core reading loop timeout.
- get_topic_signatures()
Contracts must have at least one event of both these signatures
Find contracts emitting these events
Later prod these contracts to see which of them are proper vaults
We are likely having a real ERC-4262 contract if both events match,
Depositevent might have few similar contractsAlso includes BrinkVault DepositFunds/WithdrawFunds events
- Return type
- build_query(start_block, end_block)
Create HyperSync query that extracts all potential lead events from the chain.
See example here: https://github.com/enviodev/hypersync-client-python/blob/main/examples/all-erc20-transfers.py
- fetch_leads(start_block, end_block, display_progress=True, attempts=3, retry_sleep=30)
Synchronous wrapper around async lead scanning.
- async scan_potential_vaults(start_block, end_block, display_progress=True)
Identify smart contracts emitting 4626 like events.
Scan all event matches using HyperSync
See stream() example here: https://github.com/enviodev/hypersync-client-python/blob/main/examples/all-erc20-transfers.py
- 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
- 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]) –