erc_4626.settlement_events
Documentation for eth_defi.erc_4626.settlement_events Python module.
ERC-4626 event reader helpers for settlement-style events.
This module contains the chain-log mechanics shared by protocol-specific
settlement readers. Protocol modules decide which events matter; this helper
fetches logs and converts them to eth_defi.vault.settlement_data.VaultSettlement
rows for the generic DuckDB store.
Functions
|
Build generic settlement rows from vault logs. |
|
Fetch vault settlement-style logs using Hypersync or JSON-RPC. |
Fetch vault settlement-style logs for multiple vaults as one address batch. |
|
Fetch vault settlement-style logs using Hypersync. |
|
Fetch vault settlement-style logs for multiple vaults using Hypersync. |
|
|
Fetch vault settlement-style logs using chunked JSON-RPC |
|
Return lower-case |
|
Resolve a Web3 log event name. |
Convert a Hypersync log to Web3.py log shape. |
|
|
Normalise a Web3 log topic value to lowercase |
|
Normalise an event topic. |
Check whether Hypersync should be used for event reads. |
- get_event_topic(event)
Return lower-case
0x-prefixed event topic0.- Parameters
event (web3.contract.contract.ContractEvent) – Web3.py contract event class.
- Returns
Normalised topic string.
- Return type
- normalise_topic(topic)
Normalise an event topic.
- should_use_hypersync()
Check whether Hypersync should be used for event reads.
- Returns
TrueifHYPERSYNC_API_KEYexists andUSE_HYPERSYNCis not explicitly disabled.- Return type
- fetch_vault_settlement_logs(*, web3, address, topic0_list, start_block, end_block, use_hypersync=None, chunk_size=50000)
Fetch vault settlement-style logs using Hypersync or JSON-RPC.
- Parameters
web3 (web3.main.Web3) – Web3 connection for the vault chain.
address (Union[eth_typing.evm.HexAddress, str]) – Vault contract address.
start_block (int) – Inclusive start block.
end_block (int) – Inclusive end block.
use_hypersync (Optional[bool]) – Whether to use Hypersync.
Noneauto-detects based on environment.chunk_size (int) – JSON-RPC
eth_getLogschunk size used by the fallback reader.
- Returns
Web3-compatible log objects.
- Return type
list[web3.datastructures.AttributeDict]
- fetch_vault_settlement_logs_for_addresses(*, web3, addresses, topic0_list, start_block, end_block, use_hypersync=None, chunk_size=50000)
Fetch vault settlement-style logs for multiple vaults as one address batch.
- Parameters
web3 (web3.main.Web3) – Web3 connection for the vault chain.
addresses (list[eth_typing.evm.HexAddress | str]) – Vault contract addresses.
start_block (int) – Inclusive start block.
end_block (int) – Inclusive end block.
use_hypersync (Optional[bool]) – Whether to use Hypersync.
Noneauto-detects based on environment.chunk_size (int) – JSON-RPC
eth_getLogschunk size used by the fallback reader.
- Returns
Web3-compatible log objects.
- Return type
list[web3.datastructures.AttributeDict]
- fetch_vault_settlement_logs_hypersync(*, web3, address, topic0_list, start_block, end_block)
Fetch vault settlement-style logs using Hypersync.
- Parameters
- Returns
Web3-compatible log objects.
- Return type
list[web3.datastructures.AttributeDict]
- fetch_vault_settlement_logs_hypersync_for_addresses(*, web3, addresses, topic0_list, start_block, end_block)
Fetch vault settlement-style logs for multiple vaults using Hypersync.
- Parameters
- Returns
Web3-compatible log objects.
- Return type
list[web3.datastructures.AttributeDict]
- indexed_log_to_web3_log(log)
Convert a Hypersync log to Web3.py log shape.
- Parameters
log (eth_defi.vault.flow_events.IndexedVaultFlowLog) – Hypersync log wrapper.
- Returns
Web3.py-style log.
- Return type
web3.datastructures.AttributeDict
- fetch_vault_settlement_logs_rpc(*, web3, address, topics, start_block, end_block, chunk_size)
Fetch vault settlement-style logs using chunked JSON-RPC
eth_getLogs.- Parameters
web3 (web3.main.Web3) – Web3 connection.
address (Union[eth_typing.evm.HexAddress, str, list[eth_typing.evm.HexAddress | str]]) – Vault contract address or list of addresses.
start_block (int) – Inclusive start block.
end_block (int) – Inclusive end block.
chunk_size (int) – Maximum block count per
eth_getLogscall.
- Returns
Web3-compatible logs.
- Return type
list[web3.datastructures.AttributeDict]
- build_settlement_rows_from_logs(*, chain_id, address, web3, protocol, logs, event_by_topic=None)
Build generic settlement rows from vault logs.
- Parameters
chain_id (int) – Vault chain id.
address (Union[eth_typing.evm.HexAddress, str]) – Vault address.
web3 (Optional[web3.main.Web3]) – Web3 connection, needed when logs do not contain timestamps or block hashes.
protocol (str) – Protocol name stored in DuckDB.
logs (list[web3.datastructures.AttributeDict]) – Web3-compatible logs.
event_by_topic (Optional[collections.abc.Mapping[str, Union[web3.contract.contract.ContractEvent, str]]]) – Optional event topic0 to event class/name mapping used to populate
event_name.
- Returns
Settlement rows sorted by block and transaction hash.
- Return type
- get_log_event_name(log, event_by_topic)
Resolve a Web3 log event name.
- Parameters
log (web3.datastructures.AttributeDict) – Web3-compatible log.
event_by_topic (collections.abc.Mapping[str, Union[web3.contract.contract.ContractEvent, str]]) – Mapping from normalised topic0 to event class or event name.
- Returns
Event name, or empty string if it cannot be resolved.
- Return type