Skip to content

Add a property test asserting compute_route_fee and quote_route agree even with an absolute fee cap configured #135

Description

@mikewheeleer

Property-test quote/compute fee parity under a random absolute fee cap

Description

The existing prop_quote_matches_compute property test in src/lib.rs asserts quote_route and compute_route_fee return the same fee — but only with no MaxFeeAbsolute configured. Both quote_route and compute_route_fee independently call apply_fee_cap, so a divergence in how the cap is applied on one path but not the other would not be caught today. This issue adds a property test that sets a random absolute cap and asserts the two paths still agree across the full (amount, fee_bps, cap) space, and that the charged fee never exceeds the cap.

Requirements and context

  • Repository scope: StableRoute-Org/Stableroute-contracts only.
  • Add a proptest! case that registers a pair with a random fee_bps, sets a random positive MaxFeeAbsolute, and asserts quote_route fee == compute_route_fee fee for a random valid amount.
  • Assert the resulting fee is min(amount * fee_bps / 10_000, cap) and never exceeds the cap.
  • Keep the fixed ProptestConfig { cases: 96 } convention used by the existing property tests for deterministic CI.
  • Distinct from issues-1's general fee-math property harness and issues-4's "cap never exceeded across the input space" — this issue specifically pins quote/compute parity under a cap.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/contracts-quote-compute-parity-under-cap
  • Implement changes
    • Write code in: src/lib.rs — no production change expected.
    • Write comprehensive tests in: src/lib.rs (inline #[cfg(test)] mod test, in the existing proptest! block) — add the parity-under-cap property using setup_pair_with_fee plus set_max_fee_absolute.
    • Add documentation: none required beyond test doc comments.
    • Include NatSpec-style doc comments (///) on the new property explaining the invariant, matching the existing style in lib.rs.
    • Validate security assumptions: the cap is applied identically on both read and compute paths.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases: cap below the bps fee (clamp active), cap above the bps fee (no clamp), and a free pair.
  • Include the full cargo test output in the PR description.

Example commit message

test: property-test quote/compute fee parity under a random absolute fee cap

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No one assigned

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions