dappuniversity / price-bot

397 stars 392 forks source link

First price shows then I get this error #29

Open sabatage opened 3 years ago

sabatage commented 3 years ago

Listening on 5000 Checking prices... ┌─────────┬─────────────┬──────────────┬──────────────┬────────────────────────┬────────────────────────┬────────────────────────┬─────────────────────────────┐ │ (index) │ Input Token │ Output Token │ Input Amount │ Uniswap Return │ Kyber Expected Rate │ Kyber Min Return │ Timestamp │ ├─────────┼─────────────┼──────────────┼──────────────┼────────────────────────┼────────────────────────┼────────────────────────┼─────────────────────────────┤ │ 0 │ 'ETH' │ 'MKR' │ '1' │ '0.788379287855327053' │ '0.788300854732243338' │ '0.764651829090276037' │ '2021-06-14T07:28:00-05:00' │ └─────────┴─────────────┴──────────────┴──────────────┴────────────────────────┴────────────────────────┴────────────────────────┴─────────────────────────────┘

Error: Returned error: execution reverted at Object.ErrorResponse (C:\Users\user\price-bot\node_modules\web3-core-helpers\src\errors.js:29:16) at C:\Users\user\price-bot\node_modules\web3-core-requestmanager\src\index.js:140:36 at XMLHttpRequest.request.onreadystatechange (C:\Users\user\price-bot\node_modules\web3-providers-http\src\index.js:96:13) at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\user\price-bot\node_modules\xhr2-cookies\xml-http-request-event-target.ts:44:13) at XMLHttpRequest._setReadyState (C:\Users\user\price-bot\node_modules\xhr2-cookies\xml-http-request.ts:219:8) at XMLHttpRequest._onHttpResponseEnd (C:\Users\user\price-bot\node_modules\xhr2-cookies\xml-http-request.ts:345:8) at IncomingMessage. (C:\Users\user\price-bot\node_modules\xhr2-cookies\xml-http-request.ts:311:39) at IncomingMessage.emit (events.js:388:22) at endReadableNT (internal/streams/readable.js:1336:12) at processTicksAndRejections (internal/process/task_queues.js:82:21)

every time I run it. I get the same issue. can someone please assist

UsernameGitiHub commented 3 years ago

I have the same error, after installing it i run the inex.js and i get the same shit :)

ajithak9945 commented 3 years ago

Facing the same issue. Can't find a way to fix it.

jakehova commented 3 years ago

There is a pull request that addresses this issue. The issue itself is because the kyber proxy in the code is invalid. You can update your code with the code in the pull request, and it should work properly.

UsernameGitiHub commented 3 years ago

its true if you change the kyber smart contract id you can slove the problem, but overall this script stops to work after some time with error info like "json incorrect" or simular.

i also dont like the way how this script does read the price, is it not possible just to write a smart contract id from a token and a smart contract id from a dex and then get the price for that token without all this calculation which this script does?

i just want to get the clean price for a token from a dex then ic an build my own scanner much better then this. problem is just i dont have experience with web3.js or which libary is doing the read work, so i dont know at moment how to change the script to just give me the clear token price from a dex, let me know if somebody can do that or if that is not possible?

coolgas commented 2 years ago

This code is using abis of contracts from Uniswap V1, which is probably deprecated. If blindly copying this template, errors will be inevitable. So my advice is not wasting time on this code instead heading to the docs of Uniswap V2. By simply copying the codes in docs, you can already go pretty far.

UsernameGitiHub commented 2 years ago

This code is using abis of contracts from Uniswap V1, which is probably deprecated. If blindly copying this template, errors will be inevitable. So my advice is not wasting time on this code instead heading to the docs of Uniswap V2. By simply copying the codes in docs, you can already go pretty far.

i overall dont understand why to use Uniswap, is it not so that Uniswap is just a product of Ethereum Blockchain? What i want to find out is just a simple way how i can get the current price for a token from Ethereum Blockchain and in optimal situation from any other Blokchain.

