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 27, 2024
1 parent fd87d4d commit 3f26bfa
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 3f26bfa

Please sign in to comment.