Skip to content

Split Ratio High-Precision Decimal Support #518

Description

@Kingsman-99

Description

The current integer basis-point system (10 000 = 100%) cannot represent ratios like one-third exactly, leading to rounding errors in three-way splits. The contract should support higher-precision ratios using a configurable denominator.

Technical Context

Add ratio_denominator: u64 to the Invoice struct in types.rs. Validate that all ratios are < ratio_denominator and sum to exactly ratio_denominator. Update the payout calculation in contracts/split/src/lib.rs to use amount * ratio / ratio_denominator with checked arithmetic. Default denominator is 10_000.

Acceptance Criteria

  • Denominator of 3 with ratios [1, 1, 1] distributes exactly one-third each (within 1 stroop rounding)
  • Remainder from rounding is awarded to the first recipient
  • Ratios must be strictly less than the denominator value
  • Existing basis-point invoices with denominator 10_000 continue to work
  • Fuzz test in fuzz/ covers random denominators and ratio combinations
  • All CI checks (cargo build --target wasm32-unknown-unknown, cargo test, cargo clippy) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsperformance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions