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 isOpen
and sizeInTokens
will be populated incorrectly.
For this change in position - opening a long 1x leverage position:
isOpen
is true becasue the position will be opened and throughout the execution isOpen
is true
sizeInTokens
should represent the amount of tokens that were swapped becasue 1x leverage
only 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 run
function.
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 sizeDeltaUsd
set: This value of 0 is used for the remainder of the code path.
When the code path meets its end, in afterOrderExecution
this final patch of code is executed, emitting the event and populating the event incorrectly: look at comments in the code
The event will emit:
false
for isOpen
parameter -> which is incorrect and notifies that the position is closed when in fact it is open
0
for sizeInToken
-> which should be the output amount of tokens from the swap
manual review
Update the input paramaters for the event GmxPositionUpdated
:
isOpen
should be true
sizeInTokens
should 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.