yuichiroaoki / poly-flashloan-bot

Flashloan Bot on Polygon
https://yuichiroaoki.medium.com/flashloan-bot-on-polygon-part-2-3eae0ac33986?sk=80821da4ca1d0462c7c9ae617df56bdd
MIT License
303 stars 192 forks source link

Fees Issue #15

Open ezera23 opened 2 years ago

ezera23 commented 2 years ago

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

MetaNynja commented 2 years ago

It processes in Matic. What did you set the gas limit to? I haven’t had a successful one yet, they all fail and chew up my gas.

ezera23 commented 2 years ago

Ok i got requests logs from alchemy dashboard so the bot behavior is a bit more clear to me now, I can see that many transactions (maybe 4-7) was done during the last 24hours. But I still have nothing in terminal and in polygonscan, everything seems to be cancelled without error maybe due to gas fees. I would not say cancelled I would say not going through without error on alchemy and then nothing on polygonscan. I did not paid any MATIC from my wallet for gas yet so I assume that's a gas issue.

Before i setup it to 600 gwei and did a yarn rebuild.... Now i have increased it to 1200 (and slippage 5) and did a yarn rebuild. I am testing again for today.

Also i have noted that my 600 gwei setting doesn't reflect properly in the transaction log on alchemy: I got a gasPrice of 3.000000000e+10 means 0.3, why???? image_2022-01-07_092644

MetaNynja commented 2 years ago

I’m surprised it hasn’t logged anything on polyscan. Did you by chance mistakenly use your wallet address in the .env instead of the private key?

Do you get any error messages in your terminal?

Have you connected your wallet to the polygon mainnet and moved your matic to the polygon mainnet?

Check out my failed attempts.

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

ezera23 commented 2 years ago

in the eth_sendRawTransaction its my wallet address in the "From" so the .env seems to work (I have double checked in case)

No error in terminal

For you, It may be the fees or a bad contract, did you encounter any error during deployment and compilations ? Do you have any errors on alchemy (if you use it)

MetaNynja commented 2 years ago

For the contract, when I yarn install I get :

PS C:\Test Flash Loan Contract\poly-flash> yarn install ➤ YN0000: ┌ Resolution step ➤ YN0002: │ typechain@npm:3.0.0 doesn't provide typescript (p4ba7f), requested by ts-essentials ➤ YN0002: │ typechain@npm:5.1.2 doesn't provide typescript (p0e7bb), requested by ts-essentials ➤ YN0002: │ typescript-hardhat@workspace:. doesn't provide @ethersproject/abi (pf793a), requested by @typechain/ethers-v5 ➤ YN0002: │ typescript-hardhat@workspace:. doesn't provide @ethersproject/bytes (p71ee1), requested by @typechain/ethers-v5 ➤ YN0002: │ typescript-hardhat@workspace:. doesn't provide @ethersproject/providers (pbebd3), requested by @typechain/ethers-v5 ➤ YN0002: │ typescript-hardhat@workspace:. doesn't provide lodash (pd4f27), requested by @typechain/hardhat ➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements for details, where is the six-letter p-prefixed code ➤ YN0000: └ Completed in 0s 741ms ➤ YN0000: ┌ Fetch step ➤ YN0013: │ yargs-unparser@npm:1.6.0 can't be found in the cache and will be fetched from the remote registr ➤ YN0013: │ yargs@npm:13.2.4 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yargs@npm:13.3.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yargs@npm:4.8.1 can't be found in the cache and will be fetched from the remote registry ➤ YN0013: │ yn@npm:3.1.1 can't be found in the cache and will be fetched from the remote registry ➤ YN0000: └ Completed in 1m 40s ➤ YN0000: ┌ Link step ➤ YN0062: │ fsevents@patch:fsevents@npm%3A2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=1cc4b2 The platform win32 is incompatible with this module, link skipped. ➤ YN0062: │ fsevents@patch:fsevents@npm%3A2.1.3#~builtin<compat/fsevents>::version=2.1.3&hash=1cc4b2 The platform win32 is incompatible with this module, link skipped. ➤ YN0007: │ keccak@npm:3.0.1 must be built because it never has been before or the last one failed ➤ YN0007: │ postinstall-postinstall@npm:2.1.0 must be built because it never has been before or the last one failed ➤ YN0007: │ core-js-pure@npm:3.17.3 must be built because it never has been before or the last one failed
➤ YN0007: │ keccak@npm:3.0.2 must be built because it never has been before or the last one failed ➤ YN0007: │ secp256k1@npm:4.0.2 must be built because it never has been before or the last one failed
➤ YN0007: │ web3-bzz@npm:1.5.2 must be built because it never has been before or the last one failed ➤ YN0007: │ web3-shh@npm:1.5.2 must be built because it never has been before or the last one failed ➤ YN0007: │ bufferutil@npm:4.0.3 must be built because it never has been before or the last one failed
➤ YN0007: │ utf-8-validate@npm:5.0.5 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js@npm:2.6.12 must be built because it never has been before or the last one failed ➤ YN0007: │ web3@npm:1.5.2 must be built because it never has been before or the last one failed ➤ YN0000: └ Completed in 7m 27s ➤ YN0000: Done with warnings in 9m 8s

