The withdraw
function in the PerpetualVault
contract allows users to withdraw their deposited collateral tokens. When users call this function, they may need to pay an execution fee (executionFee
) by sending msg.value
. This fee is stored in depositInfo[depositId].executionFee
. However, if the position is closed (positionIsClosed == true
), the withdraw
function calls _handleReturn
with refundFee = false
, which means the execution fee is not refunded to the user. This results in the user losing the execution fee they paid, even though the withdrawal operation may not have incurred significant gas costs.
Users call withdraw
to withdraw their deposited collateral tokens and it will call _payExecutionFee
:
In _payExecutionFee
function, if msg.value > 0
, the execution fee is paid and stored in depositInfo[depositId].executionFee
The the withdraw
function will call _withdraw
function if there is no open position and in _withdraw
function, it will call _handleReturn
with refundFee = false
If refundFee
is false
, the execution fee stored in depositInfo[depositId].executionFee
is not refunded to the user:
Issue
When the position is closed (positionIsClosed == true
), the withdraw
function calls _handleReturn
with refundFee = false
. This means the execution fee paid by the user is not refunded, even though the withdrawal operation may not have incurred significant gas costs.
This behavior is unfair to users because they lose the execution fee they paid, even if the withdrawal operation is simple and does not require complex on-chain interactions (e.g., GMX position adjustments).
Financial Loss for Users: Users lose the execution fee they paid when withdrawing funds, especially in cases where the position is already closed and the withdrawal operation is straightforward.
The impact is High, the likelihood is Low, so the severity is Medium.
Manual Review
Consider following fix:
No fee needed in _payExecutionFee when position is closed. Make a PoC if you disagree.
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.