Users orders requesting a market swap order from GMX will always overpay for the execution fee , this is because oraclePriceCount has been hardcoded to 5
Consider the following ->
1.) Leverage of the perp vault is 1x and positionIsClosed is false (1x long position).
2.) A user comes to deposit , calls deposit() and since positionIsClosed is false _payExecutionFee() is triggered (L238) ->
3.) Inside _payExecutionFee() ->
4.) Inside getExecutionGasLimit() since _isLongOneLeverage is true (1x long position) ->
5.) getExecutionGasLimit() is called from GmxProxy.sol , and there the uint256 oraclePriceCount = 5; is hardcoded , for our normal swap order (Market Swap Order) we wouldn't need 5 oracles and would need maximum of two oracles , therefore multiplying by 5 will produce a way higher base gas limit ->
Users are overcharged for the execution fees specially for swaps , and since excess fees sent to GMX is not refunded to users in gamma this is a loss of funds for the users.
Manual analysis
Dont' hardcode oraclePriceCount to 5.
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.