return'This transaction will not succeed either due to price movement or fee on transfer. Try increasing your slippage tolerance.'
case'UniswapV2: TRANSFER_FAILED':
return'The token could not be transferred. There may be an issue with the token.'
case'UniswapV2: K':
return'The Uniswap invariant x*y=k was not satisfied by the swap. This usually means one of the tokens you are swapping incorporates custom behavior on transfer.'
case'Too little received':
case'Too much requested':
case'STF':
return'This transaction will not succeed due to price movement. Try increasing your slippage tolerance.'
default:
return'Unknown error. Please join the Discord to get help.'
}
}
// returns a function that will execute a swap, if the parameters are all valid
// returns a function that will execute a swap, if the parameters are all valid
// and the user has approved the slippage adjusted input amount for the trade
// and the user has approved the slippage adjusted input amount for the trade
exportfunctionuseSwapCallback(
exportfunctionuseSwapCallback(
...
@@ -198,28 +218,7 @@ export function useSwapCallback(
...
@@ -198,28 +218,7 @@ export function useSwapCallback(
'This transaction will not succeed either due to price movement or fee on transfer. Try increasing your slippage tolerance.'
break
case'UniswapV2: TRANSFER_FAILED':
errorMessage='The token could not be transferred. There may be an issue with the token.'
break
case'UniswapV2: K':
errorMessage=
'The Uniswap invariant x*y=k was not satisfied by the swap. This usually means one of the tokens you are swapping incorporates custom behavior on transfer.'
break
default:
return{call}
}
return{call,error:newError(errorMessage)}
})
})
})
})
})
})
...
@@ -289,7 +288,10 @@ export function useSwapCallback(
...
@@ -289,7 +288,10 @@ export function useSwapCallback(
}else{
}else{
// otherwise, the error was unexpected and we need to convey that
// otherwise, the error was unexpected and we need to convey that