DeFi (decentralized finance)
How lending, borrowing and trading can run on smart contracts instead of a bank: one loan followed from deposit to liquidation, where yield comes from, and what can go wrong.
In 30 seconds
DeFi means financial services run by smart contracts on a blockchain. Code, not a company, holds the money and applies the rules, and anyone with a wallet can use it.
Depositors pool tokens and borrowers pay interest on them. Because the contract cannot know or chase anyone, a borrower must lock up collateral worth more than the loan, and loses it automatically if its value falls too far.
Yield comes from interest, trading fees or newly issued tokens, and is payment for risk: bugs, bad price feeds, sudden liquidation, and no insurance.
DeFi (decentralized finance), step by step
USDx and TKN are made-up tokens with made-up prices. Real protocols use different thresholds and often liquidate only part of a loan. This explains mechanisms; it is not advice to use them.
- Step 1: A bank made of code. In a bank, a company holds the deposits, approves the loans and keeps the books. In decentralised finance, DeFi, a smart contract on a blockchain such as Ethereum does those jobs. The rules are code anyone can read, and anyone with a wallet can use them. No one can turn you away, and no one can help you.
- Step 2: A lending pool. Bob deposits 1,000 USDx, a dollar-tracking token, into a pool of 10,000. Borrowers have taken 6,000 and pay 5% a year: 300. The protocol keeps a tenth and the other 270 is shared by depositors, 2.7% on the pool. A formula moves both rates up as more of the pool is lent out.
- Step 3: Over-collateralisation. The contract knows nothing about Alice: no name, no income, no court to chase her. So she must lock up more than she borrows. She deposits 30 TKN worth 3,000 and borrows 2,000 USDx, a ratio of 150%. This protocol demands at least 125%. She gets cash without selling her TKN.
- Step 4: Liquidation. TKN drops from 100 to 80. Alice’s collateral is now worth 2,400, only 120% of her loan. Below 125% anyone may liquidate: repay her 2,000 and take collateral worth 2,100, a 5% bonus. That is 26.25 TKN. Alice keeps 3.75 TKN and the 2,000 she borrowed. No one phones first.
- Step 5: Exchanges without a desk. A decentralised exchange has no company matching buyers with sellers. In the most common design, a contract holds a pool of two tokens and quotes a price from the ratio between them. Alice sends 100 USDx and gets about 0.99 TKN at once. Each swap pays a small fee to whoever supplied the pool.
- Step 6: Where yield comes from. “Yield” is what a depositor such as Bob earns, and it comes from somewhere: interest paid by borrowers, fees paid by traders, or new tokens the protocol hands out. Each is payment for carrying a risk. Rates move constantly, and reward tokens are worth only what the market will pay.
- Step 7: The main risks. DeFi removes the middleman and with it the protections. Contract bugs have drained whole pools. Prices come from outside feeds, called oracles, that can be wrong or manipulated. Dollar tokens can lose their peg. Insiders often hold keys that change the rules. There is no deposit insurance and no undo.
Try it yourself
Learn this first
Spotted a mistake on this page?