Cointime

Download App
iOS & Android

Decentralized Exchanges — The Only Article You Have to Read About DEX

Validated Individual Expert

What are DEXes? And how can we use them? Are Decentralized Exchanges better than centralized exchanges? Have you ever wondered why and how many DeFi protocols all follow a particular guideline or structure of code or governance that all dApps should follow?

In this article, we will dissect what exactly a DEX is, how they work, and examine the biggest DEX and the pros and cons of using a DEX. Shall we?

BTW, if you are really interested in learning everything about DeFi, check this out.

What are Decentralized Exchange (DEX) Protocols

Decentralized exchanges are a marketplace that facilitates the exchange of one cryptocurrency to the other with no centralized parties involved. Everything is automated via Smart Contracts on the blockchain. The core capabilities of every DEX are buying, selling, trading, and portfolio management. These rely on the smart contract to lock funds (tokens) and automate transactions through AMM — Automated Market Maker.

In a DEX, users can only swap cryptocurrency for another cryptocurrency. Unlike centralized finance, where a user is matched with an individual seller and can set a buy order, the AMM offers tokens from a pool where people (also called liquidity providers) have deposited their tokens over time. This is called liquidity pool or yield farming.

Liquidity pools are the mechanism by which users can deposit their assets into a DEX smart contract so other traders can have access to swap their tokens. We will talk further about this later in this article.

What is the biggest DEX?

The first ever DEX in the Ethereum network was EtherDelta launched in 2016. EtherDelta is still active, by the way. From inception till now, many other dexes have emerged. We have the likes of CurveBalancerdYdX (for perpetual), Sushi swapPancake swapUniswapQuickswap, and the other numerous “swaps”. In all these, a few of the major game players are Uniswap, Curve, and dYdX.

Why are these considered the biggest DEX? If we look at their stats on coinmarketcap, the market cap for Uniswap, Curve and Pancake Swap are approximately $4.9b, $3.3b, and $639m, respectively. This shows they are one of the big guys on the block.

Additionally, as you can see below, the top DEX according to their TVL — Total Value Locked — are Curve, Uniswap, Pnacakeswap, and Balancer.

Top Decentralized Exchanges by TVL. You can check this sourceto see many other DEX.

Later in this article, we will do a tutorial on how to use Uniswap.

How do DEXes work?

The process of using a DEX is very very simple. Actually simple than using most banking centralized exchange apps.

A part of this process involves yield farming (or liquidity providing). Most DEX use an Automated Market Maker (AMM), which is also known as the liquidity pool algorithm. This enables users to trade with a pool of funds from the liquidity pools. The AMM matches buyer's and seller's orders, sets prices, and allows traders to trade algorithmically using the smart contract. Unlike in traditional order books, you don’t have a buy or stop-loss order (except if you use platforms like https://dydx.exchange/ or https://gmx.io/.)

Automated Market Marker(AMM)

Let’s talk further on AMM. AMM allows traders to buy/sell assets based on algorithms. It is basically supply and demand sequence but based on an algorithm that works on the top of the liquidity pool. The law of demand and supply states that “the higher the demand, the lower the supply.” We could use a simple analogy of farming. Let’s add a little drama to it...

POV: *Alice is a mango farmer while Bob owns a cherry farm*

Alice: Hey bob, I am tired of eating only mangoes. Do you mind if we exchange produce so I can have a taste of other fruits?

Bob: *excitely* oh my!…he said, you took it outta my mouth. I thought I would die eating cherries all my life.

*They both had a plan in place to swap their produce for each other based on its value. For each mango, Bob gives Alice 10 cherries. This goes on for a few months. One day, Bob meets Alice with a suggestion*

Bob: Why don’t we check if there are other farmers like us who would like to exchange their farm produce for ours as well?

Alice: Oh, sure…why not?!

They got some other addition to the team. Frank and Tom. Frank farms Tomato, while Tom rears livestock. They all agree to store their produce in a barn. This barn is the liquidity pool. Here the exchange happens, and they can trade their produce for another among available produce in the pool. All these farmers are the liquidity providers.

There is a twist to this, however. They all want structure. They agreed on a formula to sort this. The value of each produce is determined against the liquidity pool(pl). The price feeds are calculated based on the Constant Product Market Maker. So we have,

X * Y = K

Where X = Quantity of asset X in the pool

Y = Quantity of asset Y in the pool

K = A total of all asset that needs to be in the pool. This value is Constant.

Let us assume each farmer’s produce deposited cost $1000 each. This shows they have $4000 total value locked (TVL) in the pool. Note that assets exchange are usually in a pair. So Alice deposits $1000 worth of mangoes, locked in, and she gets rewarded the lp token based on the portion of what was deposited. Bob does the same thing and gets rewarded the lp token as well. The pool is equally balanced, hence K will be $2000. So when people buy more mangoes, we have more cherries and fewer mangoes in the pool. This means more cherries will be sold for a lower price, and mangoes will be more expensive to balance their value in the pool. This could also lead to Impermanent loss.

Liquidity Pools

Liquidy providers provide tokens to the pool and earn rewards/interest on the funds/assets locked in the liquidity pool.

Anyone can add liquidity to Uniswap (or to other DEXes). You will earn part of the fees that are collected from the people that trade the pair that you have provided (in the screenshot above, it’s DAI/ETH.) The fees in this case are 0.3%, and at the end, it may represent a few percentage points for the LPs.

Users who want to swap their tokens for another token go into the pool and perform their transaction to swap their tokens without an intermediary taking custody of the funds.

BTW, I explain all these concepts in depth here.

Impermanent loss

Liquidity providers are exposed to impermanent loss. This loss is not permanent, hence the name “impermanent loss.”

Impermanent loss only happens if the prices of the assets change. It doesn’t necessarily mean you will lose money. Instead, in some circumstances, you’d be better off just holding those assets. Changes in the token price affect the composition of the liquidity pool, resulting in having slightly more or less of a particular token. The LP has a right to earn a fee on every transaction in the pool, and this may mitigate the impermanent loss. However, in the end, there are variations in the quantity of the assets in the pool.

Changes in the price of the assets that you provide will translate into a different token distribution. which leads to impermanent loss.

Impermanent Loss can also be defined as the difference between simply holding an asset and using that asset to provide liquidity to a pool

Note that you don’t need to worry about impermanent loss if you just wish to trade on a dex.

Slippage

Slippage is when the market price is different from the transaction price. It can happen in any market. This can happen in any market. There are a few reasons why slippage may happen:

  1. Market with lower liquidity
  2. High volatility
  3. Low market dept
  4. When a large order is executed, and there is not enough volume to maintain the current bid/ask.

Example of slippage in a low liquidity token pair on Uniswap.

How to use Uniswap?

We’re going to be doing a hands-on of one of the top DEX: Uniswap.

Uniswap is more than an exchange platform. It is a decentralized liquidity protocol. To use Uniswap to trade or exchange/swap crypto, follow the steps below:

  1. Visit the Uniswap website.
  2. Click on the launch app

3. Select the token you want to swap for the other and insert the amount.

4. Click on connect wallet (make sure you have actual funds in your wallet for this to go through. lol)

5. Don’t forget to connect to the right network on your wallet as well.

6. “Confirm swap.” Your metamask wallet shows up and then approve the transaction.

You should notice on the menu bar that we have the options “swap”, “pool”, “vote”, and”charts”.

Let’s talk about the “pool” menu. You should see a list of tokens in the pool that you already deposit. If not, follow along, and let’s make some investments to earn some yield…

  1. Go to the liquidity pool. You will see numerous tokens/coins listed.
  2. Deposit into the pool

Congratulations on being a liquidity provider and “low-budget investor.” The yield generated is not high, but Uniswap is quite awell battle-tested and safe DEX. Always make sure that you interact only with solid DEX that has been audited!

Downsides of using a dex

  • No user education or support. Only community support
  • Low liquidity. If you are a whale and if you sell a ton of tokens, you can crash the price, and if you buy a lot, you can hike the price.
  • Hacker attacks in small, untested, and not audited DEXes.
Comments

All Comments

Recommended for you

  • Iranian Military: Ready to Respond Decisively to 'Enemy's Breach of Promises'

    On April 21, local time, Abdollahi, commander of the Khatam al-Anbiya Central Command of the Iranian Armed Forces, stated that Iran is prepared to respond decisively to the 'enemy's breach of promises.' Abdollahi emphasized that the current Iranian military possesses 'authority, readiness, and comprehensive strategic capabilities.' He noted that the Islamic Revolutionary Guard Corps and other defense forces have demonstrated combat capabilities in relevant operations, putting 'Israel and the United States in a difficult and fatigued position,' forcing them to 'seek a ceasefire.' Abdollahi also stressed that the Iranian armed forces maintain a high level of unity with the government and the people under the supreme leader's unified command, and will respond 'decisively, resolutely, and promptly' to any threats and actions. (CCTV News)

  • Another Iranian Oil Tanker Returns to Iran After Breaking US Blockade

    On April 21, according to CCTV News, maritime intelligence company 'TankerTrackers' reported that a tanker belonging to the National Iranian Tanker Company returned to Iran after unloading approximately 2 million barrels of crude oil in Indonesia, crossing the relevant maritime blockade line. The tanker is currently en route to Iran's main oil export hub, Khark Island, and is expected to arrive on April 22 local time. It is reported that the tanker set sail from Iran in late March, heading towards the Riau Islands of Indonesia.

  • White House: US and Iran on the Verge of Reaching an Agreement

    On April 21, White House Press Secretary Kayleigh McEnany stated in an interview with Fox News on the evening of the 20th that the United States and Iran are on the "verge of reaching an agreement." McEnany remarked, "The US has never been closer to achieving a truly good deal." However, she did not disclose any information regarding the current status of the negotiations. McEnany noted that even if an agreement is not reached, President Trump has multiple options and is not afraid to utilize these measures. Previous actions have demonstrated that Trump is not just "bluffing."

  • Kelp DAO Attacker Transfers 30,800 ETH to Special Address

    On April 21, news emerged that, according to monitoring by PeckShield, the Kelp DAO attacker transferred 30,800 ETH to a special address starting with 0x00000, possibly indicating a destruction action.

  • Trump: 'Midnight Hammer' Completely Dismantled Iran's Nuclear Dust Base

    On April 21, U.S. President Trump stated that the 'Midnight Hammer' operation has completely destroyed the 'nuclear dust' base within Iran. As a result, the cleanup will be a long and arduous process. The fake news media, including CNN and other corrupt media networks and platforms, have failed to give our great pilots the credit they deserve, instead always attempting to belittle and undermine them. They are losers!!! (Dongxin News Agency)

  • BTC Drops Below $76,000

    Market data shows that BTC has dropped below $76,000, currently priced at $75,999.63, with a 24-hour increase of 1.68%. The market is experiencing significant volatility, so please ensure proper risk management.

  • Japan Officially Allows Export of Lethal Weapons Through Cabinet Resolution

    On April 21, according to Kyodo News, the Japanese government officially revised the 'Three Principles on Transfer of Defense Equipment' and its operational guidelines during a cabinet meeting, which will, in principle, allow the export of lethal weapons. (Xinhua News Agency)

  • Trump Claims Iran Will Negotiate

    On April 21, during a phone interview with CNN, U.S. President Trump stated that Iran "will negotiate" and expressed confidence in potential talks set to take place in Pakistan. Trump remarked, "They will negotiate; if they don't, they will face unprecedented problems." He also expressed hope that both sides could reach a "fair agreement" and emphasized that Iran "will not have nuclear weapons." Additionally, he defended military actions against Iran by stating there was "no choice" and claimed that they would ultimately "wrap things up."

  • Amazon to Invest Additional $5 Billion in Anthropic

    On April 21, Amazon announced on Monday that it will invest an additional $5 billion in the artificial intelligence company Anthropic, bringing the total investment to as much as $20 billion. Anthropic develops the Claude chatbot and programming tools, and plans to invest over $100 billion in Amazon's cloud technology and chips over the next decade.