What is a DEX?
A decentralized exchange (DEX) is a peer-to-peer marketplace that connects buyers and sellers of crypto assets with no intermediary.
Decentralized exchanges are powered by smart contracts, which are programs on the blockchain that self-execute when pre-set conditions are met.
The idea behind DEXs is to remove the intermediary between people, so they can trade directly with one another. DEXs are non-custodial, meaning that users have complete custody over their crypto assets when using these trading platforms.
DEX users do not need to deposit funds when buying and selling cryptocurrencies, since transactions are approved directly through their wallets.
Every trade that takes place on a DEX incurs a trading fee and a transaction fee that varies depending on the blockchain network. Since DEXs are not often built for the purpose of profit, their trading fees tend to be lower than those of centralized exchanges.
How Does a DEX Work?
The are three main types of DEXs: automated market makers, order books, and aggregators.
Automated Market Makers (AMMs)
AMMs are designed to set the price of cryptocurrencies on DEXs and are controlled by smart contracts.
Unlike traditional buy and sell orders where every buyer has to be matched with a seller, AMMs use liquidity pools instead. AMMs use these liquidity pools to algorithmically set the price of the tokens (usually in a pair e.g. BNB:ETH) so users can automatically purchase a token at any given time. The price of each token is based on the ratio of the tokens in the liquidity pool.
For example, a liquidity pool with 9 BNB and 3 ETH has a ratio of 3:1, so every ETH in the pool is worth 3 BNB. Every time a buy or sell transaction occurs, the ratio changes, therefore changing the price of what the token(s) is worth. The higher the liquidity in the pool, the more stable and the less volatile price action will be.
Apart from swapping their tokens against a liquidity pool, DEX users can earn passive income by providing liquidity to DEXs in a process called liquidity mining.
When providing liquidity to the pool, users need to deposit equal amounts of each token to keep the ratio balanced.
Liquidity providers earn a portion of trading fees for a token pair by depositing a proportionate amount of the two tokens in the relevant liquidity pool.
This system can be compared to a bank providing interest for its users to encourage them to deposit funds, just like a savings account.
Popular AMM DEXs include UniSwap, PancakeSwap, SushiSwap, and Trader Joe.
Order Books DEXs
Order books are a collection of open buy and sell orders for specific asset pairs and work similarly to traditional finance. Orders will only go through once a sell and buy order is matched.
Sell orders are held within a smart contract till the price target has been met and can be cancelled at any time, therefore making it decentralized.
The price of the crypto assets is determined by the spread between the buy and sell orders on the order book.
Popular order books DEXs include dYdX, Ox, and Serum.
DEX aggregators use various protocols and smart contracts in order to ensure that DEX traders have access to enough liquidity to make a transaction.
As the name suggests, DEX aggregators aggregate liquidity from multiple decentralized exchanges to optimize the prices and trading fees.
Essentially the goal of a DEX aggregator is to find you the best deal at any given time.
Popular DEX aggregators include 1inch, Slingshot, and ParaSwap.
What are the Advantages of Using a DEX?
DEXs are More Secure than Centralized Exchanges
Unlike centralized exchanges (CEXs), DEX users can always access their digital assets since they do not have to deposit funds into a DEX to be able to make transactions.
In the eyes of a trader, this makes DEXs more appealing, trusted and secure because they are unable to halt transactions, freeze withdrawals and seize traders’ assets, unlike centralized exchanges.
DEXs do not Require a KYC
DEXs are a great option for traders who cherish anonymity.
DEXs do not require a KYC and do not store your personal information as most CEXs do. However, making trades on DEXs can be problematic from a legal perspective and obviously does not make you immune from the law.
If it’s on Chain, it can be Traded.
The number of cryptocurrencies available for trading on DEXs far exceeds that of centralized exchanges.
DEX’s allow anyone to create liquidity pools for new token pairs, so if a token contract is on mainnet, a pool can be made for it and people can trade with it.
Unlike CEXs, DEXs do not have to comply with regulations and would list any token regardless of its trading volume and activity.
What are the Downsides and Risks of Using a DEX?
DEXs’ speed and transaction fees depend on the scalability of the network they are built on.
For instance, if there is a higher amount of people using the Ethereum network, transaction (gas) fees go up and DEX users pay more to swap tokens. This has led to a lot of users moving over to the Binance Smart Chain which has far lower fees.
DEXs are usually hard for beginners in crypto.
To use a DEX, users need a wallet such as MetaMask, so they can interact and trade with the DEX. This can be quite challenging for those who have never used a crypto wallet before.
Rug pulls and scams are more likely to happen on DEXs due to the huge number of tokens available which can be listed by anyone.
Rug pulls happen when liquidity providers (usually the creators of the token) withdraw their stake in the pool. This drains any funds that users had swapped over to purchase the token and they are now left with a worthless coin that cannot be swapped back.
You should also be careful before investing in any token and ensure that you DYOR.
Smart Contract Vulnerabilities
Smart contacts on Ethereum and other blockchains are open-source, which means they are always available for anyone to read.
This allows security researchers to contribute to the smart contract security by exposing any bugs in the smart contract for DEXs.
Moreover, large DEX smart contracts are often audited by security companies. That being said, some bugs can still slip through and cause losses for liquidity providers.
Hackers are using new, sophisticated methods to target liquidity pools. For instance, a recent phishing attack caused $8M in losses for liquidity providers on Uniswap.
The Future of Decentralized Exchanges
Decentralized exchanges are the most popular financial services offered by the DeFi (Decentralized Finance) sector.
Not only are decentralized exchanges starting to compete with centralized exchanges in trading volume, but they are also providing innovative financial products such as cryptocurrency lending, liquidity mining, flash loans, etc.
As the blockchain industry gets more and more advanced, DEXs will keep improving their services and continue contributing to the rising adoption of DeFi.