Profitability Engine Implementation #13
Merged
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.
Profitability Engine Implementation
This PR implements the profitability engine component for the staker-bots system, which analyzes and determines whether deposits can be profitably bumped based on calculator eligibility, reward constraints, gas costs, and batch optimization.
Overview
The profitability engine integrates with the Staker contract to determine bump eligibility and calculates optimal tips and batch sizes for profitable bump operations. It follows the same architectural patterns as the calculator component, using a wrapper/strategy pattern.
Key Components
ProfitabilityEngineWrapper
BaseProfitabilityEngine
Types and Interfaces
ProfitabilityCheck: Result type for single deposit analysisBatchAnalysis: Result type for batch profitability analysisBumpRequirements: Encapsulates eligibility and reward constraintsTipOptimization: Handles optimal tip calculations and profit estimatesKey Features
Deposit Validation
Unclaimed Rewards Rules
Gas Price Management
Batch Optimization
Safety Features
Configuration
The engine is configurable through
ProfitabilityConfig:minProfitMargin: Minimum required profit (default: 0.01 ETH)maxBatchSize: Maximum deposits per batch (default: 10)gasPriceBuffer: Buffer percentage for gas price (default: 20%)minConfidence: Required confidence for estimates (default: 90)defaultTipReceiver: Address to receive bump tipsTesting
Future Improvements
Enhanced Batch Optimization
Monitoring and Analytics
Performance Optimization
Dependencies
Related Issues
Deployment Notes
Please review the implementation focusing on: