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

  • CoinShares Mining Report Update: Our Insights at the 2024 Halving

    Published to coincide with the 2024 Bitcoin halving, this research article aims to update and inform investors about the risks and opportunities facing the Bitcoin mining industry. Recently, we updated our data primarily based on the Q4 2023 reported figures. We have found that the average production cost per Bitcoin among listed mining companies is now approximately US$53,000.

  • Scammers use Google to promote fake Whales Market website to steal cryptocurrency

    According to a report from BleepingComputer, threat actors have discovered a method where scammers use Google's platform to promote phishing websites impersonating Whales Market in order to steal cryptocurrency. These fraudulent websites are placed as sponsored links (i.e. advertisements) at the top of Google search result pages, and despite the domain address displayed on the search result page appearing to be real, users will be redirected to the fake website upon clicking.

  • Elven CEO Junxiu Guo: Tokenization of Digital Assets Expands the Categories of Financial Assets

    On April 19, the 6th International Blockchain Science Conference ISC2024 was successfully held in Singapore. This event was co-hosted by the Inclusive Fintech Node (NiFT) at Singapore University of Social Sciences (SUSS) and the British Blockchain Association (BBA). Researchers and industry experts from around the world specializing in Web3, cryptocurrencies, and blockchain gathered together.

  • Cyvers: Hedgey suffered the same vulnerability on Arbitrum and lost about $42.8 million

    Cyvers Alerts on X platform stated that the system detected that the financial derivative agreement Hedgey Finance executed the same vulnerability on the ARB chain and gained approximately 42.8 million US dollars in profit.

  • Tether issues 1 billion USDT on Ethereum (authorized but not yet issued)

    Whale Alert has monitored Tether Treasury's addition of 1 billion USDT on Ethereum. Tether CEO Paolo Ardoino stated that this 1 billion USDT is a supplement to Ethereum inventory. This is an authorized but unissued transaction, which means that this issuance will be used for the next issuance request and cross-chain exchange inventory.

  • CertiK: Hedgey vulnerability was exploited and $1.9 million was stolen

    CertiK Alert posted on social media that it has detected that the on-chain token infrastructure protocol Hedgey has been exploited and stolen approximately 1.9 million US dollars.The attacker abused the createLockedCampaign function in flash loans to obtain approval for the use of tokens on the victim's contract. The USDC, NOBL, and MASA tokens in the victim's contract have been depleted.

  • Binance executives' bail application postponed again, still in custody

    The bail hearing for Binance executive Tigran Gambaryan has been postponed again by a Nigerian court, and he remains detained at the Kuje Correctional Center. The hearing is now scheduled for April 22, with the EFCC requesting time to respond to new arguments from the defense. Gambaryan's lawyer criticized the prosecution for failing to respond promptly. Binance has been accused of concealing the source of its income, while Gambaryan is accused of money laundering. In addition, he has also filed a lawsuit against the government for violating his human rights.

  • BTC breaks through $64,000

    The market shows BTC breaking through $64,000, now reporting at $64,012.44, with an intraday increase of 4.95%. The market fluctuates greatly, so please be prepared for risk control.

  • SEC accuses Justin Sun of frequent trips to the U.S. to sell tokens

    The US SEC has amended its lawsuit against Tron founder Sun Yuchen, stating that his frequent travel to multiple locations in the US allows the court to have corresponding jurisdiction. The SEC accuses Sun Yuchen and his company of selling unregistered securities through Tron and BitTorrent (BTT) tokens and engaging in manipulative money laundering transactions. The SEC claims that Sun Yuchen spent more than 380 days in the US from 2017 to 2019, with travel destinations including New York, Boston, and San Francisco. Sun Yuchen argues that the token sales were conducted entirely overseas, avoiding the US market, and therefore the SEC has no jurisdiction over him and the Tron Foundation, which is headquartered in Singapore. (Cointelegraph)

  • Cyvers Alerts: Multiple phishing transactions detected this morning

    Cyvers Alerts reported on X platform that multiple phishing transactions were discovered by the system this morning. The victims have approved the external owned accounts (EOA) of the phishers. We strongly recommend revoking the relevant approvals.