erc_4626.vault_protocol.lagoon.testing
Documentation for eth_defi.erc_4626.vault_protocol.lagoon.testing Python module.
Lagoon unit test helpers.
Functions
|
Force settling of the Lagoon vault. |
|
Request a full redemption of vault shares for a given depositor. |
Request a full redemption of vault shares for a given depositor.
Initiates Phase 1 of the ERC-7540 async redemption flow:
Approve all shares for the vault
Call
requestRedeem()to queue the redemption
After calling this function, the vault must be settled to process the redemption (Phase 2), then the redeemer calls
vault.finalise_redeem()to claim their USDC (Phase 3).Supports two transaction signing modes:
Anvil mode (default): uses
.transact({"from": ...})for unlocked accounts on Anvil forks.HotWallet mode: when hot_wallet is provided, signs and broadcasts each transaction via
HotWallet.transact_and_broadcast_with_contract().
Example (HotWallet mode):
deployer.sync_nonce(web3) vault = redeem_vault_shares( web3, vault_address, redeemer=deployer.address, hot_wallet=deployer, ) # Then settle the vault (e.g. via CLI lagoon-settle) # Then finalise: tx_hash = deployer.transact_and_broadcast_with_contract( vault.finalise_redeem(deployer.address), )- Parameters
web3 (web3.main.Web3) – Web3 connection to the chain where the vault lives.
vault_address (eth_typing.evm.HexAddress) – On-chain address of the Lagoon vault.
redeemer (eth_typing.evm.HexAddress) – Address that holds vault shares and wants to redeem them.
hot_wallet (Optional[eth_defi.hotwallet.HotWallet]) – When provided, all transactions are signed with this wallet instead of using Anvil’s unlocked-account shortcut.
token_cache (Optional[eth_defi.token.TokenDiskCache]) –
- Returns
The
LagoonVaultinstance, which can be used for Phase 3 (vault.finalise_redeem()).- Return type
- force_lagoon_settle(vault, asset_manager, settlement_manager=None, raw_nav=None, gas_limit=15000000)
Force settling of the Lagoon vault.
Used in the testing to move the vault to the next epoch
- Parameters
asset_manager (eth_typing.evm.HexAddress) – Valuation-manager account, spoofed in Anvil.
settlement_manager (Optional[eth_typing.evm.HexAddress]) – Safe account that submits the settlement. Defaults to
asset_managerfor legacy test callers where both roles coincide.vault (eth_defi.erc_4626.vault_protocol.lagoon.vault.LagoonVault) –
gas_limit (int) –
- Return type
tuple[hexbytes.main.HexBytes, hexbytes.main.HexBytes]