• Stars
    star
    324
  • Rank 125,115 (Top 3 %)
  • Language
    Solidity
  • License
    MIT License
  • Created about 1 year ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

simple-blind-arbitrage

This repository contains a simple, mechanical system for blindly submitting atomic arbitrage opportunities to the Flashbots MEV-Share Node. For more details on MEV-Share please see this beta launch announcement and the docs. For high level design details see the design document on the Flashbots Forum.

Although user trade details are hidden by default to prevent frontrunning, this script can atomically backrun Uniswap v2 transactions from the Node by calculating the optimal arbitrage between two Uniswap v2 pools entirely on-chain. Off-chain logic is relatively simple and no trade details are needed beyond the pool that the user is trading on to discover and attempt to execute atomic arbitrage opportunities.

Contained in this repository are two things. First, a smart contract that attempts to execute an atomic arbitrage between two Uniswap v2 pools. Second, a script that listens to the Flashbots MEV-Share Node and submits attempted arbitrages.

This script is intended to be used as an example of blind atomic MEV and how to integrate with the Flashbots MEV-Share Node. Please do your own research and understand the code before using it or putting your money in it. We hope that you will use this code to build your own MEV strategies and share them with the community.

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/simple-blind-arbitrage.git
  1. Change to the project directory:
cd simple-blind-arbitrage/execute
  1. Install the required dependencies:
npm install

Note that this repo also uses Foundry.

Setup

  1. Deploy the smart contract using your preferred method. The dependencies may need to be changed if not using Foundry. Further, you must provide the WETH address on your deployment network as a constructor argument. Finally, please note the account that deploys the contract is the only one that can execute arbitrages.
  2. Transfer WETH to your contract.
  3. Setup your .env file by copying the template and filling it out.
rpcUrl=<YOUR_RPC_URL>
privateKey=<YOUR_PRIVATE_KEY>
executorContractAddress=<CONTRACT_ADDRESS>

Replace <YOUR_RPC_URL> with the URL of your Ethereum RPC provider, <YOUR_PRIVATE_KEY> with the private key of the Ethereum address you want to use for executing the transactions, and <CONTRACT_ADDRESS> with the address of the deployed BlindBackrun smart contract from above.

By default this bot bids 50% of its profits to block.coinbase but this can be configured by changing percentageToKeep in the config file. After a short time after open sourcing it is likely that you will need to increase percentageToKeep for your bundles to be competitive.

Usage

To start listening to the Flashbots MEV-Share Node and submitting blind arbitrage transactions, run the following command:

node index.js -n <network>

Replace with either mainnet or goerli depending on the network you want to use.

Testing

A test in Foundry for the smart contract is provided. Please test using a fork of Goerli, from the root folder please run forge test -f <GOERLI_RPC_URL> and run with -vv to display console.log()s with relevant information during execution.

If you would like to test the monitoring and execution script, please configure for Goerli and run node index.js -n goerli.

Prerequisites

Before using this tool, make sure you have the following software installed on your system:

  • Node.js (version 14.x or higher)
  • npm (usually comes with Node.js)
  • Foundry is optional for smart contract development/testing/deployment

Security

The tool requires a private key for signing transactions. Make sure you don't share your private key or .env file with anyone or commit it to a public repository.

Contributing, improvements, and further work

Contributions are welcome! If you'd like to contribute to this project, feel free to open a pull request. simple-blind-arbitrage is a starting point that can be extended to encompass other MEV strategies. Here are a few improvements we would like to see:

  • Extending the bot to arb across more pools than two.
  • Using a specialized smart contract to more efficiently query the chain for information. All the calls made off-chain can in theory be replaced with a single call.
  • Loading all Uniswap v2 pairs upfront instead of checking for them at runtime.
  • Using flashloans instead of relying on upfront capital.
  • Checking for pools from other Uniswap v2 forks beyond Uniswap and Sushiswap.
  • Arbing coins that are not WETH (DAI, USDC, etc).
  • Integrating other DEXes.
  • Submitting with custom hints that allow other searchers to build on your bundles while retaining bundle privacy.

License

This project is licensed under the MIT License - see the LICENSE file for details.

More Repositories

1

pm

Everything there is to know about Flashbots
2,454
star
2

simple-arbitrage

Example arbitrage bot using Flashbots
TypeScript
1,884
star
3

mev-boost

MEV-Boost allows Ethereum validators to source high-MEV blocks from a competitive builder marketplace
Go
1,083
star
4

mev-research

Project management for MEV Research
841
star
5

mev-inspect-py

🔎 an MEV inspector for Ethereum 🔎
Python
789
star
6

mev-job-board

Need a bot?
670
star
7

mev-inspect-rs

Discover historic Miner Extractable Value (MEV) opportunities
Rust
538
star
8

ethers-provider-flashbots-bundle

Flashbots provider for ethers.js
TypeScript
529
star
9

mev-boost-relay

