Ecosystem of Decentralized Exchanges

Understanding the spectrum of decentralized exchanges and market mapping

With the recent hype of cryptocurrencies, many have decided to invest in a variety of coins, often without thinking about the mechanism through which they are buying and how it fits into the larger ecosystem. Exchanges are instrumental to the movement of cryptocurrencies.

In this post, I aim to distinguish between centralized and decentralized exchanges, and map the exchange ecosystem. Contrary to the popular use of the words centralized and decentralized, exchanges are not binary. In fact, there are a number of variables that exist on a spectrum from complete centralization to complete decentralization. To truly understand whether an exchange is centralized or decentralized, one must consider all of these variables. Currently, more than 99% of cryptocurrency transaction volume goes through centralized exchanges.

Centralized Exchanges

If you have ever bought any cryptocurrency using websites such as Coinbase, Gemini, Poloniex, Kraken, you have used a centralized exchange. This simply means that you have purchased cryptocurrencies using a traditional method of payment such as a credit card or wire transfer.

A centralized exchange is a platform or app that allows traders to buy or sell cryptocurrencies using fiat or other cryptocurrencies. It is a marketplace for tokens, and many centralized exchanges allow new entrants / non-crypto holders to buy crypto using USD, EUR, etc. Users directly deposit money into the exchange, which holds money as a wallet until a trade order is placed. Exchanges keep their systems off-chain, which means that transactions are not recorded on the blockchain. As orders are placed, the exchange matches buy and sell orders in real-time.

The key here is that when you deposit money or trade on such an exchange, you don’t hold the private keys to those cryptocurrencies. Currently, 73% of centralized exchanges take custody of user funds, while 23% let users control keys. Instead, similar to a bank, you trust the exchange to safely store and manage your balances.

While there is certain a level of assurance with storing your cryptoassets with a centralized exchange, there are also fundamental risks associated with doing so:

Fraud can result in the loss of users’ funds: centralized exchanges are legally accountable for users’ funds, but have often been susceptible to theft Front-running by the exchange administrator or related party Concentrated liquidity on a few exchanges: exchanges such as Coinbase, that list only a few coins, can take advantage of their large user base. Whenever coins are added, they will gain traction from the public and rise in value — this is particularly appealing when entry prices are lower compared to Bitcoin

Decentralized Exchanges

In a perfectly decentralized exchange, users would have control over their funds. The aim of a decentralized exchange would be to build a peer-to-peer marketplace directly on the blockchain. Money is not sent to an exchange or wallet that is controlled by a single platform or entity: instead, orderbooks and transaction activity take place on the blockchain. As a result, there are no middleman fees, assets are not susceptible to hacks, and users are truly in control of their assets.

It is important to note that most decentralized exchanges out there are semi-decentralized. In most cases, centralized servers (off-chain) host order books, but do not hold private keys. When orders are settled on-chain, they go through the blockchain, ensuring that the exchange possesses its characteristics, benefits and limitations. There are four distinct buckets of decentralized exchanges: exchanges, P2P trading, dark pools, and open protocols for DEX.

I. Exchanges

Decentralized exchanges can typically decide whether their orderbooks are located on or off-chain. However, it is key that orders are settled on-chain. In some cases, when an order is place, there may be a relayer or orderbook that facilitates the matching process. Users are in control of their own funds and data; however, there are clear trade-offs.

On-chain trading: users are in control of their own funds and data, but on-chain trading can be a tedious process. Orderbooks: an on-chain orderbook means that miners are privy to an order before it is posted, which creates an opportunity for front-running. Blockchain orderbooks do not scale as executing code on blockchain incurs a cost, thus changing or cancelling orders can quickly become expensive. Front-running by miners or relayers: as orders are settled on-chain, miners will have the option to execute cancelled orders with themselves as the counterparty (in addition, the miner may even collect gas costs from a user’s failed cancellation). Automatic matching: in cases where orders are matched off-chain, it is possible that the exchange does not perform automatic matching and thus the exchange can suppress or front-run orders. Liquidity: due to a lack of users, there is a lack of liquidity, which can cause a more volatile market and radical change in prices particularly when large orders are placed. Cross-chain orders: majority of decentralized exchanges currently support trading of Ethereum based or ERC-20 tokens, but lack the ability to support cross-blockchain orders (for example, trading or operating over the Bitcoin, Litecoin, etc. networks). The reason for this is that it is hard for two chains and orderbooks to communicate with each other when they don’t otherwise know about each other.

