approve_and_execute_velora_swap

Documentation for eth_defi.erc_4626.vault_protocol.lagoon.velora.approve_and_execute_velora_swap function.

approve_and_execute_velora_swap(asset_manager_wallet, vault, buy_token, sell_token, amount_in, broadcast_callback=<function _default_broadcast_callback>, slippage_bps=250, api_timeout=datetime.timedelta(seconds=30))

High-level function: fetch quote, build tx, approve, and execute swap.

This is the main entry point for executing Velora swaps through a Lagoon vault.

Example:

from decimal import Decimal
from eth_defi.erc_4626.vault_protocol.lagoon.velora import approve_and_execute_velora_swap
from eth_defi.token import fetch_erc20_details

weth = fetch_erc20_details(web3, "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1")
usdc = fetch_erc20_details(web3, "0xaf88d065e77c8cC2239327C5EDb3A432268e5831")

result = approve_and_execute_velora_swap(
    asset_manager_wallet=hot_wallet,
    vault=lagoon_vault,
    buy_token=usdc,
    sell_token=weth,
    amount_in=Decimal("0.1"),
    slippage_bps=100,  # 1% slippage
)

print(f"Swapped {result.get_amount_sold_decimal()} WETH for {result.get_amount_bought_decimal()} USDC")
Parameters
Returns

VeloraSwapResult with transaction hash and amounts

Raises

VeloraAPIError – If the Velora API returns an error

Return type

eth_defi.velora.swap.VeloraSwapResult