DEX: Orderbook vs Liquidity Pool (AMM)

DEX: Orderbook vs Liquidity Pool (AMM)

DEX is one of the most powerful exchange tools available in the cryptocurrency world, thanks to its decentralization and degree of freedom that cannot be achieved by any other means.

What is a DEX?

It is a platform that allows transactions between users without the need for trusted third parties. In addition, the funds are always in the hands of the users. This reduces risks, such as the theft of funds in the event of a hypothetical hacking or theft of funds, as occurs in centralized exchanges (CEX).

DEXs are based on smart contracts. These are simply computer programs developed to perform certain functions. They are in charge of establishing exchange prices according to the market and linking buyers and sellers, among others.

As we said, the funds always remain the property of the user. This prevents theft, seizure or blocking of funds by governments or other entities. Cases that can occur in CEXs, since they are obliged to pass certain legal filters.

Although they have important strengths, such as the fact that the funds are always in the user’s possession, they also have weaknesses. One of the most important is that we can only access the tokens of the network where it is deployed. For example, Uniswap only allows us to exchange Ether and tokens within the Ethereum blockchain. We do not have access to Bitcoin, Solana, Dogecoin and other cryptocurrencies.

We also have other problems, as the transaction processing speed is lower than that of a centralized exchange. It depends on the processing capacity of the network, which in the case of Ethereum, is very low.

But DEXs are adapting and are evolving to become as similar as possible to CEXs. One of the latest movements is the emergence of DEX with order book, which brings them very close to centralized exchanges. This type of decentralized exchange is positioned as an alternative to the current platforms based on the AMM mechanism.


What types of DEX currently exist?

Currently, we can distinguish between two large groups of decentralized exchanges. On the one hand, we have those based on liquidity pools and others based on order books. We will see what are the characteristics of these two types of exchanges and their particularities.

Liquidity Pool

They have two tokens linked by a smart contract to provide liquidity to traders. Liquidity pool tokens must be of equivalent value. This is necessary, as AMM-based exchanges work by a simple mathematical formula to price the assets in the liquidity pools.

Order Book

They integrate a list of buy and sell orders for two tokens, such as BTC/USDT. All orders are sorted by price. We can see in these books the amount of shares that are offered or bid for each price. This mechanism allows users to establish buy or sell positions according to a certain price.


What is an Automated Market Makers (AMM) DEX with Liquidity Pool?

They are a type of digital asset exchange platform without the need for trusted third parties. DEXs promote user autonomy to trade through non-custodial wallets.

These DEXs eliminate order books and switch to a mechanism called Automated Market Maker (AMM). They rely on smart contracts to price tokens and provide liquidity. Liquidity is pooled in different smart contracts. We can say that users do not actually trade with other users, but trade with the available liquidity. Usually these smart contracts are called liquidity funds.

Any user can be a liquidity provider within an AMM exchange. We only need a non-custodial wallet, such as Phantom (Solana) or Metamask (Ethereum) to access and, of course, have funds. It should be noted that being a liquidity provider does not mean leaving our funds in the hands of third parties, the funds are always in our property and we can retrieve them whenever we want.

How DEX AMMs work?

Two aspects must be taken into account:

  • Centralized exchanges’ trading pars here are referred to as individual “liquidity pools”. Example: for an exchange of ether for shushi (governance token of the decentralized exchange SushiSwap) it is necessary to find an ETH/SUSHI liquidity pool.
  • It is possible to provide liquidity by depositing assets representing this pool. Example: to be a liquidity provider in ETH/SUSHI it is necessary to deposit certain amounts of both tokens.

The amount of assets within the liquidity pool is required to be balanced. This is necessary to avoid discrepancies in the prices of pooled assets. For this purpose AMMs are based on a simple mathematical formula.

This formula was proposed by Vitalik Buterin at the Ethereum Research forum as a basic idea for decentralized exchanges. Buterin named this proposal as “Improving front running resistance of x*y=k market makers”. This is:

x * y = k

  1. The ‘x’ represents the value of ‘asset A’.
  2. The ‘y’ represents the value of ‘asset B’.
  3. The ‘k’ is a constant.

Example:
We have a liquidity pool with a ‘Token A’ and a ‘Token B’. We decide to buy a certain amount of ‘Token B’ and for this we deposit ‘Token A’. The amount of ‘Token B’ is reduced, so that ‘Token B’ has an increase in price. On the other hand, the amount of ‘Token A’ increases, which causes its price to decrease. This price adjustment is automated and allows ‘k’ to remain unchanged.

