Marlin Protocol Introduced MEV support for Polygon

A lot has been written about miner-extractable value (MEV) so instead of reiterating the same information, let’s dive straight into the topic. Marlin protocol present below the case for the existence of MEV in chains other than Ethereum, describe the tools they are building to analyze (mev-inspect-*) and democratize (mev-*) such extraction opportunities and lay out future plans to integrate such capabilities in the decentralized Marlin network.

This article should interest validators in the Polygon network who would like to increase their income by including MEV bundles, dapp developers who would like their user’s transactions to be protected from frontrunning and MEV searchers who are interested in prioritizing their bundles.

MEV in Polygon, BSC & others

Flashbots’ explorations on Ethereum suggest that over USD 711m has been extracted since the start of 2020 in the form of arbitrage and liquidations. This figure is expected to be far lower than the real value as MEV is notoriously hard to detect and correctly categorize. However, the estimate is sufficient to conclude that the problem is large enough to deserve attention.

A corollary of this observation is that MEV in chains other than Ethereum is probably substantial as well. There are a number of anecdotal reasons to back such a hypothesis:

  1. DApps on EVM-compatible chains like Polygon and BSC are forks of those already deployed on Ethereum. Modifying MEV bots and smart contracts originally written to target Ethereum dapps to support these new chains is thus very easy.
  2. Polygon has a very low gas fee making the hit-and-trial method to backrun or sandwich transactions profitable. Such phenomena can be commonly observed in Polygon blocks where around 80% of the transactions in blocks interact with the same unverified contracts expected to be involved in MEV capture.

    For eg. Block 18760343 has 248 transactions where majority transactions interact with these contracts with similar bytecodes: 0xb80478b000BA07DA638C851B9A5536A587a63c62 (71 transactions) is similar to 0xdff0b65B3b40351eA2d2402bac3A51bA179d1a44 (52 transactions) and 0xfcC76D5aF07CaEace92897A67B08DAb766dF3De4 (65 transactions) is similar to 0xA4babFCa223606692F6803B45eD61A2Bf0FC1f52 (11 transactions).

  3. Thanks to their high throughput, these chains feature large TVLs and trading activity leading to proportionately high MEV opportunities. Similarly, NFT sniping or whitehat rescues are just as substantial.
Flashbots Discord
Source: Flashbots Discord

They’re not the first to make this observation. Nethermind recently launched an alpha version of its MEV plugin for the xDai chain. Our conversations with members of the Flashbots organization suggest that they would be eager to see the Flashbots spec deployed on other chains too.

Implementing the Flashbots spec on Polygon

They’re happy to open-source mev-bor, a fork of Polygon’s Bor client developed to process Flashbots bundles based on mev-geth. The beauty of a Flashbots bundle as opposed to sending a set of transactions is that the transactions in a bundle are executed in order atomically without requiring extensive gas price manipulation. Additionally, the spec guarantees that bundles which revert are not included in the block protecting against unnecessary gas usage.

To protect against bundles from being disclosed or sandwiched in the public mempool, Marlin will be running a private relay similar to Flashbots which will also be responsible for spam prevention and DoS protection.

A brief description of a bundle’s journey would be as follows:

  1. DApps or bots (MEV searchers) can send bundles to bor.txrelay.marlin.org. Bundles can pay validators through contract transfers to the coinbase address, a normal transaction to the validator or gas fee. A bundle’s format includes an additional header to identify the sender through its signature.
  2. The Marlin MEV relay is permissioned and will maintain reputation metrics of the different MEV searchers. This is done to prevent the relay from being DoS’ed and to prioritize searchers with a history of sending bundles accepted in blocks.
  3. The Marlin relay runs Bor nodes to simulate bundles to eliminate invalid ones and determine Polygon validators who would be producing the next block in upcoming slots. It then forwards bundles to appropriate validators depending on the block number mentioned in the bundle.
  4. Polygon validators run mev-bor. It spawns multiple worker threads which permute different combinations of bundles together with transactions in the public mempool to produce the most profitable block for the validator. The most profitable block could be one with no bundle produced by vanilla bor.
  5. The validator forwards the most profitable block after signing for attestation as usual.

