DeFi Basics
What Is Decentralized Finance (DeFi)?
Learn what decentralized finance (DeFi) is, how it works, and why it matters. Understand the core concepts of DeFi including smart contracts, blockchain, and permissionless financial services.
Learn how decentralized exchanges (DEXs) work, how they differ from centralized exchanges, and the role of automated market makers and liquidity pools in DeFi trading.
A decentralized exchange (DEX) is a type of cryptocurrency trading platform that operates entirely through smart contracts on a blockchain, without a central authority managing the trades or holding user funds. Instead of depositing your assets with a company and trusting them to process your trades, a DEX lets you trade directly from your own wallet.
DEXs are one of the foundational pillars of decentralized finance. They provide the infrastructure for token swaps, price discovery, and liquidity that the rest of the DeFi ecosystem depends on. Without DEXs, users would have no decentralized way to exchange one token for another — a fundamental requirement for any financial system.
The DEX landscape has grown enormously since Uniswap launched in late 2018. Today, DEXs process billions of dollars in trading volume every day across multiple blockchain networks, and for many token pairs they rival or exceed the liquidity of centralized exchanges.
To understand what makes DEXs different, it helps to know how centralized exchanges (CEXs) like Coinbase, Binance, and Kraken operate:
This model is efficient and familiar, but it introduces a central point of failure. If the exchange is hacked, goes bankrupt, or freezes withdrawals (as multiple exchanges have done historically), users can lose their funds.
Most modern DEXs do not use order books at all. Instead, they use automated market makers (AMMs) — a fundamentally different approach to facilitating trades.
Here is how an AMM-based DEX works:
Liquidity providers (LPs) deposit tokens into pools. A liquidity pool is a smart contract that holds reserves of two tokens — for example, ETH and USDC. LPs deposit equal value of both tokens and receive LP tokens representing their share of the pool.
A mathematical formula sets the price. The most common formula is the constant product formula: x * y = k, where x and y are the quantities of each token in the pool and k is a constant. This formula ensures that as one token is bought (removed from the pool), its price increases, and vice versa.
Traders swap directly with the pool. When you want to buy ETH with USDC, you send USDC to the pool and receive ETH from it. The formula determines exactly how much ETH you receive based on the current reserves.
LPs earn fees. Each trade incurs a small fee (typically 0.3%), which is distributed proportionally to all liquidity providers in that pool. This fee is the incentive for providing liquidity.
Prices adjust automatically. As trades change the ratio of tokens in the pool, the price adjusts. If the DEX price deviates from the price on other exchanges, arbitrageurs step in to balance it, buying the cheaper token and selling the expensive one until prices equalize.
Some DEXs do use order books, operating similarly to centralized exchanges but with key differences. On-chain order book DEXs (like those on Solana) record every order on the blockchain, providing full transparency. Hybrid models keep the order book off-chain for speed but settle trades on-chain for security. dYdX and Serum are examples of order-book-style DEXs.
Because liquidity is spread across many different DEXs and pools, trading a large amount on a single pool can result in significant price impact. DEX aggregators like 1inch, Paraswap, and CoW Swap solve this by routing a single trade across multiple pools and DEXs to find the best overall price. They act as a meta-layer on top of existing DEXs.
Perhaps the most important advantage: on a DEX, you never give up custody of your funds. Your tokens remain in your wallet until the exact moment a trade is executed by the smart contract. There is no deposit, no withdrawal, and no risk of exchange insolvency or withdrawal freezes.
Anyone with a crypto wallet and an internet connection can trade on a DEX. There are no account applications, no minimum balances, no geographic restrictions enforced by the protocol itself, and no KYC requirements for most DEXs. This makes DEXs globally accessible in ways that centralized exchanges are not.
Every trade, every liquidity addition, and every fee distribution is recorded on the blockchain and can be independently verified. You can inspect the smart contract code to understand exactly how the DEX works. This transparency stands in stark contrast to centralized exchanges, where the matching engine, fee structure, and internal operations are opaque.
Centralized exchanges typically list only a curated selection of tokens that pass their review process. On a permissionless DEX, anyone can create a liquidity pool for any token pair. This means new tokens are often available on DEXs long before they appear on centralized exchanges. (The flip side is that this openness also allows scam tokens to be listed, so users must exercise caution.)
Because DEXs are smart contracts, they can be integrated into larger DeFi workflows. A single transaction could borrow stablecoins from a lending protocol and swap them on a DEX in one atomic operation. This composability is what enables the complex financial products and strategies that define DeFi.
Liquidity providers face a risk called impermanent loss. When the price ratio of the two tokens in a pool changes significantly, LPs would have been better off simply holding the tokens rather than providing liquidity. The trading fees earned may or may not compensate for this loss. The term "impermanent" is somewhat misleading — the loss becomes permanent if the LP withdraws while prices are divergent.
On AMM-based DEXs, large trades relative to pool size can move the price significantly. This is called price impact or slippage. If you try to buy $100,000 worth of a token from a pool with only $500,000 in total liquidity, you will receive a much worse price than the quoted rate. DEX aggregators help mitigate this by splitting trades across multiple pools.
Because transactions on public blockchains are visible in the mempool before they are confirmed, sophisticated actors can see your pending trade and insert their own transactions before and after yours to profit at your expense. This is called a "sandwich attack" and is part of the broader category of maximal extractable value (MEV). Private transaction channels and MEV-protection services have been developed to combat this issue.
Like all DeFi applications, DEXs are built on smart contracts and inherit the associated risks. Bugs or vulnerabilities in the DEX code could lead to loss of funds. Using well-established DEXs with extensively audited code significantly reduces this risk.
Every trade on a DEX requires an on-chain transaction, which means paying gas fees to the network. On Ethereum mainnet, gas fees during periods of high network activity can make small trades uneconomical. Layer 2 networks like Arbitrum, Optimism, and Base offer much lower gas costs while maintaining Ethereum's security guarantees.
Uniswap is the most widely used DEX and popularized the AMM model. Its latest version (Uniswap v3) introduced concentrated liquidity, allowing LPs to provide liquidity within specific price ranges for greater capital efficiency. Uniswap operates on Ethereum, Arbitrum, Optimism, Base, Polygon, and several other chains.
Curve specializes in stablecoin and pegged-asset trading. Its bonding curve is optimized for assets that should trade near a 1:1 ratio, resulting in extremely low slippage for stablecoin swaps. Curve is particularly important for DeFi users who need to swap between different stablecoins efficiently.
These are Uniswap forks that introduced additional features like yield farming incentives. PancakeSwap is the largest DEX on BNB Chain, while SushiSwap operates across multiple networks.
DEXs and lending protocols are deeply interconnected:
When you use Borrow by Sats Terminal to take out a Bitcoin-backed loan, the protocols it aggregates rely on DEX liquidity for collateral price discovery and liquidation mechanisms. The health of the DEX ecosystem directly supports the security and efficiency of DeFi lending.
If you are new to decentralized exchanges:
Decentralized exchanges represent one of DeFi's greatest achievements: a system where anyone can trade any asset, at any time, without needing permission or trusting a third party with their funds.
Common Questions
A decentralized exchange (DEX) is a cryptocurrency trading platform that operates without a central authority or custodian. Instead of matching buyers and sellers through a centralized order book, most DEXs use liquidity pools and automated market makers (AMMs) — smart contracts that hold reserves of token pairs and use mathematical formulas to determine prices. Users trade directly from their own wallets, maintaining custody of their assets throughout the process.
Related Questions
DeFi Basics
Learn what decentralized finance (DeFi) is, how it works, and why it matters. Understand the core concepts of DeFi including smart contracts, blockchain, and permissionless financial services.
DeFi Basics
Understand how DeFi lending protocols work, including how interest rates are set, how collateral is managed, and which protocols are most widely used for crypto-backed borrowing.
DeFi Basics
Learn what smart contracts are, how they work on blockchain networks, and why they are the foundation of DeFi applications like lending protocols and decentralized exchanges.
Crypto Borrowing
A complete guide to how crypto borrowing works — from depositing collateral to repaying loans — covering DeFi protocols, CeFi lenders, and key concepts every borrower needs to know.