DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: medium
Invalid

Unfair share distribution during open and closed positions

Title

Unfair share distribution during open and closed positions

Summary

Deposits made when a vault position is open or closed can result in different share amounts due to variations in price impact and fee calculations. This leads to inconsistent share minting for users depositing the same collateral.

Vulnerability Details

The unfair distribution occurs because deposits during open positions use a different calculation process than those during closed positions. The key steps when the position is open are:

  1. A user calls deposit(), pays the execution fee, and sets NextActionSelector.INCREASE_ACTION.

  2. The keeper runs runNextAction() which executes a GMX swap using metadata.

  3. After the swap, afterOrderExecution() calculates the share amount using the formula:

if (priceImpact > 0) {
increased = amount - feeAmount - uint256(priceImpact) - 1;
} else {
increased = amount - feeAmount + uint256(-priceImpact) - 1;
}

This formula adjusts the deposited amount based on fees and price impact, leading to varying share minting.

Impact

The inconsistency in share distribution can cause users to receive more or fewer shares than they should for the same collateral amount. This creates an unequal system where some users may withdraw more collateral than their fair share.

Tools Used

Manual Review

Recommendations

Ensure consistent share distribution by standardizing the valuation process for deposits, regardless of the position state. Consider smoothing out transient price impacts during share calculations to eliminate disparities.

Updates

Lead Judging Commences

n0kto Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.