Skip to content

[CRITICAL] Configuration parameter interactions create hidden systemic risks — no safe combination of constants exists #175

Description

@grantfox-oss

Summary

The four contracts use interdependent configuration constants (fee BPS, minimum bet, TTL values, MAX_TOP_PLAYERS, decay parameters, referral bonus multipliers) that interact in ways the individual tests do not cover. There is no invariant test that verifies the combination of all constants produces safe behavior across all contract boundaries simultaneously.

Key interactions at risk

  1. cancel_market reclaim vs. withdraw_fees cap (issue [CRITICAL] cancel_market fee reclaim uses wrong fee rate denominator — reclaims 200 bps but market only holds 150 bps platform fees #87 vs [CRITICAL] withdraw_fees lets fee recipient drain entire accumulator — no cap, no provenance #94): cancel_market reclaims fees_in_pool = net_pool * TOTAL_FEE_BPS / (BPS_DENOM - TOTAL_FEE_BPS) from the global AccumulatedFees, but withdraw_fees draws from the same accumulator. If both fire in the same ledger sequence, the order of operations determines whether fees are under- or over-accounted.

  2. TTL vs. market duration: MarketTTL (30 days) is shorter than max_duration_secs (60 days). A market that runs its full duration and is then claimed will have an expired BetEntry before the claim window closes.

  3. Leaderboard points vs. PULSE minting: reward mints points * REWARD_RATE PULSE per call. If MAX_TOP_PLAYERS is increased without adjusting REWARD_RATE, the leaderboard can exceed the token supply cap in a single distribution round.

  4. Referral depth vs. fee caps: withdraw_fees takes from a global accumulator with per-market fee tracking. If referral chains are deep and fees compound, a single cancel_market reclaim can wipe the accumulator, leaving withdraw_fees with nothing for active markets.

Why it's critical

No single constant is individually unsafe, but the combination creates state-invariant violations that no per-issue patch can address. This is effectively unsolvable without a coordinated cross-contract redesign.

Fix

  • Add a cross-contract invariant test suite that exercises every constant combination.
  • Document the invariant matrix (fee BPS × market duration × TTL × reward rate × referral depth).
  • Introduce a governance process for constant changes that requires re-verification of all invariants.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSThird CampaignCampaign: Third CampaigncriticalCritical severity - funds at riskdesign-flawArchitectural design flaw

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions