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 exchange | DeFi protocol | |
|---|---|---|
| Who holds the assets | The company | A contract, on your instruction; your wallet holds the keys |
| Opening an account | Identity check, approval | None. Connect a wallet |
| Who can see the books | The company and its auditors | Anyone, in real time |
| If you make a mistake | Support desk, sometimes a refund | Nobody to call. Transactions are final |
| If it fails | Bankruptcy court, sometimes deposit insurance | Whatever 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.
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.
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.
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.
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.
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.
- Use an amount you could lose without it mattering, on a low-fee network.
- Reach the app through a link you have checked, not through an advert or a message.
- Approve the amount you are about to use, not an unlimited one, and revoke old approvals from time to time.
- Send a small test transaction before a large one.
- 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.