Git Product home page Git Product logo

poly-flashloan-bot's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poly-flashloan-bot's Issues

Error: replacement fee too low

I have found an arbitrage opportunity and it handed it over to the flashloan smart contract, but then it failed with this error message:

Error: replacement fee too low

Additionally, I have attached the log output thrown by the script, maybe it helps to investigate this issue.
log.txt

And there were 2 transactions on Polygon:
https://polygonscan.com/tx/0xd8595edf297a3d5760b1fde6bdaafa0d1c08bf3f9225bd2f1bd1ab405759e6d8
https://polygonscan.com/tx/0x0b2893428bc9919ab742578b03121e71b88f6fa6404ef4c71519e943eed17113

Do you have an idea why this error is happening and how to prevent it?

loanAmount: 10000000000,

Is it normal to have 10 billions in my transaction debug as loanAmount and I set only 10000 as loan amount

ENS Error on Yarn Start

Describe the bug
When running Yarn Start I receive an error.

/Users/kyleborg/poly-flashloan-bot-main/node_modules/@ethersproject/logger/lib/index.js:199
var error = new Error(message);
^

Error: network does not support ENS (operation="ENS", network="matic", code=UNSUPPORTED_OPERATION, version=providers/5.5.2)
at Logger.makeError (/Users/kyleborg/poly-flashloan-bot-main/node_modules/@ethersproject/logger/lib/index.js:199:21)
at Logger.throwError (/Users/kyleborg/poly-flashloan-bot-main/node_modules/@ethersproject/logger/lib/index.js:208:20)
at JsonRpcProvider. (/Users/kyleborg/poly-flashloan-bot-main/node_modules/@ethersproject/providers/lib/base-provider.js:2007:36)
at step (/Users/kyleborg/poly-flashloan-bot-main/node_modules/@ethersproject/providers/lib/base-provider.js:48:23)
at Object.next (/Users/kyleborg/poly-flashloan-bot-main/node_modules/@ethersproject/providers/lib/base-provider.js:29:53)
at fulfilled (/Users/kyleborg/poly-flashloan-bot-main/node_modules/@ethersproject/providers/lib/base-provider.js:20:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: 'network does not support ENS',
code: 'UNSUPPORTED_OPERATION',
operation: 'ENS',
network: 'matic'
}

To Reproduce
Steps to reproduce the behavior:
yarn start from terminal

Expected behavior
Yarn install crashes

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MACOS 12.4
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Cannot read properties of undefined

The script runs normally for some time and then it crashes showing this:

