The GmxProxy.sol::getExecutionGasLimit
function's if-else statement misses handling the LimitIncrease
order type, which could lead to incorrect gas limit calculations if this order type is used.
The GmxProxy.sol::getExecutionGasLimit
function does not handle the Order.OrderType.LimitIncrease
order type, meaning that any LimitIncrease
order submitted will use an incorrect gas limit estimation. If an order of type LimitIncrease
is created, estimatedGasLimit
remains uninitialised (causing a compilation error) or defaults to zero, leading to an underestimated gas limit. This can result in failed transactions due to insufficient gas.
The getExecutionGasLimit
function explicitly handles:
MarketIncrease
MarketDecrease
LimitDecrease
StopLossDecrease
MarketSwap
This missing case leads to estimatedGasLimit being unset (remaining 0), which results in an incorrect executionGasLimit calculation, potentially causing transaction failures.
Affected Function: getExecutionGasLimit()
Transaction Failures: Orders will be submitted with insufficient gas, causing failed transactions.
Fund Lockups: Execution fees may be locked in GMX contracts due to failed order processing.
Protocol Disruption: The inability to execute critical limit orders could destabilise hedging strategies.
Reputation Damage: Users may lose trust in the protocol’s order execution reliability.
I used DeepSeek and OpenAi to verify my hunch regarding the completeness of the IF ELSE statement. To quote Daniel Von Fange, "Every time you write an if statement you are giving Satan a little place to live in your code"
Add Explicit Handling for LimitIncrease Orders
Modify getExecutionGasLimit to properly set estimatedGasLimit for LimitIncrease:
Add a Default Case to Revert Unhandled Orders:
Implement compile-time validation of all Order.OrderType variants:
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
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.