Users, developers and validators interested in participating in the alpha release should register their interest by filling this form. Instructions for validators to install the gateway to enable communication between mev-bor and the Marlin relay can be found here.

Dissimilarities from Flashbots on Ethereum

Searchers having experience using Flashbots should note that unlike Proof-of-Work Ethereum, validators who would be producing the next block are known apriori on Polygon. This enables two new features:

  1. Searchers can pay validators directly through a normal transaction. This may not be as gas-efficient or secure against malicious validators but is still a point to keep in mind.
  2. Bundles are only sent to particular validators instead of multicasting to all, thus protecting the bundle’s privacy even further.

Analyzing MEV

It is fairly accepted that not all MEV is good for the ecosystem at large. It is thus important to know how much MEV is being extracted in a particular network and how. While the relay would be running health monitoring infrastructure to constantly evaluate the actions of validators and searchers alike, mev-inspect will be extended by our team to support Polygon. A few key features include:

  1. Adding support for Geth RPC APIs as both Python and Rust implementations of mev-inspect assume a Parity-like RPC API while an OpenEthereum/Erigon implementation for Bor is unavailable.
  2. Support for Polygon-based dapps

This work is still in early stages and will be open-sourced after some clean ups.

Future plans

mev-bor comes with the same trust assumptions as Flashbots on Ethereum. The design relies on Marlin developers running a centralized and permissioned relay which could hypothetically extract value from the bundles. This is not our intention of course.

Similarly, the bundles can be viewed by the validator producing the block. We expect validators to not engage in malpractices as it’s a comparatively smaller and well known set in PoS networks. Moreover, their long-term reputation is much more important to them in attracting delegations as compared to PoW miners. Nevertheless, differentiating such maliciousness from genuine transaction reorderings is tricky. Participants will be expected to hold on to the Fair Markets Principles otherwise risk being cut-off from the network.

Future work involves exploring ways to protect a bundle’s contents from validators whether through SGX or otherwise and decentralizing the relay – areas of interest to Flashbots core as well. An existing decentralized relay network certainly helps in this regard provided pre-trade privacy can be ensured. Simultaneously, we’re also in touch with the team at Fantom and expect to expand to other chains with such MEV opportunities.

📰 INFO 

https://blog.marlin.org/introducing-mev-support-for-polygon

Market Stats:
BTC Dominance: 57.65%(-0.59%/24h)
ETH Dominance: 12.45%(+0.26%/24h)
Defi Market Cap: $100.55B(-0.27%/24h)
Total Market Cap: $3379.18B(+2.03%/24h)
Total Trading Volume 24h: $204.85B(+1.93%/24h)
ETH Market Cap: $420.81B
Defi to ETH Ratio: 23.89%
Defi Dominance: 2.85%
Altcoin Market Cap: $1431.06B
Altcoin Volume 24h: $146.71B
Total Cryptocurrencies: 32411
Active Cryptocurrencies: 10197
Active Market Pairs: 91016
Active Exchanges: 761
Total Exchanges: 9623
BTC: 98434.26$(-0.13%/1H)
ETH: 3488.16$(-1.05%/1H)
AVAX: 45.64$(-0.75%/1H)
BNB: 666.54$(-0.15%/1H)
MATIC: 0.6$(1.27%/1H)
FTM: 0.95$(-0.23%/1H)
ADA: 1.06$(0.36%/1H)
DOT: 8.99$(-0.21%/1H)
UNI: 11.76$(-0.43%/1H)
CAKE: 2.87$(-1.78%/1H)
SUSHI: 1.16$(-0.63%/1H)
ONE: 0.02$(0.46%/1H)