What is the difference between DEX and CEX?
As in the traditional financial system, in the crypto world, there are also different systems to exchange our tokens: DEX and CEX.
For a better understanding, we could link the CEX system to traditional banks and the DEX system to peer-to-peer trading. That is to say, just as we can make transfers to another person through our bank accounts, which would act as a third-party intermediary, we can also do a P2P exchange, the same way as exchanging the money in person.
Let's start by explaining what is CEX
A CEX is a centralized exchange through which an intermediary intervenes in the exchange between two users. As in traditional banks, this intermediary takes charge of the management and controls the entire process, from the custody of the tokens to the actual exchange between the users.
This type of transaction is executed through an order book, where users specify their desire to buy or sell a certain amount of tokens at a certain price. The company is in charge of listening to these orders and executing them as soon as the conditions are met.
Who holds your assets in CEX?
In CEX, a company is in charge of the assets of those users who have decided to deposit their funds on its platform.
When users deposit their assets in a CEX, they are delegating the custody of their assets. As with traditional banks, when you delegate your assets to a CEX, it gives you in return symbolic tokens with which you can subsequently make exchanges within its platform; in a traditional bank, this corresponds to the bills and coins you withdraw instead of the gold they represent. In short, these tokens just represent the funds you have deposited and their current market value, but in no case are they actually in your possession. Once you decide to withdraw your assets from the CEX to your wallet, these assets return to your custody.
Is it safe to trade on CEX?
Nowadays, CEX platforms are popular since they are user-friendly and they facilitate operations and allow you to trade profitably, and quickly, as in Binance. However, delegating your assets to a centralized third party has its disadvantages.
Transactions are not entirely transparent to users, so we could say CEX platforms hide information about the processes of buying and selling assets, which is contrary to the main idea of cryptocurrencies. This could lead to malicious practices, such as money laundering or price manipulation.
On the other hand, the fact that all assets are under the custody of a single centralized system is very attractive to hackers. In recent years there have been several attacks, both internal and external, on the systems operated by CEX. These types of technical problems and coordinated attacks can lead to long periods of blocked funds or, in the worst case, can result in the complete loss of assets.
Central government intervention in CEX
In addition, CEX platforms are exposed to being audited by central governments, which can take the decision to freeze or confiscate users' funds, as well as force them to disclose all the users’ personal information.
So, what is a DEX?
Decentralized exchanges, unlike centralized exchange platforms, use the non-custodial framework; DEX platforms allow the exchange of cryptocurrencies between users following a peer-to-peer protocol, without the intervention of any third party intermediary. What does this mean? It means that users have full control over their assets.
This time, instead of relying on a centralized authority, users use blockchain technology to perform these exchanges. This type of trustless technology uses a predictable and transparent system that, because it is so highly unalterable, makes it unnecessary to place your trust in it.
How to trade on a DEX?
A DEX or decentralized exchange does not store user data. Moreover, in a DEX users are the sole holders and responsible for their funds.
These DEX platforms are governed by smart contracts designed on the blockchain and provide an interface that allows you to connect your decentralized wallet.
Users choose the amount and currency pair they want to exchange. Then, these smart contracts are in charge of finding a matching sell and buy order to proceed with the transaction. Once they match, the contract will be the one that accepts the assets of both users and performs the exchange.
This way, users can set automated orders from their wallets and sign for themselves each of their transactions, being part of the whole process.
Who holds your assets in DEX?
At the moment the purchase conditions of a user coincides with the sale conditions of another user, both users’ assets become under the custody of the DEX smart contract. The custody time will depend solely and exclusively on the execution time of the transaction.
Currently, most DEXs have a swap function, where the exchange takes place instantaneously once the smart contract finds the price match (for this, the DEX also relies on other smart contracts, such as crypto oracles). If both parties agree, the user will have to allow and authorize the exchange by confirming and signing it, which is done through the wallet. Once confirmed and signed, the agreed assets are automatically transferred to the respective wallets. This way, users have full control of their funds.
Some DEX platforms also have a trading function, which consists of the structuring of an order book, similar to what we see on centralized exchanges, but governed by smart contracts instead of a central authority. Users can set up an automatic buy or sell order to trade their cryptocurrencies in a decentralized manner. The custody time will depend on the execution time of the order; in case it is market order, it will be executed instantly; if a specific price is set, it will be executed when the desired conditions are met. In both cases, once the conditions match, the smart contract releases the tokens to the corresponding wallets.
Is it safe to use DEX for trading?
As it works through smart contracts, there is always the possibility of finding exploits or vulnerabilities in the code that could result in the loss of users' tokens. As we mentioned, while the transaction is being executed, users delegate the tokens to the DEX smart contract, during which time they delegate custody of their funds. In the event of a hacker detecting such vulnerabilities, these assets would be compromised.
There is already a history of attacks on DEX, so they are not exempt. Several platforms have suffered losses in the millions: Uniswap, Balancer, Bancor, and Synthetix stand out as victims of the most high-profile attacks to date.
Central government intervention in DEX
From a practical point of view, no. In DEXs everything runs on the blockchain, which makes it impossible for third parties to block or tap funds. In addition, decentralization guarantees the anonymity of users operating in DEX since they do not have to make any prior identification or registration. However, more and more countries are inviting their inhabitants to report all types of cryptocurrency transactions to avoid money laundering and tax evasion.
Would you like to change from CEX to DEX?
Now you know what is the difference between centralized and decentralized exchange, which one would you choose? It is a fact that both options have their pros and cons, however, the community is increasingly betting on decentralized exchanges and the environment that is generating around them.
More and more platforms are facilitating this type of exchange, so it is not surprising that soon most of the community will own their funds and will not depend on any CEX platform, advocating financial freedom and anonymity.