Thanks to the rise in demand for decentralized finance (DeFi), centralized exchanges (CEXs) and decentralized exchanges (DEXs) are receiving great attention than ever before. DEXs are predicted to be huge in the near future because it can solve intermediary problems, keep users anonymous, provide better security, and more choice of tokens than centralized exchanges. An enormous innovation that DEXs bring for users is allowing them to do trading activities directly from personal wallets without sharing private keys for any organization. To find out which DEXs are suitable for you, let's take a look at their design model. There are 2 main models applied for DEX Development: automated market maker (AMM) and order book. AMM is created after order book systems and it can solve some issues that an order book struggled with, such as liquidity issues. But, is AMM the better design for DEX than the order book? Let’s find out.
Related: DEX Development – A New Wave in Crypto Exchange
1. What is an order book? How can it help with DEX development?
a. Definition of an order book
The term “order books” explains the concept itself when it lists all the orders from buyers and sellers for each kind of cryptocurrency. In an order book system, a buying order is called a bid, and a selling order is an ask. When buyers upload their orders in DEXs, the order book is in charge of organizing suitable sellers that have related-price orders. Thus, DEX traders can do trading activities successfully when their orders are matched with other traders’ orders.
There are 2 types of orders in the order book: market order and limit order. When choosing a market order, traders can buy or sell for the best available price in DEXs promptly. It will match buyers and sellers with orders that are at the top of the book at that time. Meanwhile, when putting a limit order, traders choose expected prices and set the number of cryptos for buying or selling. The order will sit on the order book until a DEX system finds a suitable order and automatically matches it with yours.
b. Advantages and Disadvantages of Orderbook in DEX Development
- Order book brings benefits for the liquid market: Presently, an order book is a design model used for the majority of CEXs, including “big boss” in online trading platforms - Binance. So, it is sure that an order book has some strong advantages, and one of them is the ability to trade in a liquid market. The “Liquid Market” is a market that has a huge amount of bid orders and ask orders while the bid-ask spread is low. In a liquid market, traders find it easy to do trading activities since this market involves a large number of sellers and buyers. If you decide to sell cryptos in a DEX including high trading volume and low slippage, you can easily find a buying order that matches with yours, even if you put limit order or market orders.
- Order book brings negative impacts for illiquid markets: In contrast to the liquid market, the illiquid market makes traders have difficulty in finding matching orders due to large bid-ask spread and low trading volumes. If you want to have successful orders, you have to make sure that your highest bid is lower than the lowest ask.
- Manipulation: The order book provides a list of bid and ask orders – clues about the price of a token. Based on these clues, traders can predict the price direction of crypto in a short term. For example, an enormous number of ask orders can represent a decrease in a token’s price. Many traders tend to sell it immediately as they have a fear that the token will lose its value rapidly. However, the issue here is that these clues, which are based on a bid-ask order list, can change easily and promptly. Moreover, the order book list only displays limited records of orders in DEXs. So, predictions from these signals can not be exact. Moreover, wash trading, dump schemes, and abusive traders usually appear in DEXs while these behaviors are banned in traditional exchanges. However, DEXs keep users anonymous so it is hard to find the fraud when all trading information, transaction records, and users’ profiles are transparent.
- Front-running: There is an existing problem of the on-chain order book system in DEXs – front-running. Unlike an off-chain order book, an on-chain order book lacks censorship resistance by having relayers to store the orders on centralized servers. In this system, if users want to put limit orders or cancel existing orders, they need to create and submit a transaction. This step includes a dangerous threat for users when the transactions in blockchain storage can be revealed to miners, although they are not included in the block. For example, if a user submits a buying order to buy crypto, miners (who can see users’ order information) can create a bid order and involve it in the block before users. So, miners can earn profits by using the information of orders.
2. What is AMM? How can it bring benefits for DEX development?
a. Definition of AMM:
An automated market maker (AMM) is the underlying protocol of decentralized exchanges (DEXs) and replaces the order book with a liquidity pool. Now, we will find out the concept of AMM and how it works.
If DEXs does not use an order book, how can traders do trading activity in AMM DEXs? The answer is Smart Contracts. Many DEXs choose autonomous protocol AMM to replace the role of the order book. Instead of using matching order systems, AMM DEXs use a self-executing program, smart contract to define digital assets’ price and then provide liquidity. On DEXs that use order book systems, P2P exchange development is used for trading transactions. In contrast, AMM DEXs follow the concept of P2C (peer-to-contract) transactions because users do trading activities with the liquidity locked inside a Smart Contract. That’s why Smart Contract can also be called a liquidity pool. In the AMM system, the price of tokens is determined by a formula.
As you know that AMM doesn’t involve intermediaries, however, the market still has to be created and who can decide liquidity? That’s right, liquidity is provided by liquidity providers (LP), which are also users in AMM DEXs. LPs are known as the first person to put a certain amount of cryptos into a pool to provide liquidity. They can earn profits by transaction fees paid by traders. Normally, the AMM system rewards liquidity providers for joining the community by distributing governance tokens to them.
Before the development of AMM, liquidity was always a big challenge for DEXS. In DEXs that use order books, liquidity in the market is not stable, leading to the fluctuation in trading volume and slippage. However, AMM can fix this issue by providing liquidity pools and allowing liquidity providers to supply pools with assets. If the number of assets in the pool and liquidity increase, the trading activities will be easier. Moreover, users of AMM DEXs are encouraged to deposit digital assets in a liquidity pool to reduce slippages.
b. Advantages and Disadvantages of AMM in DEX Development
AMM provides liquidity for the illiquid market: As appearing in AMM DEXs and liquidity pool, whether the order size of these tokens or liquidity pool is large or small, liquidity of tokens is always provided by the AMM system. It can solve the fragmented issues existing in traditional exchanges.
- AMM causes high slippage for large orders: Slippage relies on the liquidity pool’s size of a certain trading pair. In AMM DEXs, the larger the orders, the higher the slippage. For example, in Uniswap, an order size that accounts for half of the liquidity pool leads to a rise in the average price of the token, as twice the normal price. The liquidity pool needs to be 100x greater than the size of the order to keep the slippage rate under 1%. AMM exchanges are not working well with large orders since each liquidity pool in the system would need to be massive while the number of traders now is quite small. That’s why many traders prefer traditional exchanges or order book DEXs, which have a large number of existing traders trading billion dollars in order every day, than AMM DEXs.
- Impermanent loss for liquidity providers: Several people misunderstand that Liquidity Providers in AMM DEXs earn a fixed income. However, the profits of LPs come from trading fees of traders in the liquidity pool and there is a huge risk for them, which is impermanent loss. It is defined as a unique risk included in the process of providing liquidity to dual-asset pools in DeFi protocol. It is the difference in value between putting tokens in an AMM liquidity pool and holding them in a cryptocurrency wallet. Actually, LPs earn the highest profits when the tokens are traded with nearly or the same price ratio that supplied by LPs at first. At this point, the impermanent loss hits the lowest position so the risk for LPs to earn profits also decreases. For example, the huge increase in ETH price can cause losses for LPs since the price of ETH that they first put in the AMM liquidity pool is lower.
3. What is better?
It is clear that AMM can solve a considerable issue in other exchange platforms that use order book systems, which is liquidity problems. However, AMM still has several problems, including high slippage and impermanent loss risk for LPs. At that time, AMM is having fewer disadvantages than an order book but it can not be 100 percent sure that AMM is always a better choice. Currently, there is a new design that combines both AMM and order book, which is Hybrid DEX. But this is a brand new model so it takes time to develop.
In conclusion, although AMM is not perfect, it has a huge potential. So, if you want to build, develop or get advice on what decentralized exchange development services you should use, don't hesitate to contact us. We, SotaTek, provide several Blockchain Development Services, such as NFT Crypto Development, Dapp Development, Tokenomics Consulting, DEX Development, etc with affordable prices and suitable IT solutions.