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
  • Overview
  • Configuration
  • Renamed methods
  • Moving from Ethers.js to Viem
  • Multiple ecosystem support
  • Examples
  • Changelog

Was this helpful?

Export as PDF
  1. Integrate LI.FI SDK

Migrate from v2 to v3

Migration guide for upgrading LI.FI SDK v2 to v3

Last updated 11 months ago

Was this helpful?

Overview

LI.FI SDK v3 has undergone a major update, improving compatibility with popular libraries like and adding new features, including support for multiple ecosystems, starting with . Consequently, as detailed in this guide, you need to be aware of some breaking changes and deprecations. We also recommend reviewing the updated documentation for additional new features not covered here.

To get started, install the latest version of LI.FI SDK.

yarn add @lifi/sdk
pnpm add @lifi/sdk
bun add @lifi/sdk
npm install @lifi/sdk

Configuration

We have made significant changes to how the LI.FI SDK is configured. It is no longer class-based, so you don't need to create, maintain, and share a LiFi class instance to use SDK functionality. Instead, it is now function-based, allowing you to configure it once and update the configuration from any place without needing to maintain or share the configuration object's reference. You can simply import the necessary functions from the package wherever needed. Read more Configure SDK

In this example, you can call the getQuote function from anywhere using SDK v3, whereas with SDK v2, you had to share a created LiFi class instance and call getQuote as a method of that class.

// SDK v2
import { ChainId, LiFi } from '@lifi/sdk'

const lifi = new LiFi({
  integrator: 'Your dApp/company name'
})

const quote = await lifi.getQuote({
  fromAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
  fromChain: ChainId.ARB,
  toChain: ChainId.OPT,
  fromToken: '0x0000000000000000000000000000000000000000',
  toToken: '0x0000000000000000000000000000000000000000',
  fromAmount: '1000000000000000000',
})

// SDK v3
import { ChainId, createConfig, getQuote } from '@lifi/sdk'

createConfig({
  integrator: 'Your dApp/company name',
})

const quote = await getQuote({
  fromAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
  fromChain: ChainId.ARB,
  toChain: ChainId.OPT,
  fromToken: '0x0000000000000000000000000000000000000000',
  toToken: '0x0000000000000000000000000000000000000000',
  fromAmount: '1000000000000000000',
})

Due to these changes, the configuration-related functions from the LiFi interface are no longer needed. The previous interface included:

interface LiFi {
  getConfig(): Config
  getConfigAsync(): Promise<Config>
  getRpcProvider(chainId: number, archive: boolean): Promise<FallbackProvider>
  setConfig(configUpdate: ConfigUpdate): Config
  // ...
}
// SDK v2
import { ChainId, LiFi } from '@lifi/sdk'

const lifi = new LiFi({
  integrator: 'Your dApp/company name'
})

lifi.setConfig({
  integrator: 'Your dApp/company name'
})

// SDK v3
import { config } from '@lifi/sdk';

config.set({
  integrator: 'Your dApp/company name',
});

Renamed methods

All methods previously supported by the class-based approach are now individual functions that you can import directly from the @lifi/sdk package. Some of these methods have been renamed to better reflect their functionality or to have a more concise name.

  • getContractCallQuote -> getContractCallsQuote

  • getTokenApproval -> getTokenAllowance

  • bulkGetTokenApproval -> getTokenAllowanceMulticall

  • approveToken -> setTokenAllowance

  • moveExecutionToBackground -> updateRouteExecution

Moving from Ethers.js to Viem

Since the first version of the LI.FI SDK, we have relied on the Ethers.js library for all EVM-related interactions. However, as the industry evolves, Viem is gaining wide adoption and starting to replace Ethers.js.

Multiple ecosystem support

LI.FI SDK v3 now supports two ecosystems — EVM and Solana — with more on the way. To accommodate these new ecosystems, we have introduced the concept of ecosystem providers in SDK v3. We extracted all EVM-related functionality from SDK v2 and integrated it into an EVM provider. Additionally, a Solana provider has been added to enable Solana-related functionality across all SDK functions.

These ecosystem providers are designed with modularity in mind and are fully tree-shakable, ensuring that they do not add unnecessary weight to your bundle if not used.

Previously, it was necessary to pass an Ethers.js Signer object to executeRoute and other functions for EVM interactions. With the introduction of ecosystem providers, you only need to configure them once when setting up the SDK. After that, you can use executeRoute and other functions without passing any additional options. The SDK will automatically determine the appropriate ecosystem provider and notify you if no suitable provider is configured.

Examples

Changelog

Now, you can import the configuration object directly and make any necessary changes to it. This simplifies the process and improves code maintainability. Read more .

See , and Token Management for more details.

To ensure our product remains robust and future-proof, we have decided to transition our entire stack to a more reliable solution - ( for the Widget).

Please see the for more details. Among other notable changes, this transition also replaces all BigNumber utilities we previously used in v2 with the native bigint primitive.

Read more .

Check out our complete examples in the , and feel free to if you encounter any problems.

For a detailed view of all the changes, please see the .

🚗
Viem
Solana
Viem
Wagmi
Ethers v5 → viem Migration Guide
SDK repository
file an issue
CHANGELOG
📦Install LI.FI SDK
Update SDK configuration
Introduction to SDK Ecosystem Providers
Request contract call Quote
Manage route execution