How to Use Blocknative to Leverage MEV Strategies & Get Bundles On-Chain

Blocknative Ethereum Web3

January 2023 Update: If you are an MEV searcher, Blocknative now offers an MEV bundle RPC endpoint. Searchers can interact with the RPC endpoint at https://api.blocknative.com/v1/auction. The API provides JSON-RPC methods for interfacing with Blocknative builders, which are documented via our bundle docs.

MEV Searchers:

How to leverage Blocknative to test and refine mempool strategies

In 2020-2021 when Ethereum was a Proof-of-Work (PoW) chain, Flashbots launched as a research and development organization to mitigate the negative externalities of maximal (formerly miner) extractable value (MEV).

Flashbots created tools, namely bundles (explained here), allowing searchers to bid on specific orders of transactions that they want to be included by miners, now validators. Fast-forward to Ethereum post-Merge and we now have a brand new ecosystem of block builders (like Blocknative), relays, and searchers centered around MEV-Boost. Builders compete for searcher's bundles and here at Blocknative, we provide all the tooling you need to get started as a searcher.

In this post, we will answer common questions about how to use Blocknative’s mempool monitoring tools to submit bundles to builders like Blocknative 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.

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!

Utilizing Blocknative to monitor the Uniswap ETH liquidity


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!

Utilzing mempool data to get real time oracle asset pricing.



3. Monitor Aave Flashloans

How about monitoring all Aave Flashloans?

You bet!

Utilizing the mempool to monitor 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 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:

  • Nonce
  • Gas price
  • Gas limit
  • To address
  • Value
  • Data
  • V
  • R
  • S

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
  • Nonce
  • Max Priority Fee Per Gas
  • Max Fee Per Gas
  • Gas limit
  • To address
  • Value
  • Data
  • Access List
  • V
  • R
  • S


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 example using Blocknative's mempool.

Type-0 Transaction Payload

 

Type 2 transaction example using Blocknative's mempool.
Type-2 Transaction Payload

Check out our example repos in Python or Golang to see how to work with the Blocknative mempool API to build your bundles. Or see our Javascript implementation below.

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, 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.

 

Utilizing the Blocknative mempool addliquidityETH filter.

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.

 

How to add websockets or webhooks in Blocknative.

Once you export the configuration, drop those two files into your project and import them:

Script for importing configuration.json files and sdkSetup.js files from Mempool Explorer.

 

Once imported, you should see your specific strategies’ transactions logged to the console.


3. Use the Payload to Construct a Signed Signature Hash

The final step is to take the transaction JSON payload and grab the necessary components to construct the signed signature hash. In Javascript, you can install the rlp module and use the encode method with the correct parameters. Or you can use a library like ethers.js and their built-in serialize functionality.

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.

 

View of what EIP-1559 legacy transaction data looks like in Blocknative's Mempool Explorer.

Example implementation for EIP-155 legacy transactions.


View of what EIP-1559 type-2 transaction data looks like in Blocknative's Mempool Explorer.

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.

Internal transaction monitoring utilizing Aave flashlon function calls.


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.

 

Insight into Aave Flashloans in the Mempool Explorer tool.

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 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. 

Observe Ethereum

Blocknative's proven & powerful enterprise-grade infrastructure makes it easy for builders and traders to work with mempool data.

Visit ethernow.xyz

Want to keep reading?

Good choice! We have more articles.

ethernow-transaction-explorer-now-supports-the-sepolia-testnet
Ethereum

Ethernow Transaction Explorer Now Supports the Sepolia Testnet

Introducing the Ethernow Sepolia Testnet Transaction Explorer The Ethernow Transaction Explorer has..

blobsplaining-part-2:-lessons-from-the-first-eip-4844-congestion-event
Gas

Blobsplaining Part 2: Lessons From The First EIP-4844 Congestion Event

We recently witnessed the first network congestion event post-Dencun with the blobscription craze,..

announcing-degen-support-in-web3-onboard
Web3 Onboard

Announcing Degen Support in Web3 Onboard

Exciting news for the Degen community! We are thrilled to announce that Web3 Onboard has enabled..

Connect with us. Build with us.

We love to connect with teams who are building with Blocknative. Tell us about your team and what you would like to learn.

"After first building our own infrastructure, we appreciate that mempool management is a difficult, expensive problem to solve at scale. That's why we partner with Blocknative to power the transaction notifications in our next-generation wallet."

Schedule a demo