Exploring The Decentralized Exchange Impossibility and Solutions

Decentralized Exchanges (DEX), are a hot topic in the bitcoin community, with many touting them as the ultimate solution to enable global hyperbitcoinization.

As we go through the purpose and history of exchanges, we shall see that a DEX that merely removes centralized custody and settlement is not enough. A true DEX is theoretically impossible even when assuming decentralized custody is completely solved. This is because decentralized liquidity, requires distributed matching engines and order books. Reality Arbitrage is presented as a possible solution that disrupts the current centralized exchanges, and is inspired by the invention of linked-timestamps, the precursor to the Bitcoin Blockchain.

With so many DEX projects coming on-line, lets first ask: What is an exchange?

Exchange

Say you are interested in buying Altcoin with ticker ALT. You interest is in owning ALT itself, either as an investor or a user. In contrast to a trader, who does not care about owning ALT, but is just trading to earn more profits in Bitcoin.

You are holding Bitcoin and want to purchase Altcoin; the price ticker is ALTBTC. To do this, you need to first find someone holding ALT, who wants bitcoin, and is willing to sell it to you. You can put adds on craigslist, ask friends, or post on social media. Better yet, what if there is a “central” place where everyone goes that wants to trade ALTBTC?

An Exchange, is like a marketplace, a physical or virtual place where like-minded people go to buy or sell financial assets.

One of the earliest “exchanges” was the Tontine Coffee House in New York City, in the late 1700s, which later became the New York Stock Exchange.

Even at a designated exchange place, finding a seller with the right quantity and price can take hours, days, weeks or months. Brokers saw a business opportunity, where for a commission, they will stay at the exchange all-day, watch the markets, and find sellers to match your buy price and quantity.

Bucket Shop, early 1900s

Bucket-Shops were are new kind of “exchange”, where you can bet on stock prices, but never actuality buy or sell any stocks at all. One of first traders and most successful speculators of all-time, Jesse Lauriston Livermore, began at bucket shops, before becoming a professional floor trader on Wall Street. The book, Reminiscences of a Stock Operator, is a fictional account of his life, and is a must read for anyone interested in the art of trading and speculation.

Advanced trading strategies emerged such as “short selling”, where a trader would borrow stock, and immediately sell it. He would hold onto the cash, and wait for the price to drop. Then use some of the cash to buy it back, and return the stock to the lender. The trader keeps the remaining cash, as profit!

Traders vs Investors

Traders, speculators, and market-makers will buy and sell any asset for the sole purpose of profiting by buying low and selling high. In one sense, traders get paid for providing liquidity to the true buyers, the investors or Altcoin users.

Investors give traders volatility with market orders, and traders give investors liquidity with limit orders.

Investors are seeking liquidity, and traders are seeking profit, and neither one wants to take on the risk that the other side of the trade will default or renege. Hence the modern financial markets were born.

Exchanges enable price-discovery by pooling buy and sell orders from investors, traders, and speculators, into a single “book” of liquidity. Orders are filled when bids and offers are matched at the desired price. When a trade is made, the exchange charges a fee, and broadcasts the price on a ticker feed.

In addition, exchanges remove counter-party credit-risk, by taking custody and guaranteeing settlement and clearing. They achieved this by only allowing pre-qualified members of the exchange to trade on the exchange. Members would consist of mostly two groups, investment brokers and floor “specialists” traders. Brokers are the agents of the investors and would work in their best interest, while floor traders are professionals seeking Alpha.

Alpha vs Beta

Beta is the returns from market movement of the underlying asset price itself, while Alpha is the excessive returns that are independent of the underlying market price. Alpha reflects your net profit and loss from trading. Beta reflects your profit and loss in relation to an underlying asset.

An investor’s portfolio with 100% ALT, would have a Beta of 1 vs ALT.

A floor trader seeks Alpha, by buying and selling ALT many times over but would always be flat the close of each trading session.

A speculator seeks Alpha, by going long or short ALT Beta, and may hold for days, weeks or longer.

Exchange volumes have always been dominated by Alpha traders over Beta investors. By the 1980s and 90s, due to real-time computerized price feeds, and electronic broker networks, more volume was coming from traders and speculators than all investors combined. Then in 1998, when the SEC authorized electronic exchanges, High Frequency Trading (HFT) was born.

HFT, took automated trading to a whole other level. By 2017 over 90% of all trading volume will come from short term Alpha strategies! source

Modern exchanges mostly rely on Alpha traders for profits, and cater to their needs.

Alpha traders rely on the Beta investors for trading profits.

