CrossChainSwap

Documentation for eth_defi.lifi.crosschain.CrossChainSwap Python class.

class CrossChainSwap

Bases: object

A prepared cross-chain gas top-up swap.

Contains all information needed to execute a bridge transaction from the source chain to a target chain.

Attributes summary

source_chain_id

Source chain ID where funds are bridged from

target_chain_id

Target chain ID where gas is needed

from_amount_raw

Amount of source token to send (raw units: wei for native, or token decimals for ERC-20)

from_amount_usd

Value of the bridged amount in USD

target_balance_usd

Current gas balance on the target chain in USD

min_gas_usd

Minimum gas threshold that triggered this swap (USD)

top_up_usd

Requested top-up amount in USD

transaction_request

Ready-to-sign transaction request from LI.FI

quote

The LI.FI quote used to build this swap

Methods summary

__init__(source_chain_id, target_chain_id, ...)

is_valid([max_age_seconds])

Check if the underlying quote is still fresh enough to execute.

source_chain_id: int

Source chain ID where funds are bridged from

target_chain_id: int

Target chain ID where gas is needed

from_amount_raw: int

Amount of source token to send (raw units: wei for native, or token decimals for ERC-20)

from_amount_usd: decimal.Decimal

Value of the bridged amount in USD

target_balance_usd: decimal.Decimal

Current gas balance on the target chain in USD

min_gas_usd: decimal.Decimal

Minimum gas threshold that triggered this swap (USD)

top_up_usd: decimal.Decimal

Requested top-up amount in USD

transaction_request: dict

Ready-to-sign transaction request from LI.FI

Contains from, to, data, value, gasLimit, gasPrice, chainId.

quote: eth_defi.lifi.quote.LifiQuote

The LI.FI quote used to build this swap

is_valid(max_age_seconds=120)

Check if the underlying quote is still fresh enough to execute.

Delegates to is_valid().

Parameters

max_age_seconds (float) – Maximum acceptable age in seconds (default 120s)

Return type

bool

__init__(source_chain_id, target_chain_id, from_amount_raw, from_amount_usd, target_balance_usd, min_gas_usd, top_up_usd, transaction_request, quote)
Parameters
Return type

None