II. Peer-to-peer Trading

Peer-to-peer trading eliminates the need for an orderbook, as users directly connect with one another via nodes to place trades. There is no middleman or orderbook facilitating the matching process. Price negotiation can take place either on or off-chain, but it is key that trades are settled on-chain.

On-chain trading and live nodes: in a peer-to-peer system, users must stay online until their orders have been filled, as they drive the matching process. An order cannot simply be placed and left for the relayer or exchange to fill. Lack of orderbook: the lack of an orderbook minimizes the opportunity for front-running as miners will not have insight into orders before they are posted on the blockchain. Front-running and automatic matching: because there is no orderbook, this minimizes the risk of front-running orders. Peer-to-peer exchanges have adopted protocols that ease the process of automatically matching makers and takers. Liquidity: due to a lack of users, there is a lack of liquidity, which can lead to a more volatile market. Cross-chain orders: peer-to-peer exchanges that have adopted atomic swaps allow for cross-chain trading to take place. Atomic swaps use a hash time-locked contract, which basically open up a payment channel between two blockchains. It is important to note that this is not exhaustive — not every blockchain supports this, and implementation of Lightning Network is necessary.

III. Dark Pool Exchanges

Dark pool exchanges typically operate with a hidden orderbook. Orders are matched without revealing the identity of the trader or the underlying trade until settlement, which is beneficial for trustless trading large block orders. In addition, because a “hidden orderbook” exists, traders do not have to remain connected to the network while their orders are being matched. Once an order is placed, nodes will run the matching computation until a match is found or the order is expired — direct connections between nodes are setup when possible or if needed.

On-chain trading: users are in control of their own funds and data, but on-chain trading can be a tedious process. Hidden orderbook: a hidden orderbook would allow orders to be matched without revealing the identity of traders, and allow large block orders to go through without causing volatility in the market. Front-running: as the orderbook is hidden, this minimizes the risk of front-running orders. However, if this information were to be exposed, the exchange and traders would be susceptible to front-running and node attacks. Liquidity: because there is lack of users on these exchanges, there is a lack of liquidity in carrying out transactions. Cross-chain orders: exchanges that have adopted atomic swaps and lightning network allow for cross-chain trading to take place.

IV. Open Protocols for Decentralized Exchanges

Open protocols are infrastructure that allow anyone to build their own services on top of them, with the aim of running a decentralized application: protocols are the pipes to hold your decentralized application.

In the case of decentralized exchanges, open protocols aim to allow all projects built on top to interact with one another, thus creating shared liquidity for the exchange. For example, there are numerous relayers (decentralized exchanges) built on top of the 0x protocol.

Ecosystem of Decentralized Exchanges

Below is an overview of the projects and startups currently in the space that fit into various categories (this is by no means an exhaustive list). Note that projects with a * indicate cross-chain or fiat support, while the remainder are focused on ERC20 tokens.

Centralized exchanges with an off-chain orderbook and off-chain settlement mechanism include examples such as Coinbase, Gemini, Kraken, Binance.

Decentralized exchanges with on-chain settlement and either an on or off-chain orderbook include IDEX, NEX, Barterdex, Legolas and a variety of 0x relayers (e.g. RadarRelay).

P2P trading ranges from centralized examples such as ShapeShift, to more decentralized options where settlement takes place on-chain. Examples include Airswap, Altcoin.io, Bisq, Etherdelta, KyberNetwork, and Bancor.

Open protocols allow developers to create their own decentralized exchanges on top of their infrastructure, increasing liquidity. Examples include 0x, Loopring, OpenRelay, Lendroid, Swap, Heridus, Blocknet and Bitshares.

Examples of dark pools, which provide hidden orderbooks, include Republic Protocol and OmegaOne.

Summary

Given the current players in the ecosystem, there are a few key components to keep in mind when designing an exchange: