The createOrder function in the GmxProxy contract incorrectly approves the gmxRouter instead of the gExchangeRouter for token transfers. This leads to failed token transfers when creating orders, causing orders to lack collateral and resulting in failed transactions or stuck funds.
In the createOrder function, the contract approves the gmxRouter to spend the initialCollateralToken. However, the actual token transfer is performed by the gExchangeRouter using the sendTokens function. This discrepancy causes the token transfer to fail due to lack of approval, leading to insufficient collateral for the created orders.
Root Cause:
The createOrder function incorrectly approves the gmxRouter instead of the gExchangeRouter for token transfers.
Proof of Concept:
Incorrect Approval:
Token Transfer:
Impact Demonstration:
When the createOrder function is called with orderType as MarketSwap or MarketIncrease, the approval is given to gmxRouter.
The sendTokens function call by gExchangeRouter will fail due to lack of approval, causing the order to lack collateral and fail.
** **
Orders will fail due to insufficient collateral, leading to loss of user funds as tokens are not properly transferred to GMX's order vault. This can result in failed transactions or stuck funds.
Manual
To fix this issue, the approval should be given to the gExchangeRouter instead of the gmxRouter
Router is the one collecting tokens: https://github.com/gmx-io/gmx-synthetics/blob/caf3dd8b51ad9ad27b0a399f668e3016fd2c14df/contracts/router/BaseRouter.sol#L46 https://github.com/gmx-io/gmx-synthetics/blob/caf3dd8b51ad9ad27b0a399f668e3016fd2c14df/contracts/router/Router.sol#L27
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.