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

Running NormalSwap and FlashSwap error #2

Closed
The-WiZaX opened this issue May 16, 2021 · 6 comments
Closed

Running NormalSwap and FlashSwap error #2

The-WiZaX opened this issue May 16, 2021 · 6 comments

Comments

@The-WiZaX
Copy link

The-WiZaX commented May 16, 2021

I tried to redo the whole process which is nicely detailed but i'm fucking up somehow

I'm getting the following error, I noticed the arbitrager contract and utils contracts weren't the same as what we have to put on .env, but even then there is no difference, I tried with both the ones in the guide and ones listed when we deploy them

Also, i'm not sure if it could be related, but I noticed when going through files that in few contracts (Such as Arbitrager.json under ./build/contracts) have sourcepath that leads somewhere else ?

Ex : "sourcePath": "/home/sammy/ropsten/contracts/Arbitrager.sol",
"absolutePath": "/home/sammy/ropsten/contracts/Arbitrager.sol"

"Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
at ABICoder.decodeParametersWith (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-abi/lib/index.js:298:15)
at ABICoder.decodeParameters (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-abi/lib/index.js:285:17)
at Contract._decodeMethodReturn (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-contract/lib/index.js:470:22)
at Method.outputFormatter (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-contract/lib/index.js:760:42)
at Method.formatOutput (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-method/lib/index.js:147:54)
at sendTxCallback (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-method/lib/index.js:523:33)
at Object.callback (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-requestmanager/lib/index.js:308:9)
at /home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:114:45
at Array.forEach ()
at WebsocketProvider._onMessage (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:102:69)
at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/yaeti/lib/EventTarget.js:115:12)
at W3CWebSocket.onMessage (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:234:14)
at WebSocketConnection. (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:205:19)
at WebSocketConnection.emit (events.js:314:20)
at WebSocketConnection.processFrame (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:554:26)
at /home/js/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:323:40
(node:3946) UnhandledPromiseRejectionWarning: Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
at ABICoder.decodeParametersWith (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-abi/lib/index.js:298:15)
at ABICoder.decodeParameters (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-abi/lib/index.js:285:17)
at Contract._decodeMethodReturn (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-contract/lib/index.js:470:22)
at Method.outputFormatter (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-contract/lib/index.js:760:42)
at Method.formatOutput (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-method/lib/index.js:147:54)
at sendTxCallback (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-method/lib/index.js:523:33)
at Object.callback (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-requestmanager/lib/index.js:308:9)
at /home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:114:45
at Array.forEach ()
at WebsocketProvider._onMessage (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:102:69)
at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/yaeti/lib/EventTarget.js:115:12)
at W3CWebSocket.onMessage (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:234:14)
at WebSocketConnection. (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:205:19)
at WebSocketConnection.emit (events.js:314:20)
at WebSocketConnection.processFrame (/home/js/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:554:26)
at /home/js/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:323:40
(node:3946) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3946) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code."

@6eer
Copy link
Owner

6eer commented May 16, 2021

Hey!

For flashswap_bot, check this lines. Here I set up gasNedeed, the amount of gas that, u are willing to spend in the swap() call below (this method modify the state of the chain, so, it cost gas). This is kind an arbitrary value, I previously measured the amount of gas required and then fixed it, for the reasons that I quote there. Maybe for some cause, that I don't really understand, it not enough gas to you (i hade some gas issues too). Try doing your own measures, and replace the gasNedeed value or simply uncomment line 144 and with this you'll be estimating the gas at runtime. Be aware that gasNeeded its calculated before call any method that involves change the blockchains state, so inspect the code looking for the gasNeeded occurrences and change them properly. This gasNeeded variable its also used in normalswap_bot.

I'm getting the following error, I noticed the arbitrager contract and utils contracts weren't the same as what we have to put on .env

Here you are saying that the addresses I provide in the .env dont mach the addresses at what your contracts where deployed?

Let me know if you could fix it!

@markvelous
Copy link

@6eer Nice tutorial. A newbie developer here who has learnt a lot from your work.

In running the bots, I faced the same bugbear as highlighted by The-WiZaX. Don't think it's a gas issue as I've tried different gas fees but the both bots could not be deployed. Have you managed to resolve the issue?

@ericscottmarquez
Copy link

bump

@ericscottmarquez
Copy link

ericscottmarquez commented Dec 6, 2021

