The Lay of the Land in

Decentralized Exchange Protocols

DED_1.png
 
 

By Deepa Sathaye 

 

In the rapidly developing digital currency landscape, decentralized exchanges have occupied perhaps the most aggressively growing sector. In short, decentralized exchange eliminates the third party service, as used in centralized exchanges, that holds a customer’s funds. In doing so, customers transact directly with one another (peer-to-peer) through an automated process, eliminating the risk of security breaches, reducing service fees, and restoring greater autonomy over one’s funds.

In this article, I’ll compare and contrast recently launched decentralized exchange designs with what we’re building here at AirSwap, and discuss the main differences of each.

Some of the projects I’ll look at do not market themselves strictly as decentralized exchanges. I’m including them because they provide some of the same services discussed or merely that a decentralized exchange is part of their design pattern. Before I can start comparing the aspects of the decentralized exchanges, I’ll be using traditional financial markets as the baseline. Just in case, a refresher:

Modern markets use central limit order books (CLOBs) as their trading mechanism. The first term, “central”, meaning that all the matching takes place in one location, meaning that everyone has to submit and retrieve their information from one geographic place.

The next phrase, “limit order,” describes a type of customer order that can be placed on exchanges to buy or sell an asset. A limit order means that there is an explicit price associated with a customer order, and that the exchange has an obligation to match this order with the limit price (price on the limit order) or a better price.

The last word — “book” — describes a record keeper and is, as mentioned, a record keeper of the limit orders. A CLOB, in most cases, uses price-time priority, meaning that orders that occurred with a better price are matched first, and then matched based on insertion time.

Now that I’ve talked a bit about what a CLOB is, I’ll discuss specific roles that participants in an order book can take, specifically “makers” and “takers”. Makers, usually called market makers, are parties that facilitate trading by competing for customer orders by placing limit orders. A taker is someone who pays to trade with these makers and therefore are “taking” liquidity from the market. I’m going to use this as a main comparison tool for decentralized exchanges.

 

Bancor

“On chain execution, automated pricing, through market orders

Bancor.png

Bancor doesn’t market itself as an exchange, though the platform does provide some of the same services as many exchanges, such as price discovery and a liquidity mechanism. Price discovery is the process of determining a price of an asset in the market through interactions between buyers and sellers. Liquidity refers to how easily an asset can be bought or sold in a market. Bancor wants to solve the challenge of providing price discovery and liquidity, without requiring high levels of trading activity (volume) like traditional services.

The Bancor Protocol is a smart contract based token exchange protocol. The smart contract is called a “Smart Token” and this contract, also conforming to the ERC20 token standard, stores balances of reserve ERC20 tokens/Ether and has logic to allow for constant updates to prices and permit token exchanges. There is no CLOB. Instead, this smart token acts like a market maker by automatically providing trades to takers.

To exchange a token through this system, there are two steps. Step one is to purchase the smart token with your selling reserve token. The second step is to liquidate the smart token to release the token that you want to hold. Below I’ve walked through an example for how to exchange 1ST for STORJ, which are two ERC20 tokens:

For my base example of trading 1ST for STORJ, I would need to find a smart token that holds both of these tokens on reserve, which I’ll name “1ST_STORJ_RESERVE”. I’ll buy this reserve token using 1ST, which will input 1ST quantity into the smart token and adjust the price between 1ST/STORJ based on Bancor’s pricing formula detailed in their whitepaper. Next, I’ll need to sell the “FIRST_STORJ_RESERVE” for STORJ, which in the background is destroying this smart token amount within the smart contract, and then releases STORJ to you.

Workflow for Bancor exchange: 1. Taker finds contract (smart token) and purchase reserve token, 2. Taker sells reserve token for desired token

Workflow for Bancor exchange: 1. Taker finds contract (smart token) and purchase reserve token, 2. Taker sells reserve token for desired token

What’s the difference between Bancor and AirSwap?

  • Bancor calculates price on-chain via an Ethereum smart contract. AirSwap uses private, off-chain price negotiation.
  • Bancor users interact directly with Bancor smart contracts (centralized price discovery), while AirSwap is peer-to-peer (decentralized pricing)
  • Bancor utilizes a smart contract as the built-in market maker, while AirSwap relies on peer-to-peer negotiation and only uses the smart contract to fill orders.

 

0x

“Multiple off chain limit order books, on chain execution”

0x.jpeg

0x markets itself as a protocol for trading ERC20 tokens that specifies an “off-chain order relay with on-chain settlement.” The off-chain component, called a “relayer,” handles the storing and updating of an order book without executing any trades. Similar to a traditional exchange, both buyers and sellers can post their orders. However, because a relayer is not automatically matching orders, it is up to the taker to access a relayer that has a matching maker order and then fill the maker’s order. Filling the order is where the on-chain settlement component comes in at which point takers will need to submit their orders to the 0x exchange contract. Note, there may be multiple relayers, so there are options for where a maker can list and where a taker can look for orders. In addition, 0x does provide a schema for doing point-to-point orders if a taker already knows a maker that they’d like to transact with.

A user can interact with the 0x protocol as a maker or a taker. Makers post an order to a relayer, while takers send the order to the Ethereum blockchain. Price discovery occurs through their relayers and takers can choose which maker order they would like to trade with. The smart contract executes the exchange between ERC20 tokens.

Now let’s walk through an example in which I’d like to trade 1ST for STORJ as a taker. I’d need to check the relayers to see if there are any orders for FIRST/STORJ. If there are, then I’ll choose to take the existing order from the relayer and submit it via the 0x exchange contract. If not, I can instead become the maker. First I’ll post my order to a relayer of my choosing, which will occur off-chain. I’ll post my order and wait to see if someone wants to match with my order. In either case, one party will take the fully signed order and submit it to the exchange contract to initiate the actual transfer. With 0x, it is possible if you are a maker that only a portion of the amount that you’d like to trade will be filled, which is similar to regular markets, and you’ll have to wait for others to fully trade your order.

Radar Relay is a current implementation of the 0x order book.

Workflow for 0x token exchange: 1. Maker posts a signed order to Relayer, 2. Taker queries the Relayer 3. Taker selects an order to match, 4. Taker submits order to exchange via smart contract

Workflow for 0x token exchange: 1. Maker posts a signed order to Relayer, 2. Taker queries the Relayer 3. Taker selects an order to match, 4. Taker submits order to exchange via smart contract

What’s the difference between 0x and AirSwap?

  • 0x specifies public off-chain limit order books. With AirSwap, counterparties discover each other through an off-chain service known as an Indexer, and subsequently negotiate orders directly peer-to-peer.
  • When a maker submits an order to a 0x relayer, they do not specify a particular taker, while with AirSwap each order is for a specific taker.

 

KyberNetwork

“On-chain limit orders for makers, market orders for takers, on-chain execution”

Kyber.jpeg

KyberNetwork is an on-chain protocol that allows for instant trading and payment services. KyberNetwork provides instant liquidity in a trustless fashion because the bulk of the product is based on smart contracts. The platform is able to provide instant liquidity to takers, who have the opportunity to check the exchange rate before submitting their tokens to trade. As counterparties to the takers, KyberNetworks also manages several makers, known as KyberReserveEntities and token contributors. KyberReserveEntites act like the market makers in that they initially submit their proposed exchange rate with some reserve quantity. The KyberReserveEntities are not serving a specific user, but instead the KyberNetwork is responsible for the matching and determining whether a user and the KyberReserveEntitiy should exchange.

There is no limit order book that the taker is able to see. Instead, KyberNetwork manages the makers and will handle the matching itself, choosing the best price through the list of makers. Makers need to be registered with the KyberNetwork to list token pairs and make updates to the exchange rates. The funds for the market makers are stored in reserve contracts, and not on the KyberNetwork.

How would you do the 1ST for STORJ trade? As a user, all your interactions will be through the KyberNetwork contract. First, you must check the exchange rate via an API call. Then, if the exchange rate is acceptable, you’ll send your 1ST into the KyberNetwork contract which is running on Ethereum, and it will give you STORJ at the agreed upon exchange rate. All actions are being run through the Ethereum blockchain, including updates to the exchange rate by reserves.

