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
// and the user has approved the slippage adjusted input amount for the trade
exportfunctionuseSwapCallback(
...
...
@@ -198,28 +218,7 @@ export function useSwapCallback(
})
.catch((callError)=>{
console.debug('Call threw error',call,callError)
leterrorMessage:string
switch(callError.reason){
case'UniswapV2Router: EXPIRED':
errorMessage=
'The transaction could not be sent because the deadline has passed. Please check that your transaction deadline is not too low.'
'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.'