23
Review of Decentralized Exchange (DEX) July 12, 2018

Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Review of

Decentralized Exchange (DEX)

July 12, 2018

Page 2: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Table of Contents

1. DEX Overview 2. DEX vs Centralized 3. DEX Benefit vs Drawbacks 4. Transition from Centralized to DEX 5. Major DEX Players

a. IDEX b. Etherdelta

6. Blockchains . Ethereum a. EOS b. NEX c. Fantom

7. Protocols . 0x a. R1

8. Blockchain related concepts . Interoperability a. Metamask b. Nodes c. Sidechain

9. Bancor, DEX, Hacked?

Page 3: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)?

· $4 billion lost due to hacking incidents between 2011 and 2017 on centralized exchanges

· Crypto-crypto exchanges (Huobi, Binance) are transitioning from centralized to decentralized, and crypto-fiat exchanges (Coinbase) are adding the new service in-lieu of centralized crypto-crypto.

Difference between Centralized and Decentralized?

· Trades on centralized exchanges are IOUs or representations and are not reflected on

the blockchain, while trades on decentralized are actually settled on the blockchain o For example, on the Ethereum blockchain, if one is trading BTC/ETH, and

customer buys Bitcoin, on a centralized exchange, the BTC is simply credited to the account

§ But on DEX, by hash-time locked contracts, or atomic swaps, the customer actually owns BTC

Difference between Decentralized and P2P?

· P2P is typically a centralized platform which holds escrow · Decentralized doesn’t require escrow, but rather can run on smart contract, which

allows atomic transfer of assets, or all or nothing asset transfer

Page 4: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Centralized Exchanges

Decentralized Exchanges

Page 5: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

What is the conventional DEX model?

· A mash between P2P and exchange on a single blockchain o P2P

§ Coins are held in the customers’ own wallets § Customer don’t need to disclose typical KYC information § Fiat is not held by the exchanges’ bank account

o Exchange § Order matching § Trading platform § Chart functionalities

o Traditional DEX operated on a single chain due to interoperability issues § Transactions occur on the blockchain, not on the orderbook within a

server § Essentially, the trades are immutable or reversible on the decentralized

exchange § Atomic swap, lightening may allow for a more dynamic

interoperability ecosystem New developments in the DEX model

· Newer DEX allow interoperability with non-native blockchains and fiat currency option

o Interoperability § Atomic swap

· Still at early stage · 2 parties each pledge on one side of crypto chain. Codes will

replace escrow. Similar to multi-sig. · Either both transaction goes through, or neither goes through.

§ Lightning network · Can use an overlay network to exchange crypto to crypto

o Fiat currency § Through partnerships with payment gateway

· PG sends the data to the system, which credits the customer · Cryptocurrency is non-reversible, but PG may reverse, so there

is risk § Bisq allows fiat with PG

· Multi-sig · No automatic match making

o Doesn’t need to be regulated in the UK because it is completely decentralized

Page 6: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

DEX Benefit · No single point of failure and control

o No hacks o No server downtime

· Privacy o Anonymity o No KYC process

§ Unless the decentralized provides fiat trading through a gateway · Faster sign-up

o No need for lengthy registration § Typically username and password

· Regulation o May be unregulated if it is setup at a tax haven and doesn’t offer fiat

DEX Drawbacks

· Personal computer’s exposure to hack o Unlike enterprise architecture, personal computers are more vulnerable to

planned attacks · Usability

o Poor user interface o No stop loss and margin trading

· Liquidity o Liquidity for larger orders is low compared to centralized exchanges

· Longer trading time o Trading requires more time to settle

· Transaction on the network o Less transactions can occur on the blockchain than centralized exchange

servers o Transaction per second (TPS) depends on the blockchain

§ BTC - 3TPS/ETH - 15 TPS § Bitshares - 1,000 TPS § Visa card network - 1,700 TPS § Binance - 1.5 million TPS

· Interoperability o Blockchain interoperability is still in infant stage o Same for inter-exchange connection among the DEXs

