Completed clean root directory structure: - Root now contains only: .git, .env, docs/, orig/ - Moved all remaining files and directories to orig/: - Config files (.claude, .dockerignore, .drone.yml, etc.) - All .env variants (except active .env) - Git config (.gitconfig, .github, .gitignore, etc.) - Tool configs (.golangci.yml, .revive.toml, etc.) - Documentation (*.md files, @prompts) - Build files (Dockerfiles, Makefile, go.mod, go.sum) - Docker compose files - All source directories (scripts, tests, tools, etc.) - Runtime directories (logs, monitoring, reports) - Dependency files (node_modules, lib, cache) - Special files (--delete) - Removed empty runtime directories (bin/, data/) V2 structure is now clean: - docs/planning/ - V2 planning documents - orig/ - Complete V1 codebase preserved - .env - Active environment config (not in git) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
76 lines
2.8 KiB
TOML
76 lines
2.8 KiB
TOML
name = "optimize-math"
|
|
description = "Optimize Mathematical Performance - Optimize the performance of mathematical functions in the MEV bot"
|
|
category = "optimization"
|
|
parameters = [
|
|
{ name = "function", type = "string", description = "The mathematical function to optimize" }
|
|
]
|
|
|
|
[command]
|
|
shell = '''
|
|
echo "# Optimize Mathematical Performance
|
|
|
|
Optimize the performance of the following mathematical function in the MEV bot: ${function}
|
|
|
|
## Performance Optimization Strategy:
|
|
|
|
### 1. **Profiling and Measurement**
|
|
```bash
|
|
# CPU profiling for mathematical functions
|
|
go tool pprof http://localhost:9090/debug/pprof/profile?seconds=30
|
|
|
|
# Memory profiling for mathematical calculations
|
|
go tool pprof http://localhost:9090/debug/pprof/heap
|
|
|
|
# Benchmark testing for mathematical functions
|
|
go test -bench=. -benchmem ./pkg/uniswap/...
|
|
```
|
|
|
|
### 2. **Optimization Areas**
|
|
|
|
#### **Precision Handling Optimization**
|
|
- Uint256 arithmetic optimization
|
|
- Object pooling for frequent calculations
|
|
- Minimize memory allocations in hot paths (Target: 20-33% reduction like in successful implementations)
|
|
- Efficient conversion between data types
|
|
|
|
#### **Algorithm Optimization**
|
|
- Mathematical formula simplification
|
|
- Lookup table implementation for repeated calculations
|
|
- Caching strategies for expensive computations (Reference: SqrtPriceX96ToPriceCached achieved 24% performance improvement)
|
|
- Parallel processing opportunities
|
|
|
|
#### **Memory Optimization**
|
|
- Pre-allocation of slices and buffers
|
|
- Object pooling for mathematical objects
|
|
- Minimize garbage collection pressure (Target: 20-33% reduction like in successful implementations)
|
|
- Efficient data structure selection
|
|
|
|
### 3. **MEV Bot Specific Optimizations**
|
|
|
|
#### **Uniswap V3 Pricing Functions**
|
|
- sqrtPriceX96 to price conversion optimization
|
|
- Tick calculation performance improvements
|
|
- Liquidity-based calculation efficiency
|
|
- Price impact computation optimization
|
|
|
|
#### **Arbitrage Calculations**
|
|
- Profit calculation optimization
|
|
- Cross-pool comparison performance
|
|
- Gas estimation accuracy and speed
|
|
- Multi-hop arbitrage efficiency
|
|
|
|
## Implementation Guidelines:
|
|
- Measure before optimizing (baseline metrics)
|
|
- Focus on bottlenecks identified through profiling
|
|
- Maintain mathematical precision while improving performance
|
|
- Add performance tests for regressions
|
|
- Document optimization strategies and results
|
|
- Consider caching strategies for expensive computations (Reference: Precomputing expensive constants like `2^96`, `2^192` achieved 19-24% performance improvements)
|
|
|
|
## Deliverables:
|
|
- Performance benchmark results (before/after) - Reference: SqrtPriceX96ToPriceCached: 1406 ns/op → 1060 ns/op (24% faster)
|
|
- Optimized code with maintained precision
|
|
- Performance monitoring enhancements
|
|
- Optimization documentation
|
|
- Regression test suite"
|
|
''' |