Finance as open code
DeFi is a broad name for financial applications that run on public blockchains. Instead of an institution holding your funds and keeping its own books, the rules live in smart contracts: programs deployed on the blockchain that execute automatically when their conditions are met. Anyone with a compatible wallet can interact with them, usually without an account sign-up.
Because the contracts and their transactions are public, anyone can inspect how a DeFi application behaves. That openness is one of its main attractions, and also one of the reasons mistakes in the code can be exploited quickly.
Main building blocks
Decentralised exchanges (DEXs)
A DEX lets people swap tokens directly from their own wallets. Many DEXs do not use an order book. Instead they use an automated market maker (AMM): a pool holding two tokens, with a formula that sets the price based on the ratio between them.
A simple, common formula keeps the product of the two balances constant: x × y = k. As an illustration, a pool holding 10 ETH and 30,000 USDT has k = 300,000. If someone buys 1 ETH, the pool must end with 9 ETH, so it needs 300,000 ÷ 9 ≈ 33,333 USDT. The buyer therefore pays about 3,333 USDT, noticeably more than the starting ratio of 3,000. Bigger trades relative to the pool's size move the price more; this is the AMM form of slippage.
Liquidity pools
The tokens in those pools come from users called liquidity providers, who deposit pairs of tokens and receive a share of the trading fees. Providers carry a specific risk known as impermanent loss: when the prices of the two tokens drift apart, the value of their pool share can end up lower than if they had simply held the tokens.
Lending and borrowing
Lending protocols let users deposit assets that others can borrow. Borrowers must post collateral worth more than the loan. If the collateral's value falls too far, the protocol automatically sells it in a liquidation to repay lenders.
Stablecoins
Many DeFi activities are denominated in stablecoins, and some stablecoins are themselves created by DeFi protocols.
DeFi compared with a centralised exchange
| Centralised exchange | DeFi application | |
|---|---|---|
| Who holds the keys | The exchange, for funds in your account | You, in your own wallet |
| How trades match | Order book and matching engine | Often a liquidity pool and formula |
| Account recovery | Possible through the platform | Usually impossible if keys are lost |
| Network fees | Not charged per trade | Paid on every blockchain transaction |
| Main risk sources | Platform and account security | Contract code, key handling, protocol design |
Risks to understand
- Smart contract bugs. A flaw in the code can let attackers drain funds. Audits reduce this risk but do not remove it.
- Unlimited token approvals. Many applications ask permission to spend your tokens. A broad approval to a malicious or compromised contract can empty that token balance. Review and revoke approvals you no longer need.
- Fake front-ends. Copycat websites can imitate a real application and ask you to sign harmful transactions. See wallet security basics.
- Liquidations. Borrowers can lose collateral quickly during sharp price moves.
- Unsustainable rewards. Very high advertised yields are often paid in newly created tokens whose price can fall sharply.
- Network fees. On busy blockchains, fees can be large relative to small transactions.
Where to start
A solid grasp of ordinary trading makes DeFi much easier to follow. Read how a spot order works, then try the practice account on the trading terminal at /trade/, which uses virtual funds only. Our risk disclosure sets out the wider risks of crypto assets.
Crypto assets are highly volatile and you may lose all the capital you invest.
Practise without risk to real funds
The practice account trades live prices with virtual USDT.