DEV Community

Cover image for Introduction to MEV on Starknet
LordGhostX
LordGhostX

Posted on

Introduction to MEV on Starknet

Maximal extractable value (MEV) refers to the maximum value that can be extracted from block production more than the standard block reward and gas fees by including, excluding, and changing the order of transactions in a block.

MEV has become more popular since Ethereum transitioned to Proof-of-Stake (PoS). The rise of Layer 2's like Starknet introduced new dynamics to the MEV landscape. Understanding MEV within these ecosystems is important in comprehending the implications of on-chain competition and its effects on network stability and user experience.

MEV on Ethereum

MEV in the Ethereum ecosystem presents a complex duality with beneficial and potentially detrimental impacts on the network.

Inefficiency and unfairness:

  • MEV can lead to network congestion and higher gas fees.
  • It may create an uneven playing field, favoring well-resourced and technically sophisticated actors.

Innovation and security incentives:

  • MEV drives advancements in transaction execution mechanisms.
  • It offers additional incentives to enhance network security and reliability.

Market health:

  • MEV helps with pricing consistency across protocols. Active MEV ensures that prices remain the same across different platforms, reducing the risk of bad debt on lending positions.
  • While some MEV practices can be harmful, useful MEV, such as arbitrage, helps maintain healthy markets by improving liquidity and price discovery.

MEV extraction strategies

There are multiple strategies to extract value from block production:

  • Front-running: Placing a transaction ahead of a known future transaction. For example, if a large trade is detected in the mempool, a front-runner might place a buy order just before it, then sell immediately after, profiting from the price impact.
  • Back-running: Positioning a transaction immediately after a target transaction. This can be used to capitalize on state changes caused by the target transaction, such as taking advantage of a newly created arbitrage opportunity.
  • Sandwich attacks: Combining front-running and back-running to profit from price movements. A sandwicher places a buy order before a large swap, then a sell order immediately after, profiting from the temporary price impact.
  • Liquidations: Liquidating under-collateralized positions to earn fees or acquire discounted collateral. Bots monitor lending protocols for positions close to liquidation thresholds and quickly execute liquidation transactions when conditions are met.

MEV infrastructure and tooling

The MEV ecosystem has developed various tools and platforms to manage and optimize MEV extraction. These solutions seek to balance the benefits of MEV while minimizing its negative impacts:

  • Flashbots: A research and development organization dedicated to addressing the challenges and opportunities of MEV in the Ethereum ecosystem.
  • Eden Network: A transaction ordering protocol designed to democratize MEV extraction and protect users from malicious MEV practices.
  • Manifold Finance: A platform focusing on gas cost optimization and MEV protection for DeFi users, enhancing the overall efficiency and security of transactions.
  • MEV-Boost: An implementation of Proposer-Builder Separation (PBS) for Ethereum validators. It allows them to access a competitive block-building market and earn a fair share of the MEV extracted in the blocks they propose.

Searchers, solvers, and builders

The MEV ecosystem on Ethereum involves several key participants:

  • Searchers: Participants who identify and exploit MEV opportunities using various strategies.
  • Solvers: Participants that optimize and execute MEV strategies. They work closely with searchers to refine extraction processes, ensuring maximum efficiency and profitability.
  • Builders: Participants responsible for constructing bundles of transactions submitted to the network. They collaborate with searchers and solvers to assemble transactions in a way that maximizes extracted value.

Trading bots (searchers)

Most MEV strategies are executed by automated trading bots that identify and exploit opportunities in real-time:

  • Arbitrage bots: Monitor token prices across exchanges and protocols, executing trades to profit from differences and help ensure uniform prices.
  • Front-running bots: Place buy orders before executing trades to capitalize on price movements.
  • Back-running bots: Identify opportunities after specific transactions and quickly execute follow-ups to extract value.
  • Sandwich bots: Implement sandwich attacks by placing orders before and after large trades to profit from price impacts.
  • Liquidation bots: Monitor lending protocols for positions near liquidation thresholds, quickly executing liquidation transactions when conditions are met.