@6eer
(this is in trying to run the demo)
Similar error here:

$ node ./src/bot_normalswap.js

Bot listening!

(node:61485) UnhandledPromiseRejectionWarning: Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
    at ABICoder.decodeParametersWith (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-abi/lib/index.js:298:15)
    at ABICoder.decodeParameters (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-abi/lib/index.js:285:17)
    at Contract._decodeMethodReturn (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-contract/lib/index.js:470:22)
    at Method.outputFormatter (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-contract/lib/index.js:760:42)
    at Method.formatOutput (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-method/lib/index.js:147:54)
    at sendTxCallback (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-method/lib/index.js:523:33)
    at Object.callback (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-requestmanager/lib/index.js:308:9)
    at /home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:114:45
    at Array.forEach (<anonymous>)
    at WebsocketProvider._onMessage (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:102:69)
    at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/yaeti/lib/EventTarget.js:115:12)
    at W3CWebSocket.onMessage (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:234:14)
    at WebSocketConnection.<anonymous> (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:205:19)
    at WebSocketConnection.emit (events.js:314:20)
    at WebSocketConnection.processFrame (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:554:26)
    at /home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:323:40
(node:61485) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:61485) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
    at ABICoder.decodeParametersWith (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-abi/lib/index.js:298:15)
    at ABICoder.decodeParameters (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-abi/lib/index.js:285:17)
    at Contract._decodeMethodReturn (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-contract/lib/index.js:470:22)
    at Method.outputFormatter (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-contract/lib/index.js:760:42)
    at Method.formatOutput (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-method/lib/index.js:147:54)
    at sendTxCallback (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-method/lib/index.js:523:33)
    at Object.callback (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-requestmanager/lib/index.js:308:9)
    at /home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:114:45
    at Array.forEach (<anonymous>)
    at WebsocketProvider._onMessage (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:102:69)
    at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/yaeti/lib/EventTarget.js:115:12)
    at W3CWebSocket.onMessage (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:234:14)
    at WebSocketConnection.<anonymous> (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:205:19)
    at WebSocketConnection.emit (events.js:314:20)
    at WebSocketConnection.processFrame (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:554:26)
    at /home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:323:40
Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
    at ABICoder.decodeParametersWith (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-abi/lib/index.js:298:15)
    at ABICoder.decodeParameters (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-abi/lib/index.js:285:17)
    at Contract._decodeMethodReturn (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-contract/lib/index.js:470:22)
    at Method.outputFormatter (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-eth-contract/lib/index.js:760:42)
    at Method.formatOutput (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-method/lib/index.js:147:54)
    at sendTxCallback (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-method/lib/index.js:523:33)
    at Object.callback (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-requestmanager/lib/index.js:308:9)
    at /home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:114:45
    at Array.forEach (<anonymous>)
    at WebsocketProvider._onMessage (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:102:69)
    at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/yaeti/lib/EventTarget.js:115:12)
    at W3CWebSocket.onMessage (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:234:14)
    at WebSocketConnection.<anonymous> (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:205:19)
    at WebSocketConnection.emit (events.js:314:20)
    at WebSocketConnection.processFrame (/home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:554:26)
    at /home/eric/Desktop/projects/crypto_shit/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:323:40

Tried doing this in bot_flashswap.js (didn't work, error output is above) :

          //gas
          // const gasNeeded = (0.3*10**6)*2 //previosly measured (line below), take to much time, overestimate 2x
          const gasNeeded = await sPair.methods
            .swap(amountIn, 0, addrArbitrager, abi)
            .estimateGas();

I made sure to modify the .env with:

  • my Alchemy account
  • my project ID for infura
  • generated arbitrage contract address
  • generated utils contract address

@kiidfreak
Copy link

Any update on this @ericscottmarquez and @6eer

@tur461
Copy link

tur461 commented Jul 5, 2022

I found the bug. its actually inside asyncsVar() function, it tries to get pair address from remote chain where it doesn't exist because demo_environment.js script doesn't deploy on remote blockchain but local one!. so it wont find anything related to router or factory which we have provided!!!.
I have modified the code which I have forked onto my github repo:
https://github.com/tur461/arbitrage-bot_sma
please have a check!
just mention inside .env file these things:
MNEMONIC of the hd wallet --- like metamask
MORALIS_TOKEN ------ you will get from creating a free account in moralis

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

6 participants