CEX vs DEX: Entrepreneurs point of view for Web3 Companies
DEX means "Decentralized exchange", while CEX means "centralized exchange".
Both terms refer to crypto exchange platforms where crypto-currency users can trade, buy and sell crypto-currencies seamlessly.
CEX offers benefits such as guaranteed liquidity, crypto to fiat exchange, ease of use, which have led to concerns about security, lack of full user ownership and lack of anonymity. Binance, Bitmax, Bitfinex, CEX.io, Kraken, and OKEx are examples of CEX.
DEX offers full coin ownership and private key control, token governance capability, and full anonymity but can be more complex to learn and use for beginners, does not allow fiat payments, and may have limited liquidity. PancakeSwap, Uniswap, Biswap are examples of DEX.
Let’s start by the beginning, what is a crypto exchange platform:
Just like stock exchanges exist as a means for people to buy and sell assets in the form of shares and derivatives, cryptocurrency exchanges are a crypto marketplace where people get to buy and sell blockchain-based coins and tokens. How your transaction works, and the possibilities for the user depend on the type of exchange you’re using.
ZOOM ON CEX:
This type of exchange platform is created and owned by a centralized organization that acts as intermediary connecting buyers and sellers.
They are custodians
One of the main characteristics of centralized exchanges is that they are depositories. What does this mean? It means that when you want to trade on a CEX, you keep your funds in a portfolio linked to the exchange itself, not in your own portfolio. Importantly, the exchange keeps the private keys to the wallet, not you - instead, you get the login details to the platform.
Centralized exchanges are very liquid.
The CEX facilitates trading by centrally matching users' buy and sell orders, known as an "order book" system. Again, it’s like the stock market. This means that liquidity is a function of the number of buys and sell orders in the books, and since most people's first steps into crypto take place on a centralized exchange, order volumes are necessarily higher than their decentralized counterparts.
*Companies like Binance, for example, have recorded over $30 billion in trades per day, and because the trading numbers are so high, you're likely to always find liquidity for the trade you need.
They collect & centralize data
With global standards evolving to accept that cryptocurrency is here to stay, exchanges have made concerted efforts to ensure that coins and tokens cannot be used to launder money. So, before you start trading on a centralized exchange, you will need to produce documents confirming your identity and sometimes your address to coordinate with these measures.
ZOOM ON DEX
Like a CEX, the purpose of a decentralized exchange is to allow you to trade your crypto assets. But the structure of this type of exchange is fundamentally different. There are two main types of DEX:
automated market makers
Like centralized exchanges, the older generation of DEXs tends to operate using a decentralized version of an order book system.
Here is some DEXs Order Book: LoopRing, Gnosis Protocol or IDEX
All of these use an algorithm (instead of a central platform) to find and route the trades between individual users, and smart contracts record the exchanges on the blockchain to reflect the coins and tokens that are moving between buyers and sellers. In other words, there is a market – but no one is in the middle selling for you, only an algorithm. This is how the service remains decentralized.
Automated Market Maker
Also known as AMM DEXs, they were developed in response to a key problem prevalent in crypto-currency exchanges - lack of liquidity. You may already be familiar with some of these protocols - SushiSwap, Uniswap and Compound are just a few of the most common.
Instead of matching buyers and sellers, trades on the AMM DEX are conducted using pools of liquidity managed by DEX's own smart contract. Liquidity comes from users who donate their coins or tokens (in trading pairs) in exchange for passive income or, if they take a more calculated approach, as part of a broader yield farming strategy. These revenues come from the true transactions of the protocol.
The exchange itself automatically prices trades between coins, based on supply and demand for those assets. This is done through an algorithm that constantly rebalances to reflect changes in liquidity and is not necessarily in sync with the rest of the market - which, by the way, is a great opportunity for eagle-eyed traders to make returns through arbitrage. This video explains very well how the automated market maker works.
You can see that it's super convenient! I can buy crypto in one go, in a fraction of a second, just by interacting with the liquidity pool, even if no one else is available in the market right now to sell them to me. The liquidity pool (in a smart contract) will then be able to handle the transactions on its own, and vary the price of its assets so that the value always remains the same on each side. Great, isn't it?
However, there is a small flaw: if the liquidity pool is too small, then the price of the assets will become very volatile very quickly.
Let's imagine that in our pool there is 1 BTC and 36,000 USDT. If I want to buy 0.5 BTC, I want to buy half the pool.
If the protocol would let me buy half of the pool at the price of 36,000 USDT/BTC, it would let the pool be emptied of BTC without making the price fluctuate. That's why for large transactions compared to the size of the liquidity pool, we have Price Impact.
Price Impact is the price variation that is uniquely related to your transaction on the liquidity pool. It can be as low as 0.01% or as high as 49% (the maximum allowed generally). This means that after our purchase, the price of BTC will be 49% higher, and we will pay more.
We understand that the problem with liquidity pools is that if they are too small compared to the volume, they quickly become very volatile.
Hence the challenge for DEX to have the largest possible liquidity pools to support the volume!
Why the price of a token on a CEX / DEX can differ significantly
One day I wake up, and I see the StaySAFU token worth 40$ on DEX and 12$ on a CEX, I didn't really understand, a very simple explanation makes it clear.
When a token is added to a CEX, trading is managed by an order book that controls supply and demand locally, in the CEX used (not in all CEXs).
When someone buys a token in this CEX at the market price, the price of the token corresponds to the cheapest offer that someone sells for the same token, in the same CEX. Even if a person wants to buy a token at the current token price, define by the liquidity of the token ($12 on a DEX for example) the price (bought at the market) on a CEX will be the one of the people who sell that same token at the lowest price on the CEX and not the one displayed on the DEX.
When there are not a lot of transactions and a lot of volatility, we can find situations where the price is completely different from CEX / DEX. For the price to be coherent in a CEX, there must be a lot of transactions that frame each time the price on the market reality. If there are few transactions and a lot of volatility, the prices can be disproportionate.
P.S: I talk about the StaySAFU token a lot because it was one of the first tokens we made, and we made a lot of mistakes that we learned from. StaySAFU was initially a token project, then it became a tool and today it is a security label in DeFi, with the realization of Audit / KYC of blockchain projects. So I do not encourage you to invest in this token.