fetch_velora_quote
Documentation for eth_defi.velora.quote.fetch_velora_quote function.
- fetch_velora_quote(from_, buy_token, sell_token, amount_in, api_timeout=datetime.timedelta(seconds=30), partner=None, max_impact=None)
Fetch a Velora price quote for a given token pair.
This calls the Velora /prices endpoint to get the optimal route and pricing for a swap.
Example:
from decimal import Decimal from eth_defi.token import fetch_erc20_details from eth_defi.velora.quote import fetch_velora_quote weth = fetch_erc20_details(web3, "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1") usdc = fetch_erc20_details(web3, "0xaf88d065e77c8cC2239327C5EDb3A432268e5831") quote = fetch_velora_quote( from_=vault_address, buy_token=usdc, sell_token=weth, amount_in=Decimal("0.1"), ) print(f"Price: {quote.get_price()}") print(f"Will receive: {quote.get_buy_amount()} USDC")
- Parameters
from – Address that will execute the swap (for routing optimisation)
buy_token (eth_defi.token.TokenDetails) – Token to receive (destination token)
sell_token (eth_defi.token.TokenDetails) – Token to sell (source token)
amount_in (decimal.Decimal) – Amount of sell_token to swap (human-readable decimals)
api_timeout (datetime.timedelta) – API request timeout
partner (str | None) – Partner name for analytics tracking
max_impact (int | None) – Maximum price impact threshold percentage (default 15%)
from_ (Union[eth_typing.evm.HexAddress, str]) –
- Returns
Quote containing route and pricing information
- Raises
VeloraAPIError – If the API returns an error
- Return type