Submitted by cmichel
The Vault.balance function uses the balanceOfThis function which scales (normalizes) all balances to 18 decimals.
Note that balance()s second term IController(manager.controllers(address(this))).balanceOf() is not normalized.
The code is adding a non-normalized amount (for example 6 decimals only for USDC) to a normalized (18 decimals).
The result is that the balance() will be under-reported.
This leads to receiving wrong shares when depositing tokens, and a wrong amount when redeeming tokens.
The second term IController(manager.controllers(address(this))).balanceOf() must also be normalized before adding it.
IController(manager.controllers(address(this))).balanceOf() uses _vaultDetails[msg.sender].balance which directly uses the raw token amounts which are not normalized.
GainsGoblin (yAxis) acknowledged
GalloDaSballo (judge) commented:
BobbyYaxis (yAxis) noted:
