Worked example · 2021-04
Uranium Finance migration-pair arithmetic error — BSC — 2021-04-28
Summary
Uranium Finance was a Uniswap v2 fork deployed on Binance Smart Chain (BSC). It operated a V1 version and announced a migration to V2 in late April 2021. The V2 migration involved deploying new pair contracts and migrating liquidity from V1 to V2 pools.
On 2021-04-28 the project was drained of over $50M across 26 market pairs. Uranium said the exploit occurred during its migration to V2.1 [theblockuranium]. Per Immunefi's analysis, Uranium forked Uniswap V2 but changed the fee scaling factor from 1000 to 10000 in the adjusted-balance calculation while the K invariant check still used 1000; the check was therefore ineffective and an attacker could swap a tiny amount of one token for nearly the entire balance of the other, with post-swap K effectively 100 times pre-swap K [immunefi]. The original file's claim that the bug was in getAmountOut's 997 multiplier is not supported.
Funds were moved by swapping DOT and ADA to ETH on PancakeSwap, bridging ETH and BTC via AnySwap and mixing ETH through Tornado Cash; The Block counted about 2,438 ETH (~$6.4M) withdrawn via Tornado Cash [theblockuranium]. Cointelegraph noted speculation about an inside job given the further upgrade only 11 days after the V2 migration [cointelegraphuranium].
Timeline (UTC)
| When | Event | OAK ref |
|---|---|---|
| 2021-04 | Uranium launches, migrates to V2 and then V2.1 | (migration deployment) |
| 2021-04-28 | Pair contracts drained across 26 pairs, over $50M [immunefi] |
T9.016 (K check inconsistent with scaled balances) |
| 2021-04-28 | Proceeds swapped, bridged and mixed through Tornado Cash [theblockuranium] |
(laundering) |
Realised extraction
Over $50M across 26 pairs [immunefi]; asset breakdown in [theblockuranium].
T9.011 classification
The Uranium Finance exploit is the earliest corpus anchor for OAK-T9.016 (Contract Accounting / State-Invariant Flaw) in the invariant-computed-wrong sub-shape — an arithmetic-constant error, not a rounding-direction error, which is why it moved out of T9.011 on 2026-10-11. In the Uniswap V2 pair, the swap adjusts balances by the fee scale and then checks the K invariant at the same scale. Uranium changed the scale to 10000 in the adjusted-balance step but not in the K check [immunefi]. The attacker did not need to manipulate an oracle, exploit a flash loan, or abuse reentrancy: calling the swap function with the flawed arithmetic was sufficient to drain the pool.
The mismatch is better described as an invariant-computed-wrong flaw (T9.016) than as precision loss; the original file's claim that the invariant check was "missing or also used the wrong constant" is replaced by the sourced description above.
Public references
[immunefi]— Immunefi, "Hack Analysis: Uranium Finance, April 2021": https://immunefi.com/blog/bug-fix-reviews/hack-analysis-uranium-finance-april-2021/[theblockuranium]— The Block, "Binance Smart Chain-based DeFi project Uranium Finance exploited, lost $50 million" (2021-04-28): https://theblock.co/news/defi/2021-04-28-binance-smart-chain-defi-uranium-finance-exploited-lost-50-million-103076[cointelegraphuranium]— Cointelegraph, "$50M reportedly stolen from BSC-based Uranium Finance" (2021-04-28): https://cointelegraph.com/news/50m-reportedly-stolen-from-bsc-based-uranium-finance