Be a crypto hero in the market by logging in

Don't you have an account? Sign in

Token price

  • BTC

    10,296,246.2KRW

    2.3%

  • ETH

    197,266.0KRW

    4.7%

  • XRP

    274.3KRW

    4.1%

  • BCH

    408,064.1KRW

    9.3%

  • BSV

    342,415.8KRW

    -5.3%

  • USDT

    1,157.8KRW

    -0.1%

  • EOS

    4,606.9KRW

    7.3%

  • LTC

    54,759.1KRW

    -0.5%

  • BNB

    20,849.3KRW

    6.7%

  • ETC

    13,761.6KRW

    47.2%

  • TRX

    20.4KRW

    5.6%

  • XMR

    77,208.3KRW

    2.6%

  • XLM

    66.5KRW

    7.5%

  • ADA

    50.5KRW

    6.9%

  • DASH

    135,683.3KRW

    -5.7%

  • XTZ

    1,752.1KRW

    13.1%

  • ATOM

    5,720.0KRW

    12.1%

  • NEO

    13,393.4KRW

    5.6%

  • HT

    3,838.7KRW

    3.7%

  • HEDG

    2,621.8KRW

    0.2%

  • MKR

    589,289.8KRW

    -1.1%

  • ZEC

    63,828.3KRW

    10.9%

  • ONT

    819.2KRW

    5.6%

  • USDC

    1,164.7KRW

    0.2%

  • XEM

    45.7KRW

    10.1%

  • VET

    7.4KRW

    9.1%

  • BAT

    260.7KRW

    3.1%

  • DOGE

    2.8KRW

    2.7%

  • PAX

    1,165.4KRW

    0.2%

  • BTG

    14,451.6KRW

    -4.2%

  • DCR

    23,218.6KRW

    -6.3%

  • QTUM

    2,389.2KRW

    9.3%

  • INB

    574.8KRW

    2.5%

  • REP

    17,437.8KRW

    -14.1%

  • ZRX

    291.4KRW

    2.8%

  • RVN

    32.6KRW

    11.5%

  • LINK

    485.1KRW

    2.0%

  • TUSD

    1,163.9KRW

    0.1%

  • BCD

    804.3KRW

    -0.7%

  • ALGO

    287.1KRW

    3.3%

  • CNX

    2,530.2KRW

    1.7%

  • XIN

    278,179.8KRW

    5.8%

  • XIN

    278,179.8KRW

    5.8%

  • OMG

    932.3KRW

    5.4%

  • NANO

    820.9KRW

    5.6%

  • THETA

    123.5KRW

    5.1%

  • KCS

    1,274.2KRW

    0.5%

  • LSK

    852.9KRW

    11.9%

  • WAVES

    1,025.7KRW

    1.9%

  • BTM

    100.4KRW

    4.9%

  • BTM

    100.4KRW

    4.9%

  • DGB

    7.9KRW

    3.8%

  • ICX

    179.1KRW

    10.3%

  • MONA

    1,403.3KRW

    16.8%

  • KMD

    764.3KRW

    9.5%

  • MCO

    5,705.3KRW

    4.0%

  • IOST

    6.9KRW

    5.6%

  • HC

    1,801.1KRW

    8.6%

  • SC

    1.8KRW

    2.1%

  • XVG

    4.6KRW

    1.0%

  • ENJ

    91.7KRW

    0.5%

  • NEXO

    125.0KRW

    11.2%

  • ABBC

    124.4KRW

    0.6%

  • BCN

    0.4KRW

    9.3%

  • XZC

    6,741.2KRW

    13.2%

  • ZIL

    6.2KRW

    6.7%

  • BTS

    22.0KRW

    5.8%

  • STEEM

    165.4KRW

    1.7%

  • AE

    193.6KRW

    6.1%

  • MATIC

    21.1KRW

    15.0%

  • ARDR

    52.7KRW

    8.0%

  • QNT

    4,023.9KRW

    5.5%

  • ETN

    4.6KRW

    -1.6%

  • MANA

    43.5KRW

    2.5%

  • SNT

    12.2KRW

    4.5%

  • DAI

    1,173.8KRW

    1.1%

  • TOMO

    567.4KRW

    5.2%

  • NPXS

    0.2KRW

    2.7%

  • STRAT

    387.9KRW

    7.9%

  • GNT

    39.3KRW

    2.6%

  • MAID

    84.3KRW

    -4.5%

  • ELF

    69.8KRW

    4.0%

  • ELA

    1,912.8KRW

    4.9%

  • FET

    47.8KRW

    4.4%

  • AION

    77.6KRW

    7.4%

  • LRC

    29.1KRW

    4.8%

  • TRUE

    314.5KRW

    5.8%

  • RDD

    0.8KRW

    0.8%

  • WAX

    22.9KRW

    1.4%

  • WTC

    529.1KRW

    -3.1%

  • LAMB

    32.3KRW

    2.3%

  • FCT

    2,502.3KRW

    6.8%

  • PPT

    404.6KRW

    4.2%

  • ARK

    178.7KRW

    6.0%

  • POWR

    48.6KRW

    2.3%

  • R

    41.9KRW

    1.4%

  • ANT

    645.4KRW

    -1.1%

  • LOOM

    20.3KRW

    -0.7%

  • PAI

    13.0KRW

    4.3%

  • PAI

    13.0KRW

    4.3%

  • BNT

    266.7KRW

    5.0%

  • DENT

    0.2KRW

    14.6%

  • PIVX

    302.8KRW

    -1.7%

  • OCEAN

    47.1KRW

    3.8%

  • MOAC

    263.2KRW

    -1.0%

  • ABT

    163.3KRW

    5.0%

  • CET

    17.4KRW

    3.8%

  • ODE

    59.5KRW

    1.6%

  • TTC

    32.8KRW

    -1.1%

  • AOA

    1.9KRW

    3.8%

  • POLY

    22.5KRW

    5.0%

  • PAY

    47.7KRW

    3.8%

  • REPO

    60.5KRW

    4.1%

  • MBL

    1.7KRW

    4.6%

  • BORA

    9.6KRW

    2.2%

  • CPT

    1.9KRW

    0.4%

  • BCV

    6.2KRW

    -2.6%

  • BAAS

    1.1KRW

    3.0%

  • COSM

    7.6KRW

    1.9%

  • GUSD

    1,157.7KRW

    0.3%

  • FLETA

    9.2KRW

    2.1%

  • FNB

    2.2KRW

    3.9%

  • UPP

    11.1KRW

    -4.4%

  • AERGO

    30.5KRW

    3.5%

  • HUM

    6.7KRW

    -1.4%

  • EOSC

    3.2KRW

    0.4%

  • MVL

    0.4KRW

    -1.4%

  • DCC

    0.9KRW

    0.1%

  • RBG

    0.8KRW

    -3.9%

  • LKY

    48.6KRW

    0.1%

  • eDEL

    2.4KRW

    -0.7%

  • VRA

    0.5KRW

    -0.5%

  • ABL

    7.1KRW

    -8.0%

  • TEMCO

    0.5KRW

    -3.8%

  • MEETONE

    0.7KRW

    10.9%

  • AID

    3.0KRW

    -7.1%

  • AMON

    2.0KRW

    6.9%

  • PXL

    21.9KRW

    2.7%

  • AKRO

    0.8KRW

    -1.4%

  • XRA

    7.8KRW

    0.2%

  • WET

    4.0KRW

    2.3%

  • HORUS

    0.7KRW

    40.2%

  • CLB

    1.2KRW

    -15.2%

  • RBTC

    9,988,295.6KRW

    5.1%

  • WIKEN

    1.7KRW

    7.0%

  • PTON

    0.0KRW

    41.4%

  • NEWS

    1.5KRW

    23.2%

  • SEAL

    0.7KRW

    -3.5%

  • PUB

    0.2KRW

    -19.8%

  • NPER

    3.4KRW

    0.1%

  • KARMA

    0.0KRW

    1.5%

  • PUT

    1.5KRW

    2.2%

  • CCH

    0.0KRW

    0.0%

  • KNT

    0.0KRW

    -43.0%

  • APIX

    0.6KRW

    0.1%

  • IQ

    3.4KRW

    -2.0%

  • BLACK

    0.5KRW

    21.8%

  • RCD

    3.0KRW

    --%

  • MCC

    4.4KRW

    0.1%

  • INC

    0.2KRW

    -21.2%

  • BZKY

    0.3KRW

    0.1%

  • CRE

    1.5KRW

    -1.9%

Community

Loopring 3.0 Overview: From A to zkSNARKs

Loopring | 06.26| 111

This post is meant to provide a quick overview of how Loopring 3.0 works, and how we use zkSNARKs to enable scalable, secure DEXs. For a deep dive, you can check out the full design doc on GitHub.

Introduction

The third version of the protocol tackles the scalability problem of decentralized exchanges. Previous versions of the protocol already did the order matching off-chain, but the settlement was completely on-chain. This still has a high computational and storage cost on-chain.

Protocol 3.0 solves this by moving almost all data off-chain as well as moving all computations for all requests off-chain using zero-knowledge proofs (zkSNARKs).

Merkle Tree

Data is stored in a Merkle tree using an account model. Each user has a single account with a one-to-one mapping to his Ethereum address. This account can store balances for all tokens the exchange wants to support and also stores all the trading history data for the user. Requests modify the Merkle tree and the state transitions are verified on-chain using proofs.

Blocks

For efficiency reasons, requests are batched together in blocks. The cost for verifying a proof remains constant no matter the number of requests in a block, but we are limited in how many requests we can include in a block, otherwise, the proof verification on-chain would not be efficient anymore. How many requests we can include in a block depends on the complexity of the request. If multiple requests types would be included in a block there would be some overhead of doing computations that are only necessary for a single request type so we limit blocks to a single request type for now.

