Uniswap Sniper Bot  1.0
Uniswap Sniper Bot

project logo

Optimized, fast and unsafe Uniswap sniping bot for buying new listings.

Table of content

How does it work?

We use BloXroute's streams to listen to liquidity add transaction and call swapExactETHForTokens on Uniswap V2 Router 02 contract. By sending our transaction with the same gas price, we have a very high chance of being very close to the original transaction in the block, hence buying tokens just after liquidity add and just before the price significantly rises.

Pregeneration

pregen-diagram We pregenerate transactions with the most probable gas prices to send them instantly, hence skip signing process which is rather slow. This solution turned out to be around 2.5x faster on our testing machines.

Used libraries

Project structure

Directory structure

libs/ - contains all external libraries, see Used libraries
includes/ - contains all headers
tests/ - contains code testing
benchmarks/ - contains code benchmarking
doxygen/ - contains Doxygen configuration
img/ - contains images
libs.build/ - contains built libraries
build/ - contains built executables
docs/ - contains generated documentation

Headers

includes/utils.hpp - converters and other utilities
includes/rlp.hpp - Recursive Length Prefix Encoding used to serialize objects in Ethereum
includes/transaction.hpp - creating and signing Ethereum transactions
includes/bot.hpp - tools to parse BloXroute messages, build transaction data, etc.
includes/config.hpp - configuration file, see Configuration

Configuration

Configuration is saved in includes/config.hpp.

Installation guide

Installing required packages on Debian

sudo apt update
sudo apt install git make build-essential cmake autoconf libtool xsltproc libasio-dev
If you use macOS, you might have to manually link the OpenSSL
ln -s /usr/local/opt/openssl/lib/*.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/*.a /usr/local/lib/

Cloning repository

git clone --recurse-submodules -j8 https://github.com/sszczep/UniswapSniperBot.git
cd UniswapSniperBot

Building and running main executable

make main
./build/main

Building and running tests

make test
./build/test

Building and running benchmarks

make benchmark
./build/benchmark

Generating documentation

make docs
Documentation is available here.