Pre-auditThree days of senior audit time for $1,500, credited in full toward your Zealynx audit.3 audit days, credited toward your auditSee how →
L-01·

Precision loss in fee calculation due to order of operations

Not reportedoptionsleverageblack-scholes
TL;DR

In the _calculateFeesUSD function of OperationalTreasury.sol, the fee calculation is performed in a way that may lead to precision loss due to Division Before Multiply.

Severity
LOW
Method
MManual review
CAT.

In the _calculateFeesUSD function of OperationalTreasury.sol, the fee calculation is performed in a way that may lead to precision loss due to Division Before Multiply. The current implementation:

solidity
fees = price.mulDivRoundingUp(baseSetUp.protocolFees, FEES_UNIT);
fees = (fees * amount).toDecimals(36, 18);

The issue arises because the protocol fees are divided by FEES_UNIT before being multiplied by the amount. This order of operations can result in rounding down of intermediate values, potentially leading to undercharging of fees.

To minimize precision loss, the calculation should be reordered. The recommended implementation should be:

solidity
fees = (price * amount).mulDivRoundingUp(baseSetUp.protocolFees, FEES_UNIT);
fees = fees.toDecimals(36, 18);
02Section · Report provenance

Report provenance

Published by Pashov Audit Group, with Carlos (Bloqarl) participating as a contractor. The source report states that its fixes review was not fully completed; no final remediation disposition is recorded for this finding. Read the full report.

L-01