diff --git a/src/swap/components/SwapProvider.tsx b/src/swap/components/SwapProvider.tsx index f844abcdb3..0bf54b62ea 100644 --- a/src/swap/components/SwapProvider.tsx +++ b/src/swap/components/SwapProvider.tsx @@ -280,7 +280,7 @@ export function SwapProvider({ } await processSwapTransaction({ config, - maxSlippage, + lifeCycleStatus, sendTransactionAsync, setLifeCycleStatus, swapTransaction: response, diff --git a/src/swap/types.ts b/src/swap/types.ts index 4145cd2ffa..4b023844c0 100644 --- a/src/swap/types.ts +++ b/src/swap/types.ts @@ -117,11 +117,11 @@ export type LifeCycleStatus = export type ProcessSwapTransactionParams = { config: Config; + lifeCycleStatus: LifeCycleStatus; setLifeCycleStatus: (state: LifeCycleStatus) => void; sendTransactionAsync: SendTransactionMutateAsync; swapTransaction: BuildSwapTransaction; useAggregator: boolean; - maxSlippage: number; }; /** diff --git a/src/swap/utils/processSwapTransaction.ts b/src/swap/utils/processSwapTransaction.ts index 87d8513758..2722ba9f41 100644 --- a/src/swap/utils/processSwapTransaction.ts +++ b/src/swap/utils/processSwapTransaction.ts @@ -9,7 +9,7 @@ import type { ProcessSwapTransactionParams } from '../types'; export async function processSwapTransaction({ config, - maxSlippage, + lifeCycleStatus, sendTransactionAsync, setLifeCycleStatus, swapTransaction, @@ -17,6 +17,11 @@ export async function processSwapTransaction({ }: ProcessSwapTransactionParams) { const { transaction, approveTransaction, quote } = swapTransaction; + const maxSlippage = + lifeCycleStatus.statusName !== 'error' + ? lifeCycleStatus.statusData.maxSlippage + : 3; + // for swaps from ERC-20 tokens, // if there is an approveTransaction present, // request approval for the amount