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

Missing slippage protection in `PerpetualVault::deposit` leads to Front-Running

Summary

The deposit function in the PerpetualVault contract lacks slippage protection, allowing deposits to be executed at unfavorable prices. This exposes users to price manipulation and front-running attacks, where an attacker can exploit price discrepancies to cause users to receive fewer shares than expected.

Vulnerability Details

  • The deposit() function in the PerpetualVault contract lacks slippage protection when minting shares, making it vulnerable to MEV attacks and front-running. Users have no way to specify a minimum number of shares they expect to receive for their deposit, which could result in significant value loss due to price manipulation.

Link to affected code

Impact

  • Users receive fewer shares for their deposits, leading to financial loss.

  • MEV bots can front-run deposit transactions to extract value

Tools Used

Manual Review

Recommendations

Add slippage protection parameters to the deposit function:

function deposit(uint256 amount, uint256 minSharesToReceive) external nonReentrant payable

Update DepositInfo struct to include slippage parameters:

struct DepositInfo {
uint256 amount;
uint256 shares;
address owner;
uint256 executionFee;
uint256 timestamp;
address recipient;
uint256 minSharesToReceive; // Add this field
}

Implement slippage checks in both immediate and delayed minting paths:

if (positionIsClosed) {
MarketPrices memory prices;
+ uint256 sharesToMint = _calculateShares(amount, prices); // add a function to calculate, expected shares
+ if (sharesToMint < minSharesToReceive) {
revert Error.SlippageExceeded();
}
_mint(counter, amount, false, prices);
// Rest of the function...
}
Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

invalid_shares_slippage

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.

Support

FAQs

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

Give us feedback!