Collateral remains locked in GMX's OrderVault when orders fail execution, causing permanent loss of user funds.
Description:
When GMX orders fail execution (due to slippage, liquidity issues, etc.), the protocol fails to recover collateral from GMX's OrderVault. The afterOrderCancellation callback resets internal state but doesn't handle collateral retrieval.
Root Cause:
The root cause of this issue is the lack of proper handling for failed orders in the createOrder function. The function does not include logic to recover collateral from GMX's OrderVault when an order fails.
Proof of Concept: Copy and paste in the PerpetualVault.t.sol
Funds Stuck in GMX's OrderVault: Collateral remains in GMX's OrderVault indefinitely if the order fails.
Protocol State Inconsistency: The PerpetualVault records the deposit as completed and mints shares, even though no GMX position is opened.
User Shares: Users may receive shares for deposits not backed by actual collateral, leading to potential financial discrepancies.
Manual
To mitigate this issue, implement logic to recover collateral from GMX's OrderVault when an order fails. Here are some recommendations:
Recover Collateral on Order Cancellation: Add logic to the afterOrderCancellation function to recover collateral from GMX's OrderVault.
Update Protocol State: Ensure that the protocol state is updated correctly when an order fails, including adjusting user shares and deposit records.
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.