In the order execution process, the price impact is calculated based on the difference between expected and actual token sizes. If the price impact in collateral tokens exceeds the initial deposit (amountIn) due to extreme market conditions (e.g., low liquidity or high volatility), the transcation will revert leading to order failures.
The function _createIncreasePosition calculates sizeDeltaUsd using amountIn and leverage, which directly affects price impact calculations.
The afterOrderExecution function calculates the amount of shares minted to the user;
The function getPriceImpactInCollateral determines the price impact based on the difference between expected and actual token sizes.
If priceImpactInCollateral is greater than amountIn, the increased position might be unprofitable, leading to unexpected losses. This issue arises in volatile markets where price slippage significantly affects trade execution.
Scenario
Given:
amountIn = 1150
leverage = 3x
prices.indexTokenPrice.min = 1000e30
prices.shortTokenPrice.min = 0.5e30
prices.shortTokenPrice.max = 1e30
Step 1: Calculate sizeDeltaInUsd
sizeDeltaUsd = 1e30 * 1150 * 3 = 3.45e33
Step 2: Calculate expectedSizeInTokensDelta
expectedSizeInTokensDelta = 3.45e33/1000e30 = 3.45 ETH
Step 3: Calculate realSizeInTokensDelta
Assuming previous position size = 0.1 tokens and new size = 0.35 tokens:
realSizeInTokensDelta = 0.35 - 0.1 = 0.25 ETH
Step 4: Calculate priceImpactInTokens
priceImpactInTokens = 3.45 - 0.25 = 3.2 ETH
Step 5: Calculate priceImpactInCollateralTokens
priceImpactInCollateralTokens = 3.2 * 1000e30 / 0.5e30 = 6400 USD
Since priceImpactInCollateral (6,400) is greater than amountIn (1,150), the increased variable in afterOrderExecution becomes negative, leading to a transaction revert.
Users may lose more than their deposited amount due to excessive price impact.
Manual Review
Allow users to set a stop-loss to prevent excessive losses due to price impact.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
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.