Chainlink and Loopring Collaborate on Oracles for zkRollup DEX Protocol
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:
- Loopring v3 drawing on Chainlink oracles to inform protocol-level security parameters (the use case currently implemented);
- Loopring-based DEXes referencing Chainlink price feeds to support advanced order types such as Stop Limit orders;
- 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 is a protocol for building high-performance, non-custodial, orderbook exchanges on Ethereum. We use zkRollups — a layer 2 scaling solution — to increase throughput and reduce settlement costs without sacrificing layer 1 security guarantees. Specifically, Loopring v3 has increased trade throughput and reduced cost by a factor of 700x compared to our v2.
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 is a decentralized oracle network that will give smart contracts secure and reliable access to data providers, web APIs, enterprise systems, cloud providers, IoT devices, payment systems, other blockchains and much more. It will feature the following.
- Binding service agreements between the oracle providers and querying smart contracts that outline the terms of service
- A robust market of independent oracles providing a range of data and connections
- 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
- 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
With Loopring v3 recently deployed on Ethereum mainnet, the team’s attention has turned toward an important consideration: oracles. There are several areas across v3 that require off-chain inputs to function effectively. An important one relates to querying the LRC price (in ETH or USD) in order to know whether or not a DEX owner is staking a sufficient amount as an economic security guarantee. We will unpack that statement, but first, note that LRC is staked along 3 different mechanisms which you can read about in this post. Briefly, they are:
- LRC Staking to Earn Protocol Fees
- LRC Staking by DEXes for Economic Security
- 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
In our zkRollup construction, DEX owners/operators receive requests (trades, cancellations, withdrawals, etc.) from users off-chain, which they batch together, and, with a zkSNARK, prove mathematically that each request satisfies the protocol rules — i.e., each trade price is respected, the signature is valid, no excess fees are being levied, etc. Creating this zkSNARK proof is a computationally heavy process, and depending on the circuit and power of the machines, can take several minutes to hours. In our prover, we target 20 minutes to generate a proof.
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
Chainlink has created a reference contract powered by its decentralized network of oracles to provide the LRC/ETH price. The price is pushed on chain at any 5% deviation from the previous price, or, with a weekly heartbeat update should that 5% level of volatility not arise. The LRC/ETH feed will be provided by 7 Chainlink nodes to begin with, drawing their data from a multitude of sources including CoinGecko, CoinMarketCap, CoinAPI, and more.
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.
Both teams are excited to work together and share similar philosophies in their respective track, focusing heavily on engineering and security.
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