Skip to main content

Overview

The ILiFi interface is the foundational contract interface for the LiFi protocol. It defines the core data structures and events used throughout the protocol for cross-chain bridging and transfer operations.

BridgeData Struct

The BridgeDataStruct contains all necessary information for executing a cross-chain bridge transaction.

Type Signature

export type BridgeDataStruct = {
  transactionId: PromiseOrValue<BytesLike>;
  bridge: PromiseOrValue<string>;
  integrator: PromiseOrValue<string>;
  referrer: PromiseOrValue<string>;
  sendingAssetId: PromiseOrValue<string>;
  receiver: PromiseOrValue<string>;
  minAmount: PromiseOrValue<BigNumberish>;
  destinationChainId: PromiseOrValue<BigNumberish>;
  hasSourceSwaps: PromiseOrValue<boolean>;
  hasDestinationCall: PromiseOrValue<boolean>;
};

Fields

transactionId
bytes32
required
Unique identifier for the transaction across the LiFi protocol
bridge
string
required
Name of the bridge protocol being used (e.g., “stargate”, “hop”, “across”)
integrator
string
required
Address or identifier of the integrator using the LiFi protocol
referrer
string
required
Address of the referrer for fee sharing purposes
sendingAssetId
address
required
Contract address of the token being sent (use zero address for native tokens)
receiver
address
required
Destination address that will receive the bridged assets
minAmount
uint256
required
Minimum amount of tokens expected on the destination chain (for slippage protection)
destinationChainId
uint256
required
Chain ID of the destination blockchain
hasSourceSwaps
bool
required
Whether the transaction includes token swaps on the source chain before bridging
hasDestinationCall
bool
required
Whether the transaction includes additional calls on the destination chain after bridging

Usage Example

import { ILiFi } from './typechain-types';

const bridgeData: ILiFi.BridgeDataStruct = {
  transactionId: '0x1234...', // Unique transaction ID
  bridge: 'stargate',
  integrator: '0xIntegratorAddress',
  referrer: '0xReferrerAddress',
  sendingAssetId: '0xUSDCAddress', // USDC token
  receiver: '0xReceiverAddress',
  minAmount: ethers.utils.parseUnits('100', 6), // 100 USDC
  destinationChainId: 137, // Polygon
  hasSourceSwaps: true,
  hasDestinationCall: false
};

Events

LiFiTransferStarted

Emitted when a cross-chain transfer is initiated.
event LiFiTransferStarted(tuple bridgeData)
bridgeData
BridgeDataStruct
Complete bridge data for the initiated transfer
Usage Example:
contract.on('LiFiTransferStarted', (bridgeData) => {
  console.log('Transfer started:', bridgeData.transactionId);
  console.log('Destination chain:', bridgeData.destinationChainId);
});

LiFiTransferCompleted

Emitted when a cross-chain transfer completes successfully on the destination chain.
event LiFiTransferCompleted(
  bytes32 indexed transactionId,
  address receivingAssetId,
  address receiver,
  uint256 amount,
  uint256 timestamp
)
transactionId
bytes32
The unique transaction identifier
receivingAssetId
address
Address of the token received on the destination chain
receiver
address
Address that received the tokens
amount
uint256
Amount of tokens received
timestamp
uint256
Block timestamp when the transfer completed
Usage Example:
const filter = contract.filters.LiFiTransferCompleted(transactionId);
const events = await contract.queryFilter(filter);
console.log('Transfer completed with amount:', events[0].args.amount);

LiFiTransferRecovered

Emitted when assets are recovered from a failed transfer.
event LiFiTransferRecovered(
  bytes32 indexed transactionId,
  address receivingAssetId,
  address receiver,
  uint256 amount,
  uint256 timestamp
)
transactionId
bytes32
The unique transaction identifier
receivingAssetId
address
Address of the token being recovered
receiver
address
Address receiving the recovered tokens
amount
uint256
Amount of tokens recovered
timestamp
uint256
Block timestamp when the recovery occurred

LiFiSwappedGeneric

Emitted when a token swap occurs as part of a LiFi transaction.
event LiFiSwappedGeneric(
  bytes32 indexed transactionId,
  string integrator,
  string referrer,
  address fromAssetId,
  address toAssetId,
  uint256 fromAmount,
  uint256 toAmount
)
transactionId
bytes32
The unique transaction identifier
integrator
string
Integrator identifier
referrer
string
Referrer identifier
fromAssetId
address
Address of the token being swapped from
toAssetId
address
Address of the token being swapped to
fromAmount
uint256
Amount of tokens sent to the swap
toAmount
uint256
Amount of tokens received from the swap

LiFiGenericSwapCompleted

Emitted when a generic swap completes, including receiver information.
event LiFiGenericSwapCompleted(
  bytes32 indexed transactionId,
  string integrator,
  string referrer,
  address receiver,
  address fromAssetId,
  address toAssetId,
  uint256 fromAmount,
  uint256 toAmount
)
transactionId
bytes32
The unique transaction identifier
integrator
string
Integrator identifier
referrer
string
Referrer identifier
receiver
address
Address that received the swapped tokens
fromAssetId
address
Address of the token being swapped from
toAssetId
address
Address of the token being swapped to
fromAmount
uint256
Amount of tokens sent to the swap
toAmount
uint256
Amount of tokens received from the swap

BridgeToNonEVMChain

Emitted when bridging to a non-EVM chain with a bytes receiver address.
event BridgeToNonEVMChain(
  bytes32 indexed transactionId,
  uint256 indexed destinationChainId,
  bytes receiver
)
transactionId
bytes32
The unique transaction identifier
destinationChainId
uint256
Chain ID of the destination blockchain
receiver
bytes
Receiver address in bytes format (for non-EVM addresses)

BridgeToNonEVMChainBytes32

Emitted when bridging to a non-EVM chain with a bytes32 receiver address.
event BridgeToNonEVMChainBytes32(
  bytes32 indexed transactionId,
  uint256 indexed destinationChainId,
  bytes32 receiver
)
transactionId
bytes32
The unique transaction identifier
destinationChainId
uint256
Chain ID of the destination blockchain
receiver
bytes32
Receiver address in bytes32 format (for chains like Solana)
Usage Example:
// Listen for non-EVM chain bridges
contract.on('BridgeToNonEVMChainBytes32', (txId, chainId, receiver) => {
  console.log(`Bridge to chain ${chainId}`);
  console.log(`Receiver: ${receiver}`);
});

Interface

The ILiFi interface extends BaseContract from ethers and provides methods for querying events and managing listeners.
export interface ILiFi extends BaseContract {
  interface: ILiFiInterface;
  
  filters: {
    LiFiTransferStarted(bridgeData?: null): LiFiTransferStartedEventFilter;
    LiFiTransferCompleted(
      transactionId?: PromiseOrValue<BytesLike> | null,
      receivingAssetId?: null,
      receiver?: null,
      amount?: null,
      timestamp?: null
    ): LiFiTransferCompletedEventFilter;
    // ... other event filters
  };
}

Build docs developers (and LLMs) love