tl;dr
- A DEX (Decentralized Exchange) enables peer-to-peer cryptocurrency trading without intermediaries.
- DEXs began in 2014 with BitShares and NXT, followed by Ethereum-based platforms like EtherDelta and IDEX.
- To use a DEX, choose a DEX, connect a wallet, select tokens, and confirm the trade.
- DEX fees vary but generally do not exceed 0.3%, often lower than centralized exchanges.
- DEXs offer improved functionality but are still less convenient than CEXs; they may surpass CEXs in the future.
DEX Definition & History
A decentralized exchange (DEX) is a platform that allows users to trade cryptocurrencies directly with each other, without relying on an intermediary or central authority.
The concept of DEXs began in 2014, driven by the desire for peer-to-peer cryptocurrency trading. BitShares, launched by Dan Larimer in July 2014, was one of the first DEXs, aiming to create a decentralized exchange infrastructure. Similarly, NXT launched in 2014, providing a decentralized asset exchange and pioneering early DEX models.
The next wave of DEXs brought more advanced Ethereum-based platforms, though challenges persisted. EtherDelta, introduced in 2016, was a pioneering platform for trading ERC-20 tokens. IDEX, launched in 2017, improved upon EtherDelta by offering a more user-friendly experience, while the 0x Protocol, also from 2017, created an open protocol for building DEXs on Ethereum, laying the groundwork for future platforms.
Automated Market Makers (AMMs) transformed DEX functionality by enabling trades through liquidity pools rather than order books. Uniswap, launched in 2018 by Hayden Adams, popularized the AMM model, allowing users to trade with unprecedented ease and efficiency.
How do DEXs Work?
Different DEXs have different architectures, and as such work in different ways. The early DEXs such as EtherDelta are very distinct from modern AMM DEXs. Here we’ll list a few kinds of popular DEXs and how they work.
Orderbook DEXs
An Orderbook DEX facilitates trading through an orderbook mechanism, similar to centralized exchanges. In an orderbook DEX, buyers and sellers place bids and asks (limit orders) on an orderbook, and trades are executed when a matching order is found.
The core of an orderbook DEX is the orderbook itself, a data structure that records all open buy and sell orders for a specific asset pair. Each entry in the orderbook specifies:
- Order type: Buy (bid) or sell (ask)
- Price: The price per unit the buyer is willing to pay or the seller is willing to accept
- Quantity: The amount of the asset for the order
AMM DEXs
An AMM DEX enables trading without a traditional orderbook. Instead of matching buyers and sellers, AMMs use smart contracts and liquidity pools to facilitate trades automatically based on predefined mathematical formulas. This approach is what powers the popular DEXs like Uniswap, SushiSwap, and PancakeSwap.
In AMM DEXs, liquidity pools replace orderbooks as the mechanism for conducting trades. A liquidity pool is essentially a smart contract that holds pairs of tokens (e.g., ETH/USDC). Each liquidity pool is dedicated to a specific trading pair, and anyone can become a liquidity provider (LP) by depositing equal values of both tokens into the pool. For example, if an LP wants to add liquidity to an ETH/USDC pool, they must deposit an equal amount of ETH and USDC.
AMMs determine asset prices using mathematical formulas. The most common formula is the constant product formula used by Uniswap, which is represented as:
x⋅y=kx \cdot y = kx⋅y=k
Here:
- x and y represent the reserves of the two tokens in the pool.
- k is a constant that must remain unchanged during trades.
This formula ensures that as the amount of one token in the pool increases, its price relative to the other token decreases, balancing supply and demand.
DEX Aggregators
A DEX Aggregator connects to multiple DEXs and pools their liquidity. By comparing prices and liquidity across various DEXs, a DEX aggregator provides users with the most efficient trading route, ensuring better prices, lower slippage, and optimized gas fees. Popular DEX aggregators include 1inch, Paraswap, and Matcha.
By connecting to multiple platforms, aggregators provide users with a deeper liquidity pool, which can minimize slippage and allow for larger trades without drastically impacting the price.
When a user initiates a trade, the DEX aggregator:
- Queries Multiple DEXs: It checks the current prices across each connected DEX for the trading pair in question.
- Factors in Slippage and Gas Fees: Calculations include slippage and gas fees to determine if the best price is also the most cost-effective after accounting for transaction costs.
- Optimal Route Calculation: Using algorithms, the aggregator calculates the most efficient route, which may include a single DEX or a combination of multiple DEXs.
THORchain
THORchain isn’t quite a DEX, and isn’t quite a cross-chain bridge. Its a fascinating amalgamation of both. THORChain defines itself as a decentralized liquidity protocol that enables cross-chain asset swaps between different blockchain networks.
THORChain is a Layer 1 blockchain and cross-chain DEX built on Cosmos SDK, enabling native asset swaps (e.g., BTC to ETH) without custody, user registration, or wrapped assets. It offers transparent, decentralized pricing and continuous liquidity pools for efficient, non-custodial trading across multiple blockchains.
THORChain pools use an AMM model (like Uniswap), pairing each asset with RUNE. Liquidity providers deposit assets at a 1:1 RUNE
ratio to support swaps.
For swaps (e.g., BTC to ETH):
User deposits BTC into a THORChain-controlled Bitcoin vault.
THORNodes confirm the transaction, then release ETH from the Ethereum vault to the user.
The swap involves two internal steps: BTC to RUNE, and RUNE to ETH.
Advantages & Benefits of DEXs
DEXs offer freedom in trading, with no cumbersome sign-up processes or KYC requirements. This allows users to trade directly from their wallets, preserving privacy and control over funds.
Unlike centralized exchanges, DEXs minimize reliance on intermediaries, ensuring greater transparency and security. With decentralized protocols, trades happen peer-to-peer, as Satoshi Nakamoto probably would’ve wanted.
This setup reduces the risk of hacking and central points of failure.
Disadvantages & Risks of DEXs
DEXs, while empowering, come with certain disadvantages and risks. Slippages can have a significant impact on trade profitability, especially with tokens with low liquidity. Additionally, "rug pulls," where developers abandon a project and drain its liquidity, are a common risk with lesser-known tokens.
DEXs also lack user support, and can be more complicated than their centralized counterparts, making them challenging for newcomers.
How to Use a DEX?
To use a DEX, first choose one that supports the chain and assets you wish to trade, like Uniswap for Ethereum-based tokens or PancakeSwap for BNB. Connect your crypto wallet (e.g., MetaMask or WalletConnect) to the DEX. Navigate to the “Trade” or “Swap” feature and select the tokens you want to exchange.
Be sure to double-check the token’s contract address to avoid scam tokens. Enter the trade amount, review details like slippage, and confirm the transaction. Always have enough funds for gas fees, and carefully verify each step before finalizing the trade.
DEX Fees
DEX fees vary by platform and trading pair, with stablecoin pairs (like USDT/USDC) often having lower fees, while more volatile pairs may incur higher fees. Typically, DEX fees don’t exceed 0.3%, making them on average more affordable than those on centralized exchanges (CEXs). Gas fees may also apply.
DEXs vs CEXs
While DEXs now offer lower fees and improved functionality, they still lack the convenience and extensive asset lists of CEXs. CEXs provide greater accessibility and support, but DEXs hold potential for further evolution and could one day surpass CEXs in popularity within the crypto market.