Skip to content

Feat: Admin-Approved Duration Extensions with Limits, Fees, Events, and History Tracking#127

Merged
greatest0fallt1me merged 16 commits into
Predictify-org:masterfrom
Jagadeeshftw:issue-62
Jul 5, 2025
Merged

Feat: Admin-Approved Duration Extensions with Limits, Fees, Events, and History Tracking#127
greatest0fallt1me merged 16 commits into
Predictify-org:masterfrom
Jagadeeshftw:issue-62

Conversation

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

Pull Request Description

📋 Basic Information

Type of Change

Please select the type of change this PR introduces:

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧪 Test addition/update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🎨 UI/UX improvement
  • 🚀 Deployment/Infrastructure change

Related Issues

Closes #62

Priority Level

  • 🔴 Critical (blocking other development)
  • 🟡 High (significant impact)
  • 🟢 Medium (moderate impact)
  • 🔵 Low (minor improvement)

📝 Detailed Description

What does this PR do?

This PR introduces a comprehensive market extension system for the Predictify Hybrid contract. It allows market admins to extend the duration of a market under controlled and validated conditions, with fee handling, event logging, and extension history tracking. The following features are included:

  • New contract functions for extending market duration, validating extension conditions, checking extension limits, emitting extension events, retrieving extension history, and handling extension fees.
  • Extension approval and validation system, including admin checks, extension limits, and fee requirements.
  • Storage and retrieval of extension history and statistics.
  • Event emission for monitoring extension actions.
  • Unit tests for extension logic.

Why is this change needed?

Currently, market duration is fixed at creation, with no way to extend it if more time is needed for proper resolution. This feature is essential for:

  • Handling unforeseen delays in market resolution.
  • Allowing admins to respond to disputes or oracle delays.
  • Improving user experience and market flexibility.
  • Enabling better governance and transparency through event logging and history tracking.

How was this tested?

  • Unit tests for extension validation, fee calculation, and statistics.
  • Manual compilation and build checks (cargo build).
  • Code review for logic and security.

Alternative Solutions Considered

  • Allowing unlimited extensions (rejected for governance and abuse reasons).
  • No fee for extension (rejected to prevent spam and ensure economic alignment).

🏗️ Smart Contract Specific

Contract Changes

Please check all that apply:

  • Core contract logic modified
  • Oracle integration changes (Pyth/Reflector)
  • New functions added
  • Existing functions modified
  • Storage structure changes
  • Events added/modified
  • Error handling improved
  • Gas optimization
  • Access control changes
  • Admin functions modified
  • Fee structure changes

Oracle Integration

  • Pyth oracle integration affected
  • Reflector oracle integration affected
  • Oracle configuration changes
  • Price feed handling modified
  • Oracle fallback mechanisms
  • Price validation logic

Market Resolution Logic

  • Hybrid resolution algorithm changed
  • Dispute mechanism modified
  • Fee structure updated
  • Voting mechanism changes
  • Community weight calculation
  • Oracle weight calculation

Security Considerations

  • Access control reviewed
  • Reentrancy protection
  • Input validation
  • Overflow/underflow protection
  • Oracle manipulation protection

🧪 Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • All tests passing locally
  • Manual testing completed
  • Oracle integration tested
  • Edge cases covered
  • Error conditions tested
  • Gas usage optimized
  • Cross-contract interactions tested

Test Results

# Paste test output here
cargo test
# Expected output: All tests passed

Manual Testing Steps

  1. Compile contract with cargo build (no errors)
  2. Run unit tests for extension logic
  3. Manual review of extension event emission and storage

📚 Documentation

Documentation Updates

  • README updated
  • Code comments added/updated
  • API documentation updated
  • Examples updated
  • Deployment instructions updated
  • Contributing guidelines updated
  • Architecture documentation updated

Breaking Changes

Breaking Changes:

  • Market storage structure now includes extension history and related fields.

Migration Guide:

  • Existing markets will need to be migrated to include new extension fields (with default values).

🔍 Code Quality

