erc_4626.vault_protocol.lagoon.velora

Documentation for eth_defi.erc_4626.vault_protocol.lagoon.velora Python module.

Velora (ParaSwap) swap support for Lagoon vaults.

Velora is a DEX aggregator that executes swaps atomically, unlike CowSwap which uses an offchain order book and presigning.

Flow:

  1. Fetch quote from Velora API (GET /prices)

  2. Build swap transaction from Velora API (POST /transactions/:network)

  3. Approve TokenTransferProxy via vault’s performCall()

  4. Execute swap via swapAndValidateVelora() on TradingStrategyModuleV0

See Velora developer documentation for more details.

Functions

approve_and_execute_velora_swap(...[, ...])

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

approve_velora(vault, token, amount)

Approve Velora TokenTransferProxy to spend tokens on behalf of the vault.

build_velora_swap(vault, buy_token, ...)

Build swapAndValidateVelora() call on TradingStrategyModuleV0.

execute_velora_swap(asset_manager, vault, ...)

Execute a Velora swap through the vault.

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

approve_velora(vault, token, amount)

Approve Velora TokenTransferProxy to spend tokens on behalf of the vault.

Warning

Approve TokenTransferProxy, NOT Augustus Swapper. Funds may be lost if approved to Augustus directly.

Parameters
Returns

Contract function to execute via performCall

Return type

web3.contract.contract.ContractFunction

build_velora_swap(vault, buy_token, sell_token, amount_in, min_amount_out, augustus_calldata)

Build swapAndValidateVelora() call on TradingStrategyModuleV0.

Parameters
Returns

Contract function to execute

Return type

web3.contract.contract.ContractFunction

execute_velora_swap(asset_manager, vault, buy_token, sell_token, amount_in, min_amount_out, augustus_calldata, broadcast_callback=<function _default_broadcast_callback>)

Execute a Velora swap through the vault.

This builds and broadcasts the swapAndValidateVelora() transaction and extracts the result from the VeloraSwapExecuted event.

Parameters
Returns

VeloraSwapResult with transaction hash and amounts

Return type

eth_defi.velora.swap.VeloraSwapResult