deposit_4626
Documentation for eth_defi.erc_4626.flow.deposit_4626 function.
- deposit_4626(vault, from_, amount=None, raw_amount=None, check_max_deposit=True, check_enough_token=True, receiver=None)
Craft a transaction for ERC-4626 vault deposit.
The resulting payload must be signed by a wallet/vault
The resulting transaction can be analysed with
eth_defi.erc_4626.analysis.analyse_4626_flow_transaction()
Example:
amount = Decimal(100) tx_hash = base_usdc.approve( vault.address, amount, ).transact({"from": depositor}) assert_transaction_success_with_explanation(web3, tx_hash) bound_func = deposit_4626( vault, depositor, amount, ) tx_hash = bound_func.transact({"from": depositor}) assert_transaction_success_with_explanation(web3, tx_hash) tx_receipt = web3.eth.get_transaction_receipt(tx_hash) # Analyse the ERC-4626 deposit transaction analysis = analyse_4626_flow_transaction( vault=vault, tx_hash=tx_hash, tx_receipt=tx_receipt, direction="deposit", ) assert analysis.path == [base_usdc.address_lower, vault.share_token.address_lower] assert analysis.price == pytest.approx(Decimal("1.033566972663402121955991264"))
Another example how to use this with Lagoon, where from (TradingStrategyModuleV0) and receiver (Safe multisig) are different contracts:
fn_calls = approve_and_deposit_4626( vault=erc4626_vault, # IPOR vault we trade amount=usdc_amount, from_=vault.address, # Our Lagoon vault check_enough_token=False, receiver=vault.safe_address, # Safe multisig address of our Lagoon vault )
- Parameters
check_enough_token –
Assume from address holds the token and do live check.
Must be disabled e.g. for Lagoon as TradingStrategyModuleV0 calls are performed from a d different address than the vault address.
vault (eth_defi.erc_4626.vault.ERC4626Vault) –
from_ (eth_typing.evm.HexAddress) –
amount (decimal.Decimal | None) –
raw_amount (int | None) –
- Return type
web3.contract.contract.ContractFunction