Description
The contract supports batching bets through BetManager::place_bets (contracts/predictify-hybrid/src/bets.rs:329, accepting Vec<(Symbol, String, i128)>), but there is no equivalent for claiming. Users with positions across several resolved markets must call the single-market claim_winnings entrypoint (contracts/predictify-hybrid/src/lib.rs:1697) once per market, paying repeated transaction overhead. This issue adds a claim_winnings_batch entrypoint mirroring the existing batch ergonomics.
Requirements and context
- Model the public API on
place_bets (bets.rs:329) and the existing MAX_BATCH_SIZE cap (50) used there.
- Reuse the resolved single-claim core (see the related batch_claim completion work) so that
AlreadyClaimed, MarketNotResolved, and the dispute-window check (market.dispute_window_seconds) are enforced per market.
- The entrypoint should accept
user: Address plus a Vec<Symbol> of market IDs and return a per-market result (success amount or error code), not abort on the first failure.
- Non-functional: a single
user.require_auth() should authorize the whole batch; gas cost must scale linearly and respect the existing MAX_BATCH_SIZE bound to avoid unbounded loops.
- Emit the same per-claim events the single path emits so off-chain indexers stay consistent.
Acceptance criteria
Suggested execution
1. Fork the repo and create a branch — git checkout -b feature/claim-winnings-batch.
2. Implement changes — add the entrypoint to contracts/predictify-hybrid/src/lib.rs; share the claim core with contracts/predictify-hybrid/src/bets.rs.
3. Write/extend tests — add a dedicated test module (e.g. contracts/predictify-hybrid/src/bet_tests.rs or a new file) using Soroban testutils.
4. Test and commit
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test -p predictify-hybrid
stellar contract build --verbose
Example commit message
feat: add claim_winnings_batch entrypoint mirroring place_bets batching
Guidelines
≥90% coverage on the new entrypoint and its failure branches. Document the atomicity policy in doc-comments and add the entrypoint to API_DOCUMENTATION.md (Balance Management). Timeframe: 96 hours.
Description
The contract supports batching bets through
BetManager::place_bets(contracts/predictify-hybrid/src/bets.rs:329, acceptingVec<(Symbol, String, i128)>), but there is no equivalent for claiming. Users with positions across several resolved markets must call the single-marketclaim_winningsentrypoint (contracts/predictify-hybrid/src/lib.rs:1697) once per market, paying repeated transaction overhead. This issue adds aclaim_winnings_batchentrypoint mirroring the existing batch ergonomics.Requirements and context
place_bets(bets.rs:329) and the existingMAX_BATCH_SIZEcap (50) used there.AlreadyClaimed,MarketNotResolved, and the dispute-window check (market.dispute_window_seconds) are enforced per market.user: Addressplus aVec<Symbol>of market IDs and return a per-market result (success amount or error code), not abort on the first failure.user.require_auth()should authorize the whole batch; gas cost must scale linearly and respect the existingMAX_BATCH_SIZEbound to avoid unbounded loops.Acceptance criteria
claim_winnings_batchentrypoint exists incontracts/predictify-hybrid/src/lib.rsand is exported in the contract client.MAX_BATCH_SIZE); exceeding it returnsError::InvalidInput.cargo fmt,cargo clippy, andcargo testpass.Suggested execution
1. Fork the repo and create a branch —
git checkout -b feature/claim-winnings-batch.2. Implement changes — add the entrypoint to
contracts/predictify-hybrid/src/lib.rs; share the claim core withcontracts/predictify-hybrid/src/bets.rs.3. Write/extend tests — add a dedicated test module (e.g.
contracts/predictify-hybrid/src/bet_tests.rsor a new file) using Soroban testutils.4. Test and commit
cargo fmt --all -- --check cargo clippy --all-targets --all-features -- -D warnings cargo test -p predictify-hybrid stellar contract build --verboseExample commit message
Guidelines
≥90% coverage on the new entrypoint and its failure branches. Document the atomicity policy in doc-comments and add the entrypoint to
API_DOCUMENTATION.md(Balance Management). Timeframe: 96 hours.