How I Reverse Engineer Sandwich bots Profitably With AI
I discovered a sandwich bot in bittensor making thousands a day and it’s fascinating because it’s something I’ve never seen before, a bot that seems to be doing the impossible
We’re talking about ordering transactions in the mempool without having direct contact to the validators, he doesn’t use flashbots because it’s not accepted there
In this article you’ll learn the steps I took to decode and reverse engineer one of the most fascinating (and profitable) bots in crypto and how you can do the same
Let’s dive in:
Using AI to win
Without AI you’ll waste hours and hours circling the same problem like a shark, never biting the target and getting to the meat of the money
Now claude got so good that it can tell you in detail how the bytecode works and reverse engineer the smart contracts without the source code, just the bytecode
What I did to start the reverse engineering process and discover how the sandwich bot works is the following:
- I prepared 10 frontruns, backruns and victim transactions to give it to claude
- Then I told it what the bot was doing from my observations in vivid detail like so:
“The bot is frontrunning transactions even though you can’t increase your transaction fee to position yourself earlier in the block.
The bot is always first in the block. The bot sandwiches a target 99% of the time being profitable with a few small loses.
The bot uses a rounded buying amount increaing in multiples of 5. The calldata is always the exact same in the frontrun transaction and the backrun indicates the subnet to sell.
The bot enters every single block yet 90% of the time he doesn’t buy anything.”
3. I then prompted claude with the exact outputs I want. This step is important otherwise it won’t give you the exact understanding you need to decode it and recreate it:
“I want you to give me a brief explanation on how the bot is able to position himself first in the block when you can’t use higher transaction fees to be early in the block.
I want you then to access the bytecode of the bot at this <address> and detect the frontrunning transaction and reverse engineer it by parsing it and decoding the bytecode into hex and opcodes for easier understanding.
I want you to fully recreate the frontrun transaction to know how he determines when to buy and when to stay away.”
I simply waited for the analysis to complete and I checked the output to determine what was going on
That allowed me to understand the following:
- How the bot is able to buy first when it’s impossible to gain priority with higher fees
- How the bot executes frontruns with the same calldata
- When the bot decides to buy and when to stay in place
- Why the bot enters every single block
- How the bot is able to predict that a user is about to buy a specific subnet
Now I’m not gonna give you the exact results because I’m still figuring it out and don’t want to ruin the opportunity by giving you the exact playbook
But suffice to say, I now fully understand how the bot works and am able to replicate it successfully and even improve it to outcompete the active bot
I could’ve decoded the bytecode myself with parsing tools that convert it into opcodes which is one step below the actual code and make it so I understand
In short: you must observe what the bot is doing and using your own understanding of sandwich bots and by being able to read the mempool and explorers you must declare in precise terms what you observe to decode it
With good clear observations, you will be able to reverse engineer it fully
Let me know if this guide helped you and follow me for more good content while joining my group t.me/mevdao