Page 7: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Major Centralized Exchange Players Position on Decentralized Exchanges

· Binance (building new blockchain, but will co-exist with centralized exchange) o Announced Binance Chain (March 2018)

§ Move to decentralization, but will co-exist with centralized exchange

· Coinbase (utilizing Ethereum blockchain and will be an add-on service) o Acquired NY based Paradex for undisclosed amount (May 2018) o CEO is Ron Bernstein who is Managing Director at Augment Partners and

advisor to Augur o 10 employees o Runs on 0x protocol

§ Open-source toolkit on the Ethereum blockchain · Paradex is essentially a “relayer” on the blockchain

o An entity which matches orders on the blockchain o Will service non-US customers and plan to offer hundreds of tokens

· Huobi (building new blockchain and will be completely decentralized)

o Announced Huobi Chain (June 2018) § Investing 30 million Huobi Tokens (approx. $170 million) toward

building Huobi Chain § Plans to move operations onto the public blockchain as a Decentralized

Autonomous Organization (DAO) o Plan to launch in 18 months

§ 8 phase development timeline § Will invite external developers to compete for money in a pool § Huobi Chain Superhero Championship Program (HCSCP), 3 week

hackathon to speed up transition to decentralized

· OKEX has been quiet on the decentralized front

Page 8: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Existing Decentralized Exchanges

· Trade volume is relatively low compared to centralized exchanges (less than $10 million per day)

· Bitshares seems to have resolved the issue of interoperability and can support tokens

from multiple blockchains o Created by Daniel Larimer, co-founder of Steemit and CTO of EOS o Bitshares seems to also run Openledger and Cryptobridge because the website

layout is essentially the same, or there is a white label provider that created the website for all 3 exchanges

§ Bitshares has also created SmartCoins, which is like Tether, but the bitUSD is not backed by USD deposits, rather the Bitshares cryptocurrency

§ Bitshares is looking to create an ecosystem - cryptocurrency (BTS), stable cryptocurrency (bitUSD), decentralized exchange, smart contracts, 100,000 TPS network,

· For ERC 20 based exchanges, users need to be familiar with Metamask before being

able to trade on the ERC 20 based exchanges, since one needs a Metamask account to login to the exchange

o It is not a simple registration process

· IDEX has the most volume but the website itself is very slow o https://idex.market/whitepaper o Although transactions may be settled on the blockchain, it seems to be a web

server or bandwidth issues o Trade continuously without waiting for transactions to mine o Cancel orders without gas costs o Part of the Aurora ecosystem o Order taking is offchain, while trade settlement is onchain

Page 9: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

· IDEX o IDEX does all the trade verification offchain, and waits for the transaction to

be sent to the blockchain. This might be why they can offer free cancellation because it hasn’t hit the blockchain yet. Once the transaction hits the blockchain, the users’ fund balances are updated.

Page 10: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

· EtherDelta o (https://hackernoon.com/understanding-decentralized-exchanges-

51b70ed3fe67) o Semi-centralized, semi- decentralized

§ Centralized part is the listing of all the Maker orders on Ether Delta’s server

§ Taker views the Maker orders and order is placed with the smart contracts

o Orders placed on relayers offchain o Orders are ordered synchronously, or FIFO o Can’t match orders automatically o The core logic of EtherDelta uses smart contracts

§ Coded in Solidity (ETH coding language) · Compiled down to Ethereum Virtual Machine (EVM)

instructions o Funds are moved to a smart contract and funds are pooled together o Below code is the code to deposit/withdraw ETH and ERC tokens

Page 11: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

DEX and Protocols and Blockchains

· DEX sit on top of a single blockchain · It is important to understand the blockchain itself · Why is it that most DEX are Ethereum based? · The underlying mechanics requires a smart contract, which is not offered on some

blockchains o I.e. Bitcoin

· Until atomic swaps become a more ubiquitous technology, DEX will function on Ethereum or other smart-contract enabling blockchains such as EOS

