LI.FI Documentation
LI.FI WebsiteAPI ReferenceHelp / FAQ / Create support ticketRequest API Key
  • 🏡Getting Started
    • ❓What is LI.FI
    • 🌟Why LI.FI?
    • 🆚LI.FI vs Aggregators/DEXs/Bridges
    • 📖LI.FI Terminology
    • ❓FAQ
    • 💡Use Cases
      • Mobile/Gaming Wallets
    • 🏹LI.FI vs. Other Aggregators
    • 🤝Partnership
    • 🌐Powered by LI.FI
  • 🔐Security First
  • ✅List: Chains, Bridges, DEX Aggregators, Solvers
  • 💲Monetization / Take Fees
  • 🔎Transaction Explorer
  • 🔏Rate Limits & API Key
  • How to get integrated by LI.FI?
    • For Bridges
    • For DEXs/Aggregators/Solvers
  • 🆘Technical FAQ
  • LI.FI PRODUCTS
    • Glacis
    • LI.FI Solver
    • LI.FI Intents System
  • LI.FI API
    • ⚙️LI.FI API
      • Transferring Tokens (Example)
      • Requesting supported Chains
      • Requesting all supported Tools
      • Requesting all known Tokens
      • Getting Token Information
      • Getting all possible Connections
      • Requesting a Quote
        • Token Transfer
        • Optimizing quote response timing
        • Cross-Chain Contract Calls
        • Possible Tool Errors
        • Testing your integration
      • Status of a Transaction
      • Requesting Analytics Data
    • ⚔️TX-Batching aka "Zaps"
    • 🏄Solana
      • Request examples
    • 🪙Bitcoin
      • Request examples
    • ⛽LI.Fuel
  • Integrate LI.FI SDK
    • 🚀LI.FI SDK Overview
    • 📦Install LI.FI SDK
    • ⚙️Configure SDK
    • 🪐Configure SDK Providers
    • 📜Request Routes/Quotes
    • 🎯Execute Routes/Quotes
    • ⛓️Chains and Tools
    • 💰Token Management
    • 🕵️Testing Integration
    • 🚗Migrate from v2 to v3
  • INTEGRATE LI.FI WIDGET
    • 🧩LI.FI Widget Overview
    • 📦Install Widget
    • 🎮Select Widget Variants
    • ⚙️Configure Widget
    • 🎨Customize Widget
    • ⚡Widget Events
    • 👛Wallet Management
    • 🌍Internationalization
    • ⚛️Compatibility with Next.js, Remix, Nuxt, etc.
    • 🛣️React Router Compatibility
    • 📖Widget API Reference
    • 🚗Migrate from v2 to v3
  • Smart Contracts
    • Overview
    • Deployments/Contract Addresses
    • Audits
  • Support & Misc.
    • API Status
    • Technical Help Desk & FAQ
    • Create a Partner Ticket
    • Discord Support
    • Telegram Support
    • Twitter
    • Github
    • Licenses
Powered by GitBook
LogoLogo

Connect with us

  • Github
  • Twitter
  • Discord
  • LinkedIn

More Information

  • Help Desk / FAQ
  • API Reference
  • Website
On this page
  • Architecture
  • Transaction and Funds Flow
  • Events

Was this helpful?

Export as PDF
  1. Smart Contracts

Overview

Last updated 3 months ago

Was this helpful?

Architecture

The main LI.FI smart contract is built using the standard. Users interact exclusively with this contract, which is called LiFiDiamond. The LiFiDiamond uses so-called "facet" contracts that it calls via to execute their logic in its own state (contrary to an external call which would execute the logic in state of the external contract being called). This means that all LI.FI transactions go through and are executed by the LiFiDiamond.

The LiFiDiamond furthermore uses so-called "periphery" contracts for specific purposes such as executing external calls in a safe environment (e.g. ), keeping treasury of funds (e.g. ), receiving tokens on destination chain and executing destination calldata (e.g. ) or for pre-bridging tasks (e.g. ).

All LI.FI smart contracts are public and can be found in the repo:

Also please see the section in the repo for more insights into how some of our contracts work in detail.

Transaction and Funds Flow

While the implementations for specific protocols vary greatly, the transaction and funds flow usually follows a coherent pattern:

  1. A caller (EOA or contract) sends a transaction that directly or indirectly calls the LiFiDiamond

  2. The LiFiDiamond will transfer the to-be-bridged/-swapped tokens from the caller (=msg.sender) to itself, making those funds available for any subsequent action. For this it is necessary that an allowance has been set by the caller prior to calling the LiFiDiamond (exception: gasless transactions).

  3. If applicable, the LiFiDiamond will execute any pre-bridging steps such as swapping tokens, wrapping/unwrapping native tokens, collecting fees or sending a small gas amount to the destination chain

  4. Then some parameter validation and protocol-specific logic is executed and, once all this clears, the funds are forwarded to the selected bridge

  5. An is emitted by the LiFiDiamond to conclude the transaction and emit the key parameters of the transfer

Events

For successfully executed destination calls , our protocol-specific receiver contract will emit either of the following two events:

Any successful bridge transaction will emit our event which contains information about what is bridged where by whom.

In case of same-chain swaps, a event is emitted.

(=destination call success)

(=destination call unsuccessful but bridged funds were forwarded to receiver address) event.

EIP-2535 ( Diamonds, Multi-Facet Proxy)
DELEGATECALL
Executor
FeeCollector
ReceiverStargateV2
TokenWrapper
contracts
LiFiDiamond
Facet Contracts
Periphery Contracts
contract-specific docs
event
LiFiTransferStarted
LiFiGenericSwapCompleted
LiFiTransferCompleted
LiFiTransferRecovered