DeFi (Decentralized Finance)
DeFi (Decentralized Finance)
Definition: Financial services, lending, trading, borrowing, insurance, rebuilt using smart contracts instead of banks or brokers as the intermediary.
How It Works
- Smart contracts automatically handle what a bank or exchange traditionally would: matching trades, calculating interest, liquidating collateral
- Users interact directly through a Wallet, no account application, credit check, or approval process required
- Liquidity often comes from other users pooling assets into a smart contract (a liquidity pool), earning fees in return, rather than a bank’s own reserves
- Prices on decentralized exchanges are frequently set algorithmically by an Automated Market Maker (AMM) formula, not a traditional order book matching buyers and sellers
- Loans are typically overcollateralized, a borrower locks up crypto worth more than what they borrow, since there’s no credit history or legal recourse to enforce repayment
- Anyone can inspect the deployed contract code, and in many cases anyone can also supply liquidity or build new products on top of existing protocols (composability, informally “money legos”)
- Off-chain data, like an asset’s current price, has to be brought on-chain by an oracle, a service the contract trusts to report accurate values
- Governance of many protocols is itself a DAO, token holders vote on parameters like interest rate models or which assets are supported
DeFi Building Blocks
- Decentralized exchange (DEX): swaps one token for another via an AMM pool instead of a matched order book, e.g. Uniswap
- Lending protocol: users deposit assets to earn interest, others borrow against posted collateral, e.g. Aave, Compound
- Stablecoin: a token designed to hold a stable value, usually pegged to a fiat currency, used as the unit of account across DeFi
- Yield farming: moving capital between protocols and pools to chase the highest available interest or reward rate
- Derivatives and synthetics: on-chain perpetual futures, options, and tokens that track the price of an off-chain asset
- Insurance protocol: lets users pay premiums to cover losses from a specific smart contract exploit or stablecoin depeg
- Liquid staking: deposit a Proof of Stake asset and receive a tradable token representing the staked position plus rewards
Oracles
- Smart contracts can’t read external data on their own, an oracle network fetches and posts real-world prices on-chain for contracts to read
- Chainlink is the most widely used oracle network, aggregating price feeds from many independent data sources before publishing a single value
- A manipulated or stale price feed is a common root cause of DeFi exploits, since liquidations, swaps, and loan sizing all depend on that reported price being accurate
Key Terms
| Term | Meaning |
|---|---|
| Collateralization ratio | Value of collateral deposited divided by value borrowed |
| Liquidation threshold | The collateralization ratio below which a position can be liquidated |
| Slippage | Price movement between submitting a swap and it executing, larger trades move AMM prices more |
| Impermanent loss | Value a liquidity provider loses compared to just holding the assets, caused by price divergence between pooled tokens |
| APY vs APR | APY compounds returns over a year, APR doesn’t, DeFi yields are often quoted as APY and can look larger than the real return |
| TVL | Total Value Locked, the dollar value of assets deposited in a protocol, a rough proxy for scale and trust, not safety |
| Oracle | A service that reports off-chain data, like asset prices, to a smart contract |
Under the Hood
Worked example: liquidation math
- Given: a borrower deposits 10 ETH as collateral at 20,000 total), borrows $12,000 in a stablecoin, the protocol’s liquidation threshold is 75% (loan value must stay below 75% of collateral value)
- Step: current loan-to-value = 20,000 = 60%, safely below 75%
- Step: ETH price drops to 1,500 = $15,000
- Step: new loan-to-value = 15,000 = 80%, above the 75% threshold
- Answer: the position becomes eligible for liquidation, a liquidator can repay part of the $12,000 debt and claim a discounted slice of the 10 ETH collateral as a reward, the original borrower keeps whatever collateral remains after the forced repayment
Worked example: AMM swap and slippage
- Given: a constant-product AMM pool holds 100 ETH and 200,000 USDC (price = 2,000 USDC/ETH), the invariant is x * y = k, so 100 * 200,000 = 20,000,000
- Step: a trader swaps 5 ETH into the pool, new ETH balance = 105
- Step: solve for new USDC balance, 105 * y = 20,000,000, so y = 190,476.19, meaning 200,000 - 190,476.19 = 9,523.81 USDC comes out
- Answer: effective price paid = 9,523.81 / 5 = 1,904.76 USDC/ETH, about 4.8% worse than the 2,000 quoted price, purely from the trade’s own size moving the pool, this gap is slippage
Common DeFi Risks
- Smart contract risk: a bug in the protocol’s code lets an attacker drain funds, the single most common cause of large DeFi losses
- Oracle risk: a manipulated or delayed price feed causes the protocol to misprice collateral, loans, or liquidations
- Depeg risk: a stablecoin loses its peg to the asset it tracks, breaking every protocol that assumed it was always worth $1
- Rug pull: a project’s team or a malicious contract owner drains liquidity or mints unlimited tokens and disappears
- Bridge risk: assets moved between chains rely on a bridge contract, historically one of the most exploited components in DeFi
- Governance risk: a malicious or rushed governance proposal can change protocol parameters or upgrade contracts in ways that harm existing users
Why It Matters
- Removes traditional gatekeepers from financial services, anyone with a wallet and internet connection can participate, for better or worse (no fraud protection or recourse either)
- Makes financial infrastructure composable, protocols can plug into each other programmatically, a lending position can be used as collateral elsewhere, for example
- Provides continuous, transparent, on-chain visibility into a protocol’s reserves and solvency, in principle checkable by anyone at any time
- Operates permissionlessly and continuously, DeFi protocols don’t close for weekends, holidays, or banking hours
- Gives users direct, self-custodied control over their assets rather than an IOU from an institution that could freeze or lose them
- Lets developers build new financial products by combining existing audited protocols instead of implementing every layer from scratch
Common Pitfalls
- Assuming DeFi protocols are risk-free because they’re “decentralized,” smart contract bugs and exploits have caused billions of dollars in losses across the industry
- Underestimating how interconnected DeFi protocols are, a failure or depeg in one widely-used protocol or stablecoin can cascade into others that depend on it
- Approving unlimited token spend for a protocol out of convenience, a compromised or malicious contract with that approval can drain the full token balance, not just the amount intended for one transaction
- Ignoring impermanent loss when providing liquidity, a pool can show attractive fee APY while the underlying position is worth less than simply holding the two assets
- Confusing a high advertised APY with a safe or sustainable one, some yields are subsidized by inflationary token rewards that lose value as more people farm them
- Underestimating liquidation risk during fast price moves, network congestion can delay a borrower’s attempt to add collateral or repay debt before a liquidation triggers
- Trusting a protocol’s “audited” label as a guarantee, audits catch known bug classes but have repeatedly missed novel exploits, an audit reduces risk, it doesn’t eliminate it
Comparison
| DeFi | CeFi (centralized crypto exchange) | Traditional finance (TradFi) | |
|---|---|---|---|
| Custody | User holds their own keys (non-custodial) | Platform holds funds (custodial) | Bank holds funds |
| Approval to participate | None, permissionless | Account signup, KYC | Application, credit check |
| Hours | 24/7, no downtime | Usually 24/7 | Business hours, banking days |
| Recourse if something goes wrong | Little to none | Platform terms of service, sometimes insurance | Regulatory protections, deposit insurance |
| Transparency | Fully on-chain and auditable | Internal, not publicly visible | Internal, regulator-audited |
| Failure mode | Smart contract exploit, oracle failure | Exchange insolvency, withdrawal freeze | Bank run, mitigated by deposit insurance |
Example
Aave lets a user deposit ETH as collateral and borrow a stablecoin like USDC against it, with interest rates set algorithmically by the pool’s current supply and demand and liquidation handled automatically by the protocol’s smart contracts, no loan officer or bank involved. Uniswap, an AMM-based DEX, lets anyone swap between tokens or supply liquidity to a pool and earn a share of trading fees, with no order book or centralized matching engine.
FAQ
Is DeFi legal? In most jurisdictions, yes, though regulatory treatment of specific activities (lending, derivatives, stablecoins) varies and is still evolving.
Do DeFi protocols have customer support that can reverse a transaction? No, transactions are final once confirmed on-chain, there’s no chargeback or account recovery process.
Related Terms
Referenced by