The _freeFunds function in the StrategyMainnet contract does not account for all possible sources of funds when attempting to free assets for withdrawal. This could lead to underreporting of available funds and potential failure to meet withdrawal requests even when sufficient assets are available across different sources.
https://github.com/Cyfrin/2024-12-alchemix/blob/5c19ee37df3aa7605bf782c9c40a482fd82adc67/src/StrategyMainnet.sol#L136-L143
This function only considers the unexpchanged balance in the transmuter, ignoring loose assets already in the contract and claimable WETH in the transmuter.
The incomplete withdrawal logic can lead to several issues:
Underreporting of available funds, potentially causing unnecessary withdrawal failures.
Inefficient use of available assets, as some sources of funds are not utilized.
Possible user frustration due to failed withdrawals when sufficient funds are actually available.
In extreme cases, this could lead to a loss of trust in the strategy if it consistently fails to meet withdrawal requests despite having sufficient assets.
manual code review.
Consider implementing a more comprehensive _freeFunds function that accounts for all potential sources of funds:
Check the balance of loose assets (alETH) already in the contract.
If more funds are needed, withdraw from the transmuter's unexpchanged balance.
If there's still a shortfall, claim WETH from the transmuter and swap it to alETH.
Something like this:
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.