Chaos LP
Chaos LP — MEV-resistant Uniswap v4 liquidity using Pyth Price Feeds + Entropy randomness
Problem Statement
Chaos LP is a Uniswap v4 Hook that creates MEV-resistant, oracle-driven, randomized liquidity ranges using Pyth Price Feeds (pull oracle) and Pyth Entropy for on-chain randomness. Instead of predictable LP bands attackers can front-run, Chaos LP continually recomputes its liquidity around the latest Pyth ETH/USD price and a fresh random offset provided by Entropy. This produces chaotic, unpredictable liquidity placement that dramatically reduces adversarial overlap and MEV profitability.The project includes: • A fully-deployed v4 pool on Base Sepolia with ChaosHook wired to Pyth Price + Entropy • A TypeScript client to fetch Hermes updates and trigger Chaos LP on-chain • A Rust MEV simulator running 10k Monte Carlo scenarios showing >95% MEV payoff reduction • Local fork tooling (Anvil) for end-to-end reproducible demosChaos LP demonstrates how oracle-fresh prices + verifiable randomness can meaningfully improve the robustness of on-chain liquidity.
Solution
Chaos LP is built using Solidity, Foundry, TypeScript, and Rust, tightly integrated with Pyth Price Feeds and Pyth Entropy. The core smart contract is a Uniswap v4 Hook that follows Pyth’s pull oracle workflow: price updates are fetched from Hermes, passed as bytes[], and delivered on-chain via updatePriceFeeds. The hook then calls getPriceNoOlderThan to consume the freshly updated price and convert it into the corresponding Uniswap tick.Next, the hook requests a random number from Pyth Entropy V2, storing the sequence until the callback arrives. The callback maps the 32-byte entropy to a random tick offset inside pre-defined bounds, snaps it to v4 tick spacing, clamps to global tick limits, and finally calls modifyLiquidity to insert liquidity into this randomized band.The system is deployed using Foundry scripts on Base Sepolia, with automatic explorer verification. A Rust MEV simulator using alloy performs 10k Monte Carlo runs comparing predictable LP bands vs Chaos LP, writing CSVs and generating visual dashboards via plotters. A TypeScript script (requestChaos.ts) fetches Hermes updates, pays Pyth+Entropy fees, and triggers Chaos LP in real time.Everything is modular, reproducible, testable, and showcases how combining oracle freshness + on-chain randomness can meaningfully improve LP security.
Hackathon
ETHGlobal Buenos Aires
2025
Contributors
- reymom
19 contributions