- LearningDefi
- Posts
- ELI5: Decentralized Exchanges
ELI5: Decentralized Exchanges
Explain it like I'm Five - Decentralized Exchanges
❈ Explain Like I’m Five ❈
Decentralized Exchanges
Decentralized Exchanges are a foundational part of Defi - put simply, they allow on-chain participants to easily exchange token A for token B.
As a fun experiment, I asked ChatGTP to ELI5 Decentralized Exchanges. Here was the result.
Decentralized exchanges are like toy markets where you can trade your toys with other kids without needing a grown-up to watch over you. In the same way, decentralized exchanges let people trade cryptocurrencies without needing a company to manage the trades. This means you can trade directly with other people, and nobody can cheat you because everything is recorded on a computer that everyone can see.
Not bad - but let’s dive deeper.
What is a Decentralized Exchange?
Decentralized exchanges, or DEXs, operate on a decentralized peer-to-peer network, aka a blockchain, without a central authority. DEXs are powered by smart contracts, which are immutable, verifiable, and autonomous pieces of code. While most DEXs may provide a user interface for traders to exchange tokens, the key benefit of a DEX is that it enables direct token swaps between traders via smart contracts, without a central intermediary. This is in contrast to centralized exchanges like Coinbase, FTX, and Gemini, which operate through a central authority.
DEXs have grown to some impressive numbers over the past two years.
As of March 23, these are the 7-day volumes of transactions that have flowed through the top DEXs.
Uniswap: $11.1 billion
Curve: $3.04 billion
Pancakeswap: $1.83 billion
Today, according to DefiLlama there are 748 different DEX platforms that have a combined TVL (total value locked) of $18.37 billion.
DEXs never actually have custody over the assets traded on their platforms. Instead, DEXs help connect two groups of individuals: liquidity providers and traders
Let's imagine a DEX that focuses on exchanging two assets, ETH and USDC. In order to make trades happen, the DEX sets up a liquidity pool (a smart contract), which can be imagined as a literal pool that's empty at the start.
Once the pool exists, that’s when the roles of the traders and liquidity providers start.
Liquidity Providers (LPs) - these individuals deposit their own ETH and USDC into the pool to be used as liquidity to allow trading to take place. When an LP deposits funds into a liquidity pool, they receive an LP receipt token representing their share in the pool. They can use this receipt token to get their share of the pool back out whenever they want.
LPs are incentivized to deposit funds into liquidity pools because they'll earn fees for all the swaps their liquidity helps to process.
Traders - these individuals use the pool to swap Token A for Token B, or vice versa. In exchange for this ability, they pay a small fee for every swap. As traders, they want to make sure that the liquidity pool they're using to swap assets has enough liquidity to handle large trades and not cause significant price impact. This is why most trade volume goes through pools with the highest liquidity.
Let’s look at an example where a trader swaps ETH for USDC using the liquidity pool. The trader is able to exchange ETH for USDC at the current market price. When a swap is made, then the trader pays a fee to the LP providers for the ability to use the pool.
If a trader comes and exchanges 0.1 ETH for 150 USDC, the pool would then have 1.1 ETH and 1350 USDC. The exchange rate would tilt slightly lower for ETH to encourage another trader to exchange USDC for ETH and average the pool back. Most DEX’s will display the pool % breakdown on their website.
Here is a screenshot from Curve’s ETH-stETH pool. You can see that there is slightly more stETH in the pool than ETH.
The fees paid by traders depend on the specific pool and the DEX they're using. In the case of Curve, traders pay a 0.04% fee on all swaps. 50% of these fees go to $CRV stakers (the governance token of the Curve DEX) and the remaining are rewarded to liquidity providers. However, these fee numbers change drastically from DEX to DEX.
Altogether, the interaction between liquidity pools, liquidity providers, and traders looks like this.
At the simplest level, a DEX is really just a collection of a bunch of liquidity pools that allow traders to swap into and out of tokens and give LPs the ability to earn fees.
Under the hood, these LP pools can be quite advanced and have different features, different swap fees, and unique swap math depending on the DEX. Some may be optimized for really efficient swaps between stablecoins (e.g. USDC <> USDT) or like-assets (e.g. ETH <> stETH). Some may allow you to enter LP pools with more than two assets. Some may have incentive rewards that they pay out to LP providers (in addition to swap fees) to help incentive bringing liquidity onto their platform. There truly is a full and very wide array of different models.
The vast majority of DEXs use this liquidity pool model and they’re referred to as AMMs (automated market makers), which is fancy speak for a system that facilitates the ability for users to trade against a pool of funds rather than against specific offers from other users (a traditional order book). We’ll talk about decentralized order book exchanges in a later piece. Pretty much every major DEX day is an AMM.
The Current DEX Landscape
Of the 748 DEXs that are live today - you’ll probably never use more than 5-10 of them. Of the DEXs you’ll use most will fall into 1 of 2 categories.
Large, mutli-chain, “brand name” DEX’s such as Uniswap, Sushiswap, Curve, Balancer. These DEXs live on multiple chains and attract most of the liquidity.
After these large, multi-chain DEXs, each chain often has a DEX that becomes the default native DEX of that ecosystem and attracts a lot of liquidity. Polygon has Quickswap. Arbitrum has Camelot. Fanton has Spookyswap. Canto has Canto Dex. Cronos has VVS Finance. Optimism has Velodrome.
Depending on what tokens you are trying to exchange, it is usually a good idea to check prices and liquidity across multiple DEXs (if they exist) to make sure you’re getting the best exchange rate.
Or you can use a DEX Aggregator such as OpenOcean, 1inch, Paraswap, etc. These tools will automatically check liquidity and prices across multiple DEXs and route your traders through multiple pools in order to get you the best possible price.
DEX Advanced Topics
If this article really made you curious about Decentralized Exchanges and you want to learn more. Here are some topics that you can start researching on your own. We’ll cover these eventually!
Impermanent loss
Decentralized Order Books
Cross-chain interoperability (cross-chain swaps)
Concentrated Liquidity
Incentivized LP rewards
Expert-level topics:
Constant product Market Makers (x y = k) vs Constant Sum Market Makers (x+y=k) vs Constant Mean Market Makers (xy*z)^(⅓)=k
❈ That’s all for today. As always - stay safe and stay yielding ❈
Question: What other defi topics should I write about in upcoming weeks?