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.
The following lines of code within the _swapUnderlyingToAsset function are flawed:
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.
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.
Manual Code Review
It is recommended to remove the two lines of code that perform the unnecessary WETH balance check:
This modification will enhance the code's clarity and accuracy, preventing potential confusion and ensuring it aligns with the strategy's intended operational logic.
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.