StabilityPool's manager array can grow indefinitely, leading to gas limit issues and blocking manager removal.
There is no check when adding a new manager to the total length of the array.
function addManager(address manager, uint256 allocation) external onlyOwner {
if (managers[manager]) revert ManagerAlreadyExists();
managers[manager] = true;
managerAllocation[manager] = allocation;
totalAllocation += allocation;
managerList.push(manager);
emit ManagerAdded(manager, allocation);
}
function removeManager(address manager) external onlyOwner {
_removeManagerFromList(manager);
}
function _removeManagerFromList(address manager) private {
uint256 managerIndex = findManagerIndex(manager);
uint256 lastIndex = managerList.length - 1;
if (managerIndex != lastIndex) {
managerList[managerIndex] = managerList[lastIndex];
}
managerList.pop();
}
If the total length exceed gasLimit, it will become impossible to remove manager after.
uint256 public constant MAX_MANAGERS = 100;
function addManager(address manager, uint256 allocation) external onlyOwner {
require(managerList.length < MAX_MANAGERS, "Too many managers");
}