The GmxProxy contract fails to automatically refund execution fees to users when GMX orders are canceled. Execution fees sent to GMX during order creation remain trapped in the contract, causing financial loss for users.
https://github.com/CodeHawks-Contests/2025-02-gamma/blame/e5b98627a4c965e203dbb616a5f43ec194e7631a/contracts/GmxProxy.sol#L292
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/e5b98627a4c965e203dbb616a5f43ec194e7631a/contracts/GmxProxy.sol#L371
Faulty Code Snippet:
No Automatic Refunds: When orders are canceled, the execution fee is not returned to the user.
No Fee Tracking: The contract does not track which user paid the fee for each order, making refunds impossible.
Example Scenario
User A deposits 1 ETH as an execution fee to open a position.
The order is canceled (e.g., due to timeout or market conditions).
Result: The 1 ETH remains stuck in the GmxProxy contract, and User A cannot recover it.
User Losses: Execution fees are permanently lost if orders fail or are canceled.
Contract ETH Buildup: Excess ETH accumulates in the contract, creating management overhead.
Maunal Review
Track Execution Fees: Store the fee amount and depositor’s address for each order.
Auto-Refund on Cancellation: Return fees to the user when orders are canceled.
After Fixes:
Added depositor and executionFee to OrderQueue to track who paid the fee.
Upon cancellation, refund the fee to the original depositor.
Verification
Test Case 1 (Successful Refund):
User deposits 1 ETH for an order.
Order is canceled.
Result: 1 ETH is returned to the user ✅.
Test Case 2 (No Double-Spending):
Multiple orders are canceled.
Result: Each refund is correctly mapped to its depositor ✅.
Order is not executed, those fees can be used for the next retry.
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.