the flow variable and other variables are deleted before they are used to emit events that are important for off-chain scripts. this can cause different problems for the keepers and the off-chain scrips.
Asking the sponsors about events in the contracts, they confirmed that it is important that these events are emitted correctly every time because the keepers in the off-chain scrips use these events to make decisions about how to handle the user's positions.
In the perpetual vault contract, there is an edge case where the flow variable is deleted before it is used to emit the GmxPositionUpdated event in the swap case causing this event is not emitted, this can bring problems for the keeper and off-chain scripts, and depending on the way these events are used in the off-chain scripts, this can cause losses for the protocol or the users of the vault.
For example, when a GMX 1x long leverage position is being opened, closed, or changed from long to short or vice versa the keeper executes the run function, and the flow variable is set to SIGNAL_CHANGE to indicate this.
Then the _runSwap function is called to swap the tokens, in the case the swap is done using Paraswap and Gmx the orderType is set OrderType.MarketSwap in the _doGmxSwap function and an order is created in the GMX contracts; at this point, the variables flow and nextAction are set to these values: flow = SIGNAL_CHANGE and nextAction = NO_ACTION .
After this, the GMX keeper will execute the executeOrder function and return a callback to the GMXProxy, the proxy will do some validations and enter the last else case for the swap scenario which calls the PerpetualVault.afterOrderExecution.
The PerpetualVault.afterOrderExecution will enter the else case where the orderType is MarketSwap and as the flow variable is set to SIGNAL_CHANGE the last else case will be executed, this case call the _updateState function which will delete the flow variable.
The _updateState function deletes the flow variable and some other variables, which set these variables to their default values.
After these variables are deleted the afterOrderExecution function will try to emit the GmxPositionUpdated if the flow variable is set to SIGNAL_CHANGE, but the flow variable was reset to its default value in the _updateState function, so this event will not be emitted, this can cause different problems in the off-chain scripts depending how they use this event.
some events will not be emitted correctly, which can bring problems for off-chain scripts.
Manual review.
make sure you delete/reset the variables that are used for other processes like emitting events are deleted at the end of the functions that use these variables to complete some process.
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.