How to use efficient Mempool service to profit in DeFi?
Editor's Note: This article comes fromCrypto Valley Live (ID: cryptovalley)Crypto Valley Live (ID: cryptovalley)
, author: Keeper DAO, translation: Olivia, reprinted by Odaily with authorization.
Traders analyze the Ethereum Mempool (memory pool), which can greatly increase the chance of profit
What is Mempool (memory pool)
A mempool is a set of Ethereum transactions that have been broadcast to the network and are waiting to be included in a block. The Mempool service can directly track the life cycle of transactions. When the transaction is broadcast to the node by the user, it will wait in the Mempool, and then the transaction will be packaged into a block or abandoned by the network. A good Mempool service will monitor for you every transaction that exists in the process. You can learn more about Mempool here.
How is Mempool used for DeFi transactions?
Traders analyze the Ethereum Mempool to dramatically increase the odds of acquiring MEV (miner extractable value). There are many different types of trading strategies that Mempool can apply. Some of these strategies involve finding trading opportunities where none would otherwise exist. As a result, the DeFi trading ecosystem has changed dramatically since these Mempool services entered the market.
Front running: Determine the Gas price required to win the Gas auction.
Back running: Based on another user's transaction results, predict transaction opportunities and package them into future blocks.
Sandwiching: Predicting trading opportunities, predicting future blocks by pushing another user's trading opportunities to the maximum slippage limit, which will lead to arbitrage opportunities at a later time (usually within the same block).
Generic predator: Hijacks the transaction call, hoping to run the Gas auction in the Front running, so as to obtain MEV (miner extractable value). This is usually done by replacing the original trader's address with the Predator's address, and submitting a new transaction with a higher gas price.
text
BloXroute
While the companies and products we discuss below offer a wide variety of products and services, our discussion this time focuses on their Ethereum Mempool functionality."secondary title"BloXroute is a Blockchain Accelerated Network (BDN) that utilizes a global network of servers to optimize network performance. They have invested a lot of resources in building the network infrastructure for Ethereum DeFi traders and builders. You can follow their development on their blog. Their Mempool function is called
text
Blocknative
BloXroute sends you Mempool events over a websocket connection. They are very fast and contain all the information, which means you can do transaction filtering in your terminal. So if you are following transactions on Uniswap, then you can simply filter based on the Uniswap addresses you are interested in."secondary title"Blocknative operates a global Mempool data platform that spans Bitcoin and Ethereum. They specialize in Mempool services for Ethereum DeFi traders and builders. You can read about their latest developments on their blog. Their Mempool function is called
text
Alchemy
Blocknative will specifically send you Mempool events via webhooks based on your watchlist, which is hosted on Blocknative's servers. So, if you are following transactions on Uniswap, you can simply add the Uniswap address to your watchlist and start receiving webhook events."alchemy_newFullPendingTransactions"text
, which can be found in their documentation.
Alchemy sends you Mempool events over a websocket connection, and these events contain all the information, which means you have to filter on your end. So if you're following trades on Uniswap, you can simply filter based on the Uniswap addresses you're interested in.
performance benchmark
We've used all three services extensively in DeFi transactions and seen huge differences in performance. Below is an overview of the performance test results and all data obtained, where performance is measured in milliseconds of latency. We hooked up all three services to our keeper bot and monitored Uniswap's router contract, as well as logging when each service reported incoming transactions. Once documented, this information is mapped and made available to the public.
Assume that the baseline of each transaction is the baseline when the first Mempool service discovers the transaction. So, the first service to discover a transaction will be positioned with zero latency, and each service after that will have a latency equal to the time difference between the time it discovered it and the first service.
The data in this graph paints a very clear picture. BloXroute's latency always runs on the zero line. Blocknative's latency is consistently slightly worse than BloXroute's. Alchemy is terrible, sometimes even a few seconds behind other services.
If we zoom in further, Blocknative is always about 175ms behind BloXroute. This makes a big difference if you are operating a large transaction with hundreds or thousands of trades per day.
BloXroute was the first to detect 228 transactions out of 235.
Why is it important to have the fastest Mempool service?
The above experimental results show that a trader's choice of Mempool service directly affects their profitability. According to data from ethstats.net, the average Ethereum block time is now just over 13 seconds. Being 180ms behind, or worse, 1000+ms, will cut into your transaction profits significantly, reducing the chances of your transaction being included in the next block. Also lag will reduce your reaction time in gas auctions.
Comparison of Websockets and Webhooks
It is worth comparing the two methods of event delivery used by these Mempool services. Technically, Websockets should be faster, however it may be slightly less reliable. With a Websocket connection, it is possible for the client to miss an event when it disconnects. When using Webhooks to connect, each Mempool event you receive has its own network connection, which pushes events for each Mempool event. This may add a small amount of latency overhead, but also adds some reliability. It is worth mentioning that traders may prefer lower latency, while DeFi product builders may prefer relatively reliable.
Best performance and redundancy solution
If you are a trader and want the best of both worlds in terms of performance and reliability, here are some redundancy solutions that might work for you.
Solution A) Use the fastest service, BloXroute, and connect to multiple gateways. You can run your own BDN gateway on your own server, or connect to multiple hosted gateways. You can also specify that these gateways are spread across different regions, so that if there is a problem with the network in one region, you don't completely lose access to Mempool for a period of time.
Solution B) Use multiple Mempool services. This way you get data as fast as possible, and if one service goes down for any reason, you have another service to fall back on. The only downside here is that it multiplies your Mempool service fee.
price comparison
All price comparisons are based on 2020-12-4. Note that the feature list and pricing structure for each service is subject to change at any time.
Compared to other services, BloXroute's pricing is very generous. The $240 Pro version is great value, considering you get the best performing Mempool service with zero rate limits, and a ton of other useful features.
Blocknative's pricing is hard to compare to BloXroute's for a few reasons: First, they only offer the Mempool service, so you don't get any extras like BloXroute. Second, they impose a daily API event limit, which may not seem like a problem at first glance, but is actually a huge limit. Let's see how this plays out with the information in the benchmark above.
Assuming you are a DeFi trader and you are utilizing Back running, you will want to monitor all Mempool transactions incoming to Uniswap. Actually, you're going to want to do this on a huge number of protocols, a lot more than just Uniswap. But let's keep it simple and focus on a single Uniswap router used above. In the data for the benchmark, let's focus on the first and last data entry so we can get an approximate transaction volume per day for comparison with Blocknative's API event limit per day.
The test starts with this first transaction and ends with this last transaction. That is, from block 11381311 to block 11381328, the time span is about 4 minutes. During this time, we evaluated 235 transactions. About one transaction per second, since there are 86400 seconds in a day, that means about 86400 transactions per day. This is roughly 8x the rate limit of Blocknative's production plan. That pushes you to the Growth plan, which is $833 per month. But this is problematic, because if Uniswap becomes more popular, you will be rate limited and forced to jump to the $8300 per month Leader plan (Leader). This can get expensive very quickly.
Alchemy's pricing is generally very flexible. However, Mempool specific pricing is not friendly to your rate limit performance. If you want to track transactions, which requires you to monitor all incoming transactions to Uniswap, you will eat up your rate limit in a very short time. Alchemy even mentions this in their documentation.
The alchemy_newFullPendingTransactions subscription type is super expensive to maintain and requires a lot of computing units because it emits full transaction information, not just transaction hashes. We do not recommend that non-enterprise tier users keep this subscription type open for a long time.
Using these services vs running your own node
In general, it is not difficult to run and maintain your own node, especially if you are simply using it to make Ethereum calls. Mempool, however, operates in a different way. In the early days of Mempool transactions, traders will obtain Mempool information from their own nodes. This is where the competition is fierce. Whoever has a better Mempool infrastructure will have a slight advantage over others in every transaction opportunity. And when you multiply that small advantage by hundreds of daily trading opportunities, it creates a huge advantage.
Cost is also an important factor. You have to factor in the cost of running your own nodes on servers all over the world. Also take into account the cost of your time developing a system capable of routing all of these transactions from your network of nodes to your trading bots.
in conclusion
secondary title


