How to leverage Blocknative to test and refine mempool strategies
As part of this Flashbots has created tools for searchers to bid on specific orders of transactions that they want to be included by miners. Blocknative’s mempool monitoring tools are a great companion to this by providing searchers with deep insights into the current state of Ethereum’s mempool.
Because MEV tools like Flashbots extract MEV by including, excluding, and reordering the sequence of transactions in a block, Blocknative’s mempool monitoring tools can provide searchers with deep insights into the current state of Ethereum’s mempool.
In this post, we will answer common questions about how to use Blocknative’s mempool monitoring tools with Flashbots, and update this post with additional questions as they arise.
How does Mempool Explorer monitor the Ethereum mempool?
The four primary ways our mempool platform monitors the entire Ethereum mempool include (i) operating a global network of nodes, (ii) running nodes in a variety of configurations, (iii) maintaining unique peering relationships, and (iv) running custom node telemetry extensions.
1. A Global Network of Ethereum Nodes
We have a deep penetration into the Ethereum peer-to-peer network to ensure we see nearly 100% of pending transactions. We operate a global network of nodes that supports all Ethereum Testnets and Mainnet using both Geth and Parity clients.
2. Multiple Ethereum Node Configurations
We run our nodes in a variety of configurations, meaning some of our nodes operate in a more narrow sense, like mining pools, while other nodes cast a wider net typical of block explorers.
3. Unique Node Peering Configurations
We optimize our network of nodes to maintain unique peering relationships that avoid peering with each other, giving our platform as wide of a view of the Ethereum mempool as possible.
4. Custom Node Telemetry Extensions
We develop custom node telemetry extensions to reveal the inner workings of the peer-to-peer network and the mempool itself, allowing our mempool monitoring tools to deliver unmatched resolution on every in-flight transaction.
How can searchers use advanced mempool filtering systems to test MEV triggers and searcher strategies?
MEV searchers can use Mempool Explorer to filter, compose, and integrate pending transaction data into your searcher bots, and you can filter on everything in the JSON payload, meaning you can get a fine-tuned view of the mempool to fit your needs.
What are some examples of MEV triggers that can be built in mempool explorer?
Here are a few MEV triggers that can be configured in Blocknative’s Mempool Explorer tool to improve your searcher strategies using Flashbots.
1. Monitor ETH Liquidity in Uniswap V2
Do you only care about add Liquidity ETH events on the Uniswap V2 router with a value over 1 ETH?
You can do that!
2. Get Oracle Asset Pricing Updates on Badger
Interested in Oracle asset-pricing updates on a protocol like Badger?
Yep, you can do that too!
3. Monitor Aave Flashloans
How about monitoring all Aave Flashloans?
Authoring your searcher strategy in Mempool Explorer is only a few clicks away. We automatically decode the most popular ABIs (Application Binary Interfaces) out of the box, but you can easily add any publicly available smart contract ABI and start filtering on it.
How to use JSON Payloads for Type-0 and Type-2 Transactions
Our mempool platform payload automatically includes the V, R, and S — as well as the other necessary components required to RLP encode the transaction data into a signed transaction hash, enhancing and extending the data you typically receive from running your own node. This hash can then be included inside a Flashbots bundle.
When somebody broadcasts a signed transaction to the mempool, they reveal their V, R, and S signature data where R and S are the ECDSA signature integers that make up the backbone cryptography used in Ethereum. While understanding the cryptography is not necessary, you can now successfully construct a signed transaction hash using Blocknative’s payload.
RLP Encode Data Required for Type-0 Ethereum Transactions
For legacy transactions (type-0) to correctly RLP encode the transaction data you need:
- Gas price
- Gas limit
- To address
Note: R,S are the output of the ECDSA signature process.
RLP Encode Data Required for Type-2 Ethereum Transactions
For new EIP-1559 transactions (type-2) to correctly RLP encode the transaction data you need:
- Chain ID
- Max Priority Fee Per Gas
- Max Fee Per Gas
- Gas limit
- To address
- Access List
Every payload you receive includes these key-value pairs and more. Additionally, you can copy and paste the JSON payload into a JSON file and start testing right away.
Type-0 Transaction Payload
Type-2 Transaction Payload
Using Blocknative to Keep Track of Pending Transactions
Now that you are up to speed with pending transactions and why you need them for some searcher opportunities with Flashbots, let’s walk through how to set up Blocknative’s mempool API to deliver real-time notifications of pending transactions you can include in your bundle.
1. Author Your Searcher Strategy in Mempool Explorer
If you want to monitor pending transactions on Uniswap V2 Router for the method name addLiquidityETH, you can set up a filter to receive notifications for these events using Mempool Explorer’s advanced filtering system that filters based on everything in the payload, including any publicly available ABIs. We also automatically decode some of the most popular ABI’s right out of the box.
User view of the addLiquidityETH filter in Blocknative’s Mempool Explorer.
2. Integrate Your Strategy with Websockets or Webhooks
Now that you have your MEV strategy set up and saved in Mempool Explorer, you can integrate your configuration using websockets or webhooks.
For example, you can download the configuration.json and sdk-setup.js files directly from Mempool Explorer by clicking on the hamburger menu, followed by clicking on the three dots to the right of the save configuration.
Once you export the configuration, drop those two files into your project and import them:
Once imported, you should see your specific strategies’ transactions logged to the console.
3. Use the Payload to Construct a Signed Signature Hash
Note, the order of parameters is important and must follow EIP 155. Below are two examples: one for the implementation for legacy transactions and another for Type-2 transactions.
Example implementation for EIP-155 legacy transactions.
Example implementation for EIP-1559 Type-2 transactions.
Congratulations! Now you have usable signed transaction hashes to include in your bundle!
How to Use Blocknative’s Internal Transaction Monitoring Tools for Advanced MEV Strategies
In addition to pending transactions, Blocknative also provides pending simulation transactions, smart contract transactions that contain internal transactions, through our Ethereum Simulation Platform.
Simulation Platform simulates all pending transactions in the Ethereum mempool with a marketable gas price in isolation against the current block state to give users the ability to see smart contract internal transactions before they happen on-chain.
With Simulation Platform, you can:
- Understand impacts to liquidity pools on a more granular level
- Monitor a specific bot’s activity and see their internal transaction function calls
- Watch for collateral liquidations
- See certain protocol’s vault activities
Advanced MEV Strategy Example Using Internal Transaction Monitoring
A specific MEV example could be that you watch all Aave Flashloan function calls to see inside the smart contract and react accordingly.
Our payload includes all of the internal transactions (i.e. the functions being called) from the smart contract, and everything inside the internal transaction is filterable like the rest of the payload.
Pending-simulation transactions also calculate the net balance changes for each associated address in the internal transactions so you don’t have to.
Excerpt of the net balance changes of the above Aave Flashloan example.
All pending-simulation transactions can be included in bundles in the same manner as regular pending transactions. Pending-simulation transactions are probabilistic and based on the simulated result of the current block state. If something changes in the mempool (e.g. other transactions you are going to add to your bundle) that could impact the internal transactions.
Stay tuned for new features to our Ethereum Simulation Platform, like simulating unsigned transactions and simulating entire Flashbots bundles against the current block state.
Act on DeFi Trading Opportunities Easier
Being a profitable DeFi trader or MEV searcher is hard work; finding new trading and arbitrage opportunities is a constant competition against bots.
Because finding opportunities and writing high-quality code to act on them is difficult, we are dedicated to making integrating mempool data the easiest part of the process.
Go hands-on with Mempool Explorer right now, or learn more with our Mempool Explorer documentation. And don't forget that we have web3's most accurate ETH gas fee tracker. Visit our YouTube channel for helpful tutorials, and if you’d like to continue the discussion, come join our Discord community or follow us on Twitter.
A special thank you to Robert Miller, Steward at Flashbots, for reviewing this post.
Master the Mempool today.
Blocknative's proven & powerful enterprise-grade infrastructure makes it easy for builders and traders to work with mempool data.Start for free