{
    "Function": "slitherConstructorConstantVariables",
    "File": "src/Timelock.sol",
    "Parent Contracts": [
        "lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol",
        "lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155Receiver.sol",
        "lib/openzeppelin-contracts/contracts/access/extensions/AccessControlEnumerable.sol",
        "lib/openzeppelin-contracts/contracts/access/AccessControl.sol",
        "lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol",
        "lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol",
        "lib/openzeppelin-contracts/contracts/access/extensions/IAccessControlEnumerable.sol",
        "lib/openzeppelin-contracts/contracts/access/IAccessControl.sol",
        "lib/openzeppelin-contracts/contracts/utils/Context.sol",
        "src/ConfigurablePause.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [
        "keccak256(bytes)"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract Timelock is\n    ConfigurablePause,\n    AccessControlEnumerable,\n    IERC1155Receiver,\n    IERC721Receiver\n{\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n    using BytesHelper for bytes;\n\n    /// ---------------------------------------------------------\n    /// ---------------------------------------------------------\n    /// ----------------------- IMMUTABLE -----------------------\n    /// ---------------------------------------------------------\n    /// ---------------------------------------------------------\n\n    /// @notice the safe address that governs this timelock\n    address public immutable safe;\n\n    /// @notice role for hot wallet signers that can instantly execute actions\n    /// in DeFi\n    bytes32 public constant HOT_SIGNER_ROLE = keccak256(\"HOT_SIGNER_ROLE\");\n\n    /// ---------------------------------------------------------\n    /// ---------------------------------------------------------\n    /// ------------------- STORAGE VARIABLES -------------------\n    /// ---------------------------------------------------------\n    /// ---------------------------------------------------------\n\n    /// @notice whether the contract has been initialized\n    bool public initialized;\n\n    /// @notice minimum delay for all timelock proposals\n    uint256 public minDelay;\n\n    /// @notice the period of time after which a proposal will be considered\n    /// expired if it has not been executed.\n    uint256 public expirationPeriod;\n\n    /// @notice store list of all live proposals, remove from set once executed or cancelled\n    EnumerableSet.Bytes32Set private _liveProposals;\n\n    /// @notice mapping of proposal id to execution time\n    mapping(bytes32 proposalId => uint256 executionTime) public timestamps;\n\n    /// @notice mapping of contract address to function selector to array of Index structs\n    mapping(\n        address contractAddress\n            => mapping(bytes4 selector => Index[] calldataChecks)\n    ) private _calldataList;\n\n    /// minDelay >= MIN_DELAY && minDelay <= MAX_DELAY\n\n    /// 1. proposed and not ready for execution\n    ///    - propose\n\n    ///    liveProposals adds id\n    ///    timestamps maps the time the proposal will be ready to execute\n    ///     - if you have just proposed, timestamps map should be gt 1\n    ///     if proposalId in _liveProposals => timestamps[proposalId] >= MIN_DELAY\n\n    /// 2. proposed and ready for execution\n    ///    - propose\n    ///    - wait\n\n    /// 3. proposed and executed\n    ///    - propose\n    ///    - execute\n\n    ///    liveProposals removes id\n    ///    timestamps map should be 1\n    ///     timestamps[proposalId] == 1 => id not in _liveProposals\n\n    /// 3. proposed and not executable\n    ///    - propose\n    ///    - wait too long\n    ///    - proposal cannot be executed as it has expired\n    ///    - cleanup can remove the proposalId from the enumerable set\n    ///       - the timestamp will remain in the timestamps mapping forever\n\n    /// check if lte or lt\n    ///    if timestamps[proposalId] + expirationPeriod < block.timestamp\n    ///        => not executable => id in liveProposals\n\n    /// 4. proposed and canceled\n    ///    - pause\n    ///    - cancel\n\n    ///    liveProposals removes id\n    ///    timestamps map should be 0\n\n    /// ---------------------------------------------------------\n    /// ---------------------------------------------------------\n    /// ------------------------ EVENTS -------------------------\n    /// ---------------------------------------------------------\n    /// ---------------------------------------------------------\n\n    /// @notice Emitted when a call is scheduled as part of operation `id`.\n    /// @param id unique identifier for the operation\n    /// @param index index of the call within the operation, non zero if not first call in a batch\n    /// @param target the address of the contract to call\n    /// @param value the amount of native asset to send with the call\n    /// @param data the calldata to send with the call\n    /// @param salt the salt to be used in the operation\n    /// @param delay the delay before the operation becomes valid\n    event CallScheduled(\n        bytes32 indexed id,\n        uint256 indexed index,\n        address indexed target,\n        uint256 value,\n        bytes data,\n        bytes32 salt,\n        uint256 delay\n    );\n\n    /// @notice Emitted when a call is performed as part of operation `id`.\n    /// @param id unique identifier for the operation\n    /// @param index index of the call within the operation, non zero if not first call in a batch\n    /// @param target the address of the contract called\n    /// @param value the amount of native asset sent with the call\n    /// @param data the calldata sent with the call\n    event CallExecuted(\n        bytes32 indexed id,\n        uint256 indexed index,\n        address target,\n        uint256 value,\n        bytes data\n    );\n\n    /// @notice Emitted when operation `id` is cancelled.\n    /// @param id unique identifier for the canceled operation\n    event Cancelled(bytes32 indexed id);\n\n    /// @notice Emitted when operation `id` is cleaned up.\n    /// @param id unique identifier for the cleaned operation\n    event Cleanup(bytes32 indexed id);\n\n    /// @notice Emitted when the minimum delay for future operations is modified.\n    /// @param oldDuration old minimum delay\n    /// @param newDuration new minimum delay\n    event MinDelayChange(uint256 indexed oldDuration, uint256 newDuration);\n\n    /// @notice Emitted when the expiration period is modified\n    /// @param oldPeriod old expiration period\n    /// @param newPeriod new expiration period\n    event ExpirationPeriodChange(uint256 indexed oldPeriod, uint256 newPeriod);\n\n    /// @notice Emitted when native currency is received\n    /// @param sender the address that sent the native currency\n    /// @param value the amount of native currency received\n    event NativeTokensReceived(address indexed sender, uint256 value);\n\n    /// @notice event emitted when a new calldata check is added\n    /// @param contractAddress the address of the contract that the calldata check is added to\n    /// @param selector the function selector of the function that the calldata check is added to\n    /// @param startIndex the start index of the calldata\n    /// @param endIndex the end index of the calldata\n    /// @param dataHash the hash of the calldata that is stored\n    event CalldataAdded(\n        address indexed contractAddress,\n        bytes4 indexed selector,\n        uint16 startIndex,\n        uint16 endIndex,\n        bytes32[] dataHash\n    );\n\n    /// @notice event emitted when a calldata check is removed\n    /// @param contractAddress the address of the contract that the calldata check is removed from\n    /// @param selector the function selector of the function that the calldata check is removed from\n    /// @param startIndex the start index of the calldata\n    /// @param endIndex the end index of the calldata\n    /// @param dataHash the hash of the calldata that is stored\n    event CalldataRemoved(\n        address indexed contractAddress,\n        bytes4 indexed selector,\n        uint16 startIndex,\n        uint16 endIndex,\n        bytes32[] dataHash\n    );\n\n    /// @notice struct used to store the start and end index of the calldata\n    /// and the calldata itself.\n    /// Once the calldata is stored, it can be used to check if the calldata\n    /// conforms to the expected values.\n    struct Index {\n        uint16 startIndex;\n        uint16 endIndex;\n        EnumerableSet.Bytes32Set dataHashes;\n    }\n\n    /// @notice struct used to return Index data\n    struct IndexData {\n        uint16 startIndex;\n        uint16 endIndex;\n        bytes32[] dataHashes;\n    }\n\n    /// @notice Initializes the contract with the following parameters:\n    /// @param _safe safe contract that owns this timelock\n    /// @param _minDelay initial minimum delay for operations\n    /// @param _expirationPeriod timelocked actions expiration period\n    /// @param _pauser address that can pause the contract\n    /// @param _pauseDuration duration the contract can be paused for\n    /// @param hotSigners accounts that can execute whitelisted calldata\n    constructor(\n        address _safe,\n        uint256 _minDelay,\n        uint256 _expirationPeriod,\n        address _pauser,\n        uint128 _pauseDuration,\n        address[] memory hotSigners\n    ) {\n        safe = _safe;\n\n        require(\n            _minDelay >= MIN_DELAY && _minDelay <= MAX_DELAY,\n            \"Timelock: delay out of bounds\"\n        );\n\n        minDelay = _minDelay;\n        emit MinDelayChange(0, minDelay);\n\n        require(\n            _expirationPeriod >= MIN_DELAY,\n            \"Timelock: expiration period too short\"\n        );\n        expirationPeriod = _expirationPeriod;\n        emit ExpirationPeriodChange(0, _expirationPeriod);\n\n        _grantGuardian(_pauser);\n        _updatePauseDuration(_pauseDuration);\n\n        /// grant the timelock the default admin role so that it can manage the\n        /// hot signer role\n        _grantRole(DEFAULT_ADMIN_ROLE, address(this));\n\n        /// set the admin of the hot signer role to the default admin role\n        _setRoleAdmin(HOT_SIGNER_ROLE, DEFAULT_ADMIN_ROLE);\n\n        for (uint256 i = 0; i < hotSigners.length; i++) {\n            _grantRole(HOT_SIGNER_ROLE, hotSigners[i]);\n        }\n    }\n\n    /// @param contractAddresses the address of the contract that the calldata check is added to\n    /// @param selectors the function selector of the function that the calldata check is added to\n    /// @param startIndexes the start indexes of the calldata\n    /// @param endIndexes the end indexes of the calldata\n    /// @param datas the calldata that is stored\n    function initialize(\n        address[] memory contractAddresses,\n        bytes4[] memory selectors,\n        uint16[] memory startIndexes,\n        uint16[] memory endIndexes,\n        bytes[][] memory datas\n    ) external {\n        require(!initialized, \"Timelock: already initialized\");\n        initialized = true;\n\n        _addCalldataChecks(\n            contractAddresses, selectors, startIndexes, endIndexes, datas\n        );\n    }\n\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n    /// -------------------------- Modifiers --------------------------\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n\n    /// @notice allows only the safe to call the function\n    modifier onlySafe() {\n        require(msg.sender == safe, \"Timelock: caller is not the safe\");\n        _;\n    }\n\n    /// @notice allows timelocked actions to make certain parameter changes\n    modifier onlyTimelock() {\n        require(\n            msg.sender == address(this), \"Timelock: caller is not the timelock\"\n        );\n        _;\n    }\n\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n    /// --------------------- View Only Functions ---------------------\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n\n    /// @notice returns all currently non cancelled and non-executed proposals\n    /// some proposals may not be able to be executed if they have passed the\n    /// expiration period\n    function getAllProposals() external view returns (bytes32[] memory) {\n        return _liveProposals.values();\n    }\n\n    /// @notice returns the proposal id at the specified index in the set\n    function atIndex(uint256 index) external view returns (bytes32) {\n        return _liveProposals.at(index);\n    }\n\n    /// @notice returns the current position of the proposal in the live\n    /// proposals set\n    function positionOf(bytes32 value) external view returns (uint256) {\n        return _liveProposals._inner._positions[value];\n    }\n\n    /// @dev See {IERC165-supportsInterface}.\n    /// @notice supports 1155 and 721 receiver\n    /// also supports ERC165 interface id\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        override(IERC165, AccessControlEnumerable)\n        returns (bool)\n    {\n        return interfaceId == type(IERC1155Receiver).interfaceId\n            || interfaceId == type(IERC721Receiver).interfaceId\n            || super.supportsInterface(interfaceId);\n    }\n\n    /// @dev Returns whether an id corresponds to a registered operation. This\n    /// includes Pending, Ready, Done and Expired operations.\n    /// Cancelled operations will return false.\n    function isOperation(bytes32 id) public view returns (bool) {\n        return timestamps[id] > 0;\n    }\n\n    /// @dev Returns whether an operation is ready for execution.\n    /// Note that a \"ready\" operation is also \"pending\".\n    /// cannot be executed after the expiry period.\n    function isOperationReady(bytes32 id) public view returns (bool) {\n        /// cache timestamp, save up to 2 extra SLOADs\n        uint256 timestamp = timestamps[id];\n        return timestamp > _DONE_TIMESTAMP && timestamp <= block.timestamp\n            && timestamp + expirationPeriod > block.timestamp;\n    }\n\n    /// @dev Returns whether an operation is done or not.\n    function isOperationDone(bytes32 id) public view returns (bool) {\n        return timestamps[id] == _DONE_TIMESTAMP;\n    }\n\n    /// @dev Returns whether an operation is expired\n    /// @notice operations expire on their expiry timestamp, not after\n    function isOperationExpired(bytes32 id) public view returns (bool) {\n        /// if operation is done, save an extra SLOAD\n        uint256 timestamp = timestamps[id];\n\n        /// if timestamp is 0, the operation is not scheduled, revert\n        require(timestamp != 0, \"Timelock: operation non-existent\");\n        require(timestamp != 1, \"Timelock: operation already executed\");\n\n        return block.timestamp >= timestamp + expirationPeriod;\n    }\n\n    /// @dev Returns the identifier of an operation containing a single transaction.\n    /// @param target the address of the contract to call\n    /// @param value the value in native tokens to send in the call\n    /// @param data the calldata to send in the call\n    /// @param salt the salt to be used in the operation\n    function hashOperation(\n        address target,\n        uint256 value,\n        bytes calldata data,\n        bytes32 salt\n    ) public pure returns (bytes32) {\n        return keccak256(abi.encode(target, value, data, salt));\n    }\n\n    /// @dev Returns the identifier of an operation containing a batch of transactions.\n    /// @param targets the addresses of the contracts to call\n    /// @param values the values to send in the calls\n    /// @param payloads the calldatas to send in the calls\n    /// @param salt the salt to be used in the operation\n    function hashOperationBatch(\n        address[] calldata targets,\n        uint256[] calldata values,\n        bytes[] calldata payloads,\n        bytes32 salt\n    ) public pure returns (bytes32) {\n        return keccak256(abi.encode(targets, values, payloads, salt));\n    }\n\n    /// @notice get the calldata checks for a specific contract and function selector\n    function getCalldataChecks(address contractAddress, bytes4 selector)\n        public\n        view\n        returns (IndexData[] memory indexDatas)\n    {\n        Index[] storage indexes = _calldataList[contractAddress][selector];\n\n        indexDatas = new IndexData[](indexes.length);\n        for (uint256 i = 0; i < indexes.length; i++) {\n            indexDatas[i] = IndexData(\n                indexes[i].startIndex,\n                indexes[i].endIndex,\n                indexes[i].dataHashes.values()\n            );\n        }\n    }\n\n    /// @notice check if the calldata conforms to the expected values\n    /// extracts indexes and checks that the data within the indexes\n    /// matches the expected data\n    /// @param contractAddress the address of the contract that the calldata check is applied to\n    /// @param data the calldata to check\n    function checkCalldata(address contractAddress, bytes memory data)\n        public\n        view\n    {\n        bytes4 selector = data.getFunctionSignature();\n\n        Index[] storage calldataChecks =\n            _calldataList[contractAddress][selector];\n\n        require(\n            calldataChecks.length > 0, \"CalldataList: No calldata checks found\"\n        );\n\n        for (uint256 i = 0; i < calldataChecks.length; i++) {\n            Index storage calldataCheck = calldataChecks[i];\n\n            if (calldataCheck.startIndex == calldataCheck.endIndex) {\n                return;\n            }\n\n            require(\n                calldataCheck.dataHashes.contains(\n                    data.getSlicedBytesHash(\n                        calldataCheck.startIndex, calldataCheck.endIndex\n                    )\n                ),\n                \"CalldataList: Calldata does not match expected value\"\n            );\n        }\n    }\n\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n    /// -------------------- Timelock Functions -----------------------\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n\n    /// @dev Schedule an operation containing a single transaction.\n    /// Emits {CallSalt} if salt is nonzero, and {CallScheduled}.\n    /// the caller must be the safe.\n    /// Callable only by the safe and when the contract is not paused\n    /// @param target to call\n    /// @param value amount of native token to spend\n    /// @param data calldata to send target\n    /// @param salt to be used in the operation\n    /// @param delay the delay before the operation becomes valid\n    function schedule(\n        address target,\n        uint256 value,\n        bytes calldata data,\n        bytes32 salt,\n        uint256 delay\n    ) external onlySafe whenNotPaused {\n        bytes32 id = hashOperation(target, value, data, salt);\n\n        /// this is technically a duplicate check as _schedule makes the same\n        /// check again\n        require(_liveProposals.add(id), \"Timelock: duplicate id\");\n\n        /// SSTORE timestamps[id] = block.timestamp + delay\n        /// check delay >= minDelay\n        _schedule(id, delay);\n\n        emit CallScheduled(id, 0, target, value, data, salt, delay);\n    }\n\n    /// @dev Schedule an operation containing a batch of transactions.\n    /// Emits {CallSalt} if salt is nonzero, and one {CallScheduled} event per\n    /// transaction in the batch.\n    /// Callable only by the safe and when the contract is not paused\n    /// @param targets the addresses of the contracts to call\n    /// @param values the values to send in the calls\n    /// @param payloads the calldata to send in the calls\n    /// @param salt the salt to be used in the operation\n    /// @param delay the delay before the operation becomes valid\n    function scheduleBatch(\n        address[] calldata targets,\n        uint256[] calldata values,\n        bytes[] calldata payloads,\n        bytes32 salt,\n        uint256 delay\n    ) external onlySafe whenNotPaused {\n        require(\n            targets.length == values.length && targets.length == payloads.length,\n            \"Timelock: length mismatch\"\n        );\n\n        bytes32 id = hashOperationBatch(targets, values, payloads, salt);\n\n        /// this is technically a duplicate check as _schedule makes the same\n        /// check again\n        require(_liveProposals.add(id), \"Timelock: duplicate id\");\n\n        /// SSTORE timestamps[id] = block.timestamp + delay\n        /// check delay >= minDelay\n        _schedule(id, delay);\n\n        for (uint256 i = 0; i < targets.length; i++) {\n            emit CallScheduled(\n                id, i, targets[i], values[i], payloads[i], salt, delay\n            );\n        }\n    }\n\n    /// @dev Execute a ready operation containing a single transaction.\n    /// cannot execute the operation if it has expired.\n    /// This function can reenter, but it doesn't pose a risk because\n    /// _afterCall checks that the proposal is pending, thus any modifications\n    /// to the operation during reentrancy should be caught.\n    /// slither-disable-next-line reentrancy-eth\n    /// @param target the address of the contract to call\n    /// @param value the value in native tokens to send in the call\n    /// @param payload the calldata to send in the call\n    /// @param salt the salt to be used in the operation of creating the ID.\n    function execute(\n        address target,\n        uint256 value,\n        bytes calldata payload,\n        bytes32 salt\n    ) external payable whenNotPaused {\n        bytes32 id = hashOperation(target, value, payload, salt);\n\n        /// first reentrancy check, impossible to reenter and execute the same\n        /// proposal twice\n        require(_liveProposals.remove(id), \"Timelock: proposal does not exist\");\n        require(isOperationReady(id), \"Timelock: operation is not ready\");\n\n        _execute(target, value, payload);\n        emit CallExecuted(id, 0, target, value, payload);\n\n        /// second reentrancy check, second check that operation is ready,\n        /// operation will be not ready if already executed as timestamp will\n        /// be set to 1\n        _afterCall(id);\n    }\n\n    /// @dev Execute an (ready) operation containing a batch of transactions.\n    /// Requirements:\n    ///  - the operation has not expired.\n    /// This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending,\n    /// thus any modifications to the operation during reentrancy should be caught.\n    /// slither-disable-next-line reentrancy-eth\n    /// @param targets the addresses of the contracts to call\n    /// @param values the values to send in the calls\n    /// @param payloads the calldata to send in the calls\n    /// @param salt the salt to be used in the operation\n    function executeBatch(\n        address[] calldata targets,\n        uint256[] calldata values,\n        bytes[] calldata payloads,\n        bytes32 salt\n    ) external payable whenNotPaused {\n        require(\n            targets.length == values.length && targets.length == payloads.length,\n            \"Timelock: length mismatch\"\n        );\n\n        bytes32 id = hashOperationBatch(targets, values, payloads, salt);\n\n        /// first reentrancy check, impossible to reenter and execute the same\n        /// proposal twice\n        require(_liveProposals.remove(id), \"Timelock: proposal does not exist\");\n        require(isOperationReady(id), \"Timelock: operation is not ready\");\n\n        for (uint256 i = 0; i < targets.length; i++) {\n            bytes calldata payload = payloads[i];\n\n            _execute(targets[i], values[i], payload);\n            emit CallExecuted(id, i, targets[i], values[i], payload);\n        }\n\n        /// second reentrancy check, second check that operation is ready,\n        /// operation will be not ready if already executed as timestamp will\n        /// be set to 1\n        _afterCall(id);\n    }\n\n    /// @notice cancel a timelocked operation\n    /// cannot cancel an already executed operation.\n    /// not callable while paused, because while paused there should not be any\n    /// proposals in the _liveProposal set.\n    /// @param id the identifier of the operation to cancel\n    function cancel(bytes32 id) external onlySafe whenNotPaused {\n        require(\n            isOperation(id) && _liveProposals.remove(id),\n            \"Timelock: operation does not exist\"\n        );\n\n        delete timestamps[id];\n        emit Cancelled(id);\n    }\n\n    /// @notice clean up an expired timelock action\n    /// not callable while paused, because while paused there should not be any\n    /// proposals in the _liveProposal set.\n    /// @param id the identifier of the expired operation\n    function cleanup(bytes32 id) external whenNotPaused {\n        require(isOperationExpired(id), \"Timelock: operation not expired\");\n        /// unreachable state assert statement\n        assert(_liveProposals.remove(id));\n\n        emit Cleanup(id);\n    }\n\n    /// ----------------------------------------------------------\n    /// ----------------------------------------------------------\n    /// ----------------- GUARDIAN ONLY FUNCTION -----------------\n    /// ----------------------------------------------------------\n    /// ----------------------------------------------------------\n\n    /// @notice cancel all outstanding pending and non executed operations\n    /// pauses the contract, revokes the guardian\n    function pause() public override {\n        /// check that msg.sender is the pause guardian, pause the contract\n        super.pause();\n\n        bytes32[] memory proposals = _liveProposals.values();\n        for (uint256 i = 0; i < proposals.length; i++) {\n            bytes32 id = proposals[i];\n\n            delete timestamps[id];\n            assert(_liveProposals.remove(id));\n\n            emit Cancelled(id);\n        }\n    }\n\n    /// ----------------------------------------------------------\n    /// ----------------------------------------------------------\n    /// ------------------ HOT SIGNER FUNCTIONS ------------------\n    /// ----------------------------------------------------------\n    /// ----------------------------------------------------------\n\n    /// @notice any hot signer can call this function and execute\n    /// a call to whitelisted contracts with whitelisted calldatas\n    /// no reentrancy checks needed here as the hot signers can execute this\n    /// whitelisted calldata as many times as they want\n    /// @param target the addresses of the contracts to call\n    /// @param value the values to send in the calls\n    /// @param payload the calldata to send in the calls\n    function executeWhitelisted(\n        address target,\n        uint256 value,\n        bytes calldata payload\n    ) external payable onlyRole(HOT_SIGNER_ROLE) whenNotPaused {\n        /// first ensure calldata to target is whitelisted,\n        /// and that parameters are not malicious\n        checkCalldata(target, payload);\n        _execute(target, value, payload);\n\n        emit CallExecuted(bytes32(0), 0, target, value, payload);\n    }\n\n    /// @notice any safe owner can call this function and execute calls\n    /// to whitelisted contracts with whitelisted calldatas\n    /// @param targets the addresses of the contracts to call\n    /// @param values the values to send in the calls\n    /// @param payloads the calldata to send in the calls\n    function executeWhitelistedBatch(\n        address[] calldata targets,\n        uint256[] calldata values,\n        bytes[] calldata payloads\n    ) external payable onlyRole(HOT_SIGNER_ROLE) whenNotPaused {\n        require(\n            targets.length == values.length && targets.length == payloads.length,\n            \"Timelock: length mismatch\"\n        );\n\n        for (uint256 i = 0; i < targets.length; i++) {\n            address target = targets[i];\n            uint256 value = values[i];\n            bytes calldata payload = payloads[i];\n\n            /// first ensure calldata to target is whitelisted,\n            /// and that parameters are not malicious\n            checkCalldata(target, payload);\n            _execute(target, value, payload);\n\n            emit CallExecuted(bytes32(0), i, target, value, payload);\n        }\n    }\n\n    /// Access Control Enumerable Overrides\n\n    /// @notice function to grant a role to an address\n    /// callable only by the timelock as timelock is the only role with admin\n    /// @param role the role to grant\n    /// @param account to grant the role to\n    function grantRole(bytes32 role, address account)\n        public\n        override(AccessControl, IAccessControl)\n    {\n        require(role != DEFAULT_ADMIN_ROLE, \"Timelock: cannot grant admin role\");\n        super.grantRole(role, account);\n    }\n\n    /// @notice function to revoke a role from an address\n    /// @param role the role to revoke\n    /// @param account the address to revoke the role from\n    function revokeRole(bytes32 role, address account)\n        public\n        override(AccessControl, IAccessControl)\n    {\n        require(\n            role != DEFAULT_ADMIN_ROLE, \"Timelock: cannot revoke admin role\"\n        );\n        super.revokeRole(role, account);\n    }\n\n    /// @notice function to renounce a role\n    /// @param role the role to renounce\n    /// @param account the address to renounce the role from\n    function renounceRole(bytes32 role, address account)\n        public\n        override(AccessControl, IAccessControl)\n    {\n        require(\n            role != DEFAULT_ADMIN_ROLE, \"Timelock: cannot renounce admin role\"\n        );\n        super.renounceRole(role, account);\n    }\n\n    /// Hot Signer Access Control Management Functions\n\n    /// @notice function to revoke the hot signer role from an address\n    /// can only be called by the timelock or the safe\n    /// @param deprecatedHotSigner the address of the hot signer to revoke\n    function revokeHotSigner(address deprecatedHotSigner) external onlySafe {\n        _revokeRole(HOT_SIGNER_ROLE, deprecatedHotSigner);\n    }\n\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n    /// ------------------- Timelock Only Functions -------------------\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n\n    /// @notice function to grant the guardian to a new address\n    /// resets the pauseStartTime to 0, which unpauses the contract\n    /// @param newGuardian the address of the new guardian\n    function setGuardian(address newGuardian) public onlyTimelock {\n        /// if a new guardian is granted, the contract is automatically unpaused\n        _setPauseTime(0);\n\n        _grantGuardian(newGuardian);\n    }\n\n    /// @notice add multiple calldata checks\n    /// @param contractAddresses the addresses of the contract that the calldata check is added to\n    /// @param selectors the function selectors of the function that the calldata check is added to\n    /// @param startIndexes the start indexes of the calldata\n    /// @param endIndexes the end indexes of the calldata\n    /// @param datas the calldatas that are checked for each corresponding function at each index\n    /// on each contract\n    function addCalldataChecks(\n        address[] memory contractAddresses,\n        bytes4[] memory selectors,\n        uint16[] memory startIndexes,\n        uint16[] memory endIndexes,\n        bytes[][] memory datas\n    ) external onlyTimelock {\n        _addCalldataChecks(\n            contractAddresses, selectors, startIndexes, endIndexes, datas\n        );\n    }\n\n    /// @notice add a single calldata check\n    /// @param contractAddress the address of the contract that the calldata check is added to\n    /// @param selector the function selector of the function that the calldata check is added to\n    /// @param startIndex the start indexes of the calldata\n    /// @param endIndex the end indexes of the calldata\n    /// @param data the calldata that is stored\n    function addCalldataCheck(\n        address contractAddress,\n        bytes4 selector,\n        uint16 startIndex,\n        uint16 endIndex,\n        bytes[] memory data\n    ) external onlyTimelock {\n        _addCalldataCheck(contractAddress, selector, startIndex, endIndex, data);\n    }\n\n    /// @notice remove a single calldata check for a given contract address\n    /// @param contractAddress the address of the contract that the\n    /// calldata checks are removed from\n    /// @param selector the function selector of the function that the\n    /// checks will be removed from\n    /// @param index the index of the calldata check to remove\n    function removeCalldataCheck(\n        address contractAddress,\n        bytes4 selector,\n        uint256 index\n    ) external onlyTimelock {\n        _removeCalldataCheck(contractAddress, selector, index);\n    }\n\n    /// @notice remove a calldata check by index\n    /// @param contractAddress the address of the contract that the calldata check is removed from\n    /// @param selector the function selector of the function that the calldata check is removed from\n    /// @param index the index of the calldata check to remove\n    /// @param dataHash the hash of the calldata that is stored\n    function removeCalldataCheckDatahash(\n        address contractAddress,\n        bytes4 selector,\n        uint256 index,\n        bytes32 dataHash\n    ) external onlyTimelock {\n        Index[] storage calldataChecks =\n            _calldataList[contractAddress][selector];\n        /// if no calldata checks are found, this check will fail because\n        /// calldataChecks.length will be 0, and no uint value can be lt 0\n        require(\n            index < calldataChecks.length,\n            \"CalldataList: Calldata index out of bounds\"\n        );\n\n        /// index check to remove the datahash from\n        Index storage indexCheck = calldataChecks[index];\n\n        uint16 removedStartIndex = indexCheck.startIndex;\n        uint16 removedEndIndex = indexCheck.endIndex;\n\n        /// require instead of assert to have clear error messages\n        require(\n            indexCheck.dataHashes.remove(dataHash),\n            \"CalldataList: DataHash does not exist\"\n        );\n\n        /// remove the index check if the dataHashes are empty\n        if (indexCheck.dataHashes.length() == 0) {\n            /// index check to overwrite the specified index check with\n            Index storage lastIndexCheck =\n                calldataChecks[calldataChecks.length - 1];\n\n            indexCheck.startIndex = lastIndexCheck.startIndex;\n            indexCheck.endIndex = lastIndexCheck.endIndex;\n            bytes32[] memory dataHashes = lastIndexCheck.dataHashes.values();\n\n            for (uint256 i = 0; i < dataHashes.length; i++) {\n                assert(indexCheck.dataHashes.add(dataHashes[i]));\n                assert(lastIndexCheck.dataHashes.remove(dataHashes[i]));\n            }\n\n            /// remove the last index check for the specified function\n            calldataChecks.pop();\n        }\n\n        {\n            bytes32[] memory dataHashes = new bytes32[](1);\n            dataHashes[0] = dataHash;\n\n            emit CalldataRemoved(\n                contractAddress,\n                selector,\n                removedStartIndex,\n                removedEndIndex,\n                dataHashes\n            );\n        }\n    }\n\n    /// @notice remove all calldata checks for a given contract address\n    /// @param contractAddresses the address of the contract that the\n    /// calldata checks are removed from\n    /// @param selectors the selectors of the functions that the checks will\n    /// be removed from\n    function removeAllCalldataChecks(\n        address[] memory contractAddresses,\n        bytes4[] memory selectors\n    ) external onlyTimelock {\n        require(\n            contractAddresses.length == selectors.length,\n            \"Timelock: arity mismatch\"\n        );\n        for (uint256 i = 0; i < contractAddresses.length; i++) {\n            _removeAllCalldataChecks(contractAddresses[i], selectors[i]);\n        }\n    }\n\n    /// @dev Changes the minimum timelock duration for future operations.\n    /// Emits a {MinDelayChange} event.\n    /// Requirements:\n    /// - the caller must be the timelock itself. This can only be achieved by scheduling and later executing\n    /// an operation where the timelock is the target and the data is the ABI-encoded call to this function.\n    /// @param newDelay the new minimum delay\n    function updateDelay(uint256 newDelay) external onlyTimelock {\n        require(\n            newDelay >= MIN_DELAY && newDelay <= MAX_DELAY,\n            \"Timelock: delay out of bounds\"\n        );\n\n        emit MinDelayChange(minDelay, newDelay);\n        minDelay = newDelay;\n    }\n\n    /// @notice update the expiration period for timelocked actions\n    /// @param newPeriod the new expiration period\n    function updateExpirationPeriod(uint256 newPeriod) external onlyTimelock {\n        require(newPeriod >= MIN_DELAY, \"Timelock: delay out of bounds\");\n\n        emit ExpirationPeriodChange(expirationPeriod, newPeriod);\n        expirationPeriod = newPeriod;\n    }\n\n    /// @notice update the pause period for timelocked actions\n    /// @dev can only be between 1 day and 30 days\n    /// @param newPauseDuration the new pause duartion\n    function updatePauseDuration(uint128 newPauseDuration)\n        external\n        onlyTimelock\n    {\n        /// min and max checks are done in the internal function\n        _updatePauseDuration(newPauseDuration);\n    }\n\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n    /// ------------------ Private Helper Functions -------------------\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n\n    /// @dev Schedule an operation that is to become valid after a given delay.\n    /// @param id the identifier of the operation\n    /// @param delay the delay before the operation becomes valid\n    function _schedule(bytes32 id, uint256 delay) private {\n        /// this line is never reachable as no duplicate id's are enforced before this call is made\n        require(!isOperation(id), \"Timelock: operation already scheduled\");\n        /// this line is reachable\n        require(delay >= minDelay, \"Timelock: insufficient delay\");\n        timestamps[id] = block.timestamp + delay;\n    }\n\n    /// @dev Checks after execution of an operation's calls.\n    /// @param id the identifier of the operation\n    function _afterCall(bytes32 id) private {\n        /// unreachable state because removing the proposal id from the\n        /// _liveProposals set prevents this function from being called on the\n        /// same id twice\n        require(isOperationReady(id), \"Timelock: operation is not ready\");\n        timestamps[id] = _DONE_TIMESTAMP;\n    }\n\n    /// @dev Execute an operation's call.\n    /// @param target the address of the contract to call\n    /// @param value the value in native tokens to send in the call\n    /// @param data the calldata to send in the call\n    function _execute(address target, uint256 value, bytes calldata data)\n        private\n    {\n        (bool success,) = target.call{value: value}(data);\n        require(success, \"Timelock: underlying transaction reverted\");\n    }\n\n    /// @notice add a calldata check\n    /// @param contractAddress the address of the contract that the calldata check is added to\n    /// @param selector the function selector of the function that the calldata check is added to\n    /// @param startIndex the start index of the calldata\n    /// @param endIndex the end index of the calldata\n    /// @param data the calldata that is stored\n    function _addCalldataCheck(\n        address contractAddress,\n        bytes4 selector,\n        uint16 startIndex,\n        uint16 endIndex,\n        bytes[] memory data\n    ) private {\n        require(\n            contractAddress != address(0),\n            \"CalldataList: Address cannot be zero\"\n        );\n        require(selector != bytes4(0), \"CalldataList: Selector cannot be empty\");\n        require(\n            startIndex >= 4, \"CalldataList: Start index must be greater than 3\"\n        );\n\n        /// prevent misconfiguration where a hot signer could change timelock\n        /// or safe parameters\n        require(\n            contractAddress != address(this),\n            \"CalldataList: Address cannot be this\"\n        );\n        require(contractAddress != safe, \"CalldataList: Address cannot be safe\");\n\n        Index[] storage calldataChecks =\n            _calldataList[contractAddress][selector];\n        uint256 listLength = calldataChecks.length;\n\n        if (listLength == 1) {\n            require(\n                calldataChecks[0].startIndex != calldataChecks[0].endIndex,\n                \"CalldataList: Cannot add check with wildcard\"\n            );\n        }\n\n        if (startIndex == endIndex) {\n            require(\n                startIndex == 4,\n                \"CalldataList: End index equals start index only when 4\"\n            );\n            require(\n                listLength == 0,\n                \"CalldataList: Add wildcard only if no existing check\"\n            );\n            require(data.length == 0, \"CalldataList: Data must be empty\");\n        } else {\n            require(\n                endIndex > startIndex,\n                \"CalldataList: End index must be greater than start index\"\n            );\n            /// if we are adding a concrete check and not a wildcard, then the\n            /// calldata must not be empty\n            require(data.length != 0, \"CalldataList: Data empty\");\n        }\n\n        Index[] storage indexes = _calldataList[contractAddress][selector];\n        uint256 targetIndex = indexes.length;\n        {\n            bool found;\n            for (uint256 i = 0; i < indexes.length; i++) {\n                if (\n                    indexes[i].startIndex == startIndex\n                        && indexes[i].endIndex == endIndex\n                ) {\n                    targetIndex = i;\n                    found = true;\n                    break;\n                }\n                /// all calldata checks must be isolated to predefined calldata segments\n                /// for example given calldata with three parameters:\n\n                ///                    1.                              2.                             3.\n                ///       000000000000000112818929111111\n                ///                                     000000000000000112818929111111\n                ///                                                                   000000000000000112818929111111\n\n                /// checks must be applied in a way such that they do not overlap with each other.\n                /// having checks that check 1 and 2 together as a single parameter would be valid,\n                /// but having checks that check 1 and 2 together, and then check one separately\n                /// would be invalid.\n                /// checking 1, 2, and 3 separately is valid\n                /// checking 1, 2, and 3 as a single check is valid\n                /// checking 1, 2, and 3 separately, and then the last half of 2 and the first half\n                /// of 3 is invalid\n\n                require(\n                    startIndex > indexes[i].endIndex\n                        || endIndex < indexes[i].startIndex,\n                    \"CalldataList: Partial check overlap\"\n                );\n            }\n\n            if (!found) {\n                indexes.push();\n                indexes[targetIndex].startIndex = startIndex;\n                indexes[targetIndex].endIndex = endIndex;\n            }\n        }\n\n        for (uint256 i = 0; i < data.length; i++) {\n            /// data length must equal delta index\n            require(\n                data[i].length == endIndex - startIndex,\n                \"CalldataList: Data length mismatch\"\n            );\n            bytes32 dataHash = keccak256(data[i]);\n\n            /// make require instead of assert to have clear error messages\n            require(\n                indexes[targetIndex].dataHashes.add(dataHash),\n                \"CalldataList: Duplicate data\"\n            );\n        }\n\n        emit CalldataAdded(\n            contractAddress,\n            selector,\n            startIndex,\n            endIndex,\n            indexes[targetIndex].dataHashes.values()\n        );\n    }\n\n    /// @notice add a calldata check\n    /// @param contractAddresses the address of the contract that the calldata check is added to\n    /// @param selectors the function selector of the function that the calldata check is added to\n    /// @param startIndexes the start indexes of the calldata\n    /// @param endIndexes the end indexes of the calldata\n    /// @param datas the calldata that is stored\n    function _addCalldataChecks(\n        address[] memory contractAddresses,\n        bytes4[] memory selectors,\n        uint16[] memory startIndexes,\n        uint16[] memory endIndexes,\n        bytes[][] memory datas\n    ) private {\n        require(\n            contractAddresses.length == selectors.length\n                && selectors.length == startIndexes.length\n                && startIndexes.length == endIndexes.length\n                && endIndexes.length == datas.length,\n            \"CalldataList: Array lengths must be equal\"\n        );\n\n        for (uint256 i = 0; i < contractAddresses.length; i++) {\n            _addCalldataCheck(\n                contractAddresses[i],\n                selectors[i],\n                startIndexes[i],\n                endIndexes[i],\n                datas[i]\n            );\n        }\n    }\n\n    /// @notice remove a calldata check by index\n    /// @param contractAddress the address of the contract that the calldata check is removed from\n    /// @param selector the function selector of the function that the calldata check is removed from\n    /// @param index the index of the calldata check to remove\n    function _removeCalldataCheck(\n        address contractAddress,\n        bytes4 selector,\n        uint256 index\n    ) private {\n        Index[] storage calldataChecks =\n            _calldataList[contractAddress][selector];\n        /// if no calldata checks are found, this check will fail because\n        /// calldataChecks.length will be 0, and no uint value can be lt 0\n        require(\n            index < calldataChecks.length,\n            \"CalldataList: Calldata index out of bounds\"\n        );\n\n        /// index check to remove by overwriting with ending list element\n        Index storage indexCheck = calldataChecks[index];\n\n        uint16 removedStartIndex = indexCheck.startIndex;\n        uint16 removedEndIndex = indexCheck.endIndex;\n        bytes32[] memory removedDataHashes = indexCheck.dataHashes.values();\n\n        for (uint256 i = 0; i < removedDataHashes.length; i++) {\n            assert(indexCheck.dataHashes.remove(removedDataHashes[i]));\n        }\n\n        /// pop the index without swap if index is same as last index\n        if (calldataChecks.length > 1) {\n            /// index check to overwrite the specified index check with\n            Index storage lastIndexCheck =\n                calldataChecks[calldataChecks.length - 1];\n\n            indexCheck.startIndex = lastIndexCheck.startIndex;\n            indexCheck.endIndex = lastIndexCheck.endIndex;\n            bytes32[] memory dataHashes = lastIndexCheck.dataHashes.values();\n\n            for (uint256 i = 0; i < dataHashes.length; i++) {\n                assert(indexCheck.dataHashes.add(dataHashes[i]));\n                assert(lastIndexCheck.dataHashes.remove(dataHashes[i]));\n            }\n        }\n\n        calldataChecks.pop();\n\n        emit CalldataRemoved(\n            contractAddress,\n            selector,\n            removedStartIndex,\n            removedEndIndex,\n            removedDataHashes\n        );\n    }\n\n    /// @notice remove all calldata checks for a given contract and selector\n    /// iterates over all checks for the given contract and selector and removes\n    /// them from the array.\n    /// @param contractAddress the address of the contract that the calldata\n    /// checks are removed from\n    /// @param selector the function selector of the function that the calldata\n    /// checks are removed from\n    function _removeAllCalldataChecks(address contractAddress, bytes4 selector)\n        private\n    {\n        Index[] storage calldataChecks =\n            _calldataList[contractAddress][selector];\n\n        uint256 checksLength = calldataChecks.length;\n\n        require(checksLength > 0, \"CalldataList: No calldata checks to remove\");\n\n        /// delete all calldata in the list for the given contract and selector\n        while (checksLength != 0) {\n            Index storage removedCalldataCheck =\n                calldataChecks[checksLength - 1];\n\n            bytes32[] memory dataHashes =\n                removedCalldataCheck.dataHashes.values();\n\n            emit CalldataRemoved(\n                contractAddress,\n                selector,\n                removedCalldataCheck.startIndex,\n                removedCalldataCheck.endIndex,\n                dataHashes\n            );\n            for (uint256 i = 0; i < dataHashes.length; i++) {\n                assert(removedCalldataCheck.dataHashes.remove(dataHashes[i]));\n            }\n            calldataChecks.pop();\n            checksLength--;\n        }\n\n        /// delete the calldata list for the given contract and selector\n        delete _calldataList[contractAddress][selector];\n    }\n\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n    /// ----------------- 721 and 1155 Compatability ------------------\n    /// ---------------------------------------------------------------\n    /// ---------------------------------------------------------------\n\n    /// @dev See {IERC721Receiver-onERC721Received}.\n    function onERC721Received(address, address, uint256, bytes memory)\n        external\n        pure\n        override\n        returns (bytes4)\n    {\n        return this.onERC721Received.selector;\n    }\n\n    /// @dev See {IERC1155Receiver-onERC1155Received}.\n    function onERC1155Received(address, address, uint256, uint256, bytes memory)\n        external\n        pure\n        override\n        returns (bytes4)\n    {\n        return this.onERC1155Received.selector;\n    }\n\n    /// @dev See {IERC1155Receiver-onERC1155BatchReceived}.\n    function onERC1155BatchReceived(\n        address,\n        address,\n        uint256[] memory,\n        uint256[] memory,\n        bytes memory\n    ) external pure override returns (bytes4) {\n        return this.onERC1155BatchReceived.selector;\n    }\n\n    /// code snippet from https://github.com/safe-global/safe-smart-account/blob/main/contracts/handler/TokenCallbackHandler.sol\n\n    /// @notice Handles ERC777 Token callback.\n    /// return nothing (not standardized)\n    /// We implement this for completeness, doesn't have any value\n    function tokensReceived(\n        address,\n        address,\n        address,\n        uint256,\n        bytes calldata,\n        bytes calldata\n    ) external pure {}\n\n    /// @dev Timelock can receive/hold ETH, emit an event when this happens for\n    /// offchain tracking\n    receive() external payable {\n        emit NativeTokensReceived(msg.sender, msg.value);\n    }\n}"
}