TypeError: Cannot read properties of undefined (reading 'status')
    at E:\poly-flashloan-bot-main\dist\inchPrice.js:81:33
    at Generator.next (<anonymous>)
    at fulfilled (E:\poly-flashloan-bot-main\dist\inchPrice.js:5:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

error when i get oppurtinity

in error.log i found every time this error

at getLendingPool (C:\Users\vkart\Desktop\bot\poly-flashloan-bot-main\dist\flashloan.js:31:46)
at C:\Users\vkart\Desktop\bot\poly-flashloan-bot-main\dist\flashloan.js:39:24
at Generator.next (<anonymous>)
at fulfilled (C:\Users\vkart\Desktop\bot\poly-flashloan-bot-main\dist\flashloan.js:5:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Does anyone make money with this bot?

Just curious to see if anyone makes money with this bot because the example contract that was actually deployed seems to only have failed transactions (not profitable).

Thank you

multiple errors

insufficient funds for intrinsic transaction cost among other errors.
there is 7 Matic balance in the wallet which based on previous transactions should cover the gas

Error Node.js v17.3.1 root@vultr:~/poly-flashloan-bot/src# yarn start ┌────┬────────┬─────────┬────────┬─────────┬─────────┬───────┬─────────────────────────────────────────────────────────┬────────┬──────────────────────────┐│ # │ From │ Amount │ To │ Amount │ ± │ % │ Log │ Time │ Timestamp │├────┼────────┼─────────┼────────┼─────────┼─────────┼───────┼─────────────────────────────────────────────────────────┼────────┼──────────────────────────┤│ 0 │ │ │ │ │ │ │ │ │ ││ 1 │ DAI │ 1000.00 │ ETH │ 997.66 │ -2.3 │ -0.2 │ │ 4.4s │ 2022-01-17T01:04:42.284Z ││ 2 │ DAI │ 1000.00 │ USDC │ 999.00 │ -1.0 │ -0.1 │ │ 8.2s │ 2022-01-17T01:04:42.667Z ││ 3 │ DAI │ 1000.00 │ USDT │ 999.00 │ -1.0 │ -0.1 │ Getting quote for USDT → DAI… │ 26.7s │ 2022-01-17T01:04:44.547Z ││ 4 │ DAI │ 1000.00 │ WMATIC │ 998.44 │ -1.6 │ -0.2 │ │ 5.3s │ 2022-01-17T01:04:42.414Z ││ 5 │ ETH │ 1000.00 │ DAI │ 815.17 │ -184.8 │ -18.5 │ │ 13.2s │ 2022-01-17T01:04:43.216Z ││ 6 │ │ │ │ │ │ │ │ │ ││ 7 │ ETH │ 1000.00 │ USDC │ 963.91 │ -36.1 │ -3.6 │ │ 13.1s │ 2022-01-17T01:04:43.219Z ││ 8 │ ETH │ 1000.00 │ USDT │ 955.84 │ -44.2 │ -4.4 │ │ 8.5s │ 2022-01-17T01:04:42.770Z ││ 9 │ ETH │ 1000.00 │ WMATIC │ 966.76 │ -33.2 │ -3.3 │ │ 18.1s │ 2022-01-17T01:04:43.747Z ││ 10 │ USDC │ 1000.00 │ DAI │ 999.00 │ -1.0 │ -0.1 │ │ 10.9s │ 2022-01-17T01:04:43.039Z ││ 11 │ USDC │ 1000.00 │ ETH │ 998.98 │ -1.0 │ -0.1 │ │ 3.7s │ 2022-01-17T01:04:42.322Z ││ 12 │ │ │ │ │ │ │ │ │ ││ 13 │ USDC │ 1000.00 │ USDT │ 999.00 │ -1.0 │ -0.1 │ │ 3.1s │ 2022-01-17T01:04:42.288Z ││ 14 │ USDC │ 1000.00 │ WMATIC │ 999.12 │ -0.9 │ -0.1 │ │ 2.6s │ 2022-01-17T01:04:42.266Z ││ 15 │ USDT │ 1000.00 │ DAI │ 999.00 │ -1.0 │ -0.1 │ │ 2.9s │ 2022-01-17T01:04:42.291Z ││ 16 │ USDT │ 1000.00 │ ETH │ 998.48 │ -1.5 │ -0.2 │ │ 4.1s │ 2022-01-17T01:04:42.425Z ││ 17 │ USDT │ 1000.00 │ USDC │ 999.00 │ -1.0 │ -0.1 │ │ 8.4s │ 2022-01-17T01:04:42.877Z ││ 18 │ │ │ │ │ │ │ │ │ ││ 19 │ USDT │ 1000.00 │ WMATIC │ 999.12 │ -0.9 │ -0.1 │ │ 4.5s │ 2022-01-17T01:04:42.492Z ││ 20 │ WMATIC │ 1000.00 │ DAI │ 998.20 │ -1.8 │ -0.2 │ │ 2.5s │ 2022-01-17T01:04:42.315Z ││ undefined21 │ undefinedWMATIC │ undefined1000.00 │ undefinedETH │ undefined1016.21 │ undefined 16.2 │ undefined 1.6 │ undefined │ undefined 37.5s │ undefined2022-01-17T01:04:45.836Z │ │ 7.9s │ 2022-01-17T01:04:42.908Z ││ 22 │ WMATIC │ 1000.00 │ USDC │ 998.60 │ -1.4 │ -0.1 │ │ 7.9s │ 2022-01-17T01:04:42.908Z ││ 23 │ WMATIC │ 1000.00 │ USDT │ 998.77 │ -1.2 │ -0.1 │ │ 4.2s │ 2022-01-17T01:04:42.549Z ││ 24 │ │ │ │ │ │ │ │ │ │└────┴────────┴─────────┴────────┴─────────┴─────────┴───────┴─────────────────────────────────────────────────────────┴────────┴──────────────────────────┘/root/poly-flashloan-bot/node_modules/@ethersproject/logger/lib/index.js:199 var error = new Error(message); ^

Error: insufficient funds for intrinsic transaction cost (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{"jsonrpc": "2.0", "id": 51, "error": {"code": -32000, "message": "insufficient funds for gas * price + value"}}","error":{"code":-32000},"requestBody":"{"method":"eth_sendRawTransaction","params":["0xf9078d3585746a52880083e4e1c094fc36872ebd477c3f10395c026036c0929298f7c780b907246bf2b46d000000000000000000000000000000000000000000000000000000000000002000000000000000000000000010dd6d8a29d489bede472cc1b22dc695c144c5c700000000000000000000000000000000000000000000000000000002540be4000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000820136a092be41c90199171cbaf13a726f49012781761107e08fd69896589a3f343de9d7a02751c537d059ca76e9748d9fb20e8a3ab19df7999fe9add041be686a4d7acbd7"],"id":51,"jsonrpc":"2.0"}","requestMethod":"POST","url":"https://polygon-mainnet.g.alchemy.com/v2/G5RvrE0Q5SmLt2jXV7X7GlvUU5qdBh6O"}, method="sendTransaction", transaction="0xf9078d3585746a52880083e4e1c094fc36872ebd477c3f10395c026036c0929298f7c780b907246bf2b46d000000000000000000000000000000000000000000000000000000000000002000000000000000000000000010dd6d8a29d489bede472cc1b22dc695c144c5c700000000000000000000000000000000000000000000000000000002540be4000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000820136a092be41c90199171cbaf13a726f49012781761107e08fd69896589a3f343de9d7a02751c537d059ca76e9748d9fb20e8a3ab19df7999fe9add041be686a4d7acbd7", code=INSUFFICIENT_FUNDS, version=providers/5.5.2)
at Logger.makeError (/root/poly-flashloan-bot/node_modules/@ethersproject/logger/lib/index.js:199:21)
at Logger.throwError (/root/poly-flashloan-bot/node_modules/@ethersproject/logger/lib/index.js:208:20)
at checkError (/root/poly-flashloan-bot/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:95:16)
at JsonRpcProvider. (/root/poly-flashloan-bot/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:659:47)
at step (/root/poly-flashloan-bot/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
at Object.throw (/root/poly-flashloan-bot/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
at rejected (/root/poly-flashloan-bot/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: 'insufficient funds for intrinsic transaction cost',
code: 'INSUFFICIENT_FUNDS',
error: Error: processing response error (body="{"jsonrpc": "2.0", "id": 51, "error": {"code": -32000, "message": "insufficient funds for gas * price + value"}}", error={"code":-32000}, requestBody="{"method":"eth_sendRawTransaction","params":["0xf9078d3585746a52880083e4e1c094fc36872ebd477c3f10395c026036c0929298f7c780b907246bf2b46d000000000000000000000000000000000000000000000000000000000000002000000000000000000000000010dd6d8a29d489bede472cc1b22dc695c144c5c700000000000000000000000000000000000000000000000000000002540be4000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000820136a092be41c90199171cbaf13a726f49012781761107e08fd69896589a3f343de9d7a02751c537d059ca76e9748d9fb20e8a3ab19df7999fe9add041be686a4d7acbd7"],"id":51,"jsonrpc":"2.0"}", requestMethod="POST", url="https://polygon-mainnet.g.alchemy.com/v2/G5RvrE0Q5SmLt2jXV7X7GlvUU5qdBh6O", code=SERVER_ERROR, version=web/5.5.1)
at Logger.makeError (/root/poly-flashloan-bot/node_modules/@ethersproject/logger/lib/index.js:199:21)
at Logger.throwError (/root/poly-flashloan-bot/node_modules/@ethersproject/logger/lib/index.js:208:20)
at /root/poly-flashloan-bot/node_modules/@ethersproject/web/lib/index.js:301:32
at step (/root/poly-flashloan-bot/node_modules/@ethersproject/web/lib/index.js:33:23)
at Object.next (/root/poly-flashloan-bot/node_modules/@ethersproject/web/lib/index.js:14:53)
at fulfilled (/root/poly-flashloan-bot/node_modules/@ethersproject/web/lib/index.js:5:58)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: 'processing response error',
code: 'SERVER_ERROR',
body: '{"jsonrpc": "2.0", "id": 51, "error": {"code": -32000, "message": "insufficient funds for gas * price + value"}}',
error: Error: insufficient funds for gas * price + value
at getResult (/root/poly-flashloan-bot/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:142:21)
at processJsonFunc (/root/poly-flashloan-bot/node_modules/@ethersproject/web/lib/index.js:344:22)
at /root/poly-flashloan-bot/node_modules/@ethersproject/web/lib/index.js:276:46
at step (/root/poly-flashloan-bot/node_modules/@ethersproject/web/lib/index.js:33:23)
at Object.next (/root/poly-flashloan-bot/node_modules/@ethersproject/web/lib/index.js:14:53)
at fulfilled (/root/poly-flashloan-bot/node_modules/@ethersproject/web/lib/index.js:5:58)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: -32000,
data: undefined
},
requestBody: '{"method":"eth_sendRawTransaction","params":["0xf9078d3585746a52880083e4e1c094fc36872ebd477c3f10395c026036c0929298f7c780b907246bf2b46d000000000000000000000000000000000000000000000000000000000000002000000000000000000000000010dd6d8a29d489bede472cc1b22dc695c144c5c700000000000000000000000000000000000000000000000000000002540be4000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000820136a092be41c90199171cbaf13a726f49012781761107e08fd69896589a3f343de9d7a02751c537d059ca76e9748d9fb20e8a3ab19df7999fe9add041be686a4d7acbd7"],"id":51,"jsonrpc":"2.0"}',
requestMethod: 'POST',
url: 'https://polygon-mainnet.g.alchemy.com/v2/G5RvrE0Q5SmLt2jXV7X7GlvUU5qdBh6O'
},
method: 'sendTransaction',
transaction: {
nonce: 53,
gasPrice: BigNumber { _hex: '0x746a528800', _isBigNumber: true },
gasLimit: BigNumber { _hex: '0xe4e1c0', _isBigNumber: true },
to: '0xFC36872EBD477c3f10395c026036c0929298f7c7',
value: BigNumber { _hex: '0x00', _isBigNumber: true },
data: '0x6bf2b46d000000000000000000000000000000000000000000000000000000000000002000000000000000000000000010dd6d8a29d489bede472cc1b22dc695c144c5c700000000000000000000000000000000000000000000000000000002540be4000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000',
chainId: 137,
v: 310,
r: '0x92be41c90199171cbaf13a726f49012781761107e08fd69896589a3f343de9d7',
s: '0x2751c537d059ca76e9748d9fb20e8a3ab19df7999fe9add041be686a4d7acbd7',
from: '0x1fc27eF673a4C61F0e58981efD3A4209f13c5651',
hash: '0xd51f21449c9f25930a37942d99c038558ec6795bb396f8eda511999e4db67303',
type: null,
confirmations: 0
},
transactionHash: '0xd51f21449c9f25930a37942d99c038558ec6795bb396f8eda511999e4db67303'
}

Node.js v17.3.1
root@vultr:~/poly-flashloan-bot/src#
value: BigNumber { _hex: '0x00', _isBigNumber: true },
data: '0x6bf2b46d000000000000000000000000000000000000000000000000000000000000002000000000000000000000000010dd6d8a29d489bede472cc1b22dc695c144c5c700000000000000000000000000000000000000000000000000000002540be4000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf12700000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000',
chainId: 137,
v: 310,
r: '0x92be41c90199171cbaf13a726f49012781761107e08fd69896589a3f343de9d7',
s: '0x2751c537d059ca76e9748d9fb20e8a3ab19df7999fe9add041be686a4d7acbd7',
from: '0x1fc27eF673a4C61F0e58981efD3A4209f13c5651',
hash: '0xd51f21449c9f25930a37942d99c038558ec6795bb396f8eda511999e4db67303',
type: null,
confirmations: 0
},
transactionHash: '0xd51f21449c9f25930a37942d99c038558ec6795bb396f8eda511999e4db67303'
}

Node.js v17.3.1

Execution flashloan test

Hello! anyone knows how to test trigger a execution of flashloan to the blockchain just to see if it is working properly.. at least streaming a tx.. I found a few opportunities but no TX was trigger. Also I don't know where exactly is the profit calculator.

Thanks!

[Feature request] Add log file to track events and failures

Would it be nice to have a log file that we can check that tracks all the meaningful events, like arbitrage opportunities detected with some related data or failures with stacktrace, that way we can help you debug the bot and report issues. Thoughts?

Finding best protocol for pair

Hi,
since you recommended not using 1inch anymore I started redesigning the bot. I encountered the problem that we don’t know the „best“ protocol anymore. Executing the bot for every protocol makes no sense since cyclic arbitraging needs more than one pair. So i tried finding the protocol by asynchronously checking all exchange rates and returning the highest rate giving protocol BUT this causes the bot to fail at some point if i set low intervals. To summarize all my tests with different strategies the last weeks: i didn’t quite found the best performing solution for this :) since your private bot is profitable I’m highly interested in your strategy of finding the protocol!

