uint256 vaultSharesValue = (vaultSharesNotInWithdrawQueue * stakeAssetPrice * BORROW_PRECISION) / (uint256(Constants.INTERNAL_TOKEN_PRECISION) * Constants.EXCHANGE_RATE_PRECISION);
so whenever vaultSharesNotInWithdrawQueue=0 as commented the vaultSharesValue will revert because it will be a 0 division which automatically reverts in solidity
Impact
Division by zero errors will lead to DOS
Code Snippet
function convertStrategyToUnderlying(
address account,
uint256 vaultShares,
uint256 /* maturity */
) public virtual override view returns (int256 underlyingValue) {
uint256 stakeAssetPrice = uint256(getExchangeRate(0));
WithdrawRequest memory w = getWithdrawRequest(account);
uint256 withdrawValue = _calculateValueOfWithdrawRequest(
w, stakeAssetPrice, BORROW_TOKEN, REDEMPTION_TOKEN
);
//@audit
// This should always be zero if there is a withdraw request.
uint256 vaultSharesNotInWithdrawQueue = (vaultShares - w.vaultShares);
//@audit
uint256 vaultSharesValue = (vaultSharesNotInWithdrawQueue * stakeAssetPrice * BORROW_PRECISION) /
(uint256(Constants.INTERNAL_TOKEN_PRECISION) * Constants.EXCHANGE_RATE_PRECISION);
return (withdrawValue + vaultSharesValue).toInt();
}
Tool used
Manual Review
Recommendation
Implement logic to handle division by zero situations
4b
Medium
DOS in
BaseStakingVault::convertStrategyToUnderlying()
Summary
In
BaseStakingVault::convertStrategyToUnderlying()
this line can result in a division by zero which will result in solidity reverts causing DOSVulnerability Detail
In
BaseStakingVault::convertStrategyToUnderlying()
on line 80 we can read a comment which says vaultSharesNotInWithdrawQueue can be 0, going forward vaultSharesNotInWithdrawQueue is used in to calculatevaultSharesValue
like this;uint256 vaultSharesValue = (vaultSharesNotInWithdrawQueue * stakeAssetPrice * BORROW_PRECISION) / (uint256(Constants.INTERNAL_TOKEN_PRECISION) * Constants.EXCHANGE_RATE_PRECISION);
so whenevervaultSharesNotInWithdrawQueue=0
as commented thevaultSharesValue
will revert because it will be a 0 division which automatically reverts in solidityImpact
Division by zero errors will lead to DOS
Code Snippet
Tool used
Manual Review
Recommendation
Implement logic to handle division by zero situations