Submitted by ktg
The functions _currentExchangeRate and _isVaultCollateralized of Vault are implemented as follows:
The function calculates the exchange rate between the amount of assets withdrawable from the YieldVault and the amount of shares minted by this Vault.
However, if _withdrawableAssets is 0, then the function returns _assetUnit (which means 1-1 ratio). This means, that even when the vault has no withdrawable assets from _yieldVault, its still considered collateralized.
To illustrate the oddity of this special case, consider when _withdrawableAssets = 1 and _totalSupplyAmount > 0; in this scenario, _currentExchangeRate returns 0 and the vault is considered under-collateralized (since 1 < _assetUnit). However, if _withdrawableAssets = 0, the vault is considered collateralized.
This case has profound impact since a lot of vault logic is based on the vaults collateralized status.
Below is a POC for the above example. For ease of testing, lets place these 2 test cases
in file vault/test/unit/Vault/Deposit.t.sol under contract VaultDepositTest,
then test them using commands:
testOneWithdrawableAmount is to demonstrate when _withdrawableAssets = 1 and the vault is considered not collateralized.
testZeroWithdrawableAmount is to demonstrate when _withdrawableAssets = 0 and the vault is considered collateralized.
Since _withdrawableAssets is the dividend, there seems to be no harm in removing the check if _withdrawableAssets = 0. Therefore, I recommend removing it from the condition.
Invalid Validation
asselstine (PoolTogether) confirmed
Picodes (judge) decreased severity to Medium and commented:
ktg9 (warden) commented:
Picodes (judge) commented:
PierrickGT (PoolTogether) commented:
PoolTogether mitigated:
Status: Mitigation confirmed. Full details in report from dirk_y, rvierdiiev and 0xStalin.
