Skip to content
Est. MMXXVIVol. VI · № 273RSS
Blockchain Breaches

An archive of cryptocurrency security incidents — hacks, exploits, bridge failures and rug pulls, documented with on-chain evidence.

Dossier № 246Smart Contract Bug

Bunni DEX Rounding Drain

Rounding error in Bunni DEX's withdraw function drained $8.4M on Ethereum and Unichain after devs misjudged how idle balances would move. Protocol shut down.

Date
Victim
Bunni
Status
Funds Stolen

On September 2, 2025, the Uniswap v4-based DEX Bunni was exploited for approximately $8.4 million across Ethereum and Unichain. The bug was a rounding-direction error in the withdraw function: the developers had rounded down believing it would cause idle balances to increase, but the math worked the opposite way, letting an attacker withdraw disproportionate tokens while burning less liquidity than they should have. Bunni permanently shut down two months later, citing $6-7 figure remediation costs for relaunch.

What happened

Bunni was a Uniswap v4-native DEX with a custom liquidity-management layer designed to optimise capital efficiency through automated rebalancing. The protocol's withdraw function calculated how much underlying liquidity to burn per unit of withdrawn output — a calculation that involved integer division with a rounding direction the developers had reasoned about during design.

The fatal flaw: the rounding direction reasoning was inverted. The developers had concluded that rounding a key intermediate value down would cause the protocol's "idle balance" to increase (a desirable conservative property). In practice, the math worked the opposite way — rounding down actually caused the idle balance calculation to decrease, leaving more value available for the withdrawer to extract.

The attack:

  1. Flash-borrowed tokens to fund operational capital.
  2. Executed carefully-crafted swaps through Bunni's weETH/ETH pool on Unichain and USDC/USDT pool on Ethereum — pre-positioning the pool state.
  3. Triggered the withdraw function with parameters that maximised the impact of the rounding error.
  4. Withdrew significantly more tokens than the burned liquidity should have permitted.
  5. Repeated across both chains, extracting approximately $8.4M total.

Aftermath

  • Bunni paused smart contracts within hours of detection.
  • The team initially announced recovery plans and protocol remediation.
  • After two months of evaluation, Bunni publicly announced permanent closure, citing:
    • Remediation costs in the "6-7 figures" for audits and monitoring required to safely relaunch.
    • Insufficient resources to absorb the loss while funding the rebuilding effort.
  • The team open-sourced the v2 contracts under MIT licence as a parting contribution.
  • Stolen funds were laundered; no public recovery.

Why it matters

The Bunni incident is one of the clearest demonstrations of how a single rounding-direction inversion can be a fully-loaded exploit primitive. The developers had explicitly reasoned about the rounding behaviour — they just reasoned incorrectly. The audit (Bunni had been audited) did not catch the inversion, presumably because the test cases didn't exercise the specific input conditions where the rounding's direction mattered.

The structural lessons:

  1. Rounding-direction reasoning is exceptionally easy to get wrong in protocol math. The combination of "intuition about what should happen" + "Solidity integer division" + "complex multi-step calculations" produces bugs that pass review by people who think they understand the code.

  2. Property-based testing (Echidna, Foundry invariants, Halmos) catches rounding-direction bugs far more reliably than example-based unit tests, because the property tests explore the input space looking for invariant violations rather than testing specific expected outputs.

  3. Post-exploit relaunch is economically infeasible for many small protocols. The Bunni team's calculus — $6-7 figure remediation cost vs. uncertain user-trust recovery — is the same calculus that destroyed Polter Finance, several Compound v2 forks, and many other mid-sized projects. The asymmetry between the cost of preventing an exploit (audits + testing infrastructure: maybe $200K) and the cost of recovering from one (remediation + audits + monitoring + user-trust rebuilding: $1M+ if the project survives at all) keeps shifting the rational frontier toward more conservative pre-launch investment.

Bunni's open-sourcing of the v2 contracts as a parting gesture is unusual and worth noting — most protocols that wind down simply stop maintaining their code. The MIT-licensed release gives other Uniswap v4 builders the chance to learn from Bunni's design (and avoid its specific bugs) without having to build the same primitives from scratch.

Sources & on-chain evidence

  1. [01]halborn.comhttps://www.halborn.com/blog/post/explained-the-bunni-hack-september-2025
  2. [02]coindesk.comhttps://www.coindesk.com/web3/2025/09/02/bunni-dex-halts-smart-contracts-after-exploit-drains-usd8-4m-across-chains
  3. [03]coindesk.comhttps://www.coindesk.com/business/2025/10/23/bunni-dex-shuts-down-cites-recovery-costs-after-usd8-4m-exploit

Related filings