Developer Portal

This developer portal provides technical information for software engineers and product managers to comprehend and adopt the solution. We welcome our community to send us feedback to enhance these documents.

Loopring

Loopring is a layer-2 protocol that consists of multiple smart contracts to verify tradable orders and perform trade settlement on-chain while keeping all order management off-chain. Loopring features a generic design with matching-as-a-service, ring-matching, and anti-front running (dual-authoring technology). We strongly encourage you to read our new whitepaper and previous blog posts as it is the best way to understand the protocol. If you have any questions, you can send us an email, or post questions on StackOverflow or Reddit. You can also learn more about the Loopring Protocol here.

Our Solution

There is a significant lack of security, transparency, and liquidity in centralized exchanges. Loopring invented a new trading experience built upon blockchain and smart contract technologies. Through our whitepaper and this developer portal, you will see that Loopring DEXs are non-custodial and perfectly secure: all trades are verified and recorded on the blockchain for absolute transparency, and every Loopring order can be trustlessly shared with as many parties as possible, which allows for greater liquidity and trade price improvement.

The Loopring Foundation provides open-sourced, ready-to-deploy solutions for our community to develop the DEX frontend with apps (a.k.a wallets), the DEX backend (a.k.a relayers or matching engines), along with liquidity sharing middleware. We also provide free-of-charge consulting and technical support.

We have multiple patents in the US, the European Union, and China to protect the design and implementation of the Loopring Protocol. Before deploying a trading protocol on any public blockchain, please make sure your smart contracts don't include the ring-matching and dual-authoring features; otherwise, you must obtain our formal authorization for using our patents in writing.

Challenges

All DEX solutions suffer low TPS (transactions per second) and high latency imposed by the underlying blockchains' slow block-times. Ethereum's current TPS is about 15 and block-time is roughly 15 seconds. Without a higher TPS, Loopring's trading experience won't be a match for centralized exchanges; but once Ethereum's TPS scales to 1000 or above, we believe the overall DEX trading experience will be even better than centralized exchanges.

Loopring and all DEX protocols are not designed for high-frequency trading (HFT). We do not view this as an issue, and seek to provide the best trading experience for regular traders and investors. Further, we believe HFT is not necessarily fair for regular traders, and has been dramatically misused for market manipulation of crypto prices.

Loopring vs. Kyber Network

Loopring and Kyber are designed for different use cases and are complementary to each other. Loopring features third-party matching-as-a-service (MAAS), whereas Kyber is a market-making protocol where market-makers offer their clients liquidity at promised prices within a given period. Kyber is more comparable to the Bancor protocol.

Loopring vs. 0x

Loopring and 0x are both order-based exchange protocols. We share many common designs, including:

  • Both protocols enable order-based trading of ERC-20 tokens;
  • Orders are managed off-chain, but settlement transactions are performed on-chain through smart contracts;
  • Both protocols suffer low TPS and long block-times of the underlying Ethereum blockchain;
  • Both teams are very open and supportive.

But we are also very different in many other ways:

  • Loopring's order model is simpler and more generalized: our single unidirectional order model fits all, whereas 0x has maker orders and taker orders;
  • Loopring features a ring-style matching that can place multiple orders in a ring for higher liquidity and price improvement. Ring-matching is a more generalized trading scheme than the trading pair notation that is used by 0x;
  • Loopring's Dual-Authoring technology prevents its orders and rings from being stolen by middlemen and Ethereum miners; it also adds another level of control for liquidity/order sharing;
  • Loopring offers significantly more open-sourced software for its partners to quickly build a DEX at a lesser cost, including a JavaScript library, two web-based wallet/DEXs, an embeddable HTML5 component for mobile apps, an iOS wallet application, a distributed relay cluster with ring-matching capability, and a liquidity sharing middleware based on pub-sub messaging;
  • Loopring will continue to focus on ERC-20 and will not support ERC-721 (non-fungible) tokens; whereas 0x aims to become the protocol for trading everything. We believe a protocol needs to be simple, elegant, easy to understand, and extensible.

How to use Loopring?

Unlike the rigid business model of centralized exchanges, Loopring's technology offers you the ability to become part of the decentralized exchange ecosystem. Let's take a look at the Loopring DEX ecosystem illustrated by the image below:

Loopring Ecosystem

Become a DEX or a Wallex

Loopring can turn any application or web page into a DEX. A DEX retrieves and displays orders and trades and may show submit-order and cancel-order forms for users to manage their trading data. In our model, a DEX does not have access to users' private keys. If it does, we refer to it as a Wallex (Wallet + DEX). Orders generated by a DEX must be signed from within a wallet such as a Ledger or MetaMask before being sent to a relayer.

The Loopring team provides an open-sourced DEX named Circulr and an open-sourced Wallex named Loopr. You can clone one of these projects to easily launch a web frontend accessing Loopring's default relayer system. If you want to start from scratch, we also offer a JavaScript library called loopring.js for you to access any compatible backend relayer system.

Loopring brings a new stream of income to DEXs and Wallexs- 20% of matching fees will be rewarded to a DEX that helps users generate their orders. This portion of fees will be automatically transferred to each DEX and Wallex's fee-collecting address by the Loopring Protocol after each trade has been settled, guaranteed!

Frontends have the option to connect to one or multiple relayers, given that permission is granted. In the graph above, "Frontend 8" connects to only one dedicated relayer. This is more like the centralized exchange model where liquidity is not shared, and there is a single point of relayer failure (albeit still non-custodial). "Frontend 7" connects to one dedicated relayer while also sharing large orders to "Relayer D" to speed up trading; "Frontend 5" always broadcasts orders to "Relay D" and "Relay C" to maximize trading speed and minimize price spread; and "Frontend 3" evenly shares liquidity across two liquidity sharing networks through "Relay B"and "Relay C".

Connecting and broadcasting users' orders to multiple relayers and the liquidity sharing networks increase the likelihood of orders being fulfilled. The network topologies and business relations between frontends, relayers, and the liquidity sharing networks are entirely up to each entity in the ecosystem; the Loopring Foundation doesn't impose any rules.

If you are not happy with 20% profit sharing, you can also run your own relayer cluster to collect further order fees.

Become a Relayer

Relayers manage orders and trades, and offer the non-custodial order-matching services as options. Relayers can receive orders from as many frontends as possible without trusting any of them. This opens the door to build a larger liquidity pool than any centralized exchange.

Relayers receive 80% of matching fees, but it doesn't come for free: Relayers must pay Ether as gas for ring-settlement transactions on the Ethereum blockchain, and pay fiat money for cloud services.

Sharing Liquidity

Besides liqudity sharing among different frontends using the same relayer, relayers can also share liquidity with each other by joining the same liquidity sharing network. The Loopring Foundation provides a pub-sub based implementation of such a network, but ecosystem partners can build their liquidity sharing network with their technology stack of choice. The Loopring Protocol does not have a standard for liquidity sharing.

Each liquidity sharing network may have their own internal economic model to incentivize order sharing: rewarding order producers and charging order receivers. This is not explicitly part of the Loopring Protocol.