CEX vs DEX — What is the difference?

Cryptocurrency adoption is at an all-time high. Although NFTs, Metaverses, and web3 were the new narratives on the block for 2021, Defi kept growing and will most likely be here for the long haul.
But with a growing number of new users, some may be left wondering what the difference is between a Centralized Exchange and a Decentralized one. Our goal in this article is to help explain just that!

CEX — The brokers of Crypto

CEX is an abbreviation for centralized exchange. This means that all transactions taking place and funds being moved are under an entity’s custody.
For a user to be able to trade on an exchange, he needs to trust a third party to hold his funds. We do this all the time outside the crypto world, with banks. Probably everyone except our great-uncle that lives on a farm and keeps his money under the blanket do this.

So what do we need DEFI for?

Well, for starters, even though CEXs are an important part of the ecosystem for now, if we rely on them entirely for trading and holding crypto, then the whole concept of cryptocurrency and bitcoin, in which one is accountable and responsible for their financial independence, goes out of the window.

In theory, CEX’s would just replace banks as centralized entities, where the powerful and with insight could manipulate the markets and have leverage over the little guy. This is not to say that we should look at CEXs as the bad guys, but rather look at them as a means to fulfill a need, while DEFI is not fully functional yet.

DEX — Automated exchange

I guess by now you already guessed it: DEX stands for decentralized exchange. So, how does an exchange work without someone controlling it behind the scenes? The answer is one of the most amazing technologies that blockchain development brought us: Smart Contracts.

A Smart Contract(SC) is a piece of code that is written on top of a blockchain and that interacts with it. In essence, a DEX SC needs to replace the work done by the exchange worker: manage liquidity for trading pairs, provide info of the pair rate for the user, and execute trades for each pair.

And what about asset managing? Do we need to send our funds to the SC? That’s the beauty of DEFI, you can always keep custody of your funds when using a DEX, and only swap the amount you want to trade.

The next question is, how do SC operate pair liquidity? There are 2 essential methods for DEXs to operate: OrderBook (that’s the one used by exchanges) and AMM (Automated Market Maker)

Orderbook model — Classic style

Orderbook model is what all centralized exchanges use for their trading.
In this format, liquidity providers set an order for one of the assets of the trading pair, by inputting the amount and price at which they wish to sell/buy. Users can also perform a market order, where they are not bound to a specific price, and just input the number of funds they wish to spend and it will fill the limit sell orders until all the input is spent (this is similar to how an AMM swap works).

Orderbooks offer the advantage of setting limit or stop orders but are also more complicated for the average user. They also offer more difficulties when interacting with the blockchain, and are rarely used in Defi for that reason

AMM — Simple and elegant

The first protocol to use an AMM-based SC was Uniswap, the most popular Ethereum DEX to date. Their Smart Contract allowed users to provide liquidity and trade any erc20 token they wanted.

In an AMM DEX, a user can create a pair of tokens, let’s say $DOEX and $ADA.
The first user to create the pair will set the ratio for it, at least initially. So if I create the pair and put 1000 $DOEX and 2000 $ADA, I’m setting the price of $DOEX at 2 $ADA. Once users start trading, this ratio will move up or down, depending on what users are buying and selling.
Let’s imagine someone wants to buy 100 $DOEX. So at the initial rate, he would need to put 200 $ADA in the pool to remove 100 $DOEX (the math is not so simple, as the price impact would be higher due to having such a low liquidity amount, but for this example, let’s pretend it is).
So now, there are 900 $DOEX and 2200 $ADA in the pool. The price of $DOEX is now 2.44 $ADA.
The larger the liquidity provided, the lower the volatility. That’s why sometimes we are led to believe that an asset is worth a lot, but if you have a highly illiquid market, you will never be able to cash out on that current price. So for an AMM to be effective, it needs liquidity providers. Anyone can provide liquidity, but what’s in it for them?

Every trade charges a fee to the buyer. That fee is used to reward the liquidity providers. So any time a trade takes place, a small amount of the asset bought is rerouted to the Liquidity Pool. One may wonder then, why doesn’t everyone provide liquidity?
There is a risk every LP incurs in: Impermanent Loss (IL)

IL happens when the ratio between the 2 assets you are providing liquidity to changes (in either direction). As users are draining one asset, that one becomes more scarce in the pool and will be worth more. If the provider then removes the liquidity, his total value can be lower than if he had not provided liquidity in the first place.
If you want to get a better understanding of how IL works, we suggest you read this Binance academy article that does a terrific job of explaining it.

To sum up, here is what you can expect to lose by providing liquidity in an AMM:

  • 1.25x price change = 0.6% loss
  • 1.50x price change = 2.0% loss
  • 1.75x price change = 3.8% loss
  • 2x price change = 5.7% loss
  • 3x price change = 13.4% loss
  • 4x price change = 20.0% loss
  • 5x price change = 25.5% loss

So for highly volatile markets, IL can mean a real big loss, unless the volume makes it up for it in trading fees

That is pretty much all there is to know about an AMM model

We hope this article helped community members understand the difference between a CEX and a DEX. We will keep adding educational content, as we feel it is our duty as blockchain developers to help spread knowledge among retail investors.

Twitter | Telegram | Discord | Reddit | Medium




DOEX — AMM-based decentralized exchange for assets that are native to the Cardano Blockchain

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Build the future now! Enabling 30M developers with the Amberdata API

What’s new in the Terra Ecosystem with Do Kwon, CEO of Terraform Labs

The Growing World of Crypto Funds

DeFi Summit 2020 Hosts Gather Network as Partner & Speaker

Pawnfi- the future?

Bounce Presents: Fangible NFT Marketplace & the $1,000,000 Artist Grant Program

A Brand New NFT Drop — A Chest Unique Network announces a NFT to mark Polkadot Decoded 2022

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


DOEX — AMM-based decentralized exchange for assets that are native to the Cardano Blockchain

More from Medium

CDA and IOG Combine Forces

Into the Gaming Metaverse: Cardania Public Sale on KICK.IO Starts February 15

Introducing Gingermuns

Buying NFTs on Cardano