Inefficient payout transfer check in `payOff()`
The payOff function of OperationalTreasury.sol calculates the net profit (netAmount) by subtracting fees (feesUSD) from the gross profit (pnl).
The payOff function of OperationalTreasury.sol calculates the net profit (netAmount) by subtracting fees (feesUSD) from the gross profit (pnl). However, the final transfer of this net profit to the user is conditional on the gross profit (pnl) being positive, rather than the net amount (netAmount) itself:
uint256 netAmount = pnl - feesUSD;// ...if (pnl > 0) baseSetUp.token.safeTransfer(account, netAmount);
This logic is inefficient because even if the gross profit (pnl) is positive, the net amount (netAmount = pnl - feesUSD) can be zero if the calculated fees equal the profit. In such a case where pnl > 0 but netAmount == 0, the condition if (pnl > 0) still evaluates to true, leading to an unnecessary safeTransfer call attempting to transfer zero. Attempting a zero-value transfer wastes gas without changing any state.
Modify the condition to check if netAmount is strictly greater than zero before attempting the transfer.
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.