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.
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.
- zaphoyd/websocketpp
- bitcoin-core/secp256k1
- XKCP/XKCP
- google/googletest
- google/benchmark
- doxygen/doxygen
- kcwongjoe/doxygen_theme_flat_design
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
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 is saved in includes/config.hpp
.
Config
Config::Transaction
- transaction fieldsConfig::Transaction::Nonce
- transaction nonce (hexadecimal)Config::Transaction::Value
- transaction value (hexadecimal, wei)Config::Transaction::To
- receiver of the transaction, mostly Uniswap V2 Router 02 (address)Config::Transaction::GasLimit
- transaction gas limit (hexadecimal)Config::Transaction::PrivateKey
- private key of sending wallet
Config::Transaction::SwapExactETHForTokens
- values to construct transaction data to call SwapExactETHForTokens methodConfig::Transaction::SwapExactETHForTokens::AmountOutMin
- minimum amount of tokens to receive from the swap (hexadecimal)Config::Transaction::SwapExactETHForTokens::TokenAddress
- token's address we want to buy (address)Config::Transaction::SwapExactETHForTokens::ReceiverAddress
- address of receiving wallet (address)
Config::BloXroute
Config::BloXroute::Connection
- BloXroute Cloud API connection credentialsConfig::BloXroute::Connection::Address
- address of the serverConfig::BloXroute::Connection::AuthToken
- authorization token
Config::BloXroute::Filters
- newTxs stream filtersConfig::BloXroute::Filters::MaxGasPrice
- maximum gas price of the transaction (we do not want to lose millions on gas, do we?) (decimal, wei)Config::BloXroute::Filters::MinValue
- minimum transaction value, skips fake liquidity adds or tokens with small liquidity (decimal, wei)Config::BloXroute::Filters::TokenAddress
- alias forConfig::SwapExactETHForTokens::TokenAddress
, left for consistency (do not change!)
Config::TransactionPreGen
- configuration for transaction pregeneration, for further explanation see PregenerationConfig::TransactionPreGen::GasPriceGweiFrom
- from gweiConfig::TransactionPreGen::GasPriceGweiTo
- to gweiConfig::TransactionPreGen::GasPriceGweiDecimals
- gwei decimals (eg. 1000 means generating transactions with gas price steps of 0.001 gwei)Config::TransactionPreGen::ArraySize
- precalculated based on above values (do not change!)
- Config::Size
Config::Size::TransactionQuantityBuffer
- size of transaction quantity buffer (do not change!)Config::Size::TransactionAddressBuffer
- size of transaction address buffer (do not change!)Config::Size::TransactionDataBuffer
- size of transaction data buffer, change when necessary (eg. when calling different method requiring more arguments)Config::Size::TransactionRawBuffer
- size of raw signed transaction, change when necessary (see above)Config::Size::BloXrouteTransactionMessageString
- size of both incoming and outcoming messages to the Cloud API
sudo apt update
sudo apt install git make build-essential cmake autoconf libtool xsltproc libasio-dev
ln -s /usr/local/opt/openssl/lib/*.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/*.a /usr/local/lib/
git clone --recurse-submodules -j8 https://github.com/sszczep/UniswapSniperBot.git
cd UniswapSniperBot
make main
./build/main
make test
./build/test
make benchmark
./build/benchmark
make docs