Fail with error 'OneSplit: swap makes no sense'
bryan27118 opened this issue · comments
Transaction keeps reverting with the error "Fail with error 'OneSplit: swap makes no sense'"
https://etherscan.io/tx/0x35c7e07964a90184d8f3571ae4b5d6b976b978b55f306cd21dcfeca39e5eff49
It seems the error is being thrown from OneSplit's swap function
function swap(
IERC20 fromToken,
IERC20 toToken,
uint256 amount,
uint256 minReturn,
uint256[] memory distribution,
uint256 featureFlags // See contants in IOneSplit.sol
) public payable {
require(fromToken != toToken && amount > 0, "OneSplit: swap makes no sense");
require((msg.value != 0) == fromToken.isETH(), "OneSplit: msg.value shoule be used only for ETH swap");
uint256 fromTokenBalanceBefore = fromToken.universalBalanceOf(address(this)).sub(msg.value);
uint256 toTokenBalanceBefore = toToken.universalBalanceOf(address(this));
fromToken.universalTransferFromSenderToThis(amount);
fromToken.universalApprove(address(oneSplitImpl), amount);
oneSplitImpl.swap.value(msg.value)(
fromToken,
toToken,
amount,
minReturn,
distribution,
featureFlags
);
uint256 fromTokenBalanceAfter = fromToken.universalBalanceOf(address(this));
uint256 toTokenBalanceAfter = toToken.universalBalanceOf(address(this));
uint256 returnAmount = toTokenBalanceAfter.sub(toTokenBalanceBefore);
require(returnAmount >= minReturn, "OneSplit: actual return amount is less than minReturn");
toToken.universalTransfer(msg.sender, returnAmount);
if (fromTokenBalanceAfter > fromTokenBalanceBefore) {
fromToken.universalTransfer(msg.sender, fromTokenBalanceAfter.sub(fromTokenBalanceBefore));
}
}
More specifically, this line here
require(fromToken != toToken && amount > 0, "OneSplit: swap makes no sense");
My guess is that the amount being passed is less than zero in the TradingBot contract.
defi-bot/src/contracts/TradingBot.sol
Lines 290 to 293 in f77ea1c
Does anyone have any ideas what might be happening or how to work around this?
I'm getting the same error. It seems that the ZRX trade is always getting 0 tokens back for some reason...
https://extropy-io.medium.com/arbitrage-bot-part-2-97e7b710dcf
The article explains it best. Essentially you are getting front-rjn, or at least that's the common opinion, I havent dug deep enough but it seems like the result from 0x is 0 because somebody front run you and hence 1inch complains that zero amount makes no sense (selling)
Ah ok. That makes sense then. Thanks!
@ezynda3 any updates on that? Have you tried testing with a forked version of Mainnet? That might prove or disprove whether it was front-runners after all.
@codemedici
I'm getting the same error. It seems that the ZRX trade is always getting 0
even with very high gas, did you found any issue on contract?
@Bcantz27 does this bot work?
@nfujimori-godaddy @Welsh-Boogie
Tbh I also go the same error when I was running the bot and it's been a year since, I never figured out the issue, haven't tried figuring it out either. I thought it was front runners that caused you to try and trade a 0 amount with OneInch (see the error message generated by the OneSplit contract ), but I'm not so sure actually...
So the question remains, has anyone been able to successfully run this bot?