How decentralised exchanges work
A DEX (decentralised exchange) is an application built on one or more chains for peer-to-peer buying and selling of assets over the blockchain. With a DEX, a trader can perform transactions without having to be bothered about any central body supervising or monitoring the transactions.
In previous posts, we have taken a deeper look into the definition of decentralised exchanges and popular examples. However, in this blog post, we will look into how decentralised exchanges work.
Related blogpost: DeFi: Beginner’s Guide to Decentralised Finance
Central Parts of a Decentralised Exchange
Transactions on centralised exchanges are recorded in an order book that is directly handled by the exchange. This order book shows the transactions of the long or short trades placed by the buyers or sellers. DEXs, however, transactions are handled by a smart contract and can be categorised into three types:
- Order book DEXs
- Automated market makers
- Dex Aggregators
All these three types differ slightly from one another in principle, but all allow traders to transact their assets using their smart contracts.
Order Book DEXs:
An order book is an electronic ledger that records all the buy or sell orders and uses that to connect buyers and sellers automatically based on the bid price. With an order book, traders can place a limit or stop order trade to be able to buy or sell an asset, long or short, at a specified price. However, on a DEX, there are two types of order books:
- On-chain order books
On-chain order books are hosted on the chain network that powers the exchange. They automatically carry out an order when two orders of the same price intersect.
- Off-Chain order books
Off-chain order books are order books hosted on a centralised ecosystem independent of a distributed ledger and update the chain almost immediately at a gas fee that is significantly reduced.
Note: The downside of the order book model in the case of DEXs is that it will only work perfectly for a very liquid market. If the number of traders willing to execute a long or short trade at a particular price is not enough, the transaction will not be executed.
Related Blogpost: DEFI: Decentralised exchanges, what they are, and how they work.
Automated Market Makers(AMM)
AMM allows traders to carry out transactions without the need to place a buy/sell request. This is possible because of liquid pools. A Liquid pool is a collection of assets supplied into the DEX. A particular token and its monetary equivalents are supplied to the pool by users called liquidity providers or market makers so that the algorithm sets the prices of the token concerning the quantity and ratio of the tokens supplied to the pool.
If you want to contribute 100 dollars’ worth of SOL to a SOL/BONK pool, it is necessary to contribute 100 dollars’ worth of BONK to the pool, or else the supply will not be processed. A constant yield formula is used to maintain the fair price of the token and this token so that any centralised entity does not influence it.
Note: A prominent issue for AMM is that it is prone to “impermanent loss.” However, these issues are tackled by AMMs, which adopt better mathematical models to stabilise liquidity.
DEX Aggregators
DEX aggregators, also called liquidity aggregators, solve a major issue in the blockchain that other DEXs encounter. The issue of slippages—a situation where the price of a token changes just as the transaction is executed. This majorly affects a higher volume of transactions; the change in volume of the purchased asset against its pair in the liquidity pool disrupts the transaction.
A DEX aggregator checks all the connected decentralised exchanges to find the most favourable prices, allowing traders to split trades across several exchanges in order to lessen the risk of spillage. Instead of manually splitting trades, users can use a DEX aggregator like 1inch or Jupiter to split the large volume of trade across multiple exchanges to derive the best price.
Examples of Dex Aggregators
1inch is one of the most well-known DEX aggregators, it provides users with the best trading rates by pooling liquidity from multiple DEXs.
Matcha was created by 0x to help users find the most competitive prices across multiple DEXs, making trading easier and more affordable.
Jupiter gets its liquidity from a variety of decentralised exchanges (DEXs), including both automated market makers (AMMs) and order book-based DEXs. Solana’s fast transactions and low fees allow Jupiter to perform reliable transactions by comparing and aggregating liquidity.
ParaSwap aggregates liquidity from multiple DEXs to optimise trading and ensure low slippage and gas costs.
KyberSwap aggregator is a part of the Kyber Network and allows users to easily swap tokens between different exchanges.
Slingshot is a more recent aggregator that connects to multiple DEXs for optimal trade execution, offering competitive pricing and an easy-to-use interface.
Related blog post: How to Instantly Identify Crypto Scams: Rug Pull and Honey Pot
Leave a Reply