-
Notifications
You must be signed in to change notification settings - Fork 15
Implement Predict.fun exchange integration #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add Predict.fun exchange configuration to .env.example - Update pyproject.toml and uv.lock to include predict-sdk dependency - Enhance ExchangeClient and ExchangeConfig to support Predict.fun - Introduce PredictFun class for handling API interactions with Predict.fun - Update strategy to manage insufficient funds and improve order handling This integration allows users to trade on the Predict.fun platform, enhancing the overall functionality of the trading system.
7dcf926 to
8bd391b
Compare
Pull Request Review: Predict.fun Exchange IntegrationSummaryThis PR adds comprehensive support for the Predict.fun exchange on BNB Chain, including both EOA and Smart Wallet modes. The implementation is substantial (~1500 lines) and introduces complex cryptographic signing logic. Code Quality & Best PracticesStrengths
Issues & Concerns🔴 CRITICAL: Violation of CLAUDE.md GuidelinesRule #4: "Single Source of Truth: DO NOT place many variables in .env file. Place them in the code instead." The PR adds 7 new environment variables to Recommendation: Consider reducing the number of env vars or refactoring to use configuration discovery/defaults where possible. At minimum, 🟡 Code Duplication
🟡 Magic Numbers
🟡 Error Handling Issues
Security Concerns🔴 HIGH: Private Key Handling
🟡 MEDIUM: Unlimited Token Approval
🟡 MEDIUM: Timestamp Validation
🟢 GOOD: Signature Implementation
Performance Considerations🟡 Inefficient Lookups
🟡 Blocking Web3 Calls
🟢 GOOD: Session Reuse
Potential Bugs🔴 Type Inconsistency
🟡 Potential Division by Zero
🟡 OutcomeToken Model Change
🟡 Fallback Price Logic
Test Coverage🔴 CRITICAL: No Unit Tests
Recommendations:
Architecture & Integration🟢 GOOD: Follows Existing Patterns
🟡 Strategy Changes Impact All Exchanges
🟢 GOOD: Factory Pattern Integration
DocumentationMissing Documentation
Recommendations
Summary & RecommendationsMust Fix Before Merge
Should Fix Before Merge
Nice to Have
Overall AssessmentCode Quality: 7/10 - Well-structured but needs refinement Recommendation: REQUEST CHANGES - The integration is solid, but requires tests and fixes before merging. The codebase guideline violation needs to be addressed. Review generated with attention to security, performance, and maintainability. Please address critical issues before merging. |
Pull Request Review: Predict.fun Exchange IntegrationSummaryThis PR adds comprehensive integration with Predict.fun, a prediction market on BNB Chain. The implementation adds ~1,490 lines of new code in predictfun.py along with supporting configuration changes. Code Quality & Best PracticesStrengths
Areas for Improvement1. Missing Test Coverage
Recommendation: Add tests/test_predictfun.py with basic property tests, configuration validation, mock-based API tests, and Smart wallet vs EOA mode switching tests. Critical: Following CLAUDE.md rule #5 (Run and Debug yourself PROACTIVELY), this integration should have been tested before PR submission. 2. Code Organization - Excessive LengthThe predictfun.py file is 1,490 lines, making it the largest single file in the codebase. Consider extracting signing logic and constants in future refactoring. Potential Bugs & Issues1. Authentication Bug in Smart Wallet Mode (Line 368)The retry logic checks self._account but should check self._owner_account in Smart Wallet mode: Current: if self.api_key and self._account: Fix: has_credentials = self._account if not self._is_using_smart_wallet() else self._owner_account 2. Hardcoded Magic Numbers (Lines 989, 1184)PRECISION, MAX_SALT, and expiration should be module-level constants with explanatory comments. 3. Silent Failure in Balance Fetching (Line 1452)Returning 0.0 on exception could mask serious issues (RPC down, wrong address, etc.). Consider logging warnings even when not verbose. Security Concerns1. Private Key Handling
Recommendation: Add private key validation. 2. Approval Transaction Gas Price (Line 1077)Uses current network gas price without upper bound. During BNB Chain congestion, this could result in excessively expensive approval transactions. Recommendation: Add configurable max gas price. Changes to Shared Codedr_manhattan/base/strategy.py
dr_manhattan/base/exchange_client.py
Final RecommendationsMust Fix Before Merge (P0)
Should Fix Before Merge (P1)
Nice to Have (P2)
Overall AssessmentCode Quality: 4/5 Recommendation: Approve with changes requested This is a solid implementation that integrates a complex exchange with dual signing modes. The code quality is generally high and follows project conventions. However, the complete lack of tests and the authentication bug should be addressed before merging. The integration appears feature-complete and ready for testing. With test coverage added and the authentication bug fixed, this would be a valuable addition to the project. |
close #43
This integration allows users to trade on the Predict.fun platform, enhancing the overall functionality of the trading system.