“Every millisecond of latency is the difference between liquidating an asset and reading about it on tomorrow’s twitter feed”
Arbitrageurs are to DeFi what networking is to blockchains, crucial to their continued operation of the system but largely gone unnoticed. It’s no surprise that they are rewarded handsomely. Margins equal competition and if you are familiar with traditional finance, you know it means latency. In this post, we show you how low-latency communication enabled by OpenWeaver can help you make the most out of your DeFi trades.
Arbitrageurs on average have made anywhere between 100,000 USD to 500,000 USD a month with the last 4 months showing significant increases, with the highest ever being 6.82 million USD in October 2020. However, these figures do not give a complete picture due to two reasons:
(i) Some of these opportunities often exist for a period of only one block interval with several traders/bots competing for them. Since only one of them can capture the trade and miners sort transactions based on gas fees, only those transactions with the highest gas fee execute successfully. These trades thus incur gas costs which can be fairly substantial and are not subtracted from the figures above.
(ii) Dex arbitrage is not the only arbitrage opportunity available in DeFi. Proper functioning of collateral-based protocols like Compound and Maker require the collateral to be sold off if its value depreciates below a certain margin to prevent the system from being undercapitalized. Liquidators are incentivized to buy these collateralized assets by being offered a discount to their market price spurring gas wars. Liquidation profits (shown in the chart by Tom Schmidt below) made through the market sale of such discounted assets are not captured in the chart above. Note that these figures this time, substantial once again, account for the gas costs and thus represent profits and not just revenue.
An article by Richard Martin on Information Week once remarked, “(a) 1-millisecond advantage in trading applications can be worth $100 million a year to a major brokerage firm”. Optimizing on milliseconds has been so critical for brokerage firms that they colocate their trading systems on exchange floors and use specialized communication protocols like InfiniBand to improve their chances of winning the race.
Unfortunate for market makers in defi there is no single location where the orders are matched. Instead, they are spread across a number of miners producing blocks. As a result, they are required to source opportunities and disseminate their own trades to independently run nodes all across the globe. Not unlike traditional finance, arbitrage opportunities in defi are largely identified and exploited algorithmically. To operate efficiently, they rely on:
(i) Fast blockchain sync - Bots benefit by updating their local state as soon as possible in order to quickly identify and react to an arbitrage opportunity given block intervals are not constant.
(ii) Fast mempool sync - Bots can gain a distinct advantage through knowledge of recently broadcast transactions so as to identify competitors seeking the same arbitrage opportunity and outbid them in gas price if needed. In some cases, looking at the mempool might also inform the bot of opportunities it might not have identified itself or might even notify them of any expected changes in gas prices and congestion.
(iii) Fast transaction relay - Transactions should reach miners as fast as possible to maximize the chances of them getting included in the next block else their bid doesn’t even get to participate in the gas war.
Peer-to-peer propagation via gossip is suboptimal here as it was never designed for such cut-throat races. OpenWeaver can help arbitrageurs achieve the above with its low-latency block and transaction relay.
The superhighway that is OpenWeaver
OpenWeaver deployments consist of a network of globally distributed Ethereum nodes at the edge which constantly listen to messages directly sent to them or that are being gossipped through the P2P network as well. On receiving new messages (like a new block or transaction), they forward them to the other nodes in the OpenWeaver network directly in an optimized way which are then forwarded to subscribers/users from the closest edge node.
All an arbitrageur is required to do is to run a gateway which automatically connects to the closest OpenWeaver gateway. The gateway then transparently keeps the node updated with the latest blocks and transactions that have been generated. OpenWeavers deployers can charge users for such services.
In short, some DeFi application scenarios that could benefit from OpenWeaver include:
Arbing decentralized exchanges
Winning races during liquidations either as a liquidator or lender
Competing in gas wars
Some additional value-added services that such operators could provide users include:
Running machines and renting compute to run arb bots right next to mining pool gateways to speed up the back and forth of bids
Teaming up with mining pools and providing gas fee subscriptions to guarantee block space.
A little math
Assume OpenWeaver can send transactions time delta, d faster than an alternative like P2P gossip. This would imply that during any block interval there's a time window d during which if a transaction is sent, it's a make or break for the transaction sender. If the transaction's sent after the window, it won't make it to the block regardless and if it were sent before the window, the alternative would have sufficed.
We thus get ∫ f(x)/x dx from 1 to ∞ where f(x) = e^(-x/13)/(13*x) from the exponential distribution of block times with lambda = 1/13 to be 0.1587. Thus, ∫ d/x f(x) dx equals 0.04, 0.08, 0.12 and 0.16 for values of d equal to 0.25, 0.5, 0.75 and 1 respectively. This means that if propagation via OpenWeaver is 250 to 1000 milliseconds faster than gossip, transactions sent through OpenWeaver have a chances of benefiting 4 to 16% of the time. Given the assumptions are reasonable and observed frequently, the results obtained present an encouraging case for efficiency gains that can be obtained by DeFi traders.
Not a panacea
OpenWeaver doesn’t solve all issues! Bids that fail to be prioritized higher than its competitors in the transaction ordering set by miners still lose out on gas fees due to reverted transactions. There’s no stopping miners from frontrunning the most competitive bids (MEV). Moreover, the OpenWeaver operator itself could frontrun its users. An interesting proposal to solve some of these issues related to transaction ordering were put forward by Karl Floersch. While relay networks can do little about issues arising due to miner interference, security issues arising due to centralized operators of relay networks seem solvable (check our previous post - Are centralized relay networks a suitable L0 scaling solution?).