Skip to content

Commit

Permalink
Found a rounding error
Browse files Browse the repository at this point in the history
truncating to 5 decimal places for a % can result in the summed
allocation exceeding 100%.

Thanks proptest
  • Loading branch information
michaeldjeffrey committed Sep 30, 2024
1 parent f677951 commit 464e9f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mobile_verifier/src/service_provider/reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ fn distribute_unalloc_over_limit(coll: &mut [RewardInfo], unallocated_perc: Deci
continue;
}
let shares = sp.realized_promo_perc * dec!(100);
sp.matched_promo_perc = ((shares / total) * unallocated_perc).round_dp(5);
sp.matched_promo_perc = (shares / total) * unallocated_perc;
}
}

Expand Down

0 comments on commit 464e9f4

Please sign in to comment.