redeem_vault_shares

Documentation for eth_defi.erc_4626.vault_protocol.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:

  1. Approve all shares for the vault

  2. 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
Returns

The LagoonVault instance, which can be used for Phase 3 (vault.finalise_redeem()).

Return type

eth_defi.erc_4626.vault_protocol.lagoon.vault.LagoonVault