diff --git a/src/hooks/useUniversalRouter.ts b/src/hooks/useUniversalRouter.ts index b5606cbc39..3d0aa16bb1 100644 --- a/src/hooks/useUniversalRouter.ts +++ b/src/hooks/useUniversalRouter.ts @@ -51,7 +51,8 @@ export function useUniversalRouterSwapCallback( gasEstimate = await provider.estimateGas(tx) } catch (gasError) { await provider.call(tx) // this should throw the actual error - throw new Error('unexpected issue with gas estimation; please try again') + // If the actual error is not thrown, just try again: + gasEstimate = await provider.estimateGas(tx) } const gasLimit = calculateGasMargin(gasEstimate) const response = await provider.getSigner().sendTransaction({ ...tx, gasLimit }) diff --git a/src/utils/swapErrorToUserReadableMessage.tsx b/src/utils/swapErrorToUserReadableMessage.tsx index d2891b4bc9..7385033d93 100644 --- a/src/utils/swapErrorToUserReadableMessage.tsx +++ b/src/utils/swapErrorToUserReadableMessage.tsx @@ -15,6 +15,8 @@ export function swapErrorToUserReadableMessage(error: any): string { } } + console.warn('Swap error:', error) + while (error) { reason = error.reason ?? error.message ?? reason error = error.error ?? error.data?.originalError @@ -44,8 +46,7 @@ export function swapErrorToUserReadableMessage(error: any): string { if (reason?.indexOf('undefined is not an object') !== -1) { return t`An error occurred when trying to execute this swap. You may need to increase your slippage tolerance. If that does not work, there may be an incompatibility with the token you are trading. Note: fee on transfer and rebase tokens are incompatible with Uniswap V3.` } - return t`Unknown error${ - reason ? `: "${reason}"` : '' - }. Try increasing your slippage tolerance. Note: fee on transfer and rebase tokens are incompatible with Uniswap V3.` + return t`Unknown error${reason ? `: "${reason}"` : ''}. Try increasing your slippage tolerance. +Note: fee on transfer and rebase tokens are incompatible with Uniswap V3.` } }