Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
Broken strategy realAssets calculation leading to wrong report of current deposit.
Vulnerability Details
RE: Morpho's documentation ( https://docs.morpho.org/learn/concepts/vault-v2/#1-the-adapter-model-a-universal-gateway-to-yield ) - Function realAssets() returns the current value of all investments that the adapter manages. This allows the vault to automatically calculate total assets by aggregating across all adapters.
But that's not the case in strategies https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/strategies/mainnet/TokeAutoEth.sol and https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/strategies/mainnet/TokeAutoUSDStrategy.sol. Inside of them the realAssets() method doesn't return the accurate value of the current investment thus passing the realAssets() output to the deallocate leads to revert.
Toke Auto Eth Vault protocol have different formulas to calculate allocations and currently the 2 strategies are not considering this in the calculation of the realAssets() - https://github.com/Tokemak/v2-core-pub/blob/main/src/vault/libs/Autopool4626.sol#L54
Impact Details
Two of the in-scope strategies returning wrong amounts of the current allocation.
Recommendation
Consider updating the realAssets method of both TokeAutoEth.sol and TokeAutoUSDStrategy.sol strategies:
Proof of Concept
Proof of Concept
Create test file src/test/strategies/TokeAutoETHStrategy.deallocate.t.sol and run it with command forge test src/test/strategies/TokeAutoETHStrategy.deallocate.t.sol -vv:
Test scenario test_deallocate_fail shows that realAssets is broken and test scenario test_deallocate_success shows that the fixed version realAssetsFixed works when requesting the strategy's deallocate method.