The StrategyMainnet::claimAndSwap function does not check if there is sufficient underlying token balance before attempting the swap, which may lead to failures or unexpected behaviors when the balance is insufficient.
The function assumes that the contract always has enough underlying token balance when calling the Curve router's exchange function. However, it does not explicitly verify whether the contract has enough underlying tokens before performing the swap. This missing balance check could lead to the following issues:
Transaction Failures: If the contract does not have sufficient underlying tokens, the transaction will fail, wasting gas.
State Inconsistency: If external actions (e.g., third-party withdrawals) cause the contract’s underlying token balance to become insufficient, it could cause an inconsistent state.
The missing balance check could lead to the following consequences:
Transaction Failure: This will result in wasted gas as transactions may fail.
State Inconsistency: The contract’s state may become inconsistent, affecting the normal execution of the strategy.
Potential Exploitation: An attacker could potentially manipulate the contract's balance to cause unexpected behaviors or exploit the situation.
Manual Code Audit
Before calling the router.exchange function in StrategyMainnet::claimAndSwap, the contract should verify that there is enough underlying token balance. For example:
This ensures that the contract has enough tokens before proceeding with the exchange.
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.