_gmxLock is not unlocked in the afterLiquidationExecution function, this will block the keeper's next action calls, causing a loss of gas and disrupting the protocol functionality momentarily.
Every time the PerpetualVault contract creates an order in the GMX contracts it sets the _gmxLock variable to true, so any other action involving the GMX contracts can modify the state in the perpetual vault contract until the GMX keeper executes the order and returns the callback to the gamma contracts so that the flow can be finished correctly.
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/84b9da452fc84762378481fa39b4087b10bab5e0/contracts/PerpetualVault.sol#L885
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/84b9da452fc84762378481fa39b4087b10bab5e0/contracts/PerpetualVault.sol#L935
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/84b9da452fc84762378481fa39b4087b10bab5e0/contracts/PerpetualVault.sol#L963
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/84b9da452fc84762378481fa39b4087b10bab5e0/contracts/PerpetualVault.sol#L1078
After the GMX contracts execute an order created by the GmxProxy contract, it returns a callback to this contract GmxProxy.afterOrderExecution this function calls the GmxProxy contract which calls the PerpetualVault contract so the flow can be finished correctly.
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/84b9da452fc84762378481fa39b4087b10bab5e0/contracts/GmxProxy.sol#L206-L283
The functions of the PerpetualVault that receive these callbacks should finish the current flow and set _gmxLock to false so the keepers can execute future actions correctly, currently in the PerpetualVault contract the afterOrderExecution and the afterOrderCancellation set the _gmxLock variable to false correctly allowing the future keeper's calls to run successfully.
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/84b9da452fc84762378481fa39b4087b10bab5e0/contracts/PerpetualVault.sol#L474
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/84b9da452fc84762378481fa39b4087b10bab5e0/contracts/PerpetualVault.sol#L600
But the afterLiquidationExecution function doesn't set the _gmxLock to false, this will cause that every subsequent call from the keeper to the runNextAction or the cancelFlow will revert in the gmxLock modifier, blocking the keeper's calls, denying the correct finalization of the current flow in the perpetual vault contract and causing gas loss from these calls.
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/84b9da452fc84762378481fa39b4087b10bab5e0/contracts/PerpetualVault.sol#L563-L583
To avoid this block, the afterLiquidationExecution function should set the _gmxLock variable to false
blocking functionality of subsequent keepers nextAction calls, cancelFlow process, and the loss of transaction gas cost.
Manual Review
Set the _gmxLock variable to false in the afterLiquidationExecution function.
Likelihood: Medium, every liquidation. Impact: Medium, runNextAction and cancelFlow are not usable before a `withdraw` or a `run`
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.