Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail with error 'OneSplit: swap makes no sense' #4

Open
bryan27118 opened this issue Dec 22, 2020 · 7 comments
Open

Fail with error 'OneSplit: swap makes no sense' #4

bryan27118 opened this issue Dec 22, 2020 · 7 comments

Comments

@bryan27118
Copy link

bryan27118 commented Dec 22, 2020

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.

uint256 _toAmount = _afterBalance - _beforeBalance;
// Swap on 1Split: give _toToken, receive _fromToken
_oneSplitSwap(_toToken, _fromToken, _toAmount, _1SplitMinReturn, _1SplitDistribution);

Does anyone have any ideas what might be happening or how to work around this?

@ezynda3
Copy link

ezynda3 commented Dec 23, 2020

I'm getting the same error. It seems that the ZRX trade is always getting 0 tokens back for some reason...

@codemedici
Copy link
Contributor

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)

@ezynda3
Copy link

ezynda3 commented Dec 23, 2020

Ah ok. That makes sense then. Thanks!

@codemedici
Copy link
Contributor

@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.

@nfujimori-godaddy
Copy link

@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?

@Welsh-Boogie
Copy link

@Bcantz27 does this bot work?

@codemedici
Copy link
Contributor

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants