• Stars
    star
    662
  • Rank 68,103 (Top 2 %)
  • Language
    Rust
  • License
    MIT License
  • Created about 2 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

Bootstrap your MEV bot strategies with a simple boilerplate to build on top of.

MEV Template

Designed by DeGatchi.

Bootstrap your MEV bot strategies with a simple boilerplate to build on top of.

How To Use This Template

I wrote an article How To Build A MEV Bot that explains the overall architecture you need to think of to build a bot - from getting a strategy and fetching data to general tips on design structure (that you most likely wont find anywhere else).

I've built out a fair few foundational features that you can customsie to your liking. Whether your strategy utilises a mempool scanner, next block strategy, event streaming, this repo lays the basics out so you don't need to copy and paste your bots for new strategies. s Majority of these features can be expanded upon to become much more comprehensive, however it's not wise to open source it since your competition will either use it/know how advance your system is ;)

Having said that, the aim of this was to create something to help people that are struggling to get into MEV. Despite it being a highly competitive field where this repo would enhance/onboard new competitors, I wanted to give people that are in the same position as I once was a chance to break into the field. It's a cold world out there in MEV-land but hopefully this will give you that inspiration you need to keep pushing forward <3

Quick Start

  • Get a node from QuickNode as they have a free websocket option or you can run your own node.
  • Import your EOA priv key for the bot to execute transactions.
  • Add your discord websocket to send alerts to.
  • For testing, run cargo run
  • For production, run cargo run --release

Features

This repo comes with the following features implemented.

  • Simple discord message system.
  • Historic block function caller.
  • Uniswap amountIn + amountOut functions.
  • Contract ABI binding.
  • Template contract
    • Uniswap getters.
    • Withdraw ERC20 + ETH functions.
  • Mempool Monitoring.
    • Simple tx decoding.

Mempool Monitoring Example

---------- MONITORING MEMPOOL ----------
Transaction: Transaction {
    hash: 0xcb3647deb3b7ada364a6643752bf9243b27e84cea78cc0010d26fa3ae52b5e13,
    nonce: 22387,
    block_hash: None,
    block_number: None,
    transaction_index: None,
    from: 0xe88102f2900483c63d0adcdaf4839c2759949de6,
    to: Some(
        0x16327e3fbdaca3bcf7e38f5af2599d2ddc33ae52,
    ),
    value: 9024569904524523678,
    gas_price: Some(
        120000000000,
    ),
    gas: 1000000,
    input: Bytes(
        b"\x7f\xf3j\xb5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x10\xbbdEK\xa0[\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x80\0\0\0\0\0\0\0\0\0\0\0\0\xe8\x81\x02\xf2\x90\x04\x83\xc6=\n\xdc\xda\xf4\x83\x9c'Y\x94\x9d\xe6\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x02\xf0\\\x10\xa0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x02\0\0\0\0\0\0\0\0\0\0\0\0!\xbe7\rS\x12\xf4L\xb4,\xe3w\xbc\x9b\x8a\x0c\xef\x1aL\x83\0\0\0\0\0\0\0\0\0\0\0\0\xbeAw%\x87\x87*\x92\x18Hs\xd5[\t\xc6\xbboY\xf8\x95",
    ),
    v: 535,
    r: 44692797049587778392645963656820336298473713424700451186489839760496971858835,
    s: 36641529939556041694165250732768051817286656083457538183752182129357071704354,
    transaction_type: Some(
        0,
    ),
    access_list: None,
    max_priority_fee_per_gas: None,
    max_fee_per_gas: None,
    chain_id: None,
    other: OtherFields {
        inner: {},
    },
}
Router Call: SwapExactETHForTokens(
    SwapExactETHForTokensCall {
        amount_out_min: 4709638961078363,
        path: [
            0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83,
            0xbe41772587872a92184873d55b09c6bb6f59f895,
        ],
        to: 0xe88102f2900483c63d0adcdaf4839c2759949de6,
        deadline: 12622500000,
    },
)

Testing Onchain Data

Setting up environment:

  • Install python3: pip install.
  • Install modules: pip install web3.
  • Run: python3 block_history.py.

5 main components to consider:

  • provider: Which chain is being utilised.
  • abi: The contract interface to interact with.
  • block: Which mined block you're calling from (can be past block).
  • contract address: Contract address to call.
  • function call: Function to call from the contract address.

More Repositories

1

Blockchain-Alpha

Alpha from various sectors in the blockchain space.
Solidity
109
star
2

calldata-decoder

A black-box raw calldata decoder using only calldata to guess types and parse parameters.
Rust
86
star
3

merkle-generator

Bootstrap your merkle tree.
Rust
54
star
4

tx-decoder

A quick way to decode a contract's transaction data with only the contract address and abi.
Rust
23
star
5

memware

A generalised MEV bot that simulates and frontruns pending transactions in the mempool.
20
star
6

solidity-experiments

Experimental contracts that test the details of Solidity, attempting to discover optimal use cases
Solidity
14
star
7

degatchi-website

JavaScript
12
star
8

zerodays

Solidity
9
star
9

learning-huff

Solidity
9
star
10

forge-template

Set up a forge testing env instantly w/ ds-test, solmate + openzeppelin preinstalled.
Solidity
8
star
11

gas-golfer

Gas golfing experiments to test lowlevel skills
5
star
12

merkle-presale

Solidity
5
star
13

evm-ctfs

The CTF damn vulnerable defi solutions w/ foundry.
5
star
14

treasury

A basic treasury contract
Solidity
3
star
15

web3-auth-rs

Authenticate your wallet by signing and verifying a message.
Rust
3
star
16

ui-encyclopedia

All the UI designs I learn will be stored here for future reference :)
JavaScript
3
star
17

rust-api-fetcher

An API fetcher for Rick and Morty API.
Rust
3
star
18

rust-experiments

Tests + experiments that aim to answer questions of optimisation + what's possible w/ Rust.
Rust
2
star
19

basic-treasury-rewarder

Solidity
2
star
20

black-hat-rust-walthrough

Rust
2
star
21

cli-database-rs

Create, view and store data using an SQL database via Rust.
2
star
22

web3-frontend-template

2
star
23

SkullySniper

Solidity
2
star
24

single-asset-liquidity

Provide one of the two tokens in a pair to provide liquidity.
1
star
25

CoinToss

First from-scratch Dapp (Gambling App)
JavaScript
1
star
26

local-rebel

An experimental algorithm to escape local minimas to attempt to discover global minimas
1
star
27

sol

1
star
28

LoyaltyNFT

1
star
29

http-server-rs

Rust
1
star
30

career-log

A digital log/diary of DeGatchi's career progress, publicly available for inspiration + accountability.
1
star
31

Flare-Token

Using an ERC-20 standard for the the token | ERC-777 snapshot additions w/ delegate vote power and get vote power of an address in a specific block.
Solidity
1
star
32

EasyBake-GrandOpening

Grand opening of https://github.com/EasybakeSwap
JavaScript
1
star