Decentralized finance, DeFi for short, is a set of financial services that run as programs on a public blockchain instead of inside a company. You can swap one token for another, lend, borrow and earn interest, and at no point does a bank, broker or exchange hold your money. The programs do, and anyone can read their code and their balances.

Most of it lives on Ethereum and on the cheaper networks built on top of it. This guide covers the three building blocks nearly every DeFi application is assembled from, where the returns come from, and what goes wrong.

What changes when there is no company in the middle

Bank or centralised exchangeDeFi protocol
Who holds the assetsThe companyA contract, on your instruction; your wallet holds the keys
Opening an accountIdentity check, approvalNone. Connect a wallet
Who can see the booksThe company and its auditorsAnyone, in real time
If you make a mistakeSupport desk, sometimes a refundNobody to call. Transactions are final
If it failsBankruptcy court, sometimes deposit insuranceWhatever is left in the contract

The left column is slower and asks you to trust people. The right column is open around the clock and asks you to trust code. Both have failed customers at scale, in different ways.

YourwalletStablecoinsdigital dollarsLendingborrow against cryptoExchangeswap tokens
DeFi apps are building blocks: one wallet can hold a stablecoin, borrow against it and swap it, and the contracts can call each other. It also means one failing piece can hurt everything built on it.

Building block 1: stablecoins

Prices in DeFi are mostly quoted in dollars, so it needs a dollar that can move on a blockchain. A stablecoin is a token built to stay at one dollar. There are three designs, and they are not equally safe:

  • Reserve-backed (USDC, USDT): a company holds dollars and short-term government debt and issues one token per dollar. The risk is the company and its bank, and the issuer can freeze tokens at an address.
  • Crypto-collateralised (DAI): users lock up crypto worth more than the stablecoins they mint. The risk is a crash faster than the collateral can be sold.
  • Algorithmic: kept at a dollar by incentives and a sister token, with little or nothing behind it. TerraUSD was the largest and it collapsed in May 2022, taking tens of billions of dollars with it.
$1USDCreserve-backed$1 in reserves$1DAIcrypto-backed$1.50+ in ETH$1USTalgorithmicno real reservecollapsed 2022
What stands behind the $1 decides how stable it is. Reserve-backed coins hold cash and bonds, crypto-backed coins lock more crypto than they issue, and UST had only an algorithm and collapsed in May 2022.

Building block 2: exchanges with no order book

A stock exchange matches buyers with sellers. Most decentralised exchanges do something simpler. A contract holds a pool of two tokens, say ETH and USDC, and sets the price from the ratio between them. Buy ETH from the pool and you add USDC and remove ETH; there is now less ETH and more USDC, so the next buyer pays more. This design is called an automated market maker, or AMM.

x · y = kABUSDCETH in poolPool before (A)10 ETH30,000 USDCprice 3,000Buy 2 ETH (B)pay 7,500 USDC= 3,750 per ETHbigger trade,worse price
Example pool: 10 ETH and 30,000 USDC, so x · y = 300,000. Buying 2 ETH has to keep that product constant, so the pool asks 7,500 USDC: 3,750 per ETH instead of 3,000 (fees left out).

Two consequences follow. First, a large trade against a small pool moves the price against you while it executes. That is slippage, and wallets let you set the most you will accept. Second, the tokens in the pool belong to people who deposited them to collect the trading fee, 0.3% per swap in the classic design. These liquidity providers earn fees but hold a mix that shifts towards whichever token is falling, a cost known as impermanent loss.

Building block 3: loans against collateral

A lending protocol has no way to check your income or chase you for a debt, so every loan is backed by more than it is worth. You deposit ETH worth $1,000 and may borrow perhaps $700 of stablecoins. Lenders on the other side deposit stablecoins into the same contract and earn the interest borrowers pay; the rate rises automatically as more of the pool is borrowed.

If your collateral falls in price until it barely covers the debt, anyone may repay part of the loan and take your collateral at a discount. That is a liquidation, and it is carried out by bots within seconds of the threshold being crossed.

