Automated Strategies
What DeFi and a DEX Actually Are
The concept behind every 'DeFi' and 'DEX' mention on this site, explained once: how trading without an exchange in the middle actually works, and what you give up and gain.
What it is
DeFi (Decentralized Finance) refers to financial services (trading, lending, borrowing, earning yield) run entirely by code (smart contracts) on a blockchain, with no company in the middle holding your funds or approving your transaction. A DEX (Decentralized Exchange) is DeFi’s version of a trading venue: instead of Kraken or Binance matching your order against another trader’s, you trade directly against a pool of funds locked in a smart contract.
This is different from everything else on this site so far. Every exchange covered in the Academy (Kraken, Bybit, Binance, Coinbase, OKX) is a company you create an account with, that holds an order book and (usually) your funds. A DEX has no account, no company, and no order book in the traditional sense. There’s also no customer support to call, no centralized entity to freeze a suspicious transaction after the fact, and no company balance sheet standing behind the protocol if something goes wrong; the code itself is the entire system.
How a DEX actually works
Most DEXs use an AMM (Automated Market Maker) instead of an order book. Other users (liquidity providers) deposit pairs of assets (e.g. ETH and USDC) into a pool. When you trade, you’re swapping directly against that pool, and a formula (not a matched buyer) determines your price. The pool’s own ratio of assets shifts with every trade, which is also the mechanism behind impermanent loss, a risk already covered in Exchange Staking vs. On-Chain Staking vs. Yield Farming for anyone supplying a pool.
You connect a self-custody wallet (see Wallets and Custody) directly to a DEX’s website; there’s no sign-up, no KYC on most DEXs, and no company that can freeze your account. The tradeoff is that there’s also no support line, no password reset, and no one to call if you send funds to the wrong contract.
A worked example: how price impact shows up in an AMM swap
Say a pool holds 100 ETH and 250,000 USDC, implying an ETH price of $2,500, using the standard constant-product formula where the product of the two balances stays fixed at 25,000,000 (100 × 250,000). If you swap 5 ETH into the pool for USDC, the pool’s new ETH balance becomes 105, and to keep the product at 25,000,000, the new USDC balance must fall to 25,000,000 ÷ 105 ≈ 238,095, meaning the pool pays out about 250,000 − 238,095 ≈ $11,905 for your 5 ETH, an average price of roughly $2,381 per ETH rather than the $2,500 the pool was quoting before your trade. That gap (price impact) grows with trade size relative to the pool’s depth: the same 5 ETH swapped against a pool ten times larger would move the price by roughly a tenth as much. It’s why a DEX interface shows an estimated price impact before you confirm a swap, and why swapping a large amount against a shallow pool can cost meaningfully more than the quoted price suggests, independent of any fee the protocol charges on top.
Gas fees, approvals, and other DEX-specific friction
Trading on a DEX isn’t fee-free just because there’s no exchange taking a cut: you pay the underlying blockchain’s gas fee for every transaction, including one that gets broadcast and then fails, which typically still costs gas even though it didn’t accomplish anything. On networks with high demand, gas costs can spike to a level that makes a small trade uneconomical: swapping $50 of a token isn’t worth it if the network fee for that swap is $30. Most DEX interactions also require a separate token approval transaction before your first swap of a given token, granting the DEX’s smart contract permission to move that token from your wallet, a legitimate and necessary step, but also the exact mechanism scam sites exploit by asking you to “approve” a malicious contract that then drains the approved token from your wallet the moment you sign. Reviewing exactly what a transaction is asking you to approve, rather than clicking through confirmation prompts by habit, is one of the few defenses that actually works here.
What you gain and what you give up
| Centralized exchange (Kraken, Bybit, etc.) | DEX | |
|---|---|---|
| Custody | Usually the exchange, unless you withdraw | Always you |
| Account required | Yes, with KYC | No |
| Counterparty | The exchange’s order book | A liquidity pool’s smart contract |
| Recourse if something goes wrong | Support team, sometimes | None; the code is the final word |
| Main added risk | Exchange insolvency or hack | Smart-contract bugs or exploits |
Risks specific to DeFi that don’t have a centralized-exchange equivalent
- MEV (maximal extractable value). Because pending transactions are visible before they’re confirmed, automated bots can see your swap coming and place their own trades immediately before and after it (a pattern called a sandwich attack), worsening your execution price beyond ordinary price impact. Setting a tight slippage tolerance limits how much of this a bot can extract, at the cost of your transaction failing if the price moves past that tolerance before it confirms.
- Rug pulls on new pools. Anyone can create a liquidity pool and a token, including someone whose only intent is to attract deposits and then withdraw all the paired liquidity, leaving the token effectively worthless, a risk that’s far more concentrated in newly launched, unaudited pools than in large, established ones.
- Bridge risk, if moving assets between blockchains to reach a specific DEX: a cross-chain bridge is its own smart contract with its own exploit history, separate from the DEX or the underlying assets it’s bridging.
Why this matters even if you never use a DEX
Every yield-farming and DeFi mention elsewhere in the Academy assumes you understand this mechanism. You don’t need to ever use a DEX (most of this site’s guides are about centralized exchanges specifically), but “smart-contract risk,” “liquidity pool,” and “AMM” only make sense once this page’s model is in your head.
Risk
DeFi removes a company from the middle of the transaction, but it does not remove risk: it trades custodial risk for smart-contract risk, and a bug or exploit in a DEX’s code can result in a total loss of funds in that pool with no recovery mechanism. Nothing on this page is financial advice.
Frequently asked questions
Do I need to KYC to use a DEX? Generally no: a DEX interacts with your wallet address, not an identity-verified account, which is a core part of what makes it “decentralized.” Regulatory treatment of DEX access varies by jurisdiction and is an evolving area, not a fixed rule.
If a DEX’s smart contract gets exploited, is there any way to get funds back? Rarely, and never guaranteed. Unlike an exchange hack, where the company may have insurance, reserves, or a legal obligation to make users whole, a DEX exploit typically means the funds are simply gone from the pool. Some protocols have voluntarily reimbursed users after major incidents, but that’s a discretionary choice, not a built-in protection.
Is a DEX always riskier than a centralized exchange? Not necessarily: it depends what you’re weighing. A DEX removes counterparty and custodial risk (the exchange can’t freeze your funds or become insolvent with your assets inside it) but adds smart-contract and self-custody risk (a bug in the code, or a mistake in how you interact with your own wallet, has no support line to call). Which is “riskier” depends on which failure mode you’re more exposed to.