Undefined when opportunity found, followed by invalid Bignumber error message.

Getting an "undefined" issue when there is profitable arb opportunity on the flash loan bot. I have changed the loan amount, and added several router addresses for different exchanges, as well as a new token.

│ 19 │ USDC │ 11111.00 │ WMATIC │ 11096.64 │ -14.4 │ -0.1 │ Getting quote for USDC → WMATIC… │ │ 2022-02-07T03:53:51.878Z │ │ WBTC │ 11111.00 │ WMATIC │ 349.05 │ -10761.9 │ -96.9 │ Getting quote for WBTC → WMATIC… │ │ 2022-02-07T03:53:51.92 │ undefined20 │ undefinedUSDC │ undefined11111.00 │ undefinedWBTC │ undefined11126.36 │ undefined 15.4 │ undefined 0.1 │ undefined │ undefined 1.7s │ undefined2022-02-07T03:53:53.600Z │C… │ 1.0s │ 2022-02-07T03:53:52.91 │ 21 │ USDC │ 11111.00 │ CRV │ 10890.26 │ -220.7 │ -2.0 │ Getting quote for CRV → USDC… │ 0.8s │ 2022-02-07T03:53:52.67

No error thrown for this but, I do get the following error which is mentioned in another issue:

Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.5.0)

I will look into this myself, and I thank you for any help you can offer.

