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

Overview

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.
You might also like...
ethers-rs scripting boilerplate

ethers-rs script boilerplate ethers-rs is a great blockchain scripting framework! This repo contains the essentials I find are useful when reading/wri

zink! is a library for developing ink! smart contracts with useful Rust macros that extend functionality and reduce boilerplate code.
zink! is a library for developing ink! smart contracts with useful Rust macros that extend functionality and reduce boilerplate code.

zink! Smart Contract Macros This is a helper library for developing ink! smart contracts. It contains useful Rust macros that extend functionality and

Metaplex is a protocol built on top of Solana that allows: Creating/Minting non-fungible tokens;
Metaplex is a protocol built on top of Solana that allows: Creating/Minting non-fungible tokens;

Metaplex is a protocol built on top of Solana that allows: Creating/Minting non-fungible tokens; Starting a variety of auctions for primary/secondary

An example smart contract that builds on top of xyz

xyz Guestbook Tutorial Contract This repository contains an example smart contract that illustrates how to build on top of the xyz NFT contract. This

As part of the IOP Stack™ Morpheus is a toolset to have gatekeeper-free identity management and verifiable claims as a 2nd layer on top of a blockchain

Internet of People Internet of People (IoP) is a software project creating a decentralized software stack that provides the building blocks and tools

A top-up of fatality based errors, originally developed for polkadot

fatality A generative approach to creating fatal and non-fatal errors. The generated source utilizes thiserror::Error derived attributes heavily, and

Baek-Zheng threshold cryptosystem on top of BLS12-381

bzte A rust implementation of the Baek-Zhang threshold cryptosystem on top of BLS12-381 using arkworks Why threshold encrypt? The advantage of thresho

Sample lightning node command-line app built on top of Ldk Node (similar to ldk-sample).

ldk-node-sample Sample lightning node command-line app built on top of Ldk Node (similar to ldk-sample ). Installation git clone https://github.com/op

A lightweight and flexible framework to build your tailored blockchain applications.

TRINCI Blockchain Core A lightweight and flexible framework to build your tailored blockchain applications. Requirements The required dependencies to

Comments
  • Next problem

    Next problem

    All work but after use command "cargo run --release" the following happens: ... Compiling ethabi v17.2.0 Compiling ethers-core v0.17.0 (https://github.com/gakonst/ethers-rs#454449b0) Compiling ethers-contract-abigen v0.17.0 (https://github.com/gakonst/ethers-rs#454449b0) Compiling ethers-providers v0.17.0 (https://github.com/gakonst/ethers-rs#454449b0) Compiling ethers-signers v0.17.0 (https://github.com/gakonst/ethers-rs#454449b0) Compiling ethers-etherscan v0.17.0 (https://github.com/gakonst/ethers-rs#454449b0) Compiling ethers-addressbook v0.17.0 (https://github.com/gakonst/ethers-rs#454449b0) Compiling ethers-solc v0.17.0 (https://github.com/gakonst/ethers-rs#454449b0) Compiling ethers-contract-derive v0.17.0 (https://github.com/gakonst/ethers-rs#454449b0) Compiling ethers-contract v0.17.0 (https://github.com/gakonst/ethers-rs#454449b0) Compiling ethers-middleware v0.17.0 (https://github.com/gakonst/ethers-rs#454449b0) Compiling ethers v0.17.0 (https://github.com/gakonst/ethers-rs#454449b0) Compiling mev-template v0.1.0 (/home/test/projects/mev-template-rs) Finished release [optimized] target(s) in 8m 30s Running target/release/mev-template Calling allPairsLength from 0x152e…1be3 ~ [PASS] Total pairs: 23461 test@-virtual-machine:~/projects/mev-template-rs$

    As far as I understand there should be monitoring - but there is not. I apologize for the stupid question - thanks to your programs I started to learn Rust and still do not fully understand the logic of the program. Do I need to specify any other parameters besides those specified in the env file?

    opened by yanrising 4
  • Error

    Error

    After command: cargo run I have error: Calling allPairsLength from 0x152e…1be3 ~ [FAIL] Total pairs: AbiError(DecodingError(InvalidName("please ensure the contract and method you're calling exist! failed to decode empty bytes. if you're using jsonrpc this is likely due to jsonrpc returning 0x in case contract or method don't exist")))

    Node - i use QuickNode

    opened by yanrising 2
Owner
DeGatchi
Building a decompiler | Rust + Solidity
DeGatchi
Open sourcing a profitable MEV Arbitrage Bot written in blazing fast Rust.

Dex Arbitrage - MEV Bot Open sourcing a profitable MEV Arbitrage Bot written in blazing fast Rust. Before Starting I am a self-taught programmer, a co

null 4 Sep 18, 2023
Bootstrap your merkle tree.

Merkle Generator Bootstrap your merkle tree, in Rust. Table of Contents Features Installation Usage Contributing Features Merkle Tree creation Merkle

DeGatchi 40 Feb 14, 2023
This is a solana lite rpc which optimizes sending transactions and confirming transactions strategies.

Solana Lite RPC This project aims to create a lite rpc server which is responsible only for sending and confirming the transactions. The lite-rpc serv

Blockworks Foundation 7 Dec 24, 2022
An MEV back-running template for ethers-rs

MEV price prediction I show how to predict ChainLink price updates from the mempool. For the sake of illustration I work with AAVE V2 price oracles. E

Andrea Simeoni 54 Apr 19, 2023
Rust client library for Flashbots MEV-Share

Flashbots MEV-Share Client   Rust client library for Flashbots MEV-Share. Based on the MEV-Share specs and the TypeScript reference implementation. Us

null 4 Aug 22, 2023
Mequeue is an executor for MEV bots optimized to be able to process multiple transactions concurrently.

Mequeue Mequeue is an executor for MEV bots optimized to be able to process multiple transactions concurrently. The main goal is to make this executor

null 13 Oct 3, 2023
Tool to retrieve mev-share events data and scan for refunds onchain

MEV-Share Analysis This repository can be used to retrieve historical events sent to mev-share and scan for any refunds that were sent to the users. T

Yash Atreya 7 Nov 30, 2023
Dione is an anonymize and encrypted messaging system build on top on a peer to peer layer.

Secure and Anonymous Messaging WARNING: Currently Dione is not ready to be used nor does it fulfill its goal of being an anonymous messenger. In order

Dione 41 Jan 5, 2023
Solana NFT marketplace boilerplate with anchor & react & candy-machine-cli

The Heros NFT Marketplace Boilerplate project is designed to let users fork, customize, and deploy their own nft marketplace app to a custom domain, ultra fast.

null 30 Dec 15, 2022
Solana NFT marketplace boilerplate with anchor & react & candy-machine-cli

Solana_Marketplace_HerosNFT The Heros NFT Marketplace Boilerplate project is designed to let users fork, customize, and deploy their own nft marketpla

null 30 Dec 15, 2022