At the end i want to be able to write the name froma token and then my script will tell me this token cost at the moment so much at this dex and so much at that dex and so on. So at the end i will have something like a arbitrage scanner which can see the current price for a token on all different dex exchanges.

i just dont know currently if technicaly that is possible or not possible, becaue i am just beginner in crypto currency codeing.

coolgas commented 2 years ago

This code is using abis of contracts from Uniswap V1, which is probably deprecated. If blindly copying this template, errors will be inevitable. So my advice is not wasting time on this code instead heading to the docs of Uniswap V2. By simply copying the codes in docs, you can already go pretty far.

i overall dont understand why to use Uniswap, is it not so that Uniswap is just a product of Ethereum Blockchain? What i want to find out is just a simple way how i can get the current price for a token from Ethereum Blockchain and in optimal situation from any other Blokchain.

At the end i want to be able to write the name froma token and then my script will tell me this token cost at the moment so much at this dex and so much at that dex and so on. So at the end i will have something like a arbitrage scanner which can see the current price for a token on all different dex exchanges.

i just dont know currently if technicaly that is possible or not possible, becaue i am just beginner in crypto currency codeing.

It is technically possible and depends on your need it may be very easy. When you say "current price of a token" which basically just means the ratio between token0 and token1 or vice versa. But this is just what people call mid-price, which will change when you add or extract certain tokens to/from the pool, so you will definitely end up trading with a price higher than the mid-price (this is so-called slippage), which will cause the discrepancy between two dexes according to mid-prices will be diminished. So Arbitrage is actually very difficult (not like promoted in many tutorials).

Uniswap is on Ethereum blockchain, and so is Sushiswap, we should probably trade on the same blockchain to diminish transections fee and unnecessary delay. When you mean "from any other blockchain", make sure you understand it. You are meaning that to talk between blockchains, say talking between Ethereum blockchain and Binance smart chain, the latter is a hard fork of the former, which means that there is probably more delays or fees in the transections. So we should better stay on the same chain to do the transections.

At last, as I mentioned, you should go for Uniswap V2 docs, they already make things clear enough. You can achieve your goals: reading prices, simply following the docs they provided.

UsernameGitiHub commented 2 years ago

This code is using abis of contracts from Uniswap V1, which is probably deprecated. If blindly copying this template, errors will be inevitable. So my advice is not wasting time on this code instead heading to the docs of Uniswap V2. By simply copying the codes in docs, you can already go pretty far.

i overall dont understand why to use Uniswap, is it not so that Uniswap is just a product of Ethereum Blockchain? What i want to find out is just a simple way how i can get the current price for a token from Ethereum Blockchain and in optimal situation from any other Blokchain. At the end i want to be able to write the name froma token and then my script will tell me this token cost at the moment so much at this dex and so much at that dex and so on. So at the end i will have something like a arbitrage scanner which can see the current price for a token on all different dex exchanges. i just dont know currently if technicaly that is possible or not possible, becaue i am just beginner in crypto currency codeing.

It is technically possible and depends on your need it may be very easy. When you say "current price of a token" which basically just means the ratio between token0 and token1 or vice versa. But this is just what people call mid-price, which will change when you add or extract certain tokens to/from the pool, so you will definitely end up trading with a price higher than the mid-price (this is so-called slippage), which will cause the discrepancy between two dexes according to mid-prices will be diminished. So Arbitrage is actually very difficult (not like promoted in many tutorials).

Uniswap is on Ethereum blockchain, and so is Sushiswap, we should probably trade on the same blockchain to diminish transections fee and unnecessary delay. When you mean "from any other blockchain", make sure you understand it. You are meaning that to talk between blockchains, say talking between Ethereum blockchain and Binance smart chain, the latter is a hard fork of the former, which means that there is probably more delays or fees in the transections. So we should better stay on the same chain to do the transections.

