Decentralized Exchanges

Liquidity pools also play an important role within another key sector of DeFi. Decentralized exchanges, or DEXes, allow users to swap between different tokens using these pools to provide the liquidity necessary. These exchanges are completely automated through smart contracts and require no middlemen or any managing entity that can control the price of assets on it. To use the exchange, you’d simply connect your digital wallet, select the token you’d like to trade and the asset you will trade it for, and then sign the transaction. This process was discussed earlier in the Digital Identity on the Blockchain section.

Source: Crypto Robin

Instead of following the traditional order book model that stock trading uses, liquidity pools on DEXes mainly operate through the use of Automated Market Makers (AMMs). AMMs are algorithms that keep the balance of the pool equal to ensure there is a balance of both assets. For example, if a pool has ETH and USDC and someone uses that pool to swap their ETH into USDC, the AMM algorithm is responsible for ensuring that the trade gets executed without disrupting the balance of the pool. Check out this article by Chainlink for a more in-depth explanation on how AMMs work.

From a trader’s perspective, they are able to access these pools and deposit one asset in return for the other. If there are no existing pools for that pair, the AMM algorithm with utilize multiple pools to complete the trade. As a trader, you directly interact with the liquidity pools when completing your trades, where you deposit one asset into a liquidity pool in exchange for the other. The trades are automatically conducted by the smart contracts, and can be executed as long as there is enough liquidity in the pool to cover the transaction amount.

💡 The Trader’s perspective

Imagine you want to trade ETH for USDC. You would simply take your ETH, enter an amount, and swap it for USDC. On the backend, the DEX is actually utilizing the ETH/USDC pool to complete the transaction where it will deposit your ETH into the pool and the return the equivalent of USDC.

If no liquidity pool exists for the pair you want to trade, the DEX will exchange tokens across multiple pools. For example, you are on Sushiswap (a popular DEX) and you want to use the USDC token to buy the PENDLE token but there is no USDC/PENDLE pool. However, there is a ETH/USDC pool and a ETH/PENDLE pool. The exchange will automatically take your USDC and convert it to ETH in the first pool and then convert that ETH into PENDLE in the second pool. Here is how the transaction would appear on-chain:

Source: Sushiswap

The transaction action shows the direct path your transaction takes, where the USDC is first swapped for ETH and that ETH is then swapped for PENDLE.

Similar to the lending and borrowing method, a DEX lets lenders provide cryptocurrency as liquidity to execute trades.

In DEXes, lenders are called liquidity providers and the process of depositing liquidity into pools is known as yield farming, where a liquidity provider is generating (farming) yield by collecting fees. Users are able to exchange one asset for another through these pools, and the fees they pay to make the swap are then paid out to the liquidity providers as interest. This system creates a self-funding ecosystem for these exchanges to thrive in, where lenders are incentivized to provide their cryptocurrency as liquidity for traders and are then rewarded for their contribution through fees.

💡 The Lender’s perspective

Imagine you are a lender and you are holding the tokens ETH and USDC. You want to earn interest on those holdings so you decide to delegate them to a liquidity pool on Uniswap, one of the largest DEXes in the crypto ecosystem. To delegate, you’d simply go to Uniswap, select the pools section, and look for the ETH/USDC pair.

Source: Sushiswap

You can view all the information about this pool by going to the ‘Pools’ section of Uniswap and selecting that liquidity pool. You will then be able to see all the metrics regarding that pool such as volume, liquidity amount, and all the transactions that occur within that pool.

Once you select a pool, you then have two options:

  1. Provide liquidity for the entire pool price range, where the liquidity you put in will be distributed evenly across all price ranges of the assets
  2. Provide concentrated liquidity for a marginal price range, where the liquidity you put in will only be provided when the asset is within that range - for example when ETH is between $3,000 and $3,500

Source: Sushiswap

If you choose to provide for the entire pool price range, you will deposit an equal amount of both assets, for example $500 worth of ETH and $500 worth of USDC. Since your assets are spread more thinly however, you are less likely to generate as high of a yield as you would with having a more concentrated position.

In a concentrated position, since you are only supplying your assets for a portion of the price range, you will generate a much larger fee return - the smaller the range, the higher the fee potential. Depending on your position, you will be required to deposit more or less of one asset versus another - for example $300 of ETH and $700 of USDC.

The risk with concentrated positions is that if the price of that asset goes outside the range you are providing liquidity for, you will no longer earn interest on that position, and your position will be converted from both tokens to only one. For example, if your position in the ETH/USDC pool is for when ETH is between $3,000-$3,500 and the price of ETH drops below $3,000 then your position will be entirely converted to ETH by the AMM algorithm to maintain the balance of assets in the pool. Similarly, if the price of ETH rises above $3,500 then your entire position will be converted to USDC.

For a more in-depth tutorial on providing liquidity, check out the Uniswap documentation.

AMMs make decentralized exchanges much more efficient than other existing financial exchanges. They can operate 24/7, there are no order books like within stock exchanges where orders need to be matched, and anyone can use them to either trade or yield farm. However, it is still a developing system and comes with certain risks including vulnerability to hacks, arbitrage, and slippage.

There is also no way to directly buy crypto using fiat on these exchanges, where a user would have to use a 3rd party such as Moonshot or a centralized exchange such as Coinbase or Binance. These centralized exchanges are still important to have around today because they offer a much stronger and more pleasant user experience for new crypto users, and they make it very easy to get started by buying cryptocurrency using fiat money.

However, it is important to note that when crypto is sitting on a centralized exchange, it’s not really your crypto but rather a representation of your assets. Only once you move that crypto out of the exchange and into a digital wallet that you fully own does it become yours. DEXes, unlike centralized exchanges, have no ability or power to take away your money or kick you out of your digital wallet, making them significantly more independent than accounts on exchanges.

Practice Question

📋 Practice Question

Decentralized exchanges utilize a ____ system to automatically execute trades.