Skip to content

Feat/issues 1035 1036 1037 1038 - #1168

Merged
Ehonrie merged 3 commits into
Netwalls:mainfrom
usman222nuhu:feat/issues-1035-1036-1037-1038
Jul 28, 2026
Merged

Feat/issues 1035 1036 1037 1038#1168
Ehonrie merged 3 commits into
Netwalls:mainfrom
usman222nuhu:feat/issues-1035-1036-1037-1038

Conversation

@usman222nuhu

Copy link
Copy Markdown
Contributor

Summary

Implement Market payout functionality and Treasury initialization for the Stellar betting protocol.

Changes

Treasury Contract

  • Implement Treasury::initialize() with fee configuration validation
  • Store admin, fee_bps, and fee_recipient addresses
  • Validate fee_bps does not exceed 1000 basis points (10%)
  • Prevent re-initialization after setup
  • Add getter functions for fee configuration

Market Contract

  • Implement Market::calculate_payout() pure view function for payout estimation
  • Add read-only views: get_market_data(), get_user_bet(), get_pool_totals()
  • Use checked arithmetic throughout to prevent overflows
  • Handle zero pool edge cases without division-by-zero
  • Verify claim_winnings() implementation completeness

Testing

All implementations include comprehensive test coverage for normal paths and edge cases.

Closes

usman222nuhu and others added 3 commits July 28, 2026 07:57
…fee_recipient validation

- Store admin, fee_bps, and fee_recipient addresses
- Validate fee_bps does not exceed 1000 basis points (10%)
- Prevent re-initialization after initial setup
- Add helper functions to retrieve fee_bps and fee_recipient
- Add comprehensive tests for initialization scenarios
…ayout calculation and read-only views

Issue Netwalls#1035: Verify Market::claim_winnings implementation
- Already properly implemented with auth verification
- Status validation for Resolved markets
- Duplicate claim prevention
- Payout calculation with fee deduction
- Re-entrancy guard via claimed flag before transfer
- Event emission for winnings_claimed

Issue Netwalls#1036: Implement Market::calculate_payout
- Pure view function for payout estimation
- Handles zero losing pool without division-by-zero
- Uses checked arithmetic throughout
- Returns stake if no one bet on the side
- Properly calculates proportional share of net pool

Issue Netwalls#1037: Implement Market read-only views
- get_market_data: Returns complete Market struct
- get_user_bet: Returns specific bet for address or None
- get_pool_totals: Returns pool_a, pool_b, total_pool tuple

Fixes:
- Remove duplicate code from get_bets_by_address function
@Ehonrie
Ehonrie merged commit 631d0df into Netwalls:main Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants