Overview
TheBridgeData struct is a standardized data structure used across all LiFi bridge facets. It contains the essential information needed to execute a cross-chain transfer, regardless of which bridge protocol is being used.
This standardization allows LiFi to support multiple bridge integrations while maintaining a consistent interface.
Type Definition
Fields
Unique identifier for this cross-chain transaction. This ID is used for tracking and correlating events across the bridge lifecycle.Example:
0x1234567890abcdef...Note: Should be unique per transaction to enable proper tracking and avoid collisions.The name of the bridge protocol being used for this transfer.Examples:
"across", "stargate", "hop", "cbridge"Purpose: Used for event emissions and analytics to track which bridge handled the transfer.Address or identifier of the integrator/partner initiating this transaction.Purpose: Enables revenue sharing and tracking for partners integrating LiFi.Example:
"myapp.xyz"Address that referred this transaction, used for fee distribution.Purpose: Supports referral programs and fee sharing.Example:
0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbNote: Use zero address (0x0000000000000000000000000000000000000000) if no referrer.The token contract address being sent/bridged.Examples:
- ERC20 token:
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48(USDC) - Native asset:
0x0000000000000000000000000000000000000000
The recipient address on the destination chain that will receive the bridged tokens.Example:
0x9876543210fedcba9876543210fedcba98765432Important: Ensure this address is valid on the destination chain.The minimum amount of tokens that must be received on the destination chain for the transaction to succeed.Purpose: Protects users from excessive slippage during the bridging process.Example:
1000000 (1 USDC with 6 decimals)Calculation: desiredAmount * (1 - maxSlippagePercent)The chain ID of the destination blockchain.Examples:
- Ethereum Mainnet:
1 - Polygon:
137 - Arbitrum:
42161 - Optimism:
10
Indicates whether token swaps are performed on the source chain before bridging.Values:
true: UsingswapAndStartBridgeTokensVia{Bridge}functionfalse: UsingstartBridgeTokensVia{Bridge}function (direct bridge)
Indicates whether there is a contract call to be executed on the destination chain after tokens arrive.Values:
true: Tokens will be used to call a contract on the destination chainfalse: Tokens will be sent directly to the receiver address
Usage Example
Direct Bridge (No Swaps)
Swap and Bridge
Related Events
When a bridge transaction is initiated, the following event is emitted:BridgeData struct, allowing off-chain systems to track the transaction across chains.
Best Practices
Transaction ID Generation
Generate unique transaction IDs to avoid conflicts:Slippage Calculation
Always calculateminAmount with appropriate slippage tolerance: