Relying on oracle price data when determining the slippage parameter during a swap is problematic,
as chainlink oracles, especially mainnet, have upwards of 2% threshold before triggering a price update.
If swapping between volatile assets, the errors will compound causing even bigger variation.
These variations can be exploited via sandwich attacks.
In the swap function of the SmartVaultV3 contract, a token exchange occurs between two different assets.
A key component of this function is the calculation of minimumAmountOut, which is intended to provide
slippage protection.
The minimumAmountOut is calculated in the calculateMinimumAmountOut function. This function, in turn,
calls calculator.tokenToEur and calculator.eurToToken, both of which rely on oracle data provided by Chainlink.
The tokenToEur and eurToToken functions in the PriceCalculator contract fetch the latest round data from Chainlink
oracles. This data is crucial as it determines the exchange rates used in the slippage calculation.
The Chainlink oracle updates are triggered based on certain thresholds, such as a deviation threshold or a
heartbeat threshold. In highly volatile markets, there can be significant price movements within a short period.
If the oracle data does not update quickly enough to reflect these market changes,
the minimumAmountOut calculated may be based on outdated prices.
This latency in oracle updates can expose the swap function to sandwich attacks. In such attacks, an attacker
can manipulate the market price before and after the swap transaction, taking advantage of the outdated slippage
protection and potentially causing financial losses to the user.
The consequence of this vulnerability is that the slippage protection provided by minimumAmountOut might
not effectively safeguard against rapid price movements, leading to potential losses for users
executing swaps, especially in volatile market conditions.
Manual Review
Allow users to specify their own slippage value, instead of relying on oracle data. You can check
that their value specified falls within a certain range of the oracle value.
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.