nextAction is not cleared if signal change order is cancelled. This breaks one of the key invariants of the protocol.
There is a key invariant in the contest readme that when an action is cimplete, the nextAction is empty. I'm guessing the there is a bot that monitors the nextAction variable for calls to the keeper contract which triggers the runNextAction() function.
After all actions completed, nextAction, swapProgressData should be empty. PositionKey is 0 when no position
However, when conducting a signal change by run(), if the position is not 1xLong, it needs to first close the current position, and open a new one. The nextAction.selector is set to INCREASE_ACTION.
If the decreasePosition order for closing position fails and gets cancelled, it will enter the afterOrderCancellation() function. The bug here is, since we are in signal_change flow, it clears the flow and flowData, but does not clear nextAction.
This breaks one of the key invariants of this protocol, and will confuse the keeper.
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/main/contracts/PerpetualVault.sol#L617
This breaks one of the key invariants of this protocol, and will confuse the keeper.
N/A
Also clear nextAction.
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.