When a strategy changes a position to opening a long 1x leverage- there is a substantial code path that is executed across many different functions -> the end result of the execution emits the wrong values in the event gmxPositionUpdated-> which doesnt accurately represent the change of the position.
The event gmxPositionUpdated takes the following paramaters:
The problem is that isOpenand sizeInTokenswill be populated incorrectly.
For this change in position - opening a long 1x leverage position:
isOpenis true becasue the position will be opened and throughout the execution isOpen is true
sizeInTokensshould represent the amount of tokens that were swapped becasue 1x leverageonly does a swap.
For the sake of simplicity, I will not walk through the entire codepath becasue it will be very long report for a low. But these are the values that are set during the codepath:
OrderType.Type = MARKET_SWAP-> set at the very beginning in runfunction.
flow = FLOW``.SIGNAL_CHANGE
When swapping with gmx- _doGmxSwap is called which opens and completes a swap in the gmxProxy - this is the value for sizeDeltaUsdset: This value of 0 is used for the remainder of the code path.
When the code path meets its end, in afterOrderExecutionthis final patch of code is executed, emitting the event and populating the event incorrectly: look at comments in the code
The event will emit:
falsefor isOpenparameter -> which is incorrect and notifies that the position is closed when in fact it is open
0for sizeInToken-> which should be the output amount of tokens from the swap
manual review
Update the input paramaters for the event GmxPositionUpdated:
isOpenshould be true
sizeInTokensshould be the output amount of tokens of the swap
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.