Code Review Checklist

  • Code follows Rust/Soroban best practices
  • Self-review completed
  • No unnecessary code duplication
  • Error handling is appropriate
  • Logging/monitoring added where needed
  • Security considerations addressed
  • Performance implications considered
  • Code is readable and well-commented
  • Variable names are descriptive
  • Functions are focused and small

Performance Impact

  • Gas Usage: Minimal increase due to additional storage and validation logic.
  • Storage Impact: Slightly increased due to extension history and stats.
  • Computational Complexity: Negligible impact; extension logic is simple and bounded.

Security Review

  • No obvious security vulnerabilities
  • Access controls properly implemented
  • Input validation in place
  • Oracle data properly validated
  • No sensitive data exposed

🚀 Deployment & Integration

Deployment Notes

  • Network: Testnet/Mainnet
  • Contract Address: TBD
  • Migration Required: Yes (for existing markets)
  • Special Instructions: Ensure all markets are updated to include new extension fields.

Integration Points

  • Frontend integration considered
  • API changes documented
  • Backward compatibility maintained (with migration)
  • Third-party integrations updated

📊 Impact Assessment

User Impact

  • End Users: Markets can be extended, improving fairness and flexibility.
  • Developers: New APIs for extension management.
  • Admins: More control over market lifecycle.

Business Impact

  • Revenue: Potential for increased fee revenue from extensions.
  • User Experience: Improved, as markets can adapt to real-world delays.
  • Technical Debt: Reduced by providing a robust, auditable extension system.

✅ Final Checklist

Pre-Submission

  • Code follows Rust/Soroban best practices
  • All CI checks passing
  • No breaking changes (or breaking changes are documented)
  • Ready for review
  • PR description is complete and accurate
  • All required sections filled out
  • Test results included
  • Documentation updated

Review Readiness

  • Self-review completed
  • Code is clean and well-formatted
  • Commit messages are clear and descriptive
  • Branch is up to date with main
  • No merge conflicts

📸 Screenshots (if applicable)

🔗 Additional Resources


💬 Notes for Reviewers

Please pay special attention to:

  • Extension validation and fee logic
  • Storage and event emission for extension history
  • Backward compatibility and migration

Questions for reviewers:

  • Are the extension limits and fee structure appropriate?
  • Is the extension event system sufficient for monitoring?

Thank you for your contribution to Predictify! 🚀

…contract, including handling for extension limits, reasons, and fees.
…id contract, providing functionalities for extending market durations, validating extensions, handling fees, and tracking extension history and statistics.
…act, including duration extension, validation, fee handling, event emission, and statistics retrieval.
…ctify Hybrid contract, including validation logic and default settings for extension management.
…y importing ExtensionStats from types and removing unused imports for cleaner code.
…y Hybrid contract to ensure proper evaluation of maximum extensions.
…d contract to ensure accurate evaluation of maximum extensions.
…s.rs by adjusting line breaks and indentation for function parameters and comments.
…act by improving code formatting, adding whitespace for readability, and ensuring consistent style across error definitions and helper functions.
… Predictify Hybrid contract by adjusting whitespace, aligning function parameters, and enhancing overall structure for better maintainability.
…ictify Hybrid contract by reordering imports and aligning function parameters for enhanced clarity and maintainability.
…Predictify Hybrid contract by reordering imports, aligning function parameters, and improving whitespace for better maintainability.
…Predictify Hybrid contract by reordering imports, aligning function parameters, and enhancing whitespace for better maintainability.
…dictify Hybrid contract by reordering imports, improving whitespace, and aligning function parameters for better maintainability.
…edictify Hybrid contract by reordering imports, enhancing whitespace, and aligning function parameters for better maintainability.
…redictify Hybrid contract by aligning function parameters, improving whitespace, and reordering imports for better maintainability.
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

LGTM! @Jagadeeshftw

@greatest0fallt1me greatest0fallt1me merged commit b20994e into Predictify-org:master Jul 5, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Market Duration Extension with Approval Mechanism

2 participants