Beta investors rely on the Alpha traders for liquidity.

At the center, and the core technology in this exchange ecosystem is the Central Limit Order Book.

Exchange order books create liquidity pools, and enable a fair and open efficient market for optimal price discovery. It contains all open orders, and is sorted first by price and then by time.

Exchange Limit Orderbook

Modern exchanges provide:

Liquidity: Matching and Execution of trades, through a single central limit order book, enabling best execution and price discovery.

Matching and Execution of trades, through a single central limit order book, enabling best execution and price discovery. Custody: Settlement and Clearing of trades, plus transfer of assets. This removes the need for buyers and sellers to trust each other.

DEX

The ultimate DEX: An exchange that provides price discovery by matching buyers and sellers from a deep pool of liquidity with transparency, immutability, and censorship resistance. Where buyers and sellers are open participants of the exchange, are always in custody of their own assets, and may remain pseudo-anonymous.

What does “Decentralized” mean in a DEX?

Decentralized Liquidity: Matching and Execution of trades through a decentralized limit order book. This requires the matching engine to be distributed, and running on each users machine.

Matching and Execution of trades through a decentralized limit order book. This requires the matching engine to be distributed, and running on each users machine. Decentralized Custody: Settlement and clearing without a centralized custodian. Users control their own asset, via private-keys.

Decentralized Custody

Most DEX blockchain projects today are only trying to solve the problem of settlement and clearing without centralized custody. This makes sense, because the main bitcoin innovation was removing the need for a central authority, when transferring digital value. However, without pooling liquidity together, they are ignoring 90% of traditional exchange volume!

These DEX projects are really geared towards the individual investors and users, who are looking find peers to trade with. This is more similar to an Over-The-Counter (OTC) trading desks, than to an “exchange”! OTC desks match buyers and sellers, privately, at negotiated prices. These prices are independent of the current prices from the liquid exchanges.

Decentralized custody is an almost impossible problem to solve, yet projects like bisq (for bitcoin to fiat), or atomic swaps (for bitcoin to altcoin), are almost there. While there still maybe fundamental problems with these solutions, we are not going to delve into those here. Instead, we will be assuming that decentralize custody is already solved, and discuss an even bigger problem. Decentralized Liquidity!

The good news is, that decentralized custody, clearing, and settlement is already solved with blockchain. The bad news is, that even when decentralized custody, clearing, and settlement is completely solved, decentralized exchanges are still impossible!

Custody solved “on-chain”

An account based blockchain with more than a single asset, can have a native on-chain “exchange” with a limit order book. Users place buy and sell orders by signing special blockchain transactions. Each node has a complete matching-engine and limit-order book built in, and processes the buy and sell orders from the block of transactions. After each trade execution, each node will automatically debit and credit funds and assets from the buyers and sellers.

In fact, many blockchains already have decentralized matching engines in production! Such as, XRP, Bitshares, Counterparty, Protoblock, Ethereum, and NXT, to name a few.

Of course this can only work with assets from inside the blockchain itself.

Decentralized Liquidity

DEX are only interesting if they can compete with centralized exchanges. For DEX to compete with centralized exchanges, they must provide deep liquidity for investors by attracting the short term Alpha traders, who account for 90% of traditional exchange volume.

Price discovery and liquidity are the main purpose of any exchange.

An exchange must provide a matching engine and order book to fill the needs, and attract Alpha traders. However decentralized limit-order books are impossible, due to Adverse Selection Risk also known as, front-running.

Adverse Selection Risk

The ability for miners to front-run orders, means that your orders only get filled when its not in your favor.

Your adversaries are selectively filling your orders, only when its profitable for them.

The problem is that matching-engines and order-books are path dependent. Meaning, the transaction ordering within a block matters. Bitcoin and Proof-of-Work solved double-spend, which only requires miners to decide which transaction to chose from in case of a double spend. Otherwise, miners are free to order the transaction in any way, since the order of transactions inside a block has no other side-effect. The same set of bitcoin transactions, in any order will create the same state data, or UTXO set.

The order of transactions is a fundamental property of exchange matching engines, since order-books are sorted by time and orders are filled first-in-first-out.

The term “Central Limit Order Book”, has been used since the 1980s, when early exchanges quickly discovered that matching engines cannot be distributed, and can only work when run on a single thread on a single server. In fact, the reason for this is same Byzantine Generals Problem, that was solved by Bitcoin!

Ordering of Transactions

Order Sequence A: These 7 orders should go though an exchange matching engine and produce the following fills and positions.