DefiPlaza Hack

Reported loss $200K
Ethereum
Swap Logic Flaw

What happened

DefiPlaza is a DEX focused on capital efficiency, running on Ethereum and Radix. On 5 July 2024 at 13:15 UTC (block 20,240,539), one transaction drained every token from the DefiPlaza V2 pool on Ethereum, about $200,000 in total. The root cause was a rounding error in removeLiquidity: withdrawing more than 15/16ths of all LP tokens into a single token rounded a factor down to zero and removed that token's entire balance.

The original attacker, 0x14b362d2e38250604f21a334d71c13e2ed478467, broadcast the attack from the public mempool, and a front-running MEV bot run by Yoink copied it. Yoink paid a 62.5 ETH priority bribe to the Lido validator that built the block, kept about $24,000 in tokens, and returned those tokens to DefiPlaza within 30 minutes of being contacted. The team says it recovered about 10% of the funds. DefiPlaza then asked the Lido DAO to return the 62.5 ETH, and forum participants argued against doing so. DefiPlaza has no plan to restore liquidity on Ethereum. The Radix bridge was paused briefly and then reopened.

How it happened

  1. The transaction flash-borrowed about $129.6 million in ETH, USDC, USDT, WBTC, DAI, MKR and CRV from Balancer.
  2. It swapped the pool's other tokens until the pool's ratios matched its own holdings, then added all the tokens as liquidity, ending up with more than 94% of the LP tokens.
  3. It redeemed all of those LP tokens into ETH alone. Because the amount exceeded 15/16ths of the LP supply, removeLiquidity rounded a factor to zero and paid out the pool's entire ETH balance.
  4. With one token at zero balance, a state the contract never expected, tiny swaps drained the rest: 1 wei bought all the SPELL, 10^-18 SPELL bought all the YFI, and so on through every listed token.
  5. The transaction repaid the flash loans. Because an MEV bot front-ran the original attacker, most of the value went out as the 62.5 ETH validator bribe.

Protocol details

Classification Protocol Logic
Protocol Type DEX
Implementation language Solidity
Protocol links Website @DefiPlaza

Security review history

Build your security review skills

Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.