Function Signature
Description
Executes a complete Li.Fi bridge or swap: discovers routes, selects one, then for each step builds the transaction, signs and broadcasts it, waits for on-chain confirmation, and polls Li.Fi until that step reaches a terminal state before moving to the next.
Steps run sequentially. Signing and confirmation for each step happen on that step’s own chain, resolved from the step itself, so a multi-chain route is handled without the caller switching networks.
Confirmation is strict — every step must confirm on-chain before the next begins. A revert or a confirmation timeout aborts the trade and throws. There is no optimistic fallback.
Unlike the React Native and Web SDKs, there is no second options argument. The signer and confirmation hooks are injected when the Lifi instance is constructed, and Portal wires both automatically.
Parameters
LifiTradeAssetParams:
Omitting fromAddress means routes are quoted without a sender while the transaction is still signed by your Portal wallet, so the quote may not match what executes. Pass it explicitly.
Returns
LifiTradeAssetResult:
Throws
Throws LifiTradeAssetError:
Also throws CancellationError if the surrounding Task is cancelled. In that case no .failed progress event is emitted — handle cancellation separately from failure.
Example Usage
Related Documentation