Denaria Hack
What happened
On 5 April 2026 an attacker drained about 165,618 USDC from Denaria Finance, a perpetual futures DEX on Linea that prices trades with a virtual AMM combined with oracle prices. The attack ran in a single transaction funded by an Aave flash loan.
Verichains traced the root cause to two bugs in Denaria's LP accounting. Trade execution rounded additions down but subtractions up (divCeil), so each trade eroded an LP's accounting matrix by about 1 wei more than exact math. Once that drift made the LP balance formula evaluate to -1, an unchecked int256 to uint256 cast in internalPerpLogic.sol wrapped it to the maximum uint256 value, which was then clamped to the pool's total assets. Olympix gives the same root cause. The recently added Chainlink Data Streams feed for BTC/USD did not prevent the attack because the flaw was in internal accounting, not the price feed.
Denaria paused all user interfaces, began investigating with the Linea team and auditors, and said users with open trades or USDC in the Vault at the time would be refunded under a procedure still being finalized. It sent the attacker an on-chain offer of a 15% bounty (about $25,600) if the remaining roughly $140K was returned within 48 hours.
How it happened
- The attacker's contract took a USDC flash loan from Aave V3 and deployed helper contracts to act as liquidity providers and traders.
- A helper LP deposited collateral into the Vault and added one-sided liquidity (virtual stable only, zero virtual asset).
- Helper traders opened trades against the pool. Per Verichains, each trade's asymmetric rounding shifted the LP's accounting matrix by about 1 wei, and after roughly eight trades the element
actualM[1][0]drifted from 0 to -1. - The LP balance calculation then produced -1, which the unchecked cast turned into the maximum
uint256, capped at the pool's available assets. - The helper LP called
realizePnLand withdrew the inflated balance as USDC. The attacker repaid the flash loan and sent about 165,618 USDC to0x8d6778d7fae00ad2e0bc12194cf03b756fed9db3.
Protocol details
Evidence
- report @DenariaFinance incident report x.com
- report Exploit Post-mortems (Olympix) olympix.security
- analysis Denaria Hack Drains $165K as Platform Suddenly Goes Offline cryptotimes.io
- analysis DeFiLlama defillama.com
- analysis Denaria Finance Exploit: When divCeil Meets an Unsafe Cast blog.verichains.io
- analysis Denaria Finance Virtual AMM Manipulation darknavy.org
Understand the attack patterns
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.