Incorrect calculation of position fee will result in higher withdraw amount for withdrawer and loss of funds for all other depositors
This is how fee is calculated in PerpetualVault::_withdraw() when users are withdrawing from an open position:
At the same time, we have the following calculation in GMX to get the fee:
This will always result in lower fees for a single withdrawer at the expense of all other depositors.
Incorrect fee calculation leading to unfair withdraw.
Manual review
Consider using min price to match the calculation in GMX.
Likelihood: Low/Medium, every withdraw, position opened, not liquidated, beenShort or not 1, and the difference between minPrice and maxPrice is significant. Impact: Low, small part of feeAmount and PnL not deducted from collateralDeltaAmount.
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.