2 KiB
2 KiB
KRAIKEN LiquidityManager Fuzzing Analysis
Tools for testing the KRAIKEN LiquidityManager's resilience against various trading strategies to identify scenarios where traders can profit.
Quick Start
# Run fuzzing analysis with default settings (100 runs per market)
forge script analysis/FuzzingAnalysis.s.sol --ffi --via-ir
# Custom configuration
FUZZING_RUNS=500 forge script analysis/FuzzingAnalysis.s.sol --ffi --via-ir
# With position tracking (generates detailed CSV for each scenario)
TRACK_POSITIONS=true FUZZING_RUNS=50 forge script analysis/FuzzingAnalysis.s.sol --ffi --via-ir
Configuration
- FUZZING_RUNS: Number of random trading scenarios per market type (default: 100)
- TRACK_POSITIONS: Enable detailed position tracking CSV output (default: false)
How It Works
- Real Deployments: Deploys actual Uniswap V3 factory, pool, and LiquidityManager
- Random Trading: Generates random buy/sell patterns with varying amounts and timing
- Recenter Calls: Triggers
lm.recenter()at random intervals - Profit Detection: Identifies scenarios where traders end with more ETH than they started
- CSV Export: Saves all profitable scenarios to
profitable_scenarios_[timestamp].csv
Output Files
profitable_scenarios_[timestamp].csv- Details of all profitable trading sequencespositions_[scenario]_[seed].csv- Liquidity position data (only with TRACK_POSITIONS=true)
Visualization
# View results in browser
python3 -m http.server 8000
# Open http://localhost:8000/scenario-visualizer.html
# Or use the shell script
./view-scenarios.sh
Analysis Tools
AnalysisVisualizer.py- Generates charts from CSV datascenario-visualizer.html- Interactive web visualizationRISK_ANALYSIS_FINDINGS.md- Summary of discovered vulnerabilities
Components
FuzzingAnalysis.s.sol- Main fuzzing scripthelpers/SwapExecutor.sol- Shared swap execution logicCSVManager.sol- CSV generation utilitiesCSVHelper.sol- CSV formatting helpers