This repo is for the Liquidity Sniping Bot on BSC. It has achieved some pretty good results, constantly being in the top three bots in the world (usually 1st or 2nd). Top 3 means that usually, we were placed +1/2/3 txs away from the Liqudity tx we were targeting.
Here is an example of sniping Token PepeV2, where the bot made a +70% profit.
We send multiple buy transactions to ensure the best possible propagation through the p2p network (multiple transactions from multiple servers; this was variable but usually around 10tx per 20ish servers).
What happened is that the server that caught liquidity the first was so fast that the fastest transactions accidentally front-ran the liquidity tx. So, while the actual buy was placed second, we were the fastest overall (first bot in the block): link. Note: the easiest way to spot the bots here is a bunch of failed txs.
The bot is like a super-light BSC/ETH node. It has fully implemented the DEVP2P layer and some parts of the ETH layer, but it doesn't store any blockchain state or has most of the features you would expect from a regular node.
The idea is that when sniping like this, you don't don't need access to the blockchain state. You need to catch the tx you are targeting with the lowest latency possible and send your buy txs with the lowest latency possible. The time scale is microseconds, e.g., if you are ~100 microseconds too slow, you are late, other bots will beat you, and chances for profit are much lower.
I usually ran ~ 20 servers on AWS, at least one server per region subnet. This is because you don't know (or at least I didn't) where TX will originate or where the next validator will be, so you must physically be as close as possible to most of your peers. From IP addresses, I reversed locations/server providers, and servers were spawned in the most popular locations and on the most popular server providers (at the time, it was AWS and Hetzner)
Since there was no need to sync blockchain or anything like that, I needed to run the servers only for sniping, vastly decreasing the cost of this whole operation. Also, this enabled me to run the thing on smaller instances, usually c7g.2xlarge
(I could've used the much cheaper instances to operate this, but I was having latency issues given that I was typically connected to ~500-1k peers, and you need to broadcast txs to all of them as quickly as possible).
The code quality is mostly meh; some parts are great, and some are bad, but importantly, it is really fast. I was working on this alone and was rushing to get it working ASAP. I haven't had time to pay attention to code quality/best practices, etc. Additionally, my blockchain knowledge at the time of writing this was 0.
- A small part (especially around RPLX, ECIES, and handling forks) was inspired by reth.
- open-fast RLP is copied from gakonst/open-fastrlp + optimizations and additions I needed.
- Of, some parts were inspired by OG geth
Note on "leaked" private keys, and auth stuff. All wallets are useless and all services disabled. I think ๐
This is what one gets when one is too lazy to use .env
๐คฆโโ๏ธ