Significant discrepancies could be generated if a large amount of a token is removed. There could be a discrepancy between the price of the token in the liquidity pool and the market price. Something that makes it possible to acquire a token at a “discount” and then sell it on another, more expensive exchange.

In order to avoid this, there is arbitrage. It is nothing more than a strategy to find large price divergences. It is incentivized for arbitrageurs to find the discrepancies. They buy tokens until the price adjusts according to the market.

Liquidity providers

These decentralized exchanges require liquidity in order to operate. Users add liquidity so that other users can trade with these funds. It should be noted that the funds contributed to these liquidity pools are always in the user’s possession and can be withdrawn at any time.

To encourage users to add liquidity, they are offered a portion of the commissions per transaction. The user receives a proportional share according to his contribution to these liquidity pools.

Yield farming

In addition, DEX AMMs offer another mechanism for earning a small return. Yield farming is another option to obtain small profits. For this we only have to deposit a certain amount of digital assets to a liquidity pool. Some may additionally offer loans and thus earn additional interest.

Through this mechanism, better earnings can be obtained and at the same time, decentralized finance (DeFi) can be made operational.

Impermanent loss

Liquidity funds have a “problem” called impermanent loss. This “problem” appears when there is a price fluctuation of the assets in the liquidity pool.

Losses are generated when the price relationship of a liquidity pool deviates from the price of the asset when it was deposited. The greater the price change, the greater the loss incurred. These losses usually appear in liquidity pools with highly volatile digital assets.

Such a period of loss is usually not permanent, as there is a possibility that prices will reverse. We only have a permanent loss if funds are withdrawn before the price relationship reverses.

Note that participation in liquidity pools usually covers these losses. A reward for participation is offered not only to attract users, but also to compensate for a hypothetical impermanent loss.


What is an Order Book DEX?

An electronic list of buy and sell orders for a digital asset that is ordered by price. The order book specifies the amount of digital assets that are offered at each price. They allow the user to set buy or sell orders according to the prices they estimate and when that value is reached, it is automatically executed.

How an order book works?

It is an automated list where all open buy and sell positions appear at any given moment. We are talking about a dynamic book that fluctuates constantly as users open and close orders.

Normally, there are three elements within an order book:

  1. Buy orders: this is the current demand for digital assets by users ordered by price. They are ordered from lowest price to highest price.
  2. Sell orders: is the amount of digital assets that users want to sell computers according to price, they are ordered from highest price to lowest price.

Additionally, the order book is accompanied by a candlestick chart. Such a chart provides useful information about the current state of the asset pair (BTC/USD, for example) and how the market has been oscillating.

Both open orders and candlestick charts provide the user with information about the market situation. It can help users make buy or sell decisions according to the market trend.

Types of DEX with Order Book

We can currently find two types of decentralized exchanges with order book. These are:

  1. On-Chain Order Book: Orders are stored within the blockchain. It eliminates the need for external servers to store transactions. It is the mechanism with the most decentralization, but depends on the processing capacity of the blockchain and its gas costs.
  2. Off-Chain Order Book: Set orders are established outside the blockchain to reduce network fees and increase speed. Within the network only settlement of trades occurs.

Comparison: On-chain order book -vs- Out-of-chain order book

On-Chain Order BookOff-Chain Order Book
Orders are generated within the blockchain itself.Orders are generated outside the blockchain, only the final transaction is recorded.
It generates many transactions, so a network that can process a high volume of transactions is needed.It only generates the settlement transaction, i.e. the transfer of funds, so the processing capacity of the network becomes less important.
There may be high commissions, since the entire process is done within the network.Commissions are significantly reduced, since only the final process is recorded.
Placement and closing of the transaction may be slow, and may not even be completed if there is congestion in the network.The transaction should go smoothly
The degree of decentralization is very highThe degree of decentralization is much reduced
We should not rely on third parties, as everything is stored on the blockchainWe have to rely on third parties
No censorship can be given, as the whole process is done within the blockchainCensorship may occur, since we use third-party systems.
Operational fees (maintenance, development, etc.) are usually low as little infrastructure is required.Operational fees (maintenance, development, etc.) can be high, since a significant infrastructure is required.

Did you like this content?

If you think this Atani post is interesting, share it!

Get started for free now, including tax reports!

GET STARTED