System Overview
LI.FI architectural overview
Introduction
LI.FI is a multi-chain liquidity aggregation platform that connects decentralized applications (dApps) with various liquidity sources, including bridges, decentralized exchanges (DEXs), and solvers. This architecture enables seamless cross-chain and same-chain trading by facilitating price discovery, smart order routing, and efficient execution.
Key Components of LI.FI Architecture
1. dApp Interface (Integrators)
- Function: What the end-user interacts with. dApps initiate quote requests and route selection to LI.FI’s backend (BE).
- Process: A user sends a request from the dApp for the best trading route or quote, which is forwarded to LI.FI BE for processing. Once the optimal route is selected, the dApp submits a transaction to execute the trade.
2. LI.FI Backend (BE) - Aggregation and Routing Layer
- Purpose: This off-chain layer performs core price discovery and smart order routing by interfacing with various liquidity sources.
- Functionality:
- Fetch Pricing: LI.FI BE retrieves quotes from multiple sources, including bridges, DEXs, and solvers, to determine the best price and route.
- Return Quote: Once the optimal route is identified, LI.FI BE returns the quote to the dApp.
- Order Routing: The dApp submits the transaction with the selected route, which LI.FI BE processes by routing it to the LI.FI Diamond Contract on-chain.
3. LI.FI Diamond Contract
- Function: Acts as the primary on-chain entry point, handling the execution of transactions based on the chosen route from LI.FI BE.
- Role:
- Routes the transaction to the appropriate facet contract (bridge, DEX, or solver) based on the chosen liquidity source.
- Acts as the router for on-chain executions, allowing modular connections to different liquidity sources.
4. LI.FI Facet Contracts
Specialized on-chain contracts that interface with respective liquidity sources:
-
Bridge Facet Contracts
- Route transactions to specific bridge contracts (e.g., Bridge A or Bridge B) for cross-chain transfers.
- Ensure bridge compatibility and secure asset transfer across blockchains.
-
DEX Facet Contracts
- Route transactions to specific DEX contracts for same-chain swaps.
- Optimize execution based on DEX-specific parameters for efficient liquidity utilization.
-
Solver Facet Contracts
- Route transactions to solver contracts for accessing extended liquidity sources.
- Enable advanced routing and pricing calculations based on solver protocols.
5. Bridge/DEX/Solver Contracts
Final execution of trades occurs on the blockchain network through interactions with selected liquidity providers (bridge, DEX, or solver contracts).
End-to-End Order Flow
-
Initiate Request
- A user initiates a quote request from the dApp for a multi-chain or same-chain trade.
-
Quote and Route Discovery
- LI.FI BE receives the request and queries bridges, DEX aggregators, and solvers to gather pricing data and route options.
- The optimal route is determined and returned to the dApp.
-
Transaction Submission
- The user selects the best route in the dApp, which submits the transaction to LI.FI Diamond contract with the selected quote data.
-
On-Chain Execution
- LI.FI Diamond contract forwards the transaction to the respective LI.FI Facet contract for execution.
- The facet contract executes the transaction with the specific bridge, DEX, or solver on-chain contract, finalizing the trade or transfer.
-
Output Return
- Once the transaction is complete, the resulting assets are returned to the user.