🪄Migrating to LI.FI SDK v2
Migration guide of upgrading LI.FI's SDK v1 to v2
This migration guide is a quick reference to the upgrades/fixes in LI.FI's SDK v2. All the breaking changes, deprecations, improvements, etc, are listed below. We advise going through all the changes and updating the SDK implementation in your project accordingly.
🚨 Breaking Changes
Deprecation of getByChainID
method
getByChainID
methodThe method getByChainID
is no longer available in the SDK, use ChainsService
instead.
Rename updateCallback
method in settings
updateCallback
method in settingsThe method updateCallback
is renamed to updateRouteHook
Rename acceptSlippageUpdateHook
callback method in settings
acceptSlippageUpdateHook
callback method in settingsThe method acceptSlippageUpdatehook
is renamed to acceptExchangeRateUpdateHook
.
Add integrator during SDK initialisation
During the initialisation of the SDK, you should pass the integrator
as part of the configuration object.
The configuration to instantiate LiFi is now mandatory.
By providing the integrator
during the initialisation of the SDK, it'll be included as request headers for all requests made by the SDK which would later be used for tracking and identification purposes on the server side.
Returning Promise instance of Route
Any route interaction to SDK would now return the initial Promise instance of Route created during the first execution of Route. In order to get more details about the Route, developer would need to resolve the Promise to access the information.
⚒️ Improvements
Add convertQuoteToRoute
helper function to execute single-step quotes
convertQuoteToRoute
helper function to execute single-step quotesFor single-step executions a new helper function, convertQuoteToRoute
is added to the SDK. This function takes a Step
object as input and returns a Route
object. It is useful for converting quotes to routes, which is necessary for executing transactions.
Add getConnections
method to LI.FI SDK
getConnections
method to LI.FI SDKA new method getConnections
is added to the SDK, which retrieves available connections for swapping or bridging tokens. This function takes a ConnectionsRequest
object as a parameter and returns a ConnectionsResponse
object.
Add support to modify Transaction Request
A new callback is added that allows developers to customise the gas configuration for the transaction request before sending the transaction to the blockchain.
The callback can be set in ExecutionSettings
while interacting with the SDK.
Only the modified gas config variable such as gasLimit
, gasPrice
, maxPriorityFeePerGas
and maxFeePerGas
are picked up from it.
Optimise Chain Switching in Bridging Steps
The update refines the executeStep
function's chain-switching logic, allowing users to leave the source chain once the transaction is signed. Users now only need to switch to the destination chain if a swap is required, streamlining the bridging process and improving the user experience.
CHANGELOG
For a detailed view of all the changes please see the CHANGELOG
Last updated