Blockchains Overview

Ethereum · 2014 · Smart contract platform · Proof of Work (PoW) · 50-100 TPS

NEO

· 2017 · Smart contract platform · NEO is close with the Chinese government · Partners include Fenbushi

EOS

· 2017 · Smart contract platform · Delegated Proof of Stake (DPOS) · Graphene technology · 10,000-100,000 TPS · Near zero fees · Partners include Block.one and Blockchain Capital

Fantom

· 2017 · DAG

Altcoin.io

· https://youtu.be/1wAbCnD-M_I

Protocols Overview

· 0x · R1 · Lighting Network / Raiden Network

Page 12: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Ethereum

· Ethereum Virtual Machine (EVM) o The Ethereum Virtual Machine (EVM) is the computer that all full nodes in

the Ethereum network agree to run. When there is code / data on the blockchain, consensus is needed to agree on what that code does. Everyone agrees on how the EVM should behave, and everyone has the same data on the blockchain, so everyone will compute the same answers. From this perspective, it looks like a single World Computer leading to that description

o The virtual machine is just fancy talk for scripting language. If you've studied Bitcoin, you could say that the Script language built in Bitcoin's code is the "Bitcoin Virtual Machine". It just happens that it is not Turing complete, as the Ethereum scripting language is Turing complete and has higher capabilities (albeit at the cost of more complexity)

· Smart Contracts · Decentralized Apps

· Ethereum yellow paper

o https://ethereum.github.io/yellowpaper/paper.pdf · Geth - Written in GO (9,500 nodes) · Parity (4,000 nodes) · Solidity is used to write smart contracts · Background process running on the computer

o Communicate with other peers on the network § Will behave like P2P, syncing § Some are miners, some just host copy of blockchain § Anyone can code programs on it on this decentralized server

· But in order to run, need to pay in ETH · JSON RPC

o Send web dictionary to the background and sends back JSON with information

· RPC Connection o Remote Procedure Call o Call made and returned

· Computers and nodes are connected globally through RPC o They share the ledgers with each other o The processors run independently, but share their findings via RPC o So 1 RPC connects with another computer and that computer is connected to

another computer o But the shortcoming for blockchain is the bottleneck created by the

synchronous, sequential block creation o Also, Bitcoin creates a new block every hour, so it will be almost impossible

to create a DEX on the Bitcoin chain, plus there is no smart contract run by a Turing complete virtual machine on Bitcoin

http://solidity.readthedocs.io/en/v0.4.24/introduction-to-smart-contracts.html

Page 13: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion
Page 14: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

NEX

Neon Exchange (sounds similar to R1 protocol as far as matching offchain)

· Publicly verifiable offchain exchange · Matched offchain · Redistributed onchain back to users · Offers limit, market, margin on NEX

EOS Neon Exchange (sounds similar to R1 protocol as far as matching offchain)

· Publicly verifiable offchain exchange

Fantom (DAG; directed acyclic graph)

· Scaling issues o Bottleneck with the sequential, synchronous o Linked list

· DAG uses a different data structure

o Kind of like a flowchart that follows only 1 direction o Everything doesn’t have to be sequential, can run parallel

· IOTA

o Removes miners completely o Everyone is essentially a miner o Everyone is validating previous transactions to validate their transaction

§ Consenus issue with 8 miners controlling Bitcoin mining · Whereas all IOTA users must mine

o IOTA made their own cryptography and MIT team found issues on cryptopgraphy

o 33% for control

· Traditional blockchain is done synchronously

· Lachesis protocol divides blocks into smaller blocks, asynchronously, parallel

· Opera chain is divided between core and ware layer

Page 15: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

0x Protocol

o https://github.com/0xProject/whitepaper/blob/master/0x_white_paper.pdf o Users interface with the decentralized apps (dApps), which then interfaces

with the blockchain o o Aim of project is to provide open protocol for DEX on top of Ethereum

§ ETH needs to be in their wallet · ETH changed into WETH, or ERC-20 token

