When users withdraw we remove the PnL based on the decreased size from the collateral delta amount. In order to get only the corresponding PnL we use VaultReader::getPnl() and pass as argument sizeDeltaInUsd equal to the amount coresponding to current withdrawal. In vault reader we call gmxReader.getPositionInfo() and pass true as the last argument which is usePositionSizeAsSizeDeltaUsd. This will basically override passed sizeDeltaInUsd and return the whole position PnL.
In PerpetualVault::_withdraw() we have the following logic to process user's withdrawal when position is opened:
And for VaultReader::getPnl() we have:
Taking a look into ReaderPositionUtils::getPositionInfo() in GMX code we can see the following snippet:
Instead of accounting only for PnL based on the position size decrease, we always account for the whole PnL which lead to loss of funds for withrawers.
Manual review.
Pass false as argument when calling getPositionInfo() and we want information only for part of the position.
Likelihood: Medium/High, every withdrawal from a short or leveraged vault that is not liquidated and has a negative PnL. Impact: High, subtract collateralDeltaAmount from the entire PnL of the position instead of the delta amount PnL. DoS or loss of funds
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.