Sirwin
Sirwin

Truly Understanding Ethereum's Zk-Rollup Loopring and Its Novel DEX

By Michael @ CryptoEQ | CryptoEQ | 18 Jan 2023


You are reading an excerpt from our free but shortened abridged report! While still packed with incredible research and data, for just $20/month you can upgrade to our FULL library of 50+ reports (including this one) and complete industry-leading analysis on the top crypto assets. 

f335db6f2e4517432f34c0844de36a5d54528d4db563ba6c0ba03f49c1a7e6a0.png

Becoming a Premium member means enjoying all the perks of a Basic membership PLUS:

  • Full-length CORE Reports: More technical, in-depth research, actionable insights, and potential market alpha for serious crypto users
  • Early access to future CORE ratings: Being early is sometimes just as important as being right!
  • Premium Member CORE+ Reports: Coverage on the top issues pertaining to crypto users like bridge security, layer two solutions, DeFi plays, and more 
  • CORE report Audio playback: Don’t want to read? No problem! Listen on the go.

What is Loopring?

Loopring is a protocol built on Ethereum's Layer 2 that utilizes zk-rollup technology for scalability and security in decentralized finance (DeFi) and non-fungible token (NFT) applications. After a successful initial coin offering (ICO) in 2017, it became the first zkRollup-powered decentralized exchange (DEX) to launch on the Ethereum mainnet in December 2019. Unlike Uniswap and Curve, which were developed directly on Ethereum's mainnet, Loopring created the first zkRollup-powered DEX on Layer 2. This allows for up to 3000 trades per second to be executed on the DEX at a fraction of the cost of an Ethereum mainnet trade.

Loopring was founded by Daniel Wang and the Loopring team in 2017 with the goal of improving the DEX experience. Since then, Loopring has developed a protocol, relayer, DEX, smart wallet, and token to create a comprehensive ecosystem. Additionally, Loopring was one of the first rollups to issue its own native coin (LRC) via an airdrop in 2018. LRC is used for staking, fee payments, rewards and, in the future, governance with the introduction of the Loopring DAO.

Loopring Technology

The Loopring team’s primary product is the Loopring Exchange, a decentralized, non-custodial trading platform that provides secure and fast trades with no gas fees. Loopring Exchange can execute up to 2,000-3,000 transactions per second (TPS) and charges a transaction fee of 0.25% for each swap. Instead of executing trades directly on Ethereum's mainnet, Loopring uses zero-knowledge rollups technology, thereby avoiding the limitations of slow transaction speeds and high costs associated with the Ethereum base layer.

Zero-knowledge Rollups

Zero-knowledge rollups (ZKRs) are Layer 2 scaling solutions that provide users with higher transaction speed, low gas fees, and similar security guarantees as Ethereum mainnet. ZK rollups achieve high scalability without compromising security by moving computation and state data off-chain while still posting a validity proof and minimum data to the Ethereum mainnet for final settlement. They send validity proofs to prove the validity of transactions and state changes.

zkr landscape Source

Zero-Knowledge Rollups TLDR

The process works as follows: 

  1. Users of a ZKR approve transactions that are sent to the L2 ZKR operator, where they get ordered and batched
  2. Highly-compressed batches of transactions are combined with the current state root
  3. The combination is sent to an off-chain Prover 
  4. Prover computes the transactions, generating a validity proof of the results 
  5. Prover sends this to an on-chain Verifier (Ethereum nodes)
  6. Verifier confirms the validity proof
  7. Smart contract on Ethereum’s L1 that maintains the state of the rollup is updated to the new state

ZKR diagram Source

Validiums

As mentioned previously, Loopring is a particular type of ZKR called a validium.

validium is nearly identical to a ZKR, with the only difference being data availability in a ZKR is on-chain (Ethereum L1), while Validiums store it off-chain for cost-reduction reasons. This means “true” ZK-rollups post data on the Ethereum mainnet itself while validiums post proofs on-chain, but the data remain on a separate network. 

zkr vs validium Source: Starkware

This benefit enables validium to achieve considerably higher throughput than traditional rollups. By sending data off-chain rather than on-chain, it further reduces the cost of each transaction and increases the transactions per second (TPS). Validiums are the cheapest on a per-transaction basis in this spectrum.

validiums Source

Accessing the latest state in a validium requires that off-chain data be available. This is fine except in cases where the data provider misbehaves or goes offline. As a result, there's no DA guarantee and security is lower. Current Validium designs, like Metis, use a Data Availability Committee (DAC) rather than a single provider due to these security concerns.

By keeping data off-chain, validiums also offer privacy benefits as users’ transaction and balance information is stored with the Validium operator instead of publicly on the blockchain. However, because transaction data isn’t published on-chain, users are forced to trust an operator to make the data available when needed. This key difference makes validiums more akin to a highly performant, custodial PoA system where Validium operators could freeze, but not steal, users' funds. 

Multiple projects launched validiums using Starkware’s StarkEx platform, including:

  • DeversiFi DEX - June 2020
    •  Mobile web browser Opera has integrated with DeversiFi, enabling users to transact on L2 directly for ultra-low transaction costs and (near) instant trading.
  • Immutable X NFT platform - April 2021
  • Sorare Fantasy Soccer - July 2021

Loopring 3.0 (described further below) features on-chain data availability (OCDA). This hybrid method to data storage provides users with the option to store their data on-chain or off-chain. When the OCDA feature is disabled, data is stored on-chain, and the network is capable of ~2,000 transactions per second (TPS). However, the throughput can reach 3,000+ TPS if OCDA is activated and data is stored off-chain via the Validium mode. Using Loopring 3.0 developments like as OCDA, non-custodial exchanges may be able to match the performance of their centralized, custodial rivals.

 

Loopring DEX

Loopring’s DEX provides a user experience that is comparable to centralized exchanges (CEXs) while maintaining the key benefits of a decentralized protocol. Its L2 solution allows it to offer the security and non-custodial characteristics of Ethereum-based exchanges while providing a similar user interface as a traditional CEX. 

The ZKR smart contract used by the Loopring DEX utilizes an off-chain Merkle Tree to represent assets deposited into the contract. Trades and other activities on the platform result in changes to this Merkle Tree, which are then aggregated by a relayer and compressed using a cryptographic proof, attesting to the validity of the changes.

Transfers between L1 and L2 incur only a token transfer gas fee, rather than the more expensive costs associated with executing smart contracts on the Ethereum mainnet. Withdrawals back to L1 Ethereum for Loopring's native LRC token and DAI take mere seconds as opposed to days for Optimist rollup competitors.

Important Entities: the Protocol Layer and the Relayer

The protocol layer consists of the Ethereum smart contracts that collect data from the main chain. The relayer is responsible for all backend transaction execution and calculations, including ZK-rollup proofs. When an order is placed on the Loopring exchange, the network's smart contracts acquire the relevant information. Then, the smart contracts check whether the user's wallet contains the necessary tokens and if so, the order is transferred off-chain to the relay layer. The relay nodes serve as the basis for the overall Loopring initiative, which aims to connect users and establish a liquidity pool.

Loopring relayer Source

How the Loopring DEX Executes a Trade

Order Rings

The Loopring protocol is distinct from traditional decentralized exchanges (DEXs) and automated market makers (AMMs) in that it utilizes a novel approach to creating liquidity for illiquid trading pairs. Instead of relying solely on a merged order book and AMM, the Loopring protocol attempts to fill orders on a peer-to-peer basis (ring orders) before checking the merged order book and AMM. The Loopring zero-knowledge rollup (ZKR) can match up to 16 orders simultaneously through an order ring on the relay layer. In contrast, typical order-book exchanges compile all bids and asks and then fill orders once corresponding trading pairs are found based on the current price of the asset.

Order rings are constructed by particular nodes in the relay-mesh network called Ring-Miners. These relays have the autonomy to choose their method of mining order rings, building order books, and communicating with each other. As ring mining is computationally intensive, it is performed completely off-chain. In return for their services, relays receive 80% of the fees for the orders they facilitate. Fees are specified by the user when they create an order.

It is worth noting that Loopring is not the only protocol to implement a ring trade mechanism. The Gnosis Protocol launched its CowSwap DEX over a year ago and debuted a similar process called Batch Auctions. Both protocols have created liquidity by prioritizing peer-to-peer transactions rather than relying on liquidity pools or an order book.

When a ring miner completes an order ring, the Loopring smart contract determines how to fill it. If it can execute the order on either side of the trade, the smart contract will execute an atomic swap, a direct transfer from the smart contract to the user's wallet. Order rings also facilitate ring-matching, which is the process of fulfilling orders by stringing them together and settling multiple trades through multiple users. This feature differentiates the Loopring protocol from other DEXs like Waves, IDEX, and Bancor.

Loopring uses a unique consensus protocol that circumvents traditional order books and the AMM mechanisms governing liquidity pools. Instead, network participants called ring miners are responsible for rapidly filling orders before they're executed or canceled. Those who operate as ring miners receive a service fee in the form of LRC tokens, the native token of the Loopring protocol, or a split on the margin of the order amount.

The function of order sharing is also made possible via order rings on the Loopring protocol. In the instance that the Loopring DEX smart contract cannot execute an order in a single trade, order sharing is used to split orders into partial components until the full original order amount is fulfilled. Ring-matching technology aggregates multiple separate orders into a single-order ring. Once the Loopring smart contract validates the orders, each party receives the assets in exchange. Orders are run through the order-sharing system as part of subsequent order rings until these partial orders are filled completely.

Loopring Adds AMM-functionality

After the successful rollout of the Loopring DEX, which solely used its ring order technique, eventually, the team offered an AMM to provide additional liquidity for trading via liquidity pools. In April 2021, the team introduced combined liquidity, directing orders to the best exchange price on AMM or the order book.

AMM liquidity mining occurs within a 14-day cycle on Loopring, and rewards are distributed within three days of the round's conclusion. Within the current cycle, liquidity providers can select from a variety of asset pairs within the DEX and are presented with the current trading volume and anticipated APR (assuming the trading volume remains constant throughout the year).

After removing the option for users to route their orders to either the AMM or order book, Loopring's AMM continued to fulfill the majority of orders. Loopring will need to increase its liquidity pools in order to sustain its growth.

How do you rate this article?

111


Michael @ CryptoEQ
Michael @ CryptoEQ

I am a Co-Founder and Lead Analyst at CryptoEQ. Gain the market insights you need to grow your cryptocurrency portfolio. Our team's supportive and interactive approach helps you refine your crypto investing and trading strategies.


CryptoEQ
CryptoEQ

Gain the market insights you need to grow your cryptocurrency portfolio. Our team's supportive and interactive approach helps you refine your crypto investing and trading strategies.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.