{
  "language": "Solidity",
  "sources": {
    "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.20;\n\nimport {OwnableUpgradeable} from \"./OwnableUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * This extension of the {Ownable} contract includes a two-step mechanism to transfer\n * ownership, where the new owner must call {acceptOwnership} in order to replace the\n * old one. This can help prevent common mistakes, such as transfers of ownership to\n * incorrect accounts, or to contracts that are unable to interact with the\n * permission system.\n *\n * The initial owner is specified at deployment time in the constructor for `Ownable`. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {\n    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable2Step\n    struct Ownable2StepStorage {\n        address _pendingOwner;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Ownable2Step\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant Ownable2StepStorageLocation = 0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00;\n\n    function _getOwnable2StepStorage() private pure returns (Ownable2StepStorage storage $) {\n        assembly {\n            $.slot := Ownable2StepStorageLocation\n        }\n    }\n\n    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n    function __Ownable2Step_init() internal onlyInitializing {\n    }\n\n    function __Ownable2Step_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev Returns the address of the pending owner.\n     */\n    function pendingOwner() public view virtual returns (address) {\n        Ownable2StepStorage storage $ = _getOwnable2StepStorage();\n        return $._pendingOwner;\n    }\n\n    /**\n     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n     * Can only be called by the current owner.\n     *\n     * Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.\n     */\n    function transferOwnership(address newOwner) public virtual override onlyOwner {\n        Ownable2StepStorage storage $ = _getOwnable2StepStorage();\n        $._pendingOwner = newOwner;\n        emit OwnershipTransferStarted(owner(), newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual override {\n        Ownable2StepStorage storage $ = _getOwnable2StepStorage();\n        delete $._pendingOwner;\n        super._transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev The new owner accepts the ownership transfer.\n     */\n    function acceptOwnership() public virtual {\n        address sender = _msgSender();\n        if (pendingOwner() != sender) {\n            revert OwnableUnauthorizedAccount(sender);\n        }\n        _transferOwnership(sender);\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {ContextUpgradeable} from \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable\n    struct OwnableStorage {\n        address _owner;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Ownable\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;\n\n    function _getOwnableStorage() private pure returns (OwnableStorage storage $) {\n        assembly {\n            $.slot := OwnableStorageLocation\n        }\n    }\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    function __Ownable_init(address initialOwner) internal onlyInitializing {\n        __Ownable_init_unchained(initialOwner);\n    }\n\n    function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        OwnableStorage storage $ = _getOwnableStorage();\n        return $._owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        OwnableStorage storage $ = _getOwnableStorage();\n        address oldOwner = $._owner;\n        $._owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Storage of the initializable contract.\n     *\n     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n     * when using with upgradeable contracts.\n     *\n     * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n     */\n    struct InitializableStorage {\n        /**\n         * @dev Indicates that the contract has been initialized.\n         */\n        uint64 _initialized;\n        /**\n         * @dev Indicates that the contract is in the process of being initialized.\n         */\n        bool _initializing;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n    /**\n     * @dev The contract is already initialized.\n     */\n    error InvalidInitialization();\n\n    /**\n     * @dev The contract is not initializing.\n     */\n    error NotInitializing();\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint64 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n     * production.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        // Cache values to avoid duplicated sloads\n        bool isTopLevelCall = !$._initializing;\n        uint64 initialized = $._initialized;\n\n        // Allowed calls:\n        // - initialSetup: the contract is not in the initializing state and no previous version was\n        //                 initialized\n        // - construction: the contract is initialized at version 1 (no reininitialization) and the\n        //                 current contract is just being deployed\n        bool initialSetup = initialized == 0 && isTopLevelCall;\n        bool construction = initialized == 1 && address(this).code.length == 0;\n\n        if (!initialSetup && !construction) {\n            revert InvalidInitialization();\n        }\n        $._initialized = 1;\n        if (isTopLevelCall) {\n            $._initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            $._initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint64 version) {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        if ($._initializing || $._initialized >= version) {\n            revert InvalidInitialization();\n        }\n        $._initialized = version;\n        $._initializing = true;\n        _;\n        $._initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        _checkInitializing();\n        _;\n    }\n\n    /**\n     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n     */\n    function _checkInitializing() internal view virtual {\n        if (!_isInitializing()) {\n            revert NotInitializing();\n        }\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     *\n     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        if ($._initializing) {\n            revert InvalidInitialization();\n        }\n        if ($._initialized != type(uint64).max) {\n            $._initialized = type(uint64).max;\n            emit Initialized(type(uint64).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint64) {\n        return _getInitializableStorage()._initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _getInitializableStorage()._initializing;\n    }\n\n    /**\n     * @dev Returns a pointer to the storage namespace.\n     */\n    // solhint-disable-next-line var-name-mixedcase\n    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n        assembly {\n            $.slot := INITIALIZABLE_STORAGE\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\nimport {IERC5267} from \"@openzeppelin/contracts/interfaces/IERC5267.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP-712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP-712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n */\nabstract contract EIP712Upgradeable is Initializable, IERC5267 {\n    bytes32 private constant TYPE_HASH =\n        keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n    /// @custom:storage-location erc7201:openzeppelin.storage.EIP712\n    struct EIP712Storage {\n        /// @custom:oz-renamed-from _HASHED_NAME\n        bytes32 _hashedName;\n        /// @custom:oz-renamed-from _HASHED_VERSION\n        bytes32 _hashedVersion;\n\n        string _name;\n        string _version;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.EIP712\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100;\n\n    function _getEIP712Storage() private pure returns (EIP712Storage storage $) {\n        assembly {\n            $.slot := EIP712StorageLocation\n        }\n    }\n\n    /**\n     * @dev Initializes the domain separator and parameter caches.\n     *\n     * The meaning of `name` and `version` is specified in\n     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP-712]:\n     *\n     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n     * - `version`: the current major version of the signing domain.\n     *\n     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n     * contract upgrade].\n     */\n    function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n        __EIP712_init_unchained(name, version);\n    }\n\n    function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n        EIP712Storage storage $ = _getEIP712Storage();\n        $._name = name;\n        $._version = version;\n\n        // Reset prior values in storage if upgrading\n        $._hashedName = 0;\n        $._hashedVersion = 0;\n    }\n\n    /**\n     * @dev Returns the domain separator for the current chain.\n     */\n    function _domainSeparatorV4() internal view returns (bytes32) {\n        return _buildDomainSeparator();\n    }\n\n    function _buildDomainSeparator() private view returns (bytes32) {\n        return keccak256(abi.encode(TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this)));\n    }\n\n    /**\n     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n     * function returns the hash of the fully encoded EIP712 message for this domain.\n     *\n     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n     *\n     * ```solidity\n     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n     *     keccak256(\"Mail(address to,string contents)\"),\n     *     mailTo,\n     *     keccak256(bytes(mailContents))\n     * )));\n     * address signer = ECDSA.recover(digest, signature);\n     * ```\n     */\n    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n        return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n    }\n\n    /**\n     * @dev See {IERC-5267}.\n     */\n    function eip712Domain()\n        public\n        view\n        virtual\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        )\n    {\n        EIP712Storage storage $ = _getEIP712Storage();\n        // If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized\n        // and the EIP712 domain is not reliable, as it will be missing name and version.\n        require($._hashedName == 0 && $._hashedVersion == 0, \"EIP712: Uninitialized\");\n\n        return (\n            hex\"0f\", // 01111\n            _EIP712Name(),\n            _EIP712Version(),\n            block.chainid,\n            address(this),\n            bytes32(0),\n            new uint256[](0)\n        );\n    }\n\n    /**\n     * @dev The name parameter for the EIP712 domain.\n     *\n     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n     * are a concern.\n     */\n    function _EIP712Name() internal view virtual returns (string memory) {\n        EIP712Storage storage $ = _getEIP712Storage();\n        return $._name;\n    }\n\n    /**\n     * @dev The version parameter for the EIP712 domain.\n     *\n     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n     * are a concern.\n     */\n    function _EIP712Version() internal view virtual returns (string memory) {\n        EIP712Storage storage $ = _getEIP712Storage();\n        return $._version;\n    }\n\n    /**\n     * @dev The hash of the name parameter for the EIP712 domain.\n     *\n     * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead.\n     */\n    function _EIP712NameHash() internal view returns (bytes32) {\n        EIP712Storage storage $ = _getEIP712Storage();\n        string memory name = _EIP712Name();\n        if (bytes(name).length > 0) {\n            return keccak256(bytes(name));\n        } else {\n            // If the name is empty, the contract may have been upgraded without initializing the new storage.\n            // We return the name hash in storage if non-zero, otherwise we assume the name is empty by design.\n            bytes32 hashedName = $._hashedName;\n            if (hashedName != 0) {\n                return hashedName;\n            } else {\n                return keccak256(\"\");\n            }\n        }\n    }\n\n    /**\n     * @dev The hash of the version parameter for the EIP712 domain.\n     *\n     * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead.\n     */\n    function _EIP712VersionHash() internal view returns (bytes32) {\n        EIP712Storage storage $ = _getEIP712Storage();\n        string memory version = _EIP712Version();\n        if (bytes(version).length > 0) {\n            return keccak256(bytes(version));\n        } else {\n            // If the version is empty, the contract may have been upgraded without initializing the new storage.\n            // We return the version hash in storage if non-zero, otherwise we assume the version is empty by design.\n            bytes32 hashedVersion = $._hashedVersion;\n            if (hashedVersion != 0) {\n                return hashedVersion;\n            } else {\n                return keccak256(\"\");\n            }\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    constructor(address initialOwner) {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
    },
    "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC-20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.\n */\ninterface IERC20Errors {\n    /**\n     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param balance Current balance for the interacting account.\n     * @param needed Minimum amount required to perform a transfer.\n     */\n    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC20InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC20InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n     * @param spender Address that may be allowed to operate on tokens without being their owner.\n     * @param allowance Amount of tokens a `spender` is allowed to operate with.\n     * @param needed Minimum amount required to perform a transfer.\n     */\n    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC20InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n     * @param spender Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC-721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.\n */\ninterface IERC721Errors {\n    /**\n     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.\n     * Used in balance queries.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC721InvalidOwner(address owner);\n\n    /**\n     * @dev Indicates a `tokenId` whose `owner` is the zero address.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC721NonexistentToken(uint256 tokenId);\n\n    /**\n     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param tokenId Identifier number of a token.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC721InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC721InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC721InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC-1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.\n */\ninterface IERC1155Errors {\n    /**\n     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param balance Current balance for the interacting account.\n     * @param needed Minimum amount required to perform a transfer.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC1155InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC1155InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC1155MissingApprovalForAll(address operator, address owner);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC1155InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC1155InvalidOperator(address operator);\n\n    /**\n     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n     * Used in batch transfers.\n     * @param idsLength Length of the array of token identifiers\n     * @param valuesLength Length of the array of token amounts\n     */\n    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n"
    },
    "@openzeppelin/contracts/interfaces/IERC1967.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\n */\ninterface IERC1967 {\n    /**\n     * @dev Emitted when the implementation is upgraded.\n     */\n    event Upgraded(address indexed implementation);\n\n    /**\n     * @dev Emitted when the admin account has changed.\n     */\n    event AdminChanged(address previousAdmin, address newAdmin);\n\n    /**\n     * @dev Emitted when the beacon is changed.\n     */\n    event BeaconUpgraded(address indexed beacon);\n}\n"
    },
    "@openzeppelin/contracts/interfaces/IERC5267.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n    /**\n     * @dev MAY be emitted to signal that the domain could have changed.\n     */\n    event EIP712DomainChanged();\n\n    /**\n     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n     * signature.\n     */\n    function eip712Domain()\n        external\n        view\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        );\n}\n"
    },
    "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n    /**\n     * @dev Must return an address that can be used as a delegate call target.\n     *\n     * {UpgradeableBeacon} will check that this address is a contract.\n     */\n    function implementation() external view returns (address);\n}\n"
    },
    "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.22;\n\nimport {Proxy} from \"../Proxy.sol\";\nimport {ERC1967Utils} from \"./ERC1967Utils.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy {\n    /**\n     * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`.\n     *\n     * If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an\n     * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.\n     *\n     * Requirements:\n     *\n     * - If `data` is empty, `msg.value` must be zero.\n     */\n    constructor(address implementation, bytes memory _data) payable {\n        ERC1967Utils.upgradeToAndCall(implementation, _data);\n    }\n\n    /**\n     * @dev Returns the current implementation address.\n     *\n     * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using\n     * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n     * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n     */\n    function _implementation() internal view virtual override returns (address) {\n        return ERC1967Utils.getImplementation();\n    }\n}\n"
    },
    "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Utils.sol)\n\npragma solidity ^0.8.22;\n\nimport {IBeacon} from \"../beacon/IBeacon.sol\";\nimport {IERC1967} from \"../../interfaces/IERC1967.sol\";\nimport {Address} from \"../../utils/Address.sol\";\nimport {StorageSlot} from \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This library provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.\n */\nlibrary ERC1967Utils {\n    /**\n     * @dev Storage slot with the address of the current implementation.\n     * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1.\n     */\n    // solhint-disable-next-line private-vars-leading-underscore\n    bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n    /**\n     * @dev The `implementation` of the proxy is invalid.\n     */\n    error ERC1967InvalidImplementation(address implementation);\n\n    /**\n     * @dev The `admin` of the proxy is invalid.\n     */\n    error ERC1967InvalidAdmin(address admin);\n\n    /**\n     * @dev The `beacon` of the proxy is invalid.\n     */\n    error ERC1967InvalidBeacon(address beacon);\n\n    /**\n     * @dev An upgrade function sees `msg.value > 0` that may be lost.\n     */\n    error ERC1967NonPayable();\n\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function getImplementation() internal view returns (address) {\n        return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the ERC-1967 implementation slot.\n     */\n    function _setImplementation(address newImplementation) private {\n        if (newImplementation.code.length == 0) {\n            revert ERC1967InvalidImplementation(newImplementation);\n        }\n        StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;\n    }\n\n    /**\n     * @dev Performs implementation upgrade with additional setup call if data is nonempty.\n     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected\n     * to avoid stuck value in the contract.\n     *\n     * Emits an {IERC1967-Upgraded} event.\n     */\n    function upgradeToAndCall(address newImplementation, bytes memory data) internal {\n        _setImplementation(newImplementation);\n        emit IERC1967.Upgraded(newImplementation);\n\n        if (data.length > 0) {\n            Address.functionDelegateCall(newImplementation, data);\n        } else {\n            _checkNonPayable();\n        }\n    }\n\n    /**\n     * @dev Storage slot with the admin of the contract.\n     * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1.\n     */\n    // solhint-disable-next-line private-vars-leading-underscore\n    bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n    /**\n     * @dev Returns the current admin.\n     *\n     * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using\n     * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n     */\n    function getAdmin() internal view returns (address) {\n        return StorageSlot.getAddressSlot(ADMIN_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the ERC-1967 admin slot.\n     */\n    function _setAdmin(address newAdmin) private {\n        if (newAdmin == address(0)) {\n            revert ERC1967InvalidAdmin(address(0));\n        }\n        StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;\n    }\n\n    /**\n     * @dev Changes the admin of the proxy.\n     *\n     * Emits an {IERC1967-AdminChanged} event.\n     */\n    function changeAdmin(address newAdmin) internal {\n        emit IERC1967.AdminChanged(getAdmin(), newAdmin);\n        _setAdmin(newAdmin);\n    }\n\n    /**\n     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n     * This is the keccak-256 hash of \"eip1967.proxy.beacon\" subtracted by 1.\n     */\n    // solhint-disable-next-line private-vars-leading-underscore\n    bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n    /**\n     * @dev Returns the current beacon.\n     */\n    function getBeacon() internal view returns (address) {\n        return StorageSlot.getAddressSlot(BEACON_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new beacon in the ERC-1967 beacon slot.\n     */\n    function _setBeacon(address newBeacon) private {\n        if (newBeacon.code.length == 0) {\n            revert ERC1967InvalidBeacon(newBeacon);\n        }\n\n        StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;\n\n        address beaconImplementation = IBeacon(newBeacon).implementation();\n        if (beaconImplementation.code.length == 0) {\n            revert ERC1967InvalidImplementation(beaconImplementation);\n        }\n    }\n\n    /**\n     * @dev Change the beacon and trigger a setup call if data is nonempty.\n     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected\n     * to avoid stuck value in the contract.\n     *\n     * Emits an {IERC1967-BeaconUpgraded} event.\n     *\n     * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since\n     * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for\n     * efficiency.\n     */\n    function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {\n        _setBeacon(newBeacon);\n        emit IERC1967.BeaconUpgraded(newBeacon);\n\n        if (data.length > 0) {\n            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n        } else {\n            _checkNonPayable();\n        }\n    }\n\n    /**\n     * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract\n     * if an upgrade doesn't perform an initialization call.\n     */\n    function _checkNonPayable() private {\n        if (msg.value > 0) {\n            revert ERC1967NonPayable();\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/proxy/Proxy.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n    /**\n     * @dev Delegates the current call to `implementation`.\n     *\n     * This function does not return to its internal call site, it will return directly to the external caller.\n     */\n    function _delegate(address implementation) internal virtual {\n        assembly {\n            // Copy msg.data. We take full control of memory in this inline assembly\n            // block because it will not return to Solidity code. We overwrite the\n            // Solidity scratch pad at memory position 0.\n            calldatacopy(0, 0, calldatasize())\n\n            // Call the implementation.\n            // out and outsize are 0 because we don't know the size yet.\n            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n            // Copy the returned data.\n            returndatacopy(0, 0, returndatasize())\n\n            switch result\n            // delegatecall returns 0 on error.\n            case 0 {\n                revert(0, returndatasize())\n            }\n            default {\n                return(0, returndatasize())\n            }\n        }\n    }\n\n    /**\n     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback\n     * function and {_fallback} should delegate.\n     */\n    function _implementation() internal view virtual returns (address);\n\n    /**\n     * @dev Delegates the current call to the address returned by `_implementation()`.\n     *\n     * This function does not return to its internal call site, it will return directly to the external caller.\n     */\n    function _fallback() internal virtual {\n        _delegate(_implementation());\n    }\n\n    /**\n     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n     * function in the contract matches the call data.\n     */\n    fallback() external payable virtual {\n        _fallback();\n    }\n}\n"
    },
    "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.22;\n\nimport {ITransparentUpgradeableProxy} from \"./TransparentUpgradeableProxy.sol\";\nimport {Ownable} from \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n    /**\n     * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgrade(address,address)`\n     * and `upgradeAndCall(address,address,bytes)` are present, and `upgrade` must be used if no function should be called,\n     * while `upgradeAndCall` will invoke the `receive` function if the third argument is the empty byte string.\n     * If the getter returns `\"5.0.0\"`, only `upgradeAndCall(address,address,bytes)` is present, and the third argument must\n     * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function\n     * during an upgrade.\n     */\n    string public constant UPGRADE_INTERFACE_VERSION = \"5.0.0\";\n\n    /**\n     * @dev Sets the initial owner who can perform upgrades.\n     */\n    constructor(address initialOwner) Ownable(initialOwner) {}\n\n    /**\n     * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation.\n     * See {TransparentUpgradeableProxy-_dispatchUpgradeToAndCall}.\n     *\n     * Requirements:\n     *\n     * - This contract must be the admin of `proxy`.\n     * - If `data` is empty, `msg.value` must be zero.\n     */\n    function upgradeAndCall(\n        ITransparentUpgradeableProxy proxy,\n        address implementation,\n        bytes memory data\n    ) public payable virtual onlyOwner {\n        proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n    }\n}\n"
    },
    "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.22;\n\nimport {ERC1967Utils} from \"../ERC1967/ERC1967Utils.sol\";\nimport {ERC1967Proxy} from \"../ERC1967/ERC1967Proxy.sol\";\nimport {IERC1967} from \"../../interfaces/IERC1967.sol\";\nimport {ProxyAdmin} from \"./ProxyAdmin.sol\";\n\n/**\n * @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}\n * does not implement this interface directly, and its upgradeability mechanism is implemented by an internal dispatch\n * mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not\n * include them in the ABI so this interface must be used to interact with it.\n */\ninterface ITransparentUpgradeableProxy is IERC1967 {\n    /// @dev See {UUPSUpgradeable-upgradeToAndCall}\n    function upgradeToAndCall(address newImplementation, bytes calldata data) external payable;\n}\n\n/**\n * @dev This contract implements a proxy that is upgradeable through an associated {ProxyAdmin} instance.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches the {ITransparentUpgradeableProxy-upgradeToAndCall} function exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can call the `upgradeToAndCall` function but any other call won't be forwarded to\n * the implementation. If the admin tries to call a function on the implementation it will fail with an error indicating\n * the proxy admin cannot fallback to the target implementation.\n *\n * These properties mean that the admin account can only be used for upgrading the proxy, so it's best if it's a\n * dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to\n * call a function from the proxy implementation. For this reason, the proxy deploys an instance of {ProxyAdmin} and\n * allows upgrades only if they come through it. You should think of the `ProxyAdmin` instance as the administrative\n * interface of the proxy, including the ability to change who can trigger upgrades by transferring ownership.\n *\n * NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not\n * inherit from that interface, and instead `upgradeToAndCall` is implicitly implemented using a custom dispatch\n * mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to\n * fully implement transparency without decoding reverts caused by selector clashes between the proxy and the\n * implementation.\n *\n * NOTE: This proxy does not inherit from {Context} deliberately. The {ProxyAdmin} of this contract won't send a\n * meta-transaction in any way, and any other meta-transaction setup should be made in the implementation contract.\n *\n * IMPORTANT: This contract avoids unnecessary storage reads by setting the admin only during construction as an\n * immutable variable, preventing any changes thereafter. However, the admin slot defined in ERC-1967 can still be\n * overwritten by the implementation logic pointed to by this proxy. In such cases, the contract may end up in an\n * undesirable state where the admin slot is different from the actual admin. Relying on the value of the admin slot\n * is generally fine if the implementation is trusted.\n *\n * WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the\n * compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new\n * function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This\n * could render the `upgradeToAndCall` function inaccessible, preventing upgradeability and compromising transparency.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n    // An immutable address for the admin to avoid unnecessary SLOADs before each call\n    // at the expense of removing the ability to change the admin once it's set.\n    // This is acceptable if the admin is always a ProxyAdmin instance or similar contract\n    // with its own ability to transfer the permissions to another account.\n    address private immutable _admin;\n\n    /**\n     * @dev The proxy caller is the current admin, and can't fallback to the proxy target.\n     */\n    error ProxyDeniedAdminAccess();\n\n    /**\n     * @dev Initializes an upgradeable proxy managed by an instance of a {ProxyAdmin} with an `initialOwner`,\n     * backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in\n     * {ERC1967Proxy-constructor}.\n     */\n    constructor(address _logic, address initialOwner, bytes memory _data) payable ERC1967Proxy(_logic, _data) {\n        _admin = address(new ProxyAdmin(initialOwner));\n        // Set the storage value and emit an event for ERC-1967 compatibility\n        ERC1967Utils.changeAdmin(_proxyAdmin());\n    }\n\n    /**\n     * @dev Returns the admin of this proxy.\n     */\n    function _proxyAdmin() internal view virtual returns (address) {\n        return _admin;\n    }\n\n    /**\n     * @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior.\n     */\n    function _fallback() internal virtual override {\n        if (msg.sender == _proxyAdmin()) {\n            if (msg.sig != ITransparentUpgradeableProxy.upgradeToAndCall.selector) {\n                revert ProxyDeniedAdminAccess();\n            } else {\n                _dispatchUpgradeToAndCall();\n            }\n        } else {\n            super._fallback();\n        }\n    }\n\n    /**\n     * @dev Upgrade the implementation of the proxy. See {ERC1967Utils-upgradeToAndCall}.\n     *\n     * Requirements:\n     *\n     * - If `data` is empty, `msg.value` must be zero.\n     */\n    function _dispatchUpgradeToAndCall() private {\n        (address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));\n        ERC1967Utils.upgradeToAndCall(newImplementation, data);\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/ERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC-20\n * applications.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n    mapping(address account => uint256) private _balances;\n\n    mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    string private _name;\n    string private _symbol;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}.\n     *\n     * All two of these values are immutable: they can only be set once during\n     * construction.\n     */\n    constructor(string memory name_, string memory symbol_) {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view virtual returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view virtual returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei. This is the default value returned by this function, unless\n     * it's overridden.\n     *\n     * NOTE: This information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * {IERC20-balanceOf} and {IERC20-transfer}.\n     */\n    function decimals() public view virtual returns (uint8) {\n        return 18;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view virtual returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) public view virtual returns (uint256) {\n        return _balances[account];\n    }\n\n    /**\n     * @dev See {IERC20-transfer}.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - the caller must have a balance of at least `value`.\n     */\n    function transfer(address to, uint256 value) public virtual returns (bool) {\n        address owner = _msgSender();\n        _transfer(owner, to, value);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender) public view virtual returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n     * `transferFrom`. This is semantically equivalent to an infinite approval.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 value) public virtual returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, value);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Skips emitting an {Approval} event indicating an allowance update. This is not\n     * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].\n     *\n     * NOTE: Does not update the allowance if the current allowance\n     * is the maximum `uint256`.\n     *\n     * Requirements:\n     *\n     * - `from` and `to` cannot be the zero address.\n     * - `from` must have a balance of at least `value`.\n     * - the caller must have allowance for ``from``'s tokens of at least\n     * `value`.\n     */\n    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n        address spender = _msgSender();\n        _spendAllowance(from, spender, value);\n        _transfer(from, to, value);\n        return true;\n    }\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to`.\n     *\n     * This internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * NOTE: This function is not virtual, {_update} should be overridden instead.\n     */\n    function _transfer(address from, address to, uint256 value) internal {\n        if (from == address(0)) {\n            revert ERC20InvalidSender(address(0));\n        }\n        if (to == address(0)) {\n            revert ERC20InvalidReceiver(address(0));\n        }\n        _update(from, to, value);\n    }\n\n    /**\n     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n     * this function.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _update(address from, address to, uint256 value) internal virtual {\n        if (from == address(0)) {\n            // Overflow check required: The rest of the code assumes that totalSupply never overflows\n            _totalSupply += value;\n        } else {\n            uint256 fromBalance = _balances[from];\n            if (fromBalance < value) {\n                revert ERC20InsufficientBalance(from, fromBalance, value);\n            }\n            unchecked {\n                // Overflow not possible: value <= fromBalance <= totalSupply.\n                _balances[from] = fromBalance - value;\n            }\n        }\n\n        if (to == address(0)) {\n            unchecked {\n                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n                _totalSupply -= value;\n            }\n        } else {\n            unchecked {\n                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n                _balances[to] += value;\n            }\n        }\n\n        emit Transfer(from, to, value);\n    }\n\n    /**\n     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n     * Relies on the `_update` mechanism\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * NOTE: This function is not virtual, {_update} should be overridden instead.\n     */\n    function _mint(address account, uint256 value) internal {\n        if (account == address(0)) {\n            revert ERC20InvalidReceiver(address(0));\n        }\n        _update(address(0), account, value);\n    }\n\n    /**\n     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n     * Relies on the `_update` mechanism.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * NOTE: This function is not virtual, {_update} should be overridden instead\n     */\n    function _burn(address account, uint256 value) internal {\n        if (account == address(0)) {\n            revert ERC20InvalidSender(address(0));\n        }\n        _update(account, address(0), value);\n    }\n\n    /**\n     * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     *\n     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n     */\n    function _approve(address owner, address spender, uint256 value) internal {\n        _approve(owner, spender, value, true);\n    }\n\n    /**\n     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n     *\n     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n     * `Approval` event during `transferFrom` operations.\n     *\n     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n     * true using the following override:\n     *\n     * ```solidity\n     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n     *     super._approve(owner, spender, value, true);\n     * }\n     * ```\n     *\n     * Requirements are the same as {_approve}.\n     */\n    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n        if (owner == address(0)) {\n            revert ERC20InvalidApprover(address(0));\n        }\n        if (spender == address(0)) {\n            revert ERC20InvalidSpender(address(0));\n        }\n        _allowances[owner][spender] = value;\n        if (emitEvent) {\n            emit Approval(owner, spender, value);\n        }\n    }\n\n    /**\n     * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n     *\n     * Does not update the allowance value in case of infinite allowance.\n     * Revert if not enough allowance is available.\n     *\n     * Does not emit an {Approval} event.\n     */\n    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n        uint256 currentAllowance = allowance(owner, spender);\n        if (currentAllowance < type(uint256).max) {\n            if (currentAllowance < value) {\n                revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n            }\n            unchecked {\n                _approve(owner, spender, currentAllowance - value, false);\n            }\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/ERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20Permit} from \"./IERC20Permit.sol\";\nimport {ERC20} from \"../ERC20.sol\";\nimport {ECDSA} from \"../../../utils/cryptography/ECDSA.sol\";\nimport {EIP712} from \"../../../utils/cryptography/EIP712.sol\";\nimport {Nonces} from \"../../../utils/Nonces.sol\";\n\n/**\n * @dev Implementation of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces {\n    bytes32 private constant PERMIT_TYPEHASH =\n        keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n    /**\n     * @dev Permit deadline has expired.\n     */\n    error ERC2612ExpiredSignature(uint256 deadline);\n\n    /**\n     * @dev Mismatched signature.\n     */\n    error ERC2612InvalidSigner(address signer, address owner);\n\n    /**\n     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n     *\n     * It's a good idea to use the same `name` that is defined as the ERC-20 token name.\n     */\n    constructor(string memory name) EIP712(name, \"1\") {}\n\n    /**\n     * @inheritdoc IERC20Permit\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) public virtual {\n        if (block.timestamp > deadline) {\n            revert ERC2612ExpiredSignature(deadline);\n        }\n\n        bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n        bytes32 hash = _hashTypedDataV4(structHash);\n\n        address signer = ECDSA.recover(hash, v, r, s);\n        if (signer != owner) {\n            revert ERC2612InvalidSigner(signer, owner);\n        }\n\n        _approve(owner, spender, value);\n    }\n\n    /**\n     * @inheritdoc IERC20Permit\n     */\n    function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) {\n        return super.nonces(owner);\n    }\n\n    /**\n     * @inheritdoc IERC20Permit\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {\n        return _domainSeparatorV4();\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC-20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n *     doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n *     token.safeTransferFrom(msg.sender, address(this), value);\n *     ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     *\n     * CAUTION: See Security Considerations above.\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-20 standard as defined in the ERC.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 value) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
    },
    "@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\nimport {Errors} from \"./Errors.sol\";\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev There's no code at `target` (it is not a contract).\n     */\n    error AddressEmptyCode(address target);\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        if (address(this).balance < amount) {\n            revert Errors.InsufficientBalance(address(this).balance, amount);\n        }\n\n        (bool success, bytes memory returndata) = recipient.call{value: amount}(\"\");\n        if (!success) {\n            _revert(returndata);\n        }\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason or custom error, it is bubbled\n     * up by this function (like regular Solidity function calls). However, if\n     * the call reverted with no returned reason, this function reverts with a\n     * {Errors.FailedCall} error.\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        if (address(this).balance < value) {\n            revert Errors.InsufficientBalance(address(this).balance, value);\n        }\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n     * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case\n     * of an unsuccessful call.\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata\n    ) internal view returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            // only check if target is a contract if the call was successful and the return data is empty\n            // otherwise we already know that it was a contract\n            if (returndata.length == 0 && target.code.length == 0) {\n                revert AddressEmptyCode(target);\n            }\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n     * revert reason or with a default {Errors.FailedCall} error.\n     */\n    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.\n     */\n    function _revert(bytes memory returndata) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            assembly (\"memory-safe\") {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert Errors.FailedCall();\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS\n    }\n\n    /**\n     * @dev The signature derives the `address(0)`.\n     */\n    error ECDSAInvalidSignature();\n\n    /**\n     * @dev The signature has an invalid length.\n     */\n    error ECDSAInvalidSignatureLength(uint256 length);\n\n    /**\n     * @dev The signature has an S value that is in the upper half order.\n     */\n    error ECDSAInvalidSignatureS(bytes32 s);\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n     * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n     * and a bytes32 providing additional information about the error.\n     *\n     * If no error is returned, then the address can be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes memory signature\n    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            assembly (\"memory-safe\") {\n                r := mload(add(signature, 0x20))\n                s := mload(add(signature, 0x40))\n                v := byte(0, mload(add(signature, 0x60)))\n            }\n            return tryRecover(hash, v, r, s);\n        } else {\n            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {\n        unchecked {\n            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n            // We do not check for an overflow here since the shift operation results in 0 or 1.\n            uint8 v = uint8((uint256(vs) >> 255) + 27);\n            return tryRecover(hash, v, r, s);\n        }\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     */\n    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function tryRecover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS, s);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature, bytes32(0));\n        }\n\n        return (signer, RecoverError.NoError, bytes32(0));\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n     */\n    function _throwError(RecoverError error, bytes32 errorArg) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert ECDSAInvalidSignature();\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert ECDSAInvalidSignatureLength(uint256(errorArg));\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert ECDSAInvalidSignatureS(errorArg);\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/cryptography/EIP712.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"./MessageHashUtils.sol\";\nimport {ShortStrings, ShortString} from \"../ShortStrings.sol\";\nimport {IERC5267} from \"../../interfaces/IERC5267.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP-712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP-712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable\n */\nabstract contract EIP712 is IERC5267 {\n    using ShortStrings for *;\n\n    bytes32 private constant TYPE_HASH =\n        keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n    // invalidate the cached domain separator if the chain id changes.\n    bytes32 private immutable _cachedDomainSeparator;\n    uint256 private immutable _cachedChainId;\n    address private immutable _cachedThis;\n\n    bytes32 private immutable _hashedName;\n    bytes32 private immutable _hashedVersion;\n\n    ShortString private immutable _name;\n    ShortString private immutable _version;\n    string private _nameFallback;\n    string private _versionFallback;\n\n    /**\n     * @dev Initializes the domain separator and parameter caches.\n     *\n     * The meaning of `name` and `version` is specified in\n     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP-712]:\n     *\n     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n     * - `version`: the current major version of the signing domain.\n     *\n     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n     * contract upgrade].\n     */\n    constructor(string memory name, string memory version) {\n        _name = name.toShortStringWithFallback(_nameFallback);\n        _version = version.toShortStringWithFallback(_versionFallback);\n        _hashedName = keccak256(bytes(name));\n        _hashedVersion = keccak256(bytes(version));\n\n        _cachedChainId = block.chainid;\n        _cachedDomainSeparator = _buildDomainSeparator();\n        _cachedThis = address(this);\n    }\n\n    /**\n     * @dev Returns the domain separator for the current chain.\n     */\n    function _domainSeparatorV4() internal view returns (bytes32) {\n        if (address(this) == _cachedThis && block.chainid == _cachedChainId) {\n            return _cachedDomainSeparator;\n        } else {\n            return _buildDomainSeparator();\n        }\n    }\n\n    function _buildDomainSeparator() private view returns (bytes32) {\n        return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));\n    }\n\n    /**\n     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n     * function returns the hash of the fully encoded EIP712 message for this domain.\n     *\n     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n     *\n     * ```solidity\n     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n     *     keccak256(\"Mail(address to,string contents)\"),\n     *     mailTo,\n     *     keccak256(bytes(mailContents))\n     * )));\n     * address signer = ECDSA.recover(digest, signature);\n     * ```\n     */\n    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n        return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n    }\n\n    /**\n     * @dev See {IERC-5267}.\n     */\n    function eip712Domain()\n        public\n        view\n        virtual\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        )\n    {\n        return (\n            hex\"0f\", // 01111\n            _EIP712Name(),\n            _EIP712Version(),\n            block.chainid,\n            address(this),\n            bytes32(0),\n            new uint256[](0)\n        );\n    }\n\n    /**\n     * @dev The name parameter for the EIP712 domain.\n     *\n     * NOTE: By default this function reads _name which is an immutable value.\n     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function _EIP712Name() internal view returns (string memory) {\n        return _name.toStringWithFallback(_nameFallback);\n    }\n\n    /**\n     * @dev The version parameter for the EIP712 domain.\n     *\n     * NOTE: By default this function reads _version which is an immutable value.\n     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function _EIP712Version() internal view returns (string memory) {\n        return _version.toStringWithFallback(_versionFallback);\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[ERC-191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x45` (`personal_sign` messages).\n     *\n     * The digest is calculated by prefixing a bytes32 `messageHash` with\n     * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n     *\n     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n     * keccak256, although any bytes32 value can be safely used because the final digest will\n     * be re-hashed.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n        assembly (\"memory-safe\") {\n            mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n        }\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x45` (`personal_sign` messages).\n     *\n     * The digest is calculated by prefixing an arbitrary `message` with\n     * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n        return\n            keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x00` (data with intended validator).\n     *\n     * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n     * `validator` address. Then hashing the result.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`).\n     *\n     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n     * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n        assembly (\"memory-safe\") {\n            let ptr := mload(0x40)\n            mstore(ptr, hex\"19_01\")\n            mstore(add(ptr, 0x02), domainSeparator)\n            mstore(add(ptr, 0x22), structHash)\n            digest := keccak256(ptr, 0x42)\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Errors.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of common custom errors used in multiple contracts\n *\n * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.\n * It is recommended to avoid relying on the error API for critical functionality.\n *\n * _Available since v5.1._\n */\nlibrary Errors {\n    /**\n     * @dev The ETH balance of the account is not enough to perform the operation.\n     */\n    error InsufficientBalance(uint256 balance, uint256 needed);\n\n    /**\n     * @dev A call to an address target failed. The target may have reverted.\n     */\n    error FailedCall();\n\n    /**\n     * @dev The deployment failed.\n     */\n    error FailedDeployment();\n\n    /**\n     * @dev A necessary precompile is missing.\n     */\n    error MissingPrecompile(address);\n}\n"
    },
    "@openzeppelin/contracts/utils/math/Math.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\nimport {Panic} from \"../Panic.sol\";\nimport {SafeCast} from \"./SafeCast.sol\";\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Floor, // Toward negative infinity\n        Ceil, // Toward positive infinity\n        Trunc, // Toward zero\n        Expand // Away from zero\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, with an success flag (no overflow).\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            uint256 c = a + b;\n            if (c < a) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            if (b > a) return (false, 0);\n            return (true, a - b);\n        }\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n            // benefit is lost if 'b' is also tested.\n            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n            if (a == 0) return (true, 0);\n            uint256 c = a * b;\n            if (c / a != b) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a / b);\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a % b);\n        }\n    }\n\n    /**\n     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.\n     *\n     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.\n     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute\n     * one branch when needed, making this function more expensive.\n     */\n    function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {\n        unchecked {\n            // branchless ternary works because:\n            // b ^ (a ^ b) == a\n            // b ^ 0 == b\n            return b ^ ((a ^ b) * SafeCast.toUint(condition));\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return ternary(a > b, a, b);\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return ternary(a < b, a, b);\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds towards infinity instead\n     * of rounding towards zero.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (b == 0) {\n            // Guarantee the same behavior as in a regular Solidity division.\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n\n        // The following calculation ensures accurate ceiling division without overflow.\n        // Since a is non-zero, (a - 1) / b will not overflow.\n        // The largest possible result occurs when (a - 1) / b is type(uint256).max,\n        // but the largest value we can obtain is type(uint256).max - 1, which happens\n        // when a = type(uint256).max and b = 1.\n        unchecked {\n            return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);\n        }\n    }\n\n    /**\n     * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n     * denominator == 0.\n     *\n     * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n     * Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use\n            // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2²⁵⁶ + prod0.\n            uint256 prod0 = x * y; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.\n            if (denominator <= prod1) {\n                Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));\n            }\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n            uint256 twos = denominator & (0 - denominator);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such\n            // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv ≡ 1 mod 2⁴.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n            // works in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2⁸\n            inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶\n            inverse *= 2 - denominator * inverse; // inverse mod 2³²\n            inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴\n            inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸\n            inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is\n            // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @dev Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);\n    }\n\n    /**\n     * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.\n     *\n     * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.\n     * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.\n     *\n     * If the input value is not inversible, 0 is returned.\n     *\n     * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the\n     * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.\n     */\n    function invMod(uint256 a, uint256 n) internal pure returns (uint256) {\n        unchecked {\n            if (n == 0) return 0;\n\n            // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)\n            // Used to compute integers x and y such that: ax + ny = gcd(a, n).\n            // When the gcd is 1, then the inverse of a modulo n exists and it's x.\n            // ax + ny = 1\n            // ax = 1 + (-y)n\n            // ax ≡ 1 (mod n) # x is the inverse of a modulo n\n\n            // If the remainder is 0 the gcd is n right away.\n            uint256 remainder = a % n;\n            uint256 gcd = n;\n\n            // Therefore the initial coefficients are:\n            // ax + ny = gcd(a, n) = n\n            // 0a + 1n = n\n            int256 x = 0;\n            int256 y = 1;\n\n            while (remainder != 0) {\n                uint256 quotient = gcd / remainder;\n\n                (gcd, remainder) = (\n                    // The old remainder is the next gcd to try.\n                    remainder,\n                    // Compute the next remainder.\n                    // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd\n                    // where gcd is at most n (capped to type(uint256).max)\n                    gcd - remainder * quotient\n                );\n\n                (x, y) = (\n                    // Increment the coefficient of a.\n                    y,\n                    // Decrement the coefficient of n.\n                    // Can overflow, but the result is casted to uint256 so that the\n                    // next value of y is \"wrapped around\" to a value between 0 and n - 1.\n                    x - y * int256(quotient)\n                );\n            }\n\n            if (gcd != 1) return 0; // No inverse exists.\n            return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.\n        }\n    }\n\n    /**\n     * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.\n     *\n     * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is\n     * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that\n     * `a**(p-2)` is the modular multiplicative inverse of a in Fp.\n     *\n     * NOTE: this function does NOT check that `p` is a prime greater than `2`.\n     */\n    function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {\n        unchecked {\n            return Math.modExp(a, p - 2, p);\n        }\n    }\n\n    /**\n     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)\n     *\n     * Requirements:\n     * - modulus can't be zero\n     * - underlying staticcall to precompile must succeed\n     *\n     * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make\n     * sure the chain you're using it on supports the precompiled contract for modular exponentiation\n     * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,\n     * the underlying function will succeed given the lack of a revert, but the result may be incorrectly\n     * interpreted as 0.\n     */\n    function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {\n        (bool success, uint256 result) = tryModExp(b, e, m);\n        if (!success) {\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).\n     * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying\n     * to operate modulo 0 or if the underlying precompile reverted.\n     *\n     * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain\n     * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in\n     * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack\n     * of a revert, but the result may be incorrectly interpreted as 0.\n     */\n    function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {\n        if (m == 0) return (false, 0);\n        assembly (\"memory-safe\") {\n            let ptr := mload(0x40)\n            // | Offset    | Content    | Content (Hex)                                                      |\n            // |-----------|------------|--------------------------------------------------------------------|\n            // | 0x00:0x1f | size of b  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x20:0x3f | size of e  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x40:0x5f | size of m  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x60:0x7f | value of b | 0x<.............................................................b> |\n            // | 0x80:0x9f | value of e | 0x<.............................................................e> |\n            // | 0xa0:0xbf | value of m | 0x<.............................................................m> |\n            mstore(ptr, 0x20)\n            mstore(add(ptr, 0x20), 0x20)\n            mstore(add(ptr, 0x40), 0x20)\n            mstore(add(ptr, 0x60), b)\n            mstore(add(ptr, 0x80), e)\n            mstore(add(ptr, 0xa0), m)\n\n            // Given the result < m, it's guaranteed to fit in 32 bytes,\n            // so we can use the memory scratch space located at offset 0.\n            success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)\n            result := mload(0x00)\n        }\n    }\n\n    /**\n     * @dev Variant of {modExp} that supports inputs of arbitrary length.\n     */\n    function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {\n        (bool success, bytes memory result) = tryModExp(b, e, m);\n        if (!success) {\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Variant of {tryModExp} that supports inputs of arbitrary length.\n     */\n    function tryModExp(\n        bytes memory b,\n        bytes memory e,\n        bytes memory m\n    ) internal view returns (bool success, bytes memory result) {\n        if (_zeroBytes(m)) return (false, new bytes(0));\n\n        uint256 mLen = m.length;\n\n        // Encode call args in result and move the free memory pointer\n        result = abi.encodePacked(b.length, e.length, mLen, b, e, m);\n\n        assembly (\"memory-safe\") {\n            let dataPtr := add(result, 0x20)\n            // Write result on top of args to avoid allocating extra memory.\n            success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)\n            // Overwrite the length.\n            // result.length > returndatasize() is guaranteed because returndatasize() == m.length\n            mstore(result, mLen)\n            // Set the memory pointer after the returned data.\n            mstore(0x40, add(dataPtr, mLen))\n        }\n    }\n\n    /**\n     * @dev Returns whether the provided byte array is zero.\n     */\n    function _zeroBytes(bytes memory byteArray) private pure returns (bool) {\n        for (uint256 i = 0; i < byteArray.length; ++i) {\n            if (byteArray[i] != 0) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n     * towards zero.\n     *\n     * This method is based on Newton's method for computing square roots; the algorithm is restricted to only\n     * using integer operations.\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        unchecked {\n            // Take care of easy edge cases when a == 0 or a == 1\n            if (a <= 1) {\n                return a;\n            }\n\n            // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a\n            // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between\n            // the current value as `ε_n = | x_n - sqrt(a) |`.\n            //\n            // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root\n            // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is\n            // bigger than any uint256.\n            //\n            // By noticing that\n            // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`\n            // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar\n            // to the msb function.\n            uint256 aa = a;\n            uint256 xn = 1;\n\n            if (aa >= (1 << 128)) {\n                aa >>= 128;\n                xn <<= 64;\n            }\n            if (aa >= (1 << 64)) {\n                aa >>= 64;\n                xn <<= 32;\n            }\n            if (aa >= (1 << 32)) {\n                aa >>= 32;\n                xn <<= 16;\n            }\n            if (aa >= (1 << 16)) {\n                aa >>= 16;\n                xn <<= 8;\n            }\n            if (aa >= (1 << 8)) {\n                aa >>= 8;\n                xn <<= 4;\n            }\n            if (aa >= (1 << 4)) {\n                aa >>= 4;\n                xn <<= 2;\n            }\n            if (aa >= (1 << 2)) {\n                xn <<= 1;\n            }\n\n            // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).\n            //\n            // We can refine our estimation by noticing that the middle of that interval minimizes the error.\n            // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).\n            // This is going to be our x_0 (and ε_0)\n            xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)\n\n            // From here, Newton's method give us:\n            // x_{n+1} = (x_n + a / x_n) / 2\n            //\n            // One should note that:\n            // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a\n            //              = ((x_n² + a) / (2 * x_n))² - a\n            //              = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a\n            //              = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)\n            //              = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)\n            //              = (x_n² - a)² / (2 * x_n)²\n            //              = ((x_n² - a) / (2 * x_n))²\n            //              ≥ 0\n            // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n\n            //\n            // This gives us the proof of quadratic convergence of the sequence:\n            // ε_{n+1} = | x_{n+1} - sqrt(a) |\n            //         = | (x_n + a / x_n) / 2 - sqrt(a) |\n            //         = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |\n            //         = | (x_n - sqrt(a))² / (2 * x_n) |\n            //         = | ε_n² / (2 * x_n) |\n            //         = ε_n² / | (2 * x_n) |\n            //\n            // For the first iteration, we have a special case where x_0 is known:\n            // ε_1 = ε_0² / | (2 * x_0) |\n            //     ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))\n            //     ≤ 2**(2*e-4) / (3 * 2**(e-1))\n            //     ≤ 2**(e-3) / 3\n            //     ≤ 2**(e-3-log2(3))\n            //     ≤ 2**(e-4.5)\n            //\n            // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:\n            // ε_{n+1} = ε_n² / | (2 * x_n) |\n            //         ≤ (2**(e-k))² / (2 * 2**(e-1))\n            //         ≤ 2**(2*e-2*k) / 2**e\n            //         ≤ 2**(e-2*k)\n            xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5)  -- special case, see above\n            xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9)    -- general case with k = 4.5\n            xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18)   -- general case with k = 9\n            xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36)   -- general case with k = 18\n            xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72)   -- general case with k = 36\n            xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144)  -- general case with k = 72\n\n            // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision\n            // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either\n            // sqrt(a) or sqrt(a) + 1.\n            return xn - SafeCast.toUint(xn > a / xn);\n        }\n    }\n\n    /**\n     * @dev Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        uint256 exp;\n        unchecked {\n            exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);\n            value >>= exp;\n            result += exp;\n\n            result += SafeCast.toUint(value > 1);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        uint256 isGt;\n        unchecked {\n            isGt = SafeCast.toUint(value > (1 << 128) - 1);\n            value >>= isGt * 128;\n            result += isGt * 16;\n\n            isGt = SafeCast.toUint(value > (1 << 64) - 1);\n            value >>= isGt * 64;\n            result += isGt * 8;\n\n            isGt = SafeCast.toUint(value > (1 << 32) - 1);\n            value >>= isGt * 32;\n            result += isGt * 4;\n\n            isGt = SafeCast.toUint(value > (1 << 16) - 1);\n            value >>= isGt * 16;\n            result += isGt * 2;\n\n            result += SafeCast.toUint(value > (1 << 8) - 1);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);\n        }\n    }\n\n    /**\n     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n     */\n    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n        return uint8(rounding) % 2 == 1;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/math/SafeCast.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeCast {\n    /**\n     * @dev Value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n    /**\n     * @dev An int value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedIntToUint(int256 value);\n\n    /**\n     * @dev Value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n    /**\n     * @dev An uint value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedUintToInt(uint256 value);\n\n    /**\n     * @dev Returns the downcasted uint248 from uint256, reverting on\n     * overflow (when the input is greater than largest uint248).\n     *\n     * Counterpart to Solidity's `uint248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     */\n    function toUint248(uint256 value) internal pure returns (uint248) {\n        if (value > type(uint248).max) {\n            revert SafeCastOverflowedUintDowncast(248, value);\n        }\n        return uint248(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint240 from uint256, reverting on\n     * overflow (when the input is greater than largest uint240).\n     *\n     * Counterpart to Solidity's `uint240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     */\n    function toUint240(uint256 value) internal pure returns (uint240) {\n        if (value > type(uint240).max) {\n            revert SafeCastOverflowedUintDowncast(240, value);\n        }\n        return uint240(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint232 from uint256, reverting on\n     * overflow (when the input is greater than largest uint232).\n     *\n     * Counterpart to Solidity's `uint232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     */\n    function toUint232(uint256 value) internal pure returns (uint232) {\n        if (value > type(uint232).max) {\n            revert SafeCastOverflowedUintDowncast(232, value);\n        }\n        return uint232(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint224 from uint256, reverting on\n     * overflow (when the input is greater than largest uint224).\n     *\n     * Counterpart to Solidity's `uint224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     */\n    function toUint224(uint256 value) internal pure returns (uint224) {\n        if (value > type(uint224).max) {\n            revert SafeCastOverflowedUintDowncast(224, value);\n        }\n        return uint224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint216 from uint256, reverting on\n     * overflow (when the input is greater than largest uint216).\n     *\n     * Counterpart to Solidity's `uint216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     */\n    function toUint216(uint256 value) internal pure returns (uint216) {\n        if (value > type(uint216).max) {\n            revert SafeCastOverflowedUintDowncast(216, value);\n        }\n        return uint216(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint208 from uint256, reverting on\n     * overflow (when the input is greater than largest uint208).\n     *\n     * Counterpart to Solidity's `uint208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     */\n    function toUint208(uint256 value) internal pure returns (uint208) {\n        if (value > type(uint208).max) {\n            revert SafeCastOverflowedUintDowncast(208, value);\n        }\n        return uint208(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint200 from uint256, reverting on\n     * overflow (when the input is greater than largest uint200).\n     *\n     * Counterpart to Solidity's `uint200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     */\n    function toUint200(uint256 value) internal pure returns (uint200) {\n        if (value > type(uint200).max) {\n            revert SafeCastOverflowedUintDowncast(200, value);\n        }\n        return uint200(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint192 from uint256, reverting on\n     * overflow (when the input is greater than largest uint192).\n     *\n     * Counterpart to Solidity's `uint192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     */\n    function toUint192(uint256 value) internal pure returns (uint192) {\n        if (value > type(uint192).max) {\n            revert SafeCastOverflowedUintDowncast(192, value);\n        }\n        return uint192(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint184 from uint256, reverting on\n     * overflow (when the input is greater than largest uint184).\n     *\n     * Counterpart to Solidity's `uint184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     */\n    function toUint184(uint256 value) internal pure returns (uint184) {\n        if (value > type(uint184).max) {\n            revert SafeCastOverflowedUintDowncast(184, value);\n        }\n        return uint184(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint176 from uint256, reverting on\n     * overflow (when the input is greater than largest uint176).\n     *\n     * Counterpart to Solidity's `uint176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     */\n    function toUint176(uint256 value) internal pure returns (uint176) {\n        if (value > type(uint176).max) {\n            revert SafeCastOverflowedUintDowncast(176, value);\n        }\n        return uint176(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint168 from uint256, reverting on\n     * overflow (when the input is greater than largest uint168).\n     *\n     * Counterpart to Solidity's `uint168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     */\n    function toUint168(uint256 value) internal pure returns (uint168) {\n        if (value > type(uint168).max) {\n            revert SafeCastOverflowedUintDowncast(168, value);\n        }\n        return uint168(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint160 from uint256, reverting on\n     * overflow (when the input is greater than largest uint160).\n     *\n     * Counterpart to Solidity's `uint160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     */\n    function toUint160(uint256 value) internal pure returns (uint160) {\n        if (value > type(uint160).max) {\n            revert SafeCastOverflowedUintDowncast(160, value);\n        }\n        return uint160(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint152 from uint256, reverting on\n     * overflow (when the input is greater than largest uint152).\n     *\n     * Counterpart to Solidity's `uint152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     */\n    function toUint152(uint256 value) internal pure returns (uint152) {\n        if (value > type(uint152).max) {\n            revert SafeCastOverflowedUintDowncast(152, value);\n        }\n        return uint152(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint144 from uint256, reverting on\n     * overflow (when the input is greater than largest uint144).\n     *\n     * Counterpart to Solidity's `uint144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     */\n    function toUint144(uint256 value) internal pure returns (uint144) {\n        if (value > type(uint144).max) {\n            revert SafeCastOverflowedUintDowncast(144, value);\n        }\n        return uint144(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint136 from uint256, reverting on\n     * overflow (when the input is greater than largest uint136).\n     *\n     * Counterpart to Solidity's `uint136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     */\n    function toUint136(uint256 value) internal pure returns (uint136) {\n        if (value > type(uint136).max) {\n            revert SafeCastOverflowedUintDowncast(136, value);\n        }\n        return uint136(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        if (value > type(uint128).max) {\n            revert SafeCastOverflowedUintDowncast(128, value);\n        }\n        return uint128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint120 from uint256, reverting on\n     * overflow (when the input is greater than largest uint120).\n     *\n     * Counterpart to Solidity's `uint120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     */\n    function toUint120(uint256 value) internal pure returns (uint120) {\n        if (value > type(uint120).max) {\n            revert SafeCastOverflowedUintDowncast(120, value);\n        }\n        return uint120(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint112 from uint256, reverting on\n     * overflow (when the input is greater than largest uint112).\n     *\n     * Counterpart to Solidity's `uint112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     */\n    function toUint112(uint256 value) internal pure returns (uint112) {\n        if (value > type(uint112).max) {\n            revert SafeCastOverflowedUintDowncast(112, value);\n        }\n        return uint112(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint104 from uint256, reverting on\n     * overflow (when the input is greater than largest uint104).\n     *\n     * Counterpart to Solidity's `uint104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     */\n    function toUint104(uint256 value) internal pure returns (uint104) {\n        if (value > type(uint104).max) {\n            revert SafeCastOverflowedUintDowncast(104, value);\n        }\n        return uint104(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint96 from uint256, reverting on\n     * overflow (when the input is greater than largest uint96).\n     *\n     * Counterpart to Solidity's `uint96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     */\n    function toUint96(uint256 value) internal pure returns (uint96) {\n        if (value > type(uint96).max) {\n            revert SafeCastOverflowedUintDowncast(96, value);\n        }\n        return uint96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint88 from uint256, reverting on\n     * overflow (when the input is greater than largest uint88).\n     *\n     * Counterpart to Solidity's `uint88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     */\n    function toUint88(uint256 value) internal pure returns (uint88) {\n        if (value > type(uint88).max) {\n            revert SafeCastOverflowedUintDowncast(88, value);\n        }\n        return uint88(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint80 from uint256, reverting on\n     * overflow (when the input is greater than largest uint80).\n     *\n     * Counterpart to Solidity's `uint80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     */\n    function toUint80(uint256 value) internal pure returns (uint80) {\n        if (value > type(uint80).max) {\n            revert SafeCastOverflowedUintDowncast(80, value);\n        }\n        return uint80(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint72 from uint256, reverting on\n     * overflow (when the input is greater than largest uint72).\n     *\n     * Counterpart to Solidity's `uint72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     */\n    function toUint72(uint256 value) internal pure returns (uint72) {\n        if (value > type(uint72).max) {\n            revert SafeCastOverflowedUintDowncast(72, value);\n        }\n        return uint72(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint64 from uint256, reverting on\n     * overflow (when the input is greater than largest uint64).\n     *\n     * Counterpart to Solidity's `uint64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toUint64(uint256 value) internal pure returns (uint64) {\n        if (value > type(uint64).max) {\n            revert SafeCastOverflowedUintDowncast(64, value);\n        }\n        return uint64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint56 from uint256, reverting on\n     * overflow (when the input is greater than largest uint56).\n     *\n     * Counterpart to Solidity's `uint56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     */\n    function toUint56(uint256 value) internal pure returns (uint56) {\n        if (value > type(uint56).max) {\n            revert SafeCastOverflowedUintDowncast(56, value);\n        }\n        return uint56(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint48 from uint256, reverting on\n     * overflow (when the input is greater than largest uint48).\n     *\n     * Counterpart to Solidity's `uint48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     */\n    function toUint48(uint256 value) internal pure returns (uint48) {\n        if (value > type(uint48).max) {\n            revert SafeCastOverflowedUintDowncast(48, value);\n        }\n        return uint48(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint40 from uint256, reverting on\n     * overflow (when the input is greater than largest uint40).\n     *\n     * Counterpart to Solidity's `uint40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     */\n    function toUint40(uint256 value) internal pure returns (uint40) {\n        if (value > type(uint40).max) {\n            revert SafeCastOverflowedUintDowncast(40, value);\n        }\n        return uint40(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint32 from uint256, reverting on\n     * overflow (when the input is greater than largest uint32).\n     *\n     * Counterpart to Solidity's `uint32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toUint32(uint256 value) internal pure returns (uint32) {\n        if (value > type(uint32).max) {\n            revert SafeCastOverflowedUintDowncast(32, value);\n        }\n        return uint32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint24 from uint256, reverting on\n     * overflow (when the input is greater than largest uint24).\n     *\n     * Counterpart to Solidity's `uint24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     */\n    function toUint24(uint256 value) internal pure returns (uint24) {\n        if (value > type(uint24).max) {\n            revert SafeCastOverflowedUintDowncast(24, value);\n        }\n        return uint24(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint16 from uint256, reverting on\n     * overflow (when the input is greater than largest uint16).\n     *\n     * Counterpart to Solidity's `uint16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toUint16(uint256 value) internal pure returns (uint16) {\n        if (value > type(uint16).max) {\n            revert SafeCastOverflowedUintDowncast(16, value);\n        }\n        return uint16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint8 from uint256, reverting on\n     * overflow (when the input is greater than largest uint8).\n     *\n     * Counterpart to Solidity's `uint8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     */\n    function toUint8(uint256 value) internal pure returns (uint8) {\n        if (value > type(uint8).max) {\n            revert SafeCastOverflowedUintDowncast(8, value);\n        }\n        return uint8(value);\n    }\n\n    /**\n     * @dev Converts a signed int256 into an unsigned uint256.\n     *\n     * Requirements:\n     *\n     * - input must be greater than or equal to 0.\n     */\n    function toUint256(int256 value) internal pure returns (uint256) {\n        if (value < 0) {\n            revert SafeCastOverflowedIntToUint(value);\n        }\n        return uint256(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int248 from int256, reverting on\n     * overflow (when the input is less than smallest int248 or\n     * greater than largest int248).\n     *\n     * Counterpart to Solidity's `int248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     */\n    function toInt248(int256 value) internal pure returns (int248 downcasted) {\n        downcasted = int248(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(248, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int240 from int256, reverting on\n     * overflow (when the input is less than smallest int240 or\n     * greater than largest int240).\n     *\n     * Counterpart to Solidity's `int240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     */\n    function toInt240(int256 value) internal pure returns (int240 downcasted) {\n        downcasted = int240(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(240, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int232 from int256, reverting on\n     * overflow (when the input is less than smallest int232 or\n     * greater than largest int232).\n     *\n     * Counterpart to Solidity's `int232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     */\n    function toInt232(int256 value) internal pure returns (int232 downcasted) {\n        downcasted = int232(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(232, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int224 from int256, reverting on\n     * overflow (when the input is less than smallest int224 or\n     * greater than largest int224).\n     *\n     * Counterpart to Solidity's `int224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     */\n    function toInt224(int256 value) internal pure returns (int224 downcasted) {\n        downcasted = int224(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(224, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int216 from int256, reverting on\n     * overflow (when the input is less than smallest int216 or\n     * greater than largest int216).\n     *\n     * Counterpart to Solidity's `int216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     */\n    function toInt216(int256 value) internal pure returns (int216 downcasted) {\n        downcasted = int216(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(216, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int208 from int256, reverting on\n     * overflow (when the input is less than smallest int208 or\n     * greater than largest int208).\n     *\n     * Counterpart to Solidity's `int208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     */\n    function toInt208(int256 value) internal pure returns (int208 downcasted) {\n        downcasted = int208(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(208, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int200 from int256, reverting on\n     * overflow (when the input is less than smallest int200 or\n     * greater than largest int200).\n     *\n     * Counterpart to Solidity's `int200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     */\n    function toInt200(int256 value) internal pure returns (int200 downcasted) {\n        downcasted = int200(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(200, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int192 from int256, reverting on\n     * overflow (when the input is less than smallest int192 or\n     * greater than largest int192).\n     *\n     * Counterpart to Solidity's `int192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     */\n    function toInt192(int256 value) internal pure returns (int192 downcasted) {\n        downcasted = int192(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(192, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int184 from int256, reverting on\n     * overflow (when the input is less than smallest int184 or\n     * greater than largest int184).\n     *\n     * Counterpart to Solidity's `int184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     */\n    function toInt184(int256 value) internal pure returns (int184 downcasted) {\n        downcasted = int184(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(184, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int176 from int256, reverting on\n     * overflow (when the input is less than smallest int176 or\n     * greater than largest int176).\n     *\n     * Counterpart to Solidity's `int176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     */\n    function toInt176(int256 value) internal pure returns (int176 downcasted) {\n        downcasted = int176(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(176, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int168 from int256, reverting on\n     * overflow (when the input is less than smallest int168 or\n     * greater than largest int168).\n     *\n     * Counterpart to Solidity's `int168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     */\n    function toInt168(int256 value) internal pure returns (int168 downcasted) {\n        downcasted = int168(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(168, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int160 from int256, reverting on\n     * overflow (when the input is less than smallest int160 or\n     * greater than largest int160).\n     *\n     * Counterpart to Solidity's `int160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     */\n    function toInt160(int256 value) internal pure returns (int160 downcasted) {\n        downcasted = int160(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(160, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int152 from int256, reverting on\n     * overflow (when the input is less than smallest int152 or\n     * greater than largest int152).\n     *\n     * Counterpart to Solidity's `int152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     */\n    function toInt152(int256 value) internal pure returns (int152 downcasted) {\n        downcasted = int152(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(152, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int144 from int256, reverting on\n     * overflow (when the input is less than smallest int144 or\n     * greater than largest int144).\n     *\n     * Counterpart to Solidity's `int144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     */\n    function toInt144(int256 value) internal pure returns (int144 downcasted) {\n        downcasted = int144(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(144, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int136 from int256, reverting on\n     * overflow (when the input is less than smallest int136 or\n     * greater than largest int136).\n     *\n     * Counterpart to Solidity's `int136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     */\n    function toInt136(int256 value) internal pure returns (int136 downcasted) {\n        downcasted = int136(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(136, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int128 from int256, reverting on\n     * overflow (when the input is less than smallest int128 or\n     * greater than largest int128).\n     *\n     * Counterpart to Solidity's `int128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toInt128(int256 value) internal pure returns (int128 downcasted) {\n        downcasted = int128(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(128, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int120 from int256, reverting on\n     * overflow (when the input is less than smallest int120 or\n     * greater than largest int120).\n     *\n     * Counterpart to Solidity's `int120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     */\n    function toInt120(int256 value) internal pure returns (int120 downcasted) {\n        downcasted = int120(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(120, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int112 from int256, reverting on\n     * overflow (when the input is less than smallest int112 or\n     * greater than largest int112).\n     *\n     * Counterpart to Solidity's `int112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     */\n    function toInt112(int256 value) internal pure returns (int112 downcasted) {\n        downcasted = int112(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(112, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int104 from int256, reverting on\n     * overflow (when the input is less than smallest int104 or\n     * greater than largest int104).\n     *\n     * Counterpart to Solidity's `int104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     */\n    function toInt104(int256 value) internal pure returns (int104 downcasted) {\n        downcasted = int104(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(104, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int96 from int256, reverting on\n     * overflow (when the input is less than smallest int96 or\n     * greater than largest int96).\n     *\n     * Counterpart to Solidity's `int96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     */\n    function toInt96(int256 value) internal pure returns (int96 downcasted) {\n        downcasted = int96(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(96, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int88 from int256, reverting on\n     * overflow (when the input is less than smallest int88 or\n     * greater than largest int88).\n     *\n     * Counterpart to Solidity's `int88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     */\n    function toInt88(int256 value) internal pure returns (int88 downcasted) {\n        downcasted = int88(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(88, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int80 from int256, reverting on\n     * overflow (when the input is less than smallest int80 or\n     * greater than largest int80).\n     *\n     * Counterpart to Solidity's `int80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     */\n    function toInt80(int256 value) internal pure returns (int80 downcasted) {\n        downcasted = int80(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(80, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int72 from int256, reverting on\n     * overflow (when the input is less than smallest int72 or\n     * greater than largest int72).\n     *\n     * Counterpart to Solidity's `int72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     */\n    function toInt72(int256 value) internal pure returns (int72 downcasted) {\n        downcasted = int72(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(72, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int64 from int256, reverting on\n     * overflow (when the input is less than smallest int64 or\n     * greater than largest int64).\n     *\n     * Counterpart to Solidity's `int64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toInt64(int256 value) internal pure returns (int64 downcasted) {\n        downcasted = int64(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(64, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int56 from int256, reverting on\n     * overflow (when the input is less than smallest int56 or\n     * greater than largest int56).\n     *\n     * Counterpart to Solidity's `int56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     */\n    function toInt56(int256 value) internal pure returns (int56 downcasted) {\n        downcasted = int56(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(56, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int48 from int256, reverting on\n     * overflow (when the input is less than smallest int48 or\n     * greater than largest int48).\n     *\n     * Counterpart to Solidity's `int48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     */\n    function toInt48(int256 value) internal pure returns (int48 downcasted) {\n        downcasted = int48(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(48, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int40 from int256, reverting on\n     * overflow (when the input is less than smallest int40 or\n     * greater than largest int40).\n     *\n     * Counterpart to Solidity's `int40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     */\n    function toInt40(int256 value) internal pure returns (int40 downcasted) {\n        downcasted = int40(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(40, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int32 from int256, reverting on\n     * overflow (when the input is less than smallest int32 or\n     * greater than largest int32).\n     *\n     * Counterpart to Solidity's `int32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toInt32(int256 value) internal pure returns (int32 downcasted) {\n        downcasted = int32(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(32, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int24 from int256, reverting on\n     * overflow (when the input is less than smallest int24 or\n     * greater than largest int24).\n     *\n     * Counterpart to Solidity's `int24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     */\n    function toInt24(int256 value) internal pure returns (int24 downcasted) {\n        downcasted = int24(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(24, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int16 from int256, reverting on\n     * overflow (when the input is less than smallest int16 or\n     * greater than largest int16).\n     *\n     * Counterpart to Solidity's `int16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toInt16(int256 value) internal pure returns (int16 downcasted) {\n        downcasted = int16(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(16, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int8 from int256, reverting on\n     * overflow (when the input is less than smallest int8 or\n     * greater than largest int8).\n     *\n     * Counterpart to Solidity's `int8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     */\n    function toInt8(int256 value) internal pure returns (int8 downcasted) {\n        downcasted = int8(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(8, value);\n        }\n    }\n\n    /**\n     * @dev Converts an unsigned uint256 into a signed int256.\n     *\n     * Requirements:\n     *\n     * - input must be less than or equal to maxInt256.\n     */\n    function toInt256(uint256 value) internal pure returns (int256) {\n        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n        if (value > uint256(type(int256).max)) {\n            revert SafeCastOverflowedUintToInt(value);\n        }\n        return int256(value);\n    }\n\n    /**\n     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.\n     */\n    function toUint(bool b) internal pure returns (uint256 u) {\n        assembly (\"memory-safe\") {\n            u := iszero(iszero(b))\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/math/SignedMath.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\nimport {SafeCast} from \"./SafeCast.sol\";\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.\n     *\n     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.\n     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute\n     * one branch when needed, making this function more expensive.\n     */\n    function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {\n        unchecked {\n            // branchless ternary works because:\n            // b ^ (a ^ b) == a\n            // b ^ 0 == b\n            return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return ternary(a > b, a, b);\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return ternary(a < b, a, b);\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // Formula from the \"Bit Twiddling Hacks\" by Sean Eron Anderson.\n            // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,\n            // taking advantage of the most significant (or \"sign\" bit) in two's complement representation.\n            // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,\n            // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).\n            int256 mask = n >> 255;\n\n            // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.\n            return uint256((n + mask) ^ mask);\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Nonces.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides tracking nonces for addresses. Nonces will only increment.\n */\nabstract contract Nonces {\n    /**\n     * @dev The nonce used for an `account` is not the expected current nonce.\n     */\n    error InvalidAccountNonce(address account, uint256 currentNonce);\n\n    mapping(address account => uint256) private _nonces;\n\n    /**\n     * @dev Returns the next unused nonce for an address.\n     */\n    function nonces(address owner) public view virtual returns (uint256) {\n        return _nonces[owner];\n    }\n\n    /**\n     * @dev Consumes a nonce.\n     *\n     * Returns the current value and increments nonce.\n     */\n    function _useNonce(address owner) internal virtual returns (uint256) {\n        // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be\n        // decremented or reset. This guarantees that the nonce never overflows.\n        unchecked {\n            // It is important to do x++ and not ++x here.\n            return _nonces[owner]++;\n        }\n    }\n\n    /**\n     * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.\n     */\n    function _useCheckedNonce(address owner, uint256 nonce) internal virtual {\n        uint256 current = _useNonce(owner);\n        if (nonce != current) {\n            revert InvalidAccountNonce(owner, current);\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Panic.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Helper library for emitting standardized panic codes.\n *\n * ```solidity\n * contract Example {\n *      using Panic for uint256;\n *\n *      // Use any of the declared internal constants\n *      function foo() { Panic.GENERIC.panic(); }\n *\n *      // Alternatively\n *      function foo() { Panic.panic(Panic.GENERIC); }\n * }\n * ```\n *\n * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].\n *\n * _Available since v5.1._\n */\n// slither-disable-next-line unused-state\nlibrary Panic {\n    /// @dev generic / unspecified error\n    uint256 internal constant GENERIC = 0x00;\n    /// @dev used by the assert() builtin\n    uint256 internal constant ASSERT = 0x01;\n    /// @dev arithmetic underflow or overflow\n    uint256 internal constant UNDER_OVERFLOW = 0x11;\n    /// @dev division or modulo by zero\n    uint256 internal constant DIVISION_BY_ZERO = 0x12;\n    /// @dev enum conversion error\n    uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;\n    /// @dev invalid encoding in storage\n    uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;\n    /// @dev empty array pop\n    uint256 internal constant EMPTY_ARRAY_POP = 0x31;\n    /// @dev array out of bounds access\n    uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;\n    /// @dev resource error (too large allocation or too large array)\n    uint256 internal constant RESOURCE_ERROR = 0x41;\n    /// @dev calling invalid internal function\n    uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;\n\n    /// @dev Reverts with a panic code. Recommended to use with\n    /// the internal constants with predefined codes.\n    function panic(uint256 code) internal pure {\n        assembly (\"memory-safe\") {\n            mstore(0x00, 0x4e487b71)\n            mstore(0x20, code)\n            revert(0x1c, 0x24)\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/ShortStrings.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.20;\n\nimport {StorageSlot} from \"./StorageSlot.sol\";\n\n// | string  | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA   |\n// | length  | 0x                                                              BB |\ntype ShortString is bytes32;\n\n/**\n * @dev This library provides functions to convert short memory strings\n * into a `ShortString` type that can be used as an immutable variable.\n *\n * Strings of arbitrary length can be optimized using this library if\n * they are short enough (up to 31 bytes) by packing them with their\n * length (1 byte) in a single EVM word (32 bytes). Additionally, a\n * fallback mechanism can be used for every other case.\n *\n * Usage example:\n *\n * ```solidity\n * contract Named {\n *     using ShortStrings for *;\n *\n *     ShortString private immutable _name;\n *     string private _nameFallback;\n *\n *     constructor(string memory contractName) {\n *         _name = contractName.toShortStringWithFallback(_nameFallback);\n *     }\n *\n *     function name() external view returns (string memory) {\n *         return _name.toStringWithFallback(_nameFallback);\n *     }\n * }\n * ```\n */\nlibrary ShortStrings {\n    // Used as an identifier for strings longer than 31 bytes.\n    bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;\n\n    error StringTooLong(string str);\n    error InvalidShortString();\n\n    /**\n     * @dev Encode a string of at most 31 chars into a `ShortString`.\n     *\n     * This will trigger a `StringTooLong` error is the input string is too long.\n     */\n    function toShortString(string memory str) internal pure returns (ShortString) {\n        bytes memory bstr = bytes(str);\n        if (bstr.length > 31) {\n            revert StringTooLong(str);\n        }\n        return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));\n    }\n\n    /**\n     * @dev Decode a `ShortString` back to a \"normal\" string.\n     */\n    function toString(ShortString sstr) internal pure returns (string memory) {\n        uint256 len = byteLength(sstr);\n        // using `new string(len)` would work locally but is not memory safe.\n        string memory str = new string(32);\n        assembly (\"memory-safe\") {\n            mstore(str, len)\n            mstore(add(str, 0x20), sstr)\n        }\n        return str;\n    }\n\n    /**\n     * @dev Return the length of a `ShortString`.\n     */\n    function byteLength(ShortString sstr) internal pure returns (uint256) {\n        uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;\n        if (result > 31) {\n            revert InvalidShortString();\n        }\n        return result;\n    }\n\n    /**\n     * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.\n     */\n    function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {\n        if (bytes(value).length < 32) {\n            return toShortString(value);\n        } else {\n            StorageSlot.getStringSlot(store).value = value;\n            return ShortString.wrap(FALLBACK_SENTINEL);\n        }\n    }\n\n    /**\n     * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.\n     */\n    function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {\n        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n            return toString(value);\n        } else {\n            return store;\n        }\n    }\n\n    /**\n     * @dev Return the length of a string that was encoded to `ShortString` or written to storage using\n     * {setWithFallback}.\n     *\n     * WARNING: This will return the \"byte length\" of the string. This may not reflect the actual length in terms of\n     * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.\n     */\n    function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {\n        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {\n            return byteLength(value);\n        } else {\n            return bytes(store).length;\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/StorageSlot.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC-1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.\n *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n *     function _getImplementation() internal view returns (address) {\n *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n *     }\n *\n *     function _setImplementation(address newImplementation) internal {\n *         require(newImplementation.code.length > 0);\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n *\n * TIP: Consider using this library along with {SlotDerivation}.\n */\nlibrary StorageSlot {\n    struct AddressSlot {\n        address value;\n    }\n\n    struct BooleanSlot {\n        bool value;\n    }\n\n    struct Bytes32Slot {\n        bytes32 value;\n    }\n\n    struct Uint256Slot {\n        uint256 value;\n    }\n\n    struct Int256Slot {\n        int256 value;\n    }\n\n    struct StringSlot {\n        string value;\n    }\n\n    struct BytesSlot {\n        bytes value;\n    }\n\n    /**\n     * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n     */\n    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `Int256Slot` with member `value` located at `slot`.\n     */\n    function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns a `StringSlot` with member `value` located at `slot`.\n     */\n    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n     */\n    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := store.slot\n        }\n    }\n\n    /**\n     * @dev Returns a `BytesSlot` with member `value` located at `slot`.\n     */\n    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n     */\n    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n        assembly (\"memory-safe\") {\n            r.slot := store.slot\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Strings.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SafeCast} from \"./math/SafeCast.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    using SafeCast for *;\n\n    bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n    uint8 private constant ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev The `value` string doesn't fit in the specified `length`.\n     */\n    error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n    /**\n     * @dev The string being parsed contains characters that are not in scope of the given base.\n     */\n    error StringsInvalidChar();\n\n    /**\n     * @dev The string being parsed is not a properly formatted address.\n     */\n    error StringsInvalidAddressFormat();\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = Math.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            assembly (\"memory-safe\") {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                assembly (\"memory-safe\") {\n                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toStringSigned(int256 value) internal pure returns (string memory) {\n        return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, Math.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        uint256 localValue = value;\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = HEX_DIGITS[localValue & 0xf];\n            localValue >>= 4;\n        }\n        if (localValue != 0) {\n            revert StringsInsufficientHexLength(value, length);\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n     * representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal\n     * representation, according to EIP-55.\n     */\n    function toChecksumHexString(address addr) internal pure returns (string memory) {\n        bytes memory buffer = bytes(toHexString(addr));\n\n        // hash the hex part of buffer (skip length + 2 bytes, length 40)\n        uint256 hashValue;\n        assembly (\"memory-safe\") {\n            hashValue := shr(96, keccak256(add(buffer, 0x22), 40))\n        }\n\n        for (uint256 i = 41; i > 1; --i) {\n            // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)\n            if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {\n                // case shift by xoring with 0x20\n                buffer[i] ^= 0x20;\n            }\n            hashValue >>= 4;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n\n    /**\n     * @dev Parse a decimal string and returns the value as a `uint256`.\n     *\n     * Requirements:\n     * - The string must be formatted as `[0-9]*`\n     * - The result must fit into an `uint256` type\n     */\n    function parseUint(string memory input) internal pure returns (uint256) {\n        return parseUint(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseUint} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `[0-9]*`\n     * - The result must fit into an `uint256` type\n     */\n    function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {\n        (bool success, uint256 value) = tryParseUint(input, begin, end);\n        if (!success) revert StringsInvalidChar();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {\n        return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid\n     * character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseUint(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, uint256 value) {\n        if (end > bytes(input).length || begin > end) return (false, 0);\n        return _tryParseUintUncheckedBounds(input, begin, end);\n    }\n\n    /**\n     * @dev Implementation of {tryParseUint} that does not check bounds. Caller should make sure that\n     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.\n     */\n    function _tryParseUintUncheckedBounds(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) private pure returns (bool success, uint256 value) {\n        bytes memory buffer = bytes(input);\n\n        uint256 result = 0;\n        for (uint256 i = begin; i < end; ++i) {\n            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));\n            if (chr > 9) return (false, 0);\n            result *= 10;\n            result += chr;\n        }\n        return (true, result);\n    }\n\n    /**\n     * @dev Parse a decimal string and returns the value as a `int256`.\n     *\n     * Requirements:\n     * - The string must be formatted as `[-+]?[0-9]*`\n     * - The result must fit in an `int256` type.\n     */\n    function parseInt(string memory input) internal pure returns (int256) {\n        return parseInt(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `[-+]?[0-9]*`\n     * - The result must fit in an `int256` type.\n     */\n    function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {\n        (bool success, int256 value) = tryParseInt(input, begin, end);\n        if (!success) revert StringsInvalidChar();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if\n     * the result does not fit in a `int256`.\n     *\n     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.\n     */\n    function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {\n        return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);\n    }\n\n    uint256 private constant ABS_MIN_INT256 = 2 ** 255;\n\n    /**\n     * @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid\n     * character or if the result does not fit in a `int256`.\n     *\n     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.\n     */\n    function tryParseInt(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, int256 value) {\n        if (end > bytes(input).length || begin > end) return (false, 0);\n        return _tryParseIntUncheckedBounds(input, begin, end);\n    }\n\n    /**\n     * @dev Implementation of {tryParseInt} that does not check bounds. Caller should make sure that\n     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.\n     */\n    function _tryParseIntUncheckedBounds(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) private pure returns (bool success, int256 value) {\n        bytes memory buffer = bytes(input);\n\n        // Check presence of a negative sign.\n        bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty\n        bool positiveSign = sign == bytes1(\"+\");\n        bool negativeSign = sign == bytes1(\"-\");\n        uint256 offset = (positiveSign || negativeSign).toUint();\n\n        (bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);\n\n        if (absSuccess && absValue < ABS_MIN_INT256) {\n            return (true, negativeSign ? -int256(absValue) : int256(absValue));\n        } else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {\n            return (true, type(int256).min);\n        } else return (false, 0);\n    }\n\n    /**\n     * @dev Parse a hexadecimal string (with or without \"0x\" prefix), and returns the value as a `uint256`.\n     *\n     * Requirements:\n     * - The string must be formatted as `(0x)?[0-9a-fA-F]*`\n     * - The result must fit in an `uint256` type.\n     */\n    function parseHexUint(string memory input) internal pure returns (uint256) {\n        return parseHexUint(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseHexUint} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `(0x)?[0-9a-fA-F]*`\n     * - The result must fit in an `uint256` type.\n     */\n    function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {\n        (bool success, uint256 value) = tryParseHexUint(input, begin, end);\n        if (!success) revert StringsInvalidChar();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {\n        return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an\n     * invalid character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseHexUint(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, uint256 value) {\n        if (end > bytes(input).length || begin > end) return (false, 0);\n        return _tryParseHexUintUncheckedBounds(input, begin, end);\n    }\n\n    /**\n     * @dev Implementation of {tryParseHexUint} that does not check bounds. Caller should make sure that\n     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.\n     */\n    function _tryParseHexUintUncheckedBounds(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) private pure returns (bool success, uint256 value) {\n        bytes memory buffer = bytes(input);\n\n        // skip 0x prefix if present\n        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2(\"0x\"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty\n        uint256 offset = hasPrefix.toUint() * 2;\n\n        uint256 result = 0;\n        for (uint256 i = begin + offset; i < end; ++i) {\n            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));\n            if (chr > 15) return (false, 0);\n            result *= 16;\n            unchecked {\n                // Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).\n                // This guaratees that adding a value < 16 will not cause an overflow, hence the unchecked.\n                result += chr;\n            }\n        }\n        return (true, result);\n    }\n\n    /**\n     * @dev Parse a hexadecimal string (with or without \"0x\" prefix), and returns the value as an `address`.\n     *\n     * Requirements:\n     * - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`\n     */\n    function parseAddress(string memory input) internal pure returns (address) {\n        return parseAddress(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseAddress} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`\n     */\n    function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {\n        (bool success, address value) = tryParseAddress(input, begin, end);\n        if (!success) revert StringsInvalidAddressFormat();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly\n     * formatted address. See {parseAddress} requirements.\n     */\n    function tryParseAddress(string memory input) internal pure returns (bool success, address value) {\n        return tryParseAddress(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly\n     * formatted address. See {parseAddress} requirements.\n     */\n    function tryParseAddress(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, address value) {\n        if (end > bytes(input).length || begin > end) return (false, address(0));\n\n        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2(\"0x\"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty\n        uint256 expectedLength = 40 + hasPrefix.toUint() * 2;\n\n        // check that input is the correct length\n        if (end - begin == expectedLength) {\n            // length guarantees that this does not overflow, and value is at most type(uint160).max\n            (bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);\n            return (s, address(uint160(v)));\n        } else {\n            return (false, address(0));\n        }\n    }\n\n    function _tryParseChr(bytes1 chr) private pure returns (uint8) {\n        uint8 value = uint8(chr);\n\n        // Try to parse `chr`:\n        // - Case 1: [0-9]\n        // - Case 2: [a-f]\n        // - Case 3: [A-F]\n        // - otherwise not supported\n        unchecked {\n            if (value > 47 && value < 58) value -= 48;\n            else if (value > 96 && value < 103) value -= 87;\n            else if (value > 64 && value < 71) value -= 55;\n            else return type(uint8).max;\n        }\n\n        return value;\n    }\n\n    /**\n     * @dev Reads a bytes32 from a bytes array without bounds checking.\n     *\n     * NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the\n     * assembly block as such would prevent some optimizations.\n     */\n    function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {\n        // This is not memory safe in the general case, but all calls to this private function are within bounds.\n        assembly (\"memory-safe\") {\n            value := mload(add(buffer, add(0x20, offset)))\n        }\n    }\n}\n"
    },
    "contracts/ActivePool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"./dependencies/CheckContract.sol\";\nimport \"./dependencies/SendCollateral.sol\";\nimport \"./interfaces/IActivePool.sol\";\nimport \"./interfaces/IBorrowerOperations.sol\";\nimport \"./interfaces/ICollSurplusPool.sol\";\nimport \"./interfaces/IDefaultPool.sol\";\nimport \"./interfaces/IInterestRateManager.sol\";\nimport \"./interfaces/IStabilityPool.sol\";\n\n/*\n * The Active Pool holds the collateral and debt (but not mUSD tokens) for all active troves.\n *\n * When a trove is liquidated, it's collateral and debt are transferred from the Active Pool, to either the\n * Stability Pool, the Default Pool, or both, depending on the liquidation conditions.\n *\n */\ncontract ActivePool is\n    CheckContract,\n    IActivePool,\n    OwnableUpgradeable,\n    SendCollateral\n{\n    address public borrowerOperationsAddress;\n    address public collSurplusPoolAddress;\n    address public defaultPoolAddress;\n    IInterestRateManager public interestRateManager;\n    address public stabilityPoolAddress;\n    address public troveManagerAddress;\n\n    uint256 internal collateral; // deposited collateral tracker\n    uint256 internal principal;\n    uint256 internal interest;\n\n    function initialize() external initializer {\n        __Ownable_init(msg.sender);\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    // --- Fallback function ---\n\n    // This executes when the contract receives BTC\n    // solhint-disable no-complex-fallback\n    receive() external payable {\n        _requireCallerIsBorrowerOperationsOrDefaultPool();\n        collateral += msg.value;\n        emit ActivePoolCollateralBalanceUpdated(collateral);\n    }\n\n    // --- Contract setters ---\n\n    function setAddresses(\n        address _borrowerOperationsAddress,\n        address _collSurplusPoolAddress,\n        address _defaultPoolAddress,\n        address _interestRateManagerAddress,\n        address _stabilityPoolAddress,\n        address _troveManagerAddress\n    ) external onlyOwner {\n        checkContract(_borrowerOperationsAddress);\n        checkContract(_collSurplusPoolAddress);\n        checkContract(_defaultPoolAddress);\n        checkContract(_interestRateManagerAddress);\n        checkContract(_stabilityPoolAddress);\n        checkContract(_troveManagerAddress);\n\n        // slither-disable-start missing-zero-check\n        borrowerOperationsAddress = _borrowerOperationsAddress;\n        collSurplusPoolAddress = _collSurplusPoolAddress;\n        defaultPoolAddress = _defaultPoolAddress;\n        interestRateManager = IInterestRateManager(_interestRateManagerAddress);\n        stabilityPoolAddress = _stabilityPoolAddress;\n        troveManagerAddress = _troveManagerAddress;\n        // slither-disable-end missing-zero-check\n\n        emit BorrowerOperationsAddressChanged(_borrowerOperationsAddress);\n        emit CollSurplusPoolAddressChanged(_collSurplusPoolAddress);\n        emit DefaultPoolAddressChanged(_defaultPoolAddress);\n        emit InterestRateManagerAddressChanged(_interestRateManagerAddress);\n        emit StabilityPoolAddressChanged(_stabilityPoolAddress);\n        emit TroveManagerAddressChanged(_troveManagerAddress);\n\n        renounceOwnership();\n    }\n\n    function increaseDebt(\n        uint256 _principal,\n        uint256 _interest\n    ) external override {\n        _requireCallerIsBorrowerOperationsOrTroveManagerOrInterestRateManager();\n        principal += _principal;\n        interest += _interest;\n        emit ActivePoolDebtUpdated(principal, interest);\n    }\n\n    function decreaseDebt(\n        uint256 _principal,\n        uint256 _interest\n    ) external override {\n        _requireCallerIsBOorTroveMorSP();\n        principal -= _principal;\n        interest -= _interest;\n        emit ActivePoolDebtUpdated(principal, interest);\n    }\n\n    function sendCollateral(address _account, uint256 _amount) external {\n        _requireCallerIsBOorTroveMorSP();\n        collateral -= _amount;\n        emit ActivePoolCollateralBalanceUpdated(collateral);\n        emit CollateralSent(_account, _amount);\n\n        _sendCollateral(_account, _amount);\n    }\n\n    /*\n     * Returns the collateral state variable.\n     *\n     * Not necessarily equal to the the contract's raw collateral balance - collateral can be forcibly sent to contracts.\n     */\n    function getCollateralBalance() external view override returns (uint) {\n        return collateral;\n    }\n\n    function getDebt() external view override returns (uint) {\n        return principal + getInterest();\n    }\n\n    function getPrincipal() external view override returns (uint) {\n        return principal;\n    }\n\n    function getInterest() public view override returns (uint) {\n        return interest + interestRateManager.getAccruedInterest();\n    }\n\n    function _requireCallerIsBorrowerOperationsOrDefaultPool() internal view {\n        require(\n            msg.sender == borrowerOperationsAddress ||\n                msg.sender == defaultPoolAddress,\n            \"ActivePool: Caller is neither BorrowerOperations nor Default Pool\"\n        );\n    }\n\n    function _requireCallerIsBorrowerOperationsOrTroveManagerOrInterestRateManager()\n        internal\n        view\n    {\n        require(\n            msg.sender == borrowerOperationsAddress ||\n                msg.sender == troveManagerAddress ||\n                msg.sender == address(interestRateManager),\n            \"ActivePool: Caller must be BorrowerOperations, TroveManager, or InterestRateManager\"\n        );\n    }\n\n    function _requireCallerIsBOorTroveMorSP() internal view {\n        require(\n            msg.sender == borrowerOperationsAddress ||\n                msg.sender == troveManagerAddress ||\n                msg.sender == stabilityPoolAddress,\n            \"ActivePool: Caller is neither BorrowerOperations nor TroveManager nor StabilityPool\"\n        );\n    }\n}\n"
    },
    "contracts/BorrowerOperations.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"./dependencies/CheckContract.sol\";\nimport \"./dependencies/InterestRateMath.sol\";\nimport \"./dependencies/LiquityBase.sol\";\nimport \"./dependencies/SendCollateral.sol\";\nimport \"./interfaces/IBorrowerOperations.sol\";\nimport \"./interfaces/ICollSurplusPool.sol\";\nimport \"./interfaces/IGovernableVariables.sol\";\nimport \"./interfaces/IInterestRateManager.sol\";\nimport \"./interfaces/IPCV.sol\";\nimport \"./interfaces/ISortedTroves.sol\";\nimport \"./interfaces/ITroveManager.sol\";\nimport \"./token/IMUSD.sol\";\n\ncontract BorrowerOperations is\n    CheckContract,\n    IBorrowerOperations,\n    LiquityBase,\n    OwnableUpgradeable,\n    SendCollateral\n{\n    /* --- Variable container structs  ---\n\n    Used to hold, return and assign variables inside a function, in order to avoid the error:\n    \"CompilerError: Stack too deep\". */\n\n    struct LocalVariables_adjustTrove {\n        uint256 price;\n        uint256 collChange;\n        uint256 netDebtChange;\n        bool isCollIncrease;\n        uint256 debt;\n        uint256 coll;\n        uint256 oldICR;\n        uint256 newICR;\n        uint256 newTCR;\n        uint256 fee;\n        uint256 newColl;\n        uint256 newPrincipal;\n        uint256 newInterest;\n        uint256 stake;\n        uint256 interestOwed;\n        uint256 principalAdjustment;\n        uint256 interestAdjustment;\n        bool isRecoveryMode;\n        uint256 newNICR;\n        uint256 maxBorrowingCapacity;\n    }\n\n    struct LocalVariables_openTrove {\n        uint256 price;\n        uint256 fee;\n        uint256 netDebt;\n        uint256 compositeDebt;\n        uint256 ICR;\n        uint256 NICR;\n        uint256 stake;\n        uint256 arrayIndex;\n    }\n\n    struct LocalVariables_refinance {\n        uint256 price;\n        ITroveManager troveManagerCached;\n        IInterestRateManager interestRateManagerCached;\n        uint16 oldRate;\n        uint256 oldDebt;\n        uint256 amount;\n        uint256 fee;\n        uint256 newICR;\n        uint256 oldPrincipal;\n        uint16 newRate;\n        uint256 maxBorrowingCapacity;\n        uint256 newNICR;\n    }\n\n    struct ContractsCache {\n        ITroveManager troveManager;\n        IActivePool activePool;\n        IMUSD musd;\n        IInterestRateManager interestRateManager;\n    }\n\n    enum BorrowerOperation {\n        openTrove,\n        closeTrove,\n        adjustTrove,\n        refinanceTrove\n    }\n\n    string public constant name = \"BorrowerOperations\";\n    uint256 public constant MIN_NET_DEBT_MIN = 50e18;\n\n    // Connected contract declarations\n    ITroveManager public troveManager;\n    address public gasPoolAddress;\n    IGovernableVariables public governableVariables;\n    address public pcvAddress;\n    address public stabilityPoolAddress;\n    address public borrowerOperationsSignaturesAddress;\n    ICollSurplusPool public collSurplusPool;\n    IMUSD public musd;\n    IPCV public pcv;\n\n    // A doubly linked list of Troves, sorted by their collateral ratios\n    ISortedTroves public sortedTroves;\n\n    // refinancing fee is always a percentage of the borrowing (issuance) fee\n    uint8 public refinancingFeePercentage;\n\n    // Governable Variables\n\n    // Minimum amount of net mUSD debt a trove must have\n    uint256 public minNetDebt;\n    uint256 public proposedMinNetDebt;\n    uint256 public proposedMinNetDebtTime;\n\n    // Borrowering Rate\n    uint256 public borrowingRate; // expressed as a percentage in 1e18 precision\n    uint256 public proposedBorrowingRate;\n    uint256 public proposedBorrowingRateTime;\n\n    // Redemption Rate\n    uint256 public redemptionRate; // expressed as a percentage in 1e18 precision\n    uint256 public proposedRedemptionRate;\n    uint256 public proposedRedemptionRateTime;\n\n    modifier onlyGovernance() {\n        require(\n            msg.sender == pcv.council() || msg.sender == pcv.treasury(),\n            \"BorrowerOps: Only governance can call this function\"\n        );\n        _;\n    }\n\n    function initialize() external initializer {\n        __Ownable_init(msg.sender);\n        refinancingFeePercentage = 20;\n        minNetDebt = 1800e18;\n\n        borrowingRate = DECIMAL_PRECISION / 1000; // 0.1%\n        proposedBorrowingRate = borrowingRate;\n        // solhint-disable-next-line not-rely-on-time\n        proposedBorrowingRateTime = block.timestamp;\n\n        redemptionRate = (DECIMAL_PRECISION * 3) / 400; // 0.75%\n        proposedRedemptionRate = redemptionRate;\n        // solhint-disable-next-line not-rely-on-time\n        proposedRedemptionRateTime = block.timestamp;\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    // Calls on PCV behalf\n    function mintBootstrapLoanFromPCV(uint256 _musdToMint) external {\n        require(\n            msg.sender == pcvAddress,\n            \"BorrowerOperations: caller must be PCV\"\n        );\n        musd.mint(pcvAddress, _musdToMint);\n    }\n\n    function burnDebtFromPCV(uint256 _musdToBurn) external virtual {\n        require(\n            msg.sender == pcvAddress,\n            \"BorrowerOperations: caller must be PCV\"\n        );\n        musd.burn(pcvAddress, _musdToBurn);\n    }\n\n    // --- Borrower Trove Operations ---\n    function openTrove(\n        uint256 _debtAmount,\n        address _upperHint,\n        address _lowerHint\n    ) external payable override {\n        _openTrove(msg.sender, msg.sender, _debtAmount, _upperHint, _lowerHint);\n    }\n\n    // Send collateral to a trove\n    function addColl(\n        address _upperHint,\n        address _lowerHint\n    ) external payable override {\n        _adjustTrove(\n            msg.sender,\n            msg.sender,\n            msg.sender,\n            0,\n            0,\n            false,\n            _upperHint,\n            _lowerHint\n        );\n    }\n\n    // Send collateral to a trove. Called by only the Stability Pool.\n    function moveCollateralGainToTrove(\n        address _borrower,\n        address _upperHint,\n        address _lowerHint\n    ) external payable override {\n        _requireCallerIsStabilityPool();\n        _adjustTrove(\n            _borrower,\n            _borrower,\n            _borrower,\n            0,\n            0,\n            false,\n            _upperHint,\n            _lowerHint\n        );\n    }\n\n    // Withdraw collateral from a trove\n    function withdrawColl(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external override {\n        _adjustTrove(\n            msg.sender,\n            msg.sender,\n            msg.sender,\n            _amount,\n            0,\n            false,\n            _upperHint,\n            _lowerHint\n        );\n    }\n\n    // Withdraw mUSD tokens from a trove: mint new mUSD tokens to the owner, and increase the trove's principal accordingly\n    function withdrawMUSD(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external override {\n        _adjustTrove(\n            msg.sender,\n            msg.sender,\n            msg.sender,\n            0,\n            _amount,\n            true,\n            _upperHint,\n            _lowerHint\n        );\n    }\n\n    // Repay mUSD tokens to a Trove: Burn the repaid mUSD tokens, and reduce the trove's debt accordingly\n    function repayMUSD(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external override {\n        _adjustTrove(\n            msg.sender,\n            msg.sender,\n            msg.sender,\n            0,\n            _amount,\n            false,\n            _upperHint,\n            _lowerHint\n        );\n    }\n\n    function closeTrove() external override {\n        _closeTrove(msg.sender, msg.sender, msg.sender);\n    }\n\n    function refinance(\n        address _upperHint,\n        address _lowerHint\n    ) external override {\n        _refinance(msg.sender, _upperHint, _lowerHint);\n    }\n\n    /*\n     * adjustTrove(): Alongside a debt change, this function can perform either a collateral top-up or a collateral withdrawal.\n     *\n     * It therefore expects either a positive msg.value, or a positive _collWithdrawal argument.\n     *\n     * If both are positive, it will revert.\n     */\n    function adjustTrove(\n        uint256 _collWithdrawal,\n        uint256 _debtChange,\n        bool _isDebtIncrease,\n        address _upperHint,\n        address _lowerHint\n    ) external payable override {\n        _adjustTrove(\n            msg.sender,\n            msg.sender,\n            msg.sender,\n            _collWithdrawal,\n            _debtChange,\n            _isDebtIncrease,\n            _upperHint,\n            _lowerHint\n        );\n    }\n\n    // Claim remaining collateral from a redemption or from a liquidation with ICR > MCR in Recovery Mode\n    function claimCollateral() external override {\n        _claimCollateral(msg.sender, msg.sender);\n    }\n\n    function setAddresses(address[13] memory _addresses) external onlyOwner {\n        // This makes impossible to open a trove with zero withdrawn mUSD\n        assert(minNetDebt > 0);\n\n        uint addressLength = _addresses.length;\n        for (uint i = 0; i < addressLength; i++) {\n            checkContract(_addresses[i]);\n        }\n\n        // slither-disable-start missing-zero-check\n        activePool = IActivePool(_addresses[0]);\n        borrowerOperationsSignaturesAddress = _addresses[1];\n        collSurplusPool = ICollSurplusPool(_addresses[2]);\n        defaultPool = IDefaultPool(_addresses[3]);\n        gasPoolAddress = _addresses[4];\n        governableVariables = IGovernableVariables(_addresses[5]);\n        interestRateManager = IInterestRateManager(_addresses[6]);\n        musd = IMUSD(_addresses[7]);\n        pcv = IPCV(_addresses[8]);\n        pcvAddress = _addresses[8];\n        priceFeed = IPriceFeed(_addresses[9]);\n        sortedTroves = ISortedTroves(_addresses[10]);\n        stabilityPoolAddress = _addresses[11];\n        troveManager = ITroveManager(_addresses[12]);\n        // slither-disable-end missing-zero-check\n\n        emit ActivePoolAddressChanged(_addresses[0]);\n        emit BorrowerOperationsSignaturesAddressChanged(_addresses[1]);\n        emit CollSurplusPoolAddressChanged(_addresses[2]);\n        emit DefaultPoolAddressChanged(_addresses[3]);\n        emit GasPoolAddressChanged(_addresses[4]);\n        emit GovernableVariablesAddressChanged(_addresses[5]);\n        emit InterestRateManagerAddressChanged(_addresses[6]);\n        emit MUSDTokenAddressChanged(_addresses[7]);\n        emit PCVAddressChanged(_addresses[8]);\n        emit PriceFeedAddressChanged(_addresses[9]);\n        emit SortedTrovesAddressChanged(_addresses[10]);\n        emit StabilityPoolAddressChanged(_addresses[11]);\n        emit TroveManagerAddressChanged(_addresses[12]);\n\n        renounceOwnership();\n    }\n\n    function setRefinancingFeePercentage(\n        uint8 _refinanceFeePercentage\n    ) external override onlyGovernance {\n        require(\n            _refinanceFeePercentage <= 100,\n            \"BorrowerOps: Refinancing fee percentage must be <= 100\"\n        );\n        refinancingFeePercentage = _refinanceFeePercentage;\n        emit RefinancingFeePercentageChanged(_refinanceFeePercentage);\n    }\n\n    function proposeMinNetDebt(uint256 _minNetDebt) external onlyGovernance {\n        require(\n            _minNetDebt >= MIN_NET_DEBT_MIN,\n            \"Minimum Net Debt must be at least $50.\"\n        );\n        proposedMinNetDebt = _minNetDebt;\n        // solhint-disable-next-line not-rely-on-time\n        proposedMinNetDebtTime = block.timestamp;\n        emit MinNetDebtProposed(proposedMinNetDebt, proposedMinNetDebtTime);\n    }\n\n    function approveMinNetDebt() external onlyGovernance {\n        // solhint-disable not-rely-on-time\n        require(\n            block.timestamp >= proposedMinNetDebtTime + 7 days,\n            \"Must wait at least 7 days before approving a change to Minimum Net Debt\"\n        );\n        require(\n            proposedMinNetDebt >= MIN_NET_DEBT_MIN,\n            \"Minimum Net Debt must be at least $50.\"\n        );\n        minNetDebt = proposedMinNetDebt;\n        emit MinNetDebtChanged(minNetDebt);\n    }\n\n    function proposeBorrowingRate(uint256 _fee) external onlyGovernance {\n        require(_fee <= 1e18, \"Origination Fee must be at most 100%.\");\n        proposedBorrowingRate = _fee;\n        proposedBorrowingRateTime = block.timestamp;\n        emit BorrowingRateProposed(\n            proposedBorrowingRate,\n            proposedBorrowingRateTime\n        );\n    }\n\n    function approveBorrowingRate() external onlyGovernance {\n        // solhint-disable not-rely-on-time\n        require(\n            block.timestamp >= proposedBorrowingRateTime + 7 days,\n            \"Must wait at least 7 days before approving a change to Origination Fee\"\n        );\n        borrowingRate = proposedBorrowingRate;\n        emit BorrowingRateChanged(borrowingRate);\n    }\n\n    function proposeRedemptionRate(uint256 _rate) external onlyGovernance {\n        require(_rate <= 1e18, \"Redemption Rate must be at most 100%.\");\n        proposedRedemptionRate = _rate;\n        proposedRedemptionRateTime = block.timestamp;\n        emit RedemptionRateProposed(\n            proposedRedemptionRate,\n            proposedRedemptionRateTime\n        );\n    }\n\n    function approveRedemptionRate() external onlyGovernance {\n        // solhint-disable not-rely-on-time\n        require(\n            block.timestamp >= proposedRedemptionRateTime + 7 days,\n            \"Must wait at least 7 days before approving a change to Redemption Rate\"\n        );\n        redemptionRate = proposedRedemptionRate;\n        emit RedemptionRateChanged(redemptionRate);\n    }\n\n    function restrictedClaimCollateral(\n        address _borrower,\n        address _recipient\n    ) external {\n        _requireCallerIsBorrowerOperationsSignatures();\n        _claimCollateral(_borrower, _recipient);\n    }\n\n    function restrictedOpenTrove(\n        address _borrower,\n        address _recipient,\n        uint256 _debtAmount,\n        address _upperHint,\n        address _lowerHint\n    ) external payable {\n        _requireCallerIsBorrowerOperationsSignatures();\n        _openTrove(_borrower, _recipient, _debtAmount, _upperHint, _lowerHint);\n    }\n\n    function restrictedCloseTrove(\n        address _borrower,\n        address _caller,\n        address _recipient\n    ) external {\n        _requireCallerIsBorrowerOperationsSignatures();\n        _closeTrove(_borrower, _caller, _recipient);\n    }\n\n    function restrictedRefinance(\n        address _borrower,\n        address _upperHint,\n        address _lowerHint\n    ) external {\n        _requireCallerIsBorrowerOperationsSignatures();\n        _refinance(_borrower, _upperHint, _lowerHint);\n    }\n\n    function restrictedAdjustTrove(\n        address _borrower,\n        address _recipient,\n        address _caller,\n        uint256 _collWithdrawal,\n        uint256 _mUSDChange,\n        bool _isDebtIncrease,\n        address _upperHint,\n        address _lowerHint\n    ) external payable {\n        _requireCallerIsBorrowerOperationsSignatures();\n        _adjustTrove(\n            _borrower,\n            _recipient,\n            _caller,\n            _collWithdrawal,\n            _mUSDChange,\n            _isDebtIncrease,\n            _upperHint,\n            _lowerHint\n        );\n    }\n\n    function getRedemptionRate(\n        uint256 _collateralDrawn\n    ) external view returns (uint256) {\n        uint256 fee = (redemptionRate * _collateralDrawn) / DECIMAL_PRECISION;\n        require(\n            fee < _collateralDrawn,\n            \"BorrowerOperations: Fee would eat up all returned collateral\"\n        );\n        return fee;\n    }\n\n    function getBorrowingFee(uint256 _debt) public view returns (uint) {\n        return (_debt * borrowingRate) / DECIMAL_PRECISION;\n    }\n\n    // Burn the specified amount of MUSD from _account and decreases the total active debt\n    function _repayMUSD(\n        IActivePool _activePool,\n        IMUSD _musd,\n        address _account,\n        uint256 _principal,\n        uint256 _interest\n    ) internal {\n        _activePool.decreaseDebt(_principal, _interest);\n        _musd.burn(_account, _principal + _interest);\n    }\n\n    function _moveTokensAndCollateralfromAdjustment(\n        IActivePool _activePool,\n        IMUSD _musd,\n        address _caller,\n        address _recipient,\n        uint256 _collChange,\n        bool _isCollIncrease,\n        uint256 _principalChange,\n        uint256 _interestChange,\n        bool _isDebtIncrease,\n        uint256 _netDebtChange\n    ) internal {\n        if (_isDebtIncrease) {\n            _withdrawMUSD(\n                _activePool,\n                _musd,\n                _recipient,\n                _principalChange,\n                _netDebtChange\n            );\n        } else {\n            _repayMUSD(\n                _activePool,\n                _musd,\n                _caller,\n                _principalChange,\n                _interestChange\n            );\n        }\n\n        if (_isCollIncrease) {\n            _activePoolAddColl(_activePool, _collChange);\n        } else {\n            _activePool.sendCollateral(_recipient, _collChange);\n        }\n    }\n\n    // Send collateral to Active Pool and increase its recorded collateral balance\n    function _activePoolAddColl(\n        IActivePool _activePool,\n        uint256 _amount\n    ) internal {\n        _sendCollateral(address(_activePool), _amount);\n    }\n\n    // Update trove's coll and debt based on whether they increase or decrease\n    function _updateTroveFromAdjustment(\n        ITroveManager _troveManager,\n        address _borrower,\n        uint256 _collChange,\n        bool _isCollIncrease,\n        uint256 _debtChange,\n        bool _isDebtIncrease\n    )\n        internal\n        returns (uint256 newColl, uint256 newPrincipal, uint256 newInterest)\n    {\n        newColl = (_isCollIncrease)\n            ? _troveManager.increaseTroveColl(_borrower, _collChange)\n            : _troveManager.decreaseTroveColl(_borrower, _collChange);\n\n        if (_isDebtIncrease) {\n            newPrincipal = _troveManager.increaseTroveDebt(\n                _borrower,\n                _debtChange\n            );\n        } else {\n            (newPrincipal, newInterest) = _troveManager.decreaseTroveDebt(\n                _borrower,\n                _debtChange\n            );\n        }\n    }\n\n    // --- Helper functions ---\n\n    function _triggerBorrowingFee(\n        IMUSD _musd,\n        uint256 _amount\n    ) internal returns (uint) {\n        uint256 fee = getBorrowingFee(_amount);\n\n        // Send fee to PCV contract\n        _musd.mint(pcvAddress, fee);\n        return fee;\n    }\n\n    function _openTrove(\n        address _borrower,\n        address _recipient,\n        uint256 _debtAmount,\n        address _upperHint,\n        address _lowerHint\n    ) internal {\n        ContractsCache memory contractsCache = ContractsCache(\n            troveManager,\n            activePool,\n            musd,\n            interestRateManager\n        );\n        contractsCache.troveManager.updateSystemInterest();\n        // slither-disable-next-line uninitialized-local\n        LocalVariables_openTrove memory vars;\n\n        vars.price = priceFeed.fetchPrice();\n        bool isRecoveryMode = _checkRecoveryMode(vars.price);\n\n        _requireTroveisNotActive(contractsCache.troveManager, _borrower);\n\n        vars.netDebt = _debtAmount;\n\n        if (\n            !isRecoveryMode &&\n            !governableVariables.isAccountFeeExempt(_borrower)\n        ) {\n            vars.fee = _triggerBorrowingFee(contractsCache.musd, _debtAmount);\n            vars.netDebt += vars.fee;\n        }\n\n        _requireAtLeastMinNetDebt(vars.netDebt);\n\n        // ICR is based on the composite debt, i.e. the requested amount + borrowing fee + gas comp.\n        vars.compositeDebt = _getCompositeDebt(vars.netDebt);\n\n        // if BTC overwrite the asset value\n        vars.ICR = LiquityMath._computeCR(\n            msg.value,\n            vars.compositeDebt,\n            vars.price\n        );\n        vars.NICR = LiquityMath._computeNominalCR(\n            msg.value,\n            vars.compositeDebt\n        );\n\n        if (isRecoveryMode) {\n            _requireICRisAboveCCR(vars.ICR);\n        } else {\n            _requireICRisAboveMCR(vars.ICR);\n            uint256 newTCR = _getNewTCRFromTroveChange(\n                msg.value,\n                true,\n                vars.compositeDebt,\n                true,\n                vars.price\n            ); // bools: coll increase, debt increase\n            _requireNewTCRisAboveCCR(newTCR);\n        }\n\n        contractsCache.troveManager.setTroveInterestRate(\n            _borrower,\n            contractsCache.interestRateManager.interestRate()\n        );\n\n        // Set the trove struct's properties\n        contractsCache.troveManager.setTroveStatus(\n            _borrower,\n            ITroveManager.Status.active\n        );\n        // slither-disable-next-line unused-return\n        contractsCache.troveManager.increaseTroveColl(_borrower, msg.value);\n        // slither-disable-next-line unused-return\n        contractsCache.troveManager.increaseTroveDebt(\n            _borrower,\n            vars.compositeDebt\n        );\n\n        // solhint-disable not-rely-on-time\n        contractsCache.troveManager.setTroveLastInterestUpdateTime(\n            _borrower,\n            block.timestamp\n        );\n        // solhint-enable not-rely-on-time\n\n        // Set trove's max borrowing capacity to the amount that would put it at 110% ICR\n        uint256 maxBorrowingCapacity = _calculateMaxBorrowingCapacity(\n            msg.value,\n            vars.price\n        );\n        contractsCache.troveManager.setTroveMaxBorrowingCapacity(\n            _borrower,\n            maxBorrowingCapacity\n        );\n\n        contractsCache.troveManager.updateTroveRewardSnapshots(_borrower);\n        vars.stake = contractsCache.troveManager.updateStakeAndTotalStakes(\n            _borrower\n        );\n\n        sortedTroves.insert(_borrower, vars.NICR, _upperHint, _lowerHint);\n        vars.arrayIndex = contractsCache.troveManager.addTroveOwnerToArray(\n            _borrower\n        );\n\n        /*\n         * Move the collateral to the Active Pool, and mint the amount to the borrower\n         * If the user has insuffient tokens to do the transfer to the Active Pool an error will cause the transaction to revert.\n         */\n        _activePoolAddColl(contractsCache.activePool, msg.value);\n        _withdrawMUSD(\n            contractsCache.activePool,\n            contractsCache.musd,\n            _recipient,\n            _debtAmount,\n            vars.netDebt\n        );\n\n        // Move the mUSD gas compensation to the Gas Pool\n        _withdrawMUSD(\n            contractsCache.activePool,\n            contractsCache.musd,\n            gasPoolAddress,\n            MUSD_GAS_COMPENSATION,\n            MUSD_GAS_COMPENSATION\n        );\n\n        // slither-disable-start reentrancy-events\n        emit TroveCreated(_borrower, vars.arrayIndex);\n\n        emit TroveUpdated(\n            _borrower,\n            vars.compositeDebt,\n            0,\n            msg.value,\n            vars.stake,\n            uint8(BorrowerOperation.openTrove)\n        );\n        emit BorrowingFeePaid(_borrower, vars.fee);\n        // slither-disable-end reentrancy-events\n    }\n\n    function _adjustTrove(\n        address _borrower,\n        address _recipient,\n        address _caller,\n        uint256 _collWithdrawal,\n        uint256 _mUSDChange,\n        bool _isDebtIncrease,\n        address _upperHint,\n        address _lowerHint\n    ) internal {\n        ContractsCache memory contractsCache = ContractsCache(\n            troveManager,\n            activePool,\n            musd,\n            interestRateManager\n        );\n\n        contractsCache.troveManager.updateSystemAndTroveInterest(_borrower);\n\n        // slither-disable-next-line uninitialized-local\n        LocalVariables_adjustTrove memory vars;\n\n        // Snapshot interest and principal before repayment so we can correctly adjust the active pool\n        vars.interestOwed = contractsCache.troveManager.getTroveInterestOwed(\n            _borrower\n        );\n\n        (vars.principalAdjustment, vars.interestAdjustment) = InterestRateMath\n            .calculateDebtAdjustment(vars.interestOwed, _mUSDChange);\n\n        vars.price = priceFeed.fetchPrice();\n        vars.isRecoveryMode = _checkRecoveryMode(vars.price);\n\n        if (_isDebtIncrease) {\n            _requireNonZeroDebtChange(_mUSDChange);\n        }\n        _requireSingularCollChange(_collWithdrawal, msg.value);\n        _requireNonZeroAdjustment(_collWithdrawal, _mUSDChange, msg.value);\n        _requireTroveisActive(contractsCache.troveManager, _borrower);\n\n        /*\n         * Confirm the operation is either a borrower adjusting their own trove (either directly or through\n         * a signature), or a pure collateral transfer from the Stability Pool to a trove\n         */\n        assert(\n            msg.sender == _borrower ||\n                (msg.sender == stabilityPoolAddress &&\n                    msg.value > 0 &&\n                    _mUSDChange == 0) ||\n                msg.sender == address(this) ||\n                msg.sender == borrowerOperationsSignaturesAddress\n        );\n\n        // Get the collChange based on whether or not collateral was sent in the transaction\n        (vars.collChange, vars.isCollIncrease) = _getCollChange(\n            msg.value,\n            _collWithdrawal\n        );\n\n        vars.netDebtChange = _mUSDChange;\n\n        // If the adjustment incorporates a principal increase and system is in Normal Mode, then trigger a borrowing fee\n        if (_isDebtIncrease && !vars.isRecoveryMode) {\n            vars.fee = _triggerBorrowingFee(contractsCache.musd, _mUSDChange);\n            vars.netDebtChange += vars.fee; // The raw debt change includes the fee\n        }\n\n        vars.debt = contractsCache.troveManager.getTroveDebt(_borrower);\n        vars.coll = contractsCache.troveManager.getTroveColl(_borrower);\n\n        // Get the trove's old ICR before the adjustment, and what its new ICR will be after the adjustment\n        vars.oldICR = LiquityMath._computeCR(vars.coll, vars.debt, vars.price);\n        vars.newICR = _getNewICRFromTroveChange(\n            vars.coll,\n            vars.debt,\n            vars.collChange,\n            vars.isCollIncrease,\n            vars.netDebtChange,\n            _isDebtIncrease,\n            vars.price\n        );\n        assert(_collWithdrawal <= vars.coll);\n\n        // Check the adjustment satisfies all conditions for the current system mode\n        _requireValidAdjustmentInCurrentMode(\n            vars.isRecoveryMode,\n            _collWithdrawal,\n            _isDebtIncrease,\n            vars\n        );\n\n        vars.maxBorrowingCapacity = contractsCache\n            .troveManager\n            .getTroveMaxBorrowingCapacity(_borrower);\n        if (_isDebtIncrease) {\n            _requireHasBorrowingCapacity(vars);\n        }\n\n        // When the adjustment is a debt repayment, check it's a valid amount and that the caller has enough mUSD\n        if (!_isDebtIncrease && _mUSDChange > 0) {\n            _requireAtLeastMinNetDebt(\n                _getNetDebt(vars.debt) - vars.netDebtChange\n            );\n            _requireValidMUSDRepayment(vars.debt, vars.netDebtChange);\n            _requireSufficientMUSDBalance(_caller, vars.netDebtChange);\n        }\n\n        (\n            vars.newColl,\n            vars.newPrincipal,\n            vars.newInterest\n        ) = _updateTroveFromAdjustment(\n            contractsCache.troveManager,\n            _borrower,\n            vars.collChange,\n            vars.isCollIncrease,\n            vars.netDebtChange,\n            _isDebtIncrease\n        );\n        vars.stake = contractsCache.troveManager.updateStakeAndTotalStakes(\n            _borrower\n        );\n\n        // If collateral was withdrawn, update the maxBorrowingCapacity\n        if (!vars.isCollIncrease && vars.collChange > 0) {\n            uint256 newMaxBorrowingCapacity = _calculateMaxBorrowingCapacity(\n                vars.newColl,\n                vars.price\n            );\n\n            uint256 currentMaxBorrowingCapacity = contractsCache\n                .troveManager\n                .getTroveMaxBorrowingCapacity(_borrower);\n\n            uint256 finalMaxBorrowingCapacity = LiquityMath._min(\n                currentMaxBorrowingCapacity,\n                newMaxBorrowingCapacity\n            );\n\n            contractsCache.troveManager.setTroveMaxBorrowingCapacity(\n                _borrower,\n                finalMaxBorrowingCapacity\n            );\n        }\n\n        // Re-insert trove in to the sorted list\n        vars.newNICR = LiquityMath._computeNominalCR(\n            vars.newColl,\n            vars.newPrincipal\n        );\n        sortedTroves.reInsert(_borrower, vars.newNICR, _upperHint, _lowerHint);\n\n        // slither-disable-next-line reentrancy-events\n        emit TroveUpdated(\n            _borrower,\n            vars.newPrincipal,\n            vars.newInterest,\n            vars.newColl,\n            vars.stake,\n            uint8(BorrowerOperation.adjustTrove)\n        );\n        // slither-disable-next-line reentrancy-events\n        emit BorrowingFeePaid(_borrower, vars.fee);\n\n        // Use the unmodified _mUSDChange here, as we don't send the fee to the user\n        _moveTokensAndCollateralfromAdjustment(\n            contractsCache.activePool,\n            contractsCache.musd,\n            _caller,\n            _recipient,\n            vars.collChange,\n            vars.isCollIncrease,\n            _isDebtIncrease ? _mUSDChange : vars.principalAdjustment,\n            vars.interestAdjustment,\n            _isDebtIncrease,\n            vars.netDebtChange\n        );\n    }\n\n    function _closeTrove(\n        address _borrower,\n        address _caller,\n        address _recipient\n    ) internal {\n        ITroveManager troveManagerCached = troveManager;\n        troveManagerCached.updateSystemAndTroveInterest(_borrower);\n\n        IActivePool activePoolCached = activePool;\n        IMUSD musdTokenCached = musd;\n        bool canMint = musdTokenCached.mintList(address(this));\n\n        _requireTroveisActive(troveManagerCached, _borrower);\n        uint256 price = priceFeed.fetchPrice();\n        if (canMint) {\n            _requireNotInRecoveryMode(price);\n        }\n\n        uint256 coll = troveManagerCached.getTroveColl(_borrower);\n        uint256 debt = troveManagerCached.getTroveDebt(_borrower);\n        uint256 interestOwed = troveManagerCached.getTroveInterestOwed(\n            _borrower\n        );\n\n        _requireSufficientMUSDBalance(_caller, debt - MUSD_GAS_COMPENSATION);\n        if (canMint) {\n            uint256 newTCR = _getNewTCRFromTroveChange(\n                coll,\n                false,\n                debt,\n                false,\n                price\n            );\n            _requireNewTCRisAboveCCR(newTCR);\n        }\n\n        troveManagerCached.removeStake(_borrower);\n        troveManagerCached.closeTrove(_borrower);\n\n        // slither-disable-next-line reentrancy-events\n        emit TroveUpdated(\n            _borrower,\n            0,\n            0,\n            0,\n            0,\n            uint8(BorrowerOperation.closeTrove)\n        );\n\n        // Decrease the active pool debt by the principal (subtracting interestOwed from the total debt)\n        activePoolCached.decreaseDebt(\n            debt - MUSD_GAS_COMPENSATION - interestOwed,\n            interestOwed\n        );\n\n        // Burn the repaid mUSD from the user's balance\n        musdTokenCached.burn(_caller, debt - MUSD_GAS_COMPENSATION);\n\n        // Burn the gas compensation from the gas pool\n        _repayMUSD(\n            activePoolCached,\n            musdTokenCached,\n            gasPoolAddress,\n            MUSD_GAS_COMPENSATION,\n            0\n        );\n\n        // Send the collateral back to the user\n        activePoolCached.sendCollateral(_recipient, coll);\n    }\n\n    function _refinance(\n        address _borrower,\n        address _upperHint,\n        address _lowerHint\n    ) internal {\n        // slither-disable-next-line uninitialized-local\n        LocalVariables_refinance memory vars;\n        vars.price = priceFeed.fetchPrice();\n        vars.troveManagerCached = troveManager;\n        vars.troveManagerCached.updateSystemAndTroveInterest(_borrower);\n\n        _requireNotInRecoveryMode(vars.price);\n        _requireTroveisActive(vars.troveManagerCached, _borrower);\n\n        vars.interestRateManagerCached = interestRateManager;\n\n        vars.oldRate = vars.troveManagerCached.getTroveInterestRate(_borrower);\n        vars.oldDebt = _getNetDebt(\n            vars.troveManagerCached.getTroveDebt(_borrower)\n        );\n        vars.amount = (refinancingFeePercentage * vars.oldDebt) / 100;\n        uint256 fee = governableVariables.isAccountFeeExempt(_borrower)\n            ? 0\n            : _triggerBorrowingFee(musd, vars.amount);\n        // slither-disable-next-line unused-return\n        vars.troveManagerCached.increaseTroveDebt(_borrower, fee);\n        if (fee > 0) {\n            activePool.increaseDebt(fee, 0);\n        }\n\n        // slither-disable-start unused-return\n        (\n            uint256 newColl,\n            uint256 newPrincipal,\n            uint256 newInterest,\n            ,\n            ,\n\n        ) = vars.troveManagerCached.getEntireDebtAndColl(_borrower);\n        // slither-disable-end unused-return\n\n        vars.newICR = LiquityMath._computeCR(\n            newColl,\n            newPrincipal + newInterest,\n            vars.price\n        );\n        _requireICRisAboveMCR(vars.newICR);\n        _requireNewTCRisAboveCCR(vars.troveManagerCached.getTCR(vars.price));\n\n        vars.oldPrincipal = vars.troveManagerCached.getTrovePrincipal(\n            _borrower\n        );\n\n        vars.interestRateManagerCached.removePrincipal(\n            vars.oldPrincipal,\n            vars.oldRate\n        );\n        vars.newRate = vars.interestRateManagerCached.interestRate();\n        vars.interestRateManagerCached.addPrincipal(\n            vars.oldPrincipal,\n            vars.newRate\n        );\n\n        vars.troveManagerCached.setTroveInterestRate(\n            _borrower,\n            vars.interestRateManagerCached.interestRate()\n        );\n\n        vars.maxBorrowingCapacity = _calculateMaxBorrowingCapacity(\n            vars.troveManagerCached.getTroveColl(_borrower),\n            vars.price\n        );\n        vars.troveManagerCached.setTroveMaxBorrowingCapacity(\n            _borrower,\n            vars.maxBorrowingCapacity\n        );\n\n        // Re-insert trove in to the sorted list\n        vars.newNICR = LiquityMath._computeNominalCR(newColl, newPrincipal);\n        sortedTroves.reInsert(_borrower, vars.newNICR, _upperHint, _lowerHint);\n\n        // slither-disable-start reentrancy-events\n        emit RefinancingFeePaid(_borrower, fee);\n        emit TroveUpdated(\n            _borrower,\n            newPrincipal,\n            newInterest,\n            newColl,\n            vars.troveManagerCached.updateStakeAndTotalStakes(_borrower),\n            uint8(BorrowerOperation.refinanceTrove)\n        );\n        // slither-disable-end reentrancy-events\n    }\n\n    // Issue the specified amount of mUSD to _account and increases the total active debt (_netDebtIncrease potentially includes a MUSDFee)\n    function _withdrawMUSD(\n        IActivePool _activePool,\n        IMUSD _musd,\n        address _account,\n        uint256 _debtAmount,\n        uint256 _netDebtIncrease\n    ) internal {\n        _activePool.increaseDebt(_netDebtIncrease, 0);\n        _musd.mint(_account, _debtAmount);\n    }\n\n    function _claimCollateral(address _borrower, address _recipient) internal {\n        troveManager.updateSystemInterest();\n\n        // send collateral from CollSurplus Pool to owner\n        collSurplusPool.claimColl(_borrower, _recipient);\n    }\n\n    function _requireCallerIsBorrowerOperationsSignatures() internal view {\n        require(\n            msg.sender == borrowerOperationsSignaturesAddress,\n            \"BorrowerOps: Caller is not BorrowerOperationsSignatures\"\n        );\n    }\n\n    function _requireNotInRecoveryMode(uint256 _price) internal view {\n        require(\n            !_checkRecoveryMode(_price),\n            \"BorrowerOps: Operation not permitted during Recovery Mode\"\n        );\n    }\n\n    function _requireTroveisNotActive(\n        ITroveManager _troveManager,\n        address _borrower\n    ) internal view {\n        ITroveManager.Status status = _troveManager.getTroveStatus(_borrower);\n        require(\n            status != ITroveManager.Status.active,\n            \"BorrowerOps: Trove is active\"\n        );\n    }\n\n    function _getNewTCRFromTroveChange(\n        uint256 _collChange,\n        bool _isCollIncrease,\n        uint256 _debtChange,\n        bool _isDebtIncrease,\n        uint256 _price\n    ) internal view returns (uint) {\n        uint256 totalColl = getEntireSystemColl();\n        uint256 totalDebt = getEntireSystemDebt();\n\n        totalColl = _isCollIncrease\n            ? totalColl + _collChange\n            : totalColl - _collChange;\n        totalDebt = _isDebtIncrease\n            ? totalDebt + _debtChange\n            : totalDebt - _debtChange;\n\n        uint256 newTCR = LiquityMath._computeCR(totalColl, totalDebt, _price);\n        return newTCR;\n    }\n\n    function _requireCallerIsStabilityPool() internal view {\n        require(\n            msg.sender == stabilityPoolAddress,\n            \"BorrowerOps: Caller is not Stability Pool\"\n        );\n    }\n\n    function _requireTroveisActive(\n        ITroveManager _troveManager,\n        address _borrower\n    ) internal view {\n        ITroveManager.Status status = _troveManager.getTroveStatus(_borrower);\n\n        require(\n            status == ITroveManager.Status.active,\n            \"BorrowerOps: Trove does not exist or is closed\"\n        );\n    }\n\n    /*\n     * In Normal Mode, ensure:\n     *\n     * - The new ICR is above MCR\n     * - The adjustment won't pull the TCR below CCR\n     */\n    function _requireValidAdjustmentInNormalMode(\n        bool _isDebtIncrease,\n        LocalVariables_adjustTrove memory _vars\n    ) internal view {\n        _requireICRisAboveMCR(_vars.newICR);\n        _vars.newTCR = _getNewTCRFromTroveChange(\n            _vars.collChange,\n            _vars.isCollIncrease,\n            _vars.netDebtChange,\n            _isDebtIncrease,\n            _vars.price\n        );\n        _requireNewTCRisAboveCCR(_vars.newTCR);\n    }\n\n    function _requireValidAdjustmentInCurrentMode(\n        bool _isRecoveryMode,\n        uint256 _collWithdrawal,\n        bool _isDebtIncrease,\n        LocalVariables_adjustTrove memory _vars\n    ) internal view {\n        if (_isRecoveryMode) {\n            _requireValidAdjustmentInRecoveryMode(\n                _collWithdrawal,\n                _isDebtIncrease,\n                _vars\n            );\n        } else {\n            _requireValidAdjustmentInNormalMode(_isDebtIncrease, _vars);\n        }\n    }\n\n    function _requireSufficientMUSDBalance(\n        address _borrower,\n        uint256 _debtRepayment\n    ) internal view {\n        require(\n            musd.balanceOf(_borrower) >= _debtRepayment,\n            \"BorrowerOps: Caller doesnt have enough mUSD to make repayment\"\n        );\n    }\n\n    function _requireAtLeastMinNetDebt(uint256 _netDebt) internal view {\n        require(\n            _netDebt >= minNetDebt,\n            \"BorrowerOps: Trove's net debt must be greater than minimum\"\n        );\n    }\n\n    function _requireValidMUSDRepayment(\n        uint256 _currentDebt,\n        uint256 _debtRepayment\n    ) internal pure {\n        require(\n            _debtRepayment <= _currentDebt - MUSD_GAS_COMPENSATION,\n            \"BorrowerOps: Amount repaid must not be larger than the Trove's debt\"\n        );\n    }\n\n    /*\n     * In Recovery Mode, only allow:\n     *\n     * - Pure collateral top-up\n     * - Pure debt repayment\n     * - Collateral top-up with debt repayment\n     * - A debt increase combined with a collateral top-up which makes the ICR\n     * >= 150% and improves the ICR (and by extension improves the TCR).\n     */\n    function _requireValidAdjustmentInRecoveryMode(\n        uint256 _collWithdrawal,\n        bool _isDebtIncrease,\n        LocalVariables_adjustTrove memory _vars\n    ) internal pure {\n        _requireNoCollWithdrawal(_collWithdrawal);\n        if (_isDebtIncrease) {\n            _requireICRisAboveCCR(_vars.newICR);\n            _requireNewICRisAboveOldICR(_vars.newICR, _vars.oldICR);\n        }\n    }\n\n    function _getCollChange(\n        uint256 _collReceived,\n        uint256 _requestedCollWithdrawal\n    ) internal pure returns (uint256 collChange, bool isCollIncrease) {\n        if (_collReceived != 0) {\n            collChange = _collReceived;\n            isCollIncrease = true;\n        } else {\n            collChange = _requestedCollWithdrawal;\n        }\n    }\n\n    // Compute the new collateral ratio, considering the change in coll and debt. Assumes 0 pending rewards.\n    function _getNewICRFromTroveChange(\n        uint256 _coll,\n        uint256 _debt,\n        uint256 _collChange,\n        bool _isCollIncrease,\n        uint256 _debtChange,\n        bool _isDebtIncrease,\n        uint256 _price\n    ) internal pure returns (uint) {\n        (uint256 newColl, uint256 newDebt) = _getNewTroveAmounts(\n            _coll,\n            _debt,\n            _collChange,\n            _isCollIncrease,\n            _debtChange,\n            _isDebtIncrease\n        );\n        uint256 newICR = LiquityMath._computeCR(newColl, newDebt, _price);\n        return newICR;\n    }\n\n    function _getNewTroveAmounts(\n        uint256 _coll,\n        uint256 _debt,\n        uint256 _collChange,\n        bool _isCollIncrease,\n        uint256 _debtChange,\n        bool _isDebtIncrease\n    ) internal pure returns (uint newColl, uint newDebt) {\n        newColl = _isCollIncrease ? _coll + _collChange : _coll - _collChange;\n        newDebt = _isDebtIncrease ? _debt + _debtChange : _debt - _debtChange;\n    }\n\n    function _calculateMaxBorrowingCapacity(\n        uint256 _coll,\n        uint256 _price\n    ) internal pure returns (uint) {\n        return (_coll * _price) / (110 * 1e16);\n    }\n\n    function _requireICRisAboveMCR(uint256 _newICR) internal pure {\n        require(\n            _newICR >= MCR,\n            \"BorrowerOps: An operation that would result in ICR < MCR is not permitted\"\n        );\n    }\n\n    function _requireICRisAboveCCR(uint256 _newICR) internal pure {\n        require(\n            _newICR >= CCR,\n            \"BorrowerOps: Operation must leave trove with ICR >= CCR\"\n        );\n    }\n\n    function _requireNewTCRisAboveCCR(uint256 _newTCR) internal pure {\n        require(\n            _newTCR >= CCR,\n            \"BorrowerOps: An operation that would result in TCR < CCR is not permitted\"\n        );\n    }\n\n    function _requireNonZeroDebtChange(uint256 _debtChange) internal pure {\n        require(\n            _debtChange > 0,\n            \"BorrowerOps: Debt increase requires non-zero debtChange\"\n        );\n    }\n\n    function _requireHasBorrowingCapacity(\n        LocalVariables_adjustTrove memory _vars\n    ) internal pure {\n        require(\n            _vars.maxBorrowingCapacity >= _vars.netDebtChange + _vars.debt,\n            \"BorrowerOps: An operation that exceeds maxBorrowingCapacity is not permitted\"\n        );\n    }\n\n    function _requireSingularCollChange(\n        uint256 _collWithdrawal,\n        uint256 _assetAmount\n    ) internal pure {\n        require(\n            _assetAmount == 0 || _collWithdrawal == 0,\n            \"BorrowerOperations: Cannot withdraw and add coll\"\n        );\n    }\n\n    function _requireNonZeroAdjustment(\n        uint256 _collWithdrawal,\n        uint256 _debtChange,\n        uint256 _assetAmount\n    ) internal pure {\n        require(\n            _assetAmount != 0 || _collWithdrawal != 0 || _debtChange != 0,\n            \"BorrowerOps: There must be either a collateral change or a debt change\"\n        );\n    }\n\n    function _requireNoCollWithdrawal(uint256 _collWithdrawal) internal pure {\n        require(\n            _collWithdrawal == 0,\n            \"BorrowerOps: Collateral withdrawal not permitted Recovery Mode\"\n        );\n    }\n\n    function _requireNewICRisAboveOldICR(\n        uint256 _newICR,\n        uint256 _oldICR\n    ) internal pure {\n        require(\n            _newICR >= _oldICR,\n            \"BorrowerOps: Cannot decrease your Trove's ICR in Recovery Mode\"\n        );\n    }\n}\n"
    },
    "contracts/BorrowerOperationsSignatures.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"./dependencies/CheckContract.sol\";\nimport \"./interfaces/IBorrowerOperations.sol\";\nimport \"./interfaces/IBorrowerOperationsSignatures.sol\";\nimport \"./interfaces/IInterestRateManager.sol\";\n\ncontract BorrowerOperationsSignatures is\n    IBorrowerOperationsSignatures,\n    CheckContract,\n    EIP712Upgradeable,\n    OwnableUpgradeable\n{\n    using ECDSA for bytes32;\n\n    struct AddColl {\n        address upperHint;\n        address lowerHint;\n        address borrower;\n        uint256 deadline;\n    }\n\n    struct OpenTrove {\n        uint256 debtAmount;\n        address upperHint;\n        address lowerHint;\n        address borrower;\n        address recipient;\n        uint256 deadline;\n    }\n\n    struct WithdrawColl {\n        uint256 amount;\n        address upperHint;\n        address lowerHint;\n        address borrower;\n        address recipient;\n        uint256 deadline;\n    }\n\n    struct RepayMUSD {\n        uint256 amount;\n        address upperHint;\n        address lowerHint;\n        address borrower;\n        uint256 deadline;\n    }\n\n    struct WithdrawMUSD {\n        uint256 amount;\n        address upperHint;\n        address lowerHint;\n        address borrower;\n        address recipient;\n        uint256 deadline;\n    }\n\n    struct AdjustTrove {\n        uint256 collWithdrawal;\n        uint256 debtChange;\n        bool isDebtIncrease;\n        address upperHint;\n        address lowerHint;\n        address borrower;\n        address recipient;\n        uint256 deadline;\n    }\n\n    struct CloseTrove {\n        address borrower;\n        address recipient;\n        uint256 deadline;\n    }\n\n    struct Refinance {\n        address upperHint;\n        address lowerHint;\n        address borrower;\n        uint256 deadline;\n    }\n\n    struct ClaimCollateral {\n        address borrower;\n        address recipient;\n        uint256 deadline;\n    }\n\n    string private constant SIGNING_DOMAIN = \"BorrowerOperationsSignatures\";\n    string private constant SIGNATURE_VERSION = \"1\";\n\n    bytes32 private constant OPEN_TROVE_TYPEHASH =\n        keccak256(\n            \"OpenTrove(uint256 assetAmount,uint256 debtAmount,address borrower,address recipient,uint256 nonce,uint256 deadline)\"\n        );\n\n    bytes32 private constant ADD_COLL_TYPEHASH =\n        keccak256(\n            \"AddColl(uint256 assetAmount,address borrower,uint256 nonce,uint256 deadline)\"\n        );\n\n    bytes32 private constant WITHDRAW_COLL_TYPEHASH =\n        keccak256(\n            \"WithdrawColl(uint256 amount,address borrower,address recipient,uint256 nonce,uint256 deadline)\"\n        );\n\n    bytes32 private constant REPAY_MUSD_TYPEHASH =\n        keccak256(\n            \"RepayMUSD(uint256 amount,address borrower,uint256 nonce,uint256 deadline)\"\n        );\n\n    bytes32 private constant WITHDRAW_MUSD_TYPEHASH =\n        keccak256(\n            \"WithdrawMUSD(uint256 amount,address borrower,address recipient,uint256 nonce,uint256 deadline)\"\n        );\n\n    bytes32 private constant ADJUST_TROVE_TYPEHASH =\n        keccak256(\n            \"AdjustTrove(uint256 collWithdrawal,uint256 debtChange,bool isDebtIncrease,uint256 assetAmount,address borrower,address recipient,uint256 nonce,uint256 deadline)\"\n        );\n\n    bytes32 private constant CLOSE_TROVE_TYPEHASH =\n        keccak256(\n            \"CloseTrove(address borrower,address recipient,uint256 nonce,uint256 deadline)\"\n        );\n\n    bytes32 private constant REFINANCE_TYPEHASH =\n        keccak256(\n            \"Refinance(address borrower,uint16 interestRate,uint256 nonce,uint256 deadline)\"\n        );\n\n    bytes32 private constant CLAIM_COLLATERAL_TYPEHASH =\n        keccak256(\n            \"ClaimCollateral(address borrower,address recipient,uint256 nonce,uint256 deadline)\"\n        );\n\n    mapping(address => uint256) private nonces;\n    IBorrowerOperations public borrowerOperations;\n    IInterestRateManager public interestRateManager;\n\n    event BorrowerOperationsAddressChanged(\n        address _newBorrowerOperationsAddress\n    );\n    event InterestRateManagerAddressChanged(\n        address _newInterestRateManagerAddress\n    );\n\n    function initialize() external initializer {\n        __Ownable_init(msg.sender);\n        __EIP712_init_unchained(SIGNING_DOMAIN, SIGNATURE_VERSION);\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    function setAddresses(\n        address _borrowerOperationsAddress,\n        address _interestRateManagerAddress\n    ) external onlyOwner {\n        checkContract(_borrowerOperationsAddress);\n        checkContract(_interestRateManagerAddress);\n\n        // slither-disable-start missing-zero-check\n        borrowerOperations = IBorrowerOperations(_borrowerOperationsAddress);\n        interestRateManager = IInterestRateManager(_interestRateManagerAddress);\n        // slither-disable-end missing-zero-check\n\n        emit BorrowerOperationsAddressChanged(_borrowerOperationsAddress);\n        emit InterestRateManagerAddressChanged(_interestRateManagerAddress);\n\n        renounceOwnership();\n    }\n\n    function addCollWithSignature(\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external payable {\n        AddColl memory addCollData = AddColl({\n            upperHint: _upperHint,\n            lowerHint: _lowerHint,\n            borrower: _borrower,\n            deadline: _deadline\n        });\n\n        _verifySignature(\n            ADD_COLL_TYPEHASH,\n            abi.encode(msg.value, addCollData.borrower),\n            addCollData.borrower,\n            _signature,\n            addCollData.deadline\n        );\n\n        borrowerOperations.restrictedAdjustTrove{value: msg.value}(\n            addCollData.borrower,\n            addCollData.borrower,\n            msg.sender,\n            0,\n            0,\n            false,\n            addCollData.upperHint,\n            addCollData.lowerHint\n        );\n    }\n\n    function closeTroveWithSignature(\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external {\n        CloseTrove memory closeTroveData = CloseTrove({\n            borrower: _borrower,\n            recipient: _recipient,\n            deadline: _deadline\n        });\n\n        _verifySignature(\n            CLOSE_TROVE_TYPEHASH,\n            abi.encode(closeTroveData.borrower, closeTroveData.recipient),\n            closeTroveData.borrower,\n            _signature,\n            closeTroveData.deadline\n        );\n\n        borrowerOperations.restrictedCloseTrove(\n            closeTroveData.borrower,\n            msg.sender,\n            closeTroveData.recipient\n        );\n    }\n\n    function adjustTroveWithSignature(\n        uint256 _collWithdrawal,\n        uint256 _debtChange,\n        bool _isDebtIncrease,\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external payable {\n        AdjustTrove memory adjustTroveData = AdjustTrove({\n            collWithdrawal: _collWithdrawal,\n            debtChange: _debtChange,\n            isDebtIncrease: _isDebtIncrease,\n            upperHint: _upperHint,\n            lowerHint: _lowerHint,\n            borrower: _borrower,\n            recipient: _recipient,\n            deadline: _deadline\n        });\n\n        _verifySignature(\n            ADJUST_TROVE_TYPEHASH,\n            abi.encode(\n                adjustTroveData.collWithdrawal,\n                adjustTroveData.debtChange,\n                adjustTroveData.isDebtIncrease,\n                msg.value,\n                adjustTroveData.borrower,\n                adjustTroveData.recipient\n            ),\n            adjustTroveData.borrower,\n            _signature,\n            adjustTroveData.deadline\n        );\n\n        borrowerOperations.restrictedAdjustTrove{value: msg.value}(\n            adjustTroveData.borrower,\n            adjustTroveData.recipient,\n            msg.sender,\n            adjustTroveData.collWithdrawal,\n            adjustTroveData.debtChange,\n            adjustTroveData.isDebtIncrease,\n            adjustTroveData.upperHint,\n            adjustTroveData.lowerHint\n        );\n    }\n\n    function withdrawCollWithSignature(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external {\n        WithdrawColl memory withdrawCollData = WithdrawColl({\n            amount: _amount,\n            upperHint: _upperHint,\n            lowerHint: _lowerHint,\n            borrower: _borrower,\n            recipient: _recipient,\n            deadline: _deadline\n        });\n\n        _verifySignature(\n            WITHDRAW_COLL_TYPEHASH,\n            abi.encode(\n                withdrawCollData.amount,\n                withdrawCollData.borrower,\n                withdrawCollData.recipient\n            ),\n            withdrawCollData.borrower,\n            _signature,\n            withdrawCollData.deadline\n        );\n\n        borrowerOperations.restrictedAdjustTrove(\n            withdrawCollData.borrower,\n            withdrawCollData.recipient,\n            msg.sender,\n            withdrawCollData.amount,\n            0,\n            false,\n            withdrawCollData.upperHint,\n            withdrawCollData.lowerHint\n        );\n    }\n\n    function openTroveWithSignature(\n        uint256 _debtAmount,\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external payable {\n        OpenTrove memory openTroveData = OpenTrove({\n            debtAmount: _debtAmount,\n            upperHint: _upperHint,\n            lowerHint: _lowerHint,\n            borrower: _borrower,\n            recipient: _recipient,\n            deadline: _deadline\n        });\n\n        _verifySignature(\n            OPEN_TROVE_TYPEHASH,\n            abi.encode(\n                msg.value,\n                openTroveData.debtAmount,\n                openTroveData.borrower,\n                openTroveData.recipient\n            ),\n            openTroveData.borrower,\n            _signature,\n            openTroveData.deadline\n        );\n\n        borrowerOperations.restrictedOpenTrove{value: msg.value}(\n            openTroveData.borrower,\n            openTroveData.recipient,\n            openTroveData.debtAmount,\n            openTroveData.upperHint,\n            openTroveData.lowerHint\n        );\n    }\n\n    function withdrawMUSDWithSignature(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external {\n        WithdrawMUSD memory withdrawMUSDData = WithdrawMUSD({\n            amount: _amount,\n            upperHint: _upperHint,\n            lowerHint: _lowerHint,\n            borrower: _borrower,\n            recipient: _recipient,\n            deadline: _deadline\n        });\n\n        _verifySignature(\n            WITHDRAW_MUSD_TYPEHASH,\n            abi.encode(\n                withdrawMUSDData.amount,\n                withdrawMUSDData.borrower,\n                withdrawMUSDData.recipient\n            ),\n            withdrawMUSDData.borrower,\n            _signature,\n            withdrawMUSDData.deadline\n        );\n\n        borrowerOperations.restrictedAdjustTrove(\n            withdrawMUSDData.borrower,\n            withdrawMUSDData.recipient,\n            msg.sender,\n            0,\n            withdrawMUSDData.amount,\n            true,\n            withdrawMUSDData.upperHint,\n            withdrawMUSDData.lowerHint\n        );\n    }\n\n    function repayMUSDWithSignature(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external {\n        RepayMUSD memory repayMUSDData = RepayMUSD({\n            amount: _amount,\n            upperHint: _upperHint,\n            lowerHint: _lowerHint,\n            borrower: _borrower,\n            deadline: _deadline\n        });\n\n        _verifySignature(\n            REPAY_MUSD_TYPEHASH,\n            abi.encode(repayMUSDData.amount, repayMUSDData.borrower),\n            repayMUSDData.borrower,\n            _signature,\n            repayMUSDData.deadline\n        );\n\n        borrowerOperations.restrictedAdjustTrove(\n            repayMUSDData.borrower,\n            repayMUSDData.borrower,\n            msg.sender,\n            0,\n            repayMUSDData.amount,\n            false,\n            repayMUSDData.upperHint,\n            repayMUSDData.lowerHint\n        );\n    }\n\n    function refinanceWithSignature(\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external {\n        Refinance memory refinanceData = Refinance({\n            upperHint: _upperHint,\n            lowerHint: _lowerHint,\n            borrower: _borrower,\n            deadline: _deadline\n        });\n\n        _verifySignature(\n            REFINANCE_TYPEHASH,\n            abi.encode(\n                refinanceData.borrower,\n                interestRateManager.interestRate()\n            ),\n            _borrower,\n            _signature,\n            _deadline\n        );\n\n        borrowerOperations.restrictedRefinance(\n            refinanceData.borrower,\n            refinanceData.upperHint,\n            refinanceData.lowerHint\n        );\n    }\n\n    function claimCollateralWithSignature(\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external {\n        ClaimCollateral memory claimCollateralData = ClaimCollateral({\n            borrower: _borrower,\n            recipient: _recipient,\n            deadline: _deadline\n        });\n\n        _verifySignature(\n            CLAIM_COLLATERAL_TYPEHASH,\n            abi.encode(\n                claimCollateralData.borrower,\n                claimCollateralData.recipient\n            ),\n            claimCollateralData.borrower,\n            _signature,\n            claimCollateralData.deadline\n        );\n\n        borrowerOperations.restrictedClaimCollateral(\n            claimCollateralData.borrower,\n            claimCollateralData.recipient\n        );\n    }\n\n    function getNonce(address user) public view returns (uint256) {\n        return nonces[user];\n    }\n\n    function _verifySignature(\n        bytes32 _typeHash,\n        bytes memory _data,\n        address _borrower,\n        bytes memory _signature,\n        uint256 _deadline\n    ) internal {\n        // solhint-disable-next-line not-rely-on-time\n        require(block.timestamp <= _deadline, \"Signature expired\");\n\n        bytes32 digest = _hashTypedDataV4(\n            keccak256(\n                abi.encodePacked(_typeHash, _data, nonces[_borrower], _deadline)\n            )\n        );\n\n        address recoveredAddress = ECDSA.recover(digest, _signature);\n        require(\n            recoveredAddress == _borrower,\n            \"BorrowerOperationsSignatures: Invalid signature\"\n        );\n\n        nonces[_borrower]++;\n    }\n}\n"
    },
    "contracts/CollSurplusPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"./dependencies/CheckContract.sol\";\nimport \"./dependencies/SendCollateral.sol\";\nimport \"./interfaces/ICollSurplusPool.sol\";\nimport \"./interfaces/IBorrowerOperations.sol\";\nimport \"./interfaces/IActivePool.sol\";\n\ncontract CollSurplusPool is\n    CheckContract,\n    ICollSurplusPool,\n    OwnableUpgradeable,\n    SendCollateral\n{\n    string public constant NAME = \"CollSurplusPool\";\n\n    address public activePoolAddress;\n    address public borrowerOperationsAddress;\n    address public troveManagerAddress;\n\n    // deposited collateral tracker\n    uint256 internal collateral;\n    // Collateral surplus claimable by trove owners\n    mapping(address => uint) internal balances;\n\n    function initialize() external initializer {\n        __Ownable_init(msg.sender);\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    // --- Fallback function ---\n\n    // solhint-disable no-complex-fallback\n    receive() external payable {\n        _requireCallerIsActivePool();\n        // slither-disable-next-line events-maths\n        collateral += msg.value;\n    }\n\n    // --- Contract setters ---\n\n    function setAddresses(\n        address _activePoolAddress,\n        address _borrowerOperationsAddress,\n        address _troveManagerAddress\n    ) external override onlyOwner {\n        checkContract(_borrowerOperationsAddress);\n        checkContract(_troveManagerAddress);\n        checkContract(_activePoolAddress);\n\n        // checkContract does the zero address check so disable slither warning\n        // slither-disable-start missing-zero-check\n        borrowerOperationsAddress = _borrowerOperationsAddress;\n        troveManagerAddress = _troveManagerAddress;\n        activePoolAddress = _activePoolAddress;\n        // slither-disable-end missing-zero-check\n\n        emit BorrowerOperationsAddressChanged(_borrowerOperationsAddress);\n        emit TroveManagerAddressChanged(_troveManagerAddress);\n        emit ActivePoolAddressChanged(_activePoolAddress);\n\n        renounceOwnership();\n    }\n\n    // --- Pool functionality ---\n\n    function accountSurplus(\n        address _account,\n        uint256 _amount\n    ) external override {\n        _requireCallerIsTroveManager();\n\n        uint256 newAmount = balances[_account] + _amount;\n        balances[_account] = newAmount;\n\n        emit CollBalanceUpdated(_account, newAmount);\n    }\n\n    function claimColl(address _account, address _recipient) external override {\n        _requireCallerIsBorrowerOperations();\n        uint256 claimableColl = balances[_account];\n        require(\n            claimableColl > 0,\n            \"CollSurplusPool: No collateral available to claim\"\n        );\n\n        balances[_account] = 0;\n        emit CollBalanceUpdated(_account, 0);\n\n        collateral -= claimableColl;\n        emit CollateralSent(_account, claimableColl);\n\n        _sendCollateral(_recipient, claimableColl);\n    }\n\n    function getCollateral(\n        address _account\n    ) external view override returns (uint) {\n        return balances[_account];\n    }\n\n    /* Returns the collateral state variable at ActivePool address.\n       Not necessarily equal to the raw collateral balance - collateral can be forcibly sent to contracts. */\n    function getCollateralBalance() external view override returns (uint) {\n        return collateral;\n    }\n\n    // --- 'require' functions ---\n\n    function _requireCallerIsBorrowerOperations() internal view {\n        require(\n            msg.sender == borrowerOperationsAddress,\n            \"CollSurplusPool: Caller is not Borrower Operations\"\n        );\n    }\n\n    function _requireCallerIsTroveManager() internal view {\n        require(\n            msg.sender == troveManagerAddress,\n            \"CollSurplusPool: Caller is not TroveManager\"\n        );\n    }\n\n    function _requireCallerIsActivePool() internal view {\n        require(\n            msg.sender == activePoolAddress,\n            \"CollSurplusPool: Caller is not Active Pool\"\n        );\n    }\n}\n"
    },
    "contracts/debugging/console.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// solhint-disable state-visibility\n\npragma solidity 0.8.24;\n\n// Buidler's helper contract for console logging\nlibrary console {\n    address constant CONSOLE_ADDRESS =\n        address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n    function log() internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log()\")\n        );\n        ignored;\n    }\n\n    function logInt(int p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(int)\", p0)\n        );\n        ignored;\n    }\n\n    function logUint(uint256 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint)\", p0)\n        );\n        ignored;\n    }\n\n    function logString(string memory p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string)\", p0)\n        );\n        ignored;\n    }\n\n    function logBool(bool p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool)\", p0)\n        );\n        ignored;\n    }\n\n    function logAddress(address p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes(bytes memory p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes)\", p0)\n        );\n        ignored;\n    }\n\n    function logByte(bytes1 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes1)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes1(bytes1 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes1)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes2(bytes2 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes2)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes3(bytes3 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes3)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes4(bytes4 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes4)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes5(bytes5 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes5)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes6(bytes6 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes6)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes7(bytes7 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes7)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes8(bytes8 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes8)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes9(bytes9 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes9)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes10(bytes10 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes10)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes11(bytes11 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes11)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes12(bytes12 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes12)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes13(bytes13 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes13)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes14(bytes14 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes14)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes15(bytes15 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes15)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes16(bytes16 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes16)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes17(bytes17 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes17)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes18(bytes18 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes18)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes19(bytes19 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes19)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes20(bytes20 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes20)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes21(bytes21 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes21)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes22(bytes22 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes22)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes23(bytes23 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes23)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes24(bytes24 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes24)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes25(bytes25 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes25)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes26(bytes26 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes26)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes27(bytes27 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes27)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes28(bytes28 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes28)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes29(bytes29 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes29)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes30(bytes30 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes30)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes31(bytes31 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes31)\", p0)\n        );\n        ignored;\n    }\n\n    function logBytes32(bytes32 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bytes32)\", p0)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint)\", p0)\n        );\n        ignored;\n    }\n\n    function log(string memory p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string)\", p0)\n        );\n        ignored;\n    }\n\n    function log(bool p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool)\", p0)\n        );\n        ignored;\n    }\n\n    function log(address p0) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address)\", p0)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,uint)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, string memory p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,string)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,bool)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,address)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, uint256 p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,uint)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, string memory p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,string)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, bool p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,bool)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, address p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,address)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,uint)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(bool p0, string memory p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,string)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,bool)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,address)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,uint)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(address p0, string memory p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,string)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,bool)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,address)\", p0, p1)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,uint,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,uint,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,uint,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,uint,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, string memory p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,string,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, string memory p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,string,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, string memory p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,string,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, string memory p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,string,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,bool,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,bool,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,bool,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,bool,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,address,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,address,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,address,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,address,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, uint256 p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,uint,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, uint256 p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,uint,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, uint256 p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,uint,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, uint256 p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,uint,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, string memory p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,string,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        string memory p2\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, string memory p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, string memory p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, bool p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,bool,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, bool p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, bool p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, bool p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, address p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,address,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, address p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, address p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(string memory p0, address p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,uint,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,uint,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,uint,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,uint,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, string memory p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,string,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, string memory p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, string memory p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, string memory p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,bool,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,address,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,uint,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,uint,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,uint,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,uint,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, string memory p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,string,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, string memory p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, string memory p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, string memory p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,bool,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, uint256 p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,address,uint)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, string memory p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, bool p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, address p2) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,uint,uint,uint)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        uint256 p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,uint,uint,bool)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        uint256 p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        uint256 p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        uint256 p1,\n        string memory p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        uint256 p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,uint,bool,uint)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        uint256 p1,\n        bool p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,uint,bool,bool)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, bool p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        uint256 p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, address p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, uint256 p1, address p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,uint,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        uint256 p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        uint256 p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        uint256 p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        string memory p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        bool p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        bool p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, string memory p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        bool p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        address p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        address p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        string memory p1,\n        address p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,string,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,bool,uint,uint)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        bool p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, uint256 p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,bool,uint,bool)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, uint256 p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        bool p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        bool p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, string memory p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        bool p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, bool p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,bool,bool,uint)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, bool p2, string memory p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(uint,bool,bool,bool)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, bool p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, address p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        bool p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, address p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, bool p1, address p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,bool,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        address p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, uint256 p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, uint256 p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        address p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        address p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        address p1,\n        string memory p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        address p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, bool p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        address p1,\n        bool p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, bool p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, address p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        uint256 p0,\n        address p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, address p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(uint256 p0, address p1, address p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(uint,address,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        uint256 p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        uint256 p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        uint256 p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        string memory p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        bool p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        bool p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(string memory p0, uint256 p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        bool p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        address p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        address p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        uint256 p1,\n        address p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,uint,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        uint256 p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        uint256 p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        uint256 p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        string memory p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        bool p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        bool p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        bool p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        bool p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        address p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        address p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        string memory p1,\n        address p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,string,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        bool p1,\n        uint256 p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        bool p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(string memory p0, bool p1, uint256 p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        bool p1,\n        uint256 p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        bool p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        bool p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        bool p1,\n        string memory p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        bool p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(string memory p0, bool p1, bool p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        bool p1,\n        bool p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(string memory p0, bool p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(string memory p0, bool p1, bool p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        bool p1,\n        address p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        bool p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(string memory p0, bool p1, address p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        bool p1,\n        address p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,bool,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        uint256 p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        uint256 p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        uint256 p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        string memory p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        bool p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        bool p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(string memory p0, address p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        bool p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        address p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        address p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        string memory p0,\n        address p1,\n        address p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(string,address,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,uint,uint,uint)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        uint256 p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, uint256 p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,uint,uint,bool)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, uint256 p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        uint256 p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        uint256 p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, string memory p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        uint256 p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, bool p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,uint,bool,uint)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, bool p2, string memory p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,uint,bool,bool)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, bool p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, address p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        uint256 p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, address p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, uint256 p1, address p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,uint,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        string memory p1,\n        uint256 p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        string memory p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, string memory p1, uint256 p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        string memory p1,\n        uint256 p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        string memory p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        string memory p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        string memory p1,\n        string memory p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        string memory p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, string memory p1, bool p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        string memory p1,\n        bool p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, string memory p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, string memory p1, bool p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        string memory p1,\n        address p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        string memory p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, string memory p1, address p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        string memory p1,\n        address p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,string,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, uint256 p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,bool,uint,uint)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, uint256 p2, string memory p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, uint256 p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,bool,uint,bool)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, uint256 p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, string memory p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        bool p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, string memory p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, string memory p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, bool p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,bool,bool,uint)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, bool p2, string memory p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3)\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, bool p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, address p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, address p2, string memory p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, address p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, bool p1, address p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,bool,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, uint256 p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        address p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, uint256 p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, uint256 p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        address p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        address p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, string memory p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        address p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, bool p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, bool p2, string memory p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, bool p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, address p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        bool p0,\n        address p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, address p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(bool p0, address p1, address p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(bool,address,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        uint256 p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, uint256 p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, uint256 p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        uint256 p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        uint256 p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        uint256 p1,\n        string memory p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        uint256 p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, bool p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        uint256 p1,\n        bool p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, bool p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, address p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        uint256 p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, address p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, uint256 p1, address p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,uint,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        uint256 p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        uint256 p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        uint256 p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        string memory p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        bool p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        bool p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, string memory p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        bool p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        address p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        address p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        string memory p1,\n        address p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,string,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, uint256 p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        bool p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, uint256 p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, uint256 p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        bool p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        bool p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, string memory p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        bool p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, bool p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, bool p2, string memory p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, bool p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, address p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        bool p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, address p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, bool p1, address p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,bool,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, uint256 p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,uint,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        address p1,\n        uint256 p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,uint,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, uint256 p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,uint,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, uint256 p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,uint,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        address p1,\n        string memory p2,\n        uint256 p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,string,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        address p1,\n        string memory p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,string,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        address p1,\n        string memory p2,\n        bool p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,string,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        address p1,\n        string memory p2,\n        address p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,string,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, bool p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,bool,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        address p1,\n        bool p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,bool,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, bool p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,bool,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, bool p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,bool,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, address p2, uint256 p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,address,uint)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(\n        address p0,\n        address p1,\n        address p2,\n        string memory p3\n    ) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,address,string)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, address p2, bool p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,address,bool)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n\n    function log(address p0, address p1, address p2, address p3) internal view {\n        (bool ignored, ) = CONSOLE_ADDRESS.staticcall(\n            abi.encodeWithSignature(\n                \"log(address,address,address,address)\",\n                p0,\n                p1,\n                p2,\n                p3\n            )\n        );\n        ignored;\n    }\n}\n"
    },
    "contracts/DefaultPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"./dependencies/CheckContract.sol\";\nimport \"./dependencies/SendCollateral.sol\";\nimport \"./interfaces/IActivePool.sol\";\nimport \"./interfaces/IDefaultPool.sol\";\n\n/*\n * The Default Pool holds the collateral and debt (but not mUSD tokens) from liquidations that have been redistributed\n * to active troves but not yet \"applied\", i.e. not yet recorded on a recipient active trove's struct.\n *\n * When a trove makes an operation that applies its pending collateral and debt, its pending collateral and debt is moved\n * from the Default Pool to the Active Pool.\n */\ncontract DefaultPool is\n    CheckContract,\n    IDefaultPool,\n    OwnableUpgradeable,\n    SendCollateral\n{\n    address public activePoolAddress;\n    address public troveManagerAddress;\n\n    uint256 internal collateral; // deposited collateral tracker\n    uint256 internal principal;\n    uint256 internal interest;\n\n    function initialize() external initializer {\n        __Ownable_init(msg.sender);\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    // solhint-disable no-complex-fallback\n    receive() external payable {\n        _requireCallerIsActivePool();\n        collateral += msg.value;\n        emit DefaultPoolCollateralBalanceUpdated(collateral);\n    }\n\n    // --- Dependency setters ---\n\n    function setAddresses(\n        address _activePoolAddress,\n        address _troveManagerAddress\n    ) external onlyOwner {\n        checkContract(_activePoolAddress);\n        checkContract(_troveManagerAddress);\n\n        // slither-disable-start missing-zero-check\n        activePoolAddress = _activePoolAddress;\n        troveManagerAddress = _troveManagerAddress;\n        // slither-disable-end missing-zero-check\n\n        emit TroveManagerAddressChanged(_troveManagerAddress);\n        emit ActivePoolAddressChanged(_activePoolAddress);\n\n        renounceOwnership();\n    }\n\n    function increaseDebt(\n        uint256 _principal,\n        uint256 _interest\n    ) external override {\n        _requireCallerIsTroveManager();\n        principal += _principal;\n        interest += _interest;\n        emit DefaultPoolDebtUpdated(principal, interest);\n    }\n\n    function decreaseDebt(\n        uint256 _principal,\n        uint256 _interest\n    ) external override {\n        _requireCallerIsTroveManager();\n        principal -= _principal;\n        interest -= _interest;\n        emit DefaultPoolDebtUpdated(principal, interest);\n    }\n\n    function sendCollateralToActivePool(uint256 _amount) external override {\n        _requireCallerIsTroveManager();\n        address activePool = activePoolAddress; // cache to save an SLOAD\n        collateral -= _amount;\n        emit DefaultPoolCollateralBalanceUpdated(collateral);\n        emit CollateralSent(activePool, _amount);\n\n        _sendCollateral(activePool, _amount);\n    }\n\n    function getCollateralBalance() external view override returns (uint) {\n        return collateral;\n    }\n\n    function getDebt() external view override returns (uint) {\n        return principal + interest;\n    }\n\n    function getPrincipal() external view override returns (uint) {\n        return principal;\n    }\n\n    function getInterest() external view override returns (uint) {\n        return interest;\n    }\n\n    function _requireCallerIsTroveManager() internal view {\n        require(\n            msg.sender == troveManagerAddress,\n            \"DefaultPool: Caller is not the TroveManager\"\n        );\n    }\n\n    function _requireCallerIsActivePool() internal view {\n        require(\n            msg.sender == activePoolAddress,\n            \"DefaultPool: Caller is not the ActivePool\"\n        );\n    }\n}\n"
    },
    "contracts/dependencies/BaseMath.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.24;\n\ncontract BaseMath {\n    uint256 public constant DECIMAL_PRECISION = 1e18;\n}\n"
    },
    "contracts/dependencies/CheckContract.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\ncontract CheckContract {\n    /**\n     * Check that the account is an already deployed non-destroyed contract.\n     * See: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol#L12\n     */\n    function checkContract(address _account) internal view {\n        require(_account != address(0), \"Account cannot be zero address\");\n\n        uint256 size;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            size := extcodesize(_account)\n        }\n        require(size > 0, \"Account code size cannot be zero\");\n    }\n}\n"
    },
    "contracts/dependencies/InterestRateMath.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nlibrary InterestRateMath {\n    // https://sibenotes.com/maths/how-many-seconds-are-in-a-year/\n    // 365.2425 days per year * 24 hours per day *\n    // 60 minutes per hour * 60 seconds per minute\n    uint256 public constant SECONDS_IN_A_YEAR = 31_556_952;\n    uint256 private constant BPS = 10_000;\n\n    function calculateInterestOwed(\n        uint256 _principal,\n        uint16 _interestRate,\n        uint256 _startTime,\n        uint256 _endTime\n    ) internal pure returns (uint256) {\n        uint256 timeElapsed = _endTime - _startTime;\n        return\n            (_principal * _interestRate * timeElapsed) /\n            (BPS * SECONDS_IN_A_YEAR);\n    }\n\n    function calculateAggregatedInterestOwed(\n        uint256 _interestNumerator,\n        uint256 _startTime,\n        uint256 _endTime\n    ) internal pure returns (uint256) {\n        uint256 timeElapsed = _endTime - _startTime;\n        return (timeElapsed * _interestNumerator) / (BPS * SECONDS_IN_A_YEAR);\n    }\n\n    function calculateDebtAdjustment(\n        uint256 _interestOwed,\n        uint256 _payment\n    )\n        internal\n        pure\n        returns (uint256 principalAdjustment, uint256 interestAdjustment)\n    {\n        if (_payment >= _interestOwed) {\n            principalAdjustment = _payment - _interestOwed;\n            interestAdjustment = _interestOwed;\n        } else {\n            principalAdjustment = 0;\n            interestAdjustment = _payment;\n        }\n    }\n}\n"
    },
    "contracts/dependencies/LiquityBase.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"./BaseMath.sol\";\nimport \"./InterestRateMath.sol\";\nimport \"./LiquityMath.sol\";\nimport \"../interfaces/IActivePool.sol\";\nimport \"../interfaces/IDefaultPool.sol\";\nimport \"../interfaces/IInterestRateManager.sol\";\nimport \"../interfaces/IPriceFeed.sol\";\nimport \"../interfaces/ILiquityBase.sol\";\n\n/*\n * Base contract for TroveManager, BorrowerOperations and StabilityPool. Contains global system constants and\n * common functions.\n */\nabstract contract LiquityBase is BaseMath, ILiquityBase {\n    uint256 public constant _100pct = 1e18; // 1e18 == 100%\n\n    // Minimum collateral ratio for individual troves\n    uint256 public constant MCR = 1.1e18; // 110%\n\n    // Critical system collateral ratio. If the system's total collateral ratio (TCR) falls below the CCR, Recovery Mode is triggered.\n    uint256 public constant CCR = 1.5e18; // 150%\n\n    // Amount of mUSD to be locked in gas pool on opening troves\n    uint256 public constant MUSD_GAS_COMPENSATION = 200e18;\n\n    uint256 public constant PERCENT_DIVISOR = 200; // dividing by 200 yields 0.5%\n\n    // slither-disable-next-line all\n    IActivePool public activePool;\n\n    // slither-disable-next-line all\n    IDefaultPool public defaultPool;\n\n    // slither-disable-next-line all\n    IInterestRateManager public interestRateManager;\n\n    // slither-disable-next-line all\n    IPriceFeed public override priceFeed;\n\n    // slither-disable-next-line unused-state\n    uint256[50] private __gap;\n\n    // --- Gas compensation functions ---\n\n    function getEntireSystemColl()\n        public\n        view\n        virtual\n        returns (uint256 entireSystemColl)\n    {\n        uint256 activeColl = activePool.getCollateralBalance();\n        uint256 liquidatedColl = defaultPool.getCollateralBalance();\n\n        return activeColl + liquidatedColl;\n    }\n\n    function getEntireSystemDebt()\n        public\n        view\n        virtual\n        returns (uint256 entireSystemDebt)\n    {\n        uint256 activeDebt = activePool.getDebt();\n        uint256 closedDebt = defaultPool.getDebt();\n\n        return activeDebt + closedDebt;\n    }\n\n    function _getTCR(\n        uint256 _price\n    ) internal view virtual returns (uint256 TCR) {\n        uint256 entireSystemColl = getEntireSystemColl();\n        uint256 entireSystemDebt = getEntireSystemDebt();\n\n        TCR = LiquityMath._computeCR(\n            entireSystemColl,\n            entireSystemDebt,\n            _price\n        );\n        return TCR;\n    }\n\n    function _checkRecoveryMode(\n        uint256 _price\n    ) internal view virtual returns (bool) {\n        uint256 TCR = _getTCR(_price);\n        return TCR < CCR;\n    }\n\n    // Return the amount of collateral to be drawn from a trove's collateral and sent as gas compensation.\n    function _getCollGasCompensation(\n        uint256 _entireColl\n    ) internal pure virtual returns (uint) {\n        return _entireColl / PERCENT_DIVISOR;\n    }\n\n    // Returns the composite debt (drawn debt + gas compensation) of a trove,\n    // for the purpose of ICR calculation\n    function _getCompositeDebt(uint256 _debt) internal pure returns (uint) {\n        return _debt + MUSD_GAS_COMPENSATION;\n    }\n\n    function _getNetDebt(uint256 _debt) internal pure returns (uint) {\n        return _debt - MUSD_GAS_COMPENSATION;\n    }\n}\n"
    },
    "contracts/dependencies/LiquityMath.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nlibrary LiquityMath {\n    /* Precision for Nominal ICR (independent of price). Rationale for the value:\n     *\n     * - Making it “too high” could lead to overflows.\n     * - Making it “too low” could lead to an ICR equal to zero, due to truncation from Solidity floor division.\n     *\n     * This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39 BTC,\n     * and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator.\n     *\n     */\n    uint256 internal constant NICR_PRECISION = 1e20;\n\n    function _min(uint256 _a, uint256 _b) internal pure returns (uint) {\n        return (_a < _b) ? _a : _b;\n    }\n\n    function _getAbsoluteDifference(\n        uint256 _a,\n        uint256 _b\n    ) internal pure returns (uint) {\n        return (_a >= _b) ? _a - _b : _b - _a;\n    }\n\n    function _computeNominalCR(\n        uint256 _coll,\n        uint256 _debt\n    ) internal pure returns (uint) {\n        if (_debt > 0) {\n            return (_coll * NICR_PRECISION) / _debt;\n        }\n        // Return the maximal value for uint256 if the Trove has a debt of 0. Represents \"infinite\" CR.\n        else {\n            // if (_debt == 0)\n            return type(uint256).max;\n        }\n    }\n\n    function _computeCR(\n        uint256 _coll,\n        uint256 _debt,\n        uint256 _price\n    ) internal pure returns (uint) {\n        if (_debt > 0) {\n            uint256 newCollRatio = (_coll * _price) / _debt;\n\n            return newCollRatio;\n        }\n        // Return the maximal value for uint256 if the Trove has a debt of 0. Represents \"infinite\" CR.\n        else {\n            // if (_debt == 0)\n            return type(uint256).max;\n        }\n    }\n}\n"
    },
    "contracts/dependencies/SendCollateral.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\ncontract SendCollateral {\n    /**\n     * Sends collateral to recipient\n     */\n    function _sendCollateral(address _recipient, uint256 _amount) internal {\n        // slither-disable-next-line low-level-calls\n        (bool success, ) = _recipient.call{value: _amount}(\"\"); // re-entry is fine here\n        require(success, \"Sending BTC failed\");\n    }\n}\n"
    },
    "contracts/echidna/BorrowerOperationsFuzzTester.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../BorrowerOperations.sol\";\nimport \"./IBorrowerOperationsFuzzTester.sol\";\n\ncontract BorrowerOperationsFuzzTester is\n    BorrowerOperations,\n    IBorrowerOperationsFuzzTester\n{\n    function getMCR() external pure returns (uint256) {\n        return MCR;\n    }\n\n    function getCCR() external pure returns (uint256) {\n        return CCR;\n    }\n\n    function getGasComp() external pure returns (uint256) {\n        return MUSD_GAS_COMPENSATION;\n    }\n}\n"
    },
    "contracts/echidna/EchidnaProxy.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../TroveManager.sol\";\nimport \"../BorrowerOperations.sol\";\nimport \"../StabilityPool.sol\";\nimport \"../token/MUSD.sol\";\n\ncontract EchidnaProxy {\n    ITroveManager private immutable troveManager;\n    IBorrowerOperations private immutable borrowerOperations;\n    IStabilityPool private immutable stabilityPool;\n    IMUSD private immutable musd;\n\n    constructor(\n        ITroveManager _troveManager,\n        IBorrowerOperations _borrowerOperations,\n        IStabilityPool _stabilityPool,\n        IMUSD _musd\n    ) {\n        troveManager = _troveManager;\n        borrowerOperations = _borrowerOperations;\n        stabilityPool = _stabilityPool;\n        musd = _musd;\n    }\n\n    receive() external payable {\n        // do nothing\n    }\n\n    // TroveManager\n\n    function liquidatePrx(address _user) external {\n        troveManager.liquidate(_user);\n    }\n\n    function batchLiquidateTrovesPrx(address[] calldata _troveArray) external {\n        troveManager.batchLiquidateTroves(_troveArray);\n    }\n\n    function redeemCollateralPrx(\n        uint _mUSDAmount,\n        address _firstRedemptionHint,\n        address _upperPartialRedemptionHint,\n        address _lowerPartialRedemptionHint,\n        uint _partialRedemptionHintNICR,\n        uint _maxIterations\n    ) external {\n        troveManager.redeemCollateral(\n            _mUSDAmount,\n            _firstRedemptionHint,\n            _upperPartialRedemptionHint,\n            _lowerPartialRedemptionHint,\n            _partialRedemptionHintNICR,\n            _maxIterations\n        );\n    }\n\n    // Borrower Operations\n    function openTrovePrx(\n        uint _BTC,\n        uint _debtAmount,\n        address _upperHint,\n        address _lowerHint\n    ) external payable {\n        // slither-disable-start arbitrary-send-eth\n        borrowerOperations.openTrove{value: _BTC}(\n            _debtAmount,\n            _upperHint,\n            _lowerHint\n        );\n        // slither-disable-end arbitrary-send-eth\n    }\n\n    function addCollPrx(\n        uint _BTC,\n        address _upperHint,\n        address _lowerHint\n    ) external payable {\n        // slither-disable-start arbitrary-send-eth\n        borrowerOperations.addColl{value: _BTC}(_upperHint, _lowerHint);\n        // slither-disable-end arbitrary-send-eth\n    }\n\n    function withdrawCollPrx(\n        uint _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external {\n        borrowerOperations.withdrawColl(_amount, _upperHint, _lowerHint);\n    }\n\n    function withdrawMUSDPrx(\n        uint _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external {\n        borrowerOperations.withdrawMUSD(_amount, _upperHint, _lowerHint);\n    }\n\n    function repayMUSDPrx(\n        uint _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external {\n        borrowerOperations.repayMUSD(_amount, _upperHint, _lowerHint);\n    }\n\n    function closeTrovePrx() external {\n        borrowerOperations.closeTrove();\n    }\n\n    function adjustTrovePrx(\n        uint _BTC,\n        uint _collWithdrawal,\n        uint _debtChange,\n        bool _isDebtIncrease,\n        address _upperHint,\n        address _lowerHint\n    ) external {\n        // slither-disable-start arbitrary-send-eth\n        borrowerOperations.adjustTrove{value: _BTC}(\n            _collWithdrawal,\n            _debtChange,\n            _isDebtIncrease,\n            _upperHint,\n            _lowerHint\n        );\n        // slither-disable-end arbitrary-send-eth\n    }\n\n    function refinancePrx() external {\n        borrowerOperations.refinance(address(0), address(0));\n    }\n\n    function claimCollateralPrx() external {\n        borrowerOperations.claimCollateral();\n    }\n\n    // Pool Manager\n    function provideToSPPrx(uint _amount) external {\n        // slither-disable-next-line unused-return\n        musd.approve(address(stabilityPool), _amount);\n        stabilityPool.provideToSP(_amount);\n    }\n\n    function withdrawFromSPPrx(uint _amount) external {\n        stabilityPool.withdrawFromSP(_amount);\n    }\n\n    function withdrawCollateralGainToTrovePrx() external {\n        stabilityPool.withdrawCollateralGainToTrove(address(0), address(0));\n    }\n\n    // MUSD Token\n\n    function transferPrx(\n        address recipient,\n        uint256 amount\n    ) external returns (bool) {\n        return musd.transfer(recipient, amount);\n    }\n\n    function approvePrx(\n        address spender,\n        uint256 amount\n    ) external returns (bool) {\n        return musd.approve(spender, amount);\n    }\n\n    function transferFromPrx(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) external returns (bool) {\n        // slither-disable-next-line arbitrary-send-erc20\n        return musd.transferFrom(sender, recipient, amount);\n    }\n}\n"
    },
    "contracts/echidna/EchidnaTest.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"./BorrowerOperationsFuzzTester.sol\";\nimport \"./IBorrowerOperationsFuzzTester.sol\";\nimport \"../BorrowerOperationsSignatures.sol\";\nimport \"../interfaces/IBorrowerOperationsSignatures.sol\";\nimport \"../InterestRateManager.sol\";\nimport \"../interfaces/IInterestRateManager.sol\";\nimport \"./TroveManagerFuzzTester.sol\";\nimport \"./ITroveManagerFuzzTester.sol\";\nimport \"../StabilityPool.sol\";\nimport \"../interfaces/IStabilityPool.sol\";\nimport \"../token/MUSD.sol\";\nimport \"../tests/MockAggregator.sol\";\nimport \"../CollSurplusPool.sol\";\nimport \"../interfaces/ICollSurplusPool.sol\";\nimport \"../ActivePool.sol\";\nimport \"../interfaces/IActivePool.sol\";\nimport \"../DefaultPool.sol\";\nimport \"../interfaces/IDefaultPool.sol\";\nimport \"../PCV.sol\";\nimport \"../interfaces/IPCV.sol\";\nimport \"../SortedTroves.sol\";\nimport \"../interfaces/ISortedTroves.sol\";\nimport \"../GasPool.sol\";\nimport \"../interfaces/IGasPool.sol\";\nimport \"../GovernableVariables.sol\";\nimport \"../interfaces/IGovernableVariables.sol\";\nimport \"../PriceFeed.sol\";\nimport \"../interfaces/IPriceFeed.sol\";\nimport \"../HintHelpers.sol\";\nimport \"../interfaces/IHintHelpers.sol\";\nimport \"./EchidnaProxy.sol\";\nimport \"../tests/MUSDTester.sol\";\n\n// Run with\n// `rm -rf echidna-corpus && echidna . --config echidna.yaml --contract EchidnaTest`\n// from the /solidity directory\ncontract EchidnaTest {\n    IInterestRateManager private immutable interestRateManager;\n    IBorrowerOperationsFuzzTester private immutable borrowerOperations;\n    IBorrowerOperationsSignatures\n        private immutable borrowerOperationsSignatures;\n    ITroveManagerFuzzTester private immutable troveManager;\n    IStabilityPool private immutable stabilityPool;\n    MUSD private immutable musd;\n    MockAggregator private immutable mockAggregator;\n    ICollSurplusPool private immutable collSurplusPool;\n    IDefaultPool private immutable defaultPool;\n    IActivePool private immutable activePool;\n    IPCV private immutable pcv;\n    ISortedTroves private immutable sortedTroves;\n    IGasPool private immutable gasPool;\n    IGovernableVariables private immutable governableVariables;\n    IPriceFeed private immutable priceFeed;\n    IHintHelpers private immutable hintHelpers;\n\n    uint public constant NUMBER_OF_ACTORS = 10;\n    uint public constant INITIAL_BALANCE = 1e24;\n\n    EchidnaProxy[NUMBER_OF_ACTORS] public echidnaProxies;\n\n    uint private immutable MCR;\n    uint private immutable CCR;\n    uint private immutable MUSD_GAS_COMPENSATION;\n\n    uint private numberOfTroves;\n\n    // Mimic the hardhat deploy process\n    constructor() payable {\n        address admin = address(new ProxyAdmin(msg.sender));\n\n        borrowerOperations = IBorrowerOperationsFuzzTester(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new BorrowerOperationsFuzzTester()),\n                    admin,\n                    abi.encodeWithSelector(\n                        BorrowerOperations.initialize.selector\n                    )\n                )\n            )\n        );\n        borrowerOperationsSignatures = IBorrowerOperationsSignatures(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new BorrowerOperationsSignatures()),\n                    admin,\n                    abi.encodeWithSelector(\n                        BorrowerOperationsSignatures.initialize.selector\n                    )\n                )\n            )\n        );\n        interestRateManager = IInterestRateManager(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new InterestRateManager()),\n                    admin,\n                    abi.encodeWithSelector(\n                        InterestRateManager.initialize.selector\n                    )\n                )\n            )\n        );\n        troveManager = ITroveManagerFuzzTester(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new TroveManagerFuzzTester()),\n                    admin,\n                    abi.encodeWithSelector(TroveManager.initialize.selector)\n                )\n            )\n        );\n        stabilityPool = IStabilityPool(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new StabilityPool()),\n                    admin,\n                    abi.encodeWithSelector(StabilityPool.initialize.selector)\n                )\n            )\n        );\n        musd = MUSD(new MUSDTester());\n        mockAggregator = new MockAggregator(18);\n        collSurplusPool = ICollSurplusPool(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new CollSurplusPool()),\n                    admin,\n                    abi.encodeWithSelector(CollSurplusPool.initialize.selector)\n                )\n            )\n        );\n        activePool = IActivePool(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new ActivePool()),\n                    admin,\n                    abi.encodeWithSelector(ActivePool.initialize.selector)\n                )\n            )\n        );\n        defaultPool = IDefaultPool(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new DefaultPool()),\n                    admin,\n                    abi.encodeWithSelector(DefaultPool.initialize.selector)\n                )\n            )\n        );\n        pcv = IPCV(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new PCV()),\n                    admin,\n                    abi.encodeWithSelector(PCV.initialize.selector, 7200)\n                )\n            )\n        );\n        sortedTroves = ISortedTroves(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new SortedTroves()),\n                    admin,\n                    abi.encodeWithSelector(SortedTroves.initialize.selector)\n                )\n            )\n        );\n        gasPool = IGasPool(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new GasPool()),\n                    admin,\n                    abi.encodeWithSelector(GasPool.initialize.selector)\n                )\n            )\n        );\n        governableVariables = IGovernableVariables(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new GovernableVariables()),\n                    admin,\n                    abi.encodeWithSelector(\n                        GovernableVariables.initialize.selector,\n                        7200\n                    )\n                )\n            )\n        );\n        priceFeed = IPriceFeed(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new PriceFeed()),\n                    admin,\n                    abi.encodeWithSelector(PriceFeed.initialize.selector)\n                )\n            )\n        );\n        hintHelpers = IHintHelpers(\n            address(\n                new TransparentUpgradeableProxy(\n                    address(new HintHelpers()),\n                    admin,\n                    abi.encodeWithSelector(HintHelpers.initialize.selector)\n                )\n            )\n        );\n\n        priceFeed.setOracle(address(mockAggregator));\n        interestRateManager.setAddresses(\n            address(activePool),\n            address(borrowerOperations),\n            address(musd),\n            address(pcv),\n            address(troveManager)\n        );\n        hintHelpers.setAddresses(\n            address(borrowerOperations),\n            address(sortedTroves),\n            address(troveManager)\n        );\n        stabilityPool.setAddresses(\n            address(activePool),\n            address(borrowerOperations),\n            address(musd),\n            address(priceFeed),\n            address(sortedTroves),\n            address(troveManager)\n        );\n        pcv.setAddresses(address(borrowerOperations), address(musd));\n        defaultPool.setAddresses(address(activePool), address(troveManager));\n        activePool.setAddresses(\n            address(borrowerOperations),\n            address(collSurplusPool),\n            address(defaultPool),\n            address(interestRateManager),\n            address(stabilityPool),\n            address(troveManager)\n        );\n        borrowerOperations.setAddresses(\n            [\n                address(activePool),\n                address(borrowerOperationsSignatures),\n                address(collSurplusPool),\n                address(defaultPool),\n                address(gasPool),\n                address(governableVariables),\n                address(interestRateManager),\n                address(musd),\n                address(pcv),\n                address(priceFeed),\n                address(sortedTroves),\n                address(stabilityPool),\n                address(troveManager)\n            ]\n        );\n        collSurplusPool.setAddresses(\n            address(activePool),\n            address(borrowerOperations),\n            address(troveManager)\n        );\n        troveManager.setAddresses(\n            address(activePool),\n            address(borrowerOperations),\n            address(collSurplusPool),\n            address(defaultPool),\n            address(gasPool),\n            address(interestRateManager),\n            address(musd),\n            address(pcv),\n            address(priceFeed),\n            address(sortedTroves),\n            address(stabilityPool)\n        );\n        gasPool.setAddresses(address(musd), address(troveManager));\n        musd.initialize(\n            address(troveManager),\n            address(stabilityPool),\n            address(borrowerOperations),\n            address(interestRateManager)\n        );\n        sortedTroves.setParams(\n            0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff,\n            address(borrowerOperations),\n            address(troveManager)\n        );\n\n        // slither-disable-start arbitrary-send-eth\n        // slither-disable-start low-level-calls\n        // slither-disable-start calls-loop\n        for (uint i = 0; i < NUMBER_OF_ACTORS; i++) {\n            echidnaProxies[i] = new EchidnaProxy(\n                troveManager,\n                borrowerOperations,\n                stabilityPool,\n                musd\n            );\n\n            (bool success, ) = address(echidnaProxies[i]).call{\n                value: INITIAL_BALANCE\n            }(\"\");\n            require(success, \"proxy funding must work\");\n        }\n        // slither-disable-end calls-loop\n        // slither-disable-end low-level-calls\n        // slither-disable-end arbitrary-send-eth\n\n        MCR = borrowerOperations.getMCR();\n        CCR = borrowerOperations.getCCR();\n        MUSD_GAS_COMPENSATION = borrowerOperations.getGasComp();\n\n        // Set all of the admin permissions to the test contract\n        pcv.initializeDebt();\n        pcv.setFeeRecipient(msg.sender);\n        pcv.setFeeSplit(50);\n        pcv.startChangingRoles(address(this), address(this));\n        pcv.finalizeChangingRoles();\n        pcv.addRecipientToWhitelist(address(this));\n    }\n\n    // TroveManager\n\n    function liquidateExt(uint _i, uint _j) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        uint debtor = _j % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].liquidatePrx(address(echidnaProxies[debtor]));\n    }\n\n    // Raw method for fuzz testing\n    function redeemCollateralExt(\n        uint _i,\n        uint _MUSDAmount,\n        address _firstRedemptionHint,\n        address _upperPartialRedemptionHint,\n        address _lowerPartialRedemptionHint,\n        uint _partialRedemptionHintNICR\n    ) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].redeemCollateralPrx(\n            _MUSDAmount,\n            _firstRedemptionHint,\n            _upperPartialRedemptionHint,\n            _lowerPartialRedemptionHint,\n            _partialRedemptionHintNICR,\n            0\n        );\n    }\n\n    // Reliable method, otherwise hitting the correct NICR doesn't happen in a\n    // normal amount of runs and the normal redemption flow is not tested.\n    function redeemCollateralSafeExt(uint _i, uint _MUSDAmount) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        EchidnaProxy echidnaProxy = echidnaProxies[actor];\n        uint256 amount = _MUSDAmount % musd.balanceOf(address(echidnaProxy));\n        uint price = priceFeed.fetchPrice();\n        (\n            address firstRedemptionHint,\n            uint256 partialRedemptionHintNICR,\n            uint256 truncatedAmount\n        ) = hintHelpers.getRedemptionHints(\n                amount,\n                price,\n                sortedTroves.getSize() * 15\n            );\n        echidnaProxy.redeemCollateralPrx(\n            truncatedAmount,\n            firstRedemptionHint,\n            address(0),\n            address(0),\n            partialRedemptionHintNICR,\n            0\n        );\n    }\n\n    // Reliable method to use an actor's whole balance for redemption. Makes\n    // testing mutli-redemptions much more probable.\n    function redeemCollateralSafeEverythingExt(uint _i) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        EchidnaProxy echidnaProxy = echidnaProxies[actor];\n        uint256 amount = musd.balanceOf(address(echidnaProxy));\n        uint price = priceFeed.fetchPrice();\n        (\n            address firstRedemptionHint,\n            uint256 partialRedemptionHintNICR,\n            uint256 truncatedAmount\n        ) = hintHelpers.getRedemptionHints(\n                amount,\n                price,\n                sortedTroves.getSize() * 15\n            );\n        echidnaProxy.redeemCollateralPrx(\n            truncatedAmount,\n            firstRedemptionHint,\n            address(0),\n            address(0),\n            partialRedemptionHintNICR,\n            0\n        );\n    }\n\n    // Borrower Operations\n\n    function getAdjustedBTC(\n        uint actorBalance,\n        uint _BTC,\n        uint ratio\n    ) internal view returns (uint) {\n        uint price = priceFeed.fetchPrice();\n        require(price > 0, \"price must be at least 0\");\n        uint minBTC = (ratio * MUSD_GAS_COMPENSATION) / price;\n        require(actorBalance > minBTC, \"balance must be at least minimum\");\n        uint BTC = minBTC + (_BTC % (actorBalance - minBTC));\n        return BTC;\n    }\n\n    function getAdjustedMUSD(\n        uint BTC,\n        uint _MUSDAmount,\n        uint ratio\n    ) internal view returns (uint) {\n        uint price = priceFeed.fetchPrice();\n        uint MUSDAmount = _MUSDAmount;\n        uint compositeDebt = MUSDAmount + MUSD_GAS_COMPENSATION;\n        uint ICR = LiquityMath._computeCR(BTC, compositeDebt, price);\n        if (ICR < ratio) {\n            compositeDebt = (BTC * price) / ratio;\n            MUSDAmount = compositeDebt - MUSD_GAS_COMPENSATION;\n        }\n        return MUSDAmount;\n    }\n\n    // solhint-disable-next-line ordering\n    function openTroveExt(uint _i, uint _BTC, uint _MUSDAmount) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        EchidnaProxy echidnaProxy = echidnaProxies[actor];\n        uint actorBalance = address(echidnaProxy).balance;\n\n        // we pass in CCR instead of MCR in case it’s the first one\n        uint BTC = getAdjustedBTC(actorBalance, _BTC, CCR);\n        uint MUSDAmount = getAdjustedMUSD(BTC, _MUSDAmount, CCR);\n\n        echidnaProxy.openTrovePrx(BTC, MUSDAmount, address(0), address(0));\n\n        // slither-disable-next-line reentrancy-benign\n        numberOfTroves = troveManager.getTroveOwnersCount();\n        assert(numberOfTroves > 0);\n    }\n\n    // Reliable method to open a trove. Takes out a loan of [1800, 101800] MUSD\n    // with a [110, 1100] collateral ratio.\n    function openTroveSafeExt(\n        uint _i,\n        uint _extraMUSD,\n        uint _collatRatio\n    ) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        EchidnaProxy echidnaProxy = echidnaProxies[actor];\n        uint addedMUSD = (_extraMUSD % 100_000) * 1e18;\n        uint musdAmount = 1800e18 + addedMUSD;\n        uint collatRatio = 110 + (_collatRatio % 1000);\n        uint price = priceFeed.fetchPrice();\n        uint amountWithFees = musdAmount + musdAmount / 200 + 200e18;\n\n        uint BTC = (amountWithFees * collatRatio * 1e18) / (100 * price);\n\n        echidnaProxy.openTrovePrx(BTC, musdAmount, address(0), address(0));\n    }\n\n    function openTroveRawExt(\n        uint _i,\n        uint _BTC,\n        uint _MUSDAmount,\n        address _upperHint,\n        address _lowerHint\n    ) public payable {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].openTrovePrx(\n            _BTC,\n            _MUSDAmount,\n            _upperHint,\n            _lowerHint\n        );\n    }\n\n    function refinanceExt(uint _i) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].refinancePrx();\n    }\n\n    function addCollExt(uint _i, uint _BTC) external payable {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        EchidnaProxy echidnaProxy = echidnaProxies[actor];\n        uint actorBalance = address(echidnaProxy).balance;\n\n        uint BTC = getAdjustedBTC(actorBalance, _BTC, MCR);\n\n        echidnaProxy.addCollPrx(BTC, address(0), address(0));\n    }\n\n    function addCollRawExt(\n        uint _i,\n        uint _BTC,\n        address _upperHint,\n        address _lowerHint\n    ) external payable {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].addCollPrx(_BTC, _upperHint, _lowerHint);\n    }\n\n    function withdrawCollExt(\n        uint _i,\n        uint _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].withdrawCollPrx(_amount, _upperHint, _lowerHint);\n    }\n\n    function withdrawMUSDExt(\n        uint _i,\n        uint _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].withdrawMUSDPrx(_amount, _upperHint, _lowerHint);\n    }\n\n    function repayMUSDExt(\n        uint _i,\n        uint _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].repayMUSDPrx(_amount, _upperHint, _lowerHint);\n    }\n\n    function closeTroveExt(uint _i) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].closeTrovePrx();\n    }\n\n    // Reliable method to close a trove. Loops through actors until one of them\n    // can send the payer enough money to close their trove.\n    function closeTroveSafeExt(uint _i) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        EchidnaProxy closer = echidnaProxies[actor];\n        uint256 debt = troveManager.getTroveDebt(address(closer));\n        if (debt == 0) {\n            return;\n        }\n        if (musd.balanceOf(address(closer)) < debt + 10) {\n            uint256 need = debt + 10 - musd.balanceOf(address(closer));\n            uint count = 0;\n            uint payerIndex = (_i + 1) % NUMBER_OF_ACTORS;\n            address payer = address(echidnaProxies[payerIndex]);\n            // slither-disable-start calls-loop\n            while (musd.balanceOf(payer) < need && count < NUMBER_OF_ACTORS) {\n                payerIndex++;\n                payer = address(echidnaProxies[payerIndex]);\n                count++;\n            }\n            // slither-disable-end calls-loop\n\n            // slither-disable-next-line unused-return\n            echidnaProxies[payerIndex].transferPrx(\n                address(echidnaProxies[actor]),\n                need\n            );\n        }\n\n        closer.closeTrovePrx();\n    }\n\n    // Reliable method to successfully adjust troves.\n    function adjustTroveExt(\n        uint _i,\n        uint _BTC,\n        uint _collWithdrawal,\n        uint _debtChange,\n        bool _isDebtIncrease\n    ) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        EchidnaProxy echidnaProxy = echidnaProxies[actor];\n        uint actorBalance = address(echidnaProxy).balance;\n\n        uint BTC = getAdjustedBTC(actorBalance, _BTC, MCR);\n        uint debtChange = _debtChange;\n        if (_isDebtIncrease) {\n            debtChange = getAdjustedMUSD(BTC, uint(_debtChange), MCR);\n        }\n        echidnaProxy.adjustTrovePrx(\n            BTC,\n            _collWithdrawal,\n            debtChange,\n            _isDebtIncrease,\n            address(0),\n            address(0)\n        );\n    }\n\n    function adjustTroveRawExt(\n        uint _i,\n        uint _BTC,\n        uint _collWithdrawal,\n        uint _debtChange,\n        bool _isDebtIncrease,\n        address _upperHint,\n        address _lowerHint\n    ) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].adjustTrovePrx(\n            _BTC,\n            _collWithdrawal,\n            _debtChange,\n            _isDebtIncrease,\n            _upperHint,\n            _lowerHint\n        );\n    }\n\n    function claimCollateralExt(uint _i) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].claimCollateralPrx();\n    }\n\n    // Pool Manager\n\n    function provideToSPExt(uint _i, uint _amount) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].provideToSPPrx(_amount);\n    }\n\n    function withdrawFromSPExt(uint _i, uint _amount) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].withdrawFromSPPrx(_amount);\n    }\n\n    function withdrawCollateralGainToTroveExt(uint _i) external {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        echidnaProxies[actor].withdrawCollateralGainToTrovePrx();\n    }\n\n    function setRefinancingFeePercentageExt(\n        uint256 _refinanceFeePercentage\n    ) external {\n        borrowerOperations.setRefinancingFeePercentage(\n            uint8(_refinanceFeePercentage % 101)\n        );\n    }\n\n    function approveMinNetDebtExt() external {\n        borrowerOperations.approveMinNetDebt();\n    }\n\n    function proposeMinNetDebtExt(uint256 _minNetDebt) external {\n        borrowerOperations.proposeMinNetDebt(_minNetDebt);\n    }\n\n    // Interest Rate Manager\n\n    function proposeInterestRateExt(uint256 _rate) external {\n        interestRateManager.proposeInterestRate(uint16(_rate % 11_000));\n    }\n\n    function approveInterestRateExt() external {\n        interestRateManager.approveInterestRate();\n    }\n\n    // MUSD Token\n\n    function transferExt(\n        uint _i,\n        address recipient,\n        uint256 amount\n    ) external returns (bool) {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        return echidnaProxies[actor].transferPrx(recipient, amount);\n    }\n\n    function transferToOtherUser(\n        uint _senderIndex,\n        uint _receiverIndex,\n        uint256 _amount\n    ) external returns (bool) {\n        uint actor = _senderIndex % NUMBER_OF_ACTORS;\n        uint recipient = _receiverIndex % NUMBER_OF_ACTORS;\n        return\n            echidnaProxies[actor].transferPrx(\n                address(echidnaProxies[recipient]),\n                _amount\n            );\n    }\n\n    function approveExt(\n        uint _i,\n        address spender,\n        uint256 amount\n    ) external returns (bool) {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        return echidnaProxies[actor].approvePrx(spender, amount);\n    }\n\n    function transferFromExt(\n        uint _i,\n        address sender,\n        address recipient,\n        uint256 amount\n    ) external returns (bool) {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        return echidnaProxies[actor].transferFromPrx(sender, recipient, amount);\n    }\n\n    // PriceFeed\n\n    function setPriceExt(uint256 _price) external {\n        bool result = mockAggregator.setPrice(_price);\n        assert(result);\n    }\n\n    // PCV\n\n    function depositToStabilityPoolExt(uint _amount) external {\n        pcv.depositToStabilityPool(_amount);\n    }\n\n    function withdrawFromStabilityPoolExt(uint _amount) external {\n        pcv.withdrawFromStabilityPool(_amount);\n    }\n\n    function withdrawCollateralExt(uint _amount) external {\n        pcv.withdrawCollateral(msg.sender, _amount);\n    }\n\n    function withdrawMUSDExt(uint _amount) external {\n        pcv.withdrawMUSD(msg.sender, _amount);\n    }\n\n    function withdrawMUSDSafeExt(uint _amount) external {\n        uint256 bal = musd.balanceOf(address(pcv));\n        uint256 amount = _amount % bal;\n        pcv.withdrawMUSD(address(this), amount);\n    }\n\n    function distributeMUSDExt(uint _amount) external {\n        pcv.distributeMUSD(_amount);\n    }\n\n    function distributeMUSDSafeExt(uint _amount) external {\n        uint256 amount = _amount % musd.balanceOf(address(pcv));\n        pcv.distributeMUSD(amount);\n    }\n\n    function distributeMUSDFullExt() external {\n        pcv.distributeMUSD(musd.balanceOf(address(pcv)));\n    }\n\n    function payDebtExt() external {\n        uint musdAmount = pcv.debtToPay() * 2;\n\n        uint i = 0;\n        EchidnaProxy actor = echidnaProxies[i];\n        // slither-disable-start calls-loop\n        while (\n            i < NUMBER_OF_ACTORS &&\n            troveManager.getTroveDebt(address(actor)) > 0\n        ) {\n            i++;\n            actor = echidnaProxies[i];\n        }\n        // slither-disable-end calls-loop\n\n        uint price = priceFeed.fetchPrice();\n\n        uint BTC = (musdAmount * 2e18) / price;\n\n        actor.openTrovePrx(BTC, musdAmount, address(0), address(0));\n\n        // slither-disable-next-line unused-return\n        actor.transferPrx(address(pcv), musdAmount);\n    }\n\n    // debugging\n\n    function musdBalance(uint _i) external view returns (uint256) {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        return musd.balanceOf(address(echidnaProxies[actor]));\n    }\n\n    function getEntireDebtAndColl(\n        uint _i\n    )\n        external\n        view\n        returns (uint256, uint256, uint256, uint256, uint256, uint256)\n    {\n        uint actor = _i % NUMBER_OF_ACTORS;\n        // slither-disable-start unused-return\n        return\n            troveManager.getEntireDebtAndColl(address(echidnaProxies[actor]));\n        // slither-disable-end unused-return\n    }\n\n    function getEntireSystemColl() external view returns (uint256) {\n        return troveManager.viewGetEntireSystemColl();\n    }\n\n    function getEntireSystemDebt() external view returns (uint256) {\n        return troveManager.viewGetEntireSystemDebt();\n    }\n\n    // invariants\n\n    // solhint-disable-next-line func-name-mixedcase\n    function echidna_troves_order() external view returns (bool) {\n        address currentTrove = sortedTroves.getFirst();\n        address nextTrove = sortedTroves.getNext(currentTrove);\n\n        // slither-disable-start calls-loop\n        while (currentTrove != address(0) && nextTrove != address(0)) {\n            if (\n                troveManager.getNominalICR(nextTrove) >\n                troveManager.getNominalICR(currentTrove)\n            ) {\n                return false;\n            }\n\n            currentTrove = nextTrove;\n            nextTrove = sortedTroves.getNext(currentTrove);\n        }\n        // slither-disable-end calls-loop\n\n        return true;\n    }\n\n    // solhint-disable-next-line func-name-mixedcase\n    function echidna_trove_properties() public view returns (bool) {\n        address currentTrove = sortedTroves.getFirst();\n        // slither-disable-start calls-loop\n        while (currentTrove != address(0)) {\n            // Status\n            if (\n                ITroveManager.Status(\n                    troveManager.getTroveStatus(currentTrove)\n                ) != ITroveManager.Status.active\n            ) {\n                return false;\n            }\n\n            // slither-disable-start unused-return\n            (, uint256 principal, uint256 interest, , , ) = troveManager\n                .getEntireDebtAndColl(currentTrove);\n            // slither-disable-end unused-return\n\n            // You can not have a trove with 0 principal and some interest\n            if (principal == 0) {\n                if (interest > 0) {\n                    return false;\n                }\n            }\n\n            // Minimum debt (gas compensation)\n            if (\n                troveManager.getTroveDebt(currentTrove) < MUSD_GAS_COMPENSATION\n            ) {\n                return false;\n            }\n\n            // Stake > 0\n            if (troveManager.getTroveStake(currentTrove) == 0) {\n                return false;\n            }\n\n            currentTrove = sortedTroves.getNext(currentTrove);\n        }\n        // slither-disable-end calls-loop\n        return true;\n    }\n\n    // solhint-disable-next-line func-name-mixedcase\n    function echidna_sum_of_debt() public view returns (bool) {\n        uint256 troveDebt = 0;\n        uint256 troveColl = 0;\n        address currentTrove = sortedTroves.getFirst();\n        // slither-disable-start calls-loop\n        while (currentTrove != address(0)) {\n            // slither-disable-start unused-return\n            (\n                uint256 coll,\n                uint256 principal,\n                uint256 interest,\n                ,\n                ,\n\n            ) = troveManager.getEntireDebtAndColl(currentTrove);\n            // slither-disable-end unused-return\n            troveDebt += principal + interest;\n            troveColl += coll;\n\n            currentTrove = sortedTroves.getNext(currentTrove);\n        }\n        // slither-disable-end calls-loop\n\n        uint256 systemDebt = troveManager.viewGetEntireSystemDebt();\n        systemDebt -=\n            (troveManager.getLastPrincipalError_Redistribution() +\n                troveManager.getLastInterestError_Redistribution()) /\n            1e18;\n\n        bool debtMatches = true;\n        if (systemDebt > troveDebt) {\n            debtMatches = systemDebt - troveDebt <= 100;\n        } else {\n            debtMatches = troveDebt - systemDebt <= 100;\n        }\n\n        uint256 systemColl = troveManager.viewGetEntireSystemColl();\n        systemColl -=\n            troveManager.getLastCollateralError_Redistribution() /\n            1e18;\n\n        bool collMatches = true;\n        if (systemColl > troveColl) {\n            collMatches = systemColl - troveColl <= 100;\n        } else {\n            collMatches = troveColl - systemColl <= 100;\n        }\n\n        return collMatches && debtMatches;\n    }\n\n    // solhint-disable-next-line func-name-mixedcase\n    function echidna_BTC_balances() public view returns (bool) {\n        if (address(troveManager).balance > 0) {\n            return false;\n        }\n\n        if (address(borrowerOperations).balance > 0) {\n            return false;\n        }\n\n        if (address(activePool).balance != activePool.getCollateralBalance()) {\n            return false;\n        }\n\n        if (\n            address(defaultPool).balance != defaultPool.getCollateralBalance()\n        ) {\n            return false;\n        }\n\n        if (\n            address(stabilityPool).balance !=\n            stabilityPool.getCollateralBalance()\n        ) {\n            return false;\n        }\n\n        if (address(musd).balance > 0) {\n            return false;\n        }\n\n        if (address(priceFeed).balance > 0) {\n            return false;\n        }\n\n        if (address(sortedTroves).balance > 0) {\n            return false;\n        }\n\n        return true;\n    }\n}\n"
    },
    "contracts/echidna/IBorrowerOperationsFuzzTester.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../interfaces/IBorrowerOperations.sol\";\n\ninterface IBorrowerOperationsFuzzTester is IBorrowerOperations {\n    function getMCR() external view returns (uint256);\n\n    function getCCR() external view returns (uint256);\n\n    function getGasComp() external view returns (uint256);\n}\n"
    },
    "contracts/echidna/ITroveManagerFuzzTester.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../interfaces/ITroveManager.sol\";\n\ninterface ITroveManagerFuzzTester is ITroveManager {\n    function viewGetEntireSystemColl() external view returns (uint256);\n\n    function viewGetEntireSystemDebt() external view returns (uint256);\n\n    // solhint-disable-next-line func-name-mixedcase\n    function getLastCollateralError_Redistribution()\n        external\n        view\n        returns (uint256);\n\n    // solhint-disable-next-line func-name-mixedcase\n    function getLastPrincipalError_Redistribution()\n        external\n        view\n        returns (uint256);\n\n    // solhint-disable-next-line func-name-mixedcase\n    function getLastInterestError_Redistribution()\n        external\n        view\n        returns (uint256);\n}\n"
    },
    "contracts/echidna/TroveManagerFuzzTester.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../TroveManager.sol\";\nimport \"./ITroveManagerFuzzTester.sol\";\n\ncontract TroveManagerFuzzTester is TroveManager, ITroveManagerFuzzTester {\n    // solhint-disable-next-line func-name-mixedcase\n    function getLastCollateralError_Redistribution()\n        external\n        view\n        returns (uint256)\n    {\n        return lastCollateralError_Redistribution;\n    }\n\n    // solhint-disable-next-line func-name-mixedcase\n    function getLastPrincipalError_Redistribution()\n        external\n        view\n        returns (uint256)\n    {\n        return lastPrincipalError_Redistribution;\n    }\n\n    // solhint-disable-next-line func-name-mixedcase\n    function getLastInterestError_Redistribution()\n        external\n        view\n        returns (uint256)\n    {\n        return lastInterestError_Redistribution;\n    }\n\n    function viewGetEntireSystemColl() external view returns (uint256) {\n        return getEntireSystemColl();\n    }\n\n    function viewGetEntireSystemDebt() external view returns (uint256) {\n        return getEntireSystemDebt();\n    }\n}\n"
    },
    "contracts/GasPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"./dependencies/CheckContract.sol\";\nimport \"./interfaces/IGasPool.sol\";\nimport \"./token/MUSD.sol\";\n\n/**\n * The purpose of this contract is to hold mUSD tokens for gas compensation:\n * https://github.com/liquity/dev#gas-compensation\n * When a borrower opens a trove, an additional 50 mUSD principal is issued,\n * and 50 mUSD is minted and sent to this contract.\n * When a borrower closes their active trove, this gas compensation is refunded:\n * 50 mUSD is burned from the this contract's balance, and the corresponding\n * 50 mUSD principal on the trove is cancelled.\n * See this issue for more context: https://github.com/liquity/dev/issues/186\n */\ncontract GasPool is CheckContract, IGasPool, OwnableUpgradeable {\n    address public troveManagerAddress;\n    IMUSD public musdToken;\n\n    function initialize() external initializer {\n        __Ownable_init(msg.sender);\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    function setAddresses(\n        address _musdTokenAddress,\n        address _troveManagerAddress\n    ) external onlyOwner {\n        checkContract(_musdTokenAddress);\n        checkContract(_troveManagerAddress);\n\n        musdToken = IMUSD(_musdTokenAddress);\n        // slither-disable-next-line missing-zero-check\n        troveManagerAddress = _troveManagerAddress;\n\n        emit TroveManagerAddressChanged(_troveManagerAddress);\n        emit MUSDTokenAddressChanged(_musdTokenAddress);\n\n        renounceOwnership();\n    }\n\n    function sendMUSD(address _account, uint256 _amount) external override {\n        require(\n            msg.sender == troveManagerAddress,\n            \"GasPool: Caller is not the TroveManager\"\n        );\n        require(\n            musdToken.transfer(_account, _amount),\n            \"GasPool: sending mUSD failed\"\n        );\n    }\n}\n"
    },
    "contracts/GovernableVariables.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"./interfaces/IGovernableVariables.sol\";\n\ncontract GovernableVariables is IGovernableVariables, OwnableUpgradeable {\n    address public council;\n    address public treasury;\n\n    uint256 public governanceTimeDelay;\n\n    address public pendingCouncilAddress;\n    address public pendingTreasuryAddress;\n    uint256 public changingRolesInitiated;\n\n    // Fee Exemption\n    mapping(address => bool) public feeExemptAccounts;\n\n    modifier onlyGovernance() {\n        require(\n            msg.sender == council || msg.sender == treasury,\n            \"GovernableVariables: Only governance can call this function\"\n        );\n        _;\n    }\n\n    function initialize(uint256 _governanceTimeDelay) external initializer {\n        __Ownable_init(msg.sender);\n\n        require(\n            _governanceTimeDelay <= 30 weeks,\n            \"Governance delay is too big\"\n        );\n        governanceTimeDelay = _governanceTimeDelay;\n    }\n\n    function startChangingRoles(\n        address _council,\n        address _treasury\n    ) external onlyOwner {\n        require(\n            _council != council || _treasury != treasury,\n            \"GovernableVariables: these roles are already set\"\n        );\n\n        // solhint-disable-next-line not-rely-on-time\n        changingRolesInitiated = block.timestamp;\n        if (council == address(0) && treasury == address(0)) {\n            // solhint-disable-next-line not-rely-on-time\n            changingRolesInitiated -= governanceTimeDelay; // skip delay if no roles set\n        }\n        pendingCouncilAddress = _council;\n        pendingTreasuryAddress = _treasury;\n    }\n\n    function cancelChangingRoles() external onlyOwner {\n        require(\n            changingRolesInitiated != 0,\n            \"GovernableVariables: Change not initiated\"\n        );\n\n        changingRolesInitiated = 0;\n        pendingCouncilAddress = address(0);\n        pendingTreasuryAddress = address(0);\n    }\n\n    function finalizeChangingRoles() external onlyOwner {\n        require(\n            changingRolesInitiated > 0,\n            \"GovernableVariables: Change not initiated\"\n        );\n        require(\n            // solhint-disable-next-line not-rely-on-time\n            block.timestamp >= changingRolesInitiated + governanceTimeDelay,\n            \"GovernableVariables: Governance delay has not elapsed\"\n        );\n\n        council = pendingCouncilAddress;\n        treasury = pendingTreasuryAddress;\n        emit RolesSet(council, treasury);\n\n        changingRolesInitiated = 0;\n        pendingCouncilAddress = address(0);\n        pendingTreasuryAddress = address(0);\n    }\n\n    function removeFeeExemptAccounts(\n        address[] calldata _accounts\n    ) external onlyGovernance {\n        require(\n            _accounts.length > 0,\n            \"GovernableVariables: Fee Exempt array must not be empty\"\n        );\n        uint accountLength = _accounts.length;\n        for (uint256 i = 0; i < accountLength; i++) {\n            removeFeeExemptAccount(_accounts[i]);\n        }\n    }\n\n    function addFeeExemptAccounts(\n        address[] calldata _accounts\n    ) external onlyGovernance {\n        require(\n            _accounts.length > 0,\n            \"GovernableVariables: Fee Exempt array must not be empty.\"\n        );\n        uint accountLength = _accounts.length;\n        for (uint256 i = 0; i < accountLength; i++) {\n            addFeeExemptAccount(_accounts[i]);\n        }\n    }\n\n    function isAccountFeeExempt(address _account) external view returns (bool) {\n        return feeExemptAccounts[_account];\n    }\n\n    function addFeeExemptAccount(address _account) public onlyGovernance {\n        require(\n            !feeExemptAccounts[_account],\n            \"GovernableVariables: Account must not already be exempt.\"\n        );\n\n        feeExemptAccounts[_account] = true;\n        emit FeeExemptAccountAdded(_account);\n    }\n\n    function removeFeeExemptAccount(address _account) public onlyGovernance {\n        require(\n            feeExemptAccounts[_account],\n            \"GovernableVariables: Account must currently be exempt.\"\n        );\n\n        feeExemptAccounts[_account] = false;\n        emit FeeExemptAccountRemoved(_account);\n    }\n}\n"
    },
    "contracts/HintHelpers.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"./dependencies/CheckContract.sol\";\nimport \"./dependencies/InterestRateMath.sol\";\nimport \"./dependencies/LiquityBase.sol\";\nimport \"./interfaces/IBorrowerOperations.sol\";\nimport \"./interfaces/ISortedTroves.sol\";\nimport \"./interfaces/ITroveManager.sol\";\nimport \"./interfaces/IHintHelpers.sol\";\n\ncontract HintHelpers is\n    CheckContract,\n    IHintHelpers,\n    LiquityBase,\n    OwnableUpgradeable\n{\n    string public constant NAME = \"HintHelpers\";\n\n    IBorrowerOperations public borrowerOperations;\n    ISortedTroves public sortedTroves;\n    ITroveManager public troveManager;\n\n    // --- Events ---\n\n    function initialize() external initializer {\n        __Ownable_init(msg.sender);\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    // --- Dependency setters ---\n\n    function setAddresses(\n        address _borrowerOperationsAddress,\n        address _sortedTrovesAddress,\n        address _troveManagerAddress\n    ) external onlyOwner {\n        checkContract(_borrowerOperationsAddress);\n        checkContract(_sortedTrovesAddress);\n        checkContract(_troveManagerAddress);\n\n        borrowerOperations = IBorrowerOperations(_borrowerOperationsAddress);\n        sortedTroves = ISortedTroves(_sortedTrovesAddress);\n        troveManager = ITroveManager(_troveManagerAddress);\n\n        emit BorrowerOperationsAddressChanged(_borrowerOperationsAddress);\n        emit SortedTrovesAddressChanged(_sortedTrovesAddress);\n        emit TroveManagerAddressChanged(_troveManagerAddress);\n\n        renounceOwnership();\n    }\n\n    // --- Functions ---\n\n    /* getRedemptionHints() - Helper function for finding the right hints to pass to redeemCollateral().\n     *\n     * It simulates a redemption of `_amount` to figure out where the redemption sequence will start and what state the final Trove\n     * of the sequence will end up in.\n     *\n     * Returns three hints:\n     *  - `firstRedemptionHint` is the address of the first Trove with ICR >= MCR (i.e. the first Trove that will be redeemed).\n     *  - `partialRedemptionHintNICR` is the final nominal ICR of the last Trove of the sequence after being hit by partial redemption,\n     *     or zero in case of no partial redemption.\n     *  - `truncatedAmount` is the maximum amount that can be redeemed out of the the provided `_amount`. This can be lower than\n     *    `_amount` when redeeming the full amount would leave the last Trove of the redemption sequence with less net debt than the\n     *    minimum allowed value (i.e. minNetDebt).\n     *\n     * The number of Troves to consider for redemption can be capped by passing a non-zero value as `_maxIterations`, while passing zero\n     * will leave it uncapped.\n     */\n\n    function getRedemptionHints(\n        uint256 _amount,\n        uint256 _price,\n        uint256 _maxIterations\n    )\n        external\n        view\n        returns (\n            address firstRedemptionHint,\n            uint256 partialRedemptionHintNICR,\n            uint256 truncatedAmount\n        )\n    {\n        ISortedTroves sortedTrovesCached = sortedTroves;\n\n        uint256 remainingMUSD = _amount;\n        address currentTroveuser = sortedTrovesCached.getLast();\n\n        // slither-disable-start calls-loop\n        while (\n            currentTroveuser != address(0) &&\n            troveManager.getCurrentICR(currentTroveuser, _price) < MCR\n        ) {\n            currentTroveuser = sortedTrovesCached.getPrev(currentTroveuser);\n        }\n\n        firstRedemptionHint = currentTroveuser;\n\n        if (_maxIterations == 0) {\n            _maxIterations = type(uint256).max;\n        }\n\n        uint256 minNetDebt = borrowerOperations.minNetDebt();\n\n        while (\n            currentTroveuser != address(0) &&\n            remainingMUSD > 0 &&\n            _maxIterations > 0\n        ) {\n            _maxIterations--;\n\n            if (troveManager.getCurrentICR(currentTroveuser, _price) < MCR) {\n                currentTroveuser = sortedTrovesCached.getPrev(currentTroveuser);\n                continue;\n            }\n\n            // slither-disable-start unused-return\n            (\n                uint256 coll,\n                uint256 principal,\n                uint256 interest,\n                ,\n                ,\n\n            ) = troveManager.getEntireDebtAndColl(currentTroveuser);\n            // slither-disable-end unused-return\n\n            uint256 netDebt = _getNetDebt(principal + interest);\n\n            if (netDebt > remainingMUSD) {\n                if (netDebt <= minNetDebt) {\n                    break;\n                }\n\n                uint256 maxRedeemableMUSD = LiquityMath._min(\n                    remainingMUSD,\n                    netDebt - minNetDebt\n                );\n\n                coll -= ((maxRedeemableMUSD * DECIMAL_PRECISION) / _price);\n\n                // slither-disable-start unused-return\n                (uint256 principalAdjustment, ) = InterestRateMath\n                    .calculateDebtAdjustment(interest, maxRedeemableMUSD);\n                // slither-disable-end unused-return\n\n                principal -= principalAdjustment;\n\n                partialRedemptionHintNICR = LiquityMath._computeNominalCR(\n                    coll,\n                    principal\n                );\n\n                remainingMUSD -= maxRedeemableMUSD;\n            } else {\n                remainingMUSD -= netDebt;\n            }\n\n            // slither-disable-start write-after-write\n            currentTroveuser = sortedTrovesCached.getPrev(currentTroveuser);\n        }\n        // slither-disable-end calls-loop\n\n        truncatedAmount = _amount - remainingMUSD;\n    }\n\n    /* getApproxHint() - return address of a Trove that is, on average, (length / numTrials) positions away in the\n    sortedTroves list from the correct insert position of the Trove to be inserted.\n\n    Note: The output address is worst-case O(n) positions away from the correct insert position, however, the function\n    is probabilistic. Input can be tuned to guarantee results to a high degree of confidence, e.g:\n\n    Submitting numTrials = k * sqrt(length), with k = 15 makes it very, very likely that the ouput address will\n    be <= sqrt(length) positions away from the correct insert position.\n    */\n    function getApproxHint(\n        uint256 _CR,\n        uint256 _numTrials,\n        uint256 _inputRandomSeed\n    )\n        external\n        view\n        returns (address hintAddress, uint256 diff, uint256 latestRandomSeed)\n    {\n        uint256 arrayLength = troveManager.getTroveOwnersCount();\n\n        if (arrayLength == 0) {\n            return (address(0), 0, _inputRandomSeed);\n        }\n\n        hintAddress = sortedTroves.getLast();\n        diff = LiquityMath._getAbsoluteDifference(\n            _CR,\n            troveManager.getNominalICR(hintAddress)\n        );\n        latestRandomSeed = _inputRandomSeed;\n\n        uint256 i = 1;\n\n        // slither-disable-start calls-loop\n        while (i < _numTrials) {\n            latestRandomSeed = uint(\n                keccak256(abi.encodePacked(latestRandomSeed))\n            );\n\n            uint256 arrayIndex = latestRandomSeed % arrayLength;\n            address currentAddress = troveManager.getTroveFromTroveOwnersArray(\n                arrayIndex\n            );\n            uint256 currentNICR = troveManager.getNominalICR(currentAddress);\n\n            // check if abs(current - CR) > abs(closest - CR), and update closest if current is closer\n            uint256 currentDiff = LiquityMath._getAbsoluteDifference(\n                currentNICR,\n                _CR\n            );\n\n            if (currentDiff < diff) {\n                diff = currentDiff;\n                hintAddress = currentAddress;\n            }\n            i++;\n        }\n        // slither-disable-end calls-loop\n    }\n\n    function computeNominalCR(\n        uint256 _coll,\n        uint256 _debt\n    ) external pure returns (uint) {\n        return LiquityMath._computeNominalCR(_coll, _debt);\n    }\n\n    function computeCR(\n        uint256 _coll,\n        uint256 _debt,\n        uint256 _price\n    ) external pure returns (uint) {\n        return LiquityMath._computeCR(_coll, _debt, _price);\n    }\n}\n"
    },
    "contracts/InterestRateManager.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"./dependencies/InterestRateMath.sol\";\nimport \"./token/IMUSD.sol\";\nimport {CheckContract} from \"./dependencies/CheckContract.sol\";\nimport {IActivePool} from \"./interfaces/IActivePool.sol\";\nimport {IInterestRateManager} from \"./interfaces/IInterestRateManager.sol\";\nimport {IPCV} from \"./interfaces/IPCV.sol\";\nimport {ITroveManager} from \"./interfaces/ITroveManager.sol\";\n\ncontract InterestRateManager is\n    CheckContract,\n    IInterestRateManager,\n    OwnableUpgradeable\n{\n    // Current interest rate per year in basis points\n    uint16 public interestRate;\n\n    // Proposed interest rate -- must be approved by governance after a minimum delay\n    uint16 public proposedInterestRate;\n    uint256 public proposedInterestRateTime;\n\n    // Minimum time delay between interest rate proposal and approval\n    uint256 public constant MIN_DELAY = 7 days;\n\n    // Maximum interest rate that can be set. Set to 100% (10000 bps)\n    uint16 public constant MAX_INTEREST_RATE = 10_000;\n\n    // In order to calculate interest on a trove, we calculate:\n    //\n    // (now - lastUpdatedTime) * principal * interestRate / (10000 * secondsInAYear)\n    //\n    // To calculate the interest on two troves (A and B)) with two different\n    // interest rates is then:\n    //\n    // (now - lastUpdatedTimeA) * principalA * interestRateA / (10000 * secondsInAYear) +\n    // (now - lastUpdatedTimeB) * principalB * interestRateB / (10000 * secondsInAYear)\n    //\n    // To simplify this and make it so that we do not need to loop over a list\n    // of troves, we track the sum of principal * interestRate as the variable\n    // `interestNumerator`.\n    //\n    // This lets us calculate interest as:\n    //\n    // (now - lastUpdatedTime) * interestNumerator / (10000 * secondsInAYear)\n    //\n    // Each time the principal change or we accrue interest, we update the\n    // `lastUpdatedTime` and the `interestNumerator` accordingly.\n    uint256 public interestNumerator;\n    uint256 public lastUpdatedTime;\n\n    IActivePool public activePool;\n    address public borrowerOperationsAddress;\n    IMUSD public musdToken;\n    IPCV internal pcv;\n    ITroveManager internal troveManager;\n\n    modifier onlyGovernance() {\n        require(\n            msg.sender == pcv.council(),\n            \"InterestRateManager: Only governance can call this function\"\n        );\n        _;\n    }\n\n    modifier onlyTroveManager() {\n        require(\n            msg.sender == address(troveManager),\n            \"InterestRateManager: Only TroveManager may call this function.\"\n        );\n        _;\n    }\n\n    modifier onlyBorrowerOperationsOrTroveManager() {\n        require(\n            msg.sender == borrowerOperationsAddress ||\n                msg.sender == address(troveManager),\n            \"InterestRateManager: Only BorrowerOperations or TroveManager may call this function.\"\n        );\n        _;\n    }\n\n    function initialize() external initializer {\n        interestRate = 100; // 1%\n        proposedInterestRate = interestRate;\n\n        // solhint-disable-next-line not-rely-on-time\n        proposedInterestRateTime = block.timestamp;\n        __Ownable_init(msg.sender);\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    function setAddresses(\n        address _activePoolAddress,\n        address _borrowerOperationsAddress,\n        address _musdTokenAddress,\n        address _pcvAddress,\n        address _troveManagerAddress\n    ) external onlyOwner {\n        checkContract(_activePoolAddress);\n        checkContract(_borrowerOperationsAddress);\n        checkContract(_musdTokenAddress);\n        checkContract(_pcvAddress);\n        checkContract(_troveManagerAddress);\n\n        activePool = IActivePool(_activePoolAddress);\n        // slither-disable-next-line missing-zero-check\n        borrowerOperationsAddress = _borrowerOperationsAddress;\n        musdToken = IMUSD(_musdTokenAddress);\n        pcv = IPCV(_pcvAddress);\n        troveManager = ITroveManager(_troveManagerAddress);\n\n        emit ActivePoolAddressChanged(_activePoolAddress);\n        emit MUSDTokenAddressChanged(_musdTokenAddress);\n        emit PCVAddressChanged(_pcvAddress);\n        emit TroveManagerAddressChanged(_troveManagerAddress);\n\n        renounceOwnership();\n    }\n\n    function proposeInterestRate(\n        uint16 _newProposedInterestRate\n    ) external onlyGovernance {\n        require(\n            _newProposedInterestRate <= MAX_INTEREST_RATE,\n            \"Interest rate exceeds the maximum interest rate\"\n        );\n        proposedInterestRate = _newProposedInterestRate;\n        // solhint-disable-next-line not-rely-on-time\n        proposedInterestRateTime = block.timestamp;\n        emit InterestRateProposed(\n            proposedInterestRate,\n            proposedInterestRateTime\n        );\n    }\n\n    function approveInterestRate() external onlyGovernance {\n        // solhint-disable not-rely-on-time\n        require(\n            block.timestamp >= proposedInterestRateTime + MIN_DELAY,\n            \"Proposal delay not met\"\n        );\n        // solhint-enable not-rely-on-time\n        _setInterestRate(proposedInterestRate);\n    }\n\n    function addPrincipal(\n        uint256 _principal,\n        uint16 _rate\n    ) external onlyBorrowerOperationsOrTroveManager {\n        interestNumerator += _principal * _rate;\n        emit InterestNumeratorChanged(interestNumerator);\n    }\n\n    function updateSystemInterest() external {\n        uint256 updatedTimeSnapshot = lastUpdatedTime;\n        // solhint-disable-next-line not-rely-on-time\n        lastUpdatedTime = block.timestamp;\n\n        if (interestNumerator == 0) {\n            return;\n        }\n\n        // solhint-disable not-rely-on-time\n        uint256 interest = InterestRateMath.calculateAggregatedInterestOwed(\n            interestNumerator,\n            updatedTimeSnapshot,\n            block.timestamp\n        );\n        // solhint-enable not-rely-on-time\n\n        // slither-disable-next-line calls-loop\n        musdToken.mint(address(pcv), interest);\n\n        // slither-disable-next-line calls-loop\n        activePool.increaseDebt(0, interest);\n    }\n\n    function updateTroveDebt(\n        uint256 _interestOwed,\n        uint256 _payment,\n        uint16 _rate\n    )\n        external\n        onlyTroveManager\n        returns (uint256 principalAdjustment, uint256 interestAdjustment)\n    {\n        (principalAdjustment, interestAdjustment) = InterestRateMath\n            .calculateDebtAdjustment(_interestOwed, _payment);\n\n        removePrincipal(principalAdjustment, _rate);\n    }\n\n    function removePrincipal(\n        uint256 _principal,\n        uint16 _rate\n    ) public onlyBorrowerOperationsOrTroveManager {\n        interestNumerator -= _principal * _rate;\n        emit InterestNumeratorChanged(interestNumerator);\n    }\n\n    function getAccruedInterest() public view returns (uint256) {\n        //solhint-disable not-rely-on-time\n        return\n            InterestRateMath.calculateAggregatedInterestOwed(\n                interestNumerator,\n                lastUpdatedTime,\n                block.timestamp\n            );\n        //solhint-enable not-rely-on-time\n    }\n\n    // slither-disable-start reentrancy-benign\n    // slither-disable-start reentrancy-events\n    function _setInterestRate(uint16 _newInterestRate) internal {\n        troveManager.updateSystemInterest();\n        interestRate = _newInterestRate;\n        emit InterestRateUpdated(_newInterestRate);\n    }\n    // slither-disable-end reentrancy-benign\n    // slither-disable-end reentrancy-events\n}\n"
    },
    "contracts/interfaces/ChainlinkAggregatorV3Interface.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\ninterface ChainlinkAggregatorV3Interface {\n    function decimals() external view returns (uint8);\n\n    function latestRoundData()\n        external\n        view\n        returns (\n            uint80 roundId,\n            int256 answer,\n            uint256 startedAt,\n            uint256 updatedAt,\n            uint80 answeredInRound\n        );\n}\n"
    },
    "contracts/interfaces/IActivePool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"./IPool.sol\";\n\ninterface IActivePool is IPool {\n    // --- Events ---\n    event BorrowerOperationsAddressChanged(\n        address _newBorrowerOperationsAddress\n    );\n    event CollSurplusPoolAddressChanged(address _newCollSurplusPoolAddress);\n    event InterestRateManagerAddressChanged(\n        address _interestRateManagerAddress\n    );\n    event TroveManagerAddressChanged(address _newTroveManagerAddress);\n\n    event ActivePoolDebtUpdated(uint256 _principal, uint256 _interest);\n    event ActivePoolCollateralBalanceUpdated(uint256 _collateral);\n\n    // --- Functions ---\n    function sendCollateral(address _account, uint256 _amount) external;\n\n    function setAddresses(\n        address _borrowerOperationsAddress,\n        address _collSurplusPoolAddress,\n        address _defaultPoolAddress,\n        address _interestRateManagerAddress,\n        address _stabilityPoolAddress,\n        address _troveManagerAddress\n    ) external;\n}\n"
    },
    "contracts/interfaces/IApproveAndCall.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.24;\n\n/// @notice An interface that should be implemented by tokens supporting\n///         `approveAndCall`/`receiveApproval` pattern.\ninterface IApproveAndCall {\n    /// @notice Executes `receiveApproval` function on spender as specified in\n    ///         `IReceiveApproval` interface previously approving tokens.\n    function approveAndCall(\n        address spender,\n        uint256 amount,\n        bytes memory extraData\n    ) external returns (bool);\n}\n"
    },
    "contracts/interfaces/IBorrowerOperations.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\n// Common interface for the Trove Manager.\ninterface IBorrowerOperations {\n    // --- Events ---\n\n    event ActivePoolAddressChanged(address _activePoolAddress);\n    event BorrowingRateChanged(uint256 borrowingRate);\n    event BorrowingRateProposed(\n        uint256 proposedBorrowingRate,\n        uint256 proposedBorrowingRateTime\n    );\n    event BorrowerOperationsSignaturesAddressChanged(\n        address _borrowerOperationsSignaturesAddress\n    );\n    event CollSurplusPoolAddressChanged(address _collSurplusPoolAddress);\n    event DefaultPoolAddressChanged(address _defaultPoolAddress);\n    event GasPoolAddressChanged(address _gasPoolAddress);\n    event GovernableVariablesAddressChanged(\n        address _governableVariablesAddress\n    );\n    event InterestRateManagerAddressChanged(\n        address _interestRateManagerAddress\n    );\n    event MUSDTokenAddressChanged(address _musdTokenAddress);\n    event MinNetDebtChanged(uint256 _minNetDebt);\n    event MinNetDebtProposed(uint256 _minNetDebt, uint256 _proposalTime);\n    event PCVAddressChanged(address _pcvAddress);\n    event PriceFeedAddressChanged(address _newPriceFeedAddress);\n    event RedemptionRateChanged(uint256 redemptionRate);\n    event RedemptionRateProposed(\n        uint256 proposedRedemptionRate,\n        uint256 proposedRedemptionRateTime\n    );\n    event RefinancingFeePercentageChanged(uint8 _refinanceFeePercentage);\n    event SortedTrovesAddressChanged(address _sortedTrovesAddress);\n    event StabilityPoolAddressChanged(address _stabilityPoolAddress);\n    event TroveManagerAddressChanged(address _newTroveManagerAddress);\n    event TroveCreated(address indexed _borrower, uint256 arrayIndex);\n    event TroveUpdated(\n        address indexed _borrower,\n        uint256 _principal,\n        uint256 _interest,\n        uint256 _coll,\n        uint256 stake,\n        uint8 operation\n    );\n    event BorrowingFeePaid(address indexed _borrower, uint256 _fee);\n    event RefinancingFeePaid(address indexed _borrower, uint256 _fee);\n\n    // --- Functions ---\n\n    function setAddresses(address[13] memory addresses) external;\n\n    function setRefinancingFeePercentage(\n        uint8 _refinanceFeePercentage\n    ) external;\n\n    function openTrove(\n        uint256 _debtAmount,\n        address _upperHint,\n        address _lowerHint\n    ) external payable;\n\n    function restrictedOpenTrove(\n        address _borrower,\n        address _recipient,\n        uint256 _debtAmount,\n        address _upperHint,\n        address _lowerHint\n    ) external payable;\n\n    function proposeMinNetDebt(uint256 _minNetDebt) external;\n\n    function approveMinNetDebt() external;\n\n    function addColl(address _upperHint, address _lowerHint) external payable;\n\n    function moveCollateralGainToTrove(\n        address _borrower,\n        address _upperHint,\n        address _lowerHint\n    ) external payable;\n\n    function withdrawColl(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external;\n\n    function withdrawMUSD(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external;\n\n    function repayMUSD(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint\n    ) external;\n\n    function closeTrove() external;\n\n    function restrictedCloseTrove(\n        address _borrower,\n        address _caller,\n        address _recipient\n    ) external;\n\n    function refinance(address _upperHint, address _lowerHint) external;\n\n    function restrictedRefinance(\n        address _borrower,\n        address _upperHint,\n        address _lowerHint\n    ) external;\n\n    function adjustTrove(\n        uint256 _collWithdrawal,\n        uint256 _debtChange,\n        bool _isDebtIncrease,\n        address _upperHint,\n        address _lowerHint\n    ) external payable;\n\n    function restrictedAdjustTrove(\n        address _borrower,\n        address _recipient,\n        address _caller,\n        uint256 _collWithdrawal,\n        uint256 _mUSDChange,\n        bool _isDebtIncrease,\n        address _upperHint,\n        address _lowerHint\n    ) external payable;\n\n    function claimCollateral() external;\n\n    function restrictedClaimCollateral(\n        address _borrower,\n        address _recipient\n    ) external;\n\n    function getBorrowingFee(uint256 _debt) external view returns (uint);\n\n    function getRedemptionRate(\n        uint256 _collateralDrawn\n    ) external view returns (uint256);\n\n    function minNetDebt() external view returns (uint256);\n}\n"
    },
    "contracts/interfaces/IBorrowerOperationsSignatures.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\ninterface IBorrowerOperationsSignatures {\n    function setAddresses(\n        address _borrowerOperationsAddress,\n        address _interestRateManagerAddress\n    ) external;\n\n    function addCollWithSignature(\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external payable;\n\n    function closeTroveWithSignature(\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external;\n\n    function claimCollateralWithSignature(\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external;\n\n    function adjustTroveWithSignature(\n        uint256 _collWithdrawal,\n        uint256 _debtChange,\n        bool _isDebtIncrease,\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external payable;\n\n    function withdrawCollWithSignature(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external;\n\n    function openTroveWithSignature(\n        uint256 _debtAmount,\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external payable;\n\n    function withdrawMUSDWithSignature(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        address _recipient,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external;\n\n    function repayMUSDWithSignature(\n        uint256 _amount,\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external;\n\n    function refinanceWithSignature(\n        address _upperHint,\n        address _lowerHint,\n        address _borrower,\n        bytes memory _signature,\n        uint256 _deadline\n    ) external;\n\n    function getNonce(address user) external view returns (uint256);\n}\n"
    },
    "contracts/interfaces/ICollSurplusPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\ninterface ICollSurplusPool {\n    // --- Events ---\n\n    event ActivePoolAddressChanged(address _newActivePoolAddress);\n    event BorrowerOperationsAddressChanged(\n        address _newBorrowerOperationsAddress\n    );\n    event TroveManagerAddressChanged(address _newTroveManagerAddress);\n\n    event CollBalanceUpdated(address indexed _account, uint256 _newBalance);\n    event CollateralSent(address _to, uint256 _amount);\n\n    // --- Contract setters ---\n\n    function setAddresses(\n        address _activePoolAddress,\n        address _borrowerOperationsAddress,\n        address _troveManagerAddress\n    ) external;\n\n    function accountSurplus(address _account, uint256 _amount) external;\n\n    function claimColl(address _account, address _recipient) external;\n\n    function getCollateralBalance() external view returns (uint);\n\n    function getCollateral(address _account) external view returns (uint);\n}\n"
    },
    "contracts/interfaces/IDefaultPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"./IPool.sol\";\n\ninterface IDefaultPool is IPool {\n    // --- Events ---\n    event TroveManagerAddressChanged(address _newTroveManagerAddress);\n    event DefaultPoolDebtUpdated(uint256 _principal, uint256 _interest);\n    event DefaultPoolCollateralBalanceUpdated(uint256 _collateral);\n\n    // --- Functions ---\n    function sendCollateralToActivePool(uint256 _amount) external;\n\n    function setAddresses(\n        address _activePoolAddress,\n        address _troveManagerAddress\n    ) external;\n}\n"
    },
    "contracts/interfaces/IGasPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\ninterface IGasPool {\n    // --- Events ---\n    event TroveManagerAddressChanged(address _newTroveManagerAddress);\n    event MUSDTokenAddressChanged(address _musdTokenAddress);\n\n    // --- Functions ---\n    function sendMUSD(address _account, uint256 _amount) external;\n\n    function setAddresses(\n        address _musdTokenAddress,\n        address _troveManagerAddress\n    ) external;\n}\n"
    },
    "contracts/interfaces/IGovernableVariables.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\ninterface IGovernableVariables {\n    event FeeExemptAccountAdded(address _account);\n    event FeeExemptAccountRemoved(address _account);\n    event RolesSet(address _council, address _treasury);\n\n    function addFeeExemptAccount(address _account) external;\n\n    function addFeeExemptAccounts(address[] calldata _accounts) external;\n\n    function removeFeeExemptAccounts(address[] calldata _accounts) external;\n\n    function removeFeeExemptAccount(address _account) external;\n\n    function startChangingRoles(address _council, address _treasury) external;\n\n    function cancelChangingRoles() external;\n\n    function finalizeChangingRoles() external;\n\n    function isAccountFeeExempt(address _account) external view returns (bool);\n\n    function council() external view returns (address);\n\n    function treasury() external view returns (address);\n}\n"
    },
    "contracts/interfaces/IHintHelpers.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\ninterface IHintHelpers {\n    // --- Events --\n    event BorrowerOperationsAddressChanged(address _borrowerOperationsAddress);\n    event SortedTrovesAddressChanged(address _sortedTrovesAddress);\n    event TroveManagerAddressChanged(address _troveManagerAddress);\n\n    // --- Functions ---\n\n    function setAddresses(\n        address _borrowerOperationsAddress,\n        address _sortedTrovesAddress,\n        address _troveManagerAddress\n    ) external;\n\n    function getRedemptionHints(\n        uint256 _amount,\n        uint256 _price,\n        uint256 _maxIterations\n    )\n        external\n        view\n        returns (\n            address firstRedemptionHint,\n            uint256 partialRedemptionHintNICR,\n            uint256 truncatedAmount\n        );\n\n    function getApproxHint(\n        uint256 _CR,\n        uint256 _numTrials,\n        uint256 _inputRandomSeed\n    )\n        external\n        view\n        returns (address hintAddress, uint256 diff, uint256 latestRandomSeed);\n\n    function computeNominalCR(\n        uint256 _coll,\n        uint256 _debt\n    ) external pure returns (uint);\n\n    function computeCR(\n        uint256 _coll,\n        uint256 _debt,\n        uint256 _price\n    ) external pure returns (uint);\n}\n"
    },
    "contracts/interfaces/IInterestRateManager.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\ninterface IInterestRateManager {\n    struct InterestRateInfo {\n        uint256 principal;\n        uint256 interest;\n        uint256 lastUpdatedTime;\n    }\n\n    event ActivePoolAddressChanged(address _activePoolAddress);\n    event BorrowerOperationsAddressChanged(address _borrowerOperationsAddress);\n    event MUSDTokenAddressChanged(address _musdTokenAddress);\n    event PCVAddressChanged(address _pcvAddress);\n    event TroveManagerAddressChanged(address _troveManagerAddress);\n\n    event InterestRateProposed(uint16 proposedRate, uint256 proposalTime);\n    event InterestRateUpdated(uint16 newInterestRate);\n    event InterestNumeratorChanged(uint256 _newNumerator);\n\n    function setAddresses(\n        address _activePoolAddress,\n        address _borrowerOperationsAddress,\n        address _musdTokenAddress,\n        address _pcvAddress,\n        address _troveManagerAddress\n    ) external;\n\n    function proposeInterestRate(uint16 _newProposedInterestRate) external;\n\n    function approveInterestRate() external;\n\n    function addPrincipal(uint256 _principal, uint16 _rate) external;\n\n    function removePrincipal(uint256 _principal, uint16 _rate) external;\n\n    function updateSystemInterest() external;\n\n    function updateTroveDebt(\n        uint256 _interestOwed,\n        uint256 _payment,\n        uint16 _rate\n    )\n        external\n        returns (uint256 principalAdjustment, uint256 interestAdjustment);\n\n    function getAccruedInterest() external view returns (uint256);\n\n    function interestRate() external view returns (uint16);\n}\n"
    },
    "contracts/interfaces/ILiquityBase.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"./IPriceFeed.sol\";\n\ninterface ILiquityBase {\n    function priceFeed() external view returns (IPriceFeed);\n}\n"
    },
    "contracts/interfaces/IPCV.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../token/IMUSD.sol\";\n\ninterface IPCV {\n    // --- Events --\n    event BorrowerOperationsAddressSet(address _borrowerOperationsAddress);\n    event MUSDTokenAddressSet(address _musdTokenAddress);\n    event RolesSet(address _council, address _treasury);\n\n    event CollateralWithdraw(address _recipient, uint256 _collateralAmount);\n    event FeeRecipientSet(address _feeRecipient);\n    event FeeSplitSet(uint8 _feeSplitPercentage);\n    event MUSDWithdraw(address _recipient, uint256 _amount);\n    event PCVDebtPayment(uint256 _paidDebt);\n    event PCVDepositSP(address indexed user, uint256 musdAmount);\n    event PCVDistribution(address _recipient, uint256 _amount);\n    event PCVWithdrawSP(\n        address indexed user,\n        uint256 musdAmount,\n        uint256 collateralAmount\n    );\n    event RecipientAdded(address _recipient);\n    event RecipientRemoved(address _recipient);\n\n    // --- Functions ---\n\n    function debtToPay() external returns (uint256);\n\n    function distributeMUSD(uint256 _musdToBurn) external;\n\n    function setAddresses(\n        address _borrowerOperations,\n        address _musdTokenAddress\n    ) external;\n\n    function initializeDebt() external;\n\n    function setFeeRecipient(address _feeRecipient) external;\n\n    function setFeeSplit(uint8 _feeSplitPercentage) external;\n\n    function withdrawMUSD(address _recipient, uint256 _musdAmount) external;\n\n    function withdrawCollateral(\n        address _recipient,\n        uint256 _collateralAmount\n    ) external;\n\n    function addRecipientToWhitelist(address _recipient) external;\n\n    function addRecipientsToWhitelist(address[] calldata _recipients) external;\n\n    function removeRecipientFromWhitelist(address _recipient) external;\n\n    function removeRecipientsFromWhitelist(\n        address[] calldata _recipients\n    ) external;\n\n    function startChangingRoles(address _council, address _treasury) external;\n\n    function cancelChangingRoles() external;\n\n    function finalizeChangingRoles() external;\n\n    function depositToStabilityPool(uint256 _amount) external;\n\n    function withdrawFromStabilityPool(uint256 _amount) external;\n\n    function musd() external view returns (IMUSD);\n\n    function council() external view returns (address);\n\n    function treasury() external view returns (address);\n}\n"
    },
    "contracts/interfaces/IPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\n// Common interface for the Pools.\ninterface IPool {\n    // --- Events ---\n\n    event CollateralBalanceUpdated(uint256 _newBalance);\n\n    event ActivePoolAddressChanged(address _newActivePoolAddress);\n    event DefaultPoolAddressChanged(address _newDefaultPoolAddress);\n    event StabilityPoolAddressChanged(address _newStabilityPoolAddress);\n\n    event CollateralSent(address _to, uint256 _amount);\n\n    // --- Functions ---\n\n    function increaseDebt(uint256 _principal, uint256 _interest) external;\n\n    function decreaseDebt(uint256 _principal, uint256 _interest) external;\n\n    function getCollateralBalance() external view returns (uint);\n\n    function getDebt() external view returns (uint);\n\n    function getPrincipal() external view returns (uint);\n\n    function getInterest() external view returns (uint);\n}\n"
    },
    "contracts/interfaces/IPriceFeed.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\ninterface IPriceFeed {\n    // --- Events ---\n    event LastGoodPriceUpdated(uint256 _lastGoodPrice);\n\n    event NewOracleRegistered(address _oracle);\n\n    // --- Function ---\n    function setOracle(address _oracle) external;\n\n    function fetchPrice() external view returns (uint);\n}\n"
    },
    "contracts/interfaces/IReceiveApproval.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.24;\n\n/// @notice An interface that should be implemented by contracts supporting\n///         `approveAndCall`/`receiveApproval` pattern.\ninterface IReceiveApproval {\n    /// @notice Receives approval to spend tokens. Called as a result of\n    ///         `approveAndCall` call on the token.\n    function receiveApproval(\n        address from,\n        uint256 amount,\n        address token,\n        bytes calldata extraData\n    ) external;\n}\n"
    },
    "contracts/interfaces/ISortedTroves.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\n// Common interface for the SortedTroves Doubly Linked List.\ninterface ISortedTroves {\n    // --- Events ---\n\n    event BorrowerOperationsAddressChanged(address _borrowerOperationsAddress);\n    event SortedTrovesAddressChanged(address _sortedDoublyLLAddress);\n\n    event NodeAdded(address _id, uint256 _NICR);\n    event NodeRemoved(address _id);\n\n    // --- Functions ---\n\n    function setParams(\n        uint256 _size,\n        address _TroveManagerAddress,\n        address _borrowerOperationsAddress\n    ) external;\n\n    function insert(\n        address _id,\n        uint256 _NICR,\n        address _prevId,\n        address _nextId\n    ) external;\n\n    function remove(address _id) external;\n\n    function reInsert(\n        address _id,\n        uint256 _newNICR,\n        address _prevId,\n        address _nextId\n    ) external;\n\n    function contains(address _id) external view returns (bool);\n\n    function isFull() external view returns (bool);\n\n    function isEmpty() external view returns (bool);\n\n    function getSize() external view returns (uint256);\n\n    function getMaxSize() external view returns (uint256);\n\n    function getFirst() external view returns (address);\n\n    function getLast() external view returns (address);\n\n    function getNext(address _id) external view returns (address);\n\n    function getPrev(address _id) external view returns (address);\n\n    function validInsertPosition(\n        uint256 _NICR,\n        address _prevId,\n        address _nextId\n    ) external view returns (bool);\n\n    function findInsertPosition(\n        uint256 _NICR,\n        address _prevId,\n        address _nextId\n    ) external view returns (address, address);\n}\n"
    },
    "contracts/interfaces/IStabilityPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\n/*\n * The Stability Pool holds mUSD tokens deposited by Stability Pool depositors.\n *\n * When a trove is liquidated, then depending on system conditions, some of its debt gets offset with\n * mUSD in the Stability Pool: that is, the offset debt evaporates, and an equal amount of mUSD tokens in the Stability Pool are burned.\n *\n * Thus, a liquidation causes each depositor to receive a mUSD loss in proportion to their deposit as a share of total deposits.\n * They also receive an collateral gain, as the collateral of the liquidated trove is distributed among Stability depositors\n * in the same proportion.\n *\n * When a liquidation occurs, it depletes every deposit by the same fraction: for example, a liquidation that depletes 40%\n * of the total mUSD in the Stability Pool, depletes 40% of each deposit.\n *\n * A deposit that has experienced a series of liquidations is termed a \"compounded deposit\": each liquidation depletes the deposit,\n * multiplying it by some factor in range ]0,1[\n *\n * Please see the implementation spec in the proof document, which closely follows on from the compounded deposit / collateral gain derivations:\n * https://github.com/liquity/liquity/blob/master/papers/Scalable_Reward_Distribution_with_Compounding_Stakes.pdf\n *\n */\ninterface IStabilityPool {\n    // --- Events ---\n\n    event StabilityPoolCollateralBalanceUpdated(uint256 _newBalance);\n    event StabilityPoolMUSDBalanceUpdated(uint256 _newBalance);\n\n    event ActivePoolAddressChanged(address _newActivePoolAddress);\n    event BorrowerOperationsAddressChanged(\n        address _newBorrowerOperationsAddress\n    );\n    event DefaultPoolAddressChanged(address _newDefaultPoolAddress);\n    event MUSDTokenAddressChanged(address _newMUSDTokenAddress);\n    event PriceFeedAddressChanged(address _newPriceFeedAddress);\n    event SortedTrovesAddressChanged(address _newSortedTrovesAddress);\n    event TroveManagerAddressChanged(address _newTroveManagerAddress);\n\n    event PUpdated(uint256 _P);\n    event SUpdated(uint256 _S, uint128 _epoch, uint128 _scale);\n    event EpochUpdated(uint128 _currentEpoch);\n    event ScaleUpdated(uint128 _currentScale);\n\n    event DepositSnapshotUpdated(\n        address indexed _depositor,\n        uint256 _P,\n        uint256 _S\n    );\n    event UserDepositChanged(address indexed _depositor, uint256 _newDeposit);\n\n    event CollateralGainWithdrawn(\n        address indexed _depositor,\n        uint256 _collateral,\n        uint256 _MUSDLoss\n    );\n    event CollateralSent(address _to, uint256 _amount);\n\n    // --- Functions ---\n\n    /*\n     * Called only once on init, to set addresses of other Liquity contracts\n     * Callable only by owner, renounces ownership at the end\n     */\n    function setAddresses(\n        address _activePoolAddress,\n        address _borrowerOperationsAddress,\n        address _musdTokenAddress,\n        address _priceFeedAddress,\n        address _sortedTrovesAddress,\n        address _troveManagerAddress\n    ) external;\n\n    /*\n     * Initial checks:\n     * - _amount is not zero\n     * ---\n     * - Sends depositor's accumulated gains (collateral) to depositor\n     */\n    function provideToSP(uint256 _amount) external;\n\n    /*\n     * Initial checks:\n     * - _amount is zero or there are no under collateralized troves left in the system\n     * - User has a non zero deposit\n     * ---\n     * - Sends all depositor's accumulated gains (collateral) to depositor\n     * - Decreases deposit stake, and takes new snapshot.\n     *\n     * If _amount > userDeposit, the user withdraws all of their compounded deposit.\n     */\n    function withdrawFromSP(uint256 _amount) external;\n\n    /*\n     * Initial checks:\n     * - User has a non zero deposit\n     * - User has an open trove\n     * - User has some collateral gain\n     * ---\n     * - Transfers the depositor's entire collateral gain from the Stability Pool to the caller's trove\n     * - Leaves their compounded deposit in the Stability Pool\n     * - Updates snapshots for deposit\n     */\n    function withdrawCollateralGainToTrove(\n        address _upperHint,\n        address _lowerHint\n    ) external;\n\n    /*\n     * Initial checks:\n     * - Caller is TroveManager\n     * ---\n     * Cancels out the specified debt against the mUSD contained in the Stability Pool (as far as possible)\n     * and transfers the Trove's collateral from ActivePool to StabilityPool.\n     * Only called by liquidation functions in the TroveManager.\n     */\n    function offset(\n        uint256 _principal,\n        uint256 _interest,\n        uint256 _coll\n    ) external;\n\n    /*\n     * Returns the total amount of collateral held by the pool, accounted in an internal variable instead of `balance`,\n     * to exclude edge cases like collateral received from a self-destruct.\n     */\n    function getCollateralBalance() external view returns (uint);\n\n    /*\n     * Returns mUSD held in the pool. Changes when users deposit/withdraw, and when Trove debt is offset.\n     */\n    function getTotalMUSDDeposits() external view returns (uint);\n\n    /*\n     * Calculates the collateral gain earned by the deposit since its last snapshots were taken.\n     */\n    function getDepositorCollateralGain(\n        address _depositor\n    ) external view returns (uint);\n\n    /*\n     * Return the user's compounded deposit.\n     */\n    function getCompoundedMUSDDeposit(\n        address _depositor\n    ) external view returns (uint);\n}\n"
    },
    "contracts/interfaces/ITroveManager.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"./IStabilityPool.sol\";\nimport \"./IPCV.sol\";\n\n// Common interface for the Trove Manager.\ninterface ITroveManager {\n    enum Status {\n        nonExistent,\n        active,\n        closedByOwner,\n        closedByLiquidation,\n        closedByRedemption\n    }\n\n    struct InterestRateChange {\n        uint16 interestRate;\n        uint256 blockNumber;\n    }\n\n    // --- Events ---\n\n    event ActivePoolAddressChanged(address _activePoolAddress);\n    event BorrowerOperationsAddressChanged(\n        address _newBorrowerOperationsAddress\n    );\n    event CollSurplusPoolAddressChanged(address _collSurplusPoolAddress);\n    event DefaultPoolAddressChanged(address _defaultPoolAddress);\n    event GasPoolAddressChanged(address _gasPoolAddress);\n    event InterestRateManagerAddressChanged(\n        address _interestRateManagerAddress\n    );\n    event MUSDTokenAddressChanged(address _newMUSDTokenAddress);\n    event PCVAddressChanged(address _pcvAddress);\n    event PriceFeedAddressChanged(address _newPriceFeedAddress);\n    event SortedTrovesAddressChanged(address _sortedTrovesAddress);\n    event StabilityPoolAddressChanged(address _stabilityPoolAddress);\n\n    event Liquidation(\n        uint256 _liquidatedPrincipal,\n        uint256 _liquidatedInterest,\n        uint256 _liquidatedColl,\n        uint256 _collGasCompensation,\n        uint256 _gasCompensation\n    );\n    event Redemption(\n        uint256 _attemptedAmount,\n        uint256 _actualAmount,\n        uint256 _collateralSent,\n        uint256 _collateralFee\n    );\n    event TroveUpdated(\n        address indexed _borrower,\n        uint256 _principal,\n        uint256 _interest,\n        uint256 _coll,\n        uint256 stake,\n        uint8 operation\n    );\n    event TroveLiquidated(\n        address indexed _borrower,\n        uint256 _debt,\n        uint256 _coll,\n        uint8 operation\n    );\n    event BaseRateUpdated(uint256 _baseRate);\n    event TotalStakesUpdated(uint256 _newTotalStakes);\n    event SystemSnapshotsUpdated(\n        uint256 _totalStakesSnapshot,\n        uint256 _totalCollateralSnapshot\n    );\n    event LTermsUpdated(\n        uint256 _L_Collateral,\n        uint256 _L_Principal,\n        uint256 _L_Interest\n    );\n    event TroveSnapshotsUpdated(\n        uint256 _L_Collateral,\n        uint256 _L_Principal,\n        uint256 _L_Interest\n    );\n    event TroveIndexUpdated(address _borrower, uint256 _newIndex);\n\n    // --- Functions ---\n\n    function setAddresses(\n        address _activePoolAddress,\n        address _borrowerOperationsAddress,\n        address _collSurplusPoolAddress,\n        address _defaultPoolAddress,\n        address _gasPoolAddress,\n        address _interestRateManagerAddress,\n        address _musdTokenAddress,\n        address _pcvAddress,\n        address _priceFeedAddress,\n        address _sortedTrovesAddress,\n        address _stabilityPoolAddress\n    ) external;\n\n    function liquidate(address _borrower) external;\n\n    function batchLiquidateTroves(address[] calldata _troveArray) external;\n\n    function redeemCollateral(\n        uint256 _amount,\n        address _firstRedemptionHint,\n        address _upperPartialRedemptionHint,\n        address _lowerPartialRedemptionHint,\n        uint256 _partialRedemptionHintNICR,\n        uint256 _maxIterations\n    ) external;\n\n    function updateStakeAndTotalStakes(\n        address _borrower\n    ) external returns (uint);\n\n    function updateTroveRewardSnapshots(address _borrower) external;\n\n    function addTroveOwnerToArray(\n        address _borrower\n    ) external returns (uint256 index);\n\n    function applyPendingRewards(address _borrower) external;\n\n    function closeTrove(address _borrower) external;\n\n    function removeStake(address _borrower) external;\n\n    function setTroveStatus(address _borrower, Status _status) external;\n\n    function setTroveMaxBorrowingCapacity(\n        address _borrower,\n        uint256 _maxBorrowingCapacity\n    ) external;\n\n    function updateSystemInterest() external;\n\n    function updateSystemAndTroveInterest(address _borrower) external;\n\n    function increaseTroveColl(\n        address _borrower,\n        uint256 _collIncrease\n    ) external returns (uint);\n\n    function decreaseTroveColl(\n        address _borrower,\n        uint256 _collDecrease\n    ) external returns (uint);\n\n    function increaseTroveDebt(\n        address _borrower,\n        uint256 _debtIncrease\n    ) external returns (uint256);\n\n    function decreaseTroveDebt(\n        address _borrower,\n        uint256 _debtDecrease\n    ) external returns (uint256, uint256);\n\n    function setTroveInterestRate(address _borrower, uint16 _rate) external;\n\n    function setTroveLastInterestUpdateTime(\n        address _borrower,\n        uint256 _timestamp\n    ) external;\n\n    function stabilityPool() external view returns (IStabilityPool);\n\n    function pcv() external view returns (IPCV);\n\n    function getTroveOwnersCount() external view returns (uint);\n\n    function getTroveFromTroveOwnersArray(\n        uint256 _index\n    ) external view returns (address);\n\n    function getTroveInterestOwed(\n        address _borrower\n    ) external view returns (uint256);\n\n    function getTrovePrincipal(address _borrower) external view returns (uint);\n\n    function getNominalICR(address _borrower) external view returns (uint);\n\n    function getCurrentICR(\n        address _borrower,\n        uint256 _price\n    ) external view returns (uint);\n\n    function getPendingCollateral(\n        address _borrower\n    ) external view returns (uint);\n\n    function getPendingDebt(\n        address _borrower\n    ) external view returns (uint256, uint256);\n\n    function hasPendingRewards(address _borrower) external view returns (bool);\n\n    function getEntireDebtAndColl(\n        address _borrower\n    )\n        external\n        view\n        returns (\n            uint256 coll,\n            uint256 principal,\n            uint256 interest,\n            uint256 pendingCollateral,\n            uint256 pendingPrincipal,\n            uint256 pendingInterest\n        );\n\n    function getTroveStatus(address _borrower) external view returns (Status);\n\n    function getTroveStake(address _borrower) external view returns (uint);\n\n    function getTroveDebt(address _borrower) external view returns (uint);\n\n    function getTroveInterestRate(\n        address _borrower\n    ) external view returns (uint16);\n\n    function getTroveLastInterestUpdateTime(\n        address _borrower\n    ) external view returns (uint);\n\n    function getTroveColl(address _borrower) external view returns (uint);\n\n    function getTCR(uint256 _price) external view returns (uint);\n\n    function getTroveMaxBorrowingCapacity(\n        address _borrower\n    ) external view returns (uint256);\n\n    function checkRecoveryMode(uint256 _price) external view returns (bool);\n}\n"
    },
    "contracts/PCV.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"./BorrowerOperations.sol\";\nimport \"./dependencies/CheckContract.sol\";\nimport \"./dependencies/SendCollateral.sol\";\nimport \"./interfaces/IPCV.sol\";\nimport \"./token/IMUSD.sol\";\n\ncontract PCV is CheckContract, IPCV, Ownable2StepUpgradeable, SendCollateral {\n    uint256 public constant BOOTSTRAP_LOAN = 1e26; // 100M mUSD\n\n    uint256 public governanceTimeDelay;\n\n    BorrowerOperations public borrowerOperations;\n    IMUSD public musd;\n\n    // TODO ideal initialization in constructor/setAddresses\n    uint256 public debtToPay;\n    bool public isInitialized;\n\n    address public council;\n    address public treasury;\n\n    mapping(address => bool) public recipientsWhitelist;\n\n    address public pendingCouncilAddress;\n    address public pendingTreasuryAddress;\n    uint256 public changingRolesInitiated;\n\n    address public feeRecipient;\n    uint8 public feeSplitPercentage; // percentage of fees to be sent to feeRecipient\n    uint8 public constant FEE_SPLIT_MAX = 50; // no more than 50% of fees can be sent until the debt is paid\n\n    modifier onlyAfterDebtPaid() {\n        require(isInitialized && debtToPay == 0, \"PCV: debt must be paid\");\n        _;\n    }\n\n    modifier onlyOwnerOrCouncilOrTreasury() {\n        require(\n            msg.sender == owner() ||\n                msg.sender == council ||\n                msg.sender == treasury,\n            \"PCV: caller must be owner or council or treasury\"\n        );\n        _;\n    }\n\n    modifier onlyWhitelistedRecipient(address _recipient) {\n        require(\n            recipientsWhitelist[_recipient],\n            \"PCV: recipient must be in whitelist\"\n        );\n        _;\n    }\n\n    function initialize(uint256 _governanceTimeDelay) external initializer {\n        __Ownable_init(msg.sender);\n\n        require(\n            _governanceTimeDelay <= 30 weeks,\n            \"Governance delay is too big\"\n        );\n        governanceTimeDelay = _governanceTimeDelay;\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    receive() external payable {}\n\n    function setAddresses(\n        address _borrowerOperations,\n        address _musdTokenAddress\n    ) external override onlyOwner {\n        require(address(musd) == address(0), \"PCV: contacts already set\");\n\n        checkContract(_borrowerOperations);\n        checkContract(_musdTokenAddress);\n\n        // slither-disable-start missing-zero-check\n        borrowerOperations = BorrowerOperations(_borrowerOperations);\n        musd = IMUSD(_musdTokenAddress);\n        // slither-disable-end missing-zero-check\n\n        emit BorrowerOperationsAddressSet(_borrowerOperations);\n        emit MUSDTokenAddressSet(_musdTokenAddress);\n    }\n\n    function initializeDebt() external override onlyOwnerOrCouncilOrTreasury {\n        require(!isInitialized, \"PCV: already initialized\");\n\n        debtToPay = BOOTSTRAP_LOAN;\n        isInitialized = true;\n        borrowerOperations.mintBootstrapLoanFromPCV(BOOTSTRAP_LOAN);\n        depositToStabilityPool(BOOTSTRAP_LOAN);\n    }\n\n    function setFeeRecipient(\n        address _feeRecipient\n    ) external onlyOwnerOrCouncilOrTreasury {\n        require(\n            _feeRecipient != address(0),\n            \"PCV: Fee recipient cannot be the zero address.\"\n        );\n        feeRecipient = _feeRecipient;\n        emit FeeRecipientSet(_feeRecipient);\n    }\n\n    function setFeeSplit(\n        uint8 _feeSplitPercentage\n    ) external onlyOwnerOrCouncilOrTreasury {\n        require(\n            feeRecipient != address(0),\n            \"PCV must set fee recipient before setFeeSplit\"\n        );\n        require(\n            (debtToPay > 0 && _feeSplitPercentage <= FEE_SPLIT_MAX) ||\n                (debtToPay == 0 && _feeSplitPercentage <= 100),\n            \"PCV: Fee split must be at most 50 while debt remains.\"\n        );\n        feeSplitPercentage = _feeSplitPercentage;\n\n        emit FeeSplitSet(_feeSplitPercentage);\n    }\n\n    function distributeMUSD(\n        uint256 _amount\n    ) external override onlyOwnerOrCouncilOrTreasury {\n        require(\n            _amount <= musd.balanceOf(address(this)),\n            \"PCV: not enough tokens\"\n        );\n\n        uint256 distributedFees = (_amount * feeSplitPercentage) / 100;\n        uint256 protocolLoanRepayment = _amount - distributedFees;\n        uint256 stabilityPoolDeposit = 0;\n\n        // check for excess to deposit into the stability pool\n        if (protocolLoanRepayment > debtToPay) {\n            stabilityPoolDeposit = protocolLoanRepayment - debtToPay;\n            protocolLoanRepayment = debtToPay;\n        }\n\n        _repayDebt(protocolLoanRepayment);\n\n        if (stabilityPoolDeposit > 0) {\n            depositToStabilityPool(stabilityPoolDeposit);\n        }\n\n        // send funds to feeRecipient address, if the feeRecipient hasnt been set then the feeSplitPercentage = 0\n        if (feeRecipient != address(0) && distributedFees > 0) {\n            require(\n                musd.transfer(feeRecipient, distributedFees),\n                \"PCV: sending mUSD failed\"\n            );\n\n            // slither-disable-next-line reentrancy-events\n            emit PCVDistribution(feeRecipient, distributedFees);\n        }\n    }\n\n    function withdrawMUSD(\n        address _recipient,\n        uint256 _amount\n    )\n        external\n        override\n        onlyOwnerOrCouncilOrTreasury\n        onlyAfterDebtPaid\n        onlyWhitelistedRecipient(_recipient)\n    {\n        require(\n            _amount <= musd.balanceOf(address(this)),\n            \"PCV: not enough tokens\"\n        );\n        require(musd.transfer(_recipient, _amount), \"PCV: sending mUSD failed\");\n\n        // slither-disable-next-line reentrancy-events\n        emit MUSDWithdraw(_recipient, _amount);\n    }\n\n    function withdrawCollateral(\n        address _recipient,\n        uint256 _collateralAmount\n    )\n        external\n        override\n        onlyOwnerOrCouncilOrTreasury\n        onlyWhitelistedRecipient(_recipient)\n    {\n        _sendCollateral(_recipient, _collateralAmount);\n\n        // slither-disable-next-line reentrancy-events\n        emit CollateralWithdraw(_recipient, _collateralAmount);\n    }\n\n    function addRecipientsToWhitelist(\n        address[] calldata _recipients\n    ) external override onlyOwner {\n        require(\n            _recipients.length > 0,\n            \"PCV: Recipients array must not be empty\"\n        );\n        for (uint256 i = 0; i < _recipients.length; i++) {\n            addRecipientToWhitelist(_recipients[i]);\n        }\n    }\n\n    function removeRecipientsFromWhitelist(\n        address[] calldata _recipients\n    ) external override onlyOwner {\n        require(\n            _recipients.length > 0,\n            \"PCV: Recipients array must not be empty\"\n        );\n        for (uint256 i = 0; i < _recipients.length; i++) {\n            removeRecipientFromWhitelist(_recipients[i]);\n        }\n    }\n\n    function startChangingRoles(\n        address _council,\n        address _treasury\n    ) external override onlyOwner {\n        require(\n            _council != council || _treasury != treasury,\n            \"PCV: these roles already set\"\n        );\n\n        // solhint-disable-next-line not-rely-on-time\n        changingRolesInitiated = block.timestamp;\n        if (council == address(0) && treasury == address(0)) {\n            // solhint-disable-next-line not-rely-on-time\n            changingRolesInitiated -= governanceTimeDelay; // skip delay if no roles set\n        }\n        pendingCouncilAddress = _council;\n        pendingTreasuryAddress = _treasury;\n    }\n\n    function cancelChangingRoles() external override onlyOwner {\n        require(changingRolesInitiated != 0, \"PCV: Change not initiated\");\n\n        changingRolesInitiated = 0;\n        pendingCouncilAddress = address(0);\n        pendingTreasuryAddress = address(0);\n    }\n\n    function finalizeChangingRoles() external override onlyOwner {\n        require(changingRolesInitiated > 0, \"PCV: Change not initiated\");\n        require(\n            // solhint-disable-next-line not-rely-on-time\n            block.timestamp >= changingRolesInitiated + governanceTimeDelay,\n            \"PCV: Governance delay has not elapsed\"\n        );\n\n        council = pendingCouncilAddress;\n        treasury = pendingTreasuryAddress;\n        emit RolesSet(council, treasury);\n\n        changingRolesInitiated = 0;\n        pendingCouncilAddress = address(0);\n        pendingTreasuryAddress = address(0);\n    }\n\n    function addRecipientToWhitelist(\n        address _recipient\n    ) public override onlyOwner {\n        require(\n            !recipientsWhitelist[_recipient],\n            \"PCV: Recipient has already been added to whitelist\"\n        );\n        recipientsWhitelist[_recipient] = true;\n        emit RecipientAdded(_recipient);\n    }\n\n    function removeRecipientFromWhitelist(\n        address _recipient\n    ) public override onlyOwner {\n        require(\n            recipientsWhitelist[_recipient],\n            \"PCV: Recipient is not in whitelist\"\n        );\n        recipientsWhitelist[_recipient] = false;\n        emit RecipientRemoved(_recipient);\n    }\n\n    function depositToStabilityPool(\n        uint256 _amount\n    ) public onlyOwnerOrCouncilOrTreasury {\n        require(\n            _amount <= musd.balanceOf(address(this)),\n            \"PCV: not enough tokens\"\n        );\n        require(\n            musd.approve(borrowerOperations.stabilityPoolAddress(), _amount),\n            \"PCV: Approval failed\"\n        );\n\n        IStabilityPool(borrowerOperations.stabilityPoolAddress()).provideToSP(\n            _amount\n        );\n\n        // slither-disable-next-line reentrancy-events\n        emit PCVDepositSP(msg.sender, _amount);\n    }\n\n    function withdrawFromStabilityPool(\n        uint256 _amount\n    ) public onlyOwnerOrCouncilOrTreasury {\n        uint256 collateralBefore = address(this).balance;\n        uint256 musdBefore = musd.balanceOf(address(this));\n\n        IStabilityPool(borrowerOperations.stabilityPoolAddress())\n            .withdrawFromSP(_amount);\n\n        uint256 collateralChange = address(this).balance - collateralBefore;\n        uint256 musdChange = musd.balanceOf(address(this)) - musdBefore;\n\n        _repayDebt(musdChange);\n\n        // slither-disable-next-line reentrancy-events\n        emit PCVWithdrawSP(msg.sender, musdChange, collateralChange);\n    }\n\n    function _repayDebt(uint _repayment) internal {\n        if (_repayment > debtToPay) {\n            _repayment = debtToPay;\n        }\n\n        if (_repayment > 0 && debtToPay > 0) {\n            debtToPay -= _repayment;\n            borrowerOperations.burnDebtFromPCV(_repayment);\n\n            // slither-disable-next-line reentrancy-events\n            emit PCVDebtPayment(_repayment);\n        }\n    }\n}\n"
    },
    "contracts/PriceFeed.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol\";\n\nimport \"./interfaces/ChainlinkAggregatorV3Interface.sol\";\nimport \"./interfaces/IPriceFeed.sol\";\n\ncontract PriceFeed is IPriceFeed, Ownable2StepUpgradeable {\n    /// @dev Used to convert an oracle price answer to an 18-digit precision uint\n    uint8 public constant TARGET_DIGITS = 18;\n    // If the oracle has not been updated in at least 60 seconds, it is stale.\n    uint256 private constant MAX_PRICE_DELAY = 60;\n\n    // State ------------------------------------------------------------------------------------------------------------\n    ChainlinkAggregatorV3Interface public oracle;\n\n    function initialize() external initializer {\n        __Ownable_init(msg.sender);\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    // Admin routines ---------------------------------------------------------------------------------------------------\n\n    function setOracle(address _oracle) external onlyOwner {\n        ChainlinkAggregatorV3Interface chainLinkOracle = ChainlinkAggregatorV3Interface(\n                _oracle\n            );\n\n        require(chainLinkOracle.decimals() > 0, \"Invalid Decimals from Oracle\");\n        // slither-disable-next-line unused-return\n        (, int256 price, , , ) = chainLinkOracle.latestRoundData();\n        require(price != 0, \"Oracle returns 0 for price\");\n\n        oracle = chainLinkOracle;\n        emit NewOracleRegistered(_oracle);\n    }\n\n    // Public functions -------------------------------------------------------------------------------------------------\n\n    function fetchPrice() public view virtual returns (uint256) {\n        // slither-disable-next-line unused-return\n        (, int256 price, , uint256 updatedAt, ) = oracle.latestRoundData();\n\n        // solhint-disable not-rely-on-time\n        require(\n            block.timestamp - updatedAt <= MAX_PRICE_DELAY,\n            \"PriceFeed: Oracle is stale.\"\n        );\n        // solhint-enable not-rely-on-time\n\n        return _scalePriceByDigits(uint256(price), oracle.decimals());\n    }\n\n    /**\n     * @dev Scales oracle's response up/down to 1e18 precisoin.\n     */\n    function _scalePriceByDigits(\n        uint256 _price,\n        uint8 _priceDigits\n    ) internal pure returns (uint256) {\n        unchecked {\n            if (_priceDigits > TARGET_DIGITS) {\n                return _price / (10 ** (_priceDigits - TARGET_DIGITS));\n            } else if (_priceDigits < TARGET_DIGITS) {\n                return _price * (10 ** (TARGET_DIGITS - _priceDigits));\n            }\n        }\n        return _price;\n    }\n}\n"
    },
    "contracts/SortedTroves.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"./dependencies/CheckContract.sol\";\nimport \"./interfaces/ISortedTroves.sol\";\nimport \"./interfaces/ITroveManager.sol\";\n\n/*\n * A sorted doubly linked list with nodes sorted in descending order.\n *\n * Nodes map to active Troves in the system - the ID property is the address of a Trove owner.\n * Nodes are ordered according to their current nominal individual collateral ratio (NICR),\n * which is like the ICR but without the price, i.e., just collateral / debt.\n *\n * The list optionally accepts insert position hints.\n *\n * NICRs are computed dynamically at runtime, and not stored on the Node. This is because NICRs of active Troves\n * change dynamically as liquidation events occur.\n *\n * The list relies on the fact that liquidation events preserve ordering: a liquidation decreases the NICRs of all active Troves,\n * but maintains their order. A node inserted based on current NICR will maintain the correct position,\n * relative to it's peers, as rewards accumulate, as long as it's raw collateral and debt have not changed.\n * Thus, Nodes remain sorted by current NICR.\n *\n * Nodes need only be re-inserted upon a Trove operation - when the owner adds or removes collateral or debt\n * to their position.\n *\n * The list is a modification of the following audited SortedDoublyLinkedList:\n * https://github.com/livepeer/protocol/blob/master/contracts/libraries/SortedDoublyLL.sol\n *\n *\n * Changes made in the Liquity implementation:\n *\n * - Keys have been removed from nodes\n *\n * - Ordering checks for insertion are performed by comparing an NICR argument to the current NICR, calculated at runtime.\n *   The list relies on the property that ordering by ICR is maintained as the collateral:USD price varies.\n *\n * - Public functions with parameters have been made internal to save gas, and given an external wrapper function for external access\n */\ncontract SortedTroves is CheckContract, ISortedTroves, OwnableUpgradeable {\n    // Information for a node in the list\n    struct Node {\n        bool exists;\n        address nextId; // Id of next node (smaller NICR) in the list\n        address prevId; // Id of previous node (larger NICR) in the list\n    }\n\n    // Information for the list\n    struct Data {\n        address head; // Head of the list. Also the node in the list with the largest NICR\n        address tail; // Tail of the list. Also the node in the list with the smallest NICR\n        uint256 maxSize; // Maximum size of the list\n        uint256 size; // Current size of the list\n        mapping(address => Node) nodes; // Track the corresponding ids for each node in the list\n    }\n\n    address public borrowerOperationsAddress;\n    ITroveManager public troveManager;\n    Data public data;\n\n    event TroveManagerAddressChanged(address _troveManagerAddress);\n\n    function initialize() external initializer {\n        __Ownable_init(msg.sender);\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    // --- Dependency setters ---\n\n    function setParams(\n        uint256 _size,\n        address _borrowerOperationsAddress,\n        address _troveManagerAddress\n    ) external override onlyOwner {\n        require(_size > 0, \"SortedTroves: Size cant be zero\");\n        checkContract(_troveManagerAddress);\n        checkContract(_borrowerOperationsAddress);\n\n        data.maxSize = _size;\n\n        // slither-disable-next-line missing-zero-check\n        borrowerOperationsAddress = _borrowerOperationsAddress;\n        troveManager = ITroveManager(_troveManagerAddress);\n\n        emit BorrowerOperationsAddressChanged(_borrowerOperationsAddress);\n        emit TroveManagerAddressChanged(_troveManagerAddress);\n\n        renounceOwnership();\n    }\n\n    function insert(\n        address _id,\n        uint256 _NICR,\n        address _prevId,\n        address _nextId\n    ) external override {\n        ITroveManager troveManagerCached = troveManager;\n\n        _requireCallerIsBOorTroveM(troveManagerCached);\n        _insert(troveManagerCached, _id, _NICR, _prevId, _nextId);\n    }\n\n    function remove(address _id) external override {\n        _requireCallerIsTroveManager();\n        _remove(_id);\n    }\n\n    /*\n     * @dev Re-insert the node at a new position, based on its new NICR\n     * @param _id Node's id\n     * @param _newNICR Node's new NICR\n     * @param _prevId Id of previous node for the new insert position\n     * @param _nextId Id of next node for the new insert position\n     */\n    function reInsert(\n        address _id,\n        uint256 _newNICR,\n        address _prevId,\n        address _nextId\n    ) external override {\n        ITroveManager troveManagerCached = troveManager;\n\n        _requireCallerIsBOorTroveM(troveManagerCached);\n        // List must contain the node\n        require(contains(_id), \"SortedTroves: List does not contain the id\");\n        // NICR must be non-zero\n        require(_newNICR > 0, \"SortedTroves: NICR must be positive\");\n\n        // Remove node from the list\n        _remove(_id);\n\n        _insert(troveManagerCached, _id, _newNICR, _prevId, _nextId);\n    }\n\n    /*\n     * @dev Returns the current size of the list\n     */\n    function getSize() external view override returns (uint256) {\n        return data.size;\n    }\n\n    /*\n     * @dev Returns the maximum size of the list\n     */\n    function getMaxSize() external view override returns (uint256) {\n        return data.maxSize;\n    }\n\n    /*\n     * @dev Returns the first node in the list (node with the largest NICR)\n     */\n    function getFirst() external view override returns (address) {\n        return data.head;\n    }\n\n    /*\n     * @dev Returns the last node in the list (node with the smallest NICR)\n     */\n    function getLast() external view override returns (address) {\n        return data.tail;\n    }\n\n    /*\n     * @dev Returns the next node (with a smaller NICR) in the list for a given node\n     * @param _id Node's id\n     */\n    function getNext(address _id) external view override returns (address) {\n        return data.nodes[_id].nextId;\n    }\n\n    /*\n     * @dev Returns the previous node (with a larger NICR) in the list for a given node\n     * @param _id Node's id\n     */\n    function getPrev(address _id) external view override returns (address) {\n        return data.nodes[_id].prevId;\n    }\n\n    /*\n     * @dev Find the insert position for a new node with the given NICR\n     * @param _NICR Node's NICR\n     * @param _prevId Id of previous node for the insert position\n     * @param _nextId Id of next node for the insert position\n     */\n    function findInsertPosition(\n        uint256 _NICR,\n        address _prevId,\n        address _nextId\n    ) external view override returns (address, address) {\n        return _findInsertPosition(troveManager, _NICR, _prevId, _nextId);\n    }\n\n    /*\n     * @dev Check if a pair of nodes is a valid insertion point for a new node with the given NICR\n     * @param _NICR Node's NICR\n     * @param _prevId Id of previous node for the insert position\n     * @param _nextId Id of next node for the insert position\n     */\n    function validInsertPosition(\n        uint256 _NICR,\n        address _prevId,\n        address _nextId\n    ) external view override returns (bool) {\n        return _validInsertPosition(troveManager, _NICR, _prevId, _nextId);\n    }\n\n    /*\n     * @dev Checks if the list contains a node\n     */\n    function contains(address _id) public view override returns (bool) {\n        return data.nodes[_id].exists;\n    }\n\n    /*\n     * @dev Checks if the list is full\n     */\n    function isFull() public view override returns (bool) {\n        return data.size == data.maxSize;\n    }\n\n    /*\n     * @dev Checks if the list is empty\n     */\n    function isEmpty() public view override returns (bool) {\n        return data.size == 0;\n    }\n\n    /*\n     * @dev Remove a node from the list\n     * @param _id Node's id\n     */\n    function _remove(address _id) internal {\n        // List must contain the node\n        require(contains(_id), \"SortedTroves: List does not contain the id\");\n\n        if (data.size > 1) {\n            // List contains more than a single node\n            if (_id == data.head) {\n                // The removed node is the head\n                // Set head to next node\n                data.head = data.nodes[_id].nextId;\n                // Set prev pointer of new head to null\n                data.nodes[data.head].prevId = address(0);\n            } else if (_id == data.tail) {\n                // The removed node is the tail\n                // Set tail to previous node\n                data.tail = data.nodes[_id].prevId;\n                // Set next pointer of new tail to null\n                data.nodes[data.tail].nextId = address(0);\n            } else {\n                // The removed node is neither the head nor the tail\n                // Set next pointer of previous node to the next node\n                data.nodes[data.nodes[_id].prevId].nextId = data\n                    .nodes[_id]\n                    .nextId;\n                // Set prev pointer of next node to the previous node\n                data.nodes[data.nodes[_id].nextId].prevId = data\n                    .nodes[_id]\n                    .prevId;\n            }\n        } else {\n            // List contains a single node\n            // Set the head and tail to null\n            data.head = address(0);\n            data.tail = address(0);\n        }\n\n        delete data.nodes[_id];\n        data.size -= 1;\n        emit NodeRemoved(_id);\n    }\n\n    function _insert(\n        ITroveManager _troveManager,\n        address _id,\n        uint256 _NICR,\n        address _prevId,\n        address _nextId\n    ) internal {\n        // List must not be full\n        require(!isFull(), \"SortedTroves: List is full\");\n        // List must not already contain node\n        require(!contains(_id), \"SortedTroves: List already contains the node\");\n        // Node id must not be null\n        require(_id != address(0), \"SortedTroves: Id cannot be zero\");\n        // NICR must be non-zero\n        require(_NICR > 0, \"SortedTroves: NICR must be positive\");\n\n        address prevId = _prevId;\n        address nextId = _nextId;\n\n        if (!_validInsertPosition(_troveManager, _NICR, prevId, nextId)) {\n            // Sender's hint was not a valid insert position\n            // Use sender's hint to find a valid insert position\n            (prevId, nextId) = _findInsertPosition(\n                _troveManager,\n                _NICR,\n                prevId,\n                nextId\n            );\n        }\n\n        data.nodes[_id].exists = true;\n\n        if (prevId == address(0) && nextId == address(0)) {\n            // Insert as head and tail\n            data.head = _id;\n            data.tail = _id;\n        } else if (prevId == address(0)) {\n            // Insert before `prevId` as the head\n            data.nodes[_id].nextId = data.head;\n            data.nodes[data.head].prevId = _id;\n            data.head = _id;\n        } else if (nextId == address(0)) {\n            // Insert after `nextId` as the tail\n            data.nodes[_id].prevId = data.tail;\n            data.nodes[data.tail].nextId = _id;\n            data.tail = _id;\n        } else {\n            // Insert at insert position between `prevId` and `nextId`\n            data.nodes[_id].nextId = nextId;\n            data.nodes[_id].prevId = prevId;\n            data.nodes[prevId].nextId = _id;\n            data.nodes[nextId].prevId = _id;\n        }\n\n        data.size += 1;\n        emit NodeAdded(_id, _NICR);\n    }\n\n    /*\n     * @dev Descend the list (larger NICRs to smaller NICRs) to find a valid insert position\n     * @param _troveManager TroveManager contract, passed in as param to save SLOAD’s\n     * @param _NICR Node's NICR\n     * @param _startId Id of node to start descending the list from\n     */\n    function _descendList(\n        ITroveManager _troveManager,\n        uint256 _NICR,\n        address _startId\n    ) internal view returns (address, address) {\n        // If `_startId` is the head, check if the insert position is before the head\n        if (\n            data.head == _startId &&\n            _NICR >= _troveManager.getNominalICR(_startId)\n        ) {\n            return (address(0), _startId);\n        }\n\n        address prevId = _startId;\n        address nextId = data.nodes[prevId].nextId;\n\n        // Descend the list until we reach the end or until we find a valid insert position\n        while (\n            prevId != address(0) &&\n            !_validInsertPosition(_troveManager, _NICR, prevId, nextId)\n        ) {\n            prevId = data.nodes[prevId].nextId;\n            nextId = data.nodes[prevId].nextId;\n        }\n\n        return (prevId, nextId);\n    }\n\n    /*\n     * @dev Ascend the list (smaller NICRs to larger NICRs) to find a valid insert position\n     * @param _troveManager TroveManager contract, passed in as param to save SLOAD’s\n     * @param _NICR Node's NICR\n     * @param _startId Id of node to start ascending the list from\n     */\n    function _ascendList(\n        ITroveManager _troveManager,\n        uint256 _NICR,\n        address _startId\n    ) internal view returns (address, address) {\n        // If `_startId` is the tail, check if the insert position is after the tail\n        if (\n            data.tail == _startId &&\n            _NICR <= _troveManager.getNominalICR(_startId)\n        ) {\n            return (_startId, address(0));\n        }\n\n        address nextId = _startId;\n        address prevId = data.nodes[nextId].prevId;\n\n        // Ascend the list until we reach the end or until we find a valid insertion point\n        while (\n            nextId != address(0) &&\n            !_validInsertPosition(_troveManager, _NICR, prevId, nextId)\n        ) {\n            nextId = data.nodes[nextId].prevId;\n            prevId = data.nodes[nextId].prevId;\n        }\n\n        return (prevId, nextId);\n    }\n\n    /*\n     * @dev Find the insert position for a new node with the given NICR\n     * @param _NICR Node's NICR\n     * @param _prevId Id of previous node for the insert position\n     * @param _nextId Id of next node for the insert position\n     */\n    function _findInsertPosition(\n        ITroveManager _troveManager,\n        uint256 _NICR,\n        address _prevId,\n        address _nextId\n    ) internal view returns (address, address) {\n        address prevId = _prevId;\n        address nextId = _nextId;\n\n        if (prevId != address(0)) {\n            if (\n                !contains(prevId) || _NICR > _troveManager.getNominalICR(prevId)\n            ) {\n                // `prevId` does not exist anymore or now has a smaller NICR than the given NICR\n                prevId = address(0);\n            }\n        }\n\n        if (nextId != address(0)) {\n            if (\n                !contains(nextId) || _NICR < _troveManager.getNominalICR(nextId)\n            ) {\n                // `nextId` does not exist anymore or now has a larger NICR than the given NICR\n                nextId = address(0);\n            }\n        }\n\n        if (prevId == address(0) && nextId == address(0)) {\n            // No hint - descend list starting from head\n            return _descendList(_troveManager, _NICR, data.head);\n        } else if (prevId == address(0)) {\n            // No `prevId` for hint - ascend list starting from `nextId`\n            return _ascendList(_troveManager, _NICR, nextId);\n        } else if (nextId == address(0)) {\n            // No `nextId` for hint - descend list starting from `prevId`\n            return _descendList(_troveManager, _NICR, prevId);\n        } else {\n            // Descend list starting from `prevId`\n            return _descendList(_troveManager, _NICR, prevId);\n        }\n    }\n\n    function _validInsertPosition(\n        ITroveManager _troveManager,\n        uint256 _NICR,\n        address _prevId,\n        address _nextId\n    ) internal view returns (bool) {\n        if (_prevId == address(0) && _nextId == address(0)) {\n            // `(null, null)` is a valid insert position if the list is empty\n            return isEmpty();\n        } else if (_prevId == address(0)) {\n            // `(null, _nextId)` is a valid insert position if `_nextId` is the head of the list\n            return\n                data.head == _nextId &&\n                _NICR >= _troveManager.getNominalICR(_nextId);\n        } else if (_nextId == address(0)) {\n            // `(_prevId, null)` is a valid insert position if `_prevId` is the tail of the list\n            return\n                data.tail == _prevId &&\n                _NICR <= _troveManager.getNominalICR(_prevId);\n        } else {\n            // `(_prevId, _nextId)` is a valid insert position if they are adjacent nodes and `_NICR` falls between the two nodes' NICRs\n            return\n                data.nodes[_prevId].nextId == _nextId &&\n                _troveManager.getNominalICR(_prevId) >= _NICR &&\n                _NICR >= _troveManager.getNominalICR(_nextId);\n        }\n    }\n\n    // --- 'require' functions ---\n    function _requireCallerIsTroveManager() internal view {\n        require(\n            msg.sender == address(troveManager),\n            \"SortedTroves: Caller is not the TroveManager\"\n        );\n    }\n\n    function _requireCallerIsBOorTroveM(\n        ITroveManager _troveManager\n    ) internal view {\n        require(\n            msg.sender == borrowerOperationsAddress ||\n                msg.sender == address(_troveManager),\n            \"SortedTroves: Caller is neither BO nor TroveM\"\n        );\n    }\n}\n"
    },
    "contracts/StabilityPool.sol": {
      "content": "// slither-disable-start reentrancy-benign\n// slither-disable-start reentrancy-events\n// slither-disable-start reentrancy-no-eth\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"./dependencies/CheckContract.sol\";\nimport \"./dependencies/LiquityBase.sol\";\nimport \"./dependencies/SendCollateral.sol\";\nimport \"./interfaces/IBorrowerOperations.sol\";\nimport \"./token/IMUSD.sol\";\nimport \"./interfaces/ISortedTroves.sol\";\nimport \"./interfaces/IStabilityPool.sol\";\nimport \"./interfaces/ITroveManager.sol\";\n\ncontract StabilityPool is\n    CheckContract,\n    IStabilityPool,\n    LiquityBase,\n    OwnableUpgradeable,\n    SendCollateral\n{\n    // --- Type Declarations ---\n    struct Snapshots {\n        uint256 S;\n        uint256 P;\n        uint128 scale;\n        uint128 epoch;\n    }\n\n    // The Product 'P' is an ever-decreasing number, though it never reaches 0. In order to handle it\n    // becoming smaller and smaller without losing precision, whenever it becomes too small (< 1e9),\n    // we multiply it by SCALE_FACTOR and record how many times we've done this in `currentScale`.\n    uint256 public constant SCALE_FACTOR = 1e9;\n\n    // --- State ---\n\n    IBorrowerOperations public borrowerOperations;\n    IMUSD public musd;\n    ISortedTroves public sortedTroves;\n    ITroveManager public troveManager;\n\n    // Tracker for mUSD held in the pool. Changes when users deposit/withdraw, and when Trove debt is offset.\n    uint256 internal totalMUSDDeposits;\n    uint256 internal collateral; // deposited collateral tracker\n    mapping(address => uint256) public deposits; // depositor address -> initial value\n    mapping(address => Snapshots) public depositSnapshots; // depositor address -> snapshots struct\n\n    /*  Product 'P': Running product by which to multiply an initial deposit, in order to find the current compounded deposit,\n     * after a series of liquidations have occurred, each of which cancel some mUSD debt with the deposit.\n     *\n     * During its lifetime, a deposit's value evolves from d_t to d_t * P / P_t , where P_t\n     * is the snapshot of P taken at the instant the deposit was made. 18-digit decimal.\n     */\n    uint256 public P;\n\n    // Each time the scale of P shifts by SCALE_FACTOR, the scale is incremented by 1\n    uint128 public currentScale;\n\n    // With each offset that fully empties the Pool, the epoch is incremented by 1\n    uint128 public currentEpoch;\n\n    /* collateral Gain sum 'S': During its lifetime, each deposit d_t earns an collateral gain of ( d_t * [S - S_t] )/P_t, where S_t\n     * is the depositor's snapshot of S taken at the time t when the deposit was made.\n     *\n     * The 'S' sums are stored in a nested mapping (epoch => scale => sum):\n     *\n     * - The inner mapping records the sum S at different scales\n     * - The outer mapping records the (scale => sum) mappings, for different epochs.\n     */\n    mapping(uint128 => mapping(uint128 => uint)) public epochToScaleToSum;\n\n    // Error trackers for the error correction in the offset calculation\n    uint256 public lastCollateralError_Offset;\n    uint256 public lastMUSDLossError_Offset;\n\n    // --- Functions --\n\n    function initialize() external initializer {\n        __Ownable_init(msg.sender);\n\n        P = DECIMAL_PRECISION;\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    // solhint-disable no-complex-fallback\n    receive() external payable {\n        _requireCallerIsActivePool();\n        collateral += msg.value;\n        emit StabilityPoolCollateralBalanceUpdated(collateral);\n    }\n\n    // --- External ---\n\n    function setAddresses(\n        address _activePoolAddress,\n        address _borrowerOperationsAddress,\n        address _musdTokenAddress,\n        address _priceFeedAddress,\n        address _sortedTrovesAddress,\n        address _troveManagerAddress\n    ) external override onlyOwner {\n        checkContract(_activePoolAddress);\n        checkContract(_borrowerOperationsAddress);\n        checkContract(_musdTokenAddress);\n        checkContract(_priceFeedAddress);\n        checkContract(_sortedTrovesAddress);\n        checkContract(_troveManagerAddress);\n\n        activePool = IActivePool(_activePoolAddress);\n        borrowerOperations = IBorrowerOperations(_borrowerOperationsAddress);\n        musd = IMUSD(_musdTokenAddress);\n        priceFeed = IPriceFeed(_priceFeedAddress);\n        sortedTroves = ISortedTroves(_sortedTrovesAddress);\n        troveManager = ITroveManager(_troveManagerAddress);\n\n        emit ActivePoolAddressChanged(_activePoolAddress);\n        emit BorrowerOperationsAddressChanged(_borrowerOperationsAddress);\n        emit MUSDTokenAddressChanged(_musdTokenAddress);\n        emit PriceFeedAddressChanged(_priceFeedAddress);\n        emit SortedTrovesAddressChanged(_sortedTrovesAddress);\n        emit TroveManagerAddressChanged(_troveManagerAddress);\n\n        renounceOwnership();\n    }\n\n    /*  provideToSP():\n     *\n     * - Sends depositor's accumulated gains (collateral) to depositor\n     */\n    function provideToSP(uint256 _amount) external override {\n        _requireNonZeroAmount(_amount);\n\n        uint256 initialDeposit = deposits[msg.sender];\n\n        uint256 depositorCollateralGain = getDepositorCollateralGain(\n            msg.sender\n        );\n        uint256 compoundedMUSDDeposit = getCompoundedMUSDDeposit(msg.sender);\n        uint256 mUSDLoss = initialDeposit - compoundedMUSDDeposit; // Needed only for event log\n\n        uint256 newDeposit = compoundedMUSDDeposit + _amount;\n\n        _updateDepositAndSnapshots(msg.sender, newDeposit);\n        emit UserDepositChanged(msg.sender, newDeposit);\n\n        emit CollateralGainWithdrawn(\n            msg.sender,\n            depositorCollateralGain,\n            mUSDLoss\n        ); // mUSD Loss required for event log\n\n        _sendMUSDtoStabilityPool(msg.sender, _amount);\n\n        _sendCollateralGainToDepositor(depositorCollateralGain);\n    }\n\n    /*  withdrawFromSP():\n     *\n     * - Sends all depositor's accumulated gains (collateral) to depositor\n     *\n     * If _amount > userDeposit, the user withdraws all of their compounded deposit.\n     */\n    function withdrawFromSP(uint256 _amount) external override {\n        if (_amount != 0) {\n            _requireNoUnderCollateralizedTroves();\n        }\n        uint256 initialDeposit = deposits[msg.sender];\n        _requireUserHasDeposit(initialDeposit);\n\n        uint256 depositorCollateralGain = getDepositorCollateralGain(\n            msg.sender\n        );\n\n        uint256 compoundedMUSDDeposit = getCompoundedMUSDDeposit(msg.sender);\n        uint256 mUSDtoWithdraw = LiquityMath._min(\n            _amount,\n            compoundedMUSDDeposit\n        );\n        uint256 mUSDLoss = initialDeposit - compoundedMUSDDeposit; // Needed only for event log\n\n        _sendMUSDToDepositor(msg.sender, mUSDtoWithdraw);\n\n        // Update deposit\n        uint256 newDeposit = compoundedMUSDDeposit - mUSDtoWithdraw;\n        _updateDepositAndSnapshots(msg.sender, newDeposit);\n        emit UserDepositChanged(msg.sender, newDeposit);\n\n        emit CollateralGainWithdrawn(\n            msg.sender,\n            depositorCollateralGain,\n            mUSDLoss\n        ); // mUSD Loss required for event log\n\n        _sendCollateralGainToDepositor(depositorCollateralGain);\n    }\n\n    /* withdrawCollateralGainToTrove:\n     * - Transfers the depositor's entire collateral gain from the Stability Pool to the caller's trove\n     * - Leaves their compounded deposit in the Stability Pool\n     * - Updates snapshots for deposit */\n    function withdrawCollateralGainToTrove(\n        address _upperHint,\n        address _lowerHint\n    ) external override {\n        uint256 initialDeposit = deposits[msg.sender];\n        _requireUserHasDeposit(initialDeposit);\n        _requireUserHasTrove(msg.sender);\n        _requireUserHasCollateralGain(msg.sender);\n\n        uint256 depositorCollateralGain = getDepositorCollateralGain(\n            msg.sender\n        );\n\n        uint256 compoundedMUSDDeposit = getCompoundedMUSDDeposit(msg.sender);\n        uint256 mUSDLoss = initialDeposit - compoundedMUSDDeposit; // Needed only for event log\n\n        _updateDepositAndSnapshots(msg.sender, compoundedMUSDDeposit);\n\n        /* Emit events before transferring collateral gain to Trove.\n              This lets the event log make more sense (i.e. so it appears that first the collateral gain is withdrawn\n             and then it is deposited into the Trove, not the other way around). */\n        emit CollateralGainWithdrawn(\n            msg.sender,\n            depositorCollateralGain,\n            mUSDLoss\n        );\n        emit UserDepositChanged(msg.sender, compoundedMUSDDeposit);\n\n        collateral -= depositorCollateralGain;\n        emit StabilityPoolCollateralBalanceUpdated(collateral);\n        emit CollateralSent(msg.sender, depositorCollateralGain);\n\n        borrowerOperations.moveCollateralGainToTrove{\n            value: depositorCollateralGain\n        }(msg.sender, _upperHint, _lowerHint);\n    }\n\n    /*\n     * Cancels out the specified debt against the mUSD contained in the Stability Pool (as far as possible)\n     * and transfers the Trove's collateral from ActivePool to StabilityPool.\n     * Only called by liquidation functions in the TroveManager.\n     */\n    function offset(\n        uint256 _principalToOffset,\n        uint256 _interestToOffset,\n        uint256 _collToAdd\n    ) external override {\n        _requireCallerIsTroveManager();\n        uint256 totalMUSD = totalMUSDDeposits; // cached to save an SLOAD\n        uint256 debtToOffset = _principalToOffset + _interestToOffset;\n        if (totalMUSD == 0 || debtToOffset == 0) {\n            return;\n        }\n\n        (\n            uint256 collateralGainPerUnitStaked,\n            uint256 mUSDLossPerUnitStaked\n        ) = _computeRewardsPerUnitStaked(_collToAdd, debtToOffset, totalMUSD);\n\n        _updateRewardSumAndProduct(\n            collateralGainPerUnitStaked,\n            mUSDLossPerUnitStaked\n        ); // updates S and P\n\n        _moveOffsetCollAndDebt(\n            _collToAdd,\n            _principalToOffset,\n            _interestToOffset\n        );\n    }\n\n    // --- Getters for public variables. Required by IPool interface ---\n\n    function getCollateralBalance() external view override returns (uint) {\n        return collateral;\n    }\n\n    function getTotalMUSDDeposits() external view override returns (uint) {\n        return totalMUSDDeposits;\n    }\n\n    // -- Public ---\n\n    /* Calculates the collateral gain earned by the deposit since its last snapshots were taken.\n     * Given by the formula:  E = d0 * (S - S(0))/P(0)\n     * where S(0) and P(0) are the depositor's snapshots of the sum S and product P, respectively.\n     * d0 is the last recorded deposit value.\n     */\n    function getDepositorCollateralGain(\n        address _depositor\n    ) public view override returns (uint) {\n        uint256 initialDeposit = deposits[_depositor];\n\n        if (initialDeposit == 0) {\n            return 0;\n        }\n\n        Snapshots memory snapshots = depositSnapshots[_depositor];\n\n        uint256 collateralGain = _getCollateralGainFromSnapshots(\n            initialDeposit,\n            snapshots\n        );\n        return collateralGain;\n    }\n\n    // --- Compounded deposit ---\n\n    /*\n     * Return the user's compounded deposit. Given by the formula:  d = d0 * P/P(0)\n     * where P(0) is the depositor's snapshot of the product P, taken when they last updated their deposit.\n     */\n    function getCompoundedMUSDDeposit(\n        address _depositor\n    ) public view override returns (uint) {\n        uint256 initialDeposit = deposits[_depositor];\n        if (initialDeposit == 0) {\n            return 0;\n        }\n\n        Snapshots memory snapshots = depositSnapshots[_depositor];\n\n        uint256 compoundedDeposit = _getCompoundedStakeFromSnapshots(\n            initialDeposit,\n            snapshots\n        );\n        return compoundedDeposit;\n    }\n\n    // -- Internal ---\n\n    function _sendMUSDToDepositor(\n        address _depositor,\n        uint256 _withdrawal\n    ) internal {\n        if (_withdrawal == 0) {\n            return;\n        }\n\n        // slither-disable-next-line unchecked-transfer\n        musd.transfer(_depositor, _withdrawal);\n        _decreaseMUSD(_withdrawal);\n    }\n\n    // Transfer the mUSD tokens from the user to the Stability Pool's address,\n    // and update its recorded mUSD\n    function _sendMUSDtoStabilityPool(\n        address _address,\n        uint256 _amount\n    ) internal {\n        uint256 newTotalMUSDDeposits = totalMUSDDeposits + _amount;\n        totalMUSDDeposits = newTotalMUSDDeposits;\n\n        emit StabilityPoolMUSDBalanceUpdated(newTotalMUSDDeposits);\n\n        bool transferSuccess = musd.transferFrom(\n            _address,\n            address(this),\n            _amount\n        );\n        require(transferSuccess, \"MUSD was not transferred successfully.\");\n    }\n\n    function _updateDepositAndSnapshots(\n        address _depositor,\n        uint256 _newValue\n    ) internal {\n        deposits[_depositor] = _newValue;\n\n        if (_newValue == 0) {\n            delete depositSnapshots[_depositor];\n            emit DepositSnapshotUpdated(_depositor, 0, 0);\n            return;\n        }\n        uint128 currentScaleCached = currentScale;\n        uint128 currentEpochCached = currentEpoch;\n        uint256 currentP = P;\n\n        // Get S and G for the current epoch and current scale\n        uint256 currentS = epochToScaleToSum[currentEpochCached][\n            currentScaleCached\n        ];\n\n        // Record new snapshots of the latest running product P, sum S, and sum G, for the depositor\n        depositSnapshots[_depositor].P = currentP;\n        depositSnapshots[_depositor].S = currentS;\n        depositSnapshots[_depositor].scale = currentScaleCached;\n        depositSnapshots[_depositor].epoch = currentEpochCached;\n\n        emit DepositSnapshotUpdated(_depositor, currentP, currentS);\n    }\n\n    function _sendCollateralGainToDepositor(uint256 _amount) internal {\n        if (_amount == 0) {\n            return;\n        }\n        uint256 newCollateral = collateral - _amount;\n        collateral = newCollateral;\n        emit StabilityPoolCollateralBalanceUpdated(newCollateral);\n        emit CollateralSent(msg.sender, _amount);\n\n        _sendCollateral(msg.sender, _amount);\n    }\n\n    function _computeRewardsPerUnitStaked(\n        uint256 _collToAdd,\n        uint256 _debtToOffset,\n        uint256 _totalMUSDDeposits\n    )\n        internal\n        returns (\n            uint256 collateralGainPerUnitStaked,\n            uint256 mUSDLossPerUnitStaked\n        )\n    {\n        /*\n         * Compute the mUSD and collateral rewards. Uses a \"feedback\" error correction, to keep\n         * the cumulative error in the P and S state variables low:\n         *\n         * 1) Form numerators which compensate for the floor division errors that occurred the last time this\n         * function was called.\n         * 2) Calculate \"per-unit-staked\" ratios.\n         * 3) Multiply each ratio back by its denominator, to reveal the current floor division error.\n         * 4) Store these errors for use in the next correction when this function is called.\n         * 5) Note: static analysis tools complain about this \"division before multiplication\", however, it is intended.\n         */\n        uint256 collateralNumerator = _collToAdd *\n            DECIMAL_PRECISION +\n            lastCollateralError_Offset;\n\n        assert(_debtToOffset <= _totalMUSDDeposits);\n        if (_debtToOffset == _totalMUSDDeposits) {\n            mUSDLossPerUnitStaked = DECIMAL_PRECISION; // When the Pool depletes to 0, so does each deposit\n            lastMUSDLossError_Offset = 0;\n        } else {\n            uint256 mUSDLossNumerator = _debtToOffset *\n                DECIMAL_PRECISION -\n                lastMUSDLossError_Offset;\n            /*\n             * Add 1 to make error in quotient positive. We want \"slightly too much\" mUSD loss,\n             * which ensures the error in any given compoundedMUSDDeposit favors the Stability Pool.\n             */\n            mUSDLossPerUnitStaked = mUSDLossNumerator / _totalMUSDDeposits + 1;\n            lastMUSDLossError_Offset =\n                mUSDLossPerUnitStaked *\n                _totalMUSDDeposits -\n                mUSDLossNumerator;\n        }\n\n        collateralGainPerUnitStaked = collateralNumerator / _totalMUSDDeposits;\n        // slither-disable-next-line divide-before-multiply\n        lastCollateralError_Offset =\n            collateralNumerator -\n            (collateralGainPerUnitStaked * _totalMUSDDeposits);\n\n        return (collateralGainPerUnitStaked, mUSDLossPerUnitStaked);\n    }\n\n    function _moveOffsetCollAndDebt(\n        uint256 _collToAdd,\n        uint256 _principalToOffset,\n        uint256 _interestToOffset\n    ) internal {\n        IActivePool activePoolCached = activePool;\n\n        uint256 debtToOffset = _principalToOffset + _interestToOffset;\n        // Cancel the liquidated debt with the mUSD in the stability pool\n        activePoolCached.decreaseDebt(_principalToOffset, _interestToOffset);\n        _decreaseMUSD(debtToOffset);\n\n        // Burn the debt that was successfully offset\n        musd.burn(address(this), debtToOffset);\n\n        activePoolCached.sendCollateral(address(this), _collToAdd);\n    }\n\n    function _decreaseMUSD(uint256 _amount) internal {\n        uint256 newTotalMUSDDeposits = totalMUSDDeposits - _amount;\n        totalMUSDDeposits = newTotalMUSDDeposits;\n        emit StabilityPoolMUSDBalanceUpdated(newTotalMUSDDeposits);\n    }\n\n    // Update the Stability Pool reward sum S and product P\n\n    // slither-disable-start dead-code\n    function _updateRewardSumAndProduct(\n        uint256 _collateralGainPerUnitStaked,\n        uint256 _mUSDLossPerUnitStaked\n    ) internal {\n        uint256 currentP = P;\n        uint256 newP;\n\n        assert(_mUSDLossPerUnitStaked <= DECIMAL_PRECISION);\n        /*\n         * The newProductFactor is the factor by which to change all deposits, due to the depletion of Stability Pool mUSD in the liquidation.\n         * We make the product factor 0 if there was a pool-emptying. Otherwise, it is (1 - MUSDLossPerUnitStaked)\n         */\n        uint256 newProductFactor = DECIMAL_PRECISION - _mUSDLossPerUnitStaked;\n\n        uint128 currentScaleCached = currentScale;\n        uint128 currentEpochCached = currentEpoch;\n        uint256 currentS = epochToScaleToSum[currentEpochCached][\n            currentScaleCached\n        ];\n\n        /*\n         * Calculate the new S first, before we update P.\n         * The collateral gain for any given depositor from a liquidation depends on the value of their deposit\n         * (and the value of totalDeposits) prior to the Stability being depleted by the debt in the liquidation.\n         *\n         * Since S corresponds to collateral gain, and P to deposit loss, we update S first.\n         */\n        uint256 marginalCollateralGain = _collateralGainPerUnitStaked *\n            currentP;\n        uint256 newS = currentS + marginalCollateralGain;\n        epochToScaleToSum[currentEpochCached][currentScaleCached] = newS;\n        emit SUpdated(newS, currentEpochCached, currentScaleCached);\n\n        uint256 PBeforeScaleChanges = (currentP * newProductFactor) /\n            DECIMAL_PRECISION;\n\n        if (newProductFactor == 0) {\n            // If the Stability Pool was emptied, increment the epoch, and reset\n            // the scale and product P\n            currentEpoch = currentEpochCached + 1;\n            emit EpochUpdated(currentEpoch);\n            currentScale = 0;\n            emit ScaleUpdated(currentScale);\n            newP = DECIMAL_PRECISION;\n        } else if (PBeforeScaleChanges == 1) {\n            // If multiplying P by the product factor results in exactly one, we\n            // need to increment the scale twice.\n            newP =\n                (currentP * newProductFactor * SCALE_FACTOR * SCALE_FACTOR) /\n                DECIMAL_PRECISION;\n            currentScale = currentScaleCached + 2;\n            emit ScaleUpdated(currentScale);\n        } else if (PBeforeScaleChanges < SCALE_FACTOR) {\n            // If multiplying P by a non-zero product factor would reduce P below\n            // the scale boundary, increment the scale\n            newP =\n                (currentP * newProductFactor * SCALE_FACTOR) /\n                DECIMAL_PRECISION;\n            currentScale = currentScaleCached + 1;\n            emit ScaleUpdated(currentScale);\n        } else {\n            newP = PBeforeScaleChanges;\n        }\n\n        assert(newP > 0);\n        P = newP;\n\n        emit PUpdated(newP);\n    }\n\n    function _requireNoUnderCollateralizedTroves() internal view {\n        uint256 price = priceFeed.fetchPrice();\n        address lowestTrove = sortedTroves.getLast();\n        uint256 ICR = troveManager.getCurrentICR(lowestTrove, price);\n        require(\n            ICR >= MCR,\n            \"StabilityPool: Cannot withdraw while there are troves with ICR < MCR\"\n        );\n    }\n\n    // Used to calculcate compounded deposits.\n    function _getCompoundedStakeFromSnapshots(\n        uint256 initialStake,\n        Snapshots memory snapshots\n    ) internal view returns (uint) {\n        uint256 snapshot_P = snapshots.P;\n        uint128 scaleSnapshot = snapshots.scale;\n        uint128 epochSnapshot = snapshots.epoch;\n\n        // If stake was made before a pool-emptying event, then it has been fully cancelled with debt -- so, return 0\n        if (epochSnapshot < currentEpoch) {\n            return 0;\n        }\n\n        uint256 compoundedStake;\n        uint128 scaleDiff = currentScale - scaleSnapshot;\n\n        /* Compute the compounded stake. If a scale change in P was made during the stake's lifetime,\n         * account for it. If more than one scale change was made, then the stake has decreased by a factor of\n         * at least 1e-9 -- so return 0.\n         */\n        if (scaleDiff == 0) {\n            compoundedStake = (initialStake * P) / snapshot_P;\n        } else if (scaleDiff == 1) {\n            compoundedStake = (initialStake * P) / snapshot_P / SCALE_FACTOR;\n        } else {\n            // if scaleDiff >= 2\n            compoundedStake = 0;\n        }\n\n        /*\n         * If compounded deposit is less than a billionth of the initial deposit, return 0.\n         *\n         * NOTE: originally, this line was in place to stop rounding errors making the deposit\n         * too large. However, the error corrections should ensure the error in P \"favors the Pool\",\n         * i.e. any given compounded deposit should be slightly less than its theoretical value.\n         *\n         * Thus it's unclear whether this line is still really needed.\n         */\n        if (compoundedStake < initialStake / 1e9) {\n            return 0;\n        }\n\n        return compoundedStake;\n    }\n\n    function _getCollateralGainFromSnapshots(\n        uint256 initialDeposit,\n        Snapshots memory snapshots\n    ) internal view returns (uint) {\n        /*\n         * Grab the sum 'S' from the epoch at which the stake was made. The collateral gain may span up to one scale change.\n         * If it does, the second portion of the collateral gain is scaled by 1e9.\n         * If the gain spans no scale change, the second portion will be 0.\n         */\n        uint128 epochSnapshot = snapshots.epoch;\n        uint128 scaleSnapshot = snapshots.scale;\n        uint256 S_Snapshot = snapshots.S;\n        uint256 P_Snapshot = snapshots.P;\n\n        uint256 firstPortion = epochToScaleToSum[epochSnapshot][scaleSnapshot] -\n            S_Snapshot;\n        uint256 secondPortion = epochToScaleToSum[epochSnapshot][\n            scaleSnapshot + 1\n        ] / SCALE_FACTOR;\n\n        uint256 collateralGain = (initialDeposit *\n            (firstPortion + secondPortion)) /\n            P_Snapshot /\n            DECIMAL_PRECISION;\n\n        return collateralGain;\n    }\n\n    function _requireCallerIsActivePool() internal view {\n        require(\n            msg.sender == address(activePool),\n            \"StabilityPool: Caller is not ActivePool\"\n        );\n    }\n\n    function _requireCallerIsTroveManager() internal view {\n        require(\n            msg.sender == address(troveManager),\n            \"StabilityPool: Caller is not TroveManager\"\n        );\n    }\n\n    function _requireUserHasTrove(address _depositor) internal view {\n        require(\n            troveManager.getTroveStatus(_depositor) ==\n                ITroveManager.Status.active,\n            \"StabilityPool: caller must have an active trove to withdraw collateralGain to\"\n        );\n    }\n\n    function _requireUserHasCollateralGain(address _depositor) internal view {\n        uint256 collateralGain = getDepositorCollateralGain(_depositor);\n        require(\n            collateralGain > 0,\n            \"StabilityPool: caller must have non-zero collateral Gain\"\n        );\n    }\n\n    function _requireUserHasDeposit(uint256 _initialDeposit) internal pure {\n        require(\n            _initialDeposit > 0,\n            \"StabilityPool: User must have a non-zero deposit\"\n        );\n    }\n\n    function _requireNonZeroAmount(uint256 _amount) internal pure {\n        require(_amount > 0, \"StabilityPool: Amount must be non-zero\");\n    }\n}\n\n// slither-disable-end dead-code\n// slither-disable-end reentrancy-benign\n// slither-disable-end reentrancy-events\n// slither-disable-end reentrancy-no-eth\n"
    },
    "contracts/tests/InterestRateManagerTester.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../InterestRateManager.sol\";\n\n/**\n * @title InterestRateManagerTester\n * @notice Test version that allows interest rate setting without governance\n */\ncontract InterestRateManagerTester is InterestRateManager {\n    /**\n     * @notice Test function to set interest rate immediately without delay\n     * @param _newInterestRate The new interest rate to set\n     */\n    // slither-disable-start reentrancy-benign\n    // slither-disable-start reentrancy-events\n    function setInterestRateForTesting(uint16 _newInterestRate) external {\n        require(\n            _newInterestRate <= MAX_INTEREST_RATE,\n            \"InterestRateManager: rate exceeds MAX_INTEREST_RATE\"\n        );\n\n        // Calculate interest with current rate before changing\n        troveManager.updateSystemInterest();\n\n        // Set new rate directly\n        interestRate = _newInterestRate;\n\n        emit InterestRateUpdated(_newInterestRate);\n    }\n    // slither-disable-end reentrancy-benign\n    // slither-disable-end reentrancy-events\n}\n"
    },
    "contracts/tests/MockAggregator.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.24;\n\nimport \"../interfaces/ChainlinkAggregatorV3Interface.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract MockAggregator is ChainlinkAggregatorV3Interface, Ownable {\n    uint256 private _price;\n    uint8 private precision;\n    uint256 private blockTime;\n\n    constructor(uint8 _decimals) Ownable(msg.sender) {\n        precision = _decimals;\n        uint256 multiplier = 10 ** uint8(precision);\n        _price = 50000 * multiplier;\n    }\n\n    // Manual external price setter.\n    function setPrice(uint256 price) external onlyOwner returns (bool) {\n        // slither-disable-next-line events-maths\n        _price = price;\n        return true;\n    }\n\n    function setPrecision(uint8 _precision) external onlyOwner returns (bool) {\n        uint256 oldMultiplier = 10 ** uint8(precision);\n        uint256 basePrice = uint256(_price / oldMultiplier);\n        uint256 multiplier = 10 ** uint8(_precision);\n        // slither-disable-start events-maths\n        _price = basePrice * multiplier;\n        precision = _precision;\n        // slither-disable-end events-maths\n        return true;\n    }\n\n    function setBlockTime(uint256 _blockTime) external onlyOwner {\n        // slither-disable-next-line events-maths\n        blockTime = _blockTime;\n    }\n\n    function latestRoundData()\n        external\n        view\n        returns (uint80, int256, uint256, uint256, uint80)\n    {\n        require(precision <= 77, \"Decimals too large\"); // Prevent overflow\n        uint256 updatedAt = blockTime;\n        if (updatedAt == 0) {\n            // solhint-disable-next-line not-rely-on-time\n            updatedAt = block.timestamp;\n        }\n        int256 answer = int256(_price);\n        return (0, answer, updatedAt, updatedAt, 0);\n    }\n\n    function decimals() public view returns (uint8) {\n        return precision;\n    }\n}\n"
    },
    "contracts/tests/MUSDTester.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"../token/MUSD.sol\";\n\ncontract MUSDTester is MUSD {\n    function unprotectedMint(address _account, uint256 _amount) external {\n        // No check on caller here\n\n        _mint(_account, _amount);\n    }\n\n    function unprotectedBurn(address _account, uint256 _amount) external {\n        // No check on caller here\n\n        _burn(_account, _amount);\n    }\n\n    function callInternalApprove(\n        address owner,\n        address spender,\n        uint256 amount\n    ) external {\n        _approve(owner, spender, amount);\n    }\n}\n"
    },
    "contracts/tests/TroveManagerTester.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"../TroveManager.sol\";\n\n/* Tester contract inherits from TroveManager, and provides external functions\nfor testing the parent's internal functions. */\n\ncontract TroveManagerTester is TroveManager {\n    function getCompositeDebt(uint256 _debt) external pure returns (uint) {\n        return _getCompositeDebt(_debt);\n    }\n\n    function computeICR(\n        uint256 _coll,\n        uint256 _debt,\n        uint256 _price\n    ) external pure returns (uint) {\n        return LiquityMath._computeCR(_coll, _debt, _price);\n    }\n\n    function calculateInterestOwed(\n        uint256 _principal,\n        uint16 _interestRate,\n        uint256 startTime,\n        uint256 endTime\n    ) external pure returns (uint256) {\n        return\n            InterestRateMath.calculateInterestOwed(\n                _principal,\n                _interestRate,\n                startTime,\n                endTime\n            );\n    }\n}\n"
    },
    "contracts/tests/upgrades/ActivePoolV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../ActivePool.sol\";\n\ncontract ActivePoolV2 is ActivePool {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 609;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/BorrowerOperationsSignaturesV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../BorrowerOperationsSignatures.sol\";\n\ncontract BorrowerOperationsSignaturesV2 is BorrowerOperationsSignatures {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        __EIP712_init_unchained(\"BorrowerOperationsSignatures\", \"2\");\n        newField = 722;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/BorrowerOperationsV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../BorrowerOperations.sol\";\n\ncontract BorrowerOperationsV2 is BorrowerOperations {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 885;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/CollSurplusPoolV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../CollSurplusPool.sol\";\n\ncontract CollSurplusPoolV2 is CollSurplusPool {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 101;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/DefaultPoolV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../DefaultPool.sol\";\n\ncontract DefaultPoolV2 is DefaultPool {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 212;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/GasPoolV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../GasPool.sol\";\n\ncontract GasPoolV2 is GasPool {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 144;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/GovernableVariablesV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../GovernableVariables.sol\";\n\ncontract GovernableVariablesV2 is GovernableVariables {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 171;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/HintHelpersV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../HintHelpers.sol\";\n\ncontract HintHelpersV2 is HintHelpers {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 254;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/InterestRateManagerV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../InterestRateManager.sol\";\n\ncontract InterestRateManagerV2 is InterestRateManager {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 880;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/PCVv2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../PCV.sol\";\n\ncontract PCVv2 is PCV {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 60;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/PriceFeedV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../PriceFeed.sol\";\n\ncontract PriceFeedV2 is PriceFeed {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 397;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/SortedTrovesV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../SortedTroves.sol\";\n\ncontract SortedTrovesV2 is SortedTroves {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 700;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/StabilityPoolV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../StabilityPool.sol\";\n\ncontract StabilityPoolV2 is StabilityPool {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 700;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/tests/upgrades/TroveManagerV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"../../TroveManager.sol\";\n\ncontract TroveManagerV2 is TroveManager {\n    uint256 public newField;\n\n    function initializeV2() external reinitializer(2) {\n        newField = 999;\n    }\n\n    function newFunction() external {\n        newField++;\n    }\n}\n"
    },
    "contracts/token/IMUSD.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol\";\n\ninterface IMUSD is IERC20Metadata, IERC20Permit {\n    event BorrowerOperationsAddressAdded(address newBorrowerOperationsAddress);\n    event InterestRateManagerAddressAdded(address interestRateManagerAddress);\n    event StabilityPoolAddressAdded(address newStabilityPoolAddress);\n    event TroveManagerAddressAdded(address troveManagerAddress);\n    event MintListAddressAdded(address _address);\n    event MintListAddressRemoved(address _address);\n    event BurnListAddressAdded(address _address);\n    event BurnListAddressRemoved(address _address);\n\n    error AddressHasMintRole();\n    error AddressHasBurnRole();\n    error AddressWithoutMintRole();\n    error AddressWithoutBurnRole();\n\n    function burn(address _account, uint256 _amount) external;\n    function mint(address _account, uint256 _amount) external;\n    function burnList(address contractAddress) external view returns (bool);\n    function mintList(address contractAddress) external view returns (bool);\n}\n"
    },
    "contracts/token/MUSD.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\nimport \"../dependencies/CheckContract.sol\";\nimport \"./IMUSD.sol\";\n\ncontract MUSD is ERC20Permit, Ownable, CheckContract, IMUSD {\n    bool public initialized;\n\n    mapping(address => bool) public burnList;\n    mapping(address => bool) public mintList;\n\n    constructor()\n        Ownable(msg.sender)\n        ERC20(\"Mezo USD\", \"MUSD\")\n        ERC20Permit(\"Mezo USD\")\n    {}\n\n    // Initializes token with system contracts outside of the constructor\n    // allowing the token deployer to establish stable address for the contract,\n    // irrespective of the system contract addresses. Can only be called by\n    // the owner (the deployer before the rights are passed) and only one time.\n    function initialize(\n        address _troveManagerAddress,\n        address _stabilityPoolAddress,\n        address _borrowerOperationsAddress,\n        address _interestRateManagerAddress\n    ) external onlyOwner {\n        require(!initialized, \"Already initialized\");\n        initialized = true;\n\n        setSystemContracts(\n            _troveManagerAddress,\n            _stabilityPoolAddress,\n            _borrowerOperationsAddress,\n            _interestRateManagerAddress\n        );\n    }\n\n    // --- Governance ---\n\n    function addToMintList(address _address) public onlyOwner {\n        if (mintList[_address]) {\n            revert AddressHasMintRole();\n        }\n        mintList[_address] = true;\n        emit MintListAddressAdded(_address);\n    }\n\n    function removeFromMintList(address _address) public onlyOwner {\n        if (!mintList[_address]) {\n            revert AddressWithoutMintRole();\n        }\n        mintList[_address] = false;\n        emit MintListAddressRemoved(_address);\n    }\n\n    function addToBurnList(address _address) public onlyOwner {\n        if (burnList[_address]) {\n            revert AddressHasBurnRole();\n        }\n        burnList[_address] = true;\n        emit BurnListAddressAdded(_address);\n    }\n\n    function removeFromBurnList(address _address) public onlyOwner {\n        if (!burnList[_address]) {\n            revert AddressWithoutBurnRole();\n        }\n        burnList[_address] = false;\n        emit BurnListAddressRemoved(_address);\n    }\n\n    function setSystemContracts(\n        address _troveManagerAddress,\n        address _stabilityPoolAddress,\n        address _borrowerOperationsAddress,\n        address _interestRateManagerAddress\n    ) public onlyOwner {\n        checkContract(_troveManagerAddress);\n        checkContract(_stabilityPoolAddress);\n        checkContract(_borrowerOperationsAddress);\n        checkContract(_interestRateManagerAddress);\n\n        addToBurnList(_troveManagerAddress);\n        emit TroveManagerAddressAdded(_troveManagerAddress);\n\n        addToBurnList(_stabilityPoolAddress);\n        emit StabilityPoolAddressAdded(_stabilityPoolAddress);\n\n        addToBurnList(_borrowerOperationsAddress);\n        addToMintList(_borrowerOperationsAddress);\n        emit BorrowerOperationsAddressAdded(_borrowerOperationsAddress);\n\n        addToMintList(_interestRateManagerAddress);\n        emit InterestRateManagerAddressAdded(_interestRateManagerAddress);\n    }\n\n    // --- Functions for intra-Liquity calls ---\n\n    function mint(address _account, uint256 _amount) external {\n        require(mintList[msg.sender], \"MUSD: Caller not allowed to mint\");\n        _mint(_account, _amount);\n    }\n\n    function burn(address _account, uint256 _amount) external {\n        require(burnList[msg.sender], \"MUSD: Caller not allowed to burn\");\n        _burn(_account, _amount);\n    }\n\n    function transfer(\n        address to,\n        uint256 amount\n    ) public virtual override(ERC20, IERC20) returns (bool) {\n        require(to != address(0), \"ERC20: transfer to the zero address\");\n        require(to != address(this), \"ERC20: transfer to the contract address\");\n        return super.transfer(to, amount);\n    }\n\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) public override(ERC20, IERC20) returns (bool) {\n        require(to != address(0), \"ERC20: transfer to the zero address\");\n        require(to != address(this), \"ERC20: transfer to the contract address\");\n        return super.transferFrom(from, to, amount);\n    }\n\n    function nonces(\n        address owner\n    )\n        public\n        view\n        virtual\n        override(ERC20Permit, IERC20Permit)\n        returns (uint256)\n    {\n        return super.nonces(owner);\n    }\n}\n"
    },
    "contracts/token/TokenDeployer.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity 0.8.24;\n\nimport \"./MUSD.sol\";\n\n/// @title MUSD Token Deployer\n/// @notice TokenDeployer allows the governance to deploy MUSD token to the\n///         chain using a stable address. The TokenDeployer should be deployed\n///         to the chain using the EIP2470 singleton factory.\ncontract TokenDeployer {\n    bytes32 public constant SALT =\n        keccak256(\"Bank on yourself. Bring everyday finance to your Bitcoin.\");\n\n    /// @notice The deployer address allowed to call the `deploy()` function.\n    /// @dev This is the same deployer EOA as the one used to deploy all tBTC v1,\n    ///      tBTC v2, and Mezo contracts across various networks.\n    address public constant DEPLOYER =\n        0x123694886DBf5Ac94DDA07135349534536D14cAf;\n\n    /// @notice The governance address receiving the control over the token;\n    /// @dev This is the same multisig as the one used to control Mezo contracts\n    ///      upgradeability and some protocol parameters of the chain.\n    address public constant GOVERNANCE =\n        0x98D8899c3030741925BE630C710A98B57F397C7a;\n\n    uint256 public constant MEZO_CHAIN_ID = 31612;\n    uint256 public constant ETHEREUM_CHAIN_ID = 1;\n\n    /// @notice The address of the deployed MUSD token contract.\n    /// @dev Zero address before the contract is deployed.\n    address public token;\n\n    event TokenDeployed(address token);\n\n    error Create2Failed();\n    error NotDeployer();\n    error NotGovernance();\n\n    /// @notice Deploys the MUSD token to the chain via create2 and initializes\n    ///         it with the provided system contract addresses and governance\n    ///         delay.\n    function deployToken(\n        address _troveManagerAddress,\n        address _stabilityPoolAddress,\n        address _borrowerOperationsAddress,\n        address _interestRateManagerAddress\n    ) external {\n        if (\n            block.chainid == MEZO_CHAIN_ID || block.chainid == ETHEREUM_CHAIN_ID\n        ) {\n            if (msg.sender != DEPLOYER) {\n                revert NotDeployer();\n            }\n        } else {\n            if (msg.sender != GOVERNANCE) {\n                revert NotGovernance();\n            }\n        }\n\n        // Slither detector yields false positive, it is a bug in Slither.\n        // https://github.com/crytic/slither/issues/1223\n        // slither-disable-next-line too-many-digits\n        token = _deploy(type(MUSD).creationCode);\n        emit TokenDeployed(token);\n\n        MUSD(token).initialize(\n            _troveManagerAddress,\n            _stabilityPoolAddress,\n            _borrowerOperationsAddress,\n            _interestRateManagerAddress\n        );\n\n        MUSD(token).transferOwnership(GOVERNANCE);\n    }\n\n    /// @dev Deploys a contract with CREATE2.\n    /// @param deploymentData Encoded deployment data.\n    /// @return deployedContract Address of the deployed contract.\n    function _deploy(\n        bytes memory deploymentData\n    ) internal returns (address deployedContract) {\n        bytes32 salt = SALT;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            deployedContract := create2(\n                0x0,\n                add(0x20, deploymentData),\n                mload(deploymentData),\n                salt\n            )\n        }\n        if (address(deployedContract) == address(0)) {\n            revert Create2Failed();\n        }\n    }\n}\n"
    },
    "contracts/TroveManager.sol": {
      "content": "// slither-disable-start reentrancy-benign\n// slither-disable-start reentrancy-events\n// slither-disable-start reentrancy-no-eth\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.24;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"./dependencies/CheckContract.sol\";\nimport \"./dependencies/InterestRateMath.sol\";\nimport \"./dependencies/LiquityBase.sol\";\nimport \"./interfaces/IBorrowerOperations.sol\";\nimport \"./interfaces/ICollSurplusPool.sol\";\nimport \"./interfaces/IGasPool.sol\";\nimport \"./interfaces/IInterestRateManager.sol\";\nimport \"./interfaces/IPCV.sol\";\nimport \"./interfaces/ISortedTroves.sol\";\nimport \"./interfaces/IStabilityPool.sol\";\nimport \"./interfaces/ITroveManager.sol\";\nimport \"./token/IMUSD.sol\";\n\ncontract TroveManager is\n    CheckContract,\n    ITroveManager,\n    LiquityBase,\n    OwnableUpgradeable\n{\n    enum TroveManagerOperation {\n        applyPendingRewards,\n        liquidate,\n        redeemCollateral\n    }\n\n    // Store the necessary data for a trove\n    struct Trove {\n        uint256 coll;\n        uint256 principal;\n        uint256 interestOwed;\n        uint256 stake;\n        Status status;\n        uint16 interestRate;\n        uint256 lastInterestUpdateTime;\n        uint256 maxBorrowingCapacity;\n        uint128 arrayIndex;\n    }\n\n    // Object containing the collateral and mUSD snapshots for a given active trove\n    struct RewardSnapshot {\n        uint256 collateral;\n        uint256 principal;\n        uint256 interest;\n    }\n\n    struct LocalVariables_OuterLiquidationFunction {\n        uint256 price;\n        uint256 mUSDInStabPool;\n        uint256 liquidatedColl;\n    }\n\n    struct LocalVariables_redeemCollateralFromTrove {\n        uint256 newDebt;\n        uint256 newColl;\n        uint256 newPrincipal;\n        uint256 interestPayment;\n        uint256 upperBoundNICR;\n        uint256 newNICR;\n        uint256 mUSDLot;\n    }\n\n    struct LocalVariables_InnerSingleLiquidateFunction {\n        uint256 collToLiquidate;\n        uint256 pendingColl;\n        uint256 pendingPrincipal;\n        uint256 pendingInterest;\n    }\n\n    struct LiquidationTotals {\n        uint256 totalCollInSequence;\n        uint256 totalPrincipalInSequence;\n        uint256 totalInterestInSequence;\n        uint256 totalCollGasCompensation;\n        uint256 totalMUSDGasCompensation;\n        uint256 totalPrincipalToOffset;\n        uint256 totalInterestToOffset;\n        uint256 totalCollToSendToSP;\n        uint256 totalPrincipalToRedistribute;\n        uint256 totalInterestToRedistribute;\n        uint256 totalCollToRedistribute;\n        uint256 totalCollSurplus;\n    }\n\n    struct LocalVariables_LiquidationSequence {\n        uint256 remainingMUSDInStabPool;\n        uint256 i;\n        uint256 ICR;\n        address user;\n        uint256 entireSystemDebt;\n        uint256 entireSystemColl;\n    }\n\n    struct LocalVariables_redeemCollateral {\n        uint256 minNetDebt;\n        uint16 interestRate;\n    }\n\n    struct LiquidationValues {\n        uint256 entireTrovePrincipal;\n        uint256 entireTroveInterest;\n        uint256 entireTroveColl;\n        uint256 collGasCompensation;\n        uint256 mUSDGasCompensation;\n        uint256 principalToOffset;\n        uint256 interestToOffset;\n        uint256 collToSendToSP;\n        uint256 principalToRedistribute;\n        uint256 interestToRedistribute;\n        uint256 collToRedistribute;\n        uint256 collSurplus;\n    }\n\n    struct ContractsCache {\n        IActivePool activePool;\n        IDefaultPool defaultPool;\n        IMUSD musdToken;\n        IPCV pcv;\n        ISortedTroves sortedTroves;\n        ICollSurplusPool collSurplusPool;\n        address gasPoolAddress;\n    }\n\n    struct SingleRedemptionValues {\n        uint256 principal;\n        uint256 interest;\n        uint256 collateralLot;\n        bool cancelledPartial;\n    }\n\n    struct RedemptionTotals {\n        uint256 remainingMUSD;\n        uint256 totalPrincipalToRedeem;\n        uint256 totalInterestToRedeem;\n        uint256 totalCollateralDrawn;\n        uint256 collateralFee;\n        uint256 collateralToSendToRedeemer;\n        uint256 price;\n        uint256 totalDebtAtStart;\n    }\n\n    // --- Connected contract declarations ---\n\n    IBorrowerOperations public borrowerOperations;\n    ICollSurplusPool public collSurplusPool;\n    address public gasPoolAddress;\n    IMUSD public musdToken;\n    IPCV public override pcv;\n    // A doubly linked list of Troves, sorted by their sorted by their collateral ratios\n    ISortedTroves public sortedTroves;\n    IStabilityPool public override stabilityPool;\n\n    // --- Data structures ---\n\n    mapping(address => Trove) public Troves;\n\n    uint256 public totalStakes;\n\n    // Snapshot of the value of totalStakes, taken immediately after the latest liquidation\n    uint256 public totalStakesSnapshot;\n\n    // Snapshot of the total collateral across the ActivePool and DefaultPool, immediately after the latest liquidation.\n    uint256 public totalCollateralSnapshot;\n\n    /*\n     * L_Collateral, L_Principal, and L_Interest track the sums of accumulated\n     * pending liquidations per unit staked. During its lifetime, each stake\n     * earns:\n     *\n     * An collateral gain of ( stake * [L_Collateral - L_Collateral(0)] )\n     * A principal increase  of ( stake * [L_Principal - L_Principal(0)] )\n     * An interest increase  of ( stake * [L_Interest - L_Interest(0)] )\n     *\n     * Where L_Collateral(0), L_Principal(0), and L_Interest(0) are snapshots of\n     * L_Collateral, L_Principal, and L_Interest for the active Trove taken at the\n     * instant the stake was made\n     */\n    uint256 public L_Collateral;\n    uint256 public L_Principal;\n    uint256 public L_Interest;\n\n    // Array of all active trove addresses - used to to compute an approximate hint off-chain, for the sorted list insertion\n    // slither-disable-next-line similar-names\n    address[] public TroveOwners;\n\n    // Error trackers for the trove redistribution calculation\n    uint256 public lastCollateralError_Redistribution;\n    uint256 public lastPrincipalError_Redistribution;\n    uint256 public lastInterestError_Redistribution;\n\n    // Map addresses with active troves to their RewardSnapshot\n    mapping(address => RewardSnapshot) public rewardSnapshots;\n\n    function initialize() external initializer {\n        __Ownable_init(msg.sender);\n    }\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor() {\n        _disableInitializers();\n    }\n\n    function setAddresses(\n        address _activePoolAddress,\n        address _borrowerOperationsAddress,\n        address _collSurplusPoolAddress,\n        address _defaultPoolAddress,\n        address _gasPoolAddress,\n        address _interestRateManagerAddress,\n        address _musdTokenAddress,\n        address _pcvAddress,\n        address _priceFeedAddress,\n        address _sortedTrovesAddress,\n        address _stabilityPoolAddress\n    ) external override onlyOwner {\n        checkContract(_activePoolAddress);\n        checkContract(_borrowerOperationsAddress);\n        checkContract(_collSurplusPoolAddress);\n        checkContract(_defaultPoolAddress);\n        checkContract(_gasPoolAddress);\n        checkContract(_interestRateManagerAddress);\n        checkContract(_musdTokenAddress);\n        checkContract(_pcvAddress);\n        checkContract(_priceFeedAddress);\n        checkContract(_sortedTrovesAddress);\n        checkContract(_stabilityPoolAddress);\n\n        // slither-disable-start missing-zero-check\n        activePool = IActivePool(_activePoolAddress);\n        borrowerOperations = IBorrowerOperations(_borrowerOperationsAddress);\n        collSurplusPool = ICollSurplusPool(_collSurplusPoolAddress);\n        defaultPool = IDefaultPool(_defaultPoolAddress);\n        gasPoolAddress = _gasPoolAddress;\n        interestRateManager = IInterestRateManager(_interestRateManagerAddress);\n        musdToken = IMUSD(_musdTokenAddress);\n        pcv = IPCV(_pcvAddress);\n        priceFeed = IPriceFeed(_priceFeedAddress);\n        sortedTroves = ISortedTroves(_sortedTrovesAddress);\n        stabilityPool = IStabilityPool(_stabilityPoolAddress);\n        // slither-disable-end missing-zero-check\n\n        emit ActivePoolAddressChanged(_activePoolAddress);\n        emit BorrowerOperationsAddressChanged(_borrowerOperationsAddress);\n        emit CollSurplusPoolAddressChanged(_collSurplusPoolAddress);\n        emit DefaultPoolAddressChanged(_defaultPoolAddress);\n        emit GasPoolAddressChanged(_gasPoolAddress);\n        emit InterestRateManagerAddressChanged(_interestRateManagerAddress);\n        emit MUSDTokenAddressChanged(_musdTokenAddress);\n        emit PCVAddressChanged(_pcvAddress);\n        emit PriceFeedAddressChanged(_priceFeedAddress);\n        emit SortedTrovesAddressChanged(_sortedTrovesAddress);\n        emit StabilityPoolAddressChanged(_stabilityPoolAddress);\n\n        renounceOwnership();\n    }\n\n    function liquidate(address _borrower) external override {\n        _requireTroveIsActive(_borrower);\n\n        address[] memory borrowers = new address[](1);\n        borrowers[0] = _borrower;\n        batchLiquidateTroves(borrowers);\n    }\n\n    /* Send _amount mUSD to the system and redeem the corresponding amount of collateral from as many Troves as are needed to fill the redemption\n     * request.  Applies pending rewards to a Trove before reducing its debt and coll.\n     *\n     * Note that if _amount is very large, this function can run out of gas, specially if traversed troves are small. This can be easily avoided by\n     * splitting the total _amount in appropriate chunks and calling the function multiple times.\n     *\n     * Param `_maxIterations` can also be provided, so the loop through Troves is capped (if it’s zero, it will be ignored).This makes it easier to\n     * avoid OOG for the frontend, as only knowing approximately the average cost of an iteration is enough, without needing to know the “topology”\n     * of the trove list. It also avoids the need to set the cap in stone in the contract, nor doing gas calculations, as both gas price and opcode\n     * costs can vary.\n     *\n     * All Troves that are redeemed from -- with the likely exception of the last one -- will end up with no debt left, therefore they will be closed.\n     * If the last Trove does have some remaining debt, it has a finite ICR, and the reinsertion could be anywhere in the list, therefore it requires a hint.\n     * A frontend should use getRedemptionHints() to calculate what the ICR of this Trove will be after redemption, and pass a hint for its position\n     * in the sortedTroves list along with the ICR value that the hint was found for.\n     *\n     * If another transaction modifies the list between calling getRedemptionHints() and passing the hints to redeemCollateral(), it\n     * is very likely that the last (partially) redeemed Trove would end up with a different ICR than what the hint is for. In this case the\n     * redemption will stop after the last completely redeemed Trove and the sender will keep the remaining mUSD amount, which they can attempt\n     * to redeem later.\n     */\n    function redeemCollateral(\n        uint256 _amount,\n        address _firstRedemptionHint,\n        address _upperPartialRedemptionHint,\n        address _lowerPartialRedemptionHint,\n        uint256 _partialRedemptionHintNICR,\n        uint256 _maxIterations\n    ) external override {\n        updateSystemInterest();\n        ContractsCache memory contractsCache = ContractsCache(\n            activePool,\n            defaultPool,\n            musdToken,\n            pcv,\n            sortedTroves,\n            collSurplusPool,\n            gasPoolAddress\n        );\n        // slither-disable-start uninitialized-local\n        RedemptionTotals memory totals;\n        LocalVariables_redeemCollateral memory vars;\n        // slither-disable-end uninitialized-local\n\n        totals.price = priceFeed.fetchPrice();\n        _requireTCRoverMCR(totals.price);\n        _requireAmountGreaterThanZero(_amount);\n        _requireMUSDBalanceCoversRedemption(\n            contractsCache.musdToken,\n            msg.sender,\n            _amount\n        );\n\n        totals.totalDebtAtStart = getEntireSystemDebt();\n        totals.remainingMUSD = _amount;\n        address currentBorrower;\n\n        if (\n            _isValidFirstRedemptionHint(\n                contractsCache.sortedTroves,\n                _firstRedemptionHint,\n                totals.price\n            )\n        ) {\n            currentBorrower = _firstRedemptionHint;\n        } else {\n            currentBorrower = contractsCache.sortedTroves.getLast();\n            // Find the first trove with ICR >= MCR\n            while (\n                currentBorrower != address(0) &&\n                getCurrentICR(currentBorrower, totals.price) < MCR\n            ) {\n                // slither-disable-next-line calls-loop\n                currentBorrower = contractsCache.sortedTroves.getPrev(\n                    currentBorrower\n                );\n            }\n        }\n\n        // Loop through the Troves starting from the one with lowest collateral ratio until _amount of mUSD is exchanged for collateral\n        if (_maxIterations == 0) {\n            _maxIterations = type(uint256).max;\n        }\n\n        vars.minNetDebt = borrowerOperations.minNetDebt();\n        vars.interestRate = interestRateManager.interestRate();\n\n        while (\n            currentBorrower != address(0) &&\n            totals.remainingMUSD > 0 &&\n            _maxIterations > 0\n        ) {\n            _maxIterations--;\n            _updateTroveInterest(currentBorrower);\n\n            // Save the address of the Trove preceding the current one, before potentially modifying the list\n            // slither-disable-next-line calls-loop\n            address nextUserToCheck = contractsCache.sortedTroves.getPrev(\n                currentBorrower\n            );\n\n            // Skip troves with ICR < MCR\n            if (getCurrentICR(currentBorrower, totals.price) < MCR) {\n                currentBorrower = nextUserToCheck;\n                continue;\n            }\n\n            SingleRedemptionValues\n                memory singleRedemption = _redeemCollateralFromTrove(\n                    contractsCache,\n                    currentBorrower,\n                    totals.remainingMUSD,\n                    totals.price,\n                    _upperPartialRedemptionHint,\n                    _lowerPartialRedemptionHint,\n                    _partialRedemptionHintNICR,\n                    vars\n                );\n\n            if (singleRedemption.cancelledPartial) break; // Partial redemption was cancelled (out-of-date hint, or new net debt < minimum), therefore we could not redeem from the last Trove\n\n            totals.totalPrincipalToRedeem += singleRedemption.principal;\n            totals.totalInterestToRedeem += singleRedemption.interest;\n            totals.totalCollateralDrawn += singleRedemption.collateralLot;\n\n            totals.remainingMUSD -=\n                singleRedemption.principal +\n                singleRedemption.interest;\n\n            // Previous write to this value would hit `continue` statement\n            // slither-disable-next-line write-after-write\n            currentBorrower = nextUserToCheck;\n        }\n        require(\n            totals.totalCollateralDrawn > 0,\n            \"TroveManager: Unable to redeem any amount\"\n        );\n\n        // Calculate the collateral fee\n        totals.collateralFee = borrowerOperations.getRedemptionRate(\n            totals.totalCollateralDrawn\n        );\n\n        totals.collateralToSendToRedeemer =\n            totals.totalCollateralDrawn -\n            totals.collateralFee;\n\n        emit Redemption(\n            _amount,\n            totals.totalPrincipalToRedeem + totals.totalInterestToRedeem,\n            totals.totalCollateralDrawn,\n            totals.collateralFee\n        );\n\n        // Burn the total mUSD that is cancelled with debt, and send the redeemed collateral to msg.sender\n        contractsCache.musdToken.burn(\n            msg.sender,\n            totals.totalPrincipalToRedeem + totals.totalInterestToRedeem\n        );\n\n        // Send the collateral fee to the PCV contract\n        contractsCache.activePool.sendCollateral(\n            address(contractsCache.pcv),\n            totals.collateralFee\n        );\n\n        // Update Active Pool mUSD, and send collateral to account\n        contractsCache.activePool.decreaseDebt(\n            totals.totalPrincipalToRedeem,\n            totals.totalInterestToRedeem\n        );\n        contractsCache.activePool.sendCollateral(\n            msg.sender,\n            totals.collateralToSendToRedeemer\n        );\n    }\n\n    function updateStakeAndTotalStakes(\n        address _borrower\n    ) external override returns (uint) {\n        _requireCallerIsBorrowerOperations();\n        return _updateStakeAndTotalStakes(_borrower);\n    }\n\n    // Update borrower's snapshots of L_Collateral, L_Principal, and L_Interest\n    // to reflect the current values\n    function updateTroveRewardSnapshots(address _borrower) external override {\n        _requireCallerIsBorrowerOperations();\n        return _updateTroveRewardSnapshots(_borrower);\n    }\n\n    // Push the owner's address to the Trove owners list, and record the corresponding array index on the Trove struct\n    function addTroveOwnerToArray(\n        address _borrower\n    ) external override returns (uint256 index) {\n        _requireCallerIsBorrowerOperations();\n        return _addTroveOwnerToArray(_borrower);\n    }\n\n    function applyPendingRewards(address _borrower) external override {\n        _requireCallerIsBorrowerOperations();\n\n        return _applyPendingRewards(activePool, defaultPool, _borrower);\n    }\n\n    function closeTrove(address _borrower) external override {\n        _requireCallerIsBorrowerOperations();\n        return _closeTrove(_borrower, Status.closedByOwner);\n    }\n\n    function removeStake(address _borrower) external override {\n        _requireCallerIsBorrowerOperations();\n        return _removeStake(_borrower);\n    }\n\n    // --- Trove property setters, called by BorrowerOperations ---\n\n    function setTroveStatus(\n        address _borrower,\n        Status _status\n    ) external override {\n        _requireCallerIsBorrowerOperations();\n        Troves[_borrower].status = _status;\n    }\n\n    function increaseTroveColl(\n        address _borrower,\n        uint256 _collIncrease\n    ) external override returns (uint) {\n        _requireCallerIsBorrowerOperations();\n        uint256 newColl = Troves[_borrower].coll + _collIncrease;\n        Troves[_borrower].coll = newColl;\n        return newColl;\n    }\n\n    function decreaseTroveColl(\n        address _borrower,\n        uint256 _collDecrease\n    ) external override returns (uint) {\n        _requireCallerIsBorrowerOperations();\n        uint256 newColl = Troves[_borrower].coll - _collDecrease;\n        Troves[_borrower].coll = newColl;\n        return newColl;\n    }\n\n    function setTroveMaxBorrowingCapacity(\n        address _borrower,\n        uint256 _maxBorrowingCapacity\n    ) external override {\n        _requireCallerIsBorrowerOperations();\n        Troves[_borrower].maxBorrowingCapacity = _maxBorrowingCapacity;\n    }\n\n    function increaseTroveDebt(\n        address _borrower,\n        uint256 _debtIncrease\n    ) external override returns (uint) {\n        _requireCallerIsBorrowerOperations();\n        interestRateManager.addPrincipal(\n            _debtIncrease,\n            Troves[_borrower].interestRate\n        );\n        uint256 newDebt = Troves[_borrower].principal + _debtIncrease;\n        Troves[_borrower].principal = newDebt;\n        return newDebt;\n    }\n\n    function decreaseTroveDebt(\n        address _borrower,\n        uint256 _debtDecrease\n    ) external override returns (uint256, uint256) {\n        _requireCallerIsBorrowerOperations();\n        _updateTroveDebt(_borrower, _debtDecrease);\n        return (Troves[_borrower].principal, Troves[_borrower].interestOwed);\n    }\n\n    function setTroveInterestRate(address _borrower, uint16 _rate) external {\n        _requireCallerIsBorrowerOperations();\n        Troves[_borrower].interestRate = _rate;\n    }\n\n    function setTroveLastInterestUpdateTime(\n        address _borrower,\n        uint256 _timestamp\n    ) external {\n        _requireCallerIsBorrowerOperations();\n        Troves[_borrower].lastInterestUpdateTime = _timestamp;\n    }\n\n    function getTroveOwnersCount() external view override returns (uint) {\n        return TroveOwners.length;\n    }\n\n    function getTroveFromTroveOwnersArray(\n        uint256 _index\n    ) external view override returns (address) {\n        return TroveOwners[_index];\n    }\n\n    function getNominalICR(\n        address _borrower\n    ) external view override returns (uint) {\n        (uint256 pendingPrincipal, ) = getPendingDebt(_borrower);\n\n        uint256 collateral = Troves[_borrower].coll +\n            getPendingCollateral(_borrower);\n\n        uint256 principal = Troves[_borrower].principal + pendingPrincipal;\n\n        return LiquityMath._computeNominalCR(collateral, principal);\n    }\n\n    function getTroveStatus(\n        address _borrower\n    ) external view override returns (Status) {\n        return Troves[_borrower].status;\n    }\n\n    function getTroveStake(\n        address _borrower\n    ) external view override returns (uint) {\n        return Troves[_borrower].stake;\n    }\n\n    function getTroveDebt(\n        address _borrower\n    ) external view override returns (uint) {\n        return _getTotalDebt(_borrower);\n    }\n\n    function getTrovePrincipal(address _borrower) external view returns (uint) {\n        return Troves[_borrower].principal;\n    }\n\n    function getTroveInterestRate(\n        address _borrower\n    ) external view returns (uint16) {\n        return Troves[_borrower].interestRate;\n    }\n\n    function getTroveLastInterestUpdateTime(\n        address _borrower\n    ) external view returns (uint) {\n        return Troves[_borrower].lastInterestUpdateTime;\n    }\n\n    function getTroveInterestOwed(\n        address _borrower\n    ) external view returns (uint256) {\n        return Troves[_borrower].interestOwed;\n    }\n\n    function getTroveColl(\n        address _borrower\n    ) external view override returns (uint) {\n        return Troves[_borrower].coll;\n    }\n\n    function getTCR(uint256 _price) external view override returns (uint) {\n        return _getTCR(_price);\n    }\n\n    function getTroveMaxBorrowingCapacity(\n        address _borrower\n    ) external view returns (uint256) {\n        return Troves[_borrower].maxBorrowingCapacity;\n    }\n\n    function checkRecoveryMode(\n        uint256 _price\n    ) external view override returns (bool) {\n        return _checkRecoveryMode(_price);\n    }\n\n    function updateSystemAndTroveInterest(address _borrower) public {\n        updateSystemInterest();\n        _updateTroveInterest(_borrower);\n    }\n\n    function updateSystemInterest() public {\n        // slither-disable-next-line calls-loop\n        interestRateManager.updateSystemInterest();\n    }\n\n    /*\n     * Attempt to liquidate a custom list of troves provided by the caller.\n     */\n    function batchLiquidateTroves(\n        address[] memory _troveArray\n    ) public override {\n        require(\n            _troveArray.length != 0,\n            \"TroveManager: Calldata address array must not be empty\"\n        );\n\n        updateSystemInterest();\n\n        for (uint i = 0; i < _troveArray.length; i++) {\n            address borrower = _troveArray[i];\n\n            _updateTroveInterest(borrower);\n        }\n\n        IActivePool activePoolCached = activePool;\n        IDefaultPool defaultPoolCached = defaultPool;\n        IStabilityPool stabilityPoolCached = stabilityPool;\n\n        // slither-disable-next-line uninitialized-local\n        LocalVariables_OuterLiquidationFunction memory vars;\n        // slither-disable-next-line uninitialized-local\n        LiquidationTotals memory totals;\n\n        vars.price = priceFeed.fetchPrice();\n        vars.mUSDInStabPool = stabilityPoolCached.getTotalMUSDDeposits();\n\n        totals = _getTotalsFromBatchLiquidate(\n            activePoolCached,\n            defaultPoolCached,\n            vars.price,\n            vars.mUSDInStabPool,\n            _troveArray\n        );\n\n        require(\n            totals.totalPrincipalInSequence > 0,\n            \"TroveManager: nothing to liquidate\"\n        );\n\n        // Move liquidated collateral and debt to the appropriate pools\n        stabilityPoolCached.offset(\n            totals.totalPrincipalToOffset,\n            totals.totalInterestToOffset,\n            totals.totalCollToSendToSP\n        );\n        _redistributeDebtAndColl(\n            activePoolCached,\n            defaultPoolCached,\n            totals.totalPrincipalToRedistribute,\n            totals.totalInterestToRedistribute,\n            totals.totalCollToRedistribute\n        );\n        if (totals.totalCollSurplus > 0) {\n            activePoolCached.sendCollateral(\n                address(collSurplusPool),\n                totals.totalCollSurplus\n            );\n        }\n\n        // Update system snapshots\n        _updateSystemSnapshotsExcludeCollRemainder(\n            activePoolCached,\n            totals.totalCollGasCompensation\n        );\n\n        vars.liquidatedColl =\n            totals.totalCollInSequence -\n            totals.totalCollGasCompensation -\n            totals.totalCollSurplus;\n        emit Liquidation(\n            totals.totalPrincipalInSequence,\n            totals.totalInterestInSequence,\n            vars.liquidatedColl,\n            totals.totalCollGasCompensation,\n            totals.totalMUSDGasCompensation\n        );\n\n        // Send gas compensation to caller\n        _sendGasCompensation(\n            activePoolCached,\n            msg.sender,\n            totals.totalMUSDGasCompensation,\n            totals.totalCollGasCompensation\n        );\n    }\n\n    function getCurrentICR(\n        address _borrower,\n        uint256 _price\n    ) public view override returns (uint) {\n        (\n            uint256 currentCollateral,\n            uint256 currentDebt\n        ) = _getCurrentTroveAmounts(_borrower);\n        uint256 ICR = LiquityMath._computeCR(\n            currentCollateral,\n            currentDebt,\n            _price\n        );\n        return ICR;\n    }\n\n    function hasPendingRewards(\n        address _borrower\n    ) public view override returns (bool) {\n        /*\n         * A Trove has pending rewards if its snapshot is less than the current rewards per-unit-staked sum:\n         * this indicates that rewards have occured since the snapshot was made, and the user therefore has\n         * pending rewards\n         */\n        if (Troves[_borrower].status != Status.active) {\n            return false;\n        }\n\n        return (rewardSnapshots[_borrower].collateral < L_Collateral);\n    }\n\n    function getEntireDebtAndColl(\n        address _borrower\n    )\n        public\n        view\n        override\n        returns (\n            uint256 coll,\n            uint256 principal,\n            uint256 interest,\n            uint256 pendingCollateral,\n            uint256 pendingPrincipal,\n            uint256 pendingInterest\n        )\n    {\n        Trove storage trove = Troves[_borrower];\n        coll = trove.coll;\n        principal = trove.principal;\n        interest = trove.interestOwed;\n\n        // solhint-disable not-rely-on-time\n        interest += InterestRateMath.calculateInterestOwed(\n            principal,\n            trove.interestRate,\n            trove.lastInterestUpdateTime,\n            block.timestamp\n        );\n        // solhint-enable not-rely-on-time\n\n        pendingCollateral = getPendingCollateral(_borrower);\n        (pendingPrincipal, pendingInterest) = getPendingDebt(_borrower);\n\n        coll += pendingCollateral;\n        principal += pendingPrincipal;\n        interest += pendingInterest;\n    }\n\n    function getPendingCollateral(\n        address _borrower\n    ) public view override returns (uint) {\n        uint256 snapshotCollateral = rewardSnapshots[_borrower].collateral;\n        uint256 rewardPerUnitStaked = L_Collateral - snapshotCollateral;\n\n        if (\n            rewardPerUnitStaked == 0 ||\n            Troves[_borrower].status != Status.active\n        ) {\n            return 0;\n        }\n\n        uint256 stake = Troves[_borrower].stake;\n\n        return (stake * rewardPerUnitStaked) / DECIMAL_PRECISION;\n    }\n\n    function getPendingDebt(\n        address _borrower\n    )\n        public\n        view\n        override\n        returns (uint256 pendingPrincipal, uint256 pendingInterest)\n    {\n        uint256 principalSnapshot = rewardSnapshots[_borrower].principal;\n        uint256 principalPerUnitStaked = L_Principal - principalSnapshot;\n\n        uint256 interestSnapshot = rewardSnapshots[_borrower].interest;\n        uint256 interestPerUnitStaked = L_Interest - interestSnapshot;\n\n        if (\n            principalPerUnitStaked == 0 ||\n            Troves[_borrower].status != Status.active\n        ) {\n            return (0, 0);\n        }\n\n        uint256 stake = Troves[_borrower].stake;\n\n        pendingPrincipal = (stake * principalPerUnitStaked) / DECIMAL_PRECISION;\n        pendingInterest = (stake * interestPerUnitStaked) / DECIMAL_PRECISION;\n    }\n\n    /**\n     * Updates the debt on the given trove by first paying down interest owed, then the principal.\n     * Note that this does not actually calculate interest owed, it just pays down the debt by the given amount.\n     * Calculation of the interest owed (for system and trove) should be performed before calling this function.\n     */\n    function _updateTroveDebt(address _borrower, uint256 _payment) internal {\n        Trove storage trove = Troves[_borrower];\n\n        // slither-disable-start calls-loop\n        (\n            uint256 principalAdjustment,\n            uint256 interestAdjustment\n        ) = interestRateManager.updateTroveDebt(\n                trove.interestOwed,\n                _payment,\n                trove.interestRate\n            );\n        // slither-disable-end calls-loop\n        trove.principal -= principalAdjustment;\n        trove.interestOwed -= interestAdjustment;\n    }\n\n    function _updateTroveInterest(address _borrower) internal {\n        Trove storage trove = Troves[_borrower];\n\n        // solhint-disable not-rely-on-time\n        trove.interestOwed += InterestRateMath.calculateInterestOwed(\n            trove.principal,\n            trove.interestRate,\n            trove.lastInterestUpdateTime,\n            block.timestamp\n        );\n        trove.lastInterestUpdateTime = block.timestamp;\n        // solhint-enable not-rely-on-time\n\n        _applyPendingRewards(activePool, defaultPool, _borrower);\n    }\n\n    // Add the borrowers's coll and debt rewards earned from redistributions, to their Trove\n    function _applyPendingRewards(\n        IActivePool _activePool,\n        IDefaultPool _defaultPool,\n        address _borrower\n    ) internal {\n        Trove storage trove = Troves[_borrower];\n        if (hasPendingRewards(_borrower)) {\n            // Compute pending rewards\n            uint256 pendingCollateral = getPendingCollateral(_borrower);\n            (\n                uint256 pendingPrincipal,\n                uint256 pendingInterest\n            ) = getPendingDebt(_borrower);\n\n            // Apply pending rewards to trove's state\n            trove.coll += pendingCollateral;\n            trove.principal += pendingPrincipal;\n            trove.interestOwed += pendingInterest;\n\n            // slither-disable-start calls-loop\n            // Apply pending rewards to system interest rate data\n            interestRateManager.addPrincipal(\n                pendingPrincipal,\n                trove.interestRate\n            );\n            // slither-disable-end calls-loop\n\n            _updateTroveRewardSnapshots(_borrower);\n\n            // Transfer from DefaultPool to ActivePool\n            _movePendingTroveRewardsToActivePool(\n                _activePool,\n                _defaultPool,\n                pendingCollateral,\n                pendingPrincipal,\n                pendingInterest\n            );\n\n            emit TroveUpdated(\n                _borrower,\n                trove.principal,\n                trove.interestOwed,\n                trove.coll,\n                trove.stake,\n                uint8(TroveManagerOperation.applyPendingRewards)\n            );\n        }\n    }\n\n    function _sendGasCompensation(\n        IActivePool _activePool,\n        address _liquidator,\n        uint256 _amount,\n        uint256 _collateral\n    ) internal {\n        if (_amount > 0) {\n            IGasPool(gasPoolAddress).sendMUSD(_liquidator, _amount);\n        }\n\n        if (_collateral > 0) {\n            _activePool.sendCollateral(_liquidator, _collateral);\n        }\n    }\n\n    /*\n     * Updates snapshots of system total stakes and total collateral, excluding a given collateral remainder from the calculation.\n     * Used in a liquidation sequence.\n     *\n     * The calculation excludes a portion of collateral that is in the ActivePool:\n     *\n     * the total collateral gas compensation from the liquidation sequence\n     *\n     * The collateral as compensation must be excluded as it is always sent out at the very end of the liquidation sequence.\n     */\n    function _updateSystemSnapshotsExcludeCollRemainder(\n        IActivePool _activePool,\n        uint256 _collRemainder\n    ) internal {\n        totalStakesSnapshot = totalStakes;\n\n        uint256 activeColl = _activePool.getCollateralBalance();\n        uint256 liquidatedColl = defaultPool.getCollateralBalance();\n        totalCollateralSnapshot = activeColl - _collRemainder + liquidatedColl;\n\n        emit SystemSnapshotsUpdated(\n            totalStakesSnapshot,\n            totalCollateralSnapshot\n        );\n    }\n\n    function _redistributeDebtAndColl(\n        IActivePool _activePool,\n        IDefaultPool _defaultPool,\n        uint256 _principal,\n        uint256 _interest,\n        uint256 _coll\n    ) internal {\n        if (_principal == 0 && _interest == 0) {\n            return;\n        }\n\n        /*\n         * Add distributed collateral, principal, and interest\n         * rewards-per-unit-staked to the running totals. Division uses a\n         * \"feedback\" error correction, to keep the cumulative error low in\n         * the running totals L_Collateral, L_Principal, and L_Interest:\n         *\n         * 1) Form numerators which compensate for the floor division errors\n         *    that occurred the last time this function was called.\n         * 2) Calculate \"per-unit-staked\" ratios.\n         * 3) Multiply each ratio back by its denominator, to reveal the current\n         *    floor division error.\n         * 4) Store these errors for use in the next correction when this\n         *    function is called.\n         * 5) Note: static analysis tools complain about this \"division before\n         *    multiplication\", however, it is intended.\n         */\n        uint256 collateralNumerator = _coll *\n            DECIMAL_PRECISION +\n            lastCollateralError_Redistribution;\n        uint256 principalNumerator = _principal *\n            DECIMAL_PRECISION +\n            lastPrincipalError_Redistribution;\n        uint256 interestNumerator = _interest *\n            DECIMAL_PRECISION +\n            lastInterestError_Redistribution;\n\n        // Get the per-unit-staked terms\n        // slither-disable-start divide-before-multiply\n        uint256 pendingCollateralPerUnitStaked = collateralNumerator /\n            totalStakes;\n        uint256 pendingPrincipalPerUnitStaked = principalNumerator /\n            totalStakes;\n        uint256 pendingInterestPerUnitStaked = interestNumerator / totalStakes;\n\n        lastCollateralError_Redistribution =\n            collateralNumerator -\n            (pendingCollateralPerUnitStaked * totalStakes);\n        lastPrincipalError_Redistribution =\n            principalNumerator -\n            (pendingPrincipalPerUnitStaked * totalStakes);\n        lastInterestError_Redistribution =\n            interestNumerator -\n            (pendingInterestPerUnitStaked * totalStakes);\n        // slither-disable-end divide-before-multiply\n\n        // Add per-unit-staked terms to the running totals\n        L_Collateral += pendingCollateralPerUnitStaked;\n        L_Principal += pendingPrincipalPerUnitStaked;\n        L_Interest += pendingInterestPerUnitStaked;\n\n        emit LTermsUpdated(L_Collateral, L_Principal, L_Interest);\n\n        // Transfer coll and debt from ActivePool to DefaultPool\n        _activePool.decreaseDebt(_principal, _interest);\n        _defaultPool.increaseDebt(_principal, _interest);\n        _activePool.sendCollateral(address(_defaultPool), _coll);\n    }\n\n    // Liquidate one trove\n    function _liquidate(\n        IActivePool _activePool,\n        IDefaultPool _defaultPool,\n        address _borrower,\n        uint256 _MUSDInStabPool\n    ) internal returns (LiquidationValues memory singleLiquidation) {\n        // slither-disable-next-line uninitialized-local\n        LocalVariables_InnerSingleLiquidateFunction memory vars;\n        if (TroveOwners.length <= 1) {\n            return singleLiquidation;\n        } // don't liquidate if last trove\n\n        (\n            singleLiquidation.entireTroveColl,\n            singleLiquidation.entireTrovePrincipal,\n            singleLiquidation.entireTroveInterest,\n            vars.pendingColl,\n            vars.pendingPrincipal,\n            vars.pendingInterest\n        ) = getEntireDebtAndColl(_borrower);\n\n        _removeStake(_borrower);\n        _movePendingTroveRewardsToActivePool(\n            _activePool,\n            _defaultPool,\n            vars.pendingColl,\n            vars.pendingPrincipal,\n            vars.pendingInterest\n        );\n\n        singleLiquidation.collGasCompensation = _getCollGasCompensation(\n            singleLiquidation.entireTroveColl\n        );\n        singleLiquidation.mUSDGasCompensation = MUSD_GAS_COMPENSATION;\n        uint256 collToLiquidate = singleLiquidation.entireTroveColl -\n            singleLiquidation.collGasCompensation;\n\n        (\n            singleLiquidation.principalToOffset,\n            singleLiquidation.interestToOffset,\n            singleLiquidation.collToSendToSP,\n            singleLiquidation.principalToRedistribute,\n            singleLiquidation.interestToRedistribute,\n            singleLiquidation.collToRedistribute\n        ) = _getOffsetAndRedistributionVals(\n            singleLiquidation.entireTrovePrincipal,\n            singleLiquidation.entireTroveInterest,\n            collToLiquidate,\n            _MUSDInStabPool\n        );\n\n        _closeTrove(_borrower, Status.closedByLiquidation);\n        emit TroveLiquidated(\n            _borrower,\n            singleLiquidation.entireTrovePrincipal,\n            singleLiquidation.entireTroveColl,\n            uint8(TroveManagerOperation.liquidate)\n        );\n        emit TroveUpdated(\n            _borrower,\n            0,\n            0,\n            0,\n            0,\n            uint8(TroveManagerOperation.liquidate)\n        );\n        return singleLiquidation;\n    }\n\n    // Remove borrower's stake from the totalStakes sum, and set their stake to 0\n    function _removeStake(address _borrower) internal {\n        uint256 stake = Troves[_borrower].stake;\n        // slither-disable-next-line costly-loop\n        totalStakes -= stake;\n        Troves[_borrower].stake = 0;\n    }\n\n    function _getTotalsFromBatchLiquidate(\n        IActivePool _activePool,\n        IDefaultPool _defaultPool,\n        uint256 _price,\n        uint256 _MUSDInStabPool,\n        address[] memory _troveArray\n    ) internal returns (LiquidationTotals memory totals) {\n        // slither-disable-next-line uninitialized-local\n        LocalVariables_LiquidationSequence memory vars;\n        // slither-disable-next-line uninitialized-local\n        LiquidationValues memory singleLiquidation;\n\n        vars.remainingMUSDInStabPool = _MUSDInStabPool;\n\n        uint troveArrayLength = _troveArray.length;\n        for (vars.i = 0; vars.i < troveArrayLength; vars.i++) {\n            vars.user = _troveArray[vars.i];\n            vars.ICR = getCurrentICR(vars.user, _price);\n\n            if (vars.ICR < MCR) {\n                singleLiquidation = _liquidate(\n                    _activePool,\n                    _defaultPool,\n                    vars.user,\n                    vars.remainingMUSDInStabPool\n                );\n                vars.remainingMUSDInStabPool -=\n                    singleLiquidation.principalToOffset +\n                    singleLiquidation.interestToOffset;\n\n                // Add liquidation values to their respective running totals\n                totals = _addLiquidationValuesToTotals(\n                    totals,\n                    singleLiquidation\n                );\n            }\n        }\n    }\n\n    /*\n     * Called when a full redemption occurs, and closes the trove.\n     * The redeemer swaps (debt - liquidation reserve) mUSD for (debt - liquidation reserve) worth of collateral, so the mUSD liquidation reserve left corresponds to the remaining debt.\n     * In order to close the trove, the mUSD liquidation reserve is burned, and the corresponding debt is removed from the active pool.\n     * The debt recorded on the trove's struct is zero'd elswhere, in _closeTrove.\n     * Any surplus collateral left in the trove, is sent to the Coll surplus pool, and can be later claimed by the borrower.\n     */\n    function _redeemCloseTrove(\n        ContractsCache memory _contractsCache,\n        address _borrower,\n        uint256 _amount,\n        uint256 _collateral\n    ) internal {\n        // slither-disable-next-line calls-loop\n        interestRateManager.removePrincipal(\n            _amount,\n            Troves[_borrower].interestRate\n        );\n        Troves[_borrower].principal -= _amount;\n        // slither-disable-next-line calls-loop\n        _contractsCache.musdToken.burn(gasPoolAddress, _amount);\n        // Update Active Pool mUSD, and send collateral to account\n        // slither-disable-next-line calls-loop\n        _contractsCache.activePool.decreaseDebt(_amount, 0);\n\n        // send collateral from Active Pool to CollSurplus Pool\n        // slither-disable-next-line calls-loop\n        _contractsCache.collSurplusPool.accountSurplus(_borrower, _collateral);\n        // slither-disable-next-line calls-loop\n        _contractsCache.activePool.sendCollateral(\n            address(_contractsCache.collSurplusPool),\n            _collateral\n        );\n    }\n\n    // Redeem as much collateral as possible from _borrower's Trove in exchange for mUSD up to _maxMUSDamount\n    function _redeemCollateralFromTrove(\n        ContractsCache memory _contractsCache,\n        address _borrower,\n        uint256 _maxMUSDamount,\n        uint256 _price,\n        address _upperPartialRedemptionHint,\n        address _lowerPartialRedemptionHint,\n        uint256 _partialRedemptionHintNICR,\n        LocalVariables_redeemCollateral memory redeemCollateralVars\n    ) internal returns (SingleRedemptionValues memory singleRedemption) {\n        // slither-disable-next-line uninitialized-local\n        LocalVariables_redeemCollateralFromTrove memory vars;\n        // Determine the remaining amount (lot) to be redeemed, capped by the entire debt of the Trove minus the liquidation reserve\n        vars.mUSDLot = LiquityMath._min(\n            _maxMUSDamount,\n            _getTotalDebt(_borrower) - MUSD_GAS_COMPENSATION\n        );\n\n        // Get the collateralLot of equivalent value in USD\n        singleRedemption.collateralLot =\n            (vars.mUSDLot * DECIMAL_PRECISION) /\n            _price;\n\n        // Decrease the debt and collateral of the current Trove according to the mUSD lot and corresponding collateral to send\n        vars.newDebt = _getTotalDebt(_borrower) - vars.mUSDLot;\n        vars.newColl = Troves[_borrower].coll - singleRedemption.collateralLot;\n        vars.newPrincipal = Troves[_borrower].principal;\n\n        // solhint-disable not-rely-on-time\n        vars.interestPayment =\n            Troves[_borrower].interestOwed +\n            InterestRateMath.calculateInterestOwed(\n                Troves[_borrower].principal,\n                Troves[_borrower].interestRate,\n                Troves[_borrower].lastInterestUpdateTime,\n                block.timestamp\n            );\n        // solhint-enable not-rely-on-time\n\n        if (vars.mUSDLot > vars.interestPayment) {\n            vars.newPrincipal -= vars.mUSDLot - vars.interestPayment;\n            singleRedemption.interest = vars.interestPayment;\n            singleRedemption.principal = vars.mUSDLot - vars.interestPayment;\n        } else {\n            singleRedemption.interest = vars.mUSDLot;\n        }\n\n        if (vars.newDebt == MUSD_GAS_COMPENSATION) {\n            // No debt left in the Trove (except for the liquidation reserve), therefore the trove gets closed\n            _removeStake(_borrower);\n            _redeemCloseTrove(\n                _contractsCache,\n                _borrower,\n                MUSD_GAS_COMPENSATION,\n                vars.newColl\n            );\n            _closeTrove(_borrower, Status.closedByRedemption);\n            emit TroveUpdated(\n                _borrower,\n                0,\n                0,\n                0,\n                0,\n                uint8(TroveManagerOperation.redeemCollateral)\n            );\n        } else {\n            // calculate 10 minutes worth of interest to account for delay between the hint call and now\n            // solhint-disable not-rely-on-time\n\n            vars.upperBoundNICR = LiquityMath._computeNominalCR(\n                vars.newColl,\n                vars.newPrincipal -\n                    InterestRateMath.calculateInterestOwed(\n                        Troves[_borrower].principal,\n                        redeemCollateralVars.interestRate,\n                        block.timestamp - 600,\n                        block.timestamp\n                    )\n            );\n            // solhint-enable not-rely-on-time\n            vars.newNICR = LiquityMath._computeNominalCR(\n                vars.newColl,\n                vars.newPrincipal\n            );\n\n            /*\n             * If the provided hint is out of date, we bail since trying to reinsert without a good hint will almost\n             * certainly result in running out of gas.\n             *\n             * If the resultant net debt of the partial is less than the minimum, net debt we bail.\n             */\n            // slither-disable-start calls-loop\n            if (\n                _partialRedemptionHintNICR < vars.newNICR ||\n                _partialRedemptionHintNICR > vars.upperBoundNICR ||\n                _getNetDebt(vars.newDebt) < redeemCollateralVars.minNetDebt\n            ) {\n                singleRedemption.cancelledPartial = true;\n                return singleRedemption;\n            }\n            // slither-disable-end calls-loop\n\n            // slither-disable-next-line calls-loop\n            _contractsCache.sortedTroves.reInsert(\n                _borrower,\n                vars.newNICR,\n                _upperPartialRedemptionHint,\n                _lowerPartialRedemptionHint\n            );\n\n            _updateTroveDebt(_borrower, vars.mUSDLot);\n            Troves[_borrower].coll = vars.newColl;\n            _updateStakeAndTotalStakes(_borrower);\n\n            emit TroveUpdated(\n                _borrower,\n                Troves[_borrower].principal,\n                Troves[_borrower].interestOwed,\n                vars.newColl,\n                Troves[_borrower].stake,\n                uint8(TroveManagerOperation.redeemCollateral)\n            );\n        }\n\n        return singleRedemption;\n    }\n\n    // Update borrower's stake based on their latest collateral value\n    function _updateStakeAndTotalStakes(\n        address _borrower\n    ) internal returns (uint) {\n        uint256 newStake = _computeNewStake(Troves[_borrower].coll);\n        uint256 oldStake = Troves[_borrower].stake;\n        Troves[_borrower].stake = newStake;\n\n        // slither-disable-next-line costly-loop\n        totalStakes = totalStakes - oldStake + newStake;\n        emit TotalStakesUpdated(totalStakes);\n\n        return newStake;\n    }\n\n    function _updateTroveRewardSnapshots(address _borrower) internal {\n        rewardSnapshots[_borrower].collateral = L_Collateral;\n        rewardSnapshots[_borrower].principal = L_Principal;\n        rewardSnapshots[_borrower].interest = L_Interest;\n        emit TroveSnapshotsUpdated(L_Collateral, L_Principal, L_Interest);\n    }\n\n    function _addTroveOwnerToArray(\n        address _borrower\n    ) internal returns (uint128 index) {\n        /* Max array size is 2**128 - 1, i.e. ~3e30 troves. No risk of overflow, since troves have minimum mUSD\n        debt of liquidation reserve plus minNetDebt. 3e30 mUSD dwarfs the value of all wealth in the world ( which is < 1e15 USD). */\n\n        // Push the Troveowner to the array\n        TroveOwners.push(_borrower);\n\n        // Record the index of the new Troveowner on their Trove struct\n        index = uint128(TroveOwners.length - 1);\n        Troves[_borrower].arrayIndex = index;\n\n        return index;\n    }\n\n    // Move a Trove's pending debt and collateral rewards from distributions, from the Default Pool to the Active Pool\n    function _movePendingTroveRewardsToActivePool(\n        IActivePool _activePool,\n        IDefaultPool _defaultPool,\n        uint256 _collateral,\n        uint256 _principal,\n        uint256 _interest\n    ) internal {\n        // slither-disable-next-line calls-loop\n        _defaultPool.decreaseDebt(_principal, _interest);\n        // slither-disable-next-line calls-loop\n        _activePool.increaseDebt(_principal, _interest);\n        // slither-disable-next-line calls-loop\n        _defaultPool.sendCollateralToActivePool(_collateral);\n    }\n\n    function _closeTrove(address _borrower, Status closedStatus) internal {\n        assert(\n            closedStatus != Status.nonExistent && closedStatus != Status.active\n        );\n\n        uint256 TroveOwnersArrayLength = TroveOwners.length;\n        // slither-disable-next-line calls-loop\n        if (musdToken.mintList(address(borrowerOperations))) {\n            _requireMoreThanOneTroveInSystem(TroveOwnersArrayLength);\n        }\n\n        // slither-disable-start calls-loop\n        interestRateManager.removePrincipal(\n            Troves[_borrower].principal,\n            Troves[_borrower].interestRate\n        );\n        // slither-disable-end calls-loop\n\n        Troves[_borrower].status = closedStatus;\n        Troves[_borrower].coll = 0;\n        Troves[_borrower].principal = 0;\n        Troves[_borrower].interestOwed = 0;\n\n        rewardSnapshots[_borrower].collateral = 0;\n        rewardSnapshots[_borrower].principal = 0;\n        rewardSnapshots[_borrower].interest = 0;\n\n        _removeTroveOwner(_borrower, TroveOwnersArrayLength);\n        // slither-disable-next-line calls-loop\n        sortedTroves.remove(_borrower);\n    }\n\n    /*\n     * Remove a Trove owner from the TroveOwners array, not preserving array order. Removing owner 'B' does the following:\n     * [A B C D E] => [A E C D], and updates E's Trove struct to point to its new array index.\n     */\n    function _removeTroveOwner(\n        address _borrower,\n        uint256 TroveOwnersArrayLength\n    ) internal {\n        Status troveStatus = Troves[_borrower].status;\n        // It’s set in caller function `_closeTrove`\n        assert(\n            troveStatus != Status.nonExistent && troveStatus != Status.active\n        );\n\n        uint128 index = Troves[_borrower].arrayIndex;\n        uint256 length = TroveOwnersArrayLength;\n        uint256 idxLast = length - 1;\n\n        assert(index <= idxLast);\n\n        address addressToMove = TroveOwners[idxLast];\n\n        TroveOwners[index] = addressToMove;\n        Troves[addressToMove].arrayIndex = index;\n        emit TroveIndexUpdated(addressToMove, index);\n\n        // slither-disable-next-line costly-loop\n        TroveOwners.pop();\n    }\n\n    function _isValidFirstRedemptionHint(\n        ISortedTroves _sortedTroves,\n        address _firstRedemptionHint,\n        uint256 _price\n    ) internal view returns (bool) {\n        if (\n            _firstRedemptionHint == address(0) ||\n            !_sortedTroves.contains(_firstRedemptionHint) ||\n            getCurrentICR(_firstRedemptionHint, _price) < MCR\n        ) {\n            return false;\n        }\n\n        address nextTrove = _sortedTroves.getNext(_firstRedemptionHint);\n        return\n            nextTrove == address(0) || getCurrentICR(nextTrove, _price) < MCR;\n    }\n\n    function _requireTCRoverMCR(uint256 _price) internal view {\n        require(\n            _getTCR(_price) >= MCR,\n            \"TroveManager: Cannot redeem when TCR < MCR\"\n        );\n    }\n\n    function _requireMUSDBalanceCoversRedemption(\n        IMUSD _musd,\n        address _redeemer,\n        uint256 _amount\n    ) internal view {\n        require(\n            _musd.balanceOf(_redeemer) >= _amount,\n            \"TroveManager: Requested redemption amount must be <= user's mUSD token balance\"\n        );\n    }\n\n    function _requireMoreThanOneTroveInSystem(\n        uint256 TroveOwnersArrayLength\n    ) internal view {\n        // slither-disable-next-line calls-loop\n        require(\n            TroveOwnersArrayLength > 1 && sortedTroves.getSize() > 1,\n            \"TroveManager: Only one trove in the system\"\n        );\n    }\n\n    function _getCurrentTroveAmounts(\n        address _borrower\n    ) internal view returns (uint currentCollateral, uint currentDebt) {\n        uint256 pendingCollateral = getPendingCollateral(_borrower);\n        (uint256 pendingPrincipal, uint256 pendingInterest) = getPendingDebt(\n            _borrower\n        );\n\n        currentCollateral = Troves[_borrower].coll + pendingCollateral;\n        currentDebt =\n            _getTotalDebt(_borrower) +\n            pendingPrincipal +\n            pendingInterest;\n    }\n\n    function _getTotalDebt(address _borrower) internal view returns (uint256) {\n        // slither-disable-start calls-loop\n        // solhint-disable not-rely-on-time\n        return\n            Troves[_borrower].principal +\n            Troves[_borrower].interestOwed +\n            InterestRateMath.calculateInterestOwed(\n                Troves[_borrower].principal,\n                Troves[_borrower].interestRate,\n                Troves[_borrower].lastInterestUpdateTime,\n                block.timestamp\n            );\n        // solhint-enable not-rely-on-time\n        // slither-disable-end calls-loop\n    }\n\n    // Calculate a new stake based on the snapshots of the totalStakes and totalCollateral taken at the last liquidation\n    function _computeNewStake(uint256 _coll) internal view returns (uint) {\n        uint256 stake;\n        if (totalCollateralSnapshot == 0) {\n            stake = _coll;\n        } else {\n            /*\n             * The following assert() holds true because:\n             * - The system always contains >= 1 trove\n             * - When we close or liquidate a trove, we redistribute the pending rewards, so if all troves were closed/liquidated,\n             * rewards would’ve been emptied and totalCollateralSnapshot would be zero too.\n             */\n            assert(totalStakesSnapshot > 0);\n            stake = (_coll * totalStakesSnapshot) / totalCollateralSnapshot;\n        }\n        return stake;\n    }\n\n    function _requireCallerIsBorrowerOperations() internal view {\n        require(\n            msg.sender == address(borrowerOperations),\n            \"TroveManager: Caller is not the BorrowerOperations contract\"\n        );\n    }\n\n    function _requireTroveIsActive(address _borrower) internal view {\n        require(\n            Troves[_borrower].status == Status.active,\n            \"TroveManager: Trove does not exist or is closed\"\n        );\n    }\n\n    /* In a full liquidation, returns the values for a trove's coll and debt to be offset, and coll and debt to be\n     * redistributed to active troves.\n     */\n    function _getOffsetAndRedistributionVals(\n        uint256 _principal,\n        uint256 _interest,\n        uint256 _coll,\n        uint256 _MUSDInStabPool\n    )\n        internal\n        pure\n        returns (\n            uint256 principalToOffset,\n            uint256 interestToOffset,\n            uint256 collToSendToSP,\n            uint256 principalToRedistribute,\n            uint256 interestToRedistribute,\n            uint256 collToRedistribute\n        )\n    {\n        if (_MUSDInStabPool > 0) {\n            /*\n             * Offset as much debt & collateral as possible against the Stability Pool, and redistribute the remainder\n             * between all active troves.\n             *\n             *  If the trove's debt is larger than the deposited mUSD in the Stability Pool:\n             *\n             *  - Offset an amount of the trove's debt equal to the mUSD in the Stability Pool\n             *  - Send a fraction of the trove's collateral to the Stability Pool, equal to the fraction of its offset debt\n             *\n             */\n            interestToOffset = LiquityMath._min(_interest, _MUSDInStabPool);\n            principalToOffset = LiquityMath._min(\n                _principal,\n                _MUSDInStabPool - interestToOffset\n            );\n            uint256 debtToOffset = principalToOffset + interestToOffset;\n            collToSendToSP = (_coll * debtToOffset) / (_principal + _interest);\n            interestToRedistribute = _interest - interestToOffset;\n            principalToRedistribute = _principal - principalToOffset;\n            collToRedistribute = _coll - collToSendToSP;\n        } else {\n            principalToOffset = 0;\n            interestToOffset = 0;\n            collToSendToSP = 0;\n            principalToRedistribute = _principal;\n            interestToRedistribute = _interest;\n            collToRedistribute = _coll;\n        }\n    }\n\n    function _requireAmountGreaterThanZero(uint256 _amount) internal pure {\n        require(_amount > 0, \"TroveManager: Amount must be greater than zero\");\n    }\n\n    function _addLiquidationValuesToTotals(\n        LiquidationTotals memory oldTotals,\n        LiquidationValues memory singleLiquidation\n    ) internal pure returns (LiquidationTotals memory newTotals) {\n        // Tally all the values with their respective running totals\n        newTotals.totalCollGasCompensation =\n            oldTotals.totalCollGasCompensation +\n            singleLiquidation.collGasCompensation;\n\n        newTotals.totalMUSDGasCompensation =\n            oldTotals.totalMUSDGasCompensation +\n            singleLiquidation.mUSDGasCompensation;\n\n        newTotals.totalPrincipalInSequence =\n            oldTotals.totalPrincipalInSequence +\n            singleLiquidation.entireTrovePrincipal;\n\n        newTotals.totalInterestInSequence =\n            oldTotals.totalInterestInSequence +\n            singleLiquidation.entireTroveInterest;\n\n        newTotals.totalCollInSequence =\n            oldTotals.totalCollInSequence +\n            singleLiquidation.entireTroveColl;\n\n        newTotals.totalPrincipalToOffset =\n            oldTotals.totalPrincipalToOffset +\n            singleLiquidation.principalToOffset;\n\n        newTotals.totalInterestToOffset =\n            oldTotals.totalInterestToOffset +\n            singleLiquidation.interestToOffset;\n\n        newTotals.totalCollToSendToSP =\n            oldTotals.totalCollToSendToSP +\n            singleLiquidation.collToSendToSP;\n\n        newTotals.totalPrincipalToRedistribute =\n            oldTotals.totalPrincipalToRedistribute +\n            singleLiquidation.principalToRedistribute;\n\n        newTotals.totalInterestToRedistribute =\n            oldTotals.totalInterestToRedistribute +\n            singleLiquidation.interestToRedistribute;\n\n        newTotals.totalCollToRedistribute =\n            oldTotals.totalCollToRedistribute +\n            singleLiquidation.collToRedistribute;\n\n        newTotals.totalCollSurplus =\n            oldTotals.totalCollSurplus +\n            singleLiquidation.collSurplus;\n\n        return newTotals;\n    }\n}\n// slither-disable-end reentrancy-benign\n// slither-disable-end reentrancy-events\n// slither-disable-end reentrancy-no-eth\n"
    }
  },
  "settings": {
    "evmVersion": "london",
    "optimizer": {
      "enabled": true,
      "runs": 100
    },
    "outputSelection": {
      "*": {
        "*": [
          "abi",
          "evm.bytecode",
          "evm.deployedBytecode",
          "evm.methodIdentifiers",
          "metadata",
          "storageLayout",
          "devdoc",
          "userdoc",
          "evm.gasEstimates"
        ],
        "": [
          "ast"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    }
  }
}