Fruitful Labs Presents: Love Boat Exchange
Fruitful Labs presents its first product, Love Boat Exchange, a decentralized exchange (DEX) platform starting on the Polygon (formerly known as Matic) network!
Topics covered in this article:
- Centralized vs Decentralized Exchanges
- Liquidity Pools & Automated Market Makers
- Liquidity Mining Rewards Program
- Maximal Extractable Value vs High-frequency Trading
What exactly is a DEX? How does it differ from a centralized exchange (CEX) platform? What are automated market makers (AMMs) and liquidity pools? How do liquidity pools in AMMs differ from traditional market makers and orderbooks? Read more to find out!
Centralized vs. Decentralized Exchanges
In the world of traditional finance (TradFi), we have CEX platforms that allow individuals to trade amongst other individuals. Most likely you’ve heard of some of these CEXs, such as the New York Stock Exchange, Nasdaq, or Coinbase. These CEXs help facilitate trades between users with a piece of technology called an orderbook. An orderbook is simply a digital collection of buy and sell orders posted by individual traders. This system allows users to execute trades by matching buy orders with sell orders in real-time.
In the world of decentralized finance (DeFi), we have DEX platforms that allow individuals to trade their digital assets with other digital assets. If you’ve been in DeFi for some time, you most certainly have heard of some DEXs, such as the famous Uniswap, Sushiswap, and Quickswap AMMs. Unlike CEXs that rely on orderbooks and high-volume trading market makers, trades in DeFi rely on liquidity pools in AMMs.
Liquidity Pools & AMMs
Automated Market Makers (AMMs) are the game-changing technology that allow digital assets to be traded in a permissionless, trustless, decentralized, and autonomous fashion. This means that no individual, corporation, or company can control the buy/sell aspects of any trades. Trades are facilitated between users against liquidity pools instead of a peer-to-peer fashion via orderbooks.
Liquidity pools — aptly named — are pools of liquidity; a collection of digital assets, particularly ERC20 standard tokens (eg: DAI, USDC) that are stored in a smart contract hosted on the blockchain network. As long as the pool has enough liquidity, that is, a sufficient amount of desired tokens in the smart contract at a given moment, users can freely trade against the pool to sell their tokens for their newly desired tokens.
The major benefit of trading on AMMs is that users can automatically execute trades without permission. Trades that would typically be highly illiquid using orderbooks — due to a lack of buyers or sellers — can be constantly managed by algorithms using liquidity pools. Instead of buyers and sellers needing to agree on prices, the constant product formula (x * y = k) in AMMs will always provide accurate market pricings on any given ERC20 trades.
Liquidity Mining Rewards Program
Since the crux of an AMM heavily depends on the depths of its liquidity pools, it is ideal to have an incentivizing mechanism in place to reward liquidity providers (LPers). Since the boom of DeFi Summer 2020, liquidity mining has been the primary mechanism to reward LPers for — you guessed it — providing their liquidity! How exactly does this mechanism work and where do the rewards come from?
To enable exchanges in an AMM, there needs to be a sufficient amount of tokens in any given pool. Rewarding LPers for providing token pairs results in significantly deeper and more liquid pools. Let’s take a look at an example:
- Joe owns a large supply of both LOVE and USDC tokens.
- Joe wants to be a liquidity provider on the new Love Boat Exchange AMM.
- Joe takes his LOVE and USDC, pairs them on the DEX in a 50:50 ratio, and successfully provides both tokens to the LOVE/USDC liquidity pool.
- Joe receives LOVE/USDC Liquidity Provider (LP) tokens in proportion to the amount of LOVE/USDC he has provided.
- Joe takes his LOVE/USDC LP tokens and deposits them into the Love Boat Exchange’s liquidity mining program to earn a passive income.
- Sally wants to trade all of her USDC tokens for LOVE, but other DEXs’ LOVE/USDC liquidity pools aren’t deep enough for such a large trade.
- Sally decides to perform her trade on the Love Boat Exchange where the liquidity is deep enough.
- Sally trades her USDC for a proportional amount of LOVE tokens after incurring some transaction (txn) fees.
- As a large LOVE/USDC LPer, Joe is earning a significant proportion of trading fees in the form of $LOVE tokens.
- The trading fees come from the txn fees that traders — like Sally — incur when swapping their tokens on the DEX.
- Joe can view his accumulating $LOVE tokens on the Love Boat Exchange’s website and is free to claim his rewards at any time or day he pleases.
Maximal Extractable Value (MEV) & High-Frequency Trading (HFT)
The recent buzz in DeFi has been debates surrounding MEV and HFT.
What exactly are MEV and HFT? How do they compare and what do they entail?
- MEV (formerly referred to as “Miner” Extractable Value) is a measure of the profit that can be extracted away from the reorganizing, including, or censoring of txns within the blocks produced by miners.
- HFT is a type of trading using algorithmic trading bots to find arbitrage opportunities in the market and capitalize on them in a manner that relies heavily on the speed of txn execution (typically within fractions of a second).
What are “arbitrage opportunities”?
- Arbitrage opportunities (“arb opps”) occur when there are price discrepancies between underlying commodities or assets across multiple exchanges. These opportunities can become extremely profitable depending on the depth of the arbitrage.
For example, 1 ETH may simultaneously cost $2,400 on one DEX and $2,350 on another DEX, which creates an arb opp for traders to make a $50 profit.
How do arbitrage opportunities relate to MEV?
Imagine there is a $10,000 arb opp on a DEX after a huge trade causing massive price slippage. Arbitrage bots detect this opportunity and submit a txn with a gas fee of $10 to the miner in order to capture it.
What will likely occur is one of two scenarios:
- The miner notices the arbitrage opportunity and attempts to capture it themselves by copying and then censoring the arbitrager’s txn.
- Other arbitrage bots detect this opportunity and begin frontrunning other bots, resulting in a gas bidding war.
In this example, the MEV is the potential $10,000 profit.
MEV Extraction Techniques
What is frontrunning?
- Frontrunning is when txnA is submitted at a higher gas price than an already pending txnB so that txnA gets mined before txnB.
- Bob’s txn to sell 1,000 ETH for USDC on a DEX is pending.
- Sally’s frontrunning bot detects Bob’s huge ETH trade.
- Knowing that Bob’s trade will cause the price of ETH to go down, Sally’s bot submits a txn to sell ETH at a higher gas price to ensure it will be mined before Bob’s pending txn.
- Bob’s txn is mined after Sally’s and results in a significantly smaller return of USDC than he initially would’ve received.
What is backrunning?
- Backrunning is when txnA is submitted at a lower gas price than an already pending txnB so that txnA gets mined right after txnB in the same block.
- Bob’s txn to sell 1,000 ETH for USDC on a DEX is pending.
- Sally’s backrunning bot detects Bob’s huge ETH trade.
- Knowing that Bob’s trade will cause the price of ETH to go down, Sally’s bot submits a txn to buy ETH at a lower gas price to ensure it will be mined right after Bob’s pending txn.
- Sally’s txn is mined immediately after Bob’s.
What is a sandwich attack?
- Sandwich attacks occur when the target txn gets frontran and backran, thus extracting all possible value from that txn.
Example: Sally’s front/backrunning bots have successfully “sandwich attacked” Bob’s huge ETH trade txn.
Problems with MEV & HFT
While these txn reordering games may result in a potential profit to the privileged protocol actors (eg: miners, validators, sequencers), they lead to negative externalities which have major consequences to the blockchain networks and their users.
In our earlier examples, Bob’s order to sell his ETH has become artificially manipulated by Sally’s arbitrage bots which have essentially levied a tax on Bob for simply executing a trade. Meanwhile, Sally instantly nets a huge MEV profit.
Not only can this harm users, but it also harms the chains themselves. Networks and chains become highly congested, resulting in artificially inflated gas prices. MEV also presents systemic risks to Ethereum’s consensus-layer, resulting in infrastructure instability. Not addressing these major flaws only undermines Ethereum’s mission for a fully transparent, decentralized, and permissionless ecosystem.
What are flashbots? How do they relate to MEV? Let’s dive in!
The Flashbots organization is a research and development team that seeks to help mitigate negative externalities caused by MEV extraction techniques (ie: frontrunning) and aims to address the existential threat MEV poses to blockchains such as Ethereum.
Flashbots provide a way to communicate txns directly to the miners. This is done by sending the miners an array of txns (“bundles”) that are atomically included in the produced block. Miners will include the txns as long as it becomes profitable for them to do so.
As a flashbot operator, you gain the following advantages:
- Guaranteed txn execution; txns will only land on-chain as long as they are profitable for the operator.
- Never have to pay for reverted txns; this is great for arb opps that may only be available for a single block (only one person can claim).
- Completely private channels between the operators and miners; other members on the network will be incapable of snooping in on pending txns in the txn memory pool (mempool).
Due to these great advantages, operators become incentivized to send these txns directly to the miners (via flashbots) instead of sending them to the regular mempool, thereby allowing for risk-free txn executions while saving on gas fees.
Currently, there are (3) main use cases for flashbots that can be extrapolated to democratize MEV:
- Risk-free txn executions
- Privatized, MEV-protected txns for regular Ethereum users that participate in AMM trading and/or liquidations. (Eg: CowSwap Exchange; ArcherDAO)
- Decentralized applications (dApps) that aim to implement more advanced user experiences, such as:
- the ability to “bundle” multiple txns at once and have them atomically included in the produced block
- the ability to send txns from accounts with no ETH (gasless txns!)
Love Boat Exchange aims to democratize MEV for users of our protocol to protect them from txn reordering exploits. As a way to provide full transparency and information symmetry, we strive to become a truly democratic and decentralized ecosystem for all users, not just those with privileged information or skillsets.