Depositing into the vault is a multi-step operation. First users call deposit and provide funds, second Gamma keeper call runNextAction to create an order in GMX, then GMX keeper execute the order which results in calling afterOrderExecution(). If ADL happens in the time period between order creation and order execution, the calculated priceImpact in afterOrderExecution would be wrongly calculated.
Consider the following scenario:
We have open position with collateral = 1000 USD, and position size = 3000 USD
User call deposit(), providing 100 USD.
Gamma keeper call runNextAction().
runNextAction internally calls _createIncreasePosition which will set
Due to highly increased PnL, GMX use the ADL functionality which will trigger GammaProxy::afterOrderExecution():
Collateral of the position and size will be lowered and wont be 1000 and 3000 respectively but a smaller values.
Now GMX keeper executes the initial order for user deposit, which again triggers GmxProxy::afterOrderExecution() which internally calls PerpetualVault::afterOrderExecution() where the shares calculation for user's deposit is done.
As we have noted above prevSizeInTokens will be based on the value before ADL which is higher than the actual one.
Taking a look into GetPriceImpactCollateral():
curSizeInTokens after ADL and user deposit can be either lower than prevSizeInTokens which will revert the callback and Gamma wont be able to account for the user shares or calculated tokens delta would be a lower than actual. This results in incorrect priceImpact calculation which is used to determine the user shares.
Incorrect calculation of shares for users and even completely failed callback which results in no shares for user and need of manual intervation of owner to setup the next action.
Manual review.
Consider accounting for such case. In GmxProxy::afterOrderExecution when handling ADL scenario, update the flow data (position size in tokens) to match the new one.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
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.