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

Unnecessary WETH Balance Check in _swapUnderlyingToAsset of StrategyOp.sol

Summary

The _swapUnderlyingToAsset function in StrategyOp.sol contains an unnecessary and logically incorrect check for the WETH balance of the strategy contract. This check is redundant because the Keeper is expected to use their own WETH for the swap, not the WETH held by the strategy contract.

Vulnerability Details

The following lines of code within the _swapUnderlyingToAsset function are flawed:

uint256 underlyingBalance = underlying.balanceOf(address(this));
require(underlyingBalance >= _amount, "not enough underlying balance");

These lines attempt to verify that the strategy contract possesses sufficient WETH (underlyingBalance) to execute a swap of _amount. However, the strategy's design mandates that the Keeper utilizes their personal WETH for the swap operation, rendering this balance check irrelevant and logically inconsistent.

Impact

While this error may not cause immediate issues under normal circumstances, it demonstrates a misunderstanding of the intended logic and could lead to unforeseen problems in edge cases. For instance, if the strategy contract inadvertently holds WETH, and this balance is less than the _amount the Keeper intends to swap, the function will revert. This would prevent the Keeper from executing the trade, despite having sufficient WETH in their own wallet.

Tools Used

  • Manual Code Review

Recommendations

It is recommended to remove the two lines of code that perform the unnecessary WETH balance check:

// uint256 underlyingBalance = underlying.balanceOf(address(this));
// require(underlyingBalance >= _amount, "not enough underlying balance");

This modification will enhance the code's clarity and accuracy, preventing potential confusion and ensuring it aligns with the strategy's intended operational logic.

Updates

Appeal created

inallhonesty Lead Judge 10 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.