olegmitrakhovich / defi-arb-bot Goto Github PK
View Code? Open in Web Editor NEWarbitrage bot, looks for prices differences on uniswap and kyber. Uses flashloan to make a trade between 2 exchanges. #eattheblocks course
arbitrage bot, looks for prices differences on uniswap and kyber. Uses flashloan to make a trade between 2 exchanges. #eattheblocks course
So far the bot was able to find some ARB opportunities, but all 3 transactions were reverted:
https://etherscan.io/address/0x92E52890cfA407D9713A6cFcd7FB6F8d50B99FB2
The error I am getting is "Fail with error 'Not enough funds to repay dydx loan!", no idea why this is happening? My theory is that the prices that the bot is finding are wrong, therefore the calculation of profit for that transaction is wrong. I tried switching to another service like QuickNode instead of Infura, but the result is the same. Any ideas are welcome :)
I can run this bot, but some erro happen,
I have no idea about it.
Kyber -> Uniswap. Dai input / output: 20000 / 19867.970249227993481323
Uniswap -> Kyber. Dai input / output: 20000 / 19888.434829561962045591
New block received. Block # 10772418
Warning: 0x6b175474e89094c44da98b954eedeac495271d0f is not checksummed.
updateEthPrice ing :0x6b175474e89094c44da98b954eedeac495271d0f
updateEthPrice end :0x6b175474e89094c44da98b954eedeac495271d0f
(node:6956) UnhandledPromiseRejectionWarning: Error: failed to meet quorum (method="call", params={"transaction":{"to":"0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11","data":"0x0902f1ac"},"blockTag":"latest"}, results=[{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"baseUrl":"https://api.etherscan.io","apiKey":"9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB","_internalBlockNumber":{}},"weight":1,"start":1598925148680,"error":{"reason":"missing response","code":"SERVER_ERROR","requestBody":null,"requestMethod":"GET","serverError":{"errno":"ETIMEDOUT","code":"ETIMEDOUT","syscall":"connect","address":"75.126.2.43","port":443},"url":"https://api.etherscan.io/api?module=proxy&action=eth_call&to=0xa478c2975ab1ea89e8196811f51a7b7ade33eb11&data=0x0902f1ac&apikey=9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB"}},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":10767750,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":1598925147726,"connection":{"url":"https://cloudflare-eth.com/"},"_nextId":44,"_internalBlockNumber":{},"_fastBlockNumber":10767750,"_fastBlockNumberPromise":{}},"weight":1,"start":1598925148680,"result":"0x0000000000000000000000000000000000000000002322989de30ee203751b3d00000000000000000000000000000000000000000000156d04917f45cba89d6b000000000000000000000000000000000000000000000000000000005f4c6bed"},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":10772416,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":1598925148679,"connection":{"url":"https://eth-mainnet.alchemyapi.io/v2/_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"},"_nextId":44,"apiKey":"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC","_internalBlockNumber":{},"_fastBlockNumber":10772416,"_fastBlockNumberPromise":{}},"weight":1,"start":1598925169682,"result":"0x0000000000000000000000000000000000000000003584c7d99b3f6304be89d2000000000000000000000000000000000000000000001ff4d99c04d1751f9e25000000000000000000000000000000000000000000000000000000005f4da953"},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":10772416,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":1598925147851,"connection":{"url":"https://mainnet.infura.io/v3/84842078b09946638c03157f83405213"},"_nextId":44,"apiKey":"84842078b09946638c03157f83405213","projectId":"84842078b09946638c03157f83405213","projectSecret":null,"_internalBlockNumber":{},"_fastBlockNumber":10772416,"_fastBlockNumberPromise":{}},"weight":1,"start":1598925169682,"result":"0x00000000000000000000000000000000000000000035878cb4ca1d8481b71005000000000000000000000000000000000000000000001ff333b3490718e4b76e000000000000000000000000000000000000000000000000000000005f4da95a"}], provider={"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":10772416,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":1598925148679,"providerConfigs":[{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":10772416,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":1598925147851,"connection":{"url":"https://mainnet.infura.io/v3/84842078b09946638c03157f83405213"},"_nextId":44,"apiKey":"84842078b09946638c03157f83405213","projectId":"84842078b09946638c03157f83405213","projectSecret":null,"_internalBlockNumber":{},"_fastBlockNumber":10772416,"_fastBlockNumberPromise":{}},"weight":1,"stallTimeout":750,"priority":1},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":-1024,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":0,"baseUrl":"https://api.etherscan.io","apiKey":"9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB","_internalBlockNumber":{}},"weight":1,"stallTimeout":750,"priority":1},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":10772416,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":1598925148679,"connection":{"url":"https://eth-mainnet.alchemyapi.io/v2/_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"},"_nextId":44,"apiKey":"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC","_internalBlockNumber":{},"_fastBlockNumber":10772416,"_fastBlockNumberPromise":{}},"weight":1,"stallTimeout":750,"priority":1},{"provider":{"_isProvider":true,"_events":[],"_emitted":{"block":-2},"formatter":{"formats":{"transaction":{},"transactionRequest":{},"receiptLog":{},"receipt":{},"block":{},"blockWithTransactions":{},"filter":{},"filterLog":{}}},"anyNetwork":false,"_network":{"name":"homestead","chainId":1,"ensAddress":"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},"_maxInternalBlockNumber":10767750,"_lastBlockNumber":-2,"_pollingInterval":4000,"_fastQueryDate":1598925147726,"connection":{"url":"https://cloudflare-eth.com/"},"_nextId":44,"_internalBlockNumber":{},"_fastBlockNumber":10767750,"_fastBlockNumberPromise":{}},"weight":1,"stallTimeout":750,"priority":1}],"quorum":2,"_highestBlockNumber":10772416,"_internalBlockNumber":{},"_fastBlockNumber":10772416,"_fastBlockNumberPromise":{}}, code=SERVER_ERROR, version=providers/5.0.5)
at Logger.makeError (C:\Users\Administrator\Downloads\Defi-Arb-Bot-master\node_modules@ethersproject\logger\lib\index.js:179:21)
at Logger.throwError (C:\Users\Administrator\Downloads\Defi-Arb-Bot-master\node_modules@ethersproject\logger\lib\index.js:188:20)
at FallbackProvider. (C:\Users\Administrator\Downloads\Defi-Arb-Bot-master\node_modules@ethersproject\providers\lib\fallback-provider.js:626:54)
at step (C:\Users\Administrator\Downloads\Defi-Arb-Bot-master\node_modules@ethersproject\providers\lib\fallback-provider.js:46:23)
at Object.next (C:\Users\Administrator\Downloads\Defi-Arb-Bot-master\node_modules@ethersproject\providers\lib\fallback-provider.js:27:53)
at fulfilled (C:\Users\Administrator\Downloads\Defi-Arb-Bot-master\node_modules@ethersproject\providers\lib\fallback-provider.js:18:58)
(node:6956) 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(). (rejection id: 3)
internal/url.js:256
throw new ERR_INVALID_URL(input);
I get the following error, pls help resolve...:
:Defi-Arb-Bot$ node run-arbitrage.js
node:internal/url:552
throw new ERR_INVALID_URL(input);
^
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:371:5)
at onParseError (node:internal/url:552:9)
at new URL (node:internal/url:628:5)
at Object.helpers [as parseURL] (/Defi-Arb-Bot/node_modules/web3-providers-ws/lib/helpers.js:14:20)
at new WebsocketProvider (/Defi-Arb-Bot/node_modules/web3-providers-ws/lib/index.js:61:29)
at Object. (/Defi-Arb-Bot/run-arbitrage.js:9:3)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47 {
input: 'undefined',
code: 'ERR_INVALID_URL'
}
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'
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.