Open huahuayu opened 3 years ago
that's the catch, when calling the uniswap router you have to set the minimum amount <= than the 10% returned, the mev bot wasn't taking that in consideration when doing the transaction. for it to work you have to set slippage at >=90% in the uniswap transaction
hi, very nice trick :)
problem
I have a test on this code but the token I added to uniswap can be swap only once, swap again will get error: UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT.
steps to reproduce
First, if I don't modify the erc20 code, then it works, every kind of swap works fine (of course!).
Second, below is the modified
transfer
method, the whole token code I am using is hereThird, add the modified erc20 to uniswap. But it can be swap only once, after that do
swapExactETHForTokens
will getUniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT
error, meanwhileswapETHForExactTokens
always works.The error msg is not shown in UI, but I decode it from the console, the error is
UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT
the error comes from here
Since I just modified the token's
transfer
function, I can't see there's a reason to get this error, because when the error occurs, it haven't run totransfer
logic.You can swap this token in kovan testnet via uniswap to reproduce.
What's the problem with my code?