You need to provide acceptExchangeRateUpdateHook https://docs.li.fi/integrate-li.fi-js-sdk/execute-a-route-transfer#acceptexchangerateupdatehook and ask users if they want to accept a new exchange rate or decide for them. During days when the market fluctuates a lot, this may happen sometimes.
Please check our docs on https://docs.li.fi/integrate-li.fi-js-sdk/migrating-to-li.fi-sdk-v2#rename-acceptslippageupdatehook-callback-method-in-settings
You need to define a callback function that handles the exchange rate update.
Here's an example:
const exchangeRateUpdateCallback = () => {
// Handle the exchange rate update logic here
// This function will be called when the exchange rate is updated
}
const executionSettings: InternalExecutionSettings = {
acceptExchangeRateUpdateHook: exchangeRateUpdateCallback,
}
In the executionSettings object, set the acceptExchangeRateUpdateHook property to your callback function exchangeRateUpdateCallback. This callback function will be invoked when the exchange rate is updated.
acceptExchangeRateUpdateHook(params: ExchangeRateUpdateParams): boolean
interface ExchangeRateUpdateParams {
toToken: Token;
oldToAmount: string;
newToAmount: string;
}
So basically you need to return true or false from that hook to accept or deny the rate change accordingly