Description
The Vicuna Finance hack resulted in a $700K loss through oracle manipulation of Beets LP tokens used as collateral on the Sonic chain. The Core Bug was that LP tokens were priced using a simple sum formula:price_lp = price_token1 * amount_token1 + price_token0 * amount_token0 instead of fair pricing that accounts for the underlying pool’s constant product formula.
Exploitation Steps:
- Pool Manipulation: Attacker swapped large amounts from token0 to token1, artificially inflating the LP token’s oracle-reported price
- Over-Collateralization: Deposited the overvalued LP tokens as collateral and borrowed assets against the inflated value
- Price Deflation: Reversed the swap (token1 back to token0), deflating the LP price and creating bad debt in the protocol
$S market and the stablecoin market - draining approximately $700K in total. The fundamental issue was that the oracle treated LP tokens like regular assets without considering that their value should reflect extractable value, not just the sum of underlying token values.
Proposed Solution
A targeted price deviation check on all calls could have prevented this oracle manipulation attack. The assertion function monitors how each call affects oracle prices and reverts if any single call causes price swings exceeding 5%:How This Assertion Prevents the Exploit
This assertion function detects oracle price manipulation by monitoring how each call affects prices. How it works:- Captures baseline: Uses
ph.forkTxPre()to get the oracle price before any calls - Monitors each call: Iterates through calls (like swaps) that could affect the oracle price
- Checks price impact: Uses
ph.forkCallPost()to see how each call changed the oracle price - Enforces limits: Reverts if any single call causes >5% price deviation from the baseline

