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

  • Lightning In A High Fee Environment: Implications for Bitcoin’s Scalability

    The topic of scaling Bitcoin dates back to its very first mailing post. In response to Satoshi’s original message, James McDonald said, “We very, very much need such a system, but the way I understand your proposal, it does not seem to scale to the required size” — a remark that probably wasn’t the welcome Satoshi had anticipated. Nonetheless, this marked the beginning of a seemingly never ending, complex debate.

  • Gaming platform Param Labs completes $7 million financing, led by Animoca Brands

    Gaming platform Param Labs has completed a $7 million financing round, led by Animoca Brands with participation from Delphi Ventures and Cypher Capital. Param Labs aims to establish a gaming ecosystem managed by its native PARAM token, which is set to launch soon. The company's first game, "Kiraverse," is a multiplayer shooting game that allows players to earn money while playing.

  • Blockchain SaaS solution AfriDex completes $5 million Pre-Seed round of financing, led by Endeavor Ventures

    AfriDex, a blockchain software-as-a-service solution based in London, UK, announced the completion of a $5 million Pre-Seed round of financing with Endeavor Ventures leading the investment and African Crops Limited, Oldenburg Vineyards, and Hank Oberoi participating. AfriDex is currently focused on the agricultural market, providing comprehensive on-chain solutions to support and protect supply chain participants, utilizing blockchain technology to achieve traceability, frictionless payments, anti-fraud transactions, verified authentication, simplified tax and subsidy management. (finsmes)

  • Rugpull occurs on Ethereum with fake NOT tokens

    PeckShield has monitored that the fake token Notcoin (NOT) on Ethereum has dropped 100%. An address starting with 0xE0eB sold 1,645,040,633,338,481.95 NOT and exchanged it for 93.5 WETH (valued at $281,000 USD). Note: Rugpull tokens have the same name as legitimate tokens.

  • U.S. senators propose spending $32 billion to develop AI and build safeguards around it

    A bipartisan group of four senators led by Chuck Schumer, the leader of the majority party in the United States, has proposed that Congress spend at least $32 billion over the next three years to develop artificial intelligence (AI) and establish safeguards around it.

  • Swiss Federal Council Plans to Implement Crypto Asset Reporting Framework to Improve Tax Transparency

    The Swiss Federal Council (consisting of seven members jointly leading the Swiss government) plans to implement a Cryptocurrency Asset Reporting Framework (CARF) to increase tax transparency.On the 15th, the Federal Council issued a consultation document to investigate public opinion on joining the Automatic Exchange of Information (AEOI) to combat tax evasion and avoidance in cooperation with international tax authorities. Currently, Switzerland's joining of AEOI is scheduled for January 1, 2026. It is reported that the Organisation for Economic Co-operation and Development (OECD) established AEOI and other initiatives for the Group of Twenty (G20) countries, which later expanded to include other countries.Switzerland previously adopted the Common Reporting Standard (CRS) of the OECD in 2014, but did not include CARF regulating cryptocurrency assets and their providers.

  • Morgan Stanley disclosed that it invested nearly $270 million in Grayscale GBTC, becoming one of the largest holders

    On May 16th, Morgan Stanley disclosed in its Q1 13F filing with the SEC that it had invested $269.9 million in the Grayscale Bitcoin Trust (GBTC) to gain exposure to physical bitcoin ETFs. According to Fintel's data, this investment made it one of the largest holders of GBTC, after Susquehanna International Group (which invested $1 billion). Morgan Stanley is also one of many global systemically important banks (G-SIBs) that have disclosed investments in physical bitcoin ETFs, including Royal Bank of Canada, JPMorgan Chase, Wells Fargo, BNP Paribas, and UBS Group.

  • Coinbase Plans to Target Australia's Self-Managed Pensions Sector with New Service

    Coinbase is developing a service that will target Australia's self-managed pensions sector, according to the exchange's Asia-Pacific Managing Director John O'Loghlen. The move comes as self-managed funds in Australia have increasingly held crypto, with nearly A$1 billion ($664 million) allocated to crypto as of the latest data from the Australian Taxation Office. O'Loghlen stated that Coinbase's offering will aim to service these clients on a one-off basis and retain their business. The interest in crypto within the self-managed pensions sector may be driven by the recent momentum gained after spot-ETF approvals in the U.S. and the possibility of similar approvals in Australia this year.

  • The Hashgraph Association and QFC launch $50 million digital asset venture studio in Qatar

    The Hashgraph Association (THA) has announced a strategic partnership with the Qatar Financial Centre (QFC) to establish a $50 million digital asset venture studio called Digital Assets Venture Studio, which will support the development of decentralized finance (DeFi) solutions that comply with regulations and digital assets based on the Hedera distributed ledger technology (DLT) network. They will also invest in Web3 startups and DeFi projects supported by Hedera.

  • US lawmaker: SEC should repeal crypto accounting policy before Senate vote

    US legislator Wiley Nickel wrote a letter to Gary Gensler, Chairman of the US Securities and Exchange Commission (SEC), on May 15th, stating that the SEC should repeal the cryptocurrency accounting policy (SAB 121) before the Senate vote. Protecting investors is the mission of the US Securities and Exchange Commission, but SAB 121 does the opposite by preventing heavily regulated US banks from mass custody of digital assets. In addition, Wiley Nickel criticized the SEC for bypassing the rule-making process when issuing SAB 121, believing that the purpose of the cryptocurrency accounting policy is to clarify existing policies, not to create new ones.