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 which merely removes centralized custody and settlement, is not enough to compete with centralized exchanges (CEX). And, that a true DEX is theoretically impossible even when assuming decentralized custody is completely solved. This is because an exchange must be a solution to liquidity, and decentralized liquidity requires distributed matching engines and order books, which are not possible. Reality Arbitrage is presented as an out-of-box idea, and a solution that will also disrupt current centralized exchanges. Inspired by the invention of the precursor to bitcoins blockchain.
With so many DEX projects coming on-line, lets first ask: What is an 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 Altcoin, but is just trading ALT 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 an advertisement 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, 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 with , but never actuality had to buy or sell 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
Investors give traders volatility with market orders, and traders give investors liquidity with limit orders.
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 users.
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 fill 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 where 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, which took it to the next 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 eco-system 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.
Custody: Settlement and Clearing of trades, plus transfer of assets. This removes the need for buyers and sellers to trust each other.
The ultimate goal of 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.
Decentralized Custody: Settlement and clearing without a centralized custodian. Users control their own asset, via private-keys.
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 exchanges! OTC desks privately match buyers and sellers at negotiated prices, which 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.
Price discovery and liquidity are the main purpose of any exchange.
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.
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.
1. trader1: Buy 5 at 500 2. trader1: Sell 5 at 1500 3. trader2: Buy 1 at 950 4. trader3: Sell 1 at 955 5. trader4: Sell 2 at 500 6. trader1: Sell 1 at 940 7. trader5: Buy 2 at 950
|*Sequence-A: Positions & Chart *|
Re-Ordering of Transactions
Order Sequence B Now lets see what happens if we just reorder transaction 5 and 7.
1. trader1: Buy 5 at 500 2. trader1: Sell 5 at 1500 3. trader2: Buy 1 at 950 4. trader3: Sell 1 at 955
5. trader5: Buy 2 at 950 6. trader1: Sell 1 at 940 7. trader4: Sell 2 at 500
|Sequence-B: Positions & Chart|
Swapping the order of just 2 transaction dramatically changes the entire market and price action
- trader4 went from -$430 to breakeven, with avg price from 725 to 950, a 25% move!
- trader1 went from flat with +$445 profit to short 1 at 950 with $0 profit
Order Sequence C What if instead a miner inserted 2 new orders after order 4?
1. trader1: Buy 5 at 500 2. trader1: Sell 5 at 1500 4. trader3: Sell 1 at 955
5. miner: Buy 2 at 501 6. miner: Sell 2 at 940
7. trader4: Sell 2 at 500 8. trader2: Buy 1 at 950 9. trader1: Sell 1 at 940 10. trader5: Buy 2 at 950
|Sequence-C: Miner Front-Run Positions & Chart|
Miners can font-run every single time and earn free money, while everyone else suffers with loses and Adverse Selection risk!
- Miner is up $878, made 46% in the trade, with no risk!
- Every other traders positions has change too, its as if they are all trading blind!
Even if the miners won’t do this themselves, they would eventually be bribed by hedge-funds to front-run for them. This changes the entire economic incentives of mining, where front-running could be worth more than block-rewards!
The above is an example of front-running during a flash-crash. However, even in more benign markets, the same opportunity for risk-free profits by miners front running exists. As we shall see below, flash crashes are thought to be caused by high-frequency-trading bots.
A Possible Solution
The approach to solving the Decentralized Liquidity problem requires a new kind of exchange. This exchange, must create new matching engine technology, that:
- Is better than current exchanges in a way that attracts liquidity from Alpha traders
- Is able to reach consensus in way that gives all traders an equal opportunity to profit.
HFT creates Flash Crashes
Although investors and exchanges have always relied on Alpha traders for price discovery and liquidity, the current HFT bots seem to be causing more harm than good. HFT is thought to be the main cause of flash crashes to begin with. Regulators, investors and governments have been trying to come up with solutions to curb the practice, to no avail.
A new decentralized exchange that eliminates HFT, thus removing the flash crash epidemic, while still retaining the longer term Alpha Trade, is a tall order!
We take inspiration from the inventors of linked-timestamping, the precursor to the blockchain. In 1991, Scott Stornetta and Steward Habor found it impossible to solve the problem of creating immutable digital records, because anyone who had access could always change it. And even when you put a group of people in-charge of watching over the data, they can ultimately collude! The solution was a “conspiracy so large that every one in the world must be in on it”. By making the data widely distributed and public, the problem is inverted!
Inverting the problem
Distributed limit order books are impossible, since there is no way to reach consensus on the ordering of the transactions within a block. This gives each miner the ability to front-run, and take free money, causing adverse selection risk to all traders at the exchange, which would kill liquidity and ruin the ability of a DEX to compete with a centralized counterpart.
What if we look at this “front-running” as a block-reward? In normal blockchains, miners need to be incentivized with block-rewards. However, here you get free profit from signing blocks and re-ordering the transactions. What if we make a new blockchain, where “miners” would have to pay to sign blocks? What are they paying for? They are paying for the rights to re-order the transactions and front-run!
|Possible Ordering and Results|
We invert the problem of front-running, by explicitly letting anyone pay to front-run. Re-ordering of the transactions is a feature, is tokenized, and awarded to the highest bidder for each block!
From the example above:
- How much would trader4 pay to go from losing $430 with Order Sequence A, to Order Sequence B where he loses nothing?
- In theory he would pay up to $430, to stop his $430 loss!
- How much would trader1 pay to keep his $440 profit with Order Sequence A, verses switching to Order Sequence B with no profit?
- In theory he would pay up to $440, to keep his $440 profit!
The price flash crashed from $950 to $500 and back up to $940, this makes the move $440 per share. Now with this bidding process between trader1 and trader4, that exact amount is now recoverable!
We called this Reality Arbitrage, since you can change the immediate past, and go back in time to a new reality!
As an Alpha trader, knowing the rules of this new exchange, how would you trade differently? Would there even be a point to placing low bids in an attempt to catch a quick drop?
Could it be, that this approach would remove the profitability of High-Frequency-Trading, solve flash-crashes, and DEX liquidity, all at the same time? Only doing the research work, can answer that!
If we are going to solve the DEX issues, it will have to be done the Bitcoin way. By a total disruption of the centralized alternatives. A completely new paradigm for financial markets and exchanges. A new blockchain where you pay sign blocks, and the highest bidder gets to re-order the transactions, with the longest chain being the total cost of the chain.
Does this seem like something that should be explored in more details? I think so! Please contact me via email or @jaybny on twitter to explore this idea farther.