Decentralized exchanges (DEXes) are hugely popular in the cypherpunk DeFi world. They allow assets to be swapped without the need for a centralized entity to organize trades, relying instead on smart contracts and distributed groups of pseudonymous individuals. These exchanges operate transparently and permissionlessly, in contrast to every centrally controlled exchange, while also yielding lucrative rewards for participants providing liquidity. 

The success of such DEXes depends largely on one key innovation known as a “liquidity pool,” an algorithmic process that, when successful, is able to perform automatic checks and balances to enable vast numbers of trades.  Here’s an explanation of how these pools work.

How Do CEXes Work?

Let’s start by understanding how traditional exchanges operate today using the order book system. When performing a trade on a centralized exchange (CEX), you’ll place an order to either buy or sell an asset. This order is compiled into an order book (a digital database managed by the CEX) and soon the CEX will find someone interested in filling that order (e.g., buying what you’re selling or vice versa). It will take a fee from each trader once both orders are executed. 

The upshot of this system is that the price of an asset on a centralized exchange is dependent on immediate demand, in addition to the coincidence of two traders wanting to buy and sell the same asset, which poses a risk with smaller tokens. If there’s no huge sell order to match a huge buy order, a thinly traded token’s price will skyrocket, and vice versa. 

What Is a Liquidity Pool?

DEXes, by contrast, do not match individual buyers and sellers to trade against one another. Given the low liquidity of many DEX tokens, this would be calamitous. The complicated systems of “market making” used by CEXes to provide liquidity to thinly traded assets, meanwhile, would be unpopular on decentralized platforms.

Instead, DEXes corral crypto assets in digital “pools” that are the main sources of liquidity. Rather than trading against individual counterparties, users effectively trade against the pool. It’s the difference between finding two people to barter an apple for an orange and providing access to an entire supermarket. (DEXes themselves are basically collections of these pools.)

A liquidity pool is initially set up by creating two connected reserves of tokens with a fixed ratio, from which the assets’ prices are derived. When someone wants to trade one token for the other, they deposit one token and take a corresponding amount of the other, maintaining the fixed ratio. This is called the automated market maker, or AMM, system.

Anyone can create a pool to allow trades between two tokens, and anyone can contribute tokens to a liquidity pool that someone else created. That means there is no possibility of buying or selling a token that nobody wants. If you have the option to trade it, that means somebody has already created a pool. That also means the price ought to reflect supply and demand, and is less vulnerable to manipulation from individual actors.   

Crucially, liquidity pools also feature a distributed fee model, meaning that the fees paid by users on trades are credited to the providers of tokens in the pool (i.e., the liquidity providers) as opposed to a handful of officials running a CEX. 

Liquidity Pool Simulation

Here’s an example. I can create a liquidity pool for $ETH and $USDC so that people can trade one of those tokens for the other. I can also set the fee people must pay when performing a trade. Perhaps I start the pool off with 1 $ETH and a corresponding amount of $USDC—$1,809.51 as of the time of writing—and charge 1%. Someone else may want to make a trade and deposit 0.5 $ETH, taking a proportional amount of $USDC out, or $904.75, 1% of which goes to me as the reward for providing liquidity (i.e., the tokens in the pool).

Now the pool I created has amassed $2714.26 USDC, but only has 0.5 $ETH left in it. This will cause the value of the ETH to go up slightly, to account for its scarcity relative to the $USDC. A third person may see that shortfall as an opportunity to generate a return by adding liquidity to this pool, restoring the balance with new capital. 

When the next person comes along and makes a trade, the 1% is split between the other liquidity provider and myself. More individuals can add liquidity if they wish, without needing permission from anyone. The rewards are distributed proportionally by the smart contract. I do not get any additional privilege for creating the pool. All that matters is who provided liquidity and how much.

Oracles

Since assets like $ETH trade on many platforms, the prices of assets may fluctuate based on activity that happens outside of a single pool on a DEX. Liquidity pools must be able to adapt to these prices. Beyond the automatic adjustment of token supply, which reflects supply and demand on the DEX itself, many liquidity pools also rely on “oracles.” 

Oracles are a decentralized way to obtain information about things that happen in the world, and provide that information to the blockchain. In the context of DEXes, they provide price updates that adjust the ratio that liquidity pools maintain between tokens. So, the amount of $USDC necessary to balance the $ETH/$USDC pool, for instance, may adjust as market values fluctuate. 

Risks to Liquidity Providers

