fund_lagoon_vault

Documentation for eth_defi.lagoon.testing.fund_lagoon_vault function.

fund_lagoon_vault(web3, vault_address, asset_manager, test_account_with_balance, trading_strategy_module_address, amount=Decimal('500'), nav=Decimal('0'), hot_wallet=None, token_cache=None)

Deposit tokens into a Lagoon vault so the Safe holds funds.

Supports two transaction signing modes:

  • Anvil mode (default): uses .transact({"from": ...}) for unlocked accounts on Anvil forks. This is the mode used by pytest fixtures.

  • HotWallet mode: when hot_wallet is provided, signs and broadcasts each transaction via HotWallet.transact_and_broadcast_with_contract(). Use this for real deployments and scripts.

Example (Anvil mode — pytest):

fund_lagoon_vault(
    web3,
    vault.address,
    asset_manager,
    depositor,
    module.address,
    amount=Decimal(500),
)

Example (HotWallet mode — deploy script):

deployer = HotWallet.from_private_key(os.environ["PRIVATE_KEY"])
deployer.sync_nonce(web3)
fund_lagoon_vault(
    web3,
    vault.address,
    deployer.address,
    deployer.address,
    module.address,
    amount=Decimal(2),
    hot_wallet=deployer,
)
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.

  • asset_manager (eth_typing.evm.HexAddress) – Address that has the updateNewTotalAssets + settleDeposit role on the vault.

  • test_account_with_balance (eth_typing.evm.HexAddress) – Address that holds the denomination token and will deposit.

  • trading_strategy_module_address (eth_typing.evm.HexAddress) – Address of the TradingStrategyModuleV0 guard contract.

  • amount – Human-readable amount to deposit (e.g. Decimal(500) for 500 USDC).

  • nav – NAV value to post during settlement (usually Decimal(0) for initial funding).

  • 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]) –