SetToken can't be unlocked early.
SetToken can't be unlocked early\\nThe function unlock() is used to unlock the setToken after rebalancing, as how it is right now there are two ways to unlock the setToken.\\ncan be unlocked once the rebalance duration has elapsed\\ncan be unlocked early if all targets are met, there is excess or at-target quote asset, and raiseTargetPercentage is zero\\n```\\n    function unlock(ISetToken _setToken) external {\\n        bool isRebalanceDurationElapsed = _isRebalanceDurationElapsed(_setToken);\\n        bool canUnlockEarly = _canUnlockEarly(_setToken);\\n\\n        // Ensure that either the rebalance duration has elapsed or the conditions for early unlock are met\\n        require(isRebalanceDurationElapsed || canUnlockEarly, "Cannot unlock early unless all targets are met and raiseTargetPercentage is zero");\\n\\n        // If unlocking early, update the state\\n        if (canUnlockEarly) {\\n            delete rebalanceInfo[_setToken].rebalanceDuration;\\n            emit LockedRebalanceEndedEarly(_setToken);\\n        }\\n\\n        // Unlock the SetToken\\n        _setToken.unlock();\\n    }\\n```\\n\\n```\\n    function _canUnlockEarly(ISetToken _setToken) internal view returns (bool) {\\n        RebalanceInfo storage rebalance = rebalanceInfo[_setToken];\\n        return _allTargetsMet(_setToken) && _isQuoteAssetExcessOrAtTarget(_setToken) && rebalance.raiseTargetPercentage == 0;\\n    }\\n```\\n\\nThe main problem occurs as the value of raiseTargetPercentage isn't reset after rebalancing. The other thing is that the function setRaiseTargetPercentage can't be used to fix this issue as it doesn't allow giving raiseTargetPercentage a zero value.\\nA setToken can use the AuctionModule to rebalance multiple times, duo to the fact that raiseTargetPercentage value isn't reset after every rebalancing. Once changed with the help of the function setRaiseTargetPercentage this value will only be non zero for every next rebalancing. A setToken can be unlocked early only if all other requirements are met and the raiseTargetPercentage equals zero.\\nThis problem prevents for a setToken to be unlocked early on the next rebalances, once the value of the variable raiseTargetPercentage is set to non zero.\\nOn every rebalance a manager should be able to keep the value of raiseTargetPercentage to zero (so the setToken can be unlocked early), or increase it at any time with the function setRaiseTargetPercentage.\\n```\\n    function setRaiseTargetPercentage(\\n        ISetToken _setToken,\\n        uint256 _raiseTargetPercentage\\n    )\\n        external\\n        onlyManagerAndValidSet(_setToken)\\n    {\\n        // Ensure the raise target percentage is greater than 0\\n        require(_raiseTargetPercentage > 0, "Target percentage must be greater than 0");\\n\\n        // Update the raise target percentage in the RebalanceInfo struct\\n        rebalanceInfo[_setToken].raiseTargetPercentage = _raiseTargetPercentage;\\n\\n        // Emit an event to log the updated raise target percentage\\n        emit RaiseTargetPercentageUpdated(_setToken, _raiseTargetPercentage);\\n    }\\n```\\n
Recommend to reset the value raiseTargetPercentage after every rebalancing.\\n```\\n    function unlock(ISetToken _setToken) external {\\n        bool isRebalanceDurationElapsed = _isRebalanceDurationElapsed(_setToken);\\n        bool canUnlockEarly = _canUnlockEarly(_setToken);\\n\\n        // Ensure that either the rebalance duration has elapsed or the conditions for early unlock are met\\n        require(isRebalanceDurationElapsed || canUnlockEarly, "Cannot unlock early unless all targets are met and raiseTargetPercentage is zero");\\n\\n        // If unlocking early, update the state\\n        if (canUnlockEarly) {\\n            delete rebalanceInfo[_setToken].rebalanceDuration;\\n            emit LockedRebalanceEndedEarly(_setToken);\\n        }\\n\\n+       rebalanceInfo[_setToken].raiseTargetPercentage = 0;\\n\\n        // Unlock the SetToken\\n        _setToken.unlock();\\n    }\\n```\\n
Once the value of raiseTargetPercentage is set to non zero, every next rebalancing of the setToken won't be eligible for unlocking early. As the value of raiseTargetPercentage isn't reset after every rebalance and neither the manager can set it back to zero with the function setRaiseTargetPercentage().
```\\n    function unlock(ISetToken _setToken) external {\\n        bool isRebalanceDurationElapsed = _isRebalanceDurationElapsed(_setToken);\\n        bool canUnlockEarly = _canUnlockEarly(_setToken);\\n\\n        // Ensure that either the rebalance duration has elapsed or the conditions for early unlock are met\\n        require(isRebalanceDurationElapsed || canUnlockEarly, "Cannot unlock early unless all targets are met and raiseTargetPercentage is zero");\\n\\n        // If unlocking early, update the state\\n        if (canUnlockEarly) {\\n            delete rebalanceInfo[_setToken].rebalanceDuration;\\n            emit LockedRebalanceEndedEarly(_setToken);\\n        }\\n\\n        // Unlock the SetToken\\n        _setToken.unlock();\\n    }\\n```\\n