Skip to main content
The SwapperV2 contract is a base contract that provides event definitions used across swap operations in the LiFi protocol. It doesn’t expose any public functions but defines the standard events emitted during swap and bridge operations.

Purpose

SwapperV2 serves as a shared event interface for:
  • Generic swap operations
  • Bridge operations
  • Cross-chain transfers
  • Event tracking and indexing

Events

LiFiSwappedGeneric

Emitted when a generic token swap is executed.
transactionId
bytes32
Unique identifier for the transaction
integrator
string
Name or identifier of the integrator
referrer
string
Referrer address or identifier
fromAssetId
address
Address of the token being swapped from
toAssetId
address
Address of the token being swapped to
fromAmount
uint256
Amount of tokens swapped from
toAmount
uint256
Amount of tokens received

LiFiGenericSwapCompleted

Emitted when a swap operation completes and tokens are transferred to the receiver.
transactionId
bytes32
Unique identifier for the transaction
integrator
string
Name or identifier of the integrator
referrer
string
Referrer address or identifier
receiver
address
Address receiving the swapped tokens
fromAssetId
address
Address of the initial token
toAssetId
address
Address of the final token
fromAmount
uint256
Initial token amount
toAmount
uint256
Final token amount received

LiFiTransferStarted

Emitted when a bridge transfer is initiated.
bridgeData
ILiFi.BridgeData
Complete bridge data structure containing:
  • transactionId: Unique transaction identifier
  • bridge: Name of the bridge being used
  • integrator: Integrator identifier
  • referrer: Referrer address
  • sendingAssetId: Token being sent
  • receiver: Destination address
  • minAmount: Minimum amount expected
  • destinationChainId: Target chain ID
  • hasSourceSwaps: Whether source swaps are included
  • hasDestinationCall: Whether destination calls are included

LiFiTransferCompleted

Emitted when a transfer is successfully completed.
transactionId
bytes32
Unique identifier for the transaction
receivingAssetId
address
Address of the token received
receiver
address
Address that received the tokens
amount
uint256
Amount of tokens received
timestamp
uint256
Block timestamp when completed

LiFiTransferRecovered

Emitted when tokens are recovered from a failed transfer.
transactionId
bytes32
Unique identifier for the transaction
receivingAssetId
address
Address of the token recovered
receiver
address
Address receiving the recovered tokens
amount
uint256
Amount of tokens recovered
timestamp
uint256
Block timestamp when recovered

BridgeToNonEVMChain

Emitted when bridging to a non-EVM chain with bytes receiver.
transactionId
bytes32
Unique identifier for the transaction
destinationChainId
uint256
Target chain identifier
receiver
bytes
Receiver address in bytes format

BridgeToNonEVMChainBytes32

Emitted when bridging to a non-EVM chain with bytes32 receiver.
transactionId
bytes32
Unique identifier for the transaction
destinationChainId
uint256
Target chain identifier
receiver
bytes32
Receiver address in bytes32 format

Usage Example

import { SwapperV2__factory } from '@lifi/contract-types';
import { ethers } from 'ethers';

const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const contract = SwapperV2__factory.connect(CONTRACT_ADDRESS, provider);

// Listen to swap events
contract.on('LiFiSwappedGeneric', (
  transactionId,
  integrator,
  referrer,
  fromAssetId,
  toAssetId,
  fromAmount,
  toAmount
) => {
  console.log('Swap executed:', {
    transactionId,
    from: fromAssetId,
    to: toAssetId,
    amount: ethers.utils.formatUnits(toAmount, 18)
  });
});

// Listen to transfer completion
contract.on('LiFiTransferCompleted', (
  transactionId,
  receivingAssetId,
  receiver,
  amount,
  timestamp
) => {
  console.log('Transfer completed:', {
    transactionId,
    receiver,
    amount: ethers.utils.formatUnits(amount, 18)
  });
});

Build docs developers (and LLMs) love