In this post we share what's a DEX, how decentralized exchanges work and why they are different to their centralized counterparts.
- A decentralized exchange or DEX is a protocol/application based on blockchain.
- A clear advantage of DEX compared to centralized exchanges is that by functioning as a set of smart contracts programmed in the blockchain, there are never system stops.
- Bancor and Uniswap -each with its characteristics- are the most prominent representatives of on-chain DEXs called AMM -Automated Market Makers.
A decentralized exchange or DEX is a protocol/application based on blockchain, which, unlike traditional exchanges, allows its users to trade crypto assets - place orders, match prices and execute settlements - without the need for a central authority acting as an intermediary.
DEXs are one of the cornerstones of the DeFi -Decentralized Finance- movement. Although they can be found on various platforms, the ones that move the most volume and attract the most significant number of users use the Ethereum network as a base.
DEXs can be understood as an extension of the original promise of cryptocurrencies and blockchain technology: mechanisms that allow value to be exchanged without relinquishing custody of assets and without delegating the maintenance of balances to a third party.
Those programmed on public, decentralized, and permissionless blockchains such as Ethereum prevent censorship actions, confiscation of funds, or access restrictions based on the user's origin or socioeconomic criteria -basically, because they do not impose KYC processes. , that is user identification. This means that they are platforms that protect the privacy of their participants in a much more effective way.
Understanding how a DEX works
To understand how DEXs work, there is nothing better than comparing them to CEXs - the traditional centralized cryptocurrency exchanges where most of the trading volume is still concentrated today.
In this centralized platform, the user leaves the custody of their funds - that is, they must deposit their cryptocurrencies in the exchange's wallet. Instead of controlling their private keys, they operate through an account with a username and password.
The exchange is in charge of operating the order book where the orders are matched, reaching agreements with professional market makers to achieve greater liquidity, and offering banking gateway services -to buy cryptocurrencies with fiat by debit card, credit card, or bank transfer.
The problem with this model is that it requires a conventional business structure - the exchange usually has a physical headquarters and centralized servers located in a geographical area with specific sectoral regulations. This generally requires registering and identifying users who want to access the service through KYC processes and the implementation of AML policies.
Depending on the regulation to which the exchange is subject or applicable to its users based on their geographical origin, there may be certain restrictions regarding the type of assets that can be traded.
To this, we must add that, by depending on centralized servers and concentrating the funds of thousands of users, they are a priority target for hackers - who see them as coveted loot. Once or twice a year, there are more or less relevant hacks of centralized exchanges.
To DEX 🔁
DEXs, on the other hand, usually function as decentralized protocols deployed on a blockchain - made up of a series of smart contracts, which are responsible for executing the necessary operations to execute exchanges in a "trustless" and censorship-resistant manner.
This means that the user no longer loses custody of their funds - cryptocurrencies aren't transferred to a third party acting as operator, nor are they subject to counterpart risk.
Generally, trading is done directly from the user's wallet, so the user continues to control their private keys - exceptions in which there is participation in a pool.
Once the user signs the orders with their keys, the smart contracts of the decentralized exchange or DEX are in charge of executing the trade and settling the operation in the blockchain.
This design makes DEXs much more secure, although it has the downside that forces the user to take responsibility for their funds - if their seed phrase or private key is lost, it will be impossible to recover them.
What is an advantage can generate usability problems - it will always be more comfortable and more accessible for a user to create an account with an email and a password in a CEX than to take care of saving and managing your private keys to trade with a DEX.
A clear advantage of DEX compared to centralized exchanges is that by functioning as a set of smart contracts programmed in the blockchain, there are never system stops -because even if a node is disconnected or canceled, thousands will continue to keep the network running.
The trade-off of this system would be that at times of high market volatility and high trading activity, the network can become congested - which will cause transaction fees to increase.
On Chain DEX: Uniswap and Bancor 🦄
Bancor and Uniswap -each with its characteristics- are the most prominent representatives of on-chain DEXs called AMM -Automated Market Makers.
Market makers intervene, offering liquidity for the different price levels. In the Automated Market Makers, professional market makers do not intervene, but rather any user can deposit their funds in exchange for commissions -hence the concept of pooled liquidity - and an algorithm will be in charge of determining the price based on a series of parameter defaults.
When a liquidity provider deposits their tokens into a pool, they receive a token representing their share of the pool.
There are many types of AMMs, but both Bancor and Uniswap implement the same system, called Constant Product Market Maker - said system accommodates the famous equation x*y=k, in which (x) and (y) represent the reserves of each token, and (k) represents a constant.
The advantage of this type of DEXs is that they are straightforward to operate and very inclusive - since they allow everyone to contribute liquidity and benefit from the commissions generated by the operations.
The main problem they present is that they could be more efficient from the point of view of capital - if a pair has a large inventory, the slippage when more or less significant trades happen will be considerable. For this reason, other protocols, such as Curve - specialized in pairs of stablecoins - are committed to a hybrid model that combines the Constant Product Market Maker with a Constant Sum Market Maker.
DEXs are an integral part of the DeFi and Web3 ecosystem. You can see how the sector is performing and how each top protocol achieves on the Arch Exchanges Industry Index.