All hands on DEX!

4 min read

Decentralized EXchanges might not be the smooth sail you think.

With crypto, it’s always full steam ahead toward decentralization — Decentralized EXchanges are no exception.

Carried by the hype, decentralized exchanges (DEX) claim to replace centralized exchanges (CEX) with decentralized tools instead of a single entity. To trade free of any governmental and regulatory involvement and zero counterparty risk, sounds pretty sweet right?

To better understand DEXs, let’s first take a closer look at trading.

Why do we need the middleman?

Let’s say I want to trade 1 Bitcoin for 100 Litecoins with my counterparty. We’ve agreed on price. But, neither one of us wants to risk sending their coins first.

The “who goes first” deadlock stalls the trade: if I send my Bitcoin first, who’s to say I will receive the agreed amount of Litecoin? With similar FUD, the Litecoin holder counterparty doesn’t want risk kicking off the trade.

For the trade to happen at all, somebody has to take that leap of faith.

Middlemen exist to avoid such cases.

Fortunately for traders, middlemen have come up with trading tools to bypass the need for trust. On an exchange, fancy order books with clear bids and offers automatically match trades in real-time between thousands of traders.

Moreover, the “who goes first” deadlock has long been solved by placing assets in escrow on the exchange. Should the trade fall through, funds in escrow will be returned to their owner.

Placing funds in escrow works because:

  1. Instead of a random counterparty, you trust a known entity: a registered, regulated exchange.
  2. Since the exchange collects a cut from each trade in the form of fees, it cares for repeat business. Thus, it is in the exchange’s own interest to protect each party’s welfare and facilitate the trade.
  3. In case of misconduct, you can seek legal recourse through the exchange with which the funds are in escrow.

While this model has been implemented since the early days of Bitcoin, crypto enthusiasts want to take it one step further by decentralizing the exchanges themselves.

Flipping the table: the crypto way to upgrade.

How would DEXs work?

Like their centralized peers, DEXs are supposed to safely and securely support trades without trusting anyone — not even them! 
Such claims entail the following questions:

  1. How can I avoid the “who goes first” deadlock without trusting anyone — neither a random counterparty, nor an entity backing my funds?
  2. How about the exchange’s trade matching system and live order book? Are those still in play without trusting the DEX? Does full decentralization imply the whole system is trustless?

To answer those, let’s address the two main claims upheld by DEXs.

  1. DEXs support a trustless exchange of digital assets
  2. DEXs provide a trustless trade matchmaking system

First Claim: DEX support a trustless exchange of digital assets

“Trustless” entails you can trade your assets with someone else while avoiding both the “who goes first” deadlock and placing funds in escrow with the exchange.

From a traditional perspective this might sound like magic, but a handy crypto technique known as an Atomic Swap has partially solved this puzzle.

– Alice owns 100 LTC and Bob owns 1 BTC
– Alice and Bob want to trade their coins
– Both agree on 1 BTC = 100 LTC

– Bob should send 1 BTC to Alice
– Alice should send 100 LTC to Bob

How the Atomic Swap works:

  1. Alice picks a random number R
  2. Alice calculates the hash of R and calls it H
  3. Alice makes a transaction to send 100 LTC to Bob and attaches H to it, with the condition that R should be revealed. This is the basis of a Hash Time Locked Contract (HTLC) .
    Note: there is no way to calculate R from H since H is a result of a hash, a one-way function.
  4. Bob makes a transaction to send 1 BTC to Alice and attaches the same H to it, with the condition that R is revealed
  5. Provided that Alice reveals R, the conditions for both transactions are satisfied and the swap will automatically execute. Hence the designation “Atomic Swap”.

But, Atomic Swaps have a flaw in their seemingly smooth execution.

Having chosen it, Alice knows R, which she’s required to communicate to Bob for the transaction to execute (for Bob to receive Alice’s Litecoin and Alice to receive Bob’s Bitcoin).

Therefore, prior to giving R to Bob, Alice can check the price of LTC against that of BTC for recent fluctuations. If the price of BTC goes down, Alice might withhold R from Bob to have their transaction expire.

By taking advantage of the steps outlined for the HTLC, Alice earns a call option. Alice can choose whether to go through with the trade, while poor Bob is completely dependent on Alice’s decision. He has to wait for Alice to decide if and when to reveal R in order to get his Litecoins. 
Although aware of the flaw, dubbed the “inadvertent call option”, exchanges consider it inevitable.

Through Atomic Swaps, the “who goes first” deadlock reverses: everyone wants to be the trader kicking off the trade to enjoy the inadvertent call option.

In the real world, and especially with serious traders, the possibility of a call option wrecks the fairness and efficiency of the trade. Since the second trader have to trust their counterparty will reveal the hash, DEXs fall short on their promise of trustless trades.

Second Claim: A Trustless Trade Matching System

Often accused of front-running and fake volume, exchange operators have a reputation for keeping valuable information from their users. By being decentralized, the ideal DEX promises all the transparency traditional exchanges lack.

Let’s say we have this super complex smart contract managing the DEX’s order book. First of all, only Ethereum — or one of its runner-ups— would have the depth to support such a smart contract.

Second, combine an average exchange brokering around 1 million trades per day, plus the archiving issues of smart contracts, plus the scalability constraints inherent to a blockchain…No way that such a complex system can sustain.

Blockchain tech comes in all shapes and sizes, but magical it is not!

DEX are a cool solution — on paper

A decentralized, functional protocol is much harder to achieve than most are willing to admit. Unanswered questions and unknown unknowns are glossed over by the media and crypto startups pushing the narrative. In too deep, exchanges can’t back out after promising full decentralization to their investors.

DEXs have rough seas up ahead.

Don’t worry about exchanges killing their golden goose business model: no one, Binance included, is getting away with DEXs. Planning to go decentralized is, best case scenario, a show of how “up-to-date” an exchange wants to appear. Worst case scenario, it’s a ploy to pillage and plunder that sweet ICO money.

While a truly trustless, decentralized exchange could be the future of crypto, it certainly is not the present.

For more crypto industry and bitHolla news, check us out on Facebook, Twitter, LinkedIn and our website!


bitholla Team
6 min read

The Exchange Story

bitholla Team
4 min read

Leave a Reply

Your email address will not be published. Required fields are marked *