GenericSwapFacet enables users to perform same-chain token swaps through any DEX or swap aggregator. This facet is useful when you need to swap tokens without bridging to another chain.
Functions
swapTokensGeneric
Executes one or more token swaps and transfers the result to a receiver.Unique identifier for this transaction
Name or identifier of the integrator
Referrer address or identifier
Address that will receive the swapped tokens
Minimum amount of tokens expected after all swaps (slippage protection)
Array of swap data structures defining the swap operations to execute
Data Structures
LibSwap.SwapData
Defines a single swap operation.The DEX or swap contract to call
The address to approve for spending tokens (usually the same as callTo)
Address of the token being sold (use zero address for native token)
Address of the token being bought (use zero address for native token)
Amount of sendingAssetId to swap
Encoded function call data for the swap
Whether the contract should hold the tokens before swapping
Events
LiFiSwappedGeneric
Emitted when a generic swap is executed.The transaction identifier
The integrator name
The referrer identifier
Token being sold
Token being bought
Amount sold
Amount received
LiFiGenericSwapCompleted
Emitted when all swaps are completed and tokens are transferred to receiver.The transaction identifier
The integrator name
The referrer identifier
Address receiving the final tokens
Initial token
Final token
Initial amount
Final amount received
AssetSwapped
Emitted for each individual swap in the swap array.The transaction identifier
The DEX contract used
Token being sold
Token being bought
Amount sold
Amount received
Block timestamp