The result is unclear

Hi! I try to start script and a few hours later he returned this result
undefined5 │ undefinedUSDT │ undefined1000.00 │ undefinedETH │ undefined1020.48 │ undefined20.5 │ undefined2.0 │ undefined │ undefined 2.4s │ undefined2022-02-04T21:53:53.923Z │50 │ undefined19.5 │ undefined 2.0 │ undefined │ undefined6 │ undefinedUSDT │ undefined1000.00 │ undefinedUSDC │ undefined1019.50 │ undefined19.5 │ undefined2.0 │ undefined │ undefined 2.0s │ undefined2022-02-04T21:53:53.506Z │17 │ undefined15.2 │ undefined 1.5 │ undefined │ undefined7 │ undefinedUSDT │ undefined1000.00 │ undefinedWMATIC │ undefined1015.17 │ undefined15.2 │ undefined1.5 │ undefined │ undefined 5.3s │ undefined2022-02-04T21:53:56.837Z

What could be the problem? As far as I understand, the script found a positive result, but nothing happened further. Nothing happened at the contract address

Crash when detected arbitrage opportunity

│ 5 │ USDT   │ 3333.00 │ ETH    │ 3326.28 │ -6.7 │ -0.2 │ Getting quote for WETH → USDT…       │   1.1s │ 2022-02-07T04:13:49.296Z │     │ 6 │ USDT   │ 3333.00 │ USDC   │ 3337.08 │  4.1 │  0.1 │                                      │   1.2s │ 2022-02-07T04:13:49.379Z │     │ 7 │ USDT   │ 3333.00 │ WMATIC │ 3340.57 │  7.6 │  0.2 │                                      │   0.8s │ 2022-02-07T04:13:48.972Z │     └───┴────────┴─────────┴────────┴─────────┴──────┴──────┴──────────────────────────────────────┴────────┴──────────────────────────┘     /Users/adedade/poly-flashloan-bot/node_modules/@ethersproject/logger/lib/index.js:199ATIC…     │        │ 2022-02-07T03:53:52.713Z │
        var error = new Error(message);22 │  3.2 │  0.1 │                                      │   2.8s │ 2022-02-07T03:53:55.531Z │
                    ^──┴────────┴─────────┴──────┴──────┴──────────────────────────────────────┴────────┴──────────────────────────┘

Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.5.0)
    at Logger.makeError (/Users/adedade/poly-flashloan-bot/node_modules/@ethersproject/logger/lib/index.js:199:21)
    at Logger.throwError (/Users/adedade/poly-flashloan-bot/node_modules/@ethersproject/logger/lib/index.js:208:20)
    at Logger.throwArgumentError (/Users/adedade/poly-flashloan-bot/node_modules/@ethersproject/logger/lib/index.js:211:21)
    at Function.BigNumber.from (/Users/adedade/poly-flashloan-bot/node_modules/@ethersproject/bignumber/lib/bignumber.js:241:23)
    at NumberCoder.encode (/Users/adedade/poly-flashloan-bot/node_modules/@ethersproject/abi/lib/coders/number.js:36:39)
    at /Users/adedade/poly-flashloan-bot/node_modules/@ethersproject/abi/lib/coders/array.js:74:19
    at Array.forEach (<anonymous>)
    at pack (/Users/adedade/poly-flashloan-bot/node_modules/@ethersproject/abi/lib/coders/array.js:60:12)
    at TupleCoder.encode (/Users/adedade/poly-flashloan-bot/node_modules/@ethersproject/abi/lib/coders/tuple.js:71:33)
    at AbiCoder.encode (/Users/adedade/poly-flashloan-bot/node_modules/@ethersproject/abi/lib/abi-coder.js:93:15) {
  reason: 'invalid BigNumber value',

@yuichiroaoki any chance you could look into this bug? thanks!

yuichiroaoki contact

Hello @yuichiroaoki I would like to contact you but I cannot find your information anywhere. Can you send me your contact information to chat. TG/Skype/etc is best. Thankyou

build but no output

build succussfully but no output. in error.log like below

[2022-05-30T20:01:34.330] [WARN] error - Failed to estimate price: missing revert data in call exception
[2022-05-30T20:01:34.717] [WARN] error - Failed to estimate price: missing revert data in call exception
[2022-05-30T20:01:34.868] [WARN] error - Failed to estimate price: missing revert data in call exception
[2022-05-30T20:01:34.915] [WARN] error - Failed to estimate price: missing revert data in call exception
[2022-05-30T20:01:34.917] [WARN] error - Failed to estimate price: missing revert data in call exception
[2022-05-30T20:01:34.922] [WARN] error - Failed to estimate price: missing revert data in call exception
[2022-05-30T20:01:34.927] [WARN] error - Failed to estimate price: missing revert data in call exception
[2022-05-30T20:01:34.933] [WARN] error - Failed to estimate price: missing revert data in call exception

Fees Issue

Great bot here, thanks.

Once an opportunity is detected, i have (in my terminal) the table Flash Loans and the different opportunities in the table but nothing happens.

Should I have ETH or only MATIC in the wallet or in the contract?

Actually I have some MATIC in my wallet address but not any transaction is trigeered either in my wallet address or contract address and even on the 3 txns of the 3 opportunities at that time

Contract: https://polygonscan.com/address/0x1098b028Db5edDBD5f3b807D5F9Ea04B8268d342

Add MistX

Is your feature request related to a problem? Please describe.
Prevents MEV and Frontrunning bots from moving in and stealing the profit. Also prevents lost $ from failed transactions

Describe the solution you'd like

https://mistx.stoplight.io/

Additional context
Furucombo uses it and It works well.

web UI

Build a web UI with react

Request failed with status code 400

Hi,

Sorry to bother you again with the same issue.
I deployed in the mainnet and I still get the same error message.
I can see in alchemy I am sucefully making API calls but I still get the same error message.
Do you know how to solve this.

Thanks in advance.

not found libraries/RouteUtils.sol

Describe the bug
"not found libraries/RouteUtils.sol" when compiling on remix

To Reproduce
Steps to reproduce the behavior:

  1. copy and paste contract on remix
  2. compile on correct compiler version

Expected behavior
Contract to deploy

Any help would be greatly appreciated

Can't "yarn install" anymore since last update

Hi Yuichi,

I can't yarn install anymore since the last update. Any ideas?

➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed ➤ YN0000: ┌ Fetch step ➤ YN0013: │ @ethersproject/networks@npm:5.5.2 can't be found in the cache and w ➤ YN0013: │ @ethersproject/providers@npm:5.5.2 can't be found in the cache and ➤ YN0013: │ @ethersproject/random@npm:5.5.1 can't be found in the cache and wil ➤ YN0013: │ ethers@npm:5.5.3 can't be found in the cache and will be fetched fr ➤ YN0001: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close at new NodeError (node:internal/errors:371:5) at PassThrough.onclose (node:internal/streams/end-of-stream:134:30) at PassThrough.emit (node:events:390:28) at emitCloseNT (node:internal/streams/destroy:145:10) at processTicksAndRejections (node:internal/process/task_queues:82:21) ➤ YN0001: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close at new NodeError (node:internal/errors:371:5) at PassThrough.onclose (node:internal/streams/end-of-stream:134:30) at PassThrough.emit (node:events:390:28) at emitCloseNT (node:internal/streams/destroy:145:10) at processTicksAndRejections (node:internal/process/task_queues:82:21) ➤ YN0001: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close at new NodeError (node:internal/errors:371:5) at PassThrough.onclose (node:internal/streams/end-of-stream:134:30) at PassThrough.emit (node:events:390:28) at emitCloseNT (node:internal/streams/destroy:145:10) at processTicksAndRejections (node:internal/process/task_queues:82:21) ➤ YN0001: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close at new NodeError (node:internal/errors:371:5) at PassThrough.onclose (node:internal/streams/end-of-stream:134:30) at PassThrough.emit (node:events:390:28) at emitCloseNT (node:internal/streams/destroy:145:10) at processTicksAndRejections (node:internal/process/task_queues:82:21) ➤ YN0000: └ Completed in 2s 586ms ➤ YN0000: Failed with errors in 2s 795ms

Not enough amount to return loan error

The following error message is expected when you run flashloan with no arbitrage opportunities.
Fail with error 'Not enough amount to return loan'

When the bot says there's an arbitrage opportunity and run flashloan, the transaction gets reverted because of the above error.

Adding new pairs error

Attempting to add new (common) pairs; UNI, LINK I add addresses.ts entries, directly queried from 1inch Polygon API:

UNI: { symbol:"UNI", name:"Uniswap", decimals:18, address:"0xb33eaad8d922b1083446dc23f610c2567fb5180f", logoURI: "https://tokens.1inch.io/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984.png" }, LINK: { symbol:"LINK", name:"ChainLink Token", decimals:18, address:"0x53e0bca35ec356bd5dddfebbd1fc0fd03fabad39", logoURI: "https://tokens.1inch.io/0x514910771af9ca656af840dff83e8264ecf986ca.png", },
and add trading pairs to config.ts:

export const tradingTokens = [
  ERC20Token.DAI,
  ERC20Token.WETH,
  ERC20Token.USDC,
  ERC20Token.USDT,
  ERC20Token.WMATIC,
  ERC20Token.UNI,
  ERC20Token.LINK
];

Results in the following errors during testing:

yarn test results sample:

  ● Uniswap price check › POLYGON_UNISWAP_V3 › DAI -> LINK

    missing revert data in call exception (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{\"jsonrpc\":\"2.0\",\"id\":50,\"error\":{\"code\":-32000,\"message\":\"execution reverted\"}}\n","error":{"code":-32000},"requestBody":"{\"method\":\"eth_call\",\"params\":[{\"to\":\"0xb27308f9f90d607463bb33ea1bebb41c27ce5ab6\",\"data\":\"0xf7729d430000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a06300000000000000000000000053e0bca35ec356bd5dddfebbd1fc0fd03fabad390000000000000000000000000000000000000000000000000000000000000bb80000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000\"},\"latest\"],\"id\":50,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","url":"<MY ALCHEMY ADDRESS>"}, data="0x", code=CALL_EXCEPTION, version=providers/5.5.2)

      at Logger.Object.<anonymous>.Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:225:28)
      at Logger.Object.<anonymous>.Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:237:20)
      at checkError (node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:34:16)
      at JsonRpcProvider.<anonymous> (node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:562:20)
      at step (node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
      at Object.throw (node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
      at rejected (node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)

  ● Uniswap price check › POLYGON_UNISWAP_V3 › USDT -> LINK

    call revert exception (method="quoteExactInputSingle(address,address,uint24,uint256,uint160)", errorArgs=["Unexpected error"], errorName="Error", errorSignature="Error(string)", reason="Unexpected error", code=CALL_EXCEPTION, version=abi/5.5.0)

      at Logger.Object.<anonymous>.Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:225:28)
      at Logger.Object.<anonymous>.Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:237:20)
      at Interface.Object.<anonymous>.Interface.decodeFunctionResult (node_modules/@ethersproject/abi/src.ts/interface.ts:425:23)
      at Object.<anonymous> (node_modules/@ethersproject/contracts/src.ts/index.ts:392:44)
      at step (node_modules/@ethersproject/contracts/lib/index.js:48:23)
      at Object.next (node_modules/@ethersproject/contracts/lib/index.js:29:53)
      at fulfilled (node_modules/@ethersproject/contracts/lib/index.js:20:58)

  ● Uniswap price check › POLYGON_UNISWAP_V3 › USDT -> LINK

    call revert exception (method="quoteExactInputSingle(address,address,uint24,uint256,uint160)", errorArgs=["Unexpected error"], errorName="Error", errorSignature="Error(string)", reason="Unexpected error", code=CALL_EXCEPTION, version=abi/5.5.0)

      at Logger.Object.<anonymous>.Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:225:28)
      at Logger.Object.<anonymous>.Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:237:20)
      at Interface.Object.<anonymous>.Interface.decodeFunctionResult (node_modules/@ethersproject/abi/src.ts/interface.ts:425:23)
      at Object.<anonymous> (node_modules/@ethersproject/contracts/src.ts/index.ts:392:44)
      at step (node_modules/@ethersproject/contracts/lib/index.js:48:23)
      at Object.next (node_modules/@ethersproject/contracts/lib/index.js:29:53)
      at fulfilled (node_modules/@ethersproject/contracts/lib/index.js:20:58)