MEV-Boost Relay for Ethereum proposer/builder separation (PBS)
Go
398
star
10

builder

Flashbots MEV-Boost Block Builder
Go
392
star
11

web3-flashbots

Web3.py plugin for using Flashbots' bundle APIs
Python
382
star
12

searcher-sponsored-tx

TypeScript
343
star
13

searcher-minter

Solidity
231
star
14

mempool-dumpster

Dump all the mempool transactions 🗑️ ♻️ (in Parquet + CSV)
Go
189
star
15

suave-geth

Go
171
star
16

flashbots-docs

TypeScript
171
star
17

rpc-endpoint

Flashbots RPC endpoint, to be used with wallets (eg. MetaMask)
Go
161
star
18

mev-share

Protocol for orderflow auctions
121
star
19

mev-share-client-ts

Client library for Flashbots MEV-share Matchmaker.
TypeScript
109
star
20

mev-flood

simulates MEV activity from an array of unique searchers; used for testing infra
TypeScript
109
star
21

hindsight

Retroactively estimate Uniswap-ish MEV on Flashbots MEV-Share by simulating backrun-arbitrages.
Rust
108
star
22

mev-relay-js

JavaScript
99
star
23

mev-geth-demo

JavaScript
94
star
24

boost-geth-builder

Example builder
Go
93
star
25

mev-share-node

Go
86
star
26

eth2-research

Assessing the nature and impact of MEV in eth2.
Jupyter Notebook
67
star
27

mpc-backrun

Proof-of-concept code for backrunning private transactions using MPC.
Python
63
star
28

geth-sgx-gramine

Geth-in-SGX provides an example of running go-ethereum in SGX
C
60
star
29

relayscan

Ethereum MEV-Boost Relay Monitoring
Go
58
star
30

mev-explore-public

Public repo of MEV-Explore for the community to jam on the dashboard
58
star
31

raytracing

Eth2-MEV project with liquid staking (Flashbots-Lido-Nethermind)
Go
53
star
32

simple-limit-order-bot

TypeScript
49
star
33

block-validation-geth

To be deprecated in favor of https://github.com/flashbots/builder
Go
44
star
34

go-boost-utils

Eth2 builder API types and signing for Golang
Go
41
star
35

reorg-monitor

Ethereum Reorg Monitoring
Go
40
star
36

prysm

Our custom Prysm fork for boost relay and builder CL. Sends payload attributes for block building on every slot to trigger building.
Go
33
star
37

go-template

Template for Go projects
Go
32
star
38

suave-std

Collection of helpful smart contracts to build Suapps
Solidity
32
star
39

sync-proxy

Proxy from consensus client to block builders
Go
31
star
40

suapp-examples

SUAVE Suapp Examples
Go
28
star
41

relay-specs

MEV-Boost Relay API Specs
HTML
26
star
42

dowg

Decentralized Orderflow Working Group
25
star
43

prio-load-balancer

Priority JSON-RPC load balancer (with retries, good logging, and other goodies like SGX/SEV attestation support)
Go
25
star
44

suave-specs

☀️ SUAVE Alpha Protocol Specifications
21
star
45

suave-andromeda-revm

Andromeda revm execution service
Rust
20
star
46

mev-proxy

JavaScript
18
star
47

mev-blocks

JavaScript
17
star
48

flashbots-repository-template

Template to bootstrap and configure new projects maintained by the Flashbots collective
17
star
49

flashbots-dashboard

TypeScript
16
star
50

suave-viem

Typescript client library to interact with SUAVE.
TypeScript
16
star
51

flashbots-writings-website

MDX
15
star
52

andromeda-sirrah-contracts

forge development env for SUAVE key management
Solidity
12
star
53

go-utils

Various reusable Go utilities and modules
Go
11
star
54

EIP-712-swap-PoC

Solidity
10
star
55

curve-based-bundle-pricing

Jupyter Notebook
6
star
56

flashbots-airflow-workflows

Python
6
star
57

dealer-smart-contract

Integral DEX smart contract
TypeScript
6
star
58

flashbots-data-transparency

Collection, analysis and presentation of Flashbots data.
JavaScript
6
star
59

mev-inspect-logs

Log-based MEV inspections
JavaScript
5
star
60

aleth

C++
5
star
61

suave-docs

TypeScript
5
star
62

research-mev-eip1559

Jupyter Notebook
4
star
63

node-healthchecker

Composite health (sync status) checker for blockchain nodes
Go
3
star
64

gramine-andromeda-revm

Python
3
star
65

web3-data-tools

Data tools for Web3
Jupyter Notebook
2
star
66

builder-olympics-website

HTML
2
star
67

suave-toolchain

JavaScript
2
star
68

prometheus-sns-lambda-slack

Receive prometheus alerts via AWS SNS and publish then to slack channel
Go
2
star
69

nginx-static-response

nginx image that returns a fixed status code
Dockerfile
1
star
70

revm

Revm suited for suave needs
Rust
1
star