You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
Incorrect value calculation in _getValueOfSplitFinalizedWithdrawRequest due to missing decimals conversion
Summary
If a withdraw request is split and finalized, _getValueOfSplitFinalizedWithdrawRequest will be invoked to calculate the value of the split request.
However, the function does not account for the decimals of the borrowToken, which can result in an incorrect value calculation when borrowToken is not redeemToken.
Vulnerability Detail
s.totalWithdraw represents the amount of redeemToken, so when the borrowToken is not equal to redeemToken, the decimals conversion is neccessary for calculating the correct value.
The incorrect value calculation can lead to an incorrect calculation of collateralRatio in notional VaultAcccountHealth, result in a loss of funds for the user.
function _getValueOfSplitFinalizedWithdrawRequest(
WithdrawRequest memoryw,
SplitWithdrawRequest memorys,
addressborrowToken,
addressredeemToken
) internalvirtualviewreturns (uint256) {
// If the borrow token and the withdraw token match, then there is no need to apply// an exchange rate at this point.if (borrowToken == redeemToken) {
return (s.totalWithdraw * w.vaultShares) / s.totalVaultShares;
} else {
// Otherwise, apply the proper exchange rate
(int256rate, /* */) = Deployments.TRADING_MODULE.getOraclePrice(redeemToken, borrowToken);
return (s.totalWithdraw * rate.toUint() * w.vaultShares) /
(s.totalVaultShares * Constants.EXCHANGE_RATE_PRECISION); // @audit -high missing redeemDecimals to borrowDecimals conversion
}
}
Tool used
Manual Review
Recommendation
It's recommended to add the borrowToken decimals conversion to the _getValueOfSplitFinalizedWithdrawRequest function to calculate the correct value when borrowToken is not equal to redeemToken.
sherlock-admin4
changed the title
Fantastic Gunmetal Skunk - Incorrect value calculation in _getValueOfSplitFinalizedWithdrawRequest due to missing decimals conversion
blackhole - Incorrect value calculation in _getValueOfSplitFinalizedWithdrawRequest due to missing decimals conversion
Jul 11, 2024
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
blackhole
High
Incorrect value calculation in
_getValueOfSplitFinalizedWithdrawRequest
due to missing decimals conversionSummary
If a withdraw request is split and finalized,
_getValueOfSplitFinalizedWithdrawRequest
will be invoked to calculate the value of the split request.However, the function does not account for the decimals of the
borrowToken
, which can result in an incorrect value calculation whenborrowToken
is notredeemToken
.Vulnerability Detail
s.totalWithdraw
represents the amount ofredeemToken
, so when theborrowToken
is not equal toredeemToken
, the decimals conversion is neccessary for calculating the correct value.Impact
The incorrect value calculation can lead to an incorrect calculation of collateralRatio in notional VaultAcccountHealth, result in a loss of funds for the user.
Code Snippet
https://github.com/sherlock-audit/2024-06-leveraged-vaults/blob/main/leveraged-vaults-private/contracts/vaults/common/WithdrawRequestBase.sol#L80
Tool used
Manual Review
Recommendation
It's recommended to add the borrowToken decimals conversion to the
_getValueOfSplitFinalizedWithdrawRequest
function to calculate the correct value when borrowToken is not equal to redeemToken.Duplicate of #60
The text was updated successfully, but these errors were encountered: