Description
Fee collection is single-market only. FeeManager::collect_fees (contracts/predictify-hybrid/src/fees.rs:720) collects from one market_id per call, so an admin closing out many resolved markets must issue one transaction each. This issue adds a batch collection entrypoint that aggregates fees across a bounded set of markets in a single admin-authorized call, consistent with the batch pattern already used for bets.
Requirements and context
- Build on
FeeManager::collect_fees (fees.rs:720) and its guards (FeeValidator::validate_market_for_fee_collection, FeeAlreadyCollected, NoFeesToCollect).
- Fee math must continue to use the checked helpers in
fees.rs (checked_fee_add, checked_mul_div_floor) which raise Error::FeeArithmeticOverflow; the batch must not bypass these.
- Reuse
FeeTracker::record_fee_collection (fees.rs:1413) per market so analytics (get_fee_analytics) remain accurate.
- Non-functional: bound the batch size (reuse the
MAX_BATCH_SIZE/BatchConfig.max_operations_per_batch convention), authorize once via the admin, and skip-with-error markets that have already been collected rather than aborting the whole batch.
- Emit per-market fee-collection events identical to the single path.
Acceptance criteria
Suggested execution
1. Fork the repo and create a branch — git checkout -b feature/collect-fees-batch.
2. Implement changes — extend contracts/predictify-hybrid/src/fees.rs and add the entrypoint in contracts/predictify-hybrid/src/lib.rs.
3. Write/extend tests — add fee-batch cases (Soroban testutils), e.g. alongside the fee idempotency tests.
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 collect_fees_batch for multi-market fee collection
Guidelines
≥90% coverage on new branches. Add doc-comments and update API_DOCUMENTATION.md (Fee Management) and docs/contracts/FEES.md. Timeframe: 96 hours.
Description
Fee collection is single-market only.
FeeManager::collect_fees(contracts/predictify-hybrid/src/fees.rs:720) collects from onemarket_idper call, so an admin closing out many resolved markets must issue one transaction each. This issue adds a batch collection entrypoint that aggregates fees across a bounded set of markets in a single admin-authorized call, consistent with the batch pattern already used for bets.Requirements and context
FeeManager::collect_fees(fees.rs:720) and its guards (FeeValidator::validate_market_for_fee_collection,FeeAlreadyCollected,NoFeesToCollect).fees.rs(checked_fee_add,checked_mul_div_floor) which raiseError::FeeArithmeticOverflow; the batch must not bypass these.FeeTracker::record_fee_collection(fees.rs:1413) per market so analytics (get_fee_analytics) remain accurate.MAX_BATCH_SIZE/BatchConfig.max_operations_per_batchconvention), authorize once via the admin, and skip-with-error markets that have already been collected rather than aborting the whole batch.Acceptance criteria
collect_fees_batchentrypoint accepting a boundedVec<Symbol>exists and returns per-market collected amounts plus an aggregate total.Error::FeeAlreadyCollectedfor that entry without reverting successful collections.i128math is introduced.Error::InvalidInput.cargo fmt,cargo clippy, andcargo testpass.Suggested execution
1. Fork the repo and create a branch —
git checkout -b feature/collect-fees-batch.2. Implement changes — extend
contracts/predictify-hybrid/src/fees.rsand add the entrypoint incontracts/predictify-hybrid/src/lib.rs.3. Write/extend tests — add fee-batch cases (Soroban testutils), e.g. alongside the fee idempotency tests.
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 new branches. Add doc-comments and update
API_DOCUMENTATION.md(Fee Management) anddocs/contracts/FEES.md. Timeframe: 96 hours.