When calculating fees in FeeCollector.sol, distributeCollectedFees()
is called by the DISTRIBUTOR_ROLE
which calls _calculateDistribution()
In _calculateDistribution()
, the weight and feeType.xShare may be very low, which result in a truncation when dividing by BASIS_POINTS
In _calculateDistribution()
, feeAmount
is calculated per feeType which is then divided by totalFees
to get weight
. The weight
is then multiplied by the share and divided by BASIS_POINTS
which is 10000.
Looking at an example, let's say total fees is 40e18, which is distributed as such: (1e18,10e18,5e18,4e18,0e18,3e18,7e18,10e18)
For feeAmount(0) which is 1e18, the weight is 1e18 * 10000 / 40e18 which is 250. The calculation here has no problems, assuming initial feetype:
Now, if we look at feeType(6), weight = 7e18 * 10000 / 40e18 = 1750. Note the truncation of 87.5
This also accounts for the fact that the weight is quite high already, if the weight is lowered, the truncation can be zero.
Fees is not counted properly, leading to loss fees
Manual Review
Recommend improving the precision of the shares calculation to prevent truncation down or even to zero.
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.