LearnCryptoDeFi & Smart Contracts
Crypto · Lesson 12 of 12

DeFi & Smart Contracts

7 min read  ·  Advanced

Decentralised Finance — DeFi — is the attempt to rebuild the functions of the traditional financial system on public blockchains. Lending, borrowing, trading, earning interest, insurance — all without banks, intermediaries, or anyone's permission. At its peak in late 2021, over $250 billion was locked in DeFi protocols. At its core are smart contracts: the technology that makes all of it possible, and all of it vulnerable.

What smart contracts actually are

A smart contract is code stored on a blockchain that executes automatically when predetermined conditions are met. "If X happens, then Y occurs" — enforced by the blockchain itself, not by any person or company. Once deployed, the code runs exactly as written with no ability for anyone to intervene, modify it, or stop it.

This is both the power and the danger. A smart contract can hold and move billions of dollars with no human involved. If the code has a bug, there is often no way to stop the exploit once it begins.

Core DeFi protocols

Lending / borrowing (Aave, Compound): deposit crypto as collateral, borrow other assets. Always overcollateralised — if collateral falls below a threshold, the protocol automatically liquidates it. No credit checks, no paperwork, available to anyone globally.

Decentralised exchanges (Uniswap, Curve): trade tokens directly from your wallet via AMM liquidity pools. No order book, no KYC, no counterparty.

Yield aggregators (Yearn Finance): automatically move your funds between protocols to maximise yield. Complexity abstracted away — deposit once and earn optimised returns.

Yield farming — what it is and why it's risky

Yield farming is deploying crypto across multiple DeFi protocols to maximise returns — typically through a combination of lending fees, trading fees, and governance token rewards. Advertised yields of 100%+ APY are common. These are almost always paid in the protocol's own governance token, not stable value — as the token inflates, your real return evaporates.

Genuine yield in DeFi — from trading fees in liquid pools, for example — is real but modest (1–10% annually). Anything dramatically above that almost always involves: governance token inflation, smart contract risk, or unsustainable subsidies from a treasury that will eventually run dry.

The hack problem

Over $5 billion has been stolen from DeFi protocols through smart contract exploits. Notable incidents:

Bridges — contracts that move assets between different blockchains — are particularly vulnerable. They hold large amounts of locked assets and must process complex cross-chain logic, creating large attack surfaces.

The DeFi risk framework: smart contract risk (code bugs), oracle risk (price feed manipulation), governance risk (malicious proposals), liquidity risk (inability to exit during panic), and regulatory risk (protocols being shut down). Audits reduce but don't eliminate smart contract risk. The only DeFi that has truly proven itself is the oldest — Uniswap, Aave, Compound have been running for years with no catastrophic exploits. New protocols, however hyped, carry dramatically higher risk.

That wraps up the Crypto section. You now understand the technology, the ecosystems, the risks, and the genuine innovations. Next: Strategy — how to actually invest across all of these asset classes.

Put this to the test in RIP.

Answer questions on defi & smart contracts, earn XP, and challenge your mates to a stock duel.

Download free on iOS →