DeFiEthereum

DeFi Basics: Decentralized Exchanges, Lending and Their Risks

No bank account, no paperwork, just a wallet. DeFi lets you trade, borrow and earn yield on-chain. Here's how it works, with real numbers, and where the traps are hiding.

Imagine a bank with no branches, no staff and no closing time. Anyone with a wallet can deposit, borrow or swap currencies, and every rule is written in public code. That's DeFi (decentralized finance).

It also comes with headlines like "Earn 300% APY!" So how does DeFi actually work, where does that yield come from, and what are most people missing? Let's break it down.

Key takeaways

  • DeFi replaces banks and brokers with smart contracts. You interact directly from your wallet.
  • Decentralized exchanges (DEXs) often use automated market makers that price trades with a formula.
  • Lending is over-collateralized, and a falling collateral price can trigger liquidation.
  • Stablecoins are DeFi's settlement currency, but "stable" isn't a guarantee.
  • When you see a high yield, ask one question first: who's paying for it?

DeFi vs. traditional finance

Traditional financeDeFi
Getting startedAccount opening, ID checks, approvalJust a wallet
HoursBusiness days and hours24/7, every day
Who runs the rulesInstitutions and staffPublic smart contracts
When things go wrongCustomer support, regulators, deposit insuranceUsually no support; losses are often permanent
TransparencyPrivate booksEvery transaction is on-chain

DeFi's biggest strength is openness. Its biggest cost: you are your own bank, and you carry all the risk.

Decentralized exchanges and AMMs

On a centralized exchange, buyers and sellers are matched through an order book. Many DEXs, such as Uniswap, use an automated market maker (AMM) instead. There's no counterparty; you trade directly against a pool of tokens.

An AMM prices trades from a pool of two tokens, with no traditional order book
An AMM prices trades from a pool of two tokens, with no traditional order book

The classic pricing rule is the constant product formula:

x × y = k

The product of the two token balances stays constant. Say a pool holds 10 ETH and 25,000 USDC. Then k = 250,000, and the price is 2,500 USDC per ETH.

Now you buy 1 ETH. The pool drops to 9 ETH, so to keep k constant, it needs 250,000 ÷ 9 ≈ 27,778 USDC. You pay about 2,778 USDC before fees, 11% more than the quoted price. That's slippage: the smaller the pool and the bigger the trade, the worse it gets. Major pairs have deep pools and tiny slippage; small-cap tokens can move dramatically on a single large order.

People who deposit tokens into the pool are liquidity providers (LPs), and they earn a share of trading fees. But LPs face impermanent loss: when the two tokens' relative price changes, the position ends up worth less than if you'd simply held both tokens.

Price change since depositImpermanent loss (before fees)
+25%About 0.6%
−25%About 1.0%
2×About 5.7%
4×About 20%
5×About 25.5%

If fee income doesn't cover the loss, providing liquidity loses money. That's how LPs end up with "more tokens, less value."

Over-collateralized lending

DeFi lending protocols like Aave don't check your credit score. They rely on over-collateralization: you deposit assets worth more than what you borrow.

Borrowers lock up collateral worth more than the loan and are liquidated if the ratio falls below the threshold
Borrowers lock up collateral worth more than the loan and are liquidated if the ratio falls below the threshold

Why would anyone do that? Usually because they don't want to sell their ETH but need cash. It's similar to taking out a home equity loan instead of selling your house.

Protocols constantly track your health factor. Here's how it plays out:

ItemValue
Collateral$10,000 of ETH
Liquidation threshold80%
Borrowed6,000 USDC
Health factor10,000 × 80% ÷ 6,000 ≈ 1.33
Collateral value at liquidation6,000 ÷ 80% = $7,500

In other words, a 25% drop in ETH pushes your health factor below 1 and gets you liquidated: part of your collateral is sold to repay the debt, and you pay a liquidation penalty on top. A 25% move in a day isn't unusual in crypto, and during a sharp wick, liquidations can happen within minutes. The more you borrow, the closer you sit to the line.

Stablecoins: DeFi's settlement currency

Most DeFi activity is priced and settled in stablecoins. There are three main types:

TypeExamplesHow it holds the pegMain risk
Fiat-backedUSDT, USDCIssuer holds cash and short-term TreasuriesIssuer trust, reserve transparency, regulation
Crypto-backedDAIMinted against over-collateralized cryptoLiquidation stress when collateral crashes
AlgorithmicUST (collapsed)Algorithms and arbitrage incentivesA "death spiral" when confidence breaks

"Stable" is never a promise. In May 2022, the algorithmic stablecoin UST collapsed within days, wiping out tens of billions of dollars in value. In March 2023, Silicon Valley Bank failed, and because part of USDC's reserves sat there, USDC briefly fell to about $0.88. Any stablecoin can lose its peg because of its reserves, its design or plain panic.

Where does high yield come from?

Before you get excited about "20% APY" or "200% APY," ask: who is paying me this?

  • More sustainable sources: trading fees, interest paid by borrowers, staking rewards. These yields tend to be modest and move with the market.
  • Be cautious with: rewards paid in a project's newly minted token. When the token price falls, so does your yield, sometimes to zero.
  • Walk away from: anything that can't explain its yield, promises guaranteed returns or pays you to recruit others. That's a Ponzi scheme in disguise.

As the saying goes: if you don't know where the yield comes from, you are the yield.

Five risks people overlook

  1. Smart contract risk: a bug can let attackers drain funds. Audits reduce risk; they don't remove it.
  2. Oracle risk: protocols rely on outside price feeds, and a manipulated price can trigger wrongful liquidations.
  3. Admin key risk: some teams can upgrade or pause contracts. Check whether those powers sit behind a timelock or multisig.
  4. Bridge and liquidity risk: bridges are prime hacking targets (the Ronin bridge lost about $625 million in 2022), and thin pools mean big slippage on large trades.
  5. Approval risk: token allowances granted to contracts can be abused; see our scam prevention guide.

FAQ

How much money do I need to start with DeFi?

There's no minimum, but gas fees matter. On Ethereum mainnet, fees can eat a big chunk of a small transaction. Beginners can practice on a Layer 2 network with a small amount first.

If a DeFi protocol gets hacked, can I get my money back?

Usually not. In a few cases, hackers returned funds or the protocol compensated users from its treasury, but that's the exception. Assume you could lose everything you put in.

Does an audit mean a protocol is safe?

No. An audit covers one version of the code and the scope the auditors reviewed. Plenty of hacked protocols had been audited. Treat an audit as a plus, not a guarantee.

Is "yield farming" the same as crypto mining?

No. Yield farming means depositing tokens into pools to earn fees and token rewards. It has nothing to do with mining hardware. If someone asks you to buy a "DeFi mining machine" or deposit funds on a specific platform to "mine," be very careful.

Summary

DeFi makes finance open, transparent and composable: DEXs swap order books for formulas, lending protocols swap credit checks for collateral, and stablecoins make on-chain settlement possible. The trade-off is that there's no help desk and no safety net. Every risk is yours.

Before you dive in, understand how the protocol works, start small and only use money you can afford to lose. New to smart contracts and gas? Start with our Ethereum guide. This article is for education only and isn't investment advice.

Related reading