fetch_lifi_quote
Documentation for eth_defi.lifi.quote.fetch_lifi_quote function.
- fetch_lifi_quote(from_chain_id, to_chain_id, from_token, to_token, from_amount, from_address, to_address=None, slippage=0.03, order='CHEAPEST', api_timeout=30)
Fetch a cross-chain quote from the LI.FI API.
Calls
GET /v1/quoteto get a bridge/swap quote with ready-to-sign transaction data.Example:
from eth_defi.lifi.quote import fetch_lifi_quote from eth_defi.lifi.constants import LIFI_NATIVE_TOKEN_ADDRESS quote = fetch_lifi_quote( from_chain_id=1, # Ethereum to_chain_id=42161, # Arbitrum from_token=LIFI_NATIVE_TOKEN_ADDRESS, to_token=LIFI_NATIVE_TOKEN_ADDRESS, from_amount=10000000000000000, # 0.01 ETH in wei from_address="0xYourWalletAddress", ) tx_request = quote.get_transaction_request() # Sign and send tx_request
- Parameters
from_chain_id (int) – Source chain ID
to_chain_id (int) – Destination chain ID
from_token (str) – Source token address (use
LIFI_NATIVE_TOKEN_ADDRESSfor native token)to_token (str) – Destination token address (use
LIFI_NATIVE_TOKEN_ADDRESSfor native token)from_amount (int) – Amount to send in raw units (wei for ETH)
from_address (str) – Sender wallet address
to_address (str | None) – Recipient wallet address. If None, defaults to
from_address.slippage (float) – Maximum allowed slippage as a decimal (0.03 = 3%)
order (str) – Route preference:
CHEAPESTorFASTESTapi_timeout (float) – API request timeout in seconds
- Returns
Quote with transaction data ready for signing
- Raises
LifiAPIError – If the API returns an error or no route is found
- Return type