Since liquidity pools necessarily expose liquidity providers to different tokens, there are some risks involved that are worth noting.

Liquidity pools, especially new ones, can have misleading reward rates that may influence people to purchase assets purely to provide them as liquidity. While there is varying risk in exposure to different tokens, there are also impacts to the rates of return pools can offer, known as APR, or annual percentage rates. These rates fluctuate wildly based on the popularity of the tokens in the pool, as well as on how popular one liquidity pool is over another.

In the example above, someone may create a similar $ETH-to-$USDC pool but only charge 0.5%, accepting a lower profit margin for more popularity. And in the unlikely event that $USDC collapses, the pool may be drained of its $ETH by users making trades at lower rates until there’s no $ETH left to trade for. While it is unlikely that $USDC will collapse, liquidity providers for pools of less popular tokens may have more risk exposure to a liquidity pool that’s drying up.

Finally, there is a risk known as impermanent loss, which is a less extreme impact of differences in token popularity. If over time $ETH goes up in price, it’ll become the more popular asset users trade in my pool for. More people will swap their $USDC for $ETH to take advantage of slight price differences, leading to a greater proportion of $USDC than $ETH in the pool. This leads to my share of liquidity being in the less popular token ($USDC).

The loss is labeled impermanent since, over time, two strong assets should have different phases of popularity relative to one another. $ETH goes up relative to $USDC as it goes down, so the proportion of those two tokens evens out, but there is no guarantee this will happen.

Bancor tried to combat impermanent loss with a protection program intended to mitigate the risk of providing liquidity to pools on their platform. The program offered insurance for liquidity providers, assuring they would be able to withdraw an equivalent value of tokens to what they’d deposited, regardless of fluctuations in token prices. This was achieved by offering fees accrued by Bancor as insurance for liquidity providers, with any shortfall being supplemented by the issuance of new $BNT, Bancor’s native token. This program, however, was retired when markets faced turmoil in 2022, arguably the exact kind of unforeseen fallout the provisions were designed to protect against. 

Notables

  • Uniswap launched in 2018 and is the biggest DEX on Ethereum, and also operates on other blockchains and layer-two blockchains as well. Uniswap airdropped its $UNI token to users of the platform, creating a DAO (decentralized autonomous organization) and giving token-holders control of the DEX. However, the website where people make trades is controlled by Uniswap Labs, a private company. This has resulted in instances where tokens have been “delisted” from the platform, but in actuality they were only hidden from the website.
    • The specific type of AMM that Uniswap uses is known as a constant product market maker AMM. This is a formula that maintains the ratio of the two tokens in the pool (e.g., x * y = k). Here, x and y represent the different tokens in a pool, and k is the constant that must always be reached when x and y are multiplied.
  • SushiSwap launched in 2020 with crypto’s first vampire attack, a strategy that encouraged users to move their liquidity from Uniswap over to SushiSwap instead. SushiSwap offered extremely high rewards in the $SUSHI token for liquidity providers that moved over from Uniswap. The platform issued 1,000 $Sushi tokens per block at first, enabling it to secure $1 billion in liquidity for the first seven days.
    • SushiSwap is a fork of Uniswap and uses the same exact AMM, i.e., the constant product market maker model. 
  • Balancer launched in 2020 to allow liquidity pools to exist with more than just two tokens inside. Balancer pools can have multiple tokens in a single liquidity pool, providing users with more options when performing swaps, as well as enabling liquidity providers to have exposure to a basket of assets instead of only two. For this reason, Balancer pools have often been compared to index funds.
    • Since Balancer pools contain more than two tokens, the AMM model they use has a slightly different formula (which accomplishes the same objective). Instead of two assets multiplying together to create a constant, pools of three assets or more are multiplied instead. When there is an equal value of each token, each is weighted identically. This is called the constant mean market maker formula, with “constant mean” hinting at the stable average that the product of multiplication should have. This can be seen in the formula (x*y*z)^(1/3) = k

Why Liquidity Pools Matter

Liquidity pools allow anyone to generate a portion of the profits people pay when trading assets. The profits that would have otherwise been generated by a company instead go to individuals. While companies can, of course, still provide liquidity to pools, the innovation is in allowing anyone to do so without the need for permission.

In providing this service, liquidity pools and DEXes allow anyone to trade assets transparently and without needing to trust a centralized exchange. The security of smart contracts and the underlying blockchain provide guarantees that assets are tradable by users and withdrawable by providers. The security provided by a company is provided by the blockchain instead.