The function _createIncreasePosition in the PerpetualVault contract and settle function in the gmxProxy is consistently reverting due to an issue with the swap path validation mechanism within the GMX protocol. The core problem stems from the swapPath being set to an empty array (new address ), which leads to a chain of function calls that ultimately causes the transaction to revert.
Here i only discuss the case for _createIncreasePosition function, for settle it will be same
Swap Path Validation Failure:
First the keeper calls the run function to open a position assume with the leverage of 20000(2x) in the run function calls the _createIncreasePosition.
The function _createIncreasePosition prepares order data with an empty swapPath array.
This order data is used to call gmxProxy.createOrder, which interacts with GMX's exchangeRouter.createOrder function.
gmxProxy createOrder
The gExchangeRouter.createOrder function calls the OrderHandler.createOrder
Within GMX’s internal flow, OrderUtils.createOrder is triggered by the OrderHandler.createOrder, which calls MarketUtils.validateSwapPath(dataStore, params.addresses.swapPath); to validate the swap path.
In MarketUtils.validateSwapPath, each address in the swapPath is checked.
Since swapPath is empty, marketAddress defaults to 0x0000000000000000000000000000000000000000.
This invalid market address is then passed to validateSwapMarket.
validateSwapMarket attempts to retrieve market data using MarketStoreUtils.get, but since the marketAddress is zero, it returns an empty market structure.
The function validateEnabledMarket is then called, where it checks if market.marketToken is zero.
Since the retrieved market has no valid token it fails the check and triggers a revert with Errors.EmptyMarket().
Any attempt to call _createIncreasePosition results in a transaction failure.
Keeper cannot open positions due to the incorrect swap path configuration.
Smart contract functionality is effectively blocked for increasing positions.
Manual Review and Arbitrum explorer
Explicitly Define a Valid Swap Path:
Instead of using new address ensure the swapPath contains at least one valid market address.
Fetch the correct swap path dynamically from GMX’s DataStore.
Add a Pre-Validation Check:
Before calling gmxProxy.createOrder, check if the swapPath is empty and provide a meaningful error message.
Ensure Market Addresses are Resolved Correctly:
Confirm that marketToken is correctly set before calling GMX’s order functions.
Fetch market data properly to avoid passing zero addresses.
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.