The refundExecutionFee call in the _handleReturn function cannot execute
In the _handleReturn function in the PerpetualVault contract has a conditional statement if (refundFee) which is meant to refund the unused execution fee, however before the conditional statement is reached in the flow of the function, there is a call to the _burn(depositId) function which deletes the deposit Information maping for the depositId as show below
As shown in the above illustration, after the call to the _burn function that deletes the mapping, and the refundFee bool is true, in the loop the depositInfo[depositId].executionFee statement will always return 0 since the mapping is non-existent, therefore the executionFee will never be > usedFee with is neccesary to trigger the execution fee refund function in the gmxProxy contract.
This will happen when the _handleReturn function is called in the runSwap function. The specific instance is given below:
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/main/contracts/PerpetualVault.sol#L1007
Loss of User Funds:
Users who are entitled to a refund of excess execution fees (when depositInfo[depositId].executionFee > usedFee) will never receive it. The condition depositInfo[depositId].executionFee > usedFee can never evaluate to true post-deletion, causing the refundExecutionFee call to the GmxProxy contract to be skipped. This effectively results in users losing funds they should have reclaimed, undermining trust in the system.
Permanent Underfunding of Refunds :
The perpetual deletion of the depositInfo[depositId] mapping before the refund logic ensures that no execution fee refunds are processed, regardless of the actual gas usage (usedFee = callbackGasLimit * tx.gasprice). This disrupts the intended economic model of the contract, where unused fees are returned to depositors, potentially leading to an accumulation of unclaimed funds within the system or misaligned incentives.
Manual Review
Likelihood: High, every time a user withdraw on 1x vault with paraswap Impact: Medium, fees never claimed to GMX and refund to the owner.
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.