olegmitrakhovich / Defi-Arb-Bot

arbitrage bot, looks for prices differences on uniswap and kyber. Uses flashloan to make a trade between 2 exchanges. #eattheblocks course
295 stars 92 forks source link

ERR_INVALID_URL #5

Closed manseth closed 3 years ago

manseth commented 3 years ago

Hi. I just tried to use your bot but when i run the node run-arbitrage.js i get this error. I assume i need to put my web3 infura URL but i can't find where. Could you please help me ?

`~/Defi-Arb-Bot$ node run-arbitrage.js internal/url.js:257 throw new ERR_INVALID_URL(input); ^

TypeError [ERR_INVALID_URL]: Invalid URL: undefined at onParseError (internal/url.js:257:9) at new URL (internal/url.js:333:5) at Object.helpers [as parseURL] (/home/volrod/Defi-Arb-Bot/node_modules/web3-providers-ws/src/helpers.js:14:20) at new WebsocketProvider (/home/volrod/Defi-Arb-Bot/node_modules/web3-providers-ws/src/index.js:70:29) at Object. (/home/volrod/Defi-Arb-Bot/run-arbitrage.js:9:3) at Module._compile (internal/modules/cjs/loader.js:1015:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10) at Module.load (internal/modules/cjs/loader.js:879:32) at Function.Module._load (internal/modules/cjs/loader.js:724:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) at internal/main/run_main_module.js:17:47 { input: 'undefined', code: 'ERR_INVALID_URL' `

manseth commented 3 years ago

When i run the command "truffle migrate --network mainnet --reset" i get this

`Compiling your contracts...

Everything is up to date, there is nothing to compile.

Migrations dry-run (simulation)

Network name: 'mainnet-fork' Network id: 1 Block gas limit: 12487759 (0xbe8c4f)

1_initial_migration.js

Deploying 'Migrations'

block number: 11157205 block timestamp: 1604047996 account: 0xcE3C76F91Ca359A6D6379E409E490DfB9d83E756 balance: 0.009407028 gas used: 176931 (0x2b323) gas price: 92 gwei value sent: 0 ETH total cost: 0.016277652 ETH


Total cost: 0.016277652 ETH

2_deploy_contracts.js

Replacing 'Flashloan'

Error: Deployment Failed

"Flashloan" could not deploy due to insufficient funds

then i run the "node run-arbitrage.js" and i get the same "ERR_INVALID_URL". I have already create a .env like this in the root folder and still get the same error

INFURA_URL=wss://mainnet.infura.io/ws/***************************** PRIVATE_KEY=ac**********************************************

You can notice i get a ""Flashloan" could not deploy due to insufficient funds" but the total cost is 0.016277652 ETH since i have a lot more than that in my wallet.

olegmitrakhovich commented 3 years ago

hey man, sorry for the late reply. but look at this line here: https://github.com/olegmitrakhovich/Defi-Arb-Bot/blob/master/run-arbitrage.js#L8

you need to make a ".env" file and inside that file just write "INFURA_URL="

olegmitrakhovich commented 3 years ago

as for your gas issue, 0.016277652 ETH is way too cheap.. I had to pay 90$ bucks to deploy this thing, keep playing with the gas fee and make you have atleast 1 ETH in your account.

manseth commented 3 years ago

No worries, okay that's what i have done i have create a .env file and i have put inside my infura url + private key and and i still get the error when i run the node run-arbitrage.js :( but when i run truffle migrate --network mainnet --reset the only error it's for the gas.

How can i change the gas fee ? On the script or on my wallet ?

Sorry if my questions seem dumb but i'm "new" to this.

EDIT: OKAAAY i understand let me explain

The problem of fees is due to the fact that "truffle migrate --network mainnet --reset" could not finish because I do not have enough ETH on my wallet so the 0.016277652 is only a part of the total amount to deploy the contract the total amount being about $ 90 as you said.

olegmitrakhovich commented 3 years ago

lol not a problem, no such thing as a dumb questions. its kinda cool that people are trying to make this code work, so I'm flattered. Also check this line again : https://github.com/olegmitrakhovich/Defi-Arb-Bot/blob/master/run-arbitrage.js#L8

make sure the variable you are using is right, because I switched to QUICK_NODE recently. Make sure you are using the right name for your variable.

manseth commented 3 years ago

Okay i will replace infura by quick node. Thank you for your answer ! And one last question, when the contract is deployed (i assume you done it) did you make any profit from it ? If yes that's very good but if no what should we for make profit from it ?

olegmitrakhovich commented 3 years ago

no I didn't make any money, if anything I lost money lol. That's why I posted the code here to see if someone can tell me what's going on. The prices I am getting are wrong for some reason...wrong or my bot is not fast enough to do the transaction ... take a look at other issues. People forked this code multiple times so I'm hoping to through their stuff soon and see if I find anything.