Workflow for Kyber token exchange: 1. Makers post their exchange rates and size information to a smart contract 2. Takers query this smart contract for instant exchange 3. Exchange update occurs notifying both maker and taker

Workflow for Kyber token exchange: 1. Makers post their exchange rates and size information to a smart contract 2. Takers query this smart contract for instant exchange 3. Exchange update occurs notifying both maker and taker

What’s the difference between KyberNetwork and AirSwap?

  • Kyber uses smart contracts to manage makers and service takers, while AirSwap uses the smart contract only when orders are to be filled.
  • Makers are managed through Kyber and need to be registered, while with AirSwap makers merely need to add their intent to trade via the Indexer.
  • Users primarily interact with Kyber through a smart contract, while with AirSwap makers and takers interact in a peer-to-peer fashion.

 

AirSwap

“Off-chain negotiation, on-chain settlement”

AIRSWAP_Layofland.png

AirSwap is a decentralized exchange platform that implements the Swap protocol, a peer-to-peer protocol for trading Ethereum-based (ERC20) tokens. AirSwap does not contain a traditional order book, but instead individuals solicit quotes from each other in a peer-to-peer fashion through off-chain negotiation. Counterparty discovery is done through an “indexer” component. The Indexer contains information regarding which token-pairs individuals would like to trade. Users are able to post and query the Indexer to find suitable counterparties.

With AirSwap, you can interact either as a maker or a taker. The taker will initiate the negotiation with the maker. Also, the taker submits an order to the AirSwap exchange smart contract on the Ethereum blockchain. The maker is responding to requests from takers and negotiating prices with them off-chain.

For the base example of trading 1ST for STORJ as a taker, I would first need to find a counterparty to trade with through the Indexer. I would query the Indexer, off-chain, 1ST for STORJ and it would respond with maker addresses who had previously posted matching “intent to trade”. I’d privately negotiate a price and quantities with the individual makers, and then ultimately agree on a price. From there, I’ll submit the order through the AirSwap exchange contract where the exchange can occur atomically.

Workflow for AirSwap token exchange: 1. Maker posts a token pair as “intent to trade” 2. Taker queries the indexer for token pair 3. Taker fetches counterparty from Maker 4–5: Maker and Taker directly negotiate a suitable trade 6. Taker submits order to smart contract for execution

Workflow for AirSwap token exchange: 1. Maker posts a token pair as “intent to trade” 2. Taker queries the indexer for token pair 3. Taker fetches counterparty from Maker 4–5: Maker and Taker directly negotiate a suitable trade 6. Taker submits order to smart contract for execution

Workflow for AirSwap token exchange: 1. Maker posts a token pair as “intent to trade” 2. Taker queries the indexer for token pair 3. Taker fetches counterparty from Maker 4–5: Maker and Taker directly negotiate a suitable trade 6. Taker submits order to smart contract for execution

What are some of the key features of AirSwap?

  • AirSwap uses an off-chain solution known as an Indexer for counterparty discovery instead of using order books.
  • AirSwap allows takers to request quotes from makers and and subsequently can privately negotiate a price.
  • An exchange smart contract handles the token exchange.

In Summary

Each project has utilized different approaches to how Ethereum-based tokens and Ether can be exchanged. In all cases, the actual exchanging of Ethereum based tokens occurs within a smart contract and relies on the Ethereum network to make the exchange. For 0x and AirSwap, users keep control of their funds because token exchanges occur directly between the two parties without having to be held with an intermediary. With projects like Bancor and Kyber, market making is done via a smart contract allowing for immediate exchange by users. Individual users must take the exchange price calculated through the smart contract though. 0x has multiple limit order books where users can find existing orders to trade with or post an order and rely on another to find a match. AirSwap has built a counterparty discovery mechanism called an indexer, and from there, price discovery occurs through negotiation.

As with any exchange, the value will ultimately come from the consumers’ trust, use, and the ability to remain robust and relevant in an ever-evolving market. Decentralized exchanges, like the ones addressed above, are positioned uniquely to be able to meet these criteria. With AirSwap, we’ve decided to uniquely focus on peer-to-peer, and are directly addressing two problems that occur in a peer-to-peer trading environment — counterparty discovery and pricing suggestions — in a globally secure, scalable platform.