DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

User should get redund when positionIsClosed.

Summary

In PerpetualVault::_withdraw function when positionIsClose is true then the user gets their collateral token based on the current collateral balance of the protcol, If there is no GMX order execution the fee would be refunded and if there isn't the fee won't be refunded.
so the user should get their fee refunded if the postion is closed.

Vulnerability Details

function _withdraw(uint256 depositId, bytes memory metadata, MarketPrices memory prices) internal {
...
>> if (positionIsClosed) {
_handleReturn(0, true, false);
} else if (_isLongOneLeverage(beenLong)) { // beenLong && leverage == BASIS_POINTS_DIVISOR
...
}
>> else if (curPositionKey == bytes32(0)) { // vault liquidated
_handleReturn(0, true, false);
} else {
....
}
}

Impact

user not getting their executionFee refunded.

Recommendations

function _withdraw(uint256 depositId, bytes memory metadata, MarketPrices memory prices) internal {
...
if (positionIsClosed) {
- _handleReturn(0, true, false);
+ _handleReturn(0, true, true);
} else if (_isLongOneLeverage(beenLong)) { // beenLong && leverage == BASIS_POINTS_DIVISOR
...
}
else if (curPositionKey == bytes32(0)) { // vault liquidated
- _handleReturn(0, true, false);
+ _handleReturn(0, true, true);
} else {
....
}
}
Updates

Lead Judging Commences

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

invalid_withdraw_positionIsClosed_does_not_refund_fees

No fee needed in _payExecutionFee when position is closed. Make a PoC if you disagree.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.