Implement core prediction market lifecycle & comprehensive documentation#1
Open
philip-hue wants to merge 5 commits intomainfrom
Open
Implement core prediction market lifecycle & comprehensive documentation#1philip-hue wants to merge 5 commits intomainfrom
philip-hue wants to merge 5 commits intomainfrom
Conversation
…pation
The `user-predictions` map was introduced to enable tracking of user-specific predictions in each market. This map stores the user's prediction ("up" or "down"), their stake amount, and whether they have claimed their rewards.
Key changes:
- Added `user-predictions` map with keys `{market-id: uint, user: principal}`.
- Values include `prediction` (string-ascii 4), `stake` (uint), and `claimed` (bool).
This feature is essential for managing user participation in prediction markets, ensuring accurate reward distribution, and preventing duplicate claims.
Impact:
- Enhances the platform's ability to track user activity in markets.
- Enables secure and transparent reward claiming.
- Lays the groundwork for future features like user-specific analytics.
The `make-prediction` function was added to allow users to place stakes on active prediction markets. This function validates the market's state, ensures the user's stake meets the minimum requirement, and updates both the user's prediction and the market's total stakes. Key changes: - Added validation for market activity (start and end block checks). - Ensured predictions are either "up" or "down" and stakes meet the minimum threshold. - Transferred the stake amount from the user to the contract. - Updated the `user-predictions` map to track user-specific predictions and stakes. - Updated the `markets` map to reflect changes in total stakes for "up" and "down" predictions. Impact: - Enables users to actively participate in prediction markets. - Ensures secure and transparent handling of user stakes. - Provides the foundation for reward distribution based on market outcomes.
…t resolution and reward distribution The `resolve-market` and `claim-winnings` functions were added to enable market resolution and allow users to claim their rewards based on the outcome of a prediction market. Key changes: - **resolve-market**: Allows the oracle to finalize a market by setting the `end-price` and marking the market as resolved. Includes validation for oracle access, market state, and input parameters. - **claim-winnings**: Enables users to claim their rewards for a resolved market. Validates the user's prediction, calculates winnings proportionally, deducts platform fees, and transfers the payout. Impact: - Ensures markets are resolved securely and transparently by the designated oracle. - Provides a mechanism for users to claim rewards while enforcing proper validation and fee deductions. - Enhances the platform's functionality by completing the prediction market lifecycle.
… management This update introduces administrative functions to manage key contract configurations and handle platform fees. These functions are restricted to the contract owner to ensure secure and controlled updates. Key changes: - **set-oracle-address**: Updates the oracle address responsible for market resolution. - **set-minimum-stake**: Adjusts the minimum stake required for predictions. - **set-fee-percentage**: Modifies the platform fee percentage applied to winnings. - **withdraw-fees**: Allows the contract owner to withdraw accumulated platform fees. Impact: - Enhances contract flexibility by enabling dynamic updates to critical parameters. - Provides a secure mechanism for managing platform fees and configurations. - Ensures compliance with administrative controls for contract operations.
This update introduces a detailed README file to provide clear and structured documentation for the BitPredict project. The README covers all essential aspects of the protocol, including its features, architecture, and usage instructions. Key changes: - Added an overview of BitPredict's functionality and purpose. - Documented key features such as market mechanics, economic model, and technical specifications. - Included contract architecture details with core data structures and state management. - Provided installation instructions for setting up the project locally. - Listed error codes with descriptions for better debugging and understanding. - Detailed administrative functions for contract configuration and fee management. - Highlighted security considerations to ensure safe and reliable usage. - Added a contributing guide for developers to collaborate on the project. Impact: - Improves developer onboarding by providing clear and concise documentation. - Enhances project transparency and usability for contributors and users. - Establishes a foundation for future updates and community engagement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
This PR introduces the foundational components for BitPredict's prediction market protocol, enabling:
✅ User participation tracking
✅ Market creation and resolution
✅ Secure reward distribution
✅ Administrative controls
✅ Developer-friendly documentation
Key Features Implemented
1. User Prediction Management (
user-predictionsmap){market-id, principal}2. Market Interaction Functions
make-prediction: Validated STX staking mechanismresolve-market: Oracle-controlled market finalizationclaim-winnings: Proportional reward distribution with fee deduction3. Administrative Controls
4. Documentation System
Impact Analysis
user-predictionsmake-predictionclaimedbool flag