DeFiFoundrySolidity
16,653 OP
View results
Submission Details
Severity: high
Invalid

Incorrect Slippage Validation in claimAndSwap Function

Summary

The claimAndSwap function currently validates slippage by comparing the raw difference in token quantities before and after the swap, without accounting for variations in the conversion rate between tokens. This approach may incorrectly revert transactions when the value of the received token (alETH) exceeds the claimed token (WETH) amount in terms of value, even if the raw quantity does not meet the _minOut threshold. A value-based comparison, considering token conversion rates, would provide a more accurate slippage validation

Vulnerability Details
https://github.com/Cyfrin/2024-12-alchemix/blob/main/src/StrategyMainnet.sol#L92-L113

The claimandSwap function is called only when WETH price is bigger than alETH or alETH price is lower than WETH.
Example:

Calling the function with _amountClaim -> 20

setting _minOut -> 21 since minOut cannot be lower than the amountClaim (this assures you always swap on win)

If WETH swap to alETH and its 41 + it will pass, but if alETH swaps for 22 (its still good swap and thats the idea of the protocol and function you get 20 WETH swap it for more alETH)

so if you swap it for 22, function will fail since 22-20 = 2 >= 21 -> reverts

require((balAfter - balBefore) >= _minOut, "Slippage too high");

so instead of balAfter - balBefore it should be just balAfter

Impact
High since the whole functionality of the protocol is getting broken. If you cannot pass this function you cannot do anything with the protocol at all.

Tools Used

Manual Review

Recommendations

do not deduct in the require just use balAfter

Updates

Appeal created

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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