Normal behavior: The withdrawFees function allows the contract owner to withdraw accumulated protocol fees (totalFees) in USDC. The function transfers the current totalFees to the owner and then resets totalFees to zero.
Issue: If a user calls buyOrder (which increases totalFees) during the execution of withdrawFees - specifically, after the transfer but before totalFees is set to zero - the newly added fee will be overwritten and lost, making it impossible for the owner to withdraw it later.
Likelihood:
This will occur when a user calls buyOrder and pays a protocol fee at the same time as the owner is withdrawing fees.
The risk increases with higher contract usage and frequent fee withdrawals.
Impact:
Protocol fees paid during this race window will be lost and cannot be withdrawn by the owner.
This results in a direct loss of protocol revenue and may cause accounting discrepancies.
Call buyOrder after the transfer but before totalFees is set to zero fees of that buying will be lost.
Get amount of fees and set fees to 0 before transfer.
`withdrawFees()` function performs an external transfer using `iUSDC.safeTransfer()` before resetting totalFees. This breaks the `Checks-Effects-Interactions (CEI)` pattern and can lead to incorrect internal state if the transfer fails for any reason.
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.