Documentation Index
Fetch the complete documentation index at: https://docs.li.fi/llms.txt
Use this file to discover all available pages before exploring further.
Overview
LI.FI SDK v4 introduces a client-based architecture that provides better type safety, improved modularity, and clearer separation of concerns. The SDK now uses a client instance pattern instead of global configuration, making it easier to manage multiple SDK instances and improving testability. To get started, install the latest version of LI.FI SDK.Configuration
The most significant change in v4 is the move from a global configuration pattern to a client-based architecture. Instead of callingcreateConfig() and using global functions, you now create a client instance and pass it to all SDK functions.
Before (v3)
After (v4)
Function Signatures
All SDK action functions now require the client as the first parameter. This includes:getRoutes(client, {...})getQuote(client, {...})getContractCallsQuote(client, {...})getChains(client, {...})getTools(client, {...})getConnections(client, {...})getTokens(client, {...})getToken(client, chain, token)getTokenBalance(client, walletAddress, token)getTokenBalances(client, walletAddress, tokens)getTokenBalancesByChain(client, walletAddress, tokensByChain)getWalletBalances(client, walletAddress)getStatus(client, {...})getStepTransaction(client, step)executeRoute(client, route, options)resumeRoute(client, route, options)getGasRecommendation(client, {...})getTransactionHistory(client, {...})getNameServiceAddress(client, name, chainType?)getRelayerQuote(client, {...})relayTransaction(client, {...})getRelayedTransactionStatus(client, {...})patchContractCalls(client, {...})
Example Migration
Before (v3)
After (v4)
Provider Packages
In v4, ecosystem providers have been moved to separate packages for better modularity and tree-shaking. You need to install the provider packages separately and import providers from their respective packages.Install Provider Packages
Only install the provider packages for the ecosystems you need. For example, if you only support EVM chains, you only need
@lifi/sdk-provider-ethereum.Provider Configuration
Before (v3)
After (v4)
Provider Names
Provider factory names have been updated to be more descriptive:EVM→EthereumProvider(from@lifi/sdk-provider-ethereum)Solana→SolanaProvider(from@lifi/sdk-provider-solana)UTXO→BitcoinProvider(from@lifi/sdk-provider-bitcoin)Sui→SuiProvider(from@lifi/sdk-provider-sui)- New:
TronProvider(from@lifi/sdk-provider-tron) — adds Tron ecosystem support
Solana Provider: getWalletAdapter → getWallet
The Solana provider now uses @solana/kit and the Wallet Standard instead of @solana/web3.js and the legacy wallet adapter.
Before (v3)
After (v4)
Sui Provider: getWallet → getClient + getSigner
The Sui provider now uses @mysten/sui v2 and requires a ClientWithCoreApi and a Signer instead of a wallet object.
Before (v3)
After (v4)
Configuration Management
Before (v3)
After (v4)
Execution Model: Process → Action
The execution tracking model has been renamed for clarity. What was previously called a “process” is now called an “action.”Type and field renames
Execution.process→Execution.actionsProcess→ExecutionActionProcessType→ExecutionActionTypegetProcessMessage()→getActionMessage()+getSubstatusMessage()
New action types
TheTOKEN_ALLOWANCE process type has been split into more granular action types:
CHECK_ALLOWANCE- Checking token allowanceRESET_ALLOWANCE- Resetting token allowanceSET_ALLOWANCE- Setting token allowance
NATIVE_PERMIT action type has been added.
Before (v3)
After (v4)
ExecutionOptions Changes
TheswitchChainHook and disableMessageSigning options have been removed from ExecutionOptions and moved to EthereumProviderOptions, which is configured when setting up the EVM provider. Note that switchChainHook has been renamed to switchChain on the provider (as shown in the example below).
Before (v3)
After (v4)
Token Allowance Functions
Token allowance functions are now exported from the Ethereum provider package instead of the main SDK package.Before (v3)
After (v4)
The actions() Helper
If you prefer calling SDK functions without passing the client as the first parameter each time, you can use the actions() helper. It returns an object with all SDK action functions pre-bound to the client.
New Utilities
v4 exports common utilities from@lifi/sdk so you no longer need viem or other libraries for basic formatting:
Removed Parameters
Some configuration parameters have been removed or changed:chains- No longer passed tocreateClient. Chains are fetched automatically from the API.
Client Instance Pattern
The client instance pattern allows you to:- Create multiple clients with different configurations
- Better testability - easier to mock and test
- Type safety - better TypeScript support
- Explicit dependencies - clear what functions depend on
Example: Multiple Clients
Migration Checklist
- Update package installation to include provider packages
- Replace
createConfig()withcreateClient()and store the client instance - Update all function calls to include
clientas the first parameter (or use theactions()helper) - Update provider imports to use separate provider packages
- Update provider factory names (
EVM→EthereumProvider, etc.) - For Solana: replace
getWalletAdapterwithgetWallet(returns wallet-standardWallet) - For Sui: replace
getWalletwithgetClient+getSigner - Move
switchChainHook(renamed toswitchChain) anddisableMessageSigningfromExecutionOptionstoEthereumProviderOptions - Update execution monitoring code:
execution.process→execution.actions - Replace
getProcessMessage()withgetActionMessage()andgetSubstatusMessage() - Update token allowance function imports to
@lifi/sdk-provider-ethereum - Update token allowance function calls to include
clientparameter - Replace
config.set()andconfig.getChains()with client methods - Remove any references to global
configobject - Replace
viem’sformatUnits/parseUnitswith@lifi/sdkexports if desired

