erc_4626.vault_protocol.d2.settlement

Documentation for eth_defi.erc_4626.vault_protocol.d2.settlement Python module.

D2 Finance settlement and phase event reader.

D2 vaults are epoch based. The contract emits lifecycle events that explain historical phase transitions:

EpochStarted

New funding/epoch schedule was published. The event payload contains the funding start, epoch start, and epoch end timestamps used to infer when deposits and redemptions are expected to be open.

FundsCustodied

Vault funds were moved to the trading account for the epoch.

FundsReturned

Vault funds were returned after the epoch, making redemption checks open again when notCustodiedAndNotDuringEpoch() is true.

NewMaxDeposits

Deposit capacity changed.

Functions

build_d2_settlement_rows_from_logs(vault, logs)

Build generic settlement rows from D2 settlement and phase logs.

fetch_d2_settlements(vault, start_block, ...)

Fetch D2 settlement and phase transition events for a vault.

get_d2_settlement_events_by_topic(vault)

Return D2 settlement and phase event classes keyed by topic0.

update_d2_settlement_database(database, ...)

Fetch and store D2 settlement and phase transition events.

fetch_d2_settlements(vault, start_block, end_block, use_hypersync=None, chunk_size=50000)

Fetch D2 settlement and phase transition events for a vault.

Parameters
  • vault (eth_defi.erc_4626.vault_protocol.d2.vault.D2Vault) – D2 vault adapter.

  • start_block (int) – Inclusive start block.

  • end_block (int) – Inclusive end block.

  • use_hypersync (Optional[bool]) – Whether to use Hypersync. None auto-detects based on environment.

  • chunk_size (int) – JSON-RPC eth_getLogs chunk size used by the fallback reader.

Returns

Generic settlement rows sorted by block and transaction hash.

Return type

list[eth_defi.vault.settlement_data.VaultSettlement]

update_d2_settlement_database(database, vault, start_block, end_block, use_hypersync=None, chunk_size=50000)

Fetch and store D2 settlement and phase transition events.

Parameters
Returns

Number of settlement rows written.

Return type

int

get_d2_settlement_events_by_topic(vault)

Return D2 settlement and phase event classes keyed by topic0.

Parameters

vault (eth_defi.erc_4626.vault_protocol.d2.vault.D2Vault) – D2 vault adapter.

Returns

Mapping from topic0 to event class.

Return type

dict[str, web3.contract.contract.ContractEvent]

build_d2_settlement_rows_from_logs(vault, logs, event_by_topic=None)

Build generic settlement rows from D2 settlement and phase logs.

Parameters
Returns

Settlement rows sorted by block and transaction hash.

Return type

list[eth_defi.vault.settlement_data.VaultSettlement]