flashbots / simple-arbitrage

Example arbitrage bot using Flashbots
1.98k stars 749 forks source link

Adding variables to readme for ease of use, change bundle executor to use a flashloan #5

Open bertmiller opened 3 years ago

bertmiller commented 3 years ago

Originally this PR was only about making changes to the readme to add variables in two places, but I accidentally committed to this branch instead of another, so it is now a PR to do that and add flashloans to the bot. Sorry!

Here are a list of changes to the readme:

And to the actual functionality of the bot:

I've tested this using Hardhat (specifically lowering the profit threshold, copying the targets/params/profit/miner reward over to a test script, and ensuring it executes properly) and it works. It also successfully estimates gas. But I have yet to get any transactions accepted with this being deployed on mainnet.

epheph commented 3 years ago

@bertmiller did you get a chance to test this out like we discussed offline?

bertmiller commented 3 years ago

@epheph I did test it last weekend and today. Last weekend it worked on a local hardhat instance, but after running it for a few days it didn't have any transactions accepted. It would successfully estimate gas and I saw some decent sized arbs come through, so I was confused as to why it wasn't working.

That was running on Aave's v1 flashloans instead of v2, so I upgraded it to v2 and tested that on Hardhat today, which again worked. These changes are reflected in this PR. I've got it up and running so we'll see if this version gets any arbs. If it does I'll report back. Not sure what you want to do with the PR in the meantime. Sorry this has taken some time to get in place!

Also - the check that failed (npm test) isn't really a problem. The reason why that failed is because in Arbitrage.test.ts it expects a much lower test volume, and I've set the minimum test volume high (10 ETH vs the status quo of 0.01 ETH). If you set the test volume back to the array it was before then this passes all expected conditions.

bertmiller commented 3 years ago

So, to any searchers reading this as an update: this code works and a few people, myself included, have submitted successful transactions with it. But, it's almost certainly not profitable anymore with the increased competition for Uniswap like market arbs.

At some point in the future the new auth method needs to be added, and this should probably become a branch instead of a PR, but for now I'm just going to leave this PR open for folks who are interested.

epheph commented 3 years ago

@bertmiller i think the usefulness of having a non-WETH-custodian contract is 100% worth it and it is a much better example for people, especially those who don't have 10 ETH. let me review and merge, i really appreciate this PR