January 11, 2024

DeFi Basics: Decentralized Exchanges (DEX)

EMURGO

DeFi-Basics_-Decentralized-Exchanges

DeFi (decentralized finance) has evolved since really taking off in adoption in 2020. Since its inception, the advancement of the entire DeFi ecosystem as a whole has required a few functioning parts and pieces to provide users with decentralized financial services. In this “DeFi Basics” series, we will go over these parts and pieces and explain their roles.

These primitives are crucial for the proper functioning of any decentralized blockchain and also serve as a pulse for its success. One of these primitives is the decentralized exchange or DEX, which is one of the most important types of applications in DeFi.

DEXs serve a fundamental purpose not only for users but also for blockchain developers and dApp (decentralized application) projects created on top of a blockchain ecosystem. They are the primary way to swap cryptocurrencies and tokens. They also add liquidity for such crypto and tokens and also help their market price discovery. 

In this blog, let’s take a deeper dive into DEXs.

What is a decentralized exchange (DEX)?

A DEX is a peer-to-peer swap market or platform built on a decentralized blockchain network where users can exchange a cryptocurrency or token for another. It’s a non-custodial system that does not require third parties to hold the assets to facilitate a transaction. These DEXs are just software protocols and algorithms that facilitate the swapping and transactions of users’ crypto and tokens peer-to-peer.

The matchmaking of the crypto assets and the amount of tokens to be swapped is managed by the logic written on a blockchain-based smart contract which is designed to self-execute once pre-programmed conditions have been met.

The execution of the order to do the swap is then processed by the decentralized blockchain network in a completely transparent way. There is a difference in how an automated market maker (AMM) and an order book handle this process, which is discussed below. In both types, the wallet address of the user initiates the swap and it interacts with the logic on-chain.

How do DEXs work?
DeFi-Basics_-Decentralized-Exchanges-IG

DEXs are more a family of technologies where several coexist to provide the same service. There are two main camps in the world of DEXs:

  • Order book 
  • Automated market makers (AMMs)

Additionally, there is a group called DEX aggregators, which scrape swap pricing information from different DEXs in a single platform, but that’s beyond this blog’s subject.

Order book DEXs are largely analogous to what exists in the traditional centralized financial system, albeit with a lot more decentralization and transparency. The order book is how traditional stock exchanges like NASDAQ match orders, or how centralized crypto exchanges like Binance, Coinbase, etc. allow for trading in cryptocurrencies. 

On the other hand, AMMs are a technology more native to blockchain and its design.  

The inner working of a DEX depends on users providing liquidity to a pool. Those who provide it receive a portion of the fees charged by the DEX for their service. A person looking to swap tokens needs to pay two types of fees: the network fee of the blockchain, and the exchange fee of the DEX.

DEXs are a fundamental part of DeFi because they allow for two important things. 

First, it provides price discovery for the cryptocurrency and/or tokens created by different dApp projects. 

Second, they provide liquidity for said tokens, allowing dApp projects access to funds and also the construction of a dApp treasury.  

This results in DEXs being one of the earliest projects to appear in a DeFi ecosystem. They are also an important metric to judge a blockchain network’s adoption, as transaction volume on DEXs, fees generated, number of liquidity pools, etc. all paint a picture of the overall health of a blockchain. For these reasons, the DEX is one of the fundamental building blocks not only for a blockchain but also for dApp projects building on a blockchain. 

As mentioned, there are two main types of DEX. Let’s go over each. 

Order Book

An order book is a matchmaking system where orders are placed in real-time and require constant adjustment. These require actors called market makers who constantly adjust their bids and try to profit from the differences that happen in the price.

Order books were the first type of DEX that appeared in the industry, with Ether Delta being the earliest. They are less common because the market makers constantly have to adjust their spread, which means paying fees for open orders that may never be filled. This made order book DEXs expensive to use in the early days of DeFi. 

Many of those that were at the beginning have closed, but the order book is currently having a resurgence. This is especially true on Cardano, where the eUTxO model can work well with the way order books are arranged. The most notable example of this would be Genius Yield which borrows many of the principles of a traditional order book.

Read more: What is Cardano’s eUTxO model?

Automated Market Makers

The AMM arose as an answer to the problems order books had operating fully on-chain. The first AMM was introduced by Bancor in 2017, as a permissioned system for those providing liquidity. 

Later, Uniswap launched the first AMM where anyone could add liquidity or create pools, becoming the largest DEX in the industry.

AMMs work by creating a bonding curve between two tokens. The curve manages the price of the tokens by increasing the swap rate every time one of the tokens is removed from the liquidity pool. The ratio between the 2 tokens in the liquidity pool must always be 50% measured by the price. 

This can create markets for token pairs almost instantly. The mechanism also doesn’t need intermediaries or market makers, like with order books, as the liquidity providers create a market when adding liquidity to a pool. 

The AMM is the most common type of DEX design in the industry and remains the leader in virtually all blockchains. Some notable examples of DEXs on Cardano are Minswap, SundaeSwap, and WingRiders, just to name a few. 

Join an exclusive 2-day DeFi workshop organized by EMURGO and the Institute of Blockchain Singapore

Click here to sign up

Are you a finance professional and interested in learning more about DeFi?

Then, EMURGO’s DeFi workshop specifically geared for finance professionals is right for you.

EMURGO and the Institute of Blockchain Singapore are hosting a 2-day workshop on DeFi in the early part of 2024 (originally scheduled for January 2024) with speakers from EMURGO, EMURGO Academy, Coinbase Singapore, Merkle Science, and more.

The workshop will provide you with a deeper understanding of DeFi, enabling you to prepare for DeFi’s evolution, participate in the DeFi ecosystem, and contribute to the growth of DeFi. 

For more workshop information including dates and registration info, please visit the official registration page here.

About EMURGO

Disclaimer 

You should not construe any such information or other material as legal, tax, investment, financial, or other advice. Nothing contained herein shall constitute a solicitation, recommendation, endorsement, or offer by EMURGO to invest.

Related articles