Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@lifi/sdk

lifinance119.4kApache-2.03.7.9TypeScript support: included

LI.FI Any-to-Any Cross-Chain-Swap SDK

bridge, bridge-aggregation, cross-chain, cross-chain-applications, cross-chain-bridge, dapp, defi, ethereum, ethers, lifi, metamask, multi-chain, sdk, swap, viem, wagmi, web3, web3-react

readme

license npm latest package npm downloads Follow on Twitter

LI.FI SDK

LI.FI SDK provides a powerful toolkit for developers to enable seamless cross-chain and on-chain swaps and bridging within their applications. Our JavaScript/TypeScript SDK can be implemented in front-end or back-end environments, allowing you to build robust UX/UI around our advanced bridge and swap functionalities. LI.FI SDK efficiently manages all communications between our smart routing API and smart contracts and ensures optimal performance, security, and scalability for your cross-chain and on-chain needs.

LI.FI SDK features include:

  • All ecosystems, chains, bridges, exchanges, and solvers that LI.FI supports
  • Complete functionality covering full-cycle from obtaining routes/quotes to executing transactions
  • Easy tracking of the route and quote execution through the robust event and hooks handling
  • Highly customizable settings to tailor the SDK to your specific needs including configuration of RPCs and options to allow or deny certain chains, tokens, bridges, exchanges, solvers
  • Supports widely adopted industry standards, including EIP-5792, ERC-2612, EIP-712, and Permit2
  • SDK ecosystem providers are based on industry-standard libraries (Viem, Wallet Standard, Bigmi)
  • Support for arbitrary contract calls on the destination chain
  • Designed for optimal performance with tree-shaking and dead-code elimination, ensuring minimal bundle sizes and faster page load times in front-end environments
  • Compatibility tested with Node.js and popular front-end tools like Vite

Installation

pnpm add @lifi/sdk

or

npm install --save @lifi/sdk

Quick Start

Set up the SDK

Firstly, create SDK config with your integrator string.

import { createConfig } from '@lifi/sdk'

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

Request a Quote

Now you can interact with the SDK and for example request a quote.

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

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

Examples

See examples folder in this repository.

Documentation

Please checkout the SDK documentation and our API reference for further information.

Changelog

The changelog is regularly updated to reflect what's changed in each new release.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

3.7.9 (2025-06-06)

