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

  • The Bitcoin-native stablecoin bitSmiley Alphanet V1 Surpasses $24M TVL in 24 Hours!

    In a remarkable achievement, bitSmiley's Alphanet V1 skyrocketed to over $24 million in TVL within just 24 hours of its launch with over 6 million bitUSD stablecoins minted through over-collateralization. bitSmiley stands as a pioneering initiative, introducing stablecoins by over-collateralizing Bitcoin.

  • Securitize raises $47M in funding led by BlackRock to enhance innovation and expansion in digital asset securities ecosystem

    Miami-based company Securitize, which specializes in tokenizing real-world assets, has raised $47 million in funding. The round was led by BlackRock, with participation from Hamilton Lane, ParaFi Capital, Tradeweb Markets, Aptos Labs, Circle, and Paxos. The funds will be used to enhance the company's innovation and expansion as it consolidates its position in the digital asset securities ecosystem. BlackRock's first tokenized fund, the BlackRock USD Institutional Digital Liquidity Fund, has also been launched on Ethereum and is available to investors by subscribing to the fund with Securitize.

  • Web3 game Shadow War completes $5 million financing, led by Momentum 6

    Game studio Patriots Division has raised $5 million in seed and Series A financing for its Web3 game Shadow War. The Series A funding was led by Momentum 6, with participation from iAngels, Cointelligence Fund, Xborg, Andromeda VC, Cogitent Ventures, and Cluster Capital.

  • BTC falls below $57,000

    According to market data, BTC has fallen below $57,000 and is currently trading at $56,999.99, with a daily decline of 5.48%. The market is volatile, so please be prepared for risk control.

  • CoreWeave, an AI cloud service provider, completes $1.1 billion Series C financing led by Coatue

    CoreWeave, a cloud service provider focusing on artificial intelligence, announced the completion of a $110 million Series C financing round. Coatue led this round of financing, with Magnetar (the main investor in the previous round), Altimeter Capital, Fidelity Management & Research Company, and Lykos Global Management participating.

  • Cointime MAY 1 News Express

    1.Celsius Network destroys 94% of total supply of CEL, worth over $89 million2.USDC Treasury destroyed more than 200 million USDC3.Pike was suspected of being hacked and lost 479 ETH4.Fantom launches $6.5 million development fund, betting on safer memecoins5.Yesterday, the U.S. spot Bitcoin ETF had a net outflow of $162 million6.The balance of Binance Bitcoin wallet increased by 6249.36 in the past 24 hours, and 15565.89 inflows in the past 7 days7.In April, NFT sales on the Bitcoin chain exceeded US$685 million, setting the third highest monthly record in history8.On-chain content distribution agreement Metale Protocol completes additional $2 million in seed round financing9.A whale deposited 1,140 MKR into Coinbase, losing about $1.1 million10.The Bitcoin stablecoin project, bitSmiley, goes live with its Alphanet V1, marking its debut deployment on the Bitcoin Layer 2 network, Bitlayer.

  • CZ sentenced: A chronology of Binance’s legal battles in the US

    Former Binance CEO Changpeng “CZ” Zhao was sentenced to four months in prison for violating U.S. money laundering laws.

  • Here’s what happened in crypto today

    Need to know what happened in crypto today? Here is the latest news on daily trends and events impacting Bitcoin price, blockchain, DeFi, NFTs, Web3 and crypto regulation.

  • Barcelona-based Web3 Video Games Startup GFAL Raises $3.2M in Seed Funding to Expand Team and Accelerate Production Plans

    Barcelona-based startup GFAL has secured $3.2 million in seed funding from investors including Supercell Ltd and Mitch Lasky. The company plans to use the funds to expand its team and accelerate its game production plans, which leverage AI and Web3 technology for immersive gameplay. GFAL's Elemental Raiders mobile game soft-launched in March 2023, with plans to build on this for a 2024 launch. CEO Manel Sort expressed gratitude for the investment and excitement to work with former colleagues from Digital Chocolate.

  • US Court to hear proposed remedies from Terraform Labs, Do Kwon in May

    The SEC proposed that Do Kwon and Terraform pay roughly $5.3 billion in disgorgement, prejudgment interest and civil penalties, while the firm’s team suggested only $1 million.