At last, as I mentioned, you should go for Uniswap V2 docs, they already make things clear enough. You can achieve your goals: reading prices, simply following the docs they provided.

you have a good overview about the blockchains. i am as newbie dont know how to sort all this things currently.

overall i think you also dont belivie so much in arbitrage? maybe its just a promotion trick which youtubers use when they talk about flash loan and dex arbitrage in there videos, maybe just clickbate and they try to sell tutorials to become blockchain experts.

coolgas commented 2 years ago

This code is using abis of contracts from Uniswap V1, which is probably deprecated. If blindly copying this template, errors will be inevitable. So my advice is not wasting time on this code instead heading to the docs of Uniswap V2. By simply copying the codes in docs, you can already go pretty far.

i overall dont understand why to use Uniswap, is it not so that Uniswap is just a product of Ethereum Blockchain? What i want to find out is just a simple way how i can get the current price for a token from Ethereum Blockchain and in optimal situation from any other Blokchain. At the end i want to be able to write the name froma token and then my script will tell me this token cost at the moment so much at this dex and so much at that dex and so on. So at the end i will have something like a arbitrage scanner which can see the current price for a token on all different dex exchanges. i just dont know currently if technicaly that is possible or not possible, becaue i am just beginner in crypto currency codeing.

It is technically possible and depends on your need it may be very easy. When you say "current price of a token" which basically just means the ratio between token0 and token1 or vice versa. But this is just what people call mid-price, which will change when you add or extract certain tokens to/from the pool, so you will definitely end up trading with a price higher than the mid-price (this is so-called slippage), which will cause the discrepancy between two dexes according to mid-prices will be diminished. So Arbitrage is actually very difficult (not like promoted in many tutorials). Uniswap is on Ethereum blockchain, and so is Sushiswap, we should probably trade on the same blockchain to diminish transections fee and unnecessary delay. When you mean "from any other blockchain", make sure you understand it. You are meaning that to talk between blockchains, say talking between Ethereum blockchain and Binance smart chain, the latter is a hard fork of the former, which means that there is probably more delays or fees in the transections. So we should better stay on the same chain to do the transections. At last, as I mentioned, you should go for Uniswap V2 docs, they already make things clear enough. You can achieve your goals: reading prices, simply following the docs they provided.

you have a good overview about the blockchains. i am as newbie dont know how to sort all this things currently.

overall i think you also dont belivie so much in arbitrage? maybe its just a promotion trick which youtubers use when they talk about flash loan and dex arbitrage in there videos, maybe just clickbate and they try to sell tutorials to become blockchain experts.

you can use what I developed to monitor the price (on Binance smart chain though), which is much clear than this template.

UsernameGitiHub commented 2 years ago

This code is using abis of contracts from Uniswap V1, which is probably deprecated. If blindly copying this template, errors will be inevitable. So my advice is not wasting time on this code instead heading to the docs of Uniswap V2. By simply copying the codes in docs, you can already go pretty far.

i overall dont understand why to use Uniswap, is it not so that Uniswap is just a product of Ethereum Blockchain? What i want to find out is just a simple way how i can get the current price for a token from Ethereum Blockchain and in optimal situation from any other Blokchain. At the end i want to be able to write the name froma token and then my script will tell me this token cost at the moment so much at this dex and so much at that dex and so on. So at the end i will have something like a arbitrage scanner which can see the current price for a token on all different dex exchanges. i just dont know currently if technicaly that is possible or not possible, becaue i am just beginner in crypto currency codeing.