§ Easier to settle with other ERC-20 tokens o Matching efficiency is not high because of constant monitoring of wallet

balance and may create counterparty risk/transaction failure if high volume affects the network

o the team at 0X claims to solve one of the most infamous issues about the dApps — interoperability

Page 16: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

1. Both Maker and Taker allows DEX to to access their Metamask accounts

a. Fund is stored on Ethereum chain 2. Maker sends order + signature to a centralized server 3. Relayer

· Manages the offchain orderbook o Centralized server

4. Taker sees the order and sends order + signature to smart contract 5. Exchange’s smart contract on the ETH blockchain authenticates the signatures and transfers tokens

Page 17: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

R1 Protocol

Page 18: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Lightning Network/Raiden Network

· https://www.youtube.com/watch?v=rrr_zPmEiME · https://www.youtube.com/watch?v=UYHFrf5ci_g · https://www.youtube.com/watch?v=UYHFrf5ci_g · Visa 4,000 TPS · Bitcoin 7 TPS · Not scalable at such a low TPS

o Scalability issue Scalability Solution - Payment Channel

· Payment channel created between 2 parties · BTC deposited into an account, off-chain · Until the BTC is used up, or either party disconnects from the payment channel,

technically can do numerous transactions offchain and just maintain the balance Lightning Hubs

· Essentially like nodes, but these are a central point of contact for payment channels o One person postulates that financial institutions will be the ones who control

the Hubs, thereby centralizing bitcoins (probably a Bitcoin Cash proponent) Blockstreams’ Role in Bitcoin Protocol

· Blockstream plan to make profit by making sidechains to businesses · Controls Bitcoin core · Profits from developing sidechains · Send BTC to a Sidechain

Bitcoin Core

· As of 2018, Bitcoin Core repositories are maintained by a team of maintainers, with Wladimir J. van der Laan leading the release process

· Gavin Andresen was the previous main developer Bitcoin Core vs Bitcoin Cash

· The split between Bitcoin Core and Bitcoin Cash was the block size o Bitcoin Cash wanted to increase the block size, but Bitcoin Core wanted to

keep the 1MB cap, and implement SegWit · Satoshi supposedly wrote to allow the block size to grow from 1 MB to what is

necessary o Originally, the size had no limit, but some malicious users could send huge

block sizes, which is a form of Denial of Service (DoS) attack · However, Bitcoin Core developers decided against the block size increase, which is

why Roger Ver decided to make Bitcoin Cash · Transaction fees on Bitcoin Core went up to $20 vs $0.001 for Bitcoin Cash · Roger Ver’s accusation is Bitcoin Core developers are forcing people to adopt the

Lightning Network, which is where Blockstream can make money by charging fees · “Scaling by increasing block is a dead end”

Segwit · Bitcoin Core adopted Segregated Witness, or SegWit.

Page 19: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

· Most of the data in a block is comprised of data to verify the signature data, so the change would remove the signature data in an extended block

Page 20: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Interoperability Side Chains

· Ethereum can only handle 15 transactions per second. · One project that leverages heavily on side chains is Aelf. According to their white

paper, Aelf is a multi-chain cloud computing blockchain framework. · Proof of Work (PoW), each node races to solve a problem. · Competitive consensus algorithm, losers of the hashing waste energy and money, so

nodes started to work together to solve a problem and share the reward based on computational power.

· Co-operative consensus algorithm, fixed number of votes and if the majority agree on the value of the data, then system works.

o Can handle 30,000 TPS · Aelf uses Delegated Proof of Stake (DPoS)

· For example, let’s say we have side chain 1 (SC1) and side chain 2 (SC2). A transaction occurs on SC1. A node in SC1 broadcasts the transaction to nodes in the main chain to record this transaction. The same node of SC1 calls a function from SC2 with a proof. The function in the nodes of SC2 verifies the proof on the main chain. The function gets executed.

Page 21: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Atomic Swap

