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
Returns

Quote containing route and pricing information

Raises

VeloraAPIError – If the API returns an error

Return type

eth_defi.velora.quote.VeloraQuote