In the PerpMarket::getPendingFundingFeePerUnit
function, where we calculate the pending funding fee per unit value to accumulate, we are called upon to perform multiplication operations and a division operation. However, division in solidity is rounded down to zero, which causes losses, and these losses are accentuated when multiplied.
In Solidity, integer division naturally rounds down towards zero.So when we have an operation that includes multiplication and division, doing the division first makes us less accurate than doing the multiplication first.
Loss of precision in calculating of `the pending funding fee per unit value to accumulate` in the `PerpMarket::getPendingFundingFeePerUnit` function; which also leads to a loss of precision in the calculation of `the next funding fee per unit value` in function `PerpMarket::getNextFundingFeePerUnit` because the two functions are linked.
Manual review
Only do the division last after all the multiplications.
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.