During an active possition a user will be minted shares based on the current collateral they supply. However due to the lack of any slippage protection a user might receive unpredicatble shares in the protocol.
When a user creates a deposit during an active possition they only specify the amount:
However when they deposit during an active position, a keeper would be required to call runNextAction. The keeper will then create an order to the gmx protocol which will be based on the prices provided by the keeper:
https://github.com/CodeHawks-Contests/2025-02-gamma/blob/84b9da452fc84762378481fa39b4087b10bab5e0/contracts/PerpetualVault.sol#L369
The order will then be executed by a gmx keeper and trigger afterOrderExecution at the time of execution.
The user's deposit will also be affected by any slippage which occurred between the time when user initiated a deposit and the increase order was finally executed by the gmx keeper:
However the time between the order submission and the order execution can vary and the user will not have any control over the slippage.
Users will be distributed shares they have no control over.
Manual Review
Add slippage protection
Shares represent a part of the vault. Even if someone performs a frontrun or sandwich attack, you will still have the corresponding amount of shares representing your deposit. A user could add liquidity two days later, and you would still have the same amount of shares.
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.