At FeeColletor::_calculateDistribution() there can be rounding errors to 0. Leading to some of the rewards receivers not receiving them.
At _calculateDistribution(), if the fees collected from one action are 10_000 times smaller that the total fees collected, the treasury will get 100% of those fees due to rounding error. This means, imagine that from feeType == 1 you accrue 100 tokens, and in total, including the rest of feeTypes you accrue 1_000_000 tokens. The treasury will get the 100 tokens that were meant to distributed to different actors.
All value set on the remainder goes to treasury because it is accounted to in shares[3] which is the value later transferred to treasury on _processDistributions():
Treasury can and will get more fees than it should. This is unfair as it leads to some fee receivers, like veRAAC holders, receiving less fees than they should.
You can play with the following code on RemixIDE to see that the logic does the described behavior.
Input 1: _calculateDistribution(100e18, 1000000e18) -> Round down to 0, all would go to treasury.
This is a simplified version of the original function, here.
Yet the logic is exactly the same, just deleted the for loop and focused on 1 feetype logic.
Increase the precision of the BASIS_POINTS. You can use RAYs as done in other parts of the code, these have 27 decimals and that is quite a lot of precision for token amounts arising from fees.
If you increase the precision the rounding to 0 error will disappear, as the rounding will be more precise. Making everyone receive their fair share.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.