Unaddressed nextAction state after Signal_CHANGE cancellation
When a decrease order fails during position closure and reopening, the nextAction isn't reset. This violates the system's invariant that expects nextAction to be empty after all actions are completed.
A leveraged position on GMX is being closed and a new one opened.
The keeper triggers the run() function, leading to the else block at lines 314-325:
This schedules the next action as INCREASE_ACTION.
During _createDecreasePosition(), a MarketDecrease order is created, but it fails on GMX.
The keeper cancels the order, triggering afterOrderCancellation(), which resets flow and flowData but doesn't clear nextAction.
The nextAction remains set to INCREASE_ACTION, breaking the invariant that it should be empty after all actions.
Manual Review
Modify the afterOrderCancellation() function to reset nextAction when flow is SIGNAL_CHANGE.
Normal behavior, the keeper will retry to increase the position. That’s why there is this condition in `_createIncreasePosition`: ``` if (flow == FLOW.DEPOSIT) { amountIn = depositInfo[counter].amount; flowData = vaultReader.getPositionSizeInTokens(curPositionKey); } else { amountIn = collateralToken.balanceOf(address(this)); } ```
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.