Understanding the Technology Behind Decentralized Exchanges

A deeper dive into liquidity pools, automated market makers, yield farming and other aspects of DEXs. This is the third part of a continuing series on understanding DeFi.

AccessTimeIconMar 17, 2022 at 12:50 p.m. UTC
Updated Apr 10, 2024 at 2:07 a.m. UTC

Financial advisors are very familiar with traditional finance and how the industry works. Registered investment advisory firms are clients of custodians like Fidelity, Schwab and IBRK that have relationships with exchanges like the New York Stock Exchange and Nasdaq.

Individual securities transact on exchanges, and portfolios of securities are held with custodians. Clients of firms have log-in access to the platforms built by custodians, and the advisors can manage those assets through the custodian. This is how the traditional financial system has worked for decades.

Decentralized finance (DeFi), however, is much different. It’s important that advisors understand this new system so that they will be prepared to explain it to clients and help make recommendations on crypto assets.

This article originally appeared in Crypto for Advisors, CoinDesk’s weekly newsletter defining crypto, digital assets and the future of finance. Sign up here to get it in your inbox every Thursday.

At the core of DeFi sit decentralized exchanges, or DEXs for short. (I wrote about the importance of DEXs in last week’s newsletter, for the second part of this continuing series on understanding DeFi.) DEXs facilitate the trading of digital assets for users around the world.

Unlike centralized exchanges like the NYSE, DEXs don't use the order book system, which has been used for decades and, to be quite honest, continues to work well today. The reason that DEXs don't use the time-proven order book system is because it requires a team of centralized individuals and technology to run. Instead, DEXs use smart contracts to facilitate trading. The smart contract that governs the trading on a DEX is called a liquidity pool.

Read the first and second parts of this series on understanding DeFi.

What’s a liquidity pool, exactly?

A liquidity pool is simply a pool of locked assets governed by a smart contract (or a piece of software code) that is used by the DEX to trade – often called “swapping” – crypto assets. Liquidity pools are crowdsourced, meaning the paired assets in the pool are not pledged by one single person or institution. True to the decentralized and grassroots style of crypto, liquidity pools come into existence from contributions made by the crypto community. Liquidity pools can be thought of as a giant pot of paired assets that facilitates swapping between currencies.

What are automated market makers?

Liquidity pools are governed by automated market makers, or AMMs, software code that governs and automates the process of swapping assets and providing liquidity and that allows digital assets to be traded on a DEX by using the liquidity pool. On platforms with AMMs, users don't trade with another counterparty (think of buyer and seller in the traditional order book system); instead, they trade against the pool of paired assets.

To understand AMMs, one must understand the mathematical formula that sits at the core of the AMM:

X * Y = k

In a blog post written by Ethereum co-founder Vitalik Buterin, he proposed the AMM formula, and shortly after that, AMM protocols were born. In the formula, X represents Token A, Y represents Token B, and k represents a constant balance between the two tokens.

In a liquidity pool of two paired assets, if the price of X increases, the price of Y decreases, and therefore the constant, k, remains the same. Only when new assets are pledged to the liquidity pool does the total pool volume increase. This formula governs the liquidity pool and creates a state of balance between the prices of the tokens. Buying Token A will increase the price of Token A, and selling Token A will decrease the price of Token A. The opposite will happen to Token B in the liquidity pool.

Another component of AMMs is the arbitrage feature. These smart contracts are able to compare the prices of paired assets in their own pools with those across the DeFi ecosystem. If the price varies too much, the AMM will incentivize traders to take advantage of the mispricing in the native liquidity and the outside pools, and with this incentive, the native AMM reaches equilibrium once again.

Understanding yield farming

Not only do AMMs incentivize traders to arbitrage cross-pool prices, but the actual liquidity pools themselves give participants an incentive to pledge assets to the pools. Yield farming is a popular way to generate income in the crypto ecosystem and offers an attractive opportunity for token holders to generate a return besides relying solely on price appreciation.

When an individual pledges paired assets into the liquidity pool, he begins to generate tokenized rewards. When a user wants to swap assets through a pool, the pool charges a small fee to the user in order to facilitate the swap. That fee is then paid to the individuals who have pledged their assets to the pool. This fee is often paid out as a liquidity provider (LP) token.

For example, a user may pledge assets to a liquidity pool on a decentralized exchange, such as PancakeSwap. The pledger will generate a yield on his pledged asset as determined by the AMM, and in exchange for providing liquidity, the user will be paid in CAKE, the native LP token that was created by PancakeSwap. The user can then sell his LP token for any other token he wishes.

What to be careful about

Caution is important when it comes to yield farming. New asset pairs, with very low liquidity, often incentivize individuals to contribute to the pool by offering a very high yield. Often these pairs and pools are new, and users face an increased risk of being a victim of fraud or theft. Most of the new pools provide an attractive way for malicious actors to perform an exit scam called a “rug pull.” This is a scam where project creators collect tokens from the community and then abandon the project without repaying the tokens.

Another form of risk is called impermanent loss, which occurs mainly during a period of high volatility, something quite common in cryptocurrency. When the price of one token in a pool moves significantly compared with the price of the other token and liquidity providers decide to withdraw assets from the pool, the individuals who have pledged assets may have less than their original contribution. If the liquidity provider decides to keep assets in the pool, it is possible that the liquidity value returns to break-even given enough time and given a decrease in volatility.

Navigating a new system

So how is an advisor supposed to navigate this entirely new system of asset swapping, decentralization and yield farming, and the associated risks? It’s important to know that the traditional financial system isn’t going away any time soon. However, the blockchain technology that powers DeFi is extremely appealing, for both users and providers in the finance industry.

Advisors need to understand how this technology works and be prepared to see the DeFi industry grow over the next few years. The improvements in efficiency and costs are appealing to consumers and will increase the user experience for our clients.


Please note that our privacy policy, terms of use, cookies, and do not sell my personal information has been updated.

CoinDesk is an award-winning media outlet that covers the cryptocurrency industry. Its journalists abide by a strict set of editorial policies. In November 2023, CoinDesk was acquired by the Bullish group, owner of Bullish, a regulated, digital assets exchange. The Bullish group is majority-owned by Block.one; both companies have interests in a variety of blockchain and digital asset businesses and significant holdings of digital assets, including bitcoin. CoinDesk operates as an independent subsidiary with an editorial committee to protect journalistic independence. CoinDesk employees, including journalists, may receive options in the Bullish group as part of their compensation.

Jackson Wood

Jackson Wood is a portfolio manager at Freedom Day Solutions, where he manages the crypto strategy. He is a contributing writer for CoinDesk’s Crypto Explainer+ and the Crypto for Advisors newsletter.