Test Suites: 1 failed, 3 passed, 4 total
Tests:       18 failed, 133 passed, 151 total
Snapshots:   0 total
Time:        109.821 s
Ran all test suites.

All exchanges have the same error for UNI and LINK pairs.

Fees calculation before send the transaction

Fees need to be calculated before send the transaction to avoid 'Not enough amount to return loan', 'INSUFFICIENT_OUTPUT_AMOUNT' errors... It would be nice if you can implement something like this:

  1. Get Quote
  2. Calculate each swap fees and add to it loan fees and ADD the slippery % (the one set in config.ts)
  3. Check the difference of % or calculate amount and check amount diff.
  4. If difference % or amnt is +n (this should be a const in config.ts to include/edit MATIC fees as needed) so send transaction BUT if difference % or amnt -n or = 0 so do not send the transaction

Actually when you swap 3 times in one transactions it can be 0.05x3 = 0.15 % fees on top of the flashloans fees 0.09%... Total 0.24% and.... slippery can add it on top again if the bot takes to long time to get the quote :) Eg: 0.24 + 6 = 6.24%

'const diffAmount' should be here MORE than 1000 + 6.24% or 62.4 USD to return to loan BUT we don't know how many swaps will be done before getting the quote so this const doesn't really help for now (but interesting to get it there).

Everything need to be done in milliseconds.

To avoid "high slippery" Im testing some auto rotation proxies services directly in the CallUrl... (I'm not a dev so I try easy way first) in order to increase transactions speed. I'll continue my tests...

With all of this we may have much less opportunities but at least we will be able to get a profit from them when their is big prices movements and to make it works.

https://polygonscan.com/address/0x3b89c1a54a2db96826b1319ae393b52a86938e60

error "Fail"

For the first time the bot made a transaction on the contract ;) but returned a error Fail

Capture d’écran du 2022-02-12 16-12-49

Crash when fetching prices for 1inch

/Users/adedade/poly-flashloan-bot/dist/inchPrice.js:30
        amount.toString() +
               ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at get1inchQuoteCallUrl (/Users/adedade/poly-flashloan-bot/dist/inchPrice.js:30:16)
    at /Users/adedade/poly-flashloan-bot/dist/inchPrice.js:53:31
    at Generator.next (<anonymous>)
    at fulfilled (/Users/adedade/poly-flashloan-bot/dist/inchPrice.js:5:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

"insufficient funds for gas * price + value\"}}","error"

Error: insufficient funds for intrinsic transaction cost (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{"jsonrpc": "2.0", "id": 51, "error": {"code": -32000, "message": "insufficient funds for gas * price + value"}}","error":{"code":-32000}

I keep getting the above error. I have changed the gas from 30 to 150 to test if I needed to indicate a high gas price however it gives the same error at a price of 150.

Any suggestions?

Error Request failed with status code 400

Hi!
First of all thanks for sharing this code.
I am having an issue I cant solve when I use the command "yarn start". It says "Error Request failed with status code 400".
Can you please help me to sort that issue?

Thanks in advance.

Edited but I haven't found a profitable arbitrage!

Edited but I haven't found a profitable arbitrage!

I really appreciate what you have done but I'm not agree with what you have write.

I've edited your bot, I have removed 1inch API and add call directly with dex smartcontract quote.
I have done 1 to 1 swap.

I have run bot for several time but I never have found a profitable arbitrage!
I share an example:

1 USD Coin -> 0.99924 Tether USD [UNISWAP_V3]
1 USD Coin -> 0.99549 Tether USD [SUSHISWAP]
1 USD Coin -> 0.99407 Tether USD [QUICKSWAP]
1 USD Coin -> 0.99723 Tether USD [APESWAP]
1 USD Coin -> 0.99868 Tether USD [JETSWAP]
1 USD Coin -> 0.99818 Tether USD [POLYCAT]
1 USD Coin -> 0.99812 Tether USD [WAULTSWAP]

0.99924 Tether USD -> 0.99899 USD Coin [UNISWAP_V3]
0.99924 Tether USD -> 0.99774 USD Coin [SUSHISWAP]
0.99924 Tether USD -> 0.99918 USD Coin [QUICKSWAP]
0.99924 Tether USD -> 0.998 USD Coin [APESWAP]
0.99924 Tether USD -> 0.99855 USD Coin [JETSWAP]
0.99924 Tether USD -> 0.99623 USD Coin [POLYCAT]
0.99924 Tether USD -> 0.9971 USD Coin [WAULTSWAP]

Request failed with status code 400

Thank you for sharing your code!

I have it up and running by following your instructions but I keep getting lots of errors like Request failed with status code 400. What am I doing wrong?

I am on the Polygon mainnet and the smart contract is deployed.

Thanks for your help.

Docker giving error, and yarn hanging infinitely.

When use the command source startup.sh I get the following error

[+] Building 2.3s (10/12)
 => [internal] load build definition from Dockerfile                                                                                                                                                                                    0.1s
 => => transferring dockerfile: 38B                                                                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                       0.1s
 => => transferring context: 35B                                                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/node:16.14                                                                                                                                                                           1.1s
 => [internal] load build context                                                                                                                                                                                                       0.4s
 => => transferring context: 3.72kB                                                                                                                                                                                                     0.4s
 => [1/8] FROM docker.io/library/node:16.14@sha256:6e54786b2ad01667d46524e82806298714f50d2be72b39706770aed55faedbd7                                                                                                                     0.0s
 => CACHED [2/8] WORKDIR /app                                                                                                                                                                                                           0.0s
 => CACHED [3/8] COPY package.json .                                                                                                                                                                                                    0.0s
 => CACHED [4/8] RUN yarn set version berry                                                                                                                                                                                             0.0s
 => CACHED [5/8] COPY .yarn tsconfig.json .yarnrc.yml ./                                                                                                                                                                                0.0s
 => ERROR [6/8] RUN yarn install                                                                                                                                                                                                        0.6s
------
 > [6/8] RUN yarn install:
#10 0.593 node:internal/modules/cjs/loader:936
#10 0.593   throw err;
#10 0.593   ^
#10 0.593
#10 0.593 Error: Cannot find module '/app/.yarn/releases/yarn-3.2.0.cjs'
#10 0.593     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
#10 0.593     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
#10 0.593     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
#10 0.593     at node:internal/main/run_main_module:17:47 {
#10 0.593   code: 'MODULE_NOT_FOUND',
#10 0.593   requireStack: []
#10 0.593 }
------
executor failed running [/bin/sh -c yarn install]: exit code: 1
TypeError: process.stdout.getWindowSize is not a function or its return value is not iterable
    at /app/dist/index.js:27:38
    at Generator.next (<anonymous>)
    at /app/dist/index.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/app/dist/index.js:4:12)
    at main (/app/dist/index.js:24:20)
    at Object.<anonymous> (/app/dist/index.js:173:18)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)

Using Ubuntu WSL2 and Yarn 3.2.0

Using yarn:
Yarn install & build seem to work, but yarn start command hangs infinitely.

Invalid Big number error when find opportunity (dodo branch)

/home/h4ckm1n/Documents/GitHub/poly-flashloan-bot/node_modules/@ethersproject/logger/src.ts/index.ts:225
const error: any = new Error(message);
^
Error: invalid BigNumber value (argument="value", value=[500], code=INVALID_ARGUMENT, version=bignumber/5.5.0)
at Logger.makeError (/home/h4ckm1n/Documents/GitHub/poly-flashloan-bot/node_modules/@ethersproject/logger/src.ts/index.ts:225:28)
at Logger.throwError (/home/h4ckm1n/Documents/GitHub/poly-flashloan-bot/node_modules/@ethersproject/logger/src.ts/index.ts:237:20)
at Logger.throwArgumentError (/home/h4ckm1n/Documents/GitHub/poly-flashloan-bot/node_modules/@ethersproject/logger/src.ts/index.ts:241:21)
at Function.BigNumber.from (/home/h4ckm1n/Documents/GitHub/poly-flashloan-bot/node_modules/@ethersproject/bignumber/src.ts/bignumber.ts:291:23)
at NumberCoder.encode (/home/h4ckm1n/Documents/GitHub/poly-flashloan-bot/node_modules/@ethersproject/abi/src.ts/coders/number.ts:25:27)
at /home/h4ckm1n/Documents/GitHub/poly-flashloan-bot/node_modules/@ethersproject/abi/src.ts/coders/array.ts:71:19
at Array.forEach ()
at pack (/home/h4ckm1n/Documents/GitHub/poly-flashloan-bot/node_modules/@ethersproject/abi/src.ts/coders/array.ts:54:12)
at TupleCoder.encode (/home/h4ckm1n/Documents/GitHub/poly-flashloan-bot/node_modules/@ethersproject/abi/src.ts/coders/tuple.ts:54:20)
at AbiCoder.encode (/home/h4ckm1n/Documents/GitHub/poly-flashloan-bot/node_modules/@ethersproject/abi/src.ts/abi-coder.ts:112:15) {
reason: 'invalid BigNumber value',
code: 'INVALID_ARGUMENT',
argument: 'value',
value: [ 500 ]
}
Waiting for the debugger to disconnect...
[nodemon] app crashed - waiting for file changes before starting...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.