Bug Fixes

  • increase timeout for batch transactions (#266) (5fa974d)

3.7.8 (2025-06-06)

Bug Fixes

3.7.7 (2025-05-30)

3.7.6 (2025-05-30)

Bug Fixes

3.7.5 (2025-05-29)

Bug Fixes

  • error handling should include nested error causes (e54fc73)

3.7.4 (2025-05-29)

Bug Fixes

  • error class names can't be minified correctly (65662d3)

3.7.3 (2025-05-28)

Bug Fixes

  • add public client fallback for wallet client failures on EVM RPC calls (#261) (df917b2)
  • improve 7702 upgrade rejection error handling (#263) (3adf253)

3.7.2 (2025-05-21)

Bug Fixes

  • ensure safe access to error cause when handling wallet upgrade rejections (#260) (426bd15)

3.7.1 (2025-05-20)

Bug Fixes

  • handle wallet 7702 upgrade rejections more gracefully (#259) (f1df53a)

3.7.0 (2025-05-15)

Features

3.6.16 (2025-05-14)

Bug Fixes

  • refine allowance checks for direct transfers (dbcd640)

3.6.15 (2025-05-14)

Bug Fixes

  • skip allowance check for direct transfers (#258) (2ecf469)

3.6.14 (2025-05-12)

Bug Fixes

  • add timeout for getCapabilities call (#256) (ee07c25)

3.6.13 (2025-05-06)

Bug Fixes

3.6.12 (2025-05-05)

Bug Fixes

  • disable message signing for custom steps (#253) (6a90712)

3.6.11 (2025-04-29)

Bug Fixes

  • let the wallet estimate the gas in case of failure (123860e)

3.6.10 (2025-04-29)

Bug Fixes

  • take old gas estimate if we failed to provide a new one (#251) (d4c17c1)

3.6.9 (2025-04-28)

Bug Fixes

  • viem: make EIP-5792 stable (310a4cc)

3.6.8 (2025-04-15)

Bug Fixes

3.6.7 (2025-04-07)

Bug Fixes

  • improve error handling for transaction rejection in Safe (#246) (e22f7ab)
  • sync to latest EIP-5792 spec (#247) (fa5578f)

3.6.6 (2025-04-04)

Bug Fixes

3.6.5 (2025-04-01)

Bug Fixes

  • improve replaced transactions handling (#244) (d5e7829)

3.6.4 (2025-04-01)

Bug Fixes

  • update sendCalls to support EIP-5792 with backward compatibility (#243) (95f6575)

3.6.3 (2025-04-01)

Bug Fixes

  • allow order permit type (6c6efd4)
  • make permit message serializable (23ed44d)

3.6.2 (2025-03-13)

Bug Fixes

  • update permit handling with standardized EIP-712 typed data (#238) (57bbd8e)

3.6.1 (2025-03-11)

Bug Fixes

  • execution: add started and done timestamps (#237) (4b28dc7)

3.6.0 (2025-03-10)

Features

  • add Permit (ERC-2612), Permit2 and Wallet Call API (EIP-5792) support (#224) (3278265)

Bug Fixes

  • improve bitcoin public client handling (#235) (06a2d80)
  • status-manager: set startedAt for started processes (#236) (edac285)

3.5.4 (2025-02-16)

3.5.3 (2025-02-04)

Bug Fixes

3.5.2 (2025-01-14)

Bug Fixes

  • preserve transaction hash when creating new process (#232) (7e8c829)

3.5.1 (2025-01-09)

Bug Fixes

  • add bugs field to published package.json (67c6685)

3.5.0 (2025-01-02)

Features

  • improve transaction execution for smart account clients (#222) (2580dbe)

3.4.4 (2024-12-20)

3.4.3 (2024-12-13)

3.4.2 (2024-12-05)

3.4.1 (2024-10-31)

Bug Fixes

  • export more provider types (24a0e80)

3.4.0 (2024-10-28)

Features

  • add support for multiple Solana RPCs (#220) (08b7faa)

3.3.1 (2024-10-23)

Bug Fixes

3.3.0 (2024-10-18)

Features

3.2.3 (2024-09-17)

Bug Fixes

3.2.2 (2024-09-16)

Bug Fixes

3.2.1 (2024-09-12)

3.2.0 (2024-09-10)

Features

  • replace wallet and public clients with base client (#215) (76122c6)

3.1.5 (2024-08-09)

Bug Fixes

3.2.2 (2024-09-16)

Bug Fixes

3.2.1 (2024-09-12)

3.2.0 (2024-09-10)

Features

  • replace wallet and public clients with base client (#215) (76122c6)

3.1.5 (2024-08-09)

Bug Fixes

  • add fallback for wallet client account address (#213) (a1ea259)

3.1.4 (2024-08-09)

3.1.3 (2024-07-24)

Bug Fixes

  • should not send execution object to the API (714a128)

3.1.2 (2024-07-22)

Bug Fixes

  • remove response message prop name from http error message (#202) (6ddd1ad)

3.1.1 (2024-07-22)

Bug Fixes

  • better handle blockheight exceeded error (2eb6158)
  • reduce http transport batch size (b89343a)

3.1.0 (2024-07-19)

Features

  • deprecate execution options (f4c9fff)

3.0.1 (2024-07-15)

Bug Fixes

3.0.0 (2024-06-26)

2.5.0 (2023-11-01)

Features

Bug Fixes

  • improve error handling during LiFi initialization (#171) (0756631)

2.4.3 (2023-10-03)

Bug Fixes

  • wallet analytics API request changes (#167) (e4a145d)

2.4.2 (2023-10-03)

Bug Fixes

  • wallet analytics API request changes (#167) (e4a145d)

2.4.1 (2023-09-25)

Bug Fixes

2.4.0 (2023-09-20)

Features

  • add multi-contract calls API endpoint (#164) (bb721cb)

2.3.1 (2023-09-04)

Bug Fixes

  • remove updateTransactionRequestHook from allowance read call (#162) (79ea63b)

2.3.0 (2023-08-17)

Features

  • allow to pass api key to all requests (#159) (e9dc0fe)

2.2.3 (2023-08-04)

Bug Fixes

  • getConnections: get connections endpoint error (#160) (53ad776)

2.2.2 (2023-08-01)

Bug Fixes

  • integrator string is not applied in quote requests (f76dbe6)

2.2.1 (2023-07-24)

Bug Fixes

  • fixed types for multisig config (#156) (9a28de6)
  • parsing params in available connections api request (#155) (177723a)

2.2.0 (2023-07-11)

Features

Bug Fixes

  • deprecate possibilities endpoint (80e6e98)

2.1.3-beta.0 (2023-07-04)

2.1.2 (2023-07-04)

2.1.2-beta.1 (2023-07-04)

2.1.2-beta.0 (2023-07-04)

2.1.1 (2023-07-03)

Bug Fixes

2.1.0 (2023-06-27)

Features

Bug Fixes

2.0.1 (2023-06-16)

Bug Fixes

  • prevent division by zero (43340f0)

2.0.0 (2023-06-15)

2.0.0-beta.16 (2023-06-12)

Bug Fixes

  • estimate gas price from signer LF-2417 (#143) (a71152d)

2.0.0-beta.15 (2023-05-25)

Bug Fixes

2.0.0-beta.14 (2023-05-25)

Bug Fixes

  • increment gas on retry if out of gas (#137) (c65fb0d)

2.0.0-beta.13 (2023-05-11)

Bug Fixes

2.0.0-beta.12 (2023-05-11)

⚠ BREAKING CHANGES

  • types and names cleanup (#136)

Features

Bug Fixes

  • add missing config while updating transaction request (#135) (e783d3c)
  • moved getconnections method inside the lifi class (#140) (ce7b6e6)

2.0.0-beta.11 (2023-04-27)

Bug Fixes

  • add tenderly for readable error messages (#134) (0246a2c)
  • remove acceptSlippageUpdateHook (use acceptExchangeRateUpdateHook) (22eabed)
  • unable to configure provider for chain on first load (9c3590e)

2.0.0-beta.10 (2023-04-25)

Bug Fixes

  • don't trigger chain switch if all actions are done from source chain [LF-1131] (#133) (e6d2076)

2.0.0-beta.9 (2023-04-21)

Features

  • add callbacks to support custom transaction config (#128) (122f6b2)

Bug Fixes

  • return contextual transaction error message (#127) (4af19be)
  • update step types (de1434a)

2.0.0-beta.8 (2023-04-11)

Bug Fixes

  • update step types tests (a2a75bd)

2.0.0-beta.7 (2023-04-11)

Features

  • adding getConnections endpoint to SDK (#130) (20f8464)

Bug Fixes

2.0.0-beta.6 (2023-03-21)

2.0.0-beta.5 (2023-03-17)

Features

  • adding widget + sdk version in header (#125) (3516717)
  • allow user tracking by passing userId in header (#123) (d5b2d84)

2.0.0-beta.4 (2023-03-13)

2.0.0-beta.3 (2023-03-09)

Bug Fixes

  • filter undefined config props (326d7bb)

2.0.0-beta.2 (2023-03-08)

Bug Fixes

  • add missing types for gas recommendation (3d2a044)

2.0.0-beta.1 (2023-03-08)

Bug Fixes

  • check package updates URL (7a3db8c)

2.0.0-beta.0 (2023-03-08)

Features

Bug Fixes

1.7.2 (2022-12-13)

1.7.1 (2022-12-12)

Bug Fixes

1.7.0 (2022-11-23)

Features

  • add acceptExchangeRateUpdateHook and return gas info during route execution (#111) (65c4cb1)

1.6.4 (2022-11-16)

1.6.3 (2022-10-26)

Bug Fixes

1.6.2 (2022-10-26)

1.6.1 (2022-10-24)

1.6.0 (2022-09-14)

Features

  • add bridgeExplorerLink to receiving chain process (#110) (b9891a5)

1.5.0 (2022-09-06)

Features

1.4.1 (2022-09-06)

1.4.0 (2022-09-05)

Features

  • skip step tx generation if tx data already provided (#100) (280de4a)

1.3.1 (2022-09-05)

Bug Fixes

  • pass default options right for quote requests (#109) (776c5a3)

1.3.0 (2022-09-05)

Features

Bug Fixes

1.2.2 (2022-08-24)

1.2.1 (2022-08-22)

1.2.0 (2022-08-22)

Features

1.1.6 (2022-08-19)

1.1.5 (2022-08-19)

1.1.4 (2022-08-19)

1.1.3 (2022-08-06)

Bug Fixes

1.1.2 (2022-08-04)

Bug Fixes

1.1.1 (2022-08-03)

Bug Fixes

1.1.0 (2022-08-02)

Features

  • add fee parameter and getContractCallQuote endpoint (#92) (56695d6)
  • add gasinformation to execution object (#91) (f3a13b4)
  • expose get getRpcProvider (#89) (750b675)
  • increase gasLimit or gasPrice on restart if necessary (#90) (6f947d3)

Bug Fixes

1.0.2 (2022-07-15)

1.0.1 (2022-07-14)

Bug Fixes

1.0.0 (2022-07-12)

⚠ BREAKING CHANGES

  • move to a new @lifi scope (#85)

Features

1.0.0-beta.14 (2022-07-06)

Features

1.0.0-beta.13 (2022-07-05)

Bug Fixes

1.0.0-beta.12 (2022-06-29)

Features

1.0.0-beta.11 (2022-06-08)

1.0.0-beta.10 (2022-06-07)

Bug Fixes

1.0.0-beta.9 (2022-06-07)

Bug Fixes

  • updated e2e + added tsc compilation on push (#77) (7d99cd1)

1.0.0-beta.8 (2022-06-02)

Features

  • use tryBlockAndAggregate to fetch balances (#76) (5f01961)

1.0.0-beta.7 (2022-06-01)

Features

Bug Fixes

  • added toolDetails + workaround for non EVM chains testing (#70) (f972477)
  • fix yarn.lock (abdef57)
  • log error if provider can not be configured (#75) (85e22e9)
  • utils: only allow one status poll loop per tx (#69) (0cc7e2b)

1.0.0-beta.6 (2022-05-17)

Features

1.0.0-beta.5 (2022-05-17)

Bug Fixes

1.0.0-beta.4 (2022-05-13)

Bug Fixes

  • fix types for requests cancellation (36d7b55)

1.0.0-beta.3 (2022-05-13)

Features

Bug Fixes

  • remove duplicated getRoutes logic (#66) (52bb994)

1.0.0-beta.2 (2022-05-06)

⚠ BREAKING CHANGES

  • refine error messages and codes (#64)

Features

1.0.0-beta.1 (2022-05-06)

⚠ BREAKING CHANGES

  • deep clone incoming routes to prevent side effects (#62)
  • improve status management (#63)

Features

Bug Fixes

1.0.0-beta.0 (2022-04-13)

⚠ BREAKING CHANGES

  • use object pattern for public methods with many params (#56)
  • load available chains from the backend (#53)

Features

  • load available chains from the backend (#53) (67cff83)
  • use /status for swap execution handling (#55) (0e4821c)
  • use object pattern for public methods with many params (#56) (b167240)

Bug Fixes

0.5.4 (2022-04-04)

0.5.3 (2022-04-04)

0.5.2 (2022-04-04)

Features

  • adjust status handling to new behaviour (#50) (3d3c540)

Bug Fixes

  • continue status calls after failure (#49) (3db0a62)

0.5.1 (2022-03-24)

0.5.0 (2022-03-24)

0.4.11 (2022-03-24)

Features

  • add infinite approval to execution settings (#47) (e2b3995)
  • add token approval methods (#48) (1f3b64d)

0.4.10 (2022-03-20)

Features

0.4.9 (2022-03-15)

Bug Fixes

  • store received token in execution object (#45) (8115ccd)

0.4.8 (2022-03-07)

Features

  • randomly select RPCs to prevent quota issues (#44) (4346282)

0.4.7 (2022-02-24)

Features

  • use common bridge executor for all known BridgeTools (#43) (77626b3)

0.4.6 (2022-02-24)

Bug Fixes

  • handle tokens with 0xeee... zero addresses (#41) (130df5)

Features

  • use common bridge executor for bridge calls (#42) (2c8865)
  • Hop: use common bridge executor for hop transfers (#40) (b65519)

0.4.5 (2022-02-10)

0.4.4 (2022-02-09)

Bug Fixes

  • check chain before sending transactions (#33) (6b92a77)
  • fix type changes (59b9981)
  • nxtp: wait for subgraph setup before calling waitFor (62c7f73)
  • show better connext error message (#32) (e3f9998)

0.4.3 (2022-01-29)

0.4.2 (2022-01-28)

Features

Bug Fixes

  • Hop: check subgraphs for success confirmation instead of using hop sdk (#24) (ce95623)
  • nxtp: improve nxtp timeout handling (#23) (fa12dec)
  • nxtp: use transactionId returned by the backend ( LF-78) (121c103)
  • resolve eslint issues (#27) (5b307ce)
  • type in hook (#28) (9e72a39)

0.4.1 (2022-01-14)

0.4.0 (2022-01-14)

⚠ BREAKING CHANGES

  • interface of external status management methods changed

Bug Fixes

  • nxtp: handle cancelled transfers (#18) (02cd6de)
  • scripts: make install script OS agnostic (6792a8f)

  • refactor status handling (#5) (aa924d8)

0.3.4 (2022-01-12)

Bug Fixes

  • nxtp: handle cancelled transfers (#18) (02cd6de)
  • scripts: make install script OS agnostic (6792a8f)

0.3.3 (2022-01-04)

Bug Fixes

  • nxtp: wait until balance rpc contains block number larger than claim block number (#14) (5146af0)

0.2.3 (2021-12-30)

Features

  • bal: add local balance checks to avoid impossible transactions (2a8e0b2)
  • balance: update multicall contract usage in balance util (#9) (74b1d8f)
  • dex: parse exchange transactions (97cba56)

0.2.2 (2021-12-28)

Bug Fixes

  • paraswap: improve receipt parsing (ee604a5)

0.2.1 (2021-12-16)

0.2.0 (2021-12-16)

Features

  • config: allow to edit the underlying config (#2) (3c04ead)

Bug Fixes

  • balance: split large token lists into chunks (#7) (d19f837)

0.1.1 (2021-12-13)

Features

  • balances: handle empty token lists (b0a4837)
  • nxtp: handle encryption/decryption via hooks (#4) (4e4f27d)

0.1.0 (2021-12-10)

  • Token: refactor token and coin usage (#1) (5ee4d86)