Many of these trading bots are integrated within various MEV infrastructure platforms, aiming to reduce the risks of manipulative tactics.

MEV on Starknet

Starknet is an Ethereum Layer 2 (L2) designed to deliver high transaction throughput and low costs while maintaining Ethereum's core principles.

Starknet Network Architecture

Starknet operates as a Zero-Knowledge Rollup (ZK-Rollup), using a STARK proof to bundle transactions off-chain before submitting a single proof to the Ethereum mainnet. MEV on L2's like Starknet differs from L1 due to increased throughput, reduced transaction costs, First-Come-First-Serve (FCFS) model, account abstraction, and censorship resistance. Here's how:

  • Higher TPS: L2's process more transactions simultaneously, reducing MEV opportunities and lowering the profitability of front-running.
  • Lower transaction fees: Reduced fees decrease the incentives for MEV extraction.
  • First-Come-First-Serve (FCFS) model: The Starknet sequencer processes transactions as they are received, eliminating the need for transaction reordering and mempool monitoring.
  • Account abstraction: Starknet's native account abstraction allows anyone to handle transactions, minimizing exposure to MEV.
  • Censorship resistance: Starknet's design prevents entities from monopolizing MEV extraction, ensuring a fairer ecosystem.

However, MEV opportunities still exist on Starknet. The interaction between L1 and L2 creates complex transaction flows that are "MEV-exploitable", allowing searchers to capitalize on information and timing differences between these layers for profit.

Profitable MEV strategies on L2s

Due to the L2 design, MEV strategies that rely on gas fee manipulation are less effective. However, searchers are still exploring profitable strategies. Here are some notable ones:

Atomic arbitrage

Atomic arbitrage involves profiting from price differences across exchanges and protocols (such as Ekubo and Nostra). The lower transaction fees and high TPS on L2s like Starknet make it easier and faster for bots to execute these arbitrage strategies efficiently. For a practical guide on creating an atomic arbitrage bot, check out Maksim's blog and Matteo's blog.

Liquidations

MEV bots can profit from liquidations on lending protocols when collateral values drop below certain thresholds. When this happens, bots can quickly act to liquidate these positions for profit. For a practical guide on building a liquidation bot, check out Kristan's blog on ZKLend.

Statistical arbitrage

This strategy uses statistical models to predict price movements and identify profitable trading opportunities. While it can be riskier, the high throughput and low transaction costs on L2s make it easier to execute effectively.

Cross-layer sandwich attacks

Cross-layer sandwich attacks involve monitoring interactions between L1 and L2 to place transactions that manipulate prices. Searchers can observe pending transactions on L1 and strategically place transactions on L2 to influence prices in their favor.

All these strategies are possible on Ethereum and its L2s. However, many L2s are exploring MEV auctions and decentralized sequencers to mitigate MEV risks for end users.

Starknet ecosystem strategies and MEV mitigation

Starknet actively employs strategies to create a fair ecosystem and mitigate MEV on the mainnet. The community is engaged in healthy discussions and multiple initiatives focused on addressing MEV on Starknet.

Starknet is improving TPS and performance by implementing parallel transactions, resulting in lower fees, reduced congestion, and fairer transactions.

The community is also developing tools and engaging in conversations to address MEV's impact. Here are some notable ones:

Looking ahead, the future of L2s is promising, with the potential implementation of decentralized sequencers to decentralize the network and MEV auctions to reduce MEV risks.

Conclusion

I hope this article has introduced you to the world of MEV on Ethereum and Starknet. You should now be able to compare the MEV dynamics between these layers and better understand how MEV works on Starknet.

If you want to discuss MEV on Starknet or have valuable insights to share, join our MEV discussion group.

This piece is part of a series exploring MEV on Starknet, so stay tuned for more insights and discussions in the upcoming articles.

Top comments (0)