It is technically possible and depends on your need it may be very easy. When you say "current price of a token" which basically just means the ratio between token0 and token1 or vice versa. But this is just what people call mid-price, which will change when you add or extract certain tokens to/from the pool, so you will definitely end up trading with a price higher than the mid-price (this is so-called slippage), which will cause the discrepancy between two dexes according to mid-prices will be diminished. So Arbitrage is actually very difficult (not like promoted in many tutorials). Uniswap is on Ethereum blockchain, and so is Sushiswap, we should probably trade on the same blockchain to diminish transections fee and unnecessary delay. When you mean "from any other blockchain", make sure you understand it. You are meaning that to talk between blockchains, say talking between Ethereum blockchain and Binance smart chain, the latter is a hard fork of the former, which means that there is probably more delays or fees in the transections. So we should better stay on the same chain to do the transections. At last, as I mentioned, you should go for Uniswap V2 docs, they already make things clear enough. You can achieve your goals: reading prices, simply following the docs they provided.

you have a good overview about the blockchains. i am as newbie dont know how to sort all this things currently. overall i think you also dont belivie so much in arbitrage? maybe its just a promotion trick which youtubers use when they talk about flash loan and dex arbitrage in there videos, maybe just clickbate and they try to sell tutorials to become blockchain experts.

you can use what I developed to monitor the price (on Binance smart chain though), which is much clear than this template.

i asked you if you belivie in flash loan arbitrage and binance smart change for me is something complete different have no flash loan arbitrage.

my idea was to build a arbitrage scanner to find price difference in etereum and then take a flash loan to make arbitrage tardes but it sound like the chance is not so big to make that profitable

coolgas commented 2 years ago

This code is using abis of contracts from Uniswap V1, which is probably deprecated. If blindly copying this template, errors will be inevitable. So my advice is not wasting time on this code instead heading to the docs of Uniswap V2. By simply copying the codes in docs, you can already go pretty far.

i overall dont understand why to use Uniswap, is it not so that Uniswap is just a product of Ethereum Blockchain? What i want to find out is just a simple way how i can get the current price for a token from Ethereum Blockchain and in optimal situation from any other Blokchain. At the end i want to be able to write the name froma token and then my script will tell me this token cost at the moment so much at this dex and so much at that dex and so on. So at the end i will have something like a arbitrage scanner which can see the current price for a token on all different dex exchanges. i just dont know currently if technicaly that is possible or not possible, becaue i am just beginner in crypto currency codeing.

It is technically possible and depends on your need it may be very easy. When you say "current price of a token" which basically just means the ratio between token0 and token1 or vice versa. But this is just what people call mid-price, which will change when you add or extract certain tokens to/from the pool, so you will definitely end up trading with a price higher than the mid-price (this is so-called slippage), which will cause the discrepancy between two dexes according to mid-prices will be diminished. So Arbitrage is actually very difficult (not like promoted in many tutorials). Uniswap is on Ethereum blockchain, and so is Sushiswap, we should probably trade on the same blockchain to diminish transections fee and unnecessary delay. When you mean "from any other blockchain", make sure you understand it. You are meaning that to talk between blockchains, say talking between Ethereum blockchain and Binance smart chain, the latter is a hard fork of the former, which means that there is probably more delays or fees in the transections. So we should better stay on the same chain to do the transections. At last, as I mentioned, you should go for Uniswap V2 docs, they already make things clear enough. You can achieve your goals: reading prices, simply following the docs they provided.

you have a good overview about the blockchains. i am as newbie dont know how to sort all this things currently. overall i think you also dont belivie so much in arbitrage? maybe its just a promotion trick which youtubers use when they talk about flash loan and dex arbitrage in there videos, maybe just clickbate and they try to sell tutorials to become blockchain experts.

you can use what I developed to monitor the price (on Binance smart chain though), which is much clear than this template.

i asked you if you belivie in flash loan arbitrage and binance smart change for me is something complete different have no flash loan arbitrage.

my idea was to build a arbitrage scanner to find price difference in etereum and then take a flash loan to make arbitrage tardes but it sound like the chance is not so big to make that profitable

It is super easy to achieve a working prototype. At the core, BSC and Ethereum are the same. The code can be interchanged. The gas fee on ethereum is simply high, without modified algorithms running fast, it doesn't make sense to arbitrage on ethereum. Binance smart chain is simply a playground, don't ever take these stuffs seriously.