· An atomic swap is atomic in the sense that if the swap isn’t successful, neither party loses out. The swap takes place or it doesn’t — there are no half measures

· There are two kinds of atomic swap: on-chain and off-chain. On-chain swaps are great, but off-chain swaps take this concept to another level as they’re nearly instant, private, and require almost zero fees

· Both kinds use hashed-time-locked-contracts, or HTLCs · If neither or only one of them confirms the code within a set timeframe, both sets of

coins return to their original owners and the exchange is cancelled. · The principle is similar with atomic swaps. If one person is out of sync or doesn’t turn

their key, nothing happens (and their coins are returned). But if both do as they’re supposed to, the vault opens, and each gets their new coins.

On-chain Atomic Swap (same blockchain)

· On 19th September 2017, Decred completed the first on-chain atomic swap between Decred and Litecoin.

On-chain Atomic Swap (different blockchain)

· On October 7th 2017, Altcoin.io completed the first Ethereum to Bitcoin atomic swap. · 2-3 minutes to confirm · https://blog.altcoin.io/the-evolution-of-atomic-swaps-e33ad3af8818

Off-chain Atomic Swap (different blockchain)

· On 16th November 2017, Lightning Labs confirmed the world’s first off-chain atomic swap over the lightning network.

Page 22: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Blockchains are really supercomputers

· IBM’s Watson, and other supercomputers are centralized, owned by a certain entity or company

· However, blockchains are decentralized supercomputers, where the combined computing power of all the nodes in itself would have the computing power of a supercomputer

o Bitcoin is essentially a large supercomputer DB o Ethereum is a large supercomputer processor

Metamask

· Metamask is a plug-in on the browser which connects directly with the Ethereum blockchain

· Allows user to connect with Ethereum blockchain, without being a node · Acts as Ethereum wallet

o If someone finds the secret words, can authorize Metamask to send the funds in the Ethereum blockchain wallet to another wallet

· MetaMask injects a javascript library called web3.js into the namespace of each page your browser loads. web3.js is written by the Ethereum core team, and has functions that regular webpages can use to make read and write requests on the blockchain that are consistent with the existing protocol

· Furthermore, MetaMask allows users to specify which Ethereum node to send these requests to. The ability to send requests to nodes outside of the user’s computers is important because it means that people can use Ethereum without having to download a node consisting the 10+GB blockchain on to their computers

· It allows you to run Ethereum dApps right in your browser without running a full Ethereum node.

· Once you create a password, the Ethereum blockchain makes a unique wallet linked with the email address that is used to login to Chrome, or some other supported browser

o Typically, one needs an email address and password to login to exchanges, so the login/registration is taken care of by Metamask

· Ethereum based dApps, through Web3 API, goes through Metamask, to connect with the Ethereum blockchain

Nodes

· https://news.bitcoin.com/cost-full-bitcoin-node · Bitcoin’s health largely depends on how many people run the decentralized peer-to-

peer network globally by participating as a ‘Bitcoin node,’ which vary in size. A node might represent a single individual with a laptop, a company running a single node for mostly symbolic purposes or even a massive Bitcoin mining farm harnessing a large percentage of Bitcoin’s overall hashing power. In short, Bitcoin nodes keep the Bitcoin blockchain’s peer-to-peer network running.

Page 23: Review of Decentralized Exchange (DEX) July 12, 2018 · 2018-07-12 · Decentralized Exchange Overview Why transition from Centralized to Decentralized Exchange (DEX)? · $4 billion

Bancor, a DEX, was Hacked?

· Bancor is an Israeli based “decentralized exchange” · Raised $153 million in ICO in 2017 · ERC-20 token which allows one to convert to another ERC-20 token

· How is it that a DEX was hacked?

o A wallet which is linked to a smart contract was compromised. § Stole Bancor coins and ETH

o Bancor coins can be frozen, but the ETH was $12.5 million

· Technically, only the “exchanges” wallet was hacked o Not the customers’ funds

· Somebody probably found the private key of the wallet