Pnl of the currentposition is not accounted while deposit shares are calculated
When calculating shares for deposits, the code uses:
And the _totalAmount()
function:
Here, positionData.netValue
includes: code
Collateral amount
Claimable funding fees
Minus pending fees to be paid
But crucially, it doesn't incorporate unrealized PnL from the position.
This creates a disparity:
When users deposit, they receive shares based on the collateral amount only
When users withdraw, their payout includes their proportion of both collateral and PnL
This means early depositors could end up sharing their profits with later depositors who didn't actually contribute to earning that profit. Similarly, if the position is losing money, later depositors would be unfairly diluted by bearing losses they weren't part of creating.
For example:
User A deposits 1000 USDC, gets 1000 shares
Position gains 500 USDC in profit
User B deposits 1000 USDC, gets ~1000 shares (not accounting for profit)
Total: 2000 shares for 2500 USDC value
If both withdraw, they each get 1250 USDC
This unfairly gives User B half of User A's profits, even though User B just deposited.
This represents a significant design flaw in the vault's share calculation mechanism that could lead to unfair profit/loss distribution among depositors.
Pnl is distributed incorrectly among withdraweers leading last withdrawers to gain more if the position is in profit.
Manual
Add position pnl also while calculating totalAMountBefore()
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.