Description
Several read APIs return placeholder zeros. In contracts/predictify-hybrid/src/queries.rs, query_user_balance hardcodes available_balance = 0i128, total_winnings = 0i128, and resolved_market_count = 0u32 (each tagged // TODO), and query_market_pool hardcodes platform_fees = 0i128 // TODO: Retrieve from fees module. The module's own "Gap Analysis" doc-comment explicitly flags query_contract_state as having "stubbed metrics". Clients relying on these fields receive misleading data. This issue computes the real values.
Requirements and context
queries.rs:571 query_user_balance — populate total_winnings and resolved_market_count from the user's resolved positions (use BetManager/resolution helpers), and source available_balance from the token/balances layer (contracts/predictify-hybrid/src/balances.rs / tokens.rs).
queries.rs:607 query_market_pool — populate platform_fees from the fee module (FeeManager/FeeCalculator::calculate_platform_fee in fees.rs).
- The Gap Analysis block at the top of
queries.rs enumerates the stubbed/inconsistent fields and should be updated as items are resolved.
- Non-functional: queries must stay read-only and gas-bounded; reuse the existing pagination cap
MAX_PAGE_SIZE = 50 (queries.rs:56) where iteration is required, and avoid unbounded scans.
- Keep return types (
UserBalanceQuery, MarketPoolQuery) stable for client compatibility.
Acceptance criteria
Suggested execution
1. Fork the repo and create a branch — git checkout -b feature/queries-real-metrics.
2. Implement changes — contracts/predictify-hybrid/src/queries.rs, pulling from fees.rs, balances.rs, and resolution helpers.
3. Write/extend tests — extend contracts/predictify-hybrid/src/query_tests.rs (re-enable if needed) with fixtures.
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
improvement: compute real balance/pool metrics in QueryManager
Guidelines
≥90% coverage on the updated queries. Update doc-comments and API_DOCUMENTATION.md (Query Functions). Timeframe: 96 hours.
Description
Several read APIs return placeholder zeros. In
contracts/predictify-hybrid/src/queries.rs,query_user_balancehardcodesavailable_balance = 0i128,total_winnings = 0i128, andresolved_market_count = 0u32(each tagged// TODO), andquery_market_poolhardcodesplatform_fees = 0i128 // TODO: Retrieve from fees module. The module's own "Gap Analysis" doc-comment explicitly flagsquery_contract_stateas having "stubbed metrics". Clients relying on these fields receive misleading data. This issue computes the real values.Requirements and context
queries.rs:571query_user_balance— populatetotal_winningsandresolved_market_countfrom the user's resolved positions (useBetManager/resolution helpers), and sourceavailable_balancefrom the token/balances layer (contracts/predictify-hybrid/src/balances.rs/tokens.rs).queries.rs:607query_market_pool— populateplatform_feesfrom the fee module (FeeManager/FeeCalculator::calculate_platform_feeinfees.rs).queries.rsenumerates the stubbed/inconsistent fields and should be updated as items are resolved.MAX_PAGE_SIZE = 50(queries.rs:56) where iteration is required, and avoid unbounded scans.UserBalanceQuery,MarketPoolQuery) stable for client compatibility.Acceptance criteria
query_user_balancereturns realtotal_winningsandresolved_market_count;available_balanceis sourced from the balances/token layer or the field is documented as wallet-side if not on-chain.query_market_poolreturns realplatform_fees.// TODO/hardcoded-zero placeholders in the touched functions.queries.rsis updated to reflect resolved items.cargo fmt,cargo clippy, andcargo testpass.Suggested execution
1. Fork the repo and create a branch —
git checkout -b feature/queries-real-metrics.2. Implement changes —
contracts/predictify-hybrid/src/queries.rs, pulling fromfees.rs,balances.rs, and resolution helpers.3. Write/extend tests — extend
contracts/predictify-hybrid/src/query_tests.rs(re-enable if needed) with fixtures.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 updated queries. Update doc-comments and
API_DOCUMENTATION.md(Query Functions). Timeframe: 96 hours.