During the code review of the PerpetualVault smart contract, a potential issue was identified in the _cancelFlow() function regarding the execution fee refund mechanism. The current implementation refunds the full execution fee without accounting for the gas already consumed during the transaction execution.
In the _cancelFlow() function, the execution fee refund is implemented as follows:
The issue is that this implementation:
Refunds the full executionFee amount
Does not deduct the gas already consumed (callbackGasLimit * tx.gasprice)
Is inconsistent with other refund implementations in the contract (e.g., in _mint() and _handleReturn())
Financial: The contract may refund more execution fees than it should, potentially leading to economic losses for the protocol
Consistency: The refund logic differs from other similar operations in the contract, which could lead to unexpected behavior
Gas Usage: Inefficient use of gas as the full amount is refunded regardless of actual consumption
Manual code review
Code comparison with similar implementations within the contract
Likelihood: None/Very Low, when the keeper call cancelFlow after an order execution Impact: High, Inflation/deflation of total shares, and too many fees refunded.
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.