We currently support 5 different requests:

  1. Trade settlement
  2. Deposits
  3. On-chain withdrawal
  4. Off-chain withdrawal
  5. Off-chain order cancellation

Only the first three are necessary for building a fully functional DEX. The other two provide some extra flexibility for users and exchanges.

Once the DEX operator has committed a block on-chain he also needs to submit the proof for the block within a time limit. The commit of the block and the submitting of the proof is done separately because the proof generation currently takes some time. By allowing the DEX operator to commit the block first without having to wait on the proof generation allows other operators to create new blocks that build upon the state of the latest committed block and also allows the proof generation to be done in parallel. Once the proof is generated the operator can send the proof on-chain so the state transitions done in the block are verified. If the operator fails to submit a valid proof in time he is punished and the state is automatically reverted to a valid state.

Data Availability

Only the Merkle tree root is stored on-chain. This is sufficient for users to prove (using a Merkle proof) that they own a certain amount of tokens on the DEX. Even when the DEX operator doesn’t cooperate any more users can withdraw any funds they have in ‘withdrawal mode’.

Users need to be able to create a Merkle proof. For that, they need to have access to the complete Merkle tree, not just the Merkle root. In the best case, this data is made available somewhere by the DEX, but there is no guarantee that this is actually the case. To make sure all data is available for all users this data is sent on-chain (this is done using CALLDATA, not storage, which is cheaper and more future proof). Currently, this still has a high cost on Ethereum (though this will improve in the future) and this limits the maximum throughput that can be achieved. This is why we also support disabling on-chain data availability, DEXs are then free to implement some off-chain solution for this.

User Flow

Depositing

To start trading users first need to deposit some funds to the exchange smart contract. This is done using a normal on-chain transaction and the request is added to the on-chain deposit queue. Once the DEX operator includes the deposit request in a block the user can start trading.

Trading

A user signs an order a single time and the order contains all the data needed for a DEX to settle the order. The protocol supports

  • Maker/taker orders (using the same order)
  • Market orders
  • Fee payments to the DEX
  • Rebate payments from the DEX to an order owner
  • Automatic order scaling
  • Partial order matching
  • Dual-Authoring to prevent the stealing of orders and/or ring settlements

How the orders are matched is fully up to the DEX, but the settlement will respect the wishes of the order creator in all cases.

The DEX creates a ring settlement request by matching two orders and sends the request to the DEX operator who will include the request in a block to receive the fee specified in the request. The operator can then commit the block on-chain.

Withdrawing

If the user wants to withdraw their tokens from the exchange they need to do a withdrawal request. If the user does an on-chain withdrawal request the DEX needs to include it in a block in a reasonable time. If a certain amount of time has passed since the withdrawal request was done we first force the operator to process it by only making it possible to commit on-chain withdrawal blocks. If the operator still refuses to process the withdrawal request the exchange goes into ‘withdrawal mode’. ‘Withdrawal mode’ is irreversible and completely shuts down the exchange, the only thing that’s still possible is for the users to withdraw their funds. This ensures that users remain in full control of their money in all cases without having to trust anyone.

About Loopring

Loopring is a decentralized exchange protocol utilizing zkSNARKs to bring highly scalable, non-custodial trading to the masses. You can sign up for our bi-weekly update, and learn more at:

⭑ Twitter: twitter.com/loopringorg
⭑ Reddit: reddit.com/r/loopringorg
⭑ Telegram: t.me/loopring_en & t.me/loopringfans (Chinese)
⭑ Discord: discord.gg/KkYccYp
⭑ GitHub: https://github.com/Loopring
⭑ Kakao: open.kakao.com/o/gJbSZdF (Korean)


Loopring 3.0 Overview: From A to zkSNARKs was originally published in Loopring Protocol on Medium, where people are continuing the conversation by highlighting and responding to this story.

Comment 0

delete

Are you sure you want to delete this post?