Fear & Greed13▲ 1CME BTC net2,519▲ 991CME ETH net461▼ 617Prices: alternative.me14:37 UTC35 min old, not real timeBTC$53,393▼ 10.0%ETH$1,576▼ 5.2%USDT$0.99862▼ 0.0%BNB$519.08▼ 7.5%XRP$0.88823▼ 5.0%SOL$66.58▼ 7.4%TRX$0.28420▼ 2.8%ZEC$851.99▲ 7.0%

Guides

DeFi risks explained: smart contracts, oracles, bridges and liquidations

The main ways money is lost in DeFi, with real incidents, worked impermanent loss and liquidation examples, and a checklist before depositing.

Published by miz.one · facts checked · about 6 min read

Decentralised finance, or DeFi, is the name for financial services built as smart contracts on public blockchains: exchanges without an operator, lending markets without a bank, and stablecoins issued by code. Anyone with a wallet can use them, at any hour, and the rules are visible on-chain. Those same features remove many of the protections of traditional finance. There is usually no customer support, no deposit insurance and no way to reverse a mistake. Understanding where the risks sit is the first step to deciding whether a given protocol is worth using at all.

1. Smart contract risk

A DeFi protocol is software that holds money. A bug can let anyone drain it. Code is often audited, sometimes by several firms, but audits review a specific version against known classes of errors; they are not guarantees. Upgrades, new features and integrations with other protocols can introduce new flaws after an audit.

Exploits are common enough that security incidents form a regular news category: our security topic follows them. A widely studied early case is The DAO in 2016, where a re-entrancy bug let an attacker drain about 3.6 million ETH, an event that led to a split of the Ethereum chain.

What reduces the risk: a long track record with significant value at stake, multiple audits, a public bug bounty, simple code, and limits on how much any upgrade can change.

2. Oracle manipulation

Smart contracts cannot see prices in the outside world. They rely on oracles, services that bring outside data on-chain. If a protocol reads the price of a token from a thin market, an attacker can move that market briefly, borrow against the inflated price and leave the protocol with bad debt. The October 2022 attack on Mango Markets, in which a trader pushed up the price of the platform's own token and borrowed more than $100 million against it, is a well-known example.

What reduces the risk: prices from several sources, time-weighted averages, and caps on borrowing against illiquid tokens.

3. Bridges

A bridge moves assets between blockchains, typically by locking tokens on one chain and issuing a representation on another. The locked tokens make bridges large, attractive targets. In March 2022 attackers who had obtained enough validator keys took about $600 million from the Ronin bridge; in February 2022 a signature-verification flaw let an attacker mint about 120,000 wrapped ETH on the Wormhole bridge. A bridged token is only as good as the bridge behind it.

4. Admin keys and governance

Many protocols can be upgraded or paused by a team multisig or by governance votes. That allows fixes, but whoever controls those keys can, in principle, change the rules or take funds. Governance tokens can also be borrowed in bulk with "flash loans" to pass a malicious proposal in a single transaction, as happened to the Beanstalk protocol in April 2022, when roughly $180 million was taken.

What to check: who controls upgrades, whether there is a time delay before changes take effect, and how much of the governance token is held by a few addresses.

5. Liquidation risk in lending

On lending platforms you deposit collateral and borrow against it. If the collateral's value falls too far, the position is liquidated: others repay part of your debt and take your collateral at a discount.

Worked example. You deposit ETH worth $10,000 and borrow $6,000 of a stablecoin. The protocol's liquidation threshold for ETH is 80%, meaning liquidation can start once the debt exceeds 80% of the collateral's value. That happens when your collateral is worth $6,000 ÷ 0.80 = $7,500: a fall of 25% in the ETH price. In a fast market, ETH can fall 25% in a day. The liquidation penalty, often several percent of the collateral sold, comes out of your deposit. Our liquidation calculator shows a similar calculation for leveraged trading.

6. Impermanent loss for liquidity providers

On automated market makers, such as constant-product pools, liquidity providers deposit two tokens in equal value. When the price of one changes relative to the other, the pool rebalances, and the provider ends up with less value than if they had just held the two tokens.

Worked example for a 50/50 constant-product pool, before trading fees:

Price of token A relative to token BValue compared with holding
Up 25%−0.6%
Up 50%−2.0%
Doubles−5.7%
Triples−13.4%
Five times−25.5%
Halves−5.7%

The loss depends only on how far the price ratio moves, in either direction. It is called "impermanent" because it disappears if prices return to where they were, but it becomes permanent once you withdraw. Trading fees earned can offset it, or not. Try other moves in the impermanent loss calculator.

7. Stablecoin and collateral risk

DeFi runs on stablecoins and on tokens wrapping other assets. If a stablecoin loses its peg, every pool, loan and vault built on it is affected. The collapse of TerraUSD in May 2022 spread losses through many protocols that held it. The stablecoins guide explains the designs and how pegs break.

8. Front ends, approvals and phishing

You usually reach a protocol through a website. If that website is hijacked, for example through a domain or DNS attack, it can serve a malicious transaction while the smart contracts themselves are fine. And every token you deposit typically needs an approval that may stay in place long after you leave. The approvals guide explains how to review and revoke them.

9. Yield that is too good

High advertised yields are paid by someone. They may come from trading fees, borrowers, newly issued governance tokens whose price can fall, or new depositors' money. When the source of the yield is unclear, the risk is usually hidden somewhere you cannot see.

A checklist before depositing

  1. What exactly produces the yield?
  2. How long has the protocol run, and with how much value at stake?
  3. Who audited it, which version, and were the findings fixed?
  4. Who can upgrade or pause it, and with what delay?
  5. Which oracles does it use for prices?
  6. Does it depend on a bridge or a wrapped asset?
  7. How quickly can I withdraw, and is there a limit?
  8. Am I approving more tokens than I am depositing?
  9. Could I afford to lose all of this deposit?

Frequently asked questions

Is DeFi regulated?

It depends on the jurisdiction and the activity. International bodies such as the Financial Stability Board and IOSCO have published recommendations, and regulators apply existing rules where they can identify a responsible party. Many protocols operate in grey areas, and protections common in traditional finance usually do not apply.

Does an audit mean a protocol is safe?

No. It means specific code was reviewed at a specific time. Many exploited protocols had been audited. Audits lower risk; they do not remove it.

What is a flash loan?

A loan that is borrowed and repaid within a single transaction, without collateral. It is a legitimate tool, but it gives attackers temporary access to huge sums, which can be used to manipulate prices or governance votes.

Can losses from an exploit be recovered?

Sometimes. Stolen funds have occasionally been returned after negotiation or frozen at exchanges, and some protocols compensate users from treasuries. Often nothing is recovered.

How do I keep risk small while learning?

Use small amounts, a separate wallet that holds nothing else, well-established protocols, and revoke approvals when you are done.

Related on this site

Sources

  1. ethereum.org, Decentralized finance (DeFi)
  2. Financial Stability Board, The financial stability risks of decentralised finance (2023)
  3. Bank for International Settlements, DeFi risks and the decentralisation illusion (2021)
  4. Uniswap v2 core whitepaper
  5. IOSCO, Policy recommendations for decentralized finance (2023)

This guide explains how things work. It is general information, not financial, tax or legal advice, and it does not recommend any investment. Rules, rates and figures change; check the source before you act. Found an error? See the corrections policy.