Description:
In the withdrawing process, when there is an open GMX position which is in profit, the calculated pnl value does not get added to collateralDeltaAmount, which gets passed to PerpetualVault::_createDecreasePosition function as a parameter that gets set as initialCollateralDeltaAmount in the orderData that gets passed to GMX when sending the order request.
When executing MarketDecrease orders, GMX transfers the amount of collateral tokens to the owner of the position (which is GMXProxy) based on the provided initialCollateralDeltaAmount value. Due to this, GMXProxy will receive a collateral token amount that does not include the user's PnL, and the user who initiated the withdrawal will receive only this amount.
Impact:
Users will not receive the profit from GMX positions, which completely negates the user incentive to use the Gamma protocol.
Recommended Mitigation:
Add the pnl to collateralDeltaAmount if the pnl is positive:
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
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.