$1,000$800$600liquidatedETH collateralliquidation line $875debt $700
Example loan: $700 borrowed against ETH with an 80% liquidation threshold. Above $875 of collateral the loan is safe; once the ETH falls below that, it can be sold off.

Why borrow dollars against assets you already own? Mostly to keep the asset while spending or reinvesting its value, or to build a leveraged position. The second use is the one that gets liquidated in a falling market.

Where the yield comes from

Every return in DeFi is paid by someone, and it is worth finding out who before depositing:

  • Borrowers pay interest to lenders.
  • Traders pay swap fees to liquidity providers.
  • The protocol itself pays out newly created tokens to attract deposits. This is the usual source of very high advertised rates, and it lasts only while the token holds its price.

If a product pays far more than borrowers and traders could plausibly be paying, the difference is coming from new deposits or from a token being printed. TerraUSD's lending product paid close to 20% a year on that basis until it stopped.

How people lose money, most common first

Bugs and exploits in the contract

The code holds the funds, so a flaw in the code is a hole in the vault. Audits reduce the odds and do not remove them: an audit covers one version at one point in time.

Approvals that outlive their purpose

Before a contract can move your tokens you sign an approval, and many apps ask for an unlimited one to save you a step later. That permission stays in force until you revoke it. If the contract is later compromised, or was malicious from the start, it can empty that token from your wallet without another signature.

Your wallet5,000 USDCallowance ∞Swapcontractday 1: you approveday 90: contract hackedbalance drainedApprove exact amounts and revoke old approvals
An unlimited approval signed once for a swap still lets that contract pull the whole balance months later. Revoking sets the allowance back to zero.

Fake websites and signatures you did not read

The contract may be sound while the website in front of it is a copy. Phishing pages ask you to sign something that hands over your tokens. A hardware wallet helps only if you read what it shows before confirming.

Liquidation

Borrowing close to the limit leaves no room for a bad day. Markets have fallen 30% in hours more than once.

A stablecoin that stops being stable

If the dollar you are holding loses its peg, every position quoted in it is affected at once.

Admin keys and rug pulls

Many protocols can be upgraded or paused by a handful of keys. That power can rescue users in an emergency and can also be abused. New tokens with anonymous teams and locked-up liquidity that turns out not to be locked are the classic exit scam.

If you want to try it

This is not advice to invest; it is a list of habits that keep a first experiment cheap.

  1. Use an amount you could lose without it mattering, on a low-fee network.
  2. Reach the app through a link you have checked, not through an advert or a message.
  3. Approve the amount you are about to use, not an unlimited one, and revoke old approvals from time to time.
  4. Send a small test transaction before a large one.
  5. Before depositing, answer two questions: who pays this yield, and who holds the keys that can change this contract?

Unfamiliar terms are in the glossary, and Wallets, keys and seed phrases explains what “holding your own keys” involves.

Frequently asked questions

Is DeFi safe?

It removes the risk that a company mismanages or freezes your funds and replaces it with the risk that the code, the website or your own signature goes wrong. Large, old protocols have a longer record than new ones, but none carries deposit insurance.

Where does DeFi yield come from?

From three sources: interest paid by borrowers, fees paid by traders, and new tokens handed out by the protocol. The first two depend on real demand. The third lasts only while the token keeps its value.

What is TVL?

Total value locked: the dollar value of everything deposited in a protocol's contracts. It shows how much is at stake, not how safe it is, and it falls when prices fall even if nobody withdraws.

Can I lose more than I deposit?

In ordinary swaps, lending and liquidity provision the worst case is losing what you put in. With borrowed funds or leverage a liquidation can take most of your collateral, and an unlimited approval can expose tokens you never deposited.

Is DeFi regulated?

It depends on the country and is still being settled. Rules such as the European Union's MiCA apply to companies that offer crypto services and to stablecoin issuers; how they apply to a protocol with no operator is an open question in most places.