NFYR / flashbots-demo

This is a simple MEV bot written in go to demonstrate how to use flashbots v0.2 with the Goerli testnet.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flashbots-demo

This is a demo bot written in go that uses flashbots v0.2 on the Goerli testnet, and works out of the box. Feel free to take this and use it as the starting point for your own MEV bot.

Demo flow

This bot creates a simple bundle that does the following:

  1. Deposit 1 eth into the WETH token. It's using the same WETH contract used by uniswap on goerli.
  2. Withdraw 0.5 WETH back into eth, leaving 0.5 as WETH.
  3. Call FlashbotsCheckAndSend to check that the remaining WETH balance is the previous balance + 0.5.
  4. If the check passes, transfer 0.1 eth to the miner.

I've deployed FlashbotsCheckAndSend to goerli and included the address in this demo. Feel free to deploy your own version, or modify the code to use your own.

Since this demo is leaving half of each deposit in WETH, you will eventually run out. I'm leaving it as an exercise to the reader to figure out how to withdraw the rest of your eth.

Setup

First, you'll need a wallet. You can generate a new wallet using the following:

go run init/init.go > .env

Update the created .env file with the correct URL for your provider.

Next, you need some eth. You can request some from the Goerli social faucet. You'll need to tweet your new address and provide the link to the faucet.

Running the demo

Once you have a wallet with some eth and you've setup your .env file, you're ready to run the bot

go get

make run

About

This is a simple MEV bot written in go to demonstrate how to use flashbots v0.2 with the Goerli testnet.


Languages

Language:Go 93.2%Language:Solidity 5.8%Language:Makefile 0.8%Language:Shell 0.2%