Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: high
Invalid

Rounding Issue in Fee Calculation in `distributeProtocolAssetReward` Function

Summary
The distributeProtocolAssetReward function in the MarketMakingEngineConfiguration.sol contract has a potential rounding issue in the calculation of the fee recipient reward. The current implementation may result in rounding errors, leading to discrepancies in the distributed rewards.

Vulnerability Detailsuint256 feeRecipientReward = amountX18.mul(ud60x18(shares)).div(totalFeeRecipientsSharesX18).intoUint256(); //@audit should be round down

The calculation of feeRecipientReward may result in rounding errors, which can lead to discrepancies in the distributed rewards. The current implementation does not explicitly handle rounding, which may cause issues when the total distributed amount does not match the expected amount.

Impact
The impact of this issue is that it can lead to discrepancies in the distributed rewards, potentially causing some fee recipients to receive slightly more or less than their intended share. This can lead to fairness issues and potential disputes among fee recipients.


Tools Used

manual

Recommendations

To mitigate this issue, it is recommended to explicitly handle rounding in the calculation of feeRecipientReward. This can be achieved by nding function to ensure that the calculated reward is rounded down.

uint256 feeRecipientReward = amountX18.mul(ud60x18(shares)).div(totalFeeRecipientsSharesX18).floor().intoUint256();
Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.