Eth Global Submission: Chaos LP Uniswap v4 example (Price feeds + Entropy) #89
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pyth Examples Contribution
Type of Contribution
Project Information
Project/Example Name: Chaos LP — MEV-Resistant Uniswap v4 Liquidity Using Pyth Price Feeds + Entropy
Pyth Product Used:
Blockchain/Platform:
Description
What does this contribution do?
This PR adds a full working example demonstrating how to combine Pyth Price Feeds (pull oracle) and Pyth Entropy to create a MEV-resistant Uniswap v4 Liquidity Provider called Chaos LP.
Chaos LP deploys a Uniswap v4 pool + hook on Base Sepolia and uses:
The example includes:
How does it integrate with Pyth?
The hook fetches price update blobs from Hermes:
https://hermes.pyth.network/v2/updates/price/latest?ids[]=<feed-id>Then the hook:
This provides a fresh, cryptographically signed ETH/USD price for tick calculation.
Chaos LP requests on-chain randomness:
Then in the callback:
The randomness determines the LP band offset, making attacks unpredictable.
What problem does it solve or demonstrate?
Chaos LP demonstrates that price-informed + randomness-informed liquidity dramatically reduces MEV extraction.
The included Rust simulator shows:
Highly chaotic, unpredictable LP positions versus standard static LP bands
This example demonstrates a novel, production-relevant use case for Pyth:
Directory Structure (for new examples)
Testing & Verification
How to Test This Contribution
Smart Contracts:
forge test -vv. Then also deploy and run scripts as documented below.Prerequisites
Node.js ≥ 18
Rust ≥ 1.77
Foundry (forge + anvil)
Base Sepolia RPC (Alchemy/Infura/etc.)
Setup & Run Instructions
Run anvil fork:
anvil \ --fork-url $BASE_RPC \ --fork-block-number 20000000 \ --chain-id 8453Deploy Chaos LP locally:
forge script scripts/DeployChaosSystem.s.sol:DeployChaosSystem \ --rpc-url http://127.0.0.1:8545 \ --private-key $DEPLOYER_PK \ --broadcast \ -vvTrigger Chaos LP request (Pyth + Entropy):
Run the MEV simulator:
This outputs:
Deployment Information (if applicable)
Network: Base Sepolia (Chain ID 84532)
Contract Address(es):
ChaosHook: 0xD4ED3f079E04f681F8c3C16D4589c4eF82AFC800
Token0: 0xE47bC56b07f1E3D4faB5f16bD3Be53A8B6470d2E
Token1: 0x51Ea2928c87328D6Df0e4569DcC60b78EcEc725f
Demo URL: https://www.canva.com/design/DAG4n6h_QZA/tBSK1NuMxQ-6tN-UsrQSfg/view?utm_content=DAG4n6h_QZA&utm_campaign=designshare&utm_medium=link2&utm_source=uniquelinks&utlId=h927271b026
Checklist
Code Quality
Testing
Additional Context
Related Issues
Fixes #
Screenshots/Demo (if applicable)
Notes for Reviewers
The project demonstrates a novel, fully working integration of:
Pyth Price Feeds (pull mode)
Pyth Entropy
Randomized Uniswap v4 liquidity strategies
Backed by a quantitative MEV study
This is my submission for ETHGlobal Buenos Aires (Pyth Track: Price Feeds + Entropy).
As being part of a hackathon project, many details can be improved, I can do it in the future.
Thank you for contributing to Pyth Examples!