sherlock-audit / 2023-04-blueberry-judging

8 stars 5 forks source link

SanketKogekar - Incorrect condition in function `doCutVaultWithdrawFee()` of `FeeManager.sol` #148

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

SanketKogekar

medium

Incorrect condition in function doCutVaultWithdrawFee() of FeeManager.sol

Summary

The condition mentioned in comments Cut vault withdraw fee when perform withdraw from Blueberry Money Market within the given window does not match with condition added in IF statement.

(It's either that or comment does not mention things clearly - when the withdrawVaultFeeWindowStartTime is set, etc)

Vulnerability Detail

The protocol won't be able to collect the withdraw fee.

Impact

The protocol won't be able to collect the withdraw fee within the given window.

/// @notice Cut vault withdraw fee when perform withdraw from Blueberry Money Market within the given window
    function doCutVaultWithdrawFee(
        address token,
        uint256 amount
    ) external returns (uint256) {
        // Cut withdraw fee if it is in withdrawVaultFee Window
        if (
            block.timestamp <
            config.withdrawVaultFeeWindowStartTime() +
                config.withdrawVaultFeeWindow()
        ) {
            return _doCutFee(token, amount, config.withdrawVaultFee());
        } else {
            return amount;
        }
    }

Code Snippet

https://github.com/sherlock-audit/2023-04-blueberry/blob/main/blueberry-core/contracts/FeeManager.sol#L81

Tool used

Manual Review

Recommendation

Consider changing the condition to

/// @notice Cut vault withdraw fee when perform withdraw from Blueberry Money Market within the given window
    function doCutVaultWithdrawFee(
        address token,
        uint256 amount
    ) external returns (uint256) {
        // Cut withdraw fee if it is in withdrawVaultFee Window
        if (
            block.timestamp >
            config.withdrawVaultFeeWindowStartTime() +
                config.withdrawVaultFeeWindow()
        ) {
            return _doCutFee(token, amount, config.withdrawVaultFee());
        } else {
            return amount;
        }
    }