1inchProtocol icon indicating copy to clipboard operation
1inchProtocol copied to clipboard

OneSplit: msg.value shoule be used only for ETH swap

Open M3sca opened this issue 5 years ago • 4 comments

I have this error when I try to swap ETH (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) to CHAI (0x06AF07097C9Eeb7fD685c692751D5C66dB49c215)

M3sca avatar Oct 12 '20 09:10 M3sca

@M3sca apparently, you also need to attach the ethereum amount in the contract call e.g. if using ethers.js

await oneSplitContract.swap(
  '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
  '0x06AF07097C9Eeb7fD685c692751D5C66dB49c215',
  wei,
  quote.returnAmount,
  quote.distribution,
  0x04,
  { value: wei }
);

kelonye avatar Dec 08 '20 05:12 kelonye

I think this is the problem. I will close the issue!

M3sca avatar Jan 04 '21 22:01 M3sca

Hello I am having this issue with my swapping function as well converting Eth to Dai. However when I add the extra "value" parameter of my wei amount it brings back this error: UnhandledPromiseRejectionWarning: Error: Invalid number of parameters for "swap". Got 7 expected 6!

Please let me know if you find anything.

RaphaelChevallier avatar Jan 17 '21 23:01 RaphaelChevallier

Hello I am having this issue with my swapping function as well converting Eth to Dai. However when I add the extra "value" parameter of my wei amount it brings back this error: UnhandledPromiseRejectionWarning: Error: Invalid number of parameters for "swap". Got 7 expected 6!

Please let me know if you find anything.

Yes, I did the same trial, then same error displayed. Then I found that you can add the value param into the send payload, just like:

await oneSplitContract.swap(
  '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
  '0x06AF07097C9Eeb7fD685c692751D5C66dB49c215',
  wei,
  quote.returnAmount,
  quote.distribution,
  0x04
).send({ from, gas,   { value: wei } });

But it still returns a error:

Error: Returned error: VM Exception while processing transaction: revert
    at Object.ErrorResponse (/Users/ran/workspace/dapp/1inch-dapp/node_modules/web3-core-helpers/lib/errors.js:28:19)
    at /Users/ran/workspace/dapp/1inch-dapp/node_modules/web3-core-requestmanager/lib/index.js:303:36
    at XMLHttpRequest.request.onreadystatechange (/Users/ran/workspace/dapp/1inch-dapp/node_modules/web3-providers-http/lib/index.js:98:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/Users/ran/workspace/dapp/1inch-dapp/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/Users/ran/workspace/dapp/1inch-dapp/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/Users/ran/workspace/dapp/1inch-dapp/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/Users/ran/workspace/dapp/1inch-dapp/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  data: {
    '0x3dbde1ef526e1c251830a99d19f03c94eef938694be28f5929a6ef1a0860942a': { error: 'revert', program_counter: 3255, return: '0x' },
    stack: 'c: VM Exception while processing transaction: revert\n' +
      '    at Function.c.fromResults (/Users/ran/.nvm/versions/node/v12.22.1/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:192416)\n' +
      '    at A.w.processBlock (/Users/ran/.nvm/versions/node/v12.22.1/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:42:50915)\n' +
      '    at runMicrotasks (<anonymous>)\n' +
      '    at processTicksAndRejections (internal/process/task_queues.js:97:5)',
    name: 'c'
  }
}

ranlix avatar Jun 09 '21 09:06 ranlix