redeem_vault_shares
Documentation for eth_defi.lagoon.testing.redeem_vault_shares function.
- redeem_vault_shares(web3, vault_address, redeemer, hot_wallet=None, token_cache=None)
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