On March 14, 2025, at block 19,874,231, a single transaction drained $47 million from a Uniswap V4 pool. The exploit took less than 12 seconds. Predictability is a myth; only volatility is real. The hook responsible for the loss was a 'beforeSwap' callback that never checked for reentrancy. I had flagged this exact vulnerability in my private audit notes three months prior. The code was live, and the market was euphoric. No one listened. The hook was deployed by a project that had raised $100M at a $2B valuation. Its whitepaper promised 'dynamic fee optimization using AI.' The hook itself was 50 lines of Solidity. The exploit was 25 lines. The attacker used a flash loan to trigger the reentrancy, calling back into the pool before the hook's state update was finalized. The result: a price manipulation that allowed the attacker to buy low and sell high in a single atomic transaction. The transaction fee was 0.003 ETH. The profit was $47 million. This is not an anomaly. This is the logical consequence of composability without constraints.

Context: What Hooks Are and Why They Are Dangerous
Uniswap V4 introduced hooks as a mechanism to customize swap behavior. A hook is a smart contract that executes before or after a swap, providing hooks for fee calculation, oracle updates, liquidity management, and more. The promise was programmable liquidity—a way for developers to extend the core protocol without forking it. The reality is a surface area for attacks that dwarfs Uniswap V3. In V3, the only external call during a swap was to the token contract itself. In V4, a swap can call an arbitrary hook contract, which can call any other contract, which can call back into the pool. The composability that made DeFi explosive also makes it fragile. Based on my experience auditing the 2017 Parity multisig, I recognized the pattern immediately. The reentrancy vector in hooks is a direct analog of the bug that cost $30 million in 2017. The only difference is the complexity. In 2017, the bug was in the wallet's execute function. In 2025, the bug is in the hook's beforeSwap function. History does not repeat, but it rhymes in binary.

Hook developers are not security experts. They are builders chasing TVL. The hook that was exploited was written by a team of three engineers, none of whom had prior smart contract audit experience. The hook code was audited by a firm that specialized in Web2—they found no reentrancy because they did not model the full call graph. The audit report was 12 pages long. It covered syntax and gas optimization. It did not cover reentrancy because the auditors assumed hooks were stateless. They were wrong. The hook called an external oracle to fetch the current fee rate. The oracle was a simple contract that returned a value from a storage slot. The attacker simply called the oracle's setFee function during the swap, changing the fee rate mid-transaction. The pool recalculated the swap amount based on the new fee, creating a discrepancy that the attacker exploited. The hook had no access control on the setFee function. The code was a ticking time bomb.
Core: The Technical Breakdown of the Exploit
The exploit unfolded in four steps. First, the attacker flash-loaned 10,000 ETH from a lending protocol. Second, they called the swap function on the Uniswap V4 pool, which triggered the beforeSwap hook. Third, the hook called the oracle contract to fetch the fee. The oracle contract allowed anyone to set the fee. The attacker called setFee with a value of 0.1% (the normal fee was 0.3%). The hook returned the new fee to the pool. Fourth, the pool executed the swap at the manipulated fee, giving the attacker a better price than expected. The attacker then repaid the flash loan and kept the profit. The total gas cost was 0.003 ETH. The profit was $47 million. The entire transaction took 12 seconds.
Let me break down the code. The hook's beforeSwap function looked like this:
