3. AMM vs Order Book
Written by the Phezzan team
According to Wikipedia, an order book is the list of orders that a trading exchange uses to record the interest of buyers and sellers in a particular financial market. If you have traded on centralized crypto exchanges (e.g. Binance, FTX) or stock brokerages (e.g. Robinhood), you should have seen such order books.
The order book is essentially a list of orders sorted by price. When there is a limit order, the order will be added to the order book. When there is a market order, trading exchange’s matching engine will determine which orders on the orderbook can be fully or partially matched.
Order book model has existed for hundreds of years, and is very capital efficient in terms of facilitating trades. However, running an order book on-chain was not feasible because of high gas cost. Vitalik Buterin commented back in 2017 (https://www.reddit.com/r/ethereum/comments/55m04x/lets_run_onchain_decentralized_exchanges_the_way/):
The main challenge that I see with the MKR market, etherdelta and other markets right now is the high spreads, often 10% or even higher. A large part of this is that market making is very expensive, as creating an order and removing an order both take gas fees, even if the orders are never "finalized”… My proposed solution is to use the style of "on-chain automated market maker" used in prediction markets in a decentralized exchange context.
"Automated market maker" (AMM) mentioned by Vitalik is basically an on-chain smart contract that use a math formula to determine the price of the asset. The exact formula varies.
In most AMM-style DEX, its pools hold an x * y = k invariant, where x and y are the amount of quote token and base token of the market. For example, in a ETH-USDC pool, if the initial ETH amount is 10, and initial USDC amount is 1000, then k = x * y = 10 * 1000 = 10000. Unless someone add or remove liquidity, k stays constant.
If you want to sell 10 ETH, since k = 10000 is constant and the pool now has 10 + 10 = 20ETH:
20 * y = 10000 => y = 500
So you will get 500 USDC back.
Uniswap is an example of AMM-style DEXs. It now takes ~70% of total on-chain spot trading volume.
AMM is much more gas efficient, but less capital efficient than order book. For the same TVL, orderbook-style DEX can have 10x lower trading slippage than AMM-style DEX. Also, LPs in AMM-style DEX will have impermanent loss.
As blockchain scaling solution matures, it is reasonable to predict orderbook-style DEX will takes more market share. Phezzan V2 will explore the order book model, while still allowing retail investors to be LPs. Stay tuned for more updates.