Files
mev-beta/.qwen/commands/implement-algorithm.md
2025-09-14 10:09:55 -05:00

34 lines
1.8 KiB
Markdown

# Implement Mathematical Algorithm
Implement the following mathematical algorithm for the MEV bot: $ARGUMENTS
## Implementation Framework:
1. **Requirements Analysis**: Break down the mathematical requirements and precision needs
2. **Formula Implementation**: Convert mathematical formulas to precise Go code
3. **Precision Handling**: Use appropriate data types (uint256, big.Int) for calculations
4. **Edge Case Handling**: Consider boundary conditions and error scenarios
5. **Testing**: Create comprehensive tests including property-based tests
6. **Optimization**: Optimize for performance while maintaining precision
## Implementation Standards:
- **Numerical Precision**: Use github.com/holiman/uint256 for precise uint256 arithmetic
- **Error Handling**: Implement robust error handling with clear error messages
- **Documentation**: Document all mathematical formulas and implementation decisions
- **Testing**: Achieve >95% test coverage with property-based tests for mathematical functions
- **Performance**: Consider performance implications and benchmark critical paths
## File Organization:
- **Core Logic**: Place in appropriate `pkg/uniswap/` or `pkg/math/` subdirectory
- **Tests**: Co-locate with source files (`*_test.go`)
- **Documentation**: Inline comments explaining mathematical formulas
## Integration Points:
- **Uniswap Pricing**: Integrate with `pkg/uniswap/` for pricing calculations
- **Market Analysis**: Connect to `pkg/market/` for market data processing
- **Precision Libraries**: Use `github.com/holiman/uint256` for uint256 arithmetic
## Deliverables:
- Working implementation with comprehensive tests
- Documentation of mathematical formulas and implementation approach
- Performance benchmarks for critical functions
- Edge case handling and error scenarios