Skip to content

Comments

feat: implement user balance tracking and management#292

Merged
greatest0fallt1me merged 1 commit intoPredictify-org:masterfrom
Gbangbolaoluwagbemiga:feature/user-balance-management
Jan 31, 2026
Merged

feat: implement user balance tracking and management#292
greatest0fallt1me merged 1 commit intoPredictify-org:masterfrom
Gbangbolaoluwagbemiga:feature/user-balance-management

Conversation

@Gbangbolaoluwagbemiga
Copy link
Contributor

Pull Request Description

📋 Basic Information

Type: ✨ New feature & 🐛 Bug fix
Issues: Closes #206
Priority: 🟡 High

📝 Description

This PR implements User Balance Management and fixes critical bugs in the payout system.

Key Changes:

  1. Internal Balances: Winnings from distribute_payouts and claim_winnings are now credited to the user's internal BalanceStorage instead of being transferred immediately to their wallet. This allows users to accumulate funds for future bets.
  2. Bug Fix (Double Payouts): Fixed a critical logic error in distribute_payouts where users who placed bets (creating both bet and vote records) were being paid twice. The logic now correctly handles the overlap.
  3. CI Fix: Resolved InvalidState (#400) panics in event_management_tests by ensuring proper mock token initialization in TestSetup.

🧪 Testing

  • Unit: balance_tests pass (Deposit/Withdraw flows confirmed).
  • Integration: event_management_tests pass (Payouts and state transitions confirmed).
  • Manual: Verified logic for preventing double-counting of stakes.

🔍 Review Focus

  • Check distribute_payouts loop logic (skipping duplicate bettors).
  • Verify replacement of unlock_funds with BalanceStorage::add_balance.

- Updated distribute_payouts to credit user Internal Balance using BalanceStorage

- Updated claim_winnings to credit Internal Balance instead of direct transfer

- Fixed double-counting bug in distribute_payouts for bet stakes
@greatest0fallt1me greatest0fallt1me merged commit 48743d3 into Predictify-org:master Jan 31, 2026
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.

feat: implement user balance tracking and management

2 participants