Chainlink and Loopring Collaborate on Oracles for zkRollup DEX Protocol

Matthew Finestone
Dec 27, 2019 · 8 min read

Chainlink and Loopring are pleased to announce our collaboration across several oracle integrations in Loopring’s v3 zkRollup DEX protocol. The first of which is live on Ethereum mainnet: a faithful LRC/ETH price feed for DEX owners to anchor their LRC economic security staking. The most pertinent contract being the MovingAveragePriceProvider.

While Chainlink is a decentralized oracle network, and Loopring a decentralized exchange protocol, the two projects have more in common than meets the eye. Chainlink and Loopring, in their own unique ways, both operate at the critical juncture between on-chain and off-chain environments: Chainlink as a reliable, redundant oracle network to feed off-chain data to on-chain contracts; Loopring as a zero-knowledge protocol validating off-chain exchange activity on-chain.

The collaboration is set to be comprehensive with:

  1. Loopring v3 drawing on Chainlink oracles to inform protocol-level security parameters (the use case currently implemented);
  2. Loopring-based DEXes referencing Chainlink price feeds to support advanced order types such as Stop Limit orders;
  3. Loopring-based DEXes to provide inputs into Chainlink’s oracle network, with the benefit of all trading activity being perfectly verifiable on Ethereum, even through our layer 2 zkRollup.

In fact, there are more planned integrations, but before we get into further detail, let’s first provide a quick description of Loopring and Chainlink.

Loopring Protocol

We achieve this by using Zero-Knowledge Proofs (ZKPs) to perform all computations in verifiable batches off-chain, and only submit a small proof to Ethereum to validate. For a 5 minute overview of how this works, see here. Loopring is the first live zkRollup DEX protocol on Ethereum enforcing on-chain data availability — a design decision which places security above incremental scalability gains. This allows users to always access their funds, even in the absolute worst case scenarios where the Loopring Foundation and DEXes built atop cease to exist — as long as Ethereum is running, funds are safe. More on this ultimate level of security here.

Our goal is to make non-custodial exchanges the obvious option for trading on Ethereum — no excuses about lacking the high-performance of centralized competitors. In our vision, Ethereum DEXes will not just support ‘simple swaps’, but true trading. Learn the difference here.

Chainlink

  1. Binding service agreements between the oracle providers and querying smart contracts that outline the terms of service
  2. A robust market of independent oracles providing a range of data and connections
  3. Flexibility to customize an oracle connection including the number of oracles, types and number of data sources, aggregation strategies, staking deposits, trusted execution environments, Mixicles and more
  4. A reputation framework for evaluating oracles based on on-chain metrics

It’s an all-in-one network for users to customize how their contract communicates with anything off-chain using varying levels of decentralization, privacy, data aggregation, and oracle selection.

Chainlink & Loopring Integration

  1. LRC Staking to Earn Protocol Fees
  2. LRC Staking by DEXes for Economic Security
  3. LRC Staking for Protocol Fee Reductions

The first type of staking is ‘global’, meaning it is protocol-wide, and any user/holder can participate to earn protocol fees. That type of LRC staking is live as of two weeks ago. The other two types are ‘local’, or per DEX. We will focus on number 2 as it represents a crucial part of the protocol, and is the first Chainlink-Loopring integration already live on Ethereum mainnet.

LRC Price Feeds for DEX Economic Security Staking

While a proof is being generated for a batch, the DEX owner already commits to this new state of the DEX, and the next batch is already being received/processed in a highly parallelized flow to keep things running continuously.

Thus, while Loopring v3 relies on cryptographic security for every state transition, there is an ‘interim’ period where the DEX owner has painted the picture, but the paint is not yet dry. Here is where LRC is used by DEX owners as a bond for economic security. The locked LRC is partially or completely slashed when a DEX violates protocol rules, such as failing to submit a proof for a committed block on time, or having a reversion. Again, this economic security is only in play until the zkSNARKs are submitted, which provides final cryptographic proof.

The protocol mandates a minimum amount of LRC at stake in order for a Loopring DEX to open up shop. The current parameter is 500,000 LRC, but will be configurable via protocol governance. See here for a full list of protocol parameters & slashing costs.

Beyond that minimum, the amount of staked LRC reflects a DEX’s likelihood or disincentive to violate protocol rules. The more LRC locked, the more skin in the game, the more reliable a DEX should be. Note, this reliability relates only to service performance (getting things done) — user funds are always Ethereum-level secured by the protocol.

This is where Chainlink’s oracles come in. We need this economic security to be denominated in widely-known terms, so that users of a DEX know how much economic security is provided on their venue of choice. Further, even if everyone knew 500k LRC = $11,100 today, LRC price can be volatile, and that 500k could be $8,000 tomorrow, or $18,000. Thus, specifying the minimum stake amount in USD (or ETH) and translating that dynamically into LRC is necessary.

Chainlink’s LRC/ETH Reference Contract

https://feeds.chain.link/lrc-eth

This LRC/ETH price feed will then be multiplied by Chainlink’s widely used ETH/USD price feed, to gather an LRC/USD rate. This LRC/USD rate will be referenced by DEX owners to ensure they have the appropriate amount of LRC at stake. If they drop below the USD threshold, there will be a time window where they can quickly adjust and add more LRC.

Importantly, this LRC/USD rate will also be referenced for slashing penalties, such as when a DEX allows a reversion. A reversion means that a DEX has failed to provide a proof for a batch they committed to — for malicious or innocuous reasons. Either way, a reversion is a disruption to traders (and potentially harmful to their profit), so reversions result in a slashing penalty. As seen in the parameter list, a reversion currently costs a DEX owner 5,000 LRC, but again, this must be denominated in USD to be of significance. [Note, this parameter will be much higher, it is only low because v3 has just been deployed.]

The fact that we are referencing an LRC/ETH feed, but can freely multiply it with the reliable ETH/USD feed gives the protocol greater flexibility — it can reference in only LRC/ETH terms in other areas as needed.

This integration required a level of confidence because, as we’ve seen in other projects this year, a faulty price feed can be the largest, insidious attack vector. For example, if a DEX could easily or cheaply manipulate the LRC/USD price feed, they can attack/annoy their users, without a steep slashing cost to pay. Fortunately, given v3’s design, a DEX can never arbitrarily steal user funds even in a worst case scenario.

Future Integrations

Just as Loopring feels confident in using Chainlink’s network for secure and reliable oracles, Chainlink is thrilled to integrate into a leading DEX protocol that has pushed forward on scalability without sacrificing security.

The next areas for integration will center more around products & services:

  • Advanced order types, where secure price feeds of listed trading pairs are required to trigger actions. This would be an integration with Loopring’s relayer-as-a-service, named Lightcone.
  • Other token prices, for Loopring’s Hebao Wallet and DEX, to appropriately enforce allowance for meta-transactions, etc.
  • Loopring DEXes providing reliable source data via its DEX browser.

“We’re excited to work with an ambitious project like Loopring and provide their DEX protocol access to secure and reliable data oracles in a customizable manner that fits their needs. By adding decentralized oracles to their off-chain solution, Loopring is pioneering the next iteration of secure, scalable DEX protocols. We’re thrilled to aid their team in making this a fully-functional reality.” — Sergey Nazarov, Co-Founder of Chainlink

“Working with Chainlink for v3’s oracle requirements made perfect sense, and the process has been smooth and tailored to our use case. We will continue advancing the inherently aligned interests of exchange protocols and oracle networks — both well aware that a system is only as secure as its weakest link. More than anything, we appreciate the fact that they are equally unwilling as us to compromise on security guarantees — that’s what stands out.” — Daniel Wang, Co-Founder of Loopring

For more information about Chainlink, please visit the Chainlink website, Blog, Twitter or Reddit. For developers, visit the developer documentation.

For more information about Loopring, please visit the Loopring website, Blog, Twitter, Telegram, or Newsletter. For developers, please visit the GitHub.

Loopring Protocol

Loopring Official Blog

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store