Skip to content

Feature/bet placement#214

Merged
greatest0fallt1me merged 3 commits into
Predictify-org:masterfrom
dannyy2000:feature/bet-placement
Jan 23, 2026
Merged

Feature/bet placement#214
greatest0fallt1me merged 3 commits into
Predictify-org:masterfrom
dannyy2000:feature/bet-placement

Conversation

@dannyy2000

Copy link
Copy Markdown
Contributor

Add full bet lifecycle support with secure placement, validation, storage, and fund handling.

Closes #198

Changes

Add Bet, BetStatus, and BetStats types

Add BetManager for bet placement and double-betting prevention

Add BetStorage with BetRegistryKey to prevent key collisions

Add BetValidator for market, outcome, and balance validation

Add BetUtils for atomic token transfers and fund locking

Implement place_bet() with require_auth()

Add AlreadyBet error and BetPlaced event

Add comprehensive test suite (28 tests)

- Add Bet, BetStatus, and BetStats types
- Implement BetManager for bet placement and management
- Add BetStorage for persistent bet data
- Implement BetValidator for comprehensive validation
- Add BetUtils for fund locking/unlocking
- Implement BetAnalytics for probability calculations
- Add bet placement and status update events
- Prevent double betting on same market
- Add comprehensive test suite (28 tests, 4 unit tests passing)
- Add extensive inline documentation

Security features:
- User authentication via require_auth()
- Atomic fund locking with bet creation
- Double betting prevention
- Comprehensive validation (market state, amounts, outcomes)
- Reentrancy protection via Soroban design

Validation rules:
- Market must be active and not ended
- Bet amount: 0.1 XLM (min) to 10,000 XLM (max)
- Valid outcome selection required
- One bet per user per market

Implementation details:
- 893 lines of production code in bets.rs
- 822 lines of test code in bet_tests.rs
- Full NatSpec-style documentation
- Modular architecture with clear separation of concerns

Note: Integration tests require token transfer configuration
in test environment. Core bet logic verified via unit tests.
- Introduce BetRegistryKey to prevent collision with Market storage
- Fixes ConversionError in bet placement tests
- All 28 bet placement tests now passing
@dannyy2000

Copy link
Copy Markdown
Contributor Author

@greatest0fallt1me please review

@greatest0fallt1me
greatest0fallt1me self-requested a review January 23, 2026 05:28
@greatest0fallt1me
greatest0fallt1me merged commit 11cba53 into Predictify-org:master Jan 23, 2026
1 check passed
Martinsandre007 pushed a commit to Martinsandre007/predictify-contracts that referenced this pull request Mar 27, 2026
…-initialization

fix: pre-initialize outcome stake map during market creation.
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.

feat: implement bet placement with fund locking

2 participants