When I yarn compile I get :

PS C:\Test Flash Loan Contract\poly-flash> yarn compile Compiling 28 files with 0.8.4 Generating typings for: 30 artifacts in dir: typechain for target: ethers-v5 Successfully generated 44 typings! Compilation finished successfully

Alchemy Errors

ezera23 commented 2 years ago

I made a new try, AWS new VM and new contract, reinstalled everything, Im waiting a new transaction to be done on the new contract... I have set 800 Gwei and 5% slippage for test...lets see.... Now we are almost at the same stage (please note that I have git cloned the "branch uniswap 3" for the smart contract...)

Actually fetch time to get the quotes are much better... btw I think Yuishiro mistake this is not seconds but milliseconds

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

For the error fail with error 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' This seems to be a solution https://github.com/Uniswap/interface/issues/2511 https://forum.mstable.org/t/execution-reverted-uniswapv2router-insufficient-output-amount/490

Also gas limit should not exceed 1500000. 'exceeds gas limit' error

Remember that its still arbitrage, chance to get a deal are rare and you need to be extra fast to get it (so the best network server performance is a MUST HAVE), the lowest slippage of course for the flash loan and to not cancel the deal margin.

I also rebuild the bot everytime I edit the config.ts

@yuichiroaoki Great work on Uniswap 3 mate, the bot also use Uniswap 3 without requiring a update? If yes can you explain in 2 words how?

gsngsn123 commented 2 years ago

Fail with error 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT' how can i resolve this error

yuichiroaoki commented 2 years ago

I made a new try, AWS new VM and new contract, reinstalled everything, Im waiting a new transaction to be done on the new contract... I have set 800 Gwei and 5% slippage for test...lets see.... Now we are almost at the same stage (please note that I have git cloned the "branch uniswap 3" for the smart contract...)

Actually fetch time to get the quotes are much better... btw I think Yuishiro mistake this is not seconds but milliseconds

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

For the error fail with error 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' This seems to be a solution Uniswap/interface#2511 https://forum.mstable.org/t/execution-reverted-uniswapv2router-insufficient-output-amount/490

Also gas limit should not exceed 1500000. 'exceeds gas limit' error

Remember that its still arbitrage, chance to get a deal are rare and you need to be extra fast to get it (so the best network server performance is a MUST HAVE), the lowest slippage of course for the flash loan and to not cancel the deal margin.

I also rebuild the bot everytime I edit the config.ts

@yuichiroaoki Great work on Uniswap 3 mate, the bot also use Uniswap 3 without requiring a update? If yes can you explain in 2 words how?

I'm not sure why the transactions weren't triggered. Smart contracts of uniswapV3 branch seems okay, but it doesn't work with the bot because the new one needs more parameters . I'm still working on it.

MetaNynja commented 2 years ago

Looking forward to getting v3 implemented. I’m going to spend today trying to get it added too

ezera23 commented 2 years ago

What are the big steps to implement it to the bot?

On Fri, Jan 7, 2022, 20:26 MetaNynja @.***> wrote:

Looking forward to getting uninstall v3 implemented. I’m going to spend today trying to get it added too

— Reply to this email directly, view it on GitHub https://github.com/yuichiroaoki/poly-flashloan-bot/issues/15#issuecomment-1007405872, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVHKCNJUOQDH44OTY5QTD3UU3SXDANCNFSM5LL7GP4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

MetaNynja commented 2 years ago

Lets start a V3 thread, I’m just diving in to implementing it today so I can’t yet say what the big parts are but I’ll be working on it today and will post in a new thread everything I’m doing