{
  "language": "Solidity",
  "sources": {
    "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\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 Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 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 functions marked with `initializer` can be nested in the context of a\n     * constructor.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\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 255 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\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        require(_initializing, \"Initializable: contract is not initializing\");\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        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized != type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint8) {\n        return _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 _initializing;\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n     * function (like regular Solidity function calls).\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     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\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     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) 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            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../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 * By default, the owner account will be the one that deploys the contract. This\n * can 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    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\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        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\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        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\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/IERC3156FlashBorrower.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC3156FlashBorrower.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC3156 FlashBorrower, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * _Available since v4.1._\n */\ninterface IERC3156FlashBorrower {\n    /**\n     * @dev Receive a flash loan.\n     * @param initiator The initiator of the loan.\n     * @param token The loan currency.\n     * @param amount The amount of tokens lent.\n     * @param fee The additional amount of tokens to repay.\n     * @param data Arbitrary data structure, intended to contain user-defined parameters.\n     * @return The keccak256 hash of \"ERC3156FlashBorrower.onFlashLoan\"\n     */\n    function onFlashLoan(\n        address initiator,\n        address token,\n        uint256 amount,\n        uint256 fee,\n        bytes calldata data\n    ) external returns (bytes32);\n}\n"
    },
    "@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC3156FlashLender.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC3156FlashBorrower.sol\";\n\n/**\n * @dev Interface of the ERC3156 FlashLender, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * _Available since v4.1._\n */\ninterface IERC3156FlashLender {\n    /**\n     * @dev The amount of currency available to be lended.\n     * @param token The loan currency.\n     * @return The amount of `token` that can be borrowed.\n     */\n    function maxFlashLoan(address token) external view returns (uint256);\n\n    /**\n     * @dev The fee to be charged for a given loan.\n     * @param token The loan currency.\n     * @param amount The amount of tokens lent.\n     * @return The amount of `token` to be charged for the loan, on top of the returned principal.\n     */\n    function flashFee(address token, uint256 amount) external view returns (uint256);\n\n    /**\n     * @dev Initiate a flash loan.\n     * @param receiver The receiver of the tokens in the loan, and the receiver of the callback.\n     * @param token The loan currency.\n     * @param amount The amount of tokens lent.\n     * @param data Arbitrary data structure, intended to contain user-defined parameters.\n     */\n    function flashLoan(\n        IERC3156FlashBorrower receiver,\n        address token,\n        uint256 amount,\n        bytes calldata data\n    ) external returns (bool);\n}\n"
    },
    "@openzeppelin/contracts/interfaces/IERC5267.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.0;\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/Clones.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/Clones.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\n * deploying minimal proxy contracts, also known as \"clones\".\n *\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\n *\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\n * deterministic method.\n *\n * _Available since v3.4._\n */\nlibrary Clones {\n    /**\n     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\n     *\n     * This function uses the create opcode, which should never revert.\n     */\n    function clone(address implementation) internal returns (address instance) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes\n            // of the `implementation` address with the bytecode before the address.\n            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))\n            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.\n            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))\n            instance := create(0, 0x09, 0x37)\n        }\n        require(instance != address(0), \"ERC1167: create failed\");\n    }\n\n    /**\n     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\n     *\n     * This function uses the create2 opcode and a `salt` to deterministically deploy\n     * the clone. Using the same `implementation` and `salt` multiple time will revert, since\n     * the clones cannot be deployed twice at the same address.\n     */\n    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes\n            // of the `implementation` address with the bytecode before the address.\n            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))\n            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.\n            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))\n            instance := create2(0, 0x09, 0x37, salt)\n        }\n        require(instance != address(0), \"ERC1167: create2 failed\");\n    }\n\n    /**\n     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n     */\n    function predictDeterministicAddress(\n        address implementation,\n        bytes32 salt,\n        address deployer\n    ) internal pure returns (address predicted) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let ptr := mload(0x40)\n            mstore(add(ptr, 0x38), deployer)\n            mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)\n            mstore(add(ptr, 0x14), implementation)\n            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)\n            mstore(add(ptr, 0x58), salt)\n            mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))\n            predicted := keccak256(add(ptr, 0x43), 0x55)\n        }\n    }\n\n    /**\n     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n     */\n    function predictDeterministicAddress(\n        address implementation,\n        bytes32 salt\n    ) internal view returns (address predicted) {\n        return predictDeterministicAddress(implementation, salt, address(this));\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/ERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.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 * For a generic mechanism see {ERC20PresetMinterPauser}.\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 ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n    mapping(address => uint256) private _balances;\n\n    mapping(address => mapping(address => 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 override 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 override 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 override returns (uint8) {\n        return 18;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view virtual override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) public view virtual override 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 `amount`.\n     */\n    function transfer(address to, uint256 amount) public virtual override returns (bool) {\n        address owner = _msgSender();\n        _transfer(owner, to, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender) public view virtual override returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * NOTE: If `amount` 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 amount) public virtual override returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Emits an {Approval} event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of {ERC20}.\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 `amount`.\n     * - the caller must have allowance for ``from``'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {\n        address spender = _msgSender();\n        _spendAllowance(from, spender, amount);\n        _transfer(from, to, amount);\n        return true;\n    }\n\n    /**\n     * @dev Atomically increases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, allowance(owner, spender) + addedValue);\n        return true;\n    }\n\n    /**\n     * @dev Atomically decreases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `spender` must have allowance for the caller of at least\n     * `subtractedValue`.\n     */\n    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n        address owner = _msgSender();\n        uint256 currentAllowance = allowance(owner, spender);\n        require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n        unchecked {\n            _approve(owner, spender, currentAllowance - subtractedValue);\n        }\n\n        return true;\n    }\n\n    /**\n     * @dev Moves `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     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `from` must have a balance of at least `amount`.\n     */\n    function _transfer(address from, address to, uint256 amount) internal virtual {\n        require(from != address(0), \"ERC20: transfer from the zero address\");\n        require(to != address(0), \"ERC20: transfer to the zero address\");\n\n        _beforeTokenTransfer(from, to, amount);\n\n        uint256 fromBalance = _balances[from];\n        require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n        unchecked {\n            _balances[from] = fromBalance - amount;\n            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n            // decrementing then incrementing.\n            _balances[to] += amount;\n        }\n\n        emit Transfer(from, to, amount);\n\n        _afterTokenTransfer(from, to, amount);\n    }\n\n    /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function _mint(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: mint to the zero address\");\n\n        _beforeTokenTransfer(address(0), account, amount);\n\n        _totalSupply += amount;\n        unchecked {\n            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n            _balances[account] += amount;\n        }\n        emit Transfer(address(0), account, amount);\n\n        _afterTokenTransfer(address(0), account, amount);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: burn from the zero address\");\n\n        _beforeTokenTransfer(account, address(0), amount);\n\n        uint256 accountBalance = _balances[account];\n        require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n        unchecked {\n            _balances[account] = accountBalance - amount;\n            // Overflow not possible: amount <= accountBalance <= totalSupply.\n            _totalSupply -= amount;\n        }\n\n        emit Transfer(account, address(0), amount);\n\n        _afterTokenTransfer(account, address(0), amount);\n    }\n\n    /**\n     * @dev Sets `amount` 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    function _approve(address owner, address spender, uint256 amount) internal virtual {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = amount;\n        emit Approval(owner, spender, amount);\n    }\n\n    /**\n     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n     *\n     * Does not update the allowance amount in case of infinite allowance.\n     * Revert if not enough allowance is available.\n     *\n     * Might emit an {Approval} event.\n     */\n    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {\n        uint256 currentAllowance = allowance(owner, spender);\n        if (currentAllowance != type(uint256).max) {\n            require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n            unchecked {\n                _approve(owner, spender, currentAllowance - amount);\n            }\n        }\n    }\n\n    /**\n     * @dev Hook that is called before any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * will be transferred to `to`.\n     * - when `from` is zero, `amount` tokens will be minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * has been transferred to `to`.\n     * - when `from` is zero, `amount` tokens have been minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @dev Extension of {ERC20} that allows token holders to destroy both their own\n * tokens and those that they have an allowance for, in a way that can be\n * recognized off-chain (via event analysis).\n */\nabstract contract ERC20Burnable is Context, ERC20 {\n    /**\n     * @dev Destroys `amount` tokens from the caller.\n     *\n     * See {ERC20-_burn}.\n     */\n    function burn(uint256 amount) public virtual {\n        _burn(_msgSender(), amount);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n     * allowance.\n     *\n     * See {ERC20-_burn} and {ERC20-allowance}.\n     *\n     * Requirements:\n     *\n     * - the caller must have allowance for ``accounts``'s tokens of at least\n     * `amount`.\n     */\n    function burnFrom(address account, uint256 amount) public virtual {\n        _spendAllowance(account, _msgSender(), amount);\n        _burn(account, amount);\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/ERC20FlashMint.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../../interfaces/IERC3156FlashBorrower.sol\";\nimport \"../../../interfaces/IERC3156FlashLender.sol\";\nimport \"../ERC20.sol\";\n\n/**\n * @dev Implementation of the ERC3156 Flash loans extension, as defined in\n * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].\n *\n * Adds the {flashLoan} method, which provides flash loan support at the token\n * level. By default there is no fee, but this can be changed by overriding {flashFee}.\n *\n * _Available since v4.1._\n */\nabstract contract ERC20FlashMint is ERC20, IERC3156FlashLender {\n    bytes32 private constant _RETURN_VALUE = keccak256(\"ERC3156FlashBorrower.onFlashLoan\");\n\n    /**\n     * @dev Returns the maximum amount of tokens available for loan.\n     * @param token The address of the token that is requested.\n     * @return The amount of token that can be loaned.\n     */\n    function maxFlashLoan(address token) public view virtual override returns (uint256) {\n        return token == address(this) ? type(uint256).max - ERC20.totalSupply() : 0;\n    }\n\n    /**\n     * @dev Returns the fee applied when doing flash loans. This function calls\n     * the {_flashFee} function which returns the fee applied when doing flash\n     * loans.\n     * @param token The token to be flash loaned.\n     * @param amount The amount of tokens to be loaned.\n     * @return The fees applied to the corresponding flash loan.\n     */\n    function flashFee(address token, uint256 amount) public view virtual override returns (uint256) {\n        require(token == address(this), \"ERC20FlashMint: wrong token\");\n        return _flashFee(token, amount);\n    }\n\n    /**\n     * @dev Returns the fee applied when doing flash loans. By default this\n     * implementation has 0 fees. This function can be overloaded to make\n     * the flash loan mechanism deflationary.\n     * @param token The token to be flash loaned.\n     * @param amount The amount of tokens to be loaned.\n     * @return The fees applied to the corresponding flash loan.\n     */\n    function _flashFee(address token, uint256 amount) internal view virtual returns (uint256) {\n        // silence warning about unused variable without the addition of bytecode.\n        token;\n        amount;\n        return 0;\n    }\n\n    /**\n     * @dev Returns the receiver address of the flash fee. By default this\n     * implementation returns the address(0) which means the fee amount will be burnt.\n     * This function can be overloaded to change the fee receiver.\n     * @return The address for which the flash fee will be sent to.\n     */\n    function _flashFeeReceiver() internal view virtual returns (address) {\n        return address(0);\n    }\n\n    /**\n     * @dev Performs a flash loan. New tokens are minted and sent to the\n     * `receiver`, who is required to implement the {IERC3156FlashBorrower}\n     * interface. By the end of the flash loan, the receiver is expected to own\n     * amount + fee tokens and have them approved back to the token contract itself so\n     * they can be burned.\n     * @param receiver The receiver of the flash loan. Should implement the\n     * {IERC3156FlashBorrower-onFlashLoan} interface.\n     * @param token The token to be flash loaned. Only `address(this)` is\n     * supported.\n     * @param amount The amount of tokens to be loaned.\n     * @param data An arbitrary datafield that is passed to the receiver.\n     * @return `true` if the flash loan was successful.\n     */\n    // This function can reenter, but it doesn't pose a risk because it always preserves the property that the amount\n    // minted at the beginning is always recovered and burned at the end, or else the entire function will revert.\n    // slither-disable-next-line reentrancy-no-eth\n    function flashLoan(\n        IERC3156FlashBorrower receiver,\n        address token,\n        uint256 amount,\n        bytes calldata data\n    ) public virtual override returns (bool) {\n        require(amount <= maxFlashLoan(token), \"ERC20FlashMint: amount exceeds maxFlashLoan\");\n        uint256 fee = flashFee(token, amount);\n        _mint(address(receiver), amount);\n        require(\n            receiver.onFlashLoan(msg.sender, token, amount, fee, data) == _RETURN_VALUE,\n            \"ERC20FlashMint: invalid return value\"\n        );\n        address flashFeeReceiver = _flashFeeReceiver();\n        _spendAllowance(address(receiver), address(this), amount + fee);\n        if (fee == 0 || flashFeeReceiver == address(0)) {\n            _burn(address(receiver), amount + fee);\n        } else {\n            _burn(address(receiver), amount);\n            _transfer(address(receiver), flashFeeReceiver, fee);\n        }\n        return true;\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Permit.sol\";\nimport \"../ERC20.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\nimport \"../../../utils/cryptography/EIP712.sol\";\nimport \"../../../utils/Counters.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 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 * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n    using Counters for Counters.Counter;\n\n    mapping(address => Counters.Counter) private _nonces;\n\n    // solhint-disable-next-line var-name-mixedcase\n    bytes32 private constant _PERMIT_TYPEHASH =\n        keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n    /**\n     * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n     * However, to ensure consistency with the upgradeable transpiler, we will continue\n     * to reserve a slot.\n     * @custom:oz-renamed-from _PERMIT_TYPEHASH\n     */\n    // solhint-disable-next-line var-name-mixedcase\n    bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\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 ERC20 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 override {\n        require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\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        require(signer == owner, \"ERC20Permit: invalid signature\");\n\n        _approve(owner, spender, value);\n    }\n\n    /**\n     * @inheritdoc IERC20Permit\n     */\n    function nonces(address owner) public view virtual override returns (uint256) {\n        return _nonces[owner].current();\n    }\n\n    /**\n     * @inheritdoc IERC20Permit\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n        return _domainSeparatorV4();\n    }\n\n    /**\n     * @dev \"Consume a nonce\": return the current value and increment.\n     *\n     * _Available since v4.1._\n     */\n    function _useNonce(address owner) internal virtual returns (uint256 current) {\n        Counters.Counter storage nonce = _nonces[owner];\n        current = nonce.current();\n        nonce.increment();\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\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 v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 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 v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` 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 amount) external returns (bool);\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(IERC20 token, address spender, uint256 value) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n     * Revert on invalid signature.\n     */\n    function safePermit(\n        IERC20Permit token,\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal {\n        uint256 nonceBefore = token.nonces(owner);\n        token.permit(owner, spender, value, deadline, v, r, s);\n        uint256 nonceAfter = token.nonces(owner);\n        require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return\n            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n     * function (like regular Solidity function calls).\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     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\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     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) 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            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\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/Counters.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n    struct Counter {\n        // This variable should never be directly accessed by users of the library: interactions must be restricted to\n        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n        // this feature: see https://github.com/ethereum/solidity/issues/4637\n        uint256 _value; // default: 0\n    }\n\n    function current(Counter storage counter) internal view returns (uint256) {\n        return counter._value;\n    }\n\n    function increment(Counter storage counter) internal {\n        unchecked {\n            counter._value += 1;\n        }\n    }\n\n    function decrement(Counter storage counter) internal {\n        uint256 value = counter._value;\n        require(value > 0, \"Counter: decrement overflow\");\n        unchecked {\n            counter._value = value - 1;\n        }\n    }\n\n    function reset(Counter storage counter) internal {\n        counter._value = 0;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\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        InvalidSignatureV // Deprecated in v4.8\n    }\n\n    function _throwError(RecoverError error) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert(\"ECDSA: invalid signature\");\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert(\"ECDSA: invalid signature length\");\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert(\"ECDSA: invalid signature 's' value\");\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature` or error string. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode 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 {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     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\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            /// @solidity memory-safe-assembly\n            assembly {\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);\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 opcode 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 {toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, signature);\n        _throwError(error);\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[EIP-2098 short signatures]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {\n        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n        uint8 v = uint8((uint256(vs) >> 255) + 27);\n        return tryRecover(hash, v, r, s);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     *\n     * _Available since v4.2._\n     */\n    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n        _throwError(error);\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     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\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);\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);\n        }\n\n        return (signer, RecoverError.NoError);\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) = tryRecover(hash, v, r, s);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {\n        // 32 is the length in bytes of hash,\n        // enforced by the type signature above\n        /// @solidity memory-safe-assembly\n        assembly {\n            mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\")\n            mstore(0x1c, hash)\n            message := keccak256(0x00, 0x3c)\n        }\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from `s`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Typed Data, created from a\n     * `domainSeparator` and a `structHash`. This produces hash corresponding\n     * to the one signed with the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n     * JSON-RPC method as part of EIP-712.\n     *\n     * See {recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let ptr := mload(0x40)\n            mstore(ptr, \"\\x19\\x01\")\n            mstore(add(ptr, 0x02), domainSeparator)\n            mstore(add(ptr, 0x22), structHash)\n            data := keccak256(ptr, 0x42)\n        }\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Data with intended validator, created from a\n     * `validator` and `data` according to the version 0 of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19\\x00\", validator, data));\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/cryptography/EIP712.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.8;\n\nimport \"./ECDSA.sol\";\nimport \"../ShortStrings.sol\";\nimport \"../../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 specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts 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 * _Available since v3.4._\n *\n * @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\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 ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n    }\n\n    /**\n     * @dev See {EIP-5267}.\n     *\n     * _Available since v4.9._\n     */\n    function eip712Domain()\n        public\n        view\n        virtual\n        override\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            _name.toStringWithFallback(_nameFallback),\n            _version.toStringWithFallback(_versionFallback),\n            block.chainid,\n            address(this),\n            bytes32(0),\n            new uint256[](0)\n        );\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/math/Math.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\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 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 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 up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by 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^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // 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                prod0 := mul(x, y)\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^256. Also prevents denominator == 0.\n            require(denominator > prod1, \"Math: mulDiv overflow\");\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. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\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^256 / 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^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\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 works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\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^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, 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     * @notice 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        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\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 + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\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        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\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 + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/math/SignedMath.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return 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 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            // must be unchecked in order to support `n = type(int256).min`\n            return uint256(n >= 0 ? n : -n);\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/ShortStrings.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol)\n\npragma solidity ^0.8.8;\n\nimport \"./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        /// @solidity memory-safe-assembly\n        assembly {\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 {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 v4.9.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.0;\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 ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\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(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\n * _Available since v4.9 for `string`, `bytes`._\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 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        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` with member `value` located at `slot`.\n     */\n    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\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        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n     */\n    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\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        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Strings.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\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            /// @solidity memory-safe-assembly\n            assembly {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                /// @solidity memory-safe-assembly\n                assembly {\n                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\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 toString(int256 value) internal pure returns (string memory) {\n        return string(abi.encodePacked(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        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] = _SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\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 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 Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/structs/EnumerableMap.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableMap.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableMap.js.\n\npragma solidity ^0.8.0;\n\nimport \"./EnumerableSet.sol\";\n\n/**\n * @dev Library for managing an enumerable variant of Solidity's\n * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]\n * type.\n *\n * Maps have the following properties:\n *\n * - Entries are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Entries are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n *     // Add the library methods\n *     using EnumerableMap for EnumerableMap.UintToAddressMap;\n *\n *     // Declare a set state variable\n *     EnumerableMap.UintToAddressMap private myMap;\n * }\n * ```\n *\n * The following map types are supported:\n *\n * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0\n * - `address -> uint256` (`AddressToUintMap`) since v4.6.0\n * - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0\n * - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0\n * - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableMap.\n * ====\n */\nlibrary EnumerableMap {\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Map type with\n    // bytes32 keys and values.\n    // The Map implementation uses private functions, and user-facing\n    // implementations (such as Uint256ToAddressMap) are just wrappers around\n    // the underlying Map.\n    // This means that we can only create new EnumerableMaps for types that fit\n    // in bytes32.\n\n    struct Bytes32ToBytes32Map {\n        // Storage of keys\n        EnumerableSet.Bytes32Set _keys;\n        mapping(bytes32 => bytes32) _values;\n    }\n\n    /**\n     * @dev Adds a key-value pair to a map, or updates the value for an existing\n     * key. O(1).\n     *\n     * Returns true if the key was added to the map, that is if it was not\n     * already present.\n     */\n    function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) {\n        map._values[key] = value;\n        return map._keys.add(key);\n    }\n\n    /**\n     * @dev Removes a key-value pair from a map. O(1).\n     *\n     * Returns true if the key was removed from the map, that is if it was present.\n     */\n    function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) {\n        delete map._values[key];\n        return map._keys.remove(key);\n    }\n\n    /**\n     * @dev Returns true if the key is in the map. O(1).\n     */\n    function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) {\n        return map._keys.contains(key);\n    }\n\n    /**\n     * @dev Returns the number of key-value pairs in the map. O(1).\n     */\n    function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) {\n        return map._keys.length();\n    }\n\n    /**\n     * @dev Returns the key-value pair stored at position `index` in the map. O(1).\n     *\n     * Note that there are no guarantees on the ordering of entries inside the\n     * array, and it may change when more entries are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32, bytes32) {\n        bytes32 key = map._keys.at(index);\n        return (key, map._values[key]);\n    }\n\n    /**\n     * @dev Tries to returns the value associated with `key`. O(1).\n     * Does not revert if `key` is not in the map.\n     */\n    function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) {\n        bytes32 value = map._values[key];\n        if (value == bytes32(0)) {\n            return (contains(map, key), bytes32(0));\n        } else {\n            return (true, value);\n        }\n    }\n\n    /**\n     * @dev Returns the value associated with `key`. O(1).\n     *\n     * Requirements:\n     *\n     * - `key` must be in the map.\n     */\n    function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {\n        bytes32 value = map._values[key];\n        require(value != 0 || contains(map, key), \"EnumerableMap: nonexistent key\");\n        return value;\n    }\n\n    /**\n     * @dev Same as {get}, with a custom error message when `key` is not in the map.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryGet}.\n     */\n    function get(\n        Bytes32ToBytes32Map storage map,\n        bytes32 key,\n        string memory errorMessage\n    ) internal view returns (bytes32) {\n        bytes32 value = map._values[key];\n        require(value != 0 || contains(map, key), errorMessage);\n        return value;\n    }\n\n    /**\n     * @dev Return the an array containing all the keys\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function keys(Bytes32ToBytes32Map storage map) internal view returns (bytes32[] memory) {\n        return map._keys.values();\n    }\n\n    // UintToUintMap\n\n    struct UintToUintMap {\n        Bytes32ToBytes32Map _inner;\n    }\n\n    /**\n     * @dev Adds a key-value pair to a map, or updates the value for an existing\n     * key. O(1).\n     *\n     * Returns true if the key was added to the map, that is if it was not\n     * already present.\n     */\n    function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) {\n        return set(map._inner, bytes32(key), bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a map. O(1).\n     *\n     * Returns true if the key was removed from the map, that is if it was present.\n     */\n    function remove(UintToUintMap storage map, uint256 key) internal returns (bool) {\n        return remove(map._inner, bytes32(key));\n    }\n\n    /**\n     * @dev Returns true if the key is in the map. O(1).\n     */\n    function contains(UintToUintMap storage map, uint256 key) internal view returns (bool) {\n        return contains(map._inner, bytes32(key));\n    }\n\n    /**\n     * @dev Returns the number of elements in the map. O(1).\n     */\n    function length(UintToUintMap storage map) internal view returns (uint256) {\n        return length(map._inner);\n    }\n\n    /**\n     * @dev Returns the element stored at position `index` in the map. O(1).\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintToUintMap storage map, uint256 index) internal view returns (uint256, uint256) {\n        (bytes32 key, bytes32 value) = at(map._inner, index);\n        return (uint256(key), uint256(value));\n    }\n\n    /**\n     * @dev Tries to returns the value associated with `key`. O(1).\n     * Does not revert if `key` is not in the map.\n     */\n    function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) {\n        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));\n        return (success, uint256(value));\n    }\n\n    /**\n     * @dev Returns the value associated with `key`. O(1).\n     *\n     * Requirements:\n     *\n     * - `key` must be in the map.\n     */\n    function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) {\n        return uint256(get(map._inner, bytes32(key)));\n    }\n\n    /**\n     * @dev Same as {get}, with a custom error message when `key` is not in the map.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryGet}.\n     */\n    function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) {\n        return uint256(get(map._inner, bytes32(key), errorMessage));\n    }\n\n    /**\n     * @dev Return the an array containing all the keys\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function keys(UintToUintMap storage map) internal view returns (uint256[] memory) {\n        bytes32[] memory store = keys(map._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // UintToAddressMap\n\n    struct UintToAddressMap {\n        Bytes32ToBytes32Map _inner;\n    }\n\n    /**\n     * @dev Adds a key-value pair to a map, or updates the value for an existing\n     * key. O(1).\n     *\n     * Returns true if the key was added to the map, that is if it was not\n     * already present.\n     */\n    function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {\n        return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a map. O(1).\n     *\n     * Returns true if the key was removed from the map, that is if it was present.\n     */\n    function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {\n        return remove(map._inner, bytes32(key));\n    }\n\n    /**\n     * @dev Returns true if the key is in the map. O(1).\n     */\n    function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {\n        return contains(map._inner, bytes32(key));\n    }\n\n    /**\n     * @dev Returns the number of elements in the map. O(1).\n     */\n    function length(UintToAddressMap storage map) internal view returns (uint256) {\n        return length(map._inner);\n    }\n\n    /**\n     * @dev Returns the element stored at position `index` in the map. O(1).\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {\n        (bytes32 key, bytes32 value) = at(map._inner, index);\n        return (uint256(key), address(uint160(uint256(value))));\n    }\n\n    /**\n     * @dev Tries to returns the value associated with `key`. O(1).\n     * Does not revert if `key` is not in the map.\n     */\n    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {\n        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));\n        return (success, address(uint160(uint256(value))));\n    }\n\n    /**\n     * @dev Returns the value associated with `key`. O(1).\n     *\n     * Requirements:\n     *\n     * - `key` must be in the map.\n     */\n    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {\n        return address(uint160(uint256(get(map._inner, bytes32(key)))));\n    }\n\n    /**\n     * @dev Same as {get}, with a custom error message when `key` is not in the map.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryGet}.\n     */\n    function get(\n        UintToAddressMap storage map,\n        uint256 key,\n        string memory errorMessage\n    ) internal view returns (address) {\n        return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage))));\n    }\n\n    /**\n     * @dev Return the an array containing all the keys\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function keys(UintToAddressMap storage map) internal view returns (uint256[] memory) {\n        bytes32[] memory store = keys(map._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // AddressToUintMap\n\n    struct AddressToUintMap {\n        Bytes32ToBytes32Map _inner;\n    }\n\n    /**\n     * @dev Adds a key-value pair to a map, or updates the value for an existing\n     * key. O(1).\n     *\n     * Returns true if the key was added to the map, that is if it was not\n     * already present.\n     */\n    function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) {\n        return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a map. O(1).\n     *\n     * Returns true if the key was removed from the map, that is if it was present.\n     */\n    function remove(AddressToUintMap storage map, address key) internal returns (bool) {\n        return remove(map._inner, bytes32(uint256(uint160(key))));\n    }\n\n    /**\n     * @dev Returns true if the key is in the map. O(1).\n     */\n    function contains(AddressToUintMap storage map, address key) internal view returns (bool) {\n        return contains(map._inner, bytes32(uint256(uint160(key))));\n    }\n\n    /**\n     * @dev Returns the number of elements in the map. O(1).\n     */\n    function length(AddressToUintMap storage map) internal view returns (uint256) {\n        return length(map._inner);\n    }\n\n    /**\n     * @dev Returns the element stored at position `index` in the map. O(1).\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) {\n        (bytes32 key, bytes32 value) = at(map._inner, index);\n        return (address(uint160(uint256(key))), uint256(value));\n    }\n\n    /**\n     * @dev Tries to returns the value associated with `key`. O(1).\n     * Does not revert if `key` is not in the map.\n     */\n    function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {\n        (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key))));\n        return (success, uint256(value));\n    }\n\n    /**\n     * @dev Returns the value associated with `key`. O(1).\n     *\n     * Requirements:\n     *\n     * - `key` must be in the map.\n     */\n    function get(AddressToUintMap storage map, address key) internal view returns (uint256) {\n        return uint256(get(map._inner, bytes32(uint256(uint160(key)))));\n    }\n\n    /**\n     * @dev Same as {get}, with a custom error message when `key` is not in the map.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryGet}.\n     */\n    function get(\n        AddressToUintMap storage map,\n        address key,\n        string memory errorMessage\n    ) internal view returns (uint256) {\n        return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage));\n    }\n\n    /**\n     * @dev Return the an array containing all the keys\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function keys(AddressToUintMap storage map) internal view returns (address[] memory) {\n        bytes32[] memory store = keys(map._inner);\n        address[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // Bytes32ToUintMap\n\n    struct Bytes32ToUintMap {\n        Bytes32ToBytes32Map _inner;\n    }\n\n    /**\n     * @dev Adds a key-value pair to a map, or updates the value for an existing\n     * key. O(1).\n     *\n     * Returns true if the key was added to the map, that is if it was not\n     * already present.\n     */\n    function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) {\n        return set(map._inner, key, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a map. O(1).\n     *\n     * Returns true if the key was removed from the map, that is if it was present.\n     */\n    function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) {\n        return remove(map._inner, key);\n    }\n\n    /**\n     * @dev Returns true if the key is in the map. O(1).\n     */\n    function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) {\n        return contains(map._inner, key);\n    }\n\n    /**\n     * @dev Returns the number of elements in the map. O(1).\n     */\n    function length(Bytes32ToUintMap storage map) internal view returns (uint256) {\n        return length(map._inner);\n    }\n\n    /**\n     * @dev Returns the element stored at position `index` in the map. O(1).\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) {\n        (bytes32 key, bytes32 value) = at(map._inner, index);\n        return (key, uint256(value));\n    }\n\n    /**\n     * @dev Tries to returns the value associated with `key`. O(1).\n     * Does not revert if `key` is not in the map.\n     */\n    function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) {\n        (bool success, bytes32 value) = tryGet(map._inner, key);\n        return (success, uint256(value));\n    }\n\n    /**\n     * @dev Returns the value associated with `key`. O(1).\n     *\n     * Requirements:\n     *\n     * - `key` must be in the map.\n     */\n    function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) {\n        return uint256(get(map._inner, key));\n    }\n\n    /**\n     * @dev Same as {get}, with a custom error message when `key` is not in the map.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryGet}.\n     */\n    function get(\n        Bytes32ToUintMap storage map,\n        bytes32 key,\n        string memory errorMessage\n    ) internal view returns (uint256) {\n        return uint256(get(map._inner, key, errorMessage));\n    }\n\n    /**\n     * @dev Return the an array containing all the keys\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function keys(Bytes32ToUintMap storage map) internal view returns (bytes32[] memory) {\n        bytes32[] memory store = keys(map._inner);\n        bytes32[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n *     // Add the library methods\n *     using EnumerableSet for EnumerableSet.AddressSet;\n *\n *     // Declare a set state variable\n *     EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Set type with\n    // bytes32 values.\n    // The Set implementation uses private functions, and user-facing\n    // implementations (such as AddressSet) are just wrappers around the\n    // underlying Set.\n    // This means that we can only create new EnumerableSets for types that fit\n    // in bytes32.\n\n    struct Set {\n        // Storage of set values\n        bytes32[] _values;\n        // Position of the value in the `values` array, plus 1 because index 0\n        // means a value is not in the set.\n        mapping(bytes32 => uint256) _indexes;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            // The value is stored at length-1, but we add 1 to all indexes\n            // and use 0 as a sentinel value\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        // We read and store the value's index to prevent multiple reads from the same storage slot\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) {\n            // Equivalent to contains(set, value)\n            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n            // the array, and then remove the last element (sometimes called as 'swap and pop').\n            // This modifies the order of the array, as noted in {at}.\n\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            if (lastIndex != toDeleteIndex) {\n                bytes32 lastValue = set._values[lastIndex];\n\n                // Move the last value to the index where the value to delete is\n                set._values[toDeleteIndex] = lastValue;\n                // Update the index for the moved value\n                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n            }\n\n            // Delete the slot where the moved value was stored\n            set._values.pop();\n\n            // Delete the index for the deleted slot\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        return set._values[index];\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function _values(Set storage set) private view returns (bytes32[] memory) {\n        return set._values;\n    }\n\n    // Bytes32Set\n\n    struct Bytes32Set {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _add(set._inner, value);\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(Bytes32Set storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n        return _at(set._inner, index);\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        bytes32[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(AddressSet storage set) internal view returns (address[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        address[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // UintSet\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(UintSet storage set, uint256 value) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(UintSet storage set) internal view returns (uint256[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"
    },
    "contracts/core/BorrowerOperations.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../interfaces/ITroveManager.sol\";\nimport \"../interfaces/IBorrowerOperations.sol\";\nimport \"../interfaces/IPropelUSD.sol\";\nimport \"../dependencies/PropelBase.sol\";\nimport \"../dependencies/PropelMath.sol\";\nimport \"../dependencies/BlastWrapper.sol\";\nimport \"../dependencies/DelegatedOps.sol\";\nimport \"../dependencies/console.sol\";\n\n/**\n    @title Propel Borrower Operations\n    @notice Based on Liquity's `BorrowerOperations`\n            https://github.com/liquity/dev/blob/main/packages/contracts/contracts/BorrowerOperations.sol\n\n            Propel's implementation is modified to support multiple collaterals. There is a 1:n\n            relationship between `BorrowerOperations` and each `TroveManager` / `SortedTroves` pair.\n */\ncontract BorrowerOperations is IBorrowerOperations, PropelBase, BlastWrapper, DelegatedOps {\n\tusing SafeERC20 for IERC20;\n\n\tIPropelUSD public immutable PropelUSD;\n\taddress public immutable factory;\n\tuint256 public minNetDebt;\n\n\tmapping(ITroveManager => TroveManagerData) public troveManagersData;\n\tITroveManager[] internal _troveManagers;\n\n\tstruct TroveManagerData {\n\t\tIERC20 collateralToken;\n\t\tuint16 index;\n\t}\n\n\tstruct LocalVariables_adjustTrove {\n\t\tuint256 price;\n\t\tuint256 totalPricedCollateral;\n\t\tuint256 totalDebt;\n\t\tuint256 collChange;\n\t\tuint256 netDebtChange;\n\t\tbool isCollIncrease;\n\t\tuint256 debt;\n\t\tuint256 coll;\n\t\tuint256 newDebt;\n\t\tuint256 newColl;\n\t\tuint256 stake;\n\t\tuint256 debtChange;\n\t\taddress account;\n\t\tuint256 MCR;\n\t}\n\n\tstruct LocalVariables_openTrove {\n\t\tuint256 price;\n\t\tuint256 totalPricedCollateral;\n\t\tuint256 totalDebt;\n\t\tuint256 netDebt;\n\t\tuint256 compositeDebt;\n\t\tuint256 ICR;\n\t\tuint256 NICR;\n\t\tuint256 stake;\n\t\tuint256 arrayIndex;\n\t}\n\n\tconstructor(IPropelCore _PropelCore, address _PropelUSDAddress, address _factory, uint256 _minNetDebt, uint256 _gasCompensation) BlastWrapper(_PropelCore) PropelBase(_gasCompensation) {\n\t\tPropelUSD = IPropelUSD(_PropelUSDAddress);\n\t\tfactory = _factory;\n\t\t_setMinNetDebt(_minNetDebt);\n\t}\n\n\tfunction setMinNetDebt(uint256 _minNetDebt) public onlyOwner {\n\t\t_setMinNetDebt(_minNetDebt);\n\t}\n\n\tfunction _setMinNetDebt(uint256 _minNetDebt) internal {\n\t\trequire(_minNetDebt > 0, \"invalid min net debt\");\n\t\tminNetDebt = _minNetDebt;\n\t}\n\n\tfunction configureCollateral(ITroveManager troveManager, IERC20 collateralToken) external {\n\t\trequire(msg.sender == factory, \"!factory\");\n\t\ttroveManagersData[troveManager] = TroveManagerData(collateralToken, uint16(_troveManagers.length));\n\t\t_troveManagers.push(troveManager);\n\t\temit CollateralConfigured(troveManager, collateralToken);\n\t}\n\n\tfunction removeTroveManager(ITroveManager troveManager) external {\n\t\tTroveManagerData memory tmData = troveManagersData[troveManager];\n\t\trequire(address(tmData.collateralToken) != address(0) && troveManager.sunsetting() && troveManager.getEntireSystemDebt() == 0, \"Trove Manager cannot be removed\");\n\t\tdelete troveManagersData[troveManager];\n\t\tuint256 lastIndex = _troveManagers.length - 1;\n\t\tif (tmData.index < lastIndex) {\n\t\t\tITroveManager lastTm = _troveManagers[lastIndex];\n\t\t\t_troveManagers[tmData.index] = lastTm;\n\t\t\ttroveManagersData[lastTm].index = tmData.index;\n\t\t}\n\n\t\t_troveManagers.pop();\n\t\temit TroveManagerRemoved(troveManager);\n\t}\n\n\t/**\n        @notice Get the global total collateral ratio\n        @dev Not a view because fetching from the oracle is state changing.\n             Can still be accessed as a view from within the UX.\n     */\n\tfunction getTCR() external returns (uint256 globalTotalCollateralRatio) {\n\t\tSystemBalances memory balances = fetchBalances();\n\t\t(globalTotalCollateralRatio, , ) = _getTCRData(balances);\n\t\treturn globalTotalCollateralRatio;\n\t}\n\n\t/**\n        @notice Get total collateral and debt balances for all active collaterals, as well as\n                the current collateral prices\n        @dev Not a view because fetching from the oracle is state changing.\n             Can still be accessed as a view from within the UX.\n     */\n\tfunction fetchBalances() public returns (SystemBalances memory balances) {\n\t\tuint256 loopEnd = _troveManagers.length;\n\t\tbalances = SystemBalances({ collaterals: new uint256[](loopEnd), debts: new uint256[](loopEnd), prices: new uint256[](loopEnd) });\n\t\tfor (uint256 i; i < loopEnd; ) {\n\t\t\tITroveManager troveManager = _troveManagers[i];\n\t\t\t(uint256 collateral, uint256 debt, uint256 price) = troveManager.getEntireSystemBalances();\n\t\t\tbalances.collaterals[i] = collateral;\n\t\t\tbalances.debts[i] = debt;\n\t\t\tbalances.prices[i] = price;\n\t\t\tunchecked {\n\t\t\t\t++i;\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction checkRecoveryMode(uint256 TCR) public pure returns (bool) {\n\t\treturn TCR < CCR;\n\t}\n\n\tfunction getCompositeDebt(uint256 _debt) external view returns (uint256) {\n\t\treturn _getCompositeDebt(_debt);\n\t}\n\n\t// --- Borrower Trove Operations ---\n\tfunction openTrove(ITroveManager troveManager, address account, uint256 _maxFeePercentage, uint256 _collateralAmount, uint256 _debtAmount, address _upperHint, address _lowerHint) external callerOrDelegated(account) {\n\t\trequire(!PropelCore.paused(), \"Deposits are paused\");\n\t\ttroveManager.distributeInterestDebt();\n\t\tIERC20 collateralToken;\n\t\tLocalVariables_openTrove memory vars;\n\t\tbool isRecoveryMode;\n\t\t(collateralToken, vars.price, vars.totalPricedCollateral, vars.totalDebt, isRecoveryMode) = _getCollateralAndTCRData(troveManager);\n\t\t_requireValidMaxFeePercentage(_maxFeePercentage);\n\n\t\tvars.netDebt = _debtAmount;\n\n\t\tif (!isRecoveryMode) {\n\t\t\tvars.netDebt = vars.netDebt + _triggerBorrowingFee(troveManager, account, _maxFeePercentage, _debtAmount);\n\t\t}\n\t\t_requireAtLeastMinNetDebt(vars.netDebt);\n\n\t\t// ICR is based on the composite debt, i.e. the requested Debt amount + Debt borrowing fee + Debt gas comp.\n\t\tvars.compositeDebt = _getCompositeDebt(vars.netDebt);\n\t\tvars.ICR = PropelMath._computeCR(_collateralAmount, vars.compositeDebt, vars.price);\n\t\tvars.NICR = PropelMath._computeNominalCR(_collateralAmount, vars.compositeDebt);\n\n\t\tif (isRecoveryMode) {\n\t\t\t_requireICRisAboveCCR(vars.ICR);\n\t\t} else {\n\t\t\t_requireICRisAboveMCR(vars.ICR, troveManager.MCR());\n\t\t\tuint256 newTCR = _getNewTCRFromTroveChange(vars.totalPricedCollateral, vars.totalDebt, _collateralAmount * vars.price, true, vars.compositeDebt, true); // bools: coll increase, debt increase\n\t\t\t_requireNewTCRisAboveCCR(newTCR);\n\t\t}\n\n\t\t// Create the trove\n\t\t(vars.stake, vars.arrayIndex) = troveManager.openTrove(account, _collateralAmount, vars.compositeDebt, vars.NICR, _upperHint, _lowerHint);\n\t\temit TroveCreated(account, vars.arrayIndex);\n\n\t\t// Move the collateral to the Trove Manager\n\t\tcollateralToken.safeTransferFrom(msg.sender, address(troveManager), _collateralAmount);\n\n\t\t//  and mint the DebtAmount to the caller and gas compensation for Gas Pool\n\t\tPropelUSD.mintWithGasCompensation(msg.sender, _debtAmount);\n\n\t\temit TroveUpdated(account, vars.compositeDebt, _collateralAmount, vars.stake, BorrowerOperation.openTrove);\n\t}\n\n\t// Send collateral to a trove\n\tfunction addColl(ITroveManager troveManager, address account, uint256 _collateralAmount, address _upperHint, address _lowerHint) external callerOrDelegated(account) {\n\t\trequire(!PropelCore.paused(), \"Trove adjustments are paused\");\n\t\t_adjustTrove(troveManager, account, 0, _collateralAmount, 0, 0, false, _upperHint, _lowerHint);\n\t}\n\n\t// Withdraw collateral from a trove\n\tfunction withdrawColl(ITroveManager troveManager, address account, uint256 _collWithdrawal, address _upperHint, address _lowerHint) external callerOrDelegated(account) {\n\t\t_adjustTrove(troveManager, account, 0, 0, _collWithdrawal, 0, false, _upperHint, _lowerHint);\n\t}\n\n\t// Withdraw Debt tokens from a trove: mint new Debt tokens to the owner, and increase the trove's debt accordingly\n\tfunction withdrawDebt(ITroveManager troveManager, address account, uint256 _maxFeePercentage, uint256 _debtAmount, address _upperHint, address _lowerHint) external callerOrDelegated(account) {\n\t\trequire(!PropelCore.paused(), \"Withdrawals are paused\");\n\t\t_adjustTrove(troveManager, account, _maxFeePercentage, 0, 0, _debtAmount, true, _upperHint, _lowerHint);\n\t}\n\n\t// Repay Debt tokens to a Trove: Burn the repaid Debt tokens, and reduce the trove's debt accordingly\n\tfunction repayDebt(ITroveManager troveManager, address account, uint256 _debtAmount, address _upperHint, address _lowerHint) external callerOrDelegated(account) {\n\t\t_adjustTrove(troveManager, account, 0, 0, 0, _debtAmount, false, _upperHint, _lowerHint);\n\t}\n\n\tfunction adjustTrove(ITroveManager troveManager, address account, uint256 _maxFeePercentage, uint256 _collDeposit, uint256 _collWithdrawal, uint256 _debtChange, bool _isDebtIncrease, address _upperHint, address _lowerHint) external callerOrDelegated(account) {\n\t\trequire((_collDeposit == 0 && !_isDebtIncrease) || !PropelCore.paused(), \"Trove adjustments are paused\");\n\t\trequire(_collDeposit == 0 || _collWithdrawal == 0, \"BorrowerOperations: Cannot withdraw and add coll\");\n\t\t_adjustTrove(troveManager, account, _maxFeePercentage, _collDeposit, _collWithdrawal, _debtChange, _isDebtIncrease, _upperHint, _lowerHint);\n\t}\n\n\tfunction _adjustTrove(ITroveManager troveManager, address account, uint256 _maxFeePercentage, uint256 _collDeposit, uint256 _collWithdrawal, uint256 _debtChange, bool _isDebtIncrease, address _upperHint, address _lowerHint) internal {\n\t\trequire(_collDeposit != 0 || _collWithdrawal != 0 || _debtChange != 0, \"BorrowerOps: There must be either a collateral change or a debt change\");\n\t\ttroveManager.distributeInterestDebt();\n\t\tIERC20 collateralToken;\n\t\tLocalVariables_adjustTrove memory vars;\n\t\tbool isRecoveryMode;\n\t\t(collateralToken, vars.price, vars.totalPricedCollateral, vars.totalDebt, isRecoveryMode) = _getCollateralAndTCRData(troveManager);\n\n\t\t(vars.coll, vars.debt) = troveManager.applyPendingRewards(account);\n\t\ttroveManager.repayInterest(msg.sender, account, vars.debt);\n\n\t\t// Get the collChange based on whether or not collateral was sent in the transaction\n\t\t(vars.collChange, vars.isCollIncrease) = _getCollChange(_collDeposit, _collWithdrawal);\n\t\tvars.netDebtChange = _debtChange;\n\t\tvars.debtChange = _debtChange;\n\t\tvars.account = account;\n\t\tvars.MCR = troveManager.MCR();\n\n\t\tif (_isDebtIncrease) {\n\t\t\trequire(_debtChange > 0, \"BorrowerOps: Debt increase requires non-zero debtChange\");\n\t\t\t_requireValidMaxFeePercentage(_maxFeePercentage);\n\t\t\tif (!isRecoveryMode) {\n\t\t\t\t// If the adjustment incorporates a debt increase and system is in Normal Mode, trigger a borrowing fee\n\t\t\t\tvars.netDebtChange += _triggerBorrowingFee(troveManager, msg.sender, _maxFeePercentage, _debtChange);\n\t\t\t}\n\t\t}\n\n\t\t// Calculate old and new ICRs and check if adjustment satisfies all conditions for the current system mode\n\t\t_requireValidAdjustmentInCurrentMode(vars.totalPricedCollateral, vars.totalDebt, isRecoveryMode, _collWithdrawal, _isDebtIncrease, vars);\n\n\t\t// When the adjustment is a debt repayment, check it's a valid amount and that the caller has enough Debt\n\t\tif (!_isDebtIncrease && _debtChange > 0) {\n\t\t\t_requireAtLeastMinNetDebt(_getNetDebt(vars.debt) - vars.netDebtChange);\n\t\t}\n\n\t\t// If we are incrasing collateral, send tokens to the trove manager prior to adjusting the trove\n\t\tif (vars.isCollIncrease) collateralToken.safeTransferFrom(msg.sender, address(troveManager), vars.collChange);\n\n\t\t(vars.newColl, vars.newDebt, vars.stake) = troveManager.updateTroveFromAdjustment(_isDebtIncrease, vars.debtChange, vars.netDebtChange, vars.isCollIncrease, vars.collChange, _upperHint, _lowerHint, vars.account, msg.sender);\n\n\t\temit TroveUpdated(vars.account, vars.newDebt, vars.newColl, vars.stake, BorrowerOperation.adjustTrove);\n\t}\n\n\tfunction closeTrove(ITroveManager troveManager, address account) external callerOrDelegated(account) {\n\t\tIERC20 collateralToken;\n\n\t\tuint256 price;\n\t\tbool isRecoveryMode;\n\t\tuint256 totalPricedCollateral;\n\t\tuint256 totalDebt;\n\t\t(collateralToken, price, totalPricedCollateral, totalDebt, isRecoveryMode) = _getCollateralAndTCRData(troveManager);\n\t\trequire(!isRecoveryMode, \"BorrowerOps: Operation not permitted during Recovery Mode\");\n\t\ttroveManager.distributeInterestDebt();\n\t\t(uint256 coll, uint256 debt) = troveManager.applyPendingRewards(account);\n\t\ttroveManager.repayInterest(msg.sender, account, debt);\n\t\tuint256 newTCR = _getNewTCRFromTroveChange(totalPricedCollateral, totalDebt, coll * price, false, debt, false);\n\t\t_requireNewTCRisAboveCCR(newTCR);\n\n\t\ttroveManager.closeTrove(account, msg.sender, coll, debt);\n\n\t\temit TroveUpdated(account, 0, 0, 0, BorrowerOperation.closeTrove);\n\n\t\t// Burn the repaid Debt from the user's balance and the gas compensation from the Gas Pool\n\t\tPropelUSD.burnWithGasCompensation(msg.sender, debt - DEBT_GAS_COMPENSATION);\n\t}\n\n\t// --- Helper functions ---\n\n\tfunction _triggerBorrowingFee(ITroveManager _troveManager, address _caller, uint256 _maxFeePercentage, uint256 _debtAmount) internal returns (uint256) {\n\t\tuint256 debtFee = _troveManager.decayBaseRateAndGetBorrowingFee(_debtAmount);\n\n\t\t_requireUserAcceptsFee(debtFee, _debtAmount, _maxFeePercentage);\n\n\t\tPropelUSD.mint(PropelCore.feeReceiver(), debtFee);\n\n\t\temit BorrowingFeePaid(_caller, debtFee);\n\n\t\treturn debtFee;\n\t}\n\n\tfunction _getCollChange(uint256 _collReceived, uint256 _requestedCollWithdrawal) internal pure returns (uint256 collChange, bool isCollIncrease) {\n\t\tif (_collReceived != 0) {\n\t\t\tcollChange = _collReceived;\n\t\t\tisCollIncrease = true;\n\t\t} else {\n\t\t\tcollChange = _requestedCollWithdrawal;\n\t\t}\n\t}\n\n\tfunction _requireValidAdjustmentInCurrentMode(uint256 totalPricedCollateral, uint256 totalDebt, bool _isRecoveryMode, uint256 _collWithdrawal, bool _isDebtIncrease, LocalVariables_adjustTrove memory _vars) internal pure {\n\t\t/*\n\t\t *In Recovery Mode, only allow:\n\t\t *\n\t\t * - Pure collateral top-up\n\t\t * - Pure debt repayment\n\t\t * - Collateral top-up with debt repayment\n\t\t * - A debt increase combined with a collateral top-up which makes the ICR >= 150% and improves the ICR (and by extension improves the TCR).\n\t\t *\n\t\t * In Normal Mode, ensure:\n\t\t *\n\t\t * - The new ICR is above MCR\n\t\t * - The adjustment won't pull the TCR below CCR\n\t\t */\n\n\t\t// Get the trove's old ICR before the adjustment\n\t\tuint256 oldICR = PropelMath._computeCR(_vars.coll, _vars.debt, _vars.price);\n\n\t\t// Get the trove's new ICR after the adjustment\n\t\tuint256 newICR = _getNewICRFromTroveChange(_vars.coll, _vars.debt, _vars.collChange, _vars.isCollIncrease, _vars.netDebtChange, _isDebtIncrease, _vars.price);\n\n\t\tif (_isRecoveryMode) {\n\t\t\trequire(_collWithdrawal == 0, \"BorrowerOps: Collateral withdrawal not permitted Recovery Mode\");\n\t\t\tif (_isDebtIncrease) {\n\t\t\t\t_requireICRisAboveCCR(newICR);\n\t\t\t\t_requireNewICRisAboveOldICR(newICR, oldICR);\n\t\t\t}\n\t\t} else {\n\t\t\t// if Normal Mode\n\t\t\t_requireICRisAboveMCR(newICR, _vars.MCR);\n\t\t\tuint256 newTCR = _getNewTCRFromTroveChange(totalPricedCollateral, totalDebt, _vars.collChange * _vars.price, _vars.isCollIncrease, _vars.netDebtChange, _isDebtIncrease);\n\t\t\t_requireNewTCRisAboveCCR(newTCR);\n\t\t}\n\t}\n\n\tfunction _requireICRisAboveMCR(uint256 _newICR, uint256 MCR) internal pure {\n\t\trequire(_newICR >= MCR, \"BorrowerOps: An operation that would result in ICR < MCR is not permitted\");\n\t}\n\n\tfunction _requireICRisAboveCCR(uint256 _newICR) internal pure {\n\t\trequire(_newICR >= CCR, \"BorrowerOps: Operation must leave trove with ICR >= CCR\");\n\t}\n\n\tfunction _requireNewICRisAboveOldICR(uint256 _newICR, uint256 _oldICR) internal pure {\n\t\trequire(_newICR >= _oldICR, \"BorrowerOps: Cannot decrease your Trove's ICR in Recovery Mode\");\n\t}\n\n\tfunction _requireNewTCRisAboveCCR(uint256 _newTCR) internal pure {\n\t\trequire(_newTCR >= CCR, \"BorrowerOps: An operation that would result in TCR < CCR is not permitted\");\n\t}\n\n\tfunction _requireAtLeastMinNetDebt(uint256 _netDebt) internal view {\n\t\trequire(_netDebt >= minNetDebt, \"BorrowerOps: Trove's net debt must be greater than minimum\");\n\t}\n\n\tfunction _requireValidMaxFeePercentage(uint256 _maxFeePercentage) internal pure {\n\t\trequire(_maxFeePercentage <= DECIMAL_PRECISION, \"Max fee percentage must less than or equal to 100%\");\n\t}\n\n\t// Compute the new collateral ratio, considering the change in coll and debt. Assumes 0 pending rewards.\n\tfunction _getNewICRFromTroveChange(uint256 _coll, uint256 _debt, uint256 _collChange, bool _isCollIncrease, uint256 _debtChange, bool _isDebtIncrease, uint256 _price) internal pure returns (uint256) {\n\t\t(uint256 newColl, uint256 newDebt) = _getNewTroveAmounts(_coll, _debt, _collChange, _isCollIncrease, _debtChange, _isDebtIncrease);\n\n\t\tuint256 newICR = PropelMath._computeCR(newColl, newDebt, _price);\n\t\treturn newICR;\n\t}\n\n\tfunction _getNewTroveAmounts(uint256 _coll, uint256 _debt, uint256 _collChange, bool _isCollIncrease, uint256 _debtChange, bool _isDebtIncrease) internal pure returns (uint256, uint256) {\n\t\tuint256 newColl = _coll;\n\t\tuint256 newDebt = _debt;\n\t\tnewColl = _isCollIncrease ? _coll + _collChange : _coll - _collChange;\n\t\tnewDebt = _isDebtIncrease ? _debt + _debtChange : _debt - _debtChange;\n\n\t\treturn (newColl, newDebt);\n\t}\n\n\tfunction _getNewTCRFromTroveChange(uint256 totalColl, uint256 totalDebt, uint256 _collChange, bool _isCollIncrease, uint256 _debtChange, bool _isDebtIncrease) internal pure returns (uint256) {\n\t\ttotalDebt = _isDebtIncrease ? totalDebt + _debtChange : totalDebt - _debtChange;\n\t\ttotalColl = _isCollIncrease ? totalColl + _collChange : totalColl - _collChange;\n\n\t\tuint256 newTCR = PropelMath._computeCR(totalColl, totalDebt);\n\t\treturn newTCR;\n\t}\n\n\tfunction _getTCRData(SystemBalances memory balances) internal pure returns (uint256 amount, uint256 totalPricedCollateral, uint256 totalDebt) {\n\t\tuint256 loopEnd = balances.collaterals.length;\n\t\tfor (uint256 i; i < loopEnd; ) {\n\t\t\ttotalPricedCollateral += (balances.collaterals[i] * balances.prices[i]);\n\t\t\ttotalDebt += balances.debts[i];\n\t\t\tunchecked {\n\t\t\t\t++i;\n\t\t\t}\n\t\t}\n\t\tamount = PropelMath._computeCR(totalPricedCollateral, totalDebt);\n\n\t\treturn (amount, totalPricedCollateral, totalDebt);\n\t}\n\n\tfunction _getCollateralAndTCRData(ITroveManager troveManager) internal returns (IERC20 collateralToken, uint256 price, uint256 totalPricedCollateral, uint256 totalDebt, bool isRecoveryMode) {\n\t\tTroveManagerData storage t = troveManagersData[troveManager];\n\t\tuint256 index;\n\t\t(collateralToken, index) = (t.collateralToken, t.index);\n\n\t\trequire(address(collateralToken) != address(0), \"Collateral not enabled\");\n\n\t\tuint256 amount;\n\t\tSystemBalances memory balances = fetchBalances();\n\t\t(amount, totalPricedCollateral, totalDebt) = _getTCRData(balances);\n\t\tisRecoveryMode = checkRecoveryMode(amount);\n\n\t\treturn (collateralToken, balances.prices[index], totalPricedCollateral, totalDebt, isRecoveryMode);\n\t}\n\n\tfunction getGlobalSystemBalances() external returns (uint256 totalPricedCollateral, uint256 totalDebt) {\n\t\tSystemBalances memory balances = fetchBalances();\n\t\t(, totalPricedCollateral, totalDebt) = _getTCRData(balances);\n\t}\n}\n"
    },
    "contracts/core/CommunityIssuance.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"../dependencies/BlastWrapperUpgradeable.sol\";\nimport \"../dependencies/PropelMath.sol\";\nimport \"../dependencies/PropelOwnable.sol\";\nimport \"../interfaces/IEsPropel.sol\";\nimport \"../interfaces/ICommunityIssuance.sol\";\n\ncontract CommunityIssuance is ICommunityIssuance, BlastWrapperUpgradeable {\n\tIEsPropel public EsPropel;\n\taddress public stabilitypool;\n\tuint64 public lastUpdatedTime;\n\tuint64 public duration;\n\tuint64 public rewardEndTime;\n\tuint256 public rewardPerSec;\n\tuint256 public rewardStored;\n\n\tfunction initialize(IPropelCore _PropelCore, address _EsPropel, address _stabilityPool) external initializer {\n\t\t__Init_Blast(_PropelCore);\n\t\tEsPropel = IEsPropel(_EsPropel);\n\t\tstabilitypool = _stabilityPool;\n\t}\n\n\tfunction startUp(uint128 _rewardPerSec, uint64 _duration) external onlyOwner {\n\t\trequire(rewardPerSec == 0 && rewardEndTime == 0, \"CommunityIssuance: Already started\");\n\t\tduration = _duration;\n\t\trewardPerSec = _rewardPerSec;\n\t}\n\n\t// Returns current timestamp if the rewards program has not finished yet, end time otherwise\n\tfunction lastTimeRewardApplicable() public view returns (uint64) {\n\t\treturn uint64(PropelMath._min(block.timestamp, rewardEndTime));\n\t}\n\n\tfunction setRewardPerSec(uint128 _rewardPerSec) external onlyOwner {\n\t\trequire(rewardPerSec > 0, \"CommunityIssuance: invalid rewardPerSec\");\n\t\trewardStored += pendingIssues();\n\t\trewardPerSec = _rewardPerSec;\n\t\tlastUpdatedTime = lastTimeRewardApplicable();\n\t}\n\n\tfunction setRewardEndTime(uint64 _rewardEndTime) external onlyOwner {\n\t\trequire(rewardEndTime > block.timestamp, \"CommunityIssuance: invalid rewardEndTime\");\n\t\trewardStored += pendingIssues();\n\t\trewardEndTime = _rewardEndTime;\n\t\tlastUpdatedTime = lastTimeRewardApplicable();\n\t}\n\n\tfunction issueEsPropel() external override returns (uint256) {\n\t\t_requireCallerIsSP();\n\t\tif (duration == 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tif (rewardEndTime == 0) {\n\t\t\trewardEndTime = uint64(block.timestamp) + duration;\n\t\t}\n\t\tif (lastUpdatedTime == 0) {\n\t\t\tlastUpdatedTime = lastTimeRewardApplicable();\n\t\t\treturn 0;\n\t\t}\n\t\tif (lastUpdatedTime == lastTimeRewardApplicable()) {\n\t\t\treturn 0;\n\t\t}\n\t\tuint256 amount = pendingReward();\n\t\tif (rewardStored != 0) {\n\t\t\trewardStored = 0;\n\t\t}\n\t\tlastUpdatedTime = lastTimeRewardApplicable();\n\t\temit EsPropelIssued(amount);\n\t\treturn amount;\n\t}\n\n\tfunction sendEsPropel(address to, uint256 amount) external override {\n\t\t_requireCallerIsSP();\n\t\trequire(amount > 0, \"CommunityIssuance: zero amount\");\n\t\tEsPropel.transfer(to, amount);\n\t\temit EsPropelSent(to, amount);\n\t}\n\n\tfunction pendingIssues() public view returns (uint256 pending) {\n\t\tif (lastUpdatedTime == 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tif (lastTimeRewardApplicable() == lastUpdatedTime) {\n\t\t\treturn 0;\n\t\t}\n\t\tuint256 timeDiff = lastTimeRewardApplicable() - lastUpdatedTime;\n\t\tpending = (timeDiff * rewardPerSec);\n\t}\n\n\tfunction pendingReward() public view returns (uint256 pending) {\n\t\treturn pendingIssues() + rewardStored;\n\t}\n\n\tfunction _requireCallerIsSP() internal view {\n\t\trequire(msg.sender == stabilitypool, \"CommunityIssuance: Caller is not Stability Pool\");\n\t}\n}\n"
    },
    "contracts/core/EsPropel.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\nimport \"../interfaces/IEsPropel.sol\";\nimport \"../interfaces/IPropel.sol\";\nimport \"../dependencies/PropelOwnable.sol\";\n\ncontract EsPropel is ERC20Burnable, PropelOwnable, IEsPropel {\n\taddress internal deployer;\n\tIPropel public propel;\n\taddress public vest;\n\n\tmapping(address => bool) public senders;\n\n\tmapping(address => bool) public receivers;\n\n\tconstructor(IPropelCore _propelCore, address _propel, address _vest) ERC20(\"Escrow Propel\", \"esPropel\") PropelOwnable(_propelCore) {\n\t\tpropel = IPropel(_propel);\n\t\tvest = _vest;\n\t\t_authSender(_vest, true);\n\t\t_authReceiver(_vest, true);\n\t}\n\n\tfunction mint(address account, uint256 amount) external {\n\t\t_requireCallerIsPropel();\n\t\t_mint(account, amount);\n\t}\n\n\tfunction authAll(address[] memory _callers, bool[] memory _enables) external onlyOwner {\n\t\t_authSenders(_callers, _enables);\n\t\t_authReceivers(_callers, _enables);\n\t}\n\n\tfunction authSenders(address[] memory _senders, bool[] memory _enables) external onlyOwner {\n\t\t_authSenders(_senders, _enables);\n\t}\n\n\tfunction _authSenders(address[] memory _senders, bool[] memory _enables) internal {\n\t\trequire(_senders.length == _enables.length, \"EsPropel: number of senders must be equal to the number of enables\");\n\t\tfor (uint256 i = 0; i < _senders.length; i++) {\n\t\t\t_authSender(_senders[i], _enables[i]);\n\t\t}\n\t}\n\n\tfunction _authSender(address _sender, bool _enable) internal {\n\t\tsenders[_sender] = _enable;\n\t\temit SenderUpdated(_sender, _enable);\n\t}\n\n\tfunction authReceivers(address[] memory _receivers, bool[] memory _enables) external onlyOwner {\n\t\t_authReceivers(_receivers, _enables);\n\t}\n\n\tfunction _authReceivers(address[] memory _receivers, bool[] memory _enables) internal {\n\t\trequire(_receivers.length == _enables.length, \"EsPropel: number of receivers must be equal to the number of enables\");\n\t\tfor (uint256 i = 0; i < _receivers.length; i++) {\n\t\t\t_authReceiver(_receivers[i], _enables[i]);\n\t\t}\n\t}\n\n\tfunction _authReceiver(address _receiver, bool _enable) internal {\n\t\treceivers[_receiver] = _enable;\n\t\temit ReceiverUpdated(_receiver, _enable);\n\t}\n\n\tfunction burnFromPropel(address account, uint256 amount) external override {\n\t\t_requireCallerIsPropel();\n\t\t_burn(account, amount);\n\t}\n\n\tfunction burn(uint256 amount) public override(ERC20Burnable, IEsPropel) {\n\t\tERC20Burnable.burn(amount);\n\t}\n\n\tfunction burnFrom(address account, uint256 amount) public override(ERC20Burnable, IEsPropel) {\n\t\tERC20Burnable.burnFrom(account, amount);\n\t}\n\n\tfunction sendToken(address from, uint256 amount) external override {\n\t\t_requireCallerIsReceiver();\n\t\t_transfer(from, msg.sender, amount);\n\t}\n\n\tfunction transfer(address to, uint256 amount) public override(IERC20, ERC20) returns (bool) {\n\t\t_requireCallerIsSender();\n\t\t_transfer(msg.sender, to, amount);\n\t\treturn true;\n\t}\n\n\tfunction transferFrom(address from, address to, uint256 amount) public pure override(IERC20, ERC20) returns (bool) {\n\t\trevert(\"EsPropel: not allowed\");\n\t}\n\n\tfunction _requireCallerIsSender() internal view {\n\t\trequire(senders[msg.sender], \"EsPropel: invalid sender\");\n\t}\n\n\tfunction _requireCallerIsReceiver() internal view {\n\t\trequire(receivers[msg.sender], \"EsPropel: invalid receiver\");\n\t}\n\n\tfunction _requireCallerIsPropel() internal view {\n\t\trequire(msg.sender == address(propel), \"EsPropel: Caller is not Propel\");\n\t}\n}\n"
    },
    "contracts/core/Factory.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/proxy/Clones.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../dependencies/PropelOwnable.sol\";\nimport \"../dependencies/console.sol\";\nimport \"../interfaces/ITroveManager.sol\";\nimport \"../interfaces/IBorrowerOperations.sol\";\nimport \"../interfaces/IPropelUSD.sol\";\nimport \"../interfaces/ISortedTroves.sol\";\nimport \"../interfaces/IStabilityPool.sol\";\nimport \"../interfaces/ILiquidationManager.sol\";\n\n/**\n    @title Propel Trove Factory\n    @notice Deploys cloned pairs of `TroveManager` and `SortedTroves` in order to\n            add new collateral types within the system.\n */\ncontract Factory is PropelOwnable {\n\tusing Clones for address;\n\n\t// fixed single-deployment contracts\n\tIPropelUSD public immutable propelUSD;\n\tIStabilityPool public immutable stabilityPool;\n\tILiquidationManager public immutable liquidationManager;\n\tIBorrowerOperations public immutable borrowerOperations;\n\n\t// implementation contracts, redeployed each time via clone proxy\n\taddress public sortedTrovesImpl;\n\taddress public troveManagerImpl;\n\n\taddress[] public troveManagers;\n\n\t// commented values are suggested default parameters\n\tstruct DeploymentParams {\n\t\tuint256 minuteDecayFactor; // 999037758833783000  (half life of 12 hours)\n\t\tuint256 redemptionFeeFloor; // 1e18 / 1000 * 5  (0.5%)\n\t\tuint256 maxRedemptionFee; // 1e18  (100%)\n\t\tuint256 borrowingFeeFloor; // 1e18 / 1000 * 5  (0.5%)\n\t\tuint256 maxBorrowingFee; // 1e18 / 100 * 5  (5%)\n\t\tuint256 maxDebt;\n\t\tuint256 MCR; // 12 * 1e17  (120%)\n\t\tuint32 interestRate; // 1e4 (1%)\n\t}\n\n\tevent NewDeployment(IERC20 collateral, address priceFeed, address troveManager, address sortedTroves);\n\n\tconstructor(IPropelCore _propelCore, IPropelUSD _propelUSD, IStabilityPool _stabilityPool, IBorrowerOperations _borrowerOperations, address _sortedTroves, address _troveManager, ILiquidationManager _liquidationManager) PropelOwnable(_propelCore) {\n\t\tpropelUSD = _propelUSD;\n\t\tstabilityPool = _stabilityPool;\n\t\tborrowerOperations = _borrowerOperations;\n\n\t\tsortedTrovesImpl = _sortedTroves;\n\t\ttroveManagerImpl = _troveManager;\n\t\tliquidationManager = _liquidationManager;\n\t}\n\n\tfunction troveManagerCount() external view returns (uint256) {\n\t\treturn troveManagers.length;\n\t}\n\n\t/**\n        @notice Deploy new instances of `TroveManager` and `SortedTroves`, adding\n                a new collateral type to the system.\n        @dev * When using the default `PriceFeed`, ensure it is configured correctly\n               prior to calling this function.\n             * After calling this function, the owner should also call `Vault.registerReceiver`\n               to enable Propel emissions on the newly deployed `TroveManager`\n        @param collateral Collateral token to use in new deployment\n        @param priceFeed Custom `PriceFeed` deployment. Leave as `address(0)` to use the default.\n        @param params Struct of initial parameters to be set on the new trove manager\n     */\n\tfunction deployNewInstance(IERC20 collateral, address priceFeed, DeploymentParams memory params) external onlyOwner {\n\t\taddress troveManager = troveManagerImpl;\n\t\ttroveManagers.push(troveManager);\n\t\taddress sortedTroves = sortedTrovesImpl;\n\t\tITroveManager(troveManager).setAddresses(priceFeed, sortedTroves, collateral);\n\t\tISortedTroves(sortedTroves).setAddresses(troveManager);\n\n\t\t// verify that the oracle is correctly working\n\t\tITroveManager(troveManager).fetchPrice();\n\n\t\tstabilityPool.enableCollateral(collateral);\n\t\tliquidationManager.enableTroveManager(troveManager);\n\t\tpropelUSD.enableTroveManager(troveManager);\n\t\tborrowerOperations.configureCollateral(ITroveManager(troveManager), collateral);\n\n\t\tITroveManager(troveManager).setParameters(params.minuteDecayFactor, params.redemptionFeeFloor, params.maxRedemptionFee, params.borrowingFeeFloor, params.maxBorrowingFee, params.maxDebt, params.MCR, params.interestRate);\n\n\t\temit NewDeployment(collateral, priceFeed, troveManager, sortedTroves);\n\t}\n\n\tfunction setImplementations(address _troveManagerImpl, address _sortedTrovesImpl) external onlyOwner {\n\t\ttroveManagerImpl = _troveManagerImpl;\n\t\tsortedTrovesImpl = _sortedTrovesImpl;\n\t}\n}\n"
    },
    "contracts/core/FeeReceiver.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../dependencies/BlastWrapperUpgradeable.sol\";\n\ncontract FeeReceiver is BlastWrapperUpgradeable {\n\tfunction initialize(IPropelCore _PropelCore) external initializer {\n\t\t__Init_Blast(_PropelCore);\n\t}\n\n\tfunction withdraw(address to, IERC20 coin, uint256 value) external onlyOwner {\n\t\tif (address(coin) == address(0)) {\n\t\t\t(bool success, ) = to.call{ value: value }(\"\");\n\t\t\trequire(success, \"FeeReceiver: withdraw eth failed\");\n\t\t} else {\n\t\t\tcoin.transfer(to, value);\n\t\t}\n\t}\n}\n"
    },
    "contracts/core/InterestDebtPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"../interfaces/IPropelUSD.sol\";\nimport \"../dependencies/PropelMath.sol\";\nimport \"../dependencies/console.sol\";\n\nabstract contract InterestDebtPool {\n\tIPropelUSD public immutable PropelUSD;\n\tuint64 internal constant PRECISION = 1e18;\n\tuint64 internal constant SECONDS_IN_YEAR = 365 days;\n\tuint32 internal constant MAXFP = 1e6;\n\tuint32 public interestRate;\n\tuint256 internal outstandingInterestDebt;\n\tuint256 public L_Interest_Debt;\n\tuint256 public lastInterestDebtUpdateTime;\n\tuint256 public lastInterestDebtError_Redistribution;\n\n\tconstructor(address _PropelUSD) {\n\t\tPropelUSD = IPropelUSD(_PropelUSD);\n\t}\n\n\tevent InterestDebtDistributed(uint256 debt);\n\n\tfunction getOutstandingInterestDebt() public view returns (uint256) {\n\t\treturn outstandingInterestDebt;\n\t}\n\n\tfunction getCurrentOutstandingInterestDebt() public view returns (uint256) {\n\t\treturn outstandingInterestDebt + getPendingSystemInterestDebt();\n\t}\n\n\tfunction decreaseOutstandingInterestDebt(uint256 amount) internal {\n\t\toutstandingInterestDebt -= amount;\n\t}\n\n\tfunction getEntireSystemDebt() public view virtual returns (uint256 entireSystemDebt);\n\n\tfunction _distributeInterestDebt() internal returns (uint256) {\n\t\tif (lastInterestDebtUpdateTime == 0) {\n\t\t\tlastInterestDebtUpdateTime = block.timestamp;\n\t\t\treturn 0;\n\t\t}\n\t\tif (lastInterestDebtUpdateTime == block.timestamp) {\n\t\t\treturn 0;\n\t\t}\n\t\tuint256 systemDebt = getEntireSystemDebt();\n\t\tif (systemDebt == 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tuint256 feeNumerator = (systemDebt * ((block.timestamp - lastInterestDebtUpdateTime) * interestRate * PRECISION)) / SECONDS_IN_YEAR / MAXFP + lastInterestDebtError_Redistribution;\n\t\tlastInterestDebtUpdateTime = block.timestamp;\n\t\tuint256 feeRewardPerUnitDebt = feeNumerator / systemDebt;\n\t\tlastInterestDebtError_Redistribution = feeNumerator - (feeRewardPerUnitDebt * systemDebt);\n\t\tL_Interest_Debt += feeRewardPerUnitDebt;\n\t\tuint256 interest = (feeRewardPerUnitDebt * systemDebt) / PRECISION;\n\t\toutstandingInterestDebt += interest;\n\t\tPropelUSD.mint(feeReceiver(), interest);\n\t\temit InterestDebtDistributed(interest);\n\t\treturn feeRewardPerUnitDebt;\n\t}\n\n\tfunction feeReceiver() public view virtual returns (address);\n\n\tfunction getPendingSystemInterestDebt() public view returns (uint256) {\n\t\tif (lastInterestDebtUpdateTime == 0 || lastInterestDebtUpdateTime == block.timestamp) {\n\t\t\treturn 0;\n\t\t}\n\t\tuint256 systemDebt = getEntireSystemDebt();\n\t\tif (systemDebt == 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tuint256 feeNumerator = (systemDebt * ((block.timestamp - lastInterestDebtUpdateTime) * interestRate * PRECISION)) / SECONDS_IN_YEAR / MAXFP + lastInterestDebtError_Redistribution;\n\t\tuint256 feeRewardPerUnitDebt = feeNumerator / systemDebt;\n\t\treturn (feeRewardPerUnitDebt * systemDebt) / PRECISION;\n\t}\n\n\tfunction getPendingInterestDebt() public view returns (uint256) {\n\t\tif (lastInterestDebtUpdateTime == 0 || lastInterestDebtUpdateTime == block.timestamp) {\n\t\t\treturn L_Interest_Debt;\n\t\t}\n\t\tuint256 systemDebt = getEntireSystemDebt();\n\t\tif (systemDebt == 0) {\n\t\t\treturn L_Interest_Debt;\n\t\t}\n\t\tuint256 feeNumerator = (systemDebt * (block.timestamp - lastInterestDebtUpdateTime) * interestRate * PRECISION) / SECONDS_IN_YEAR / MAXFP + lastInterestDebtError_Redistribution;\n\t\treturn L_Interest_Debt + feeNumerator / systemDebt;\n\t}\n}\n"
    },
    "contracts/core/LiquidationManager.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../interfaces/IStabilityPool.sol\";\nimport \"../interfaces/ISortedTroves.sol\";\nimport \"../interfaces/IBorrowerOperations.sol\";\nimport \"../interfaces/ITroveManager.sol\";\nimport \"../dependencies/PropelMath.sol\";\nimport \"../dependencies/PropelBase.sol\";\nimport \"../dependencies/BlastWrapper.sol\";\nimport \"../dependencies/console.sol\";\n\n/**\n    @title Propel Liquidation Manager\n    @notice Based on Liquity's `TroveManager`\n            https://github.com/liquity/dev/blob/main/packages/contracts/contracts/TroveManager.sol\n\n            This contract has a 1:n relationship with `TroveManager`, handling liquidations\n            for every active collateral within the system.\n\n            Anyone can call to liquidate an eligible trove at any time. There is no requirement\n            that liquidations happen in order according to trove ICRs. There are three ways that\n            a liquidation can occur:\n\n            1. ICR <= 100\n               The trove's entire debt and collateral is redistributed between remaining active troves.\n\n            2. 100 < ICR < MCR\n               The trove is liquidated using stability pool deposits. The collateral is distributed\n               amongst stability pool depositors. If the stability pool's balance is insufficient to\n               completely repay the trove, the remaining debt and collateral is redistributed between\n               the remaining active troves.\n\n            3. MCR <= ICR < TCR && TCR < CCR\n               The trove is liquidated using stability pool deposits. Collateral equal to MCR of\n               the value of the debt is distributed between stability pool depositors. The remaining\n               collateral is left claimable by the trove owner.\n */\ncontract LiquidationManager is PropelBase, BlastWrapper {\n\tIStabilityPool public immutable stabilityPool;\n\tIBorrowerOperations public immutable borrowerOperations;\n\taddress public immutable factory;\n\n\tuint256 private constant _100pct = 1000000000000000000; // 1e18 == 100%\n\n\tmapping(ITroveManager => bool) internal _enabledTroveManagers;\n\n\t/*\n\t * --- Variable container structs for liquidations ---\n\t *\n\t * These structs are used to hold, return and assign variables inside the liquidation functions,\n\t * in order to avoid the error: \"CompilerError: Stack too deep\".\n\t **/\n\n\tstruct TroveManagerValues {\n\t\tuint256 price;\n\t\tuint256 MCR;\n\t\tbool sunsetting;\n\t}\n\n\tstruct LiquidationValues {\n\t\tuint256 entireTroveDebt;\n\t\tuint256 entireTroveColl;\n\t\tuint256 interest;\n\t\tuint256 collGasCompensation;\n\t\tuint256 debtGasCompensation;\n\t\tuint256 debtToOffset;\n\t\tuint256 collToSendToSP;\n\t\tuint256 debtToRedistribute;\n\t\tuint256 collToRedistribute;\n\t\tuint256 collSurplus;\n\t}\n\n\tstruct LiquidationTotals {\n\t\tuint256 totalCollInSequence;\n\t\tuint256 totalDebtInSequence;\n\t\tuint256 totalInterest;\n\t\tuint256 totalCollGasCompensation;\n\t\tuint256 totalDebtGasCompensation;\n\t\tuint256 totalDebtToOffset;\n\t\tuint256 totalCollToSendToSP;\n\t\tuint256 totalDebtToRedistribute;\n\t\tuint256 totalCollToRedistribute;\n\t\tuint256 totalCollSurplus;\n\t}\n\n\tevent TroveUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 _stake, TroveManagerOperation _operation);\n\tevent TroveLiquidated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 _interest, TroveManagerOperation _operation);\n\tevent Liquidation(uint256 _liquidatedDebt, uint256 _liquidatedColl, uint256 _collGasCompensation, uint256 _debtGasCompensation, uint256 _interest);\n\tevent TroveUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 stake, uint8 operation);\n\tevent TroveLiquidated(address indexed _borrower, uint256 _debt, uint256 _coll, uint8 operation);\n\n\tenum TroveManagerOperation {\n\t\tapplyPendingRewards,\n\t\tliquidateInNormalMode,\n\t\tliquidateInRecoveryMode,\n\t\tredeemCollateral\n\t}\n\n\tconstructor(IPropelCore _propelCore, IStabilityPool _stabilityPoolAddress, IBorrowerOperations _borrowerOperations, address _factory, uint256 _gasCompensation) BlastWrapper(_propelCore) PropelBase(_gasCompensation) {\n\t\tstabilityPool = _stabilityPoolAddress;\n\t\tborrowerOperations = _borrowerOperations;\n\t\tfactory = _factory;\n\t}\n\n\tfunction enableTroveManager(ITroveManager _troveManager) external {\n\t\trequire(msg.sender == factory, \"Not factory\");\n\t\t_enabledTroveManagers[_troveManager] = true;\n\t}\n\n\t// --- Trove Liquidation functions ---\n\n\t/**\n        @notice Liquidate a single trove\n        @dev Reverts if the trove is not active, or cannot be liquidated\n        @param borrower Borrower address to liquidate\n     */\n\tfunction liquidate(ITroveManager troveManager, address borrower) external {\n\t\trequire(troveManager.getTroveStatus(borrower) == 1, \"TroveManager: Trove does not exist or is closed\");\n\n\t\taddress[] memory borrowers = new address[](1);\n\t\tborrowers[0] = borrower;\n\t\tbatchLiquidateTroves(troveManager, borrowers);\n\t}\n\n\t/**\n        @notice Liquidate a sequence of troves\n        @dev Iterates through troves starting with the lowest ICR\n        @param maxTrovesToLiquidate The maximum number of troves to liquidate\n        @param maxICR Maximum ICR to liquidate. Should be set to MCR if the system\n                      is not in recovery mode, to minimize gas costs for this call.\n     */\n\tfunction liquidateTroves(ITroveManager troveManager, uint256 maxTrovesToLiquidate, uint256 maxICR) external {\n\t\trequire(_enabledTroveManagers[troveManager], \"TroveManager not approved\");\n\t\tIStabilityPool stabilityPoolCached = stabilityPool;\n\t\ttroveManager.distributeInterestDebt();\n\n\t\tISortedTroves sortedTrovesCached = ISortedTroves(troveManager.sortedTroves());\n\n\t\tLiquidationValues memory singleLiquidation;\n\t\tLiquidationTotals memory totals;\n\t\tTroveManagerValues memory troveManagerValues;\n\n\t\tuint256 trovesRemaining = maxTrovesToLiquidate;\n\t\tuint256 troveCount = troveManager.getTroveOwnersCount();\n\t\ttroveManagerValues.price = troveManager.fetchPrice();\n\t\ttroveManagerValues.sunsetting = troveManager.sunsetting();\n\t\ttroveManagerValues.MCR = troveManager.MCR();\n\t\tuint debtInStabPool = stabilityPoolCached.getTotalPropelUSDDeposits();\n\n\t\twhile (trovesRemaining > 0 && troveCount > 1) {\n\t\t\taddress account = sortedTrovesCached.getLast();\n\t\t\tuint ICR = troveManager.getCurrentICR(account, troveManagerValues.price);\n\t\t\tif (ICR > maxICR) {\n\t\t\t\t// set to 0 to ensure the next if block evaluates false\n\t\t\t\ttrovesRemaining = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (ICR <= _100pct) {\n\t\t\t\tsingleLiquidation = _liquidateWithoutSP(troveManager, account);\n\t\t\t\t_applyLiquidationValuesToTotals(totals, singleLiquidation);\n\t\t\t} else if (ICR < troveManagerValues.MCR) {\n\t\t\t\tsingleLiquidation = _liquidateNormalMode(troveManager, account, debtInStabPool, troveManagerValues.sunsetting);\n\t\t\t\tdebtInStabPool -= singleLiquidation.debtToOffset;\n\t\t\t\t_applyLiquidationValuesToTotals(totals, singleLiquidation);\n\t\t\t} else break; // break if the loop reaches a Trove with ICR >= MCR\n\t\t\tunchecked {\n\t\t\t\t--trovesRemaining;\n\t\t\t\t--troveCount;\n\t\t\t}\n\t\t}\n\t\tif (trovesRemaining > 0 && !troveManagerValues.sunsetting && troveCount > 1) {\n\t\t\t(uint entireSystemColl, uint entireSystemDebt) = borrowerOperations.getGlobalSystemBalances();\n\t\t\tentireSystemColl -= totals.totalCollToSendToSP * troveManagerValues.price;\n\t\t\tentireSystemDebt -= totals.totalDebtToOffset;\n\t\t\taddress nextAccount = sortedTrovesCached.getLast();\n\t\t\tITroveManager _troveManager = troveManager; //stack too deep workaround\n\t\t\twhile (trovesRemaining > 0 && troveCount > 1) {\n\t\t\t\tuint ICR = troveManager.getCurrentICR(nextAccount, troveManagerValues.price);\n\t\t\t\tif (ICR > maxICR) break;\n\t\t\t\tunchecked {\n\t\t\t\t\t--trovesRemaining;\n\t\t\t\t}\n\t\t\t\taddress account = nextAccount;\n\t\t\t\tnextAccount = sortedTrovesCached.getPrev(account);\n\n\t\t\t\tuint256 TCR = PropelMath._computeCR(entireSystemColl, entireSystemDebt);\n\t\t\t\tif (TCR >= CCR || ICR >= TCR) break;\n\t\t\t\tsingleLiquidation = _tryLiquidateWithCap(_troveManager, account, debtInStabPool, troveManagerValues.MCR, troveManagerValues.price);\n\t\t\t\tif (singleLiquidation.debtToOffset == 0) continue;\n\t\t\t\tdebtInStabPool -= singleLiquidation.debtToOffset;\n\t\t\t\tentireSystemColl -= (singleLiquidation.collToSendToSP + singleLiquidation.collSurplus) * troveManagerValues.price;\n\t\t\t\tentireSystemDebt -= singleLiquidation.debtToOffset;\n\t\t\t\t_applyLiquidationValuesToTotals(totals, singleLiquidation);\n\t\t\t\tunchecked {\n\t\t\t\t\t--troveCount;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\trequire(totals.totalDebtInSequence > 0, \"nothing to liquidate\");\n\t\tif (totals.totalDebtToOffset > 0 || totals.totalCollToSendToSP > 0) {\n\t\t\t// Move liquidated collateral and Debt to the appropriate pools\n\t\t\tstabilityPoolCached.offset(troveManager.collateralToken(), totals.totalDebtToOffset, totals.totalCollToSendToSP);\n\t\t\ttroveManager.decreaseDebtAndSendCollateral(address(stabilityPoolCached), totals.totalDebtToOffset, totals.totalCollToSendToSP);\n\t\t}\n\t\ttroveManager.finalizeLiquidation(msg.sender, totals.totalDebtToRedistribute, totals.totalCollToRedistribute, totals.totalCollSurplus, totals.totalDebtGasCompensation, totals.totalCollGasCompensation, totals.totalInterest);\n\n\t\temit Liquidation(totals.totalDebtInSequence, totals.totalCollInSequence - totals.totalCollGasCompensation - totals.totalCollSurplus, totals.totalCollGasCompensation, totals.totalDebtGasCompensation, totals.totalInterest);\n\t}\n\n\t/**\n        @notice Liquidate a custom list of troves\n        @dev Reverts if there is not a single trove that can be liquidated\n        @param _troveArray List of borrower addresses to liquidate. Troves that were already\n                           liquidated, or cannot be liquidated, are ignored.\n     */\n\t/*\n\t * Attempt to liquidate a custom list of troves provided by the caller.\n\t */\n\tfunction batchLiquidateTroves(ITroveManager troveManager, address[] memory _troveArray) public {\n\t\trequire(_enabledTroveManagers[troveManager], \"TroveManager not approved\");\n\t\trequire(_troveArray.length != 0, \"TroveManager: Calldata address array must not be empty\");\n\t\ttroveManager.distributeInterestDebt();\n\n\t\tLiquidationValues memory singleLiquidation;\n\t\tLiquidationTotals memory totals;\n\t\tTroveManagerValues memory troveManagerValues;\n\n\t\tIStabilityPool stabilityPoolCached = stabilityPool;\n\t\tuint debtInStabPool = stabilityPoolCached.getTotalPropelUSDDeposits();\n\t\ttroveManagerValues.price = troveManager.fetchPrice();\n\t\ttroveManagerValues.sunsetting = troveManager.sunsetting();\n\t\ttroveManagerValues.MCR = troveManager.MCR();\n\t\tuint troveCount = troveManager.getTroveOwnersCount();\n\t\tuint length = _troveArray.length;\n\t\tuint troveIter;\n\t\twhile (troveIter < length && troveCount > 1) {\n\t\t\t// first iteration round, when all liquidated troves have ICR < MCR we do not need to track TCR\n\t\t\taddress account = _troveArray[troveIter];\n\n\t\t\t// closed / non-existent troves return an ICR of type(uint).max and are ignored\n\t\t\tuint ICR = troveManager.getCurrentICR(account, troveManagerValues.price);\n\t\t\tif (ICR <= _100pct) {\n\t\t\t\tsingleLiquidation = _liquidateWithoutSP(troveManager, account);\n\t\t\t} else if (ICR < troveManagerValues.MCR) {\n\t\t\t\tsingleLiquidation = _liquidateNormalMode(troveManager, account, debtInStabPool, troveManagerValues.sunsetting);\n\t\t\t\tdebtInStabPool -= singleLiquidation.debtToOffset;\n\t\t\t} else {\n\t\t\t\t// As soon as we find a trove with ICR >= MCR we need to start tracking the global TCR with the next loop\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t_applyLiquidationValuesToTotals(totals, singleLiquidation);\n\t\t\tunchecked {\n\t\t\t\t++troveIter;\n\t\t\t\t--troveCount;\n\t\t\t}\n\t\t}\n\n\t\tif (troveIter < length && troveCount > 1) {\n\t\t\t// second iteration round, if we receive a trove with ICR > MCR and need to track TCR\n\t\t\t(uint256 entireSystemColl, uint256 entireSystemDebt) = borrowerOperations.getGlobalSystemBalances();\n\t\t\tentireSystemColl -= totals.totalCollToSendToSP * troveManagerValues.price;\n\t\t\tentireSystemDebt -= totals.totalDebtToOffset;\n\t\t\twhile (troveIter < length && troveCount > 1) {\n\t\t\t\taddress account = _troveArray[troveIter];\n\t\t\t\tuint ICR = troveManager.getCurrentICR(account, troveManagerValues.price);\n\t\t\t\tunchecked {\n\t\t\t\t\t++troveIter;\n\t\t\t\t}\n\t\t\t\tif (ICR <= _100pct) {\n\t\t\t\t\tsingleLiquidation = _liquidateWithoutSP(troveManager, account);\n\t\t\t\t} else if (ICR < troveManagerValues.MCR) {\n\t\t\t\t\tsingleLiquidation = _liquidateNormalMode(troveManager, account, debtInStabPool, troveManagerValues.sunsetting);\n\t\t\t\t} else {\n\t\t\t\t\tuint256 TCR = PropelMath._computeCR(entireSystemColl, entireSystemDebt);\n\t\t\t\t\tif (TCR >= CCR || ICR >= TCR || troveManagerValues.sunsetting) continue;\n\t\t\t\t\tsingleLiquidation = _tryLiquidateWithCap(troveManager, account, debtInStabPool, troveManagerValues.MCR, troveManagerValues.price);\n\t\t\t\t\tif (singleLiquidation.debtToOffset == 0) continue;\n\t\t\t\t}\n\n\t\t\t\tdebtInStabPool -= singleLiquidation.debtToOffset;\n\t\t\t\tentireSystemColl -= (singleLiquidation.collToSendToSP + singleLiquidation.collSurplus) * troveManagerValues.price;\n\t\t\t\tentireSystemDebt -= singleLiquidation.debtToOffset;\n\t\t\t\t_applyLiquidationValuesToTotals(totals, singleLiquidation);\n\t\t\t\tunchecked {\n\t\t\t\t\t--troveCount;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\trequire(totals.totalDebtInSequence > 0, \"TroveManager: nothing to liquidate\");\n\n\t\tif (totals.totalDebtToOffset > 0 || totals.totalCollToSendToSP > 0) {\n\t\t\t// Move liquidated collateral and Debt to the appropriate pools\n\t\t\tstabilityPoolCached.offset(troveManager.collateralToken(), totals.totalDebtToOffset, totals.totalCollToSendToSP);\n\t\t\ttroveManager.decreaseDebtAndSendCollateral(address(stabilityPoolCached), totals.totalDebtToOffset, totals.totalCollToSendToSP);\n\t\t}\n\t\ttroveManager.finalizeLiquidation(msg.sender, totals.totalDebtToRedistribute, totals.totalCollToRedistribute, totals.totalCollSurplus, totals.totalDebtGasCompensation, totals.totalCollGasCompensation, totals.totalInterest);\n\n\t\temit Liquidation(totals.totalDebtInSequence, totals.totalCollInSequence - totals.totalCollGasCompensation - totals.totalCollSurplus, totals.totalCollGasCompensation, totals.totalDebtGasCompensation, totals.totalInterest);\n\t}\n\n\t/**\n        @dev Perform a \"normal\" liquidation, where 100% < ICR < MCR. The trove\n             is liquidated as much as possible using the stability pool. Any\n             remaining debt and collateral are redistributed between active troves.\n     */\n\tfunction _liquidateNormalMode(ITroveManager troveManager, address _borrower, uint256 _debtInStabPool, bool sunsetting) internal returns (LiquidationValues memory singleLiquidation) {\n\t\tuint pendingDebtReward;\n\t\tuint pendingCollReward;\n\n\t\t(singleLiquidation.entireTroveDebt, singleLiquidation.entireTroveColl, pendingDebtReward, pendingCollReward) = troveManager.getEntireDebtAndColl(_borrower);\n\t\tsingleLiquidation.interest = troveManager.getTroveInterest(_borrower, singleLiquidation.entireTroveDebt);\n\t\tsingleLiquidation.entireTroveDebt = singleLiquidation.entireTroveDebt + singleLiquidation.interest;\n\t\ttroveManager.movePendingTroveRewardsToActiveBalances(pendingDebtReward, pendingCollReward);\n\n\t\tsingleLiquidation.collGasCompensation = _getCollGasCompensation(singleLiquidation.entireTroveColl);\n\t\tsingleLiquidation.debtGasCompensation = DEBT_GAS_COMPENSATION;\n\t\tuint256 collToLiquidate = singleLiquidation.entireTroveColl - singleLiquidation.collGasCompensation;\n\n\t\t(singleLiquidation.debtToOffset, singleLiquidation.collToSendToSP, singleLiquidation.debtToRedistribute, singleLiquidation.collToRedistribute) = _getOffsetAndRedistributionVals(singleLiquidation.entireTroveDebt, collToLiquidate, _debtInStabPool, sunsetting);\n\n\t\ttroveManager.closeTroveByLiquidation(_borrower);\n\t\temit TroveLiquidated(_borrower, singleLiquidation.entireTroveDebt, singleLiquidation.entireTroveColl, singleLiquidation.interest, TroveManagerOperation.liquidateInNormalMode);\n\t\temit TroveUpdated(_borrower, 0, 0, 0, TroveManagerOperation.liquidateInNormalMode);\n\t\treturn singleLiquidation;\n\t}\n\n\t/**\n        @dev Attempt to liquidate a single trove in recovery mode.\n             If MCR <= ICR < current TCR (accounting for the preceding liquidations in the current sequence)\n             and there is Debt in the Stability Pool, only offset, with no redistribution,\n             but at a capped rate of 1.1 and only if the whole debt can be liquidated.\n             The remainder due to the capped rate will be claimable as collateral surplus.\n     */\n\tfunction _tryLiquidateWithCap(ITroveManager troveManager, address _borrower, uint256 _debtInStabPool, uint256 _MCR, uint256 _price) internal returns (LiquidationValues memory singleLiquidation) {\n\t\tuint entireTroveDebt;\n\t\tuint entireTroveColl;\n\t\tuint pendingDebtReward;\n\t\tuint pendingCollReward;\n\n\t\t(entireTroveDebt, entireTroveColl, pendingDebtReward, pendingCollReward) = troveManager.getEntireDebtAndColl(_borrower);\n\t\tuint256 interest = troveManager.getTroveInterest(_borrower, entireTroveDebt);\n\t\tentireTroveDebt = entireTroveDebt + interest;\n\t\tif (entireTroveDebt > _debtInStabPool) {\n\t\t\t// do not liquidate if the entire trove cannot be liquidated via SP\n\t\t\treturn singleLiquidation;\n\t\t}\n\n\t\ttroveManager.movePendingTroveRewardsToActiveBalances(pendingDebtReward, pendingCollReward);\n\n\t\tsingleLiquidation.entireTroveDebt = entireTroveDebt + interest;\n\t\tsingleLiquidation.interest = interest;\n\t\tsingleLiquidation.entireTroveColl = entireTroveColl;\n\t\tuint256 collToOffset = (singleLiquidation.entireTroveDebt * _MCR) / _price;\n\n\t\tsingleLiquidation.collGasCompensation = _getCollGasCompensation(collToOffset);\n\t\tsingleLiquidation.debtGasCompensation = DEBT_GAS_COMPENSATION;\n\n\t\tsingleLiquidation.debtToOffset = singleLiquidation.entireTroveDebt;\n\t\tsingleLiquidation.collToSendToSP = collToOffset - singleLiquidation.collGasCompensation;\n\n\t\ttroveManager.closeTroveByLiquidation(_borrower);\n\n\t\tuint256 collSurplus = entireTroveColl - collToOffset;\n\t\tif (collSurplus > 0) {\n\t\t\tsingleLiquidation.collSurplus = collSurplus;\n\t\t\ttroveManager.addCollateralSurplus(_borrower, collSurplus);\n\t\t}\n\n\t\temit TroveLiquidated(_borrower, entireTroveDebt, singleLiquidation.collToSendToSP, interest, TroveManagerOperation.liquidateInRecoveryMode);\n\t\temit TroveUpdated(_borrower, 0, 0, 0, TroveManagerOperation.liquidateInRecoveryMode);\n\n\t\treturn singleLiquidation;\n\t}\n\n\t/**\n        @dev Liquidate a trove without using the stability pool. All debt and collateral\n             are distributed porportionally between the remaining active troves.\n     */\n\tfunction _liquidateWithoutSP(ITroveManager troveManager, address _borrower) internal returns (LiquidationValues memory singleLiquidation) {\n\t\tuint pendingDebtReward;\n\t\tuint pendingCollReward;\n\n\t\t(singleLiquidation.entireTroveDebt, singleLiquidation.entireTroveColl, pendingDebtReward, pendingCollReward) = troveManager.getEntireDebtAndColl(_borrower);\n\t\tsingleLiquidation.interest = troveManager.getTroveInterest(_borrower, singleLiquidation.entireTroveDebt);\n\t\tsingleLiquidation.entireTroveDebt = singleLiquidation.entireTroveDebt + singleLiquidation.interest;\n\t\tsingleLiquidation.collGasCompensation = _getCollGasCompensation(singleLiquidation.entireTroveColl);\n\t\tsingleLiquidation.debtGasCompensation = DEBT_GAS_COMPENSATION;\n\t\ttroveManager.movePendingTroveRewardsToActiveBalances(pendingDebtReward, pendingCollReward);\n\n\t\tsingleLiquidation.debtToOffset = 0;\n\t\tsingleLiquidation.collToSendToSP = 0;\n\t\tsingleLiquidation.debtToRedistribute = singleLiquidation.entireTroveDebt;\n\t\tsingleLiquidation.collToRedistribute = singleLiquidation.entireTroveColl - singleLiquidation.collGasCompensation;\n\n\t\ttroveManager.closeTroveByLiquidation(_borrower);\n\t\temit TroveLiquidated(_borrower, singleLiquidation.entireTroveDebt, singleLiquidation.entireTroveColl, singleLiquidation.interest, TroveManagerOperation.liquidateInRecoveryMode);\n\t\temit TroveUpdated(_borrower, 0, 0, 0, TroveManagerOperation.liquidateInRecoveryMode);\n\t\treturn singleLiquidation;\n\t}\n\n\t/* In a full liquidation, returns the values for a trove's coll and debt to be offset, and coll and debt to be\n\t * redistributed to active troves.\n\t */\n\tfunction _getOffsetAndRedistributionVals(uint256 _debt, uint256 _coll, uint256 _debtInStabPool, bool sunsetting) internal pure returns (uint256 debtToOffset, uint256 collToSendToSP, uint256 debtToRedistribute, uint256 collToRedistribute) {\n\t\tif (_debtInStabPool > 0 && !sunsetting) {\n\t\t\t/*\n\t\t\t * Offset as much debt & collateral as possible against the Stability Pool, and redistribute the remainder\n\t\t\t * between all active troves.\n\t\t\t *\n\t\t\t *  If the trove's debt is larger than the deposited Debt in the Stability Pool:\n\t\t\t *\n\t\t\t *  - Offset an amount of the trove's debt equal to the Debt in the Stability Pool\n\t\t\t *  - Send a fraction of the trove's collateral to the Stability Pool, equal to the fraction of its offset debt\n\t\t\t *\n\t\t\t */\n\t\t\tdebtToOffset = PropelMath._min(_debt, _debtInStabPool);\n\t\t\tcollToSendToSP = (_coll * debtToOffset) / _debt;\n\t\t\tdebtToRedistribute = _debt - debtToOffset;\n\t\t\tcollToRedistribute = _coll - collToSendToSP;\n\t\t} else {\n\t\t\tdebtToOffset = 0;\n\t\t\tcollToSendToSP = 0;\n\t\t\tdebtToRedistribute = _debt;\n\t\t\tcollToRedistribute = _coll;\n\t\t}\n\t}\n\n\t/**\n        @dev Adds values from `singleLiquidation` to `totals`\n             Calling this function mutates `totals`, the change is done in-place\n             to avoid needless expansion of memory\n     */\n\tfunction _applyLiquidationValuesToTotals(LiquidationTotals memory totals, LiquidationValues memory singleLiquidation) internal pure {\n\t\t// Tally all the values with their respective running totals\n\t\ttotals.totalCollGasCompensation = totals.totalCollGasCompensation + singleLiquidation.collGasCompensation;\n\t\ttotals.totalDebtGasCompensation = totals.totalDebtGasCompensation + singleLiquidation.debtGasCompensation;\n\t\ttotals.totalDebtInSequence = totals.totalDebtInSequence + singleLiquidation.entireTroveDebt;\n\t\ttotals.totalInterest = totals.totalInterest + singleLiquidation.interest;\n\t\ttotals.totalCollInSequence = totals.totalCollInSequence + singleLiquidation.entireTroveColl;\n\t\ttotals.totalDebtToOffset = totals.totalDebtToOffset + singleLiquidation.debtToOffset;\n\t\ttotals.totalCollToSendToSP = totals.totalCollToSendToSP + singleLiquidation.collToSendToSP;\n\t\ttotals.totalDebtToRedistribute = totals.totalDebtToRedistribute + singleLiquidation.debtToRedistribute;\n\t\ttotals.totalCollToRedistribute = totals.totalCollToRedistribute + singleLiquidation.collToRedistribute;\n\t\ttotals.totalCollSurplus = totals.totalCollSurplus + singleLiquidation.collSurplus;\n\t}\n}\n"
    },
    "contracts/core/PriceFeed.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"../interfaces/IPyth.sol\";\nimport \"../dependencies/PropelMath.sol\";\nimport \"../dependencies/PropelOwnable.sol\";\nimport \"../dependencies/console.sol\";\n\n/**\n    @title Propel Multi Token Price Feed\n    @notice Based on Gravita's PriceFeed:\n            https://github.com/Gravita-Protocol/Gravita-SmartContracts/blob/9b69d555f3567622b0f84df8c7f1bb5cd9323573/contracts/PriceFeed.sol\n\n            Propel's implementation additionally caches price values within a block and incorporates exchange rate settings for derivative tokens (e.g. stETH -> wstETH).\n */\ncontract PriceFeed is PropelOwnable {\n\tstruct OracleRecord {\n\t\tIPyth pyth;\n\t\tuint32 decimals;\n\t\tuint32 heartbeat;\n\t\tbool isFeedWorking;\n\t}\n\n\tstruct PriceRecord {\n\t\tuint96 scaledPrice;\n\t\tuint32 timestamp;\n\t\tuint32 lastUpdated;\n\t}\n\n\tstruct FeedResponse {\n\t\tint64 price;\n\t\t// Confidence interval around the price\n\t\tuint64 conf;\n\t\t// Price exponent\n\t\tint32 expo;\n\t\t// Unix timestamp describing when the price was published\n\t\tuint publishTime;\n\t\tbool success;\n\t}\n\n\t// Custom Errors --------------------------------------------------------------------------------------------------\n\n\terror PriceFeed__InvalidFeedResponseError(address token);\n\terror PriceFeed__FeedFrozenError(address token);\n\terror PriceFeed__UnknownFeedError(address token);\n\terror PriceFeed__HeartbeatOutOfBoundsError();\n\n\t// Events ---------------------------------------------------------------------------------------------------------\n\n\tevent NewOracleRegistered(address token, address pyth);\n\tevent PriceFeedStatusUpdated(address token, address oracle, bool isWorking);\n\tevent PriceRecordUpdated(address indexed token, uint256 _price);\n\n\t/** Constants ---------------------------------------------------------------------------------------------------- */\n\n\t// Used to convert a chainlink price answer to an 18-digit precision uint\n\tuint256 public constant TARGET_DIGITS = 18;\n\n\t// Responses are considered stale this many seconds after the oracle's heartbeat\n\tuint256 public constant RESPONSE_TIMEOUT_BUFFER = 0 hours;\n\n\tbytes32 public constant ETHUSDFEED = 0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace;\n\n\t// State ------------------------------------------------------------------------------------------------------------\n\tmapping(address => OracleRecord) public oracleRecords;\n\tmapping(address => PriceRecord) public priceRecords;\n\n\tconstructor(IPropelCore _PropelCore) PropelOwnable(_PropelCore) {}\n\n\t// Admin routines ---------------------------------------------------------------------------------------------------\n\n\t/**\n        @notice Set the oracle for a specific token\n        @param _token Address of the LST to set the oracle for\n        @param _pyth Address of the pyth oracle for this LST\n        @param _heartbeat Oracle heartbeat, in seconds\n     */\n\tfunction setOracle(address _token, address _pyth, uint32 _heartbeat) public onlyOwner {\n\t\tif (_heartbeat > 86400) revert PriceFeed__HeartbeatOutOfBoundsError();\n\t\tIPyth newFeed = IPyth(_pyth);\n\t\tFeedResponse memory currResponse = _fetchFeedResponses(newFeed);\n\t\tif (!_isFeedWorking(currResponse)) {\n\t\t\trevert PriceFeed__InvalidFeedResponseError(_token);\n\t\t}\n\t\tif (_isPriceStale(currResponse.publishTime, _heartbeat)) {\n\t\t\trevert PriceFeed__FeedFrozenError(_token);\n\t\t}\n\n\t\tOracleRecord memory record = OracleRecord({ pyth: newFeed, decimals: uint32(-currResponse.expo), heartbeat: _heartbeat, isFeedWorking: true });\n\n\t\toracleRecords[_token] = record;\n\t\tPriceRecord memory _priceRecord = priceRecords[_token];\n\n\t\t_processFeedResponses(_token, record, currResponse, _priceRecord);\n\t\temit NewOracleRegistered(_token, _pyth);\n\t}\n\n\t// Public functions -------------------------------------------------------------------------------------------------\n\n\t/**\n        @notice Get the latest price returned from the oracle\n        @dev You can obtain these values by calling `TroveManager.fetchPrice()`\n             rather than directly interacting with this contract.\n        @param _token Token to fetch the price for\n        @return The latest valid price for the requested token\n     */\n\tfunction fetchPrice(address _token) public returns (uint256) {\n\t\tPriceRecord memory priceRecord = priceRecords[_token];\n\t\tif (priceRecord.lastUpdated == block.timestamp) {\n\t\t\t// We short-circuit only if the price was already correct in the current block\n\t\t\treturn priceRecord.scaledPrice;\n\t\t}\n\t\tif (priceRecord.lastUpdated == 0) {\n\t\t\trevert PriceFeed__UnknownFeedError(_token);\n\t\t}\n\n\t\tOracleRecord storage oracle = oracleRecords[_token];\n\n\t\tFeedResponse memory currResponse = _fetchFeedResponses(oracle.pyth);\n\t\tif (!_isFeedWorking(currResponse)) {\n\t\t\trevert PriceFeed__InvalidFeedResponseError(_token);\n\t\t}\n\n\t\tif (_isPriceStale(currResponse.publishTime, oracle.heartbeat)) {\n\t\t\trevert PriceFeed__FeedFrozenError(_token);\n\t\t}\n\n\t\treturn _processFeedResponses(_token, oracle, currResponse, priceRecord);\n\t}\n\n\t// Internal functions -----------------------------------------------------------------------------------------------\n\n\tfunction _processFeedResponses(address _token, OracleRecord memory oracle, FeedResponse memory _currResponse, PriceRecord memory priceRecord) internal returns (uint256) {\n\t\tuint32 decimals = oracle.decimals;\n\t\tbool isValidResponse = _isFeedWorking(_currResponse) && !_isPriceStale(_currResponse.publishTime, oracle.heartbeat);\n\t\tif (isValidResponse) {\n\t\t\tuint256 scaledPrice = _scalePriceByDigits(_currResponse.price, decimals);\n\t\t\tif (!oracle.isFeedWorking) {\n\t\t\t\t_updateFeedStatus(_token, oracle, true);\n\t\t\t}\n\t\t\t_storePrice(_token, scaledPrice, _currResponse.publishTime);\n\t\t\treturn scaledPrice;\n\t\t} else {\n\t\t\tif (oracle.isFeedWorking) {\n\t\t\t\t_updateFeedStatus(_token, oracle, false);\n\t\t\t}\n\t\t\tif (_isPriceStale(priceRecord.timestamp, oracle.heartbeat)) {\n\t\t\t\trevert PriceFeed__FeedFrozenError(_token);\n\t\t\t}\n\t\t\treturn priceRecord.scaledPrice;\n\t\t}\n\t}\n\n\tfunction _fetchFeedResponses(IPyth oracle) internal view returns (FeedResponse memory currResponse) {\n\t\tcurrResponse = _fetchCurrentFeedResponse(oracle);\n\t}\n\n\tfunction _isPriceStale(uint256 _priceTimestamp, uint256 _heartbeat) internal view returns (bool) {\n\t\treturn block.timestamp - _priceTimestamp > _heartbeat + RESPONSE_TIMEOUT_BUFFER;\n\t}\n\n\tfunction _isFeedWorking(FeedResponse memory _currentResponse) internal view returns (bool) {\n\t\treturn _isValidResponse(_currentResponse);\n\t}\n\n\tfunction _isValidResponse(FeedResponse memory _response) internal view returns (bool) {\n\t\treturn (_response.success) && (_response.publishTime != 0) && (_response.publishTime <= block.timestamp) && (_response.price != 0);\n\t}\n\n\tfunction _scalePriceByDigits(int64 _price, uint256 _answerDigits) internal pure returns (uint256) {\n\t\tif (_answerDigits == TARGET_DIGITS) {\n\t\t\treturn uint256(uint64(_price));\n\t\t} else if (_answerDigits < TARGET_DIGITS) {\n\t\t\t// Scale the returned price value up to target precision\n\t\t\treturn uint256(uint64(_price)) * (10 ** (TARGET_DIGITS - _answerDigits));\n\t\t} else {\n\t\t\t// Scale the returned price value down to target precision\n\t\t\treturn uint256(uint64(_price)) / (10 ** (_answerDigits - TARGET_DIGITS));\n\t\t}\n\t}\n\n\tfunction _updateFeedStatus(address _token, OracleRecord memory _oracle, bool _isWorking) internal {\n\t\toracleRecords[_token].isFeedWorking = _isWorking;\n\t\temit PriceFeedStatusUpdated(_token, address(_oracle.pyth), _isWorking);\n\t}\n\n\tfunction _storePrice(address _token, uint256 _price, uint256 _timestamp) internal {\n\t\tpriceRecords[_token] = PriceRecord({ scaledPrice: uint96(_price), timestamp: uint32(_timestamp), lastUpdated: uint32(block.timestamp) });\n\t\temit PriceRecordUpdated(_token, _price);\n\t}\n\n\tfunction _fetchCurrentFeedResponse(IPyth _priceAggregator) internal view returns (FeedResponse memory response) {\n\t\ttry _priceAggregator.getPriceUnsafe(ETHUSDFEED) returns (IPyth.Price memory price) {\n\t\t\tresponse.price = price.price;\n\t\t\tresponse.conf = price.conf;\n\t\t\tresponse.expo = price.expo;\n\t\t\tresponse.publishTime = price.publishTime;\n\t\t\tresponse.success = true;\n\t\t} catch {\n\t\t\t// If call to Chainlink aggregator reverts, return a zero response with success = false\n\t\t\treturn response;\n\t\t}\n\t}\n}\n"
    },
    "contracts/core/Propel.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\";\n\nimport \"../interfaces/IPropel.sol\";\nimport \"../interfaces/IEsPropel.sol\";\nimport \"../dependencies/PropelOwnable.sol\";\n\ncontract Propel is ERC20Burnable, ERC20Permit, PropelOwnable, IPropel {\n\tIEsPropel public esPropel;\n\taddress public vest;\n\n\tuint256 public immutable MaxCap = 1000000000 ether;\n\n\tconstructor(IPropelCore _propelCore, IEsPropel _esPropel, address _vest) ERC20(\"Propel Coin\", \"Propel\") ERC20Permit(\"Propel Coin\") PropelOwnable(_propelCore) {\n\t\tesPropel = _esPropel;\n\t\tvest = _vest;\n\t}\n\n\tfunction mint(address account, uint256 amount) external onlyOwner {\n\t\trequire(totalSupply() + esPropel.totalSupply() + amount <= MaxCap, \"Propel: exceeds MaxCap\");\n\t\t_mint(account, amount);\n\t}\n\n\tfunction mintEsPropel(address account, uint256 amount) external onlyOwner {\n\t\trequire(totalSupply() + esPropel.totalSupply() + amount <= MaxCap, \"Propel: exceeds MaxCap\");\n\t\tesPropel.mint(account, amount);\n\t}\n\n\tfunction propel2EsPropel(address account, uint256 amount) external override {\n\t\t_burn(msg.sender, amount);\n\t\tesPropel.mint(account, amount);\n\t\temit PropelToEsPropel(account, amount);\n\t}\n\n\tfunction esPropel2Propel(address account, uint256 amount) external override {\n\t\trequire(msg.sender == vest, \"Propel: Caller is not Vest\");\n\t\tesPropel.burnFromPropel(msg.sender, amount);\n\t\t_mint(account, amount);\n\t\temit EsPropelToPropel(account, amount);\n\t}\n\n\tfunction burn(uint256 amount) public override(ERC20Burnable, IPropel) {\n\t\tERC20Burnable.burn(amount);\n\t}\n\n\tfunction burnFrom(address account, uint256 amount) public override(ERC20Burnable, IPropel) {\n\t\tERC20Burnable.burnFrom(account, amount);\n\t}\n}\n"
    },
    "contracts/core/PropelCore.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"../interfaces/IBlast.sol\";\nimport \"../interfaces/IWETH.sol\";\n\n/**\n    @title Propel PropelCore\n    @notice Single source of truth for system-wide values and contract ownership.\n\n            Ownership of this contract should be the Propel DAO via `AdminVoting`.\n            Other ownable Propel contracts inherit their ownership from this contract\n            using `PropelOwnable`.\n */\ncontract PropelCore {\n\taddress public feeReceiver;\n\taddress public priceFeed;\n\tIWETH public WETH;\n\tIBlast public blast;\n\n\taddress public owner;\n\taddress public pendingOwner;\n\tuint256 public ownershipTransferDeadline;\n\n\taddress public guardian;\n\n\t// We enforce a three day delay between committing and applying\n\t// an ownership change, as a sanity check on a proposed new owner\n\t// and to give users time to react in case the act is malicious.\n\tuint256 public constant OWNERSHIP_TRANSFER_DELAY = 86400 * 3;\n\n\t// System-wide pause. When true, disables trove adjustments across all collaterals.\n\tbool public paused;\n\n\t// System-wide start time, rounded down the nearest epoch week.\n\t// Other contracts that require access to this should inherit `SystemStart`.\n\tuint256 public immutable startTime;\n\n\tevent NewOwnerCommitted(address owner, address pendingOwner, uint256 deadline);\n\n\tevent NewOwnerAccepted(address oldOwner, address owner);\n\n\tevent NewOwnerRevoked(address owner, address revokedOwner);\n\n\tevent FeeReceiverSet(address feeReceiver);\n\n\tevent GuardianSet(address guardian);\n\n\tevent Paused();\n\n\tevent Unpaused();\n\n\tconstructor(address _owner, address _guardian, address _feeReceiver, IWETH _WETH, IBlast _blast) {\n\t\towner = _owner;\n\t\tstartTime = (block.timestamp / 1 weeks) * 1 weeks;\n\t\tguardian = _guardian;\n\t\tfeeReceiver = _feeReceiver;\n\t\tWETH = _WETH;\n\t\tblast = _blast;\n\n\t\temit GuardianSet(_guardian);\n\t\temit FeeReceiverSet(_feeReceiver);\n\t}\n\n\tmodifier onlyOwner() {\n\t\trequire(msg.sender == owner, \"Only owner\");\n\t\t_;\n\t}\n\n\t/**\n\t * @notice Set the receiver of all fees across the protocol\n\t * @param _feeReceiver Address of the fee's recipient\n\t */\n\tfunction setFeeReceiver(address _feeReceiver) external onlyOwner {\n\t\tfeeReceiver = _feeReceiver;\n\t\temit FeeReceiverSet(_feeReceiver);\n\t}\n\n\t/**\n     * @notice Set the guardian address\n               The guardian can execute some emergency actions\n     * @param _guardian Guardian address\n     */\n\tfunction setGuardian(address _guardian) external onlyOwner {\n\t\tguardian = _guardian;\n\t\temit GuardianSet(_guardian);\n\t}\n\n\t/**\n\t * @notice Sets the global pause state of the protocol\n\t *         Pausing is used to mitigate risks in exceptional circumstances\n\t *         Functionalities affected by pausing are:\n\t *         - New borrowing is not possible\n\t *         - New collateral deposits are not possible\n\t *         - New stability pool deposits are not possible\n\t * @param _paused If true the protocol is paused\n\t */\n\tfunction setPaused(bool _paused) external {\n\t\trequire((_paused && msg.sender == guardian) || msg.sender == owner, \"Unauthorized\");\n\t\tpaused = _paused;\n\t\tif (_paused) {\n\t\t\temit Paused();\n\t\t} else {\n\t\t\temit Unpaused();\n\t\t}\n\t}\n\n\tfunction commitTransferOwnership(address newOwner) external onlyOwner {\n\t\tpendingOwner = newOwner;\n\t\townershipTransferDeadline = block.timestamp + OWNERSHIP_TRANSFER_DELAY;\n\n\t\temit NewOwnerCommitted(msg.sender, newOwner, block.timestamp + OWNERSHIP_TRANSFER_DELAY);\n\t}\n\n\tfunction acceptTransferOwnership() external {\n\t\trequire(msg.sender == pendingOwner, \"Only new owner\");\n\t\trequire(block.timestamp >= ownershipTransferDeadline, \"Deadline not passed\");\n\n\t\temit NewOwnerAccepted(owner, msg.sender);\n\n\t\towner = pendingOwner;\n\t\tpendingOwner = address(0);\n\t\townershipTransferDeadline = 0;\n\t}\n\n\tfunction revokeTransferOwnership() external onlyOwner {\n\t\temit NewOwnerRevoked(msg.sender, pendingOwner);\n\n\t\tpendingOwner = address(0);\n\t\townershipTransferDeadline = 0;\n\t}\n}\n"
    },
    "contracts/core/PropelUSD.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol\";\nimport \"../interfaces/IPropelCore.sol\";\nimport \"../dependencies/BlastWrapper.sol\";\n\n/**\n    @title Propel Debt Token \"PropelUSD\"\n    @notice CDP minted against collateral deposits within `TroveManager`.\n            This contract has a 1:n relationship with multiple deployments of `TroveManager`,\n            each of which hold one collateral type which may be used to mint this token.\n */\ncontract PropelUSD is BlastWrapper, ERC20Burnable, ERC20Permit, ERC20FlashMint {\n\t// --- ERC 3156 Data ---\n\tuint256 public constant FLASH_LOAN_FEE = 9; // 1 = 0.0001%\n\t// Amount of debt to be locked in gas pool on opening troves\n\tuint256 public immutable DEBT_GAS_COMPENSATION;\n\n\tIPropelCore private immutable propelCore;\n\n\taddress public immutable stabilityPoolAddress;\n\taddress public immutable borrowerOperationsAddress;\n\taddress public immutable factory;\n\taddress public immutable gasPool;\n\n\tmapping(address => bool) public troveManager;\n\n\tconstructor(IPropelCore _propelCore, address _stabilityPoolAddress, address _borrowerOperationsAddress, address _factory, address _gasPool, uint256 _gasCompensation) BlastWrapper(_propelCore) ERC20(\"Propel USD\", \"pUSD\") ERC20Permit(\"Propel USD\") {\n\t\tstabilityPoolAddress = _stabilityPoolAddress;\n\t\tpropelCore = _propelCore;\n\t\tborrowerOperationsAddress = _borrowerOperationsAddress;\n\t\tfactory = _factory;\n\t\tgasPool = _gasPool;\n\n\t\tDEBT_GAS_COMPENSATION = _gasCompensation;\n\t}\n\n\tfunction enableTroveManager(address _troveManager) external {\n\t\trequire(msg.sender == factory, \"!Factory\");\n\t\ttroveManager[_troveManager] = true;\n\t}\n\n\t// --- Functions for intra-Propel calls ---\n\n\tfunction mintWithGasCompensation(address _account, uint256 _amount) external returns (bool) {\n\t\trequire(msg.sender == borrowerOperationsAddress, \"PropelUSD: Caller not BO\");\n\t\t_mint(_account, _amount);\n\t\t_mint(gasPool, DEBT_GAS_COMPENSATION);\n\n\t\treturn true;\n\t}\n\n\tfunction burnWithGasCompensation(address _account, uint256 _amount) external returns (bool) {\n\t\trequire(msg.sender == borrowerOperationsAddress, \"PropelUSD: Caller not BO\");\n\t\t_burn(_account, _amount);\n\t\t_burn(gasPool, DEBT_GAS_COMPENSATION);\n\t\treturn true;\n\t}\n\n\tfunction mint(address _account, uint256 _amount) external {\n\t\trequire(msg.sender == borrowerOperationsAddress || troveManager[msg.sender], \"PropelUSD: Caller not BO/TM\");\n\t\t_mint(_account, _amount);\n\t}\n\n\tfunction burn(address _account, uint256 _amount) external {\n\t\trequire(troveManager[msg.sender], \"PropelUSD: Caller not TroveManager\");\n\t\t_burn(_account, _amount);\n\t}\n\n\tfunction sendToSP(address _sender, uint256 _amount) external {\n\t\trequire(msg.sender == stabilityPoolAddress, \"PropelUSD: Caller not StabilityPool\");\n\t\t_transfer(_sender, msg.sender, _amount);\n\t}\n\n\tfunction returnFromPool(address _poolAddress, address _receiver, uint256 _amount) external {\n\t\trequire(msg.sender == stabilityPoolAddress || troveManager[msg.sender], \"PropelUSD: Caller not TM/SP\");\n\t\t_transfer(_poolAddress, _receiver, _amount);\n\t}\n\n\t// --- External functions ---\n\n\tfunction transfer(address recipient, uint256 amount) public override returns (bool) {\n\t\t_requireValidRecipient(recipient);\n\t\treturn super.transfer(recipient, amount);\n\t}\n\n\tfunction transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {\n\t\t_requireValidRecipient(recipient);\n\t\treturn super.transferFrom(sender, recipient, amount);\n\t}\n\n\t/**\n\t * @dev Returns the fee applied when doing flash loans. This function calls\n\t * the {_flashFee} function which returns the fee applied when doing flash\n\t * loans.\n\t * @param token The token to be flash loaned.\n\t * @param amount The amount of tokens to be loaned.\n\t * @return The fees applied to the corresponding flash loan.\n\t */\n\tfunction flashFee(address token, uint256 amount) public view override returns (uint256) {\n\t\treturn token == address(this) ? _flashFee(amount) : 0;\n\t}\n\n\t/**\n\t * @dev Returns the fee applied when doing flash loans. By default this\n\t * implementation has 0 fees. This function can be overloaded to make\n\t * the flash loan mechanism deflationary.\n\t * @param amount The amount of tokens to be loaned.\n\t * @return The fees applied to the corresponding flash loan.\n\t */\n\tfunction _flashFee(uint256 amount) internal pure returns (uint256) {\n\t\treturn (amount * FLASH_LOAN_FEE) / 10000;\n\t}\n\n\tfunction _flashFeeReceiver() internal view override returns (address) {\n\t\treturn propelCore.feeReceiver();\n\t}\n\n\t// --- 'require' functions ---\n\tfunction _requireValidRecipient(address _recipient) internal view {\n\t\trequire(_recipient != address(0) && _recipient != address(this), \"PropelUSD: Cannot transfer tokens directly to the Debt token contract or the zero address\");\n\t\trequire(_recipient != stabilityPoolAddress && !troveManager[_recipient] && _recipient != borrowerOperationsAddress, \"PropelUSD: Cannot transfer tokens directly to the StabilityPool, TroveManager or BorrowerOps\");\n\t}\n}\n"
    },
    "contracts/core/StabilityPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../dependencies/BlastWrapper.sol\";\nimport \"../dependencies/SystemStart.sol\";\nimport \"../dependencies/PropelMath.sol\";\nimport \"../interfaces/IPropelUSD.sol\";\nimport \"../interfaces/ICommunityIssuance.sol\";\nimport \"../interfaces/IStabilityPool.sol\";\n\n/**\n    @title Propel Stability Pool\n    @notice Based on Liquity's `StabilityPool`\n            https://github.com/liquity/dev/blob/main/packages/contracts/contracts/StabilityPool.sol\n\n            Propel's implementation is modified to support multiple collaterals. Deposits into\n            the stability pool may be used to liquidate any supported collateral type.\n */\ncontract StabilityPool is IStabilityPool, BlastWrapper {\n\tusing SafeERC20 for IERC20;\n\n\tuint256 public constant DECIMAL_PRECISION = 1e18;\n\tuint128 public constant SUNSET_DURATION = 180 days;\n\n\tIPropelUSD public immutable PropelUSD;\n\taddress public immutable factory;\n\taddress public immutable liquidationManager;\n\tICommunityIssuance public immutable communityIssuance;\n\n\tmapping(IERC20 => uint256) public indexByCollateral;\n\tIERC20[] public collateralTokens;\n\n\t// Tracker for Debt held in the pool. Changes when users deposit/withdraw, and when Trove debt is offset.\n\tuint256 internal totalPropelUSDDeposits;\n\tmapping(address => uint256) public lockTime;\n\tmapping(address => uint256) public accountDeposits; // depositor address -> initial deposit\n\tmapping(address => Snapshots) public depositSnapshots; // depositor address -> snapshots struct\n\n\t// index values are mapped against the values within `collateralTokens`\n\tmapping(address => uint256[256]) public depositSums; // depositor address -> sums\n\n\tmapping(address => uint256[256]) public collateralGainsByDepositor;\n\n\tmapping(address => uint256) private storedPendingReward;\n\n\t/*  Product 'P': Running product by which to multiply an initial deposit, in order to find the current compounded deposit,\n\t * after a series of liquidations have occurred, each of which cancel some debt with the deposit.\n\t *\n\t * During its lifetime, a deposit's value evolves from d_t to d_t * P / P_t , where P_t\n\t * is the snapshot of P taken at the instant the deposit was made. 18-digit decimal.\n\t */\n\tuint256 public P = DECIMAL_PRECISION;\n\n\tuint256 public constant SCALE_FACTOR = 1e9;\n\n\t// Each time the scale of P shifts by SCALE_FACTOR, the scale is incremented by 1\n\tuint128 public currentScale;\n\n\t// With each offset that fully empties the Pool, the epoch is incremented by 1\n\tuint128 public currentEpoch;\n\n\t/* collateral Gain sum 'S': During its lifetime, each deposit d_t earns a collateral gain of ( d_t * [S - S_t] )/P_t, where S_t\n\t * is the depositor's snapshot of S taken at the time t when the deposit was made.\n\t *\n\t * The 'S' sums are stored in a nested mapping (epoch => scale => sum):\n\t *\n\t * - The inner mapping records the sum S at different scales\n\t * - The outer mapping records the (scale => sum) mappings, for different epochs.\n\t */\n\n\t// index values are mapped against the values within `collateralTokens`\n\tmapping(uint128 => mapping(uint128 => uint256[256])) public epochToScaleToSums;\n\n\t/*\n\t * Similarly, the sum 'G' is used to calculate esPropel gains. During it's lifetime, each deposit d_t earns a esPropel gain of\n\t *  ( d_t * [G - G_t] )/P_t, where G_t is the depositor's snapshot of G taken at time t when  the deposit was made.\n\t *\n\t *  esPropel reward events occur are triggered by depositor operations (new deposit, topup, withdrawal), and liquidations.\n\t *  In each case, the esPropel reward is issued (i.e. G is updated), before other state changes are made.\n\t */\n\tmapping(uint128 => mapping(uint128 => uint256)) public epochToScaleToG;\n\n\t// Error tracker for the error correction in the esPropel issuance calculation\n\tuint256 public lastEsPropelError;\n\t// Error trackers for the error correction in the offset calculation\n\tuint256[256] public lastCollateralError_Offset;\n\tuint256 public lastDebtLossError_Offset;\n\n\tmapping(uint16 => SunsetIndex) public _sunsetIndexes;\n\n\tQueue public queue;\n\n\tstruct Snapshots {\n\t\tuint256 P;\n\t\tuint256 G;\n\t\tuint128 scale;\n\t\tuint128 epoch;\n\t}\n\n\tstruct SunsetIndex {\n\t\tuint128 idx;\n\t\tuint128 expiry;\n\t}\n\tstruct Queue {\n\t\tuint16 firstSunsetIndexKey;\n\t\tuint16 nextSunsetIndexKey;\n\t}\n\n\tconstructor(IPropelCore _PropelCore, IPropelUSD _PropelUSDAddress, address _factory, address _liquidationManager, address _communityIssuance) BlastWrapper(_PropelCore) {\n\t\tPropelUSD = _PropelUSDAddress;\n\t\tfactory = _factory;\n\t\tliquidationManager = _liquidationManager;\n\t\tcommunityIssuance = ICommunityIssuance(_communityIssuance);\n\t}\n\n\tfunction enableCollateral(IERC20 _collateral) external {\n\t\trequire(msg.sender == factory, \"Not factory\");\n\t\tuint256 length = collateralTokens.length;\n\t\tbool collateralEnabled;\n\t\tfor (uint256 i = 0; i < length; i++) {\n\t\t\tif (collateralTokens[i] == IERC20(_collateral)) {\n\t\t\t\tcollateralEnabled = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!collateralEnabled) {\n\t\t\tQueue memory queueCached = queue;\n\t\t\tif (queueCached.nextSunsetIndexKey > queueCached.firstSunsetIndexKey) {\n\t\t\t\tSunsetIndex memory sIdx = _sunsetIndexes[queueCached.firstSunsetIndexKey];\n\t\t\t\tif (sIdx.expiry < block.timestamp) {\n\t\t\t\t\tdelete _sunsetIndexes[queue.firstSunsetIndexKey++];\n\t\t\t\t\t_overwriteCollateral(_collateral, sIdx.idx);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcollateralTokens.push(_collateral);\n\t\t\tindexByCollateral[_collateral] = collateralTokens.length;\n\t\t} else {\n\t\t\t// revert if the factory is trying to deploy a new TM with a sunset collateral\n\t\t\trequire(indexByCollateral[_collateral] > 0, \"Collateral is sunsetting\");\n\t\t}\n\t}\n\n\tfunction _overwriteCollateral(IERC20 _newCollateral, uint256 idx) internal {\n\t\trequire(indexByCollateral[_newCollateral] == 0, \"Collateral must be sunset\");\n\t\tuint256 length = collateralTokens.length;\n\t\trequire(idx < length, \"Index too large\");\n\t\tuint256 externalLoopEnd = currentEpoch;\n\t\tuint256 internalLoopEnd = currentScale;\n\t\tfor (uint128 i; i <= externalLoopEnd; ) {\n\t\t\tfor (uint128 j; j <= internalLoopEnd; ) {\n\t\t\t\tepochToScaleToSums[i][j][idx] = 0;\n\t\t\t\tunchecked {\n\t\t\t\t\t++j;\n\t\t\t\t}\n\t\t\t}\n\t\t\tunchecked {\n\t\t\t\t++i;\n\t\t\t}\n\t\t}\n\t\tindexByCollateral[_newCollateral] = idx + 1;\n\t\temit CollateralOverwritten(address(collateralTokens[idx]), address(_newCollateral));\n\t\tcollateralTokens[idx] = _newCollateral;\n\t}\n\n\t/**\n     * @notice Starts sunsetting a collateral\n     *         During sunsetting liquidated collateral handoff to the SP will revert\n        @dev IMPORTANT: When sunsetting a collateral, `TroveManager.startSunset`\n                        should be called on all TM linked to that collateral\n        @param collateral Collateral to sunset\n\n     */\n\tfunction startCollateralSunset(IERC20 collateral) external onlyOwner {\n\t\trequire(indexByCollateral[collateral] > 0, \"Collateral already sunsetting\");\n\t\t_sunsetIndexes[queue.nextSunsetIndexKey++] = SunsetIndex(uint128(indexByCollateral[collateral] - 1), uint128(block.timestamp + SUNSET_DURATION));\n\t\tdelete indexByCollateral[collateral]; //This will prevent calls to the SP in case of liquidations\n\t}\n\n\tfunction getTotalPropelUSDDeposits() external view returns (uint256) {\n\t\treturn totalPropelUSDDeposits;\n\t}\n\n\t// --- External Depositor Functions ---\n\n\t/*  provideToSP():\n\t *\n\t * - Triggers a esPropel issuance, based on time passed since the last issuance. The esPropel issuance is shared between *all* depositors and front ends\n\t * - Tags the deposit with the provided front end tag param, if it's a new deposit\n\t * - Sends depositor's accumulated gains (esPropel, collateral) to depositor\n\t * - Sends the tagged front end's accumulated esPropel gains to the tagged front end\n\t * - Increases deposit and tagged front end's stake, and takes new snapshots for each.\n\t */\n\tfunction provideToSP(uint256 _amount) external {\n\t\trequire(!PropelCore.paused(), \"Deposits are paused\");\n\t\trequire(_amount > 0, \"StabilityPool: Amount must be non-zero\");\n\t\tlockTime[msg.sender] = block.timestamp;\n\t\t_triggerRewardIssuance();\n\n\t\t_accrueDepositorCollateralGain(msg.sender);\n\n\t\tuint256 compoundedDeposit = getCompoundedDeposit(msg.sender);\n\n\t\t_accrueRewards(msg.sender);\n\n\t\tPropelUSD.sendToSP(msg.sender, _amount);\n\t\tuint256 newTotalPropelUSDDeposits = totalPropelUSDDeposits + _amount;\n\t\ttotalPropelUSDDeposits = newTotalPropelUSDDeposits;\n\t\temit StabilityPoolPropelUSDBalanceUpdated(newTotalPropelUSDDeposits);\n\n\t\tuint256 newDeposit = compoundedDeposit + _amount;\n\t\taccountDeposits[msg.sender] = newDeposit;\n\n\t\t_updateSnapshots(msg.sender, newDeposit);\n\t\temit UserDepositChanged(msg.sender, newDeposit);\n\t}\n\n\t/*  withdrawFromSP():\n\t *\n\t * - Triggers a esPropel issuance, based on time passed since the last issuance. The esPropel issuance is shared between *all* depositors and front ends\n\t * - Removes the deposit's front end tag if it is a full withdrawal\n\t * - Sends all depositor's accumulated gains (esPropel, collateral) to depositor\n\t * - Sends the tagged front end's accumulated esPropel gains to the tagged front end\n\t * - Decreases deposit and tagged front end's stake, and takes new snapshots for each.\n\t *\n\t * If _amount > userDeposit, the user withdraws all of their compounded deposit.\n\t */\n\tfunction withdrawFromSP(uint256 _amount) external {\n\t\tuint256 initialDeposit = accountDeposits[msg.sender];\n\t\trequire(initialDeposit > 0, \"StabilityPool: User must have a non-zero deposit\");\n\t\trequire(lockTime[msg.sender] != block.timestamp, \"StabilityPool: Withdrawal is locked\");\n\t\t_triggerRewardIssuance();\n\n\t\t_accrueDepositorCollateralGain(msg.sender);\n\n\t\tuint256 compoundedDeposit = getCompoundedDeposit(msg.sender);\n\t\tuint256 debtToWithdraw = PropelMath._min(_amount, compoundedDeposit);\n\n\t\t_accrueRewards(msg.sender);\n\n\t\tif (debtToWithdraw > 0) {\n\t\t\tPropelUSD.returnFromPool(address(this), msg.sender, debtToWithdraw);\n\t\t\t_decreaseDebt(debtToWithdraw);\n\t\t}\n\n\t\t// Update deposit\n\t\tuint256 newDeposit = compoundedDeposit - debtToWithdraw;\n\t\taccountDeposits[msg.sender] = newDeposit;\n\n\t\t_updateSnapshots(msg.sender, newDeposit);\n\t\temit UserDepositChanged(msg.sender, newDeposit);\n\t}\n\n\tfunction claim(address recipient, uint256[] memory collateralIndexes) external {\n\t\tuint256 initialDeposit = accountDeposits[msg.sender];\n\t\trequire(initialDeposit > 0, \"StabilityPool: User must have a non-zero deposit\");\n\n\t\t_triggerRewardIssuance();\n\n\t\t_accrueDepositorCollateralGain(msg.sender);\n\n\t\tuint256 compoundedDeposit = getCompoundedDeposit(msg.sender);\n\t\t_accrueRewards(msg.sender);\n\n\t\t// Update deposit\n\t\tuint256 newDeposit = compoundedDeposit;\n\t\taccountDeposits[msg.sender] = newDeposit;\n\n\t\t_updateSnapshots(msg.sender, newDeposit);\n\t\temit UserDepositChanged(msg.sender, newDeposit);\n\t\tuint256 amount = _claimReward(msg.sender);\n\t\tif (amount > 0) {\n\t\t\tcommunityIssuance.sendEsPropel(recipient, amount);\n\t\t}\n\t\temit RewardClaimed(msg.sender, recipient, amount);\n\t\t_claimCollateralGains(recipient, collateralIndexes);\n\t}\n\n\t// --- esPropel issuance functions ---\n\n\tfunction _triggerRewardIssuance() internal {\n\t\t_updateG(communityIssuance.issueEsPropel());\n\t}\n\n\tfunction _updateG(uint256 _esPropelIssuance) internal {\n\t\tuint256 totalDebt = totalPropelUSDDeposits; // cached to save an SLOAD\n\t\t/*\n\t\t * When total deposits is 0, G is not updated. In this case, the Propel issued can not be obtained by later\n\t\t * depositors - it is missed out on, and remains in the balanceof the Treasury contract.\n\t\t *\n\t\t */\n\t\tif (totalDebt == 0 || _esPropelIssuance == 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tuint256 esPropelPerUnitStaked = _computeEsPropelPerUnitStaked(_esPropelIssuance, totalDebt);\n\t\tuint128 currentEpochCached = currentEpoch;\n\t\tuint128 currentScaleCached = currentScale;\n\t\tuint256 marginalPropelGain = esPropelPerUnitStaked * P;\n\t\tuint256 newG = epochToScaleToG[currentEpochCached][currentScaleCached] + marginalPropelGain;\n\t\tepochToScaleToG[currentEpochCached][currentScaleCached] = newG;\n\n\t\temit G_Updated(newG, currentEpochCached, currentScaleCached);\n\t}\n\n\tfunction _computeEsPropelPerUnitStaked(uint256 _esPropelIssuance, uint256 _totalPropelUSDDeposits) internal returns (uint256) {\n\t\t/*\n\t\t * Calculate the esPropel-per-unit staked.  Division uses a \"feedback\" error correction, to keep the\n\t\t * cumulative error low in the running total G:\n\t\t *\n\t\t * 1) Form a numerator which compensates for the floor division error that occurred the last time this\n\t\t * function was called.\n\t\t * 2) Calculate \"per-unit-staked\" ratio.\n\t\t * 3) Multiply the ratio back by its denominator, to reveal the current floor division error.\n\t\t * 4) Store this error for use in the next correction when this function is called.\n\t\t * 5) Note: static analysis tools complain about this \"division before multiplication\", however, it is intended.\n\t\t */\n\t\tuint256 esPropelNumerator = (_esPropelIssuance * DECIMAL_PRECISION) + lastEsPropelError;\n\n\t\tuint256 esPropelPerUnitStaked = esPropelNumerator / _totalPropelUSDDeposits;\n\t\tlastEsPropelError = esPropelNumerator - (esPropelPerUnitStaked * _totalPropelUSDDeposits);\n\n\t\treturn esPropelPerUnitStaked;\n\t}\n\n\t// --- Liquidation functions ---\n\n\t/*\n\t * Cancels out the specified debt against the Debt contained in the Stability Pool (as far as possible)\n\t */\n\tfunction offset(IERC20 collateral, uint256 _debtToOffset, uint256 _collToAdd) external virtual {\n\t\t_offset(collateral, _debtToOffset, _collToAdd);\n\t}\n\n\tfunction _offset(IERC20 collateral, uint256 _debtToOffset, uint256 _collToAdd) internal {\n\t\trequire(msg.sender == liquidationManager, \"StabilityPool: Caller is not Liquidation Manager\");\n\t\tuint256 idx = indexByCollateral[collateral];\n\t\tidx -= 1;\n\n\t\tuint256 totalDebt = totalPropelUSDDeposits; // cached to save an SLOAD\n\t\tif (totalDebt == 0 || _debtToOffset == 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t_triggerRewardIssuance();\n\n\t\t(uint256 collateralGainPerUnitStaked, uint256 debtLossPerUnitStaked) = _computeRewardsPerUnitStaked(_collToAdd, _debtToOffset, totalDebt, idx);\n\n\t\t_updateRewardSumAndProduct(collateralGainPerUnitStaked, debtLossPerUnitStaked, idx); // updates S and P\n\n\t\t// Cancel the liquidated Debt debt with the Debt in the stability pool\n\t\t_decreaseDebt(_debtToOffset);\n\t}\n\n\t// --- Offset helper functions ---\n\n\tfunction _computeRewardsPerUnitStaked(uint256 _collToAdd, uint256 _debtToOffset, uint256 _totalPropelUSDDeposits, uint256 idx) internal returns (uint256 collateralGainPerUnitStaked, uint256 debtLossPerUnitStaked) {\n\t\t/*\n\t\t * Compute the Debt and collateral rewards. Uses a \"feedback\" error correction, to keep\n\t\t * the cumulative error in the P and S state variables low:\n\t\t *\n\t\t * 1) Form numerators which compensate for the floor division errors that occurred the last time this\n\t\t * function was called.\n\t\t * 2) Calculate \"per-unit-staked\" ratios.\n\t\t * 3) Multiply each ratio back by its denominator, to reveal the current floor division error.\n\t\t * 4) Store these errors for use in the next correction when this function is called.\n\t\t * 5) Note: static analysis tools complain about this \"division before multiplication\", however, it is intended.\n\t\t */\n\t\tuint256 collateralNumerator = (_collToAdd * DECIMAL_PRECISION) + lastCollateralError_Offset[idx];\n\n\t\tif (_debtToOffset == _totalPropelUSDDeposits) {\n\t\t\tdebtLossPerUnitStaked = DECIMAL_PRECISION; // When the Pool depletes to 0, so does each deposit\n\t\t\tlastDebtLossError_Offset = 0;\n\t\t} else {\n\t\t\tuint256 debtLossNumerator = (_debtToOffset * DECIMAL_PRECISION) - lastDebtLossError_Offset;\n\t\t\t/*\n\t\t\t * Add 1 to make error in quotient positive. We want \"slightly too much\" Debt loss,\n\t\t\t * which ensures the error in any given CompoundedDeposit favors the Stability Pool.\n\t\t\t */\n\t\t\tdebtLossPerUnitStaked = (debtLossNumerator / _totalPropelUSDDeposits) + 1;\n\t\t\tlastDebtLossError_Offset = (debtLossPerUnitStaked * _totalPropelUSDDeposits) - debtLossNumerator;\n\t\t}\n\n\t\tcollateralGainPerUnitStaked = collateralNumerator / _totalPropelUSDDeposits;\n\t\tlastCollateralError_Offset[idx] = collateralNumerator - (collateralGainPerUnitStaked * _totalPropelUSDDeposits);\n\n\t\treturn (collateralGainPerUnitStaked, debtLossPerUnitStaked);\n\t}\n\n\t// Update the Stability Pool reward sum S and product P\n\tfunction _updateRewardSumAndProduct(uint256 _collateralGainPerUnitStaked, uint256 _debtLossPerUnitStaked, uint256 idx) internal {\n\t\tuint256 currentP = P;\n\t\tuint256 newP;\n\n\t\t/*\n\t\t * The newProductFactor is the factor by which to change all deposits, due to the depletion of Stability Pool Debt in the liquidation.\n\t\t * We make the product factor 0 if there was a pool-emptying. Otherwise, it is (1 - DebtLossPerUnitStaked)\n\t\t */\n\t\tuint256 newProductFactor = uint256(DECIMAL_PRECISION) - _debtLossPerUnitStaked;\n\n\t\tuint128 currentScaleCached = currentScale;\n\t\tuint128 currentEpochCached = currentEpoch;\n\t\tuint256 currentS = epochToScaleToSums[currentEpochCached][currentScaleCached][idx];\n\n\t\t/*\n\t\t * Calculate the new S first, before we update P.\n\t\t * The collateral gain for any given depositor from a liquidation depends on the value of their deposit\n\t\t * (and the value of totalDeposits) prior to the Stability being depleted by the debt in the liquidation.\n\t\t *\n\t\t * Since S corresponds to collateral gain, and P to deposit loss, we update S first.\n\t\t */\n\t\tuint256 marginalCollateralGain = _collateralGainPerUnitStaked * currentP;\n\t\tuint256 newS = currentS + marginalCollateralGain;\n\t\tepochToScaleToSums[currentEpochCached][currentScaleCached][idx] = newS;\n\t\temit S_Updated(idx, newS, currentEpochCached, currentScaleCached);\n\n\t\t// If the Stability Pool was emptied, increment the epoch, and reset the scale and product P\n\t\tif (newProductFactor == 0) {\n\t\t\tcurrentEpoch = currentEpochCached + 1;\n\t\t\temit EpochUpdated(currentEpoch);\n\t\t\tcurrentScale = 0;\n\t\t\temit ScaleUpdated(currentScale);\n\t\t\tnewP = DECIMAL_PRECISION;\n\n\t\t\t// If multiplying P by a non-zero product factor would reduce P below the scale boundary, increment the scale\n\t\t} else if ((currentP * newProductFactor) / DECIMAL_PRECISION < SCALE_FACTOR) {\n\t\t\tnewP = (currentP * newProductFactor * SCALE_FACTOR) / DECIMAL_PRECISION;\n\t\t\tcurrentScale = currentScaleCached + 1;\n\t\t\temit ScaleUpdated(currentScale);\n\t\t} else {\n\t\t\tnewP = (currentP * newProductFactor) / DECIMAL_PRECISION;\n\t\t}\n\n\t\trequire(newP > 0, \"NewP\");\n\t\tP = newP;\n\t\temit P_Updated(newP);\n\t}\n\n\tfunction _decreaseDebt(uint256 _amount) internal {\n\t\tuint256 newTotalPropelUSDDeposits = totalPropelUSDDeposits - _amount;\n\t\ttotalPropelUSDDeposits = newTotalPropelUSDDeposits;\n\t\temit StabilityPoolPropelUSDBalanceUpdated(newTotalPropelUSDDeposits);\n\t}\n\n\t// --- Reward calculator functions for depositor and front end ---\n\n\t/* Calculates the collateral gain earned by the deposit since its last snapshots were taken.\n\t * Given by the formula:  E = d0 * (S - S(0))/P(0)\n\t * where S(0) and P(0) are the depositor's snapshots of the sum S and product P, respectively.\n\t * d0 is the last recorded deposit value.\n\t */\n\tfunction getDepositorCollateralGain(address _depositor) external view returns (uint256[] memory collateralGains) {\n\t\tcollateralGains = new uint256[](collateralTokens.length);\n\n\t\tuint256 P_Snapshot = depositSnapshots[_depositor].P;\n\t\tif (P_Snapshot == 0) return collateralGains;\n\t\tuint256[256] memory depositorGains = collateralGainsByDepositor[_depositor];\n\t\tuint256 initialDeposit = accountDeposits[_depositor];\n\t\tuint128 epochSnapshot = depositSnapshots[_depositor].epoch;\n\t\tuint128 scaleSnapshot = depositSnapshots[_depositor].scale;\n\t\tuint256[256] memory sums = epochToScaleToSums[epochSnapshot][scaleSnapshot];\n\t\tuint256[256] memory nextSums = epochToScaleToSums[epochSnapshot][scaleSnapshot + 1];\n\t\tuint256[256] memory depSums = depositSums[_depositor];\n\n\t\tfor (uint256 i = 0; i < collateralGains.length; i++) {\n\t\t\tcollateralGains[i] = depositorGains[i];\n\t\t\tif (sums[i] == 0) continue; // Collateral was overwritten or not gains\n\t\t\tuint256 firstPortion = sums[i] - depSums[i];\n\t\t\tuint256 secondPortion = nextSums[i] / SCALE_FACTOR;\n\t\t\tcollateralGains[i] += (initialDeposit * (firstPortion + secondPortion)) / P_Snapshot / DECIMAL_PRECISION;\n\t\t}\n\t\treturn collateralGains;\n\t}\n\n\tfunction _accrueDepositorCollateralGain(address _depositor) private returns (bool hasGains) {\n\t\tuint256[256] storage depositorGains = collateralGainsByDepositor[_depositor];\n\t\tuint256 collaterals = collateralTokens.length;\n\t\tuint256 initialDeposit = accountDeposits[_depositor];\n\t\thasGains = false;\n\t\tif (initialDeposit == 0) {\n\t\t\treturn hasGains;\n\t\t}\n\n\t\tuint128 epochSnapshot = depositSnapshots[_depositor].epoch;\n\t\tuint128 scaleSnapshot = depositSnapshots[_depositor].scale;\n\t\tuint256 P_Snapshot = depositSnapshots[_depositor].P;\n\n\t\tuint256[256] storage sums = epochToScaleToSums[epochSnapshot][scaleSnapshot];\n\t\tuint256[256] storage nextSums = epochToScaleToSums[epochSnapshot][scaleSnapshot + 1];\n\t\tuint256[256] storage depSums = depositSums[_depositor];\n\n\t\tfor (uint256 i = 0; i < collaterals; i++) {\n\t\t\tif (sums[i] == 0) continue; // Collateral was overwritten or not gains\n\t\t\thasGains = true;\n\t\t\tuint256 firstPortion = sums[i] - depSums[i];\n\t\t\tuint256 secondPortion = nextSums[i] / SCALE_FACTOR;\n\t\t\tdepositorGains[i] += (initialDeposit * (firstPortion + secondPortion)) / P_Snapshot / DECIMAL_PRECISION;\n\t\t}\n\t\treturn (hasGains);\n\t}\n\n\t/*\n\t * Calculate the esPropel gain earned by a deposit since its last snapshots were taken.\n\t * Given by the formula:  esPropel = d0 * (G - G(0))/P(0)\n\t * where G(0) and P(0) are the depositor's snapshots of the sum G and product P, respectively.\n\t * d0 is the last recorded deposit value.\n\t */\n\tfunction claimableReward(address _depositor) external view returns (uint256) {\n\t\tuint256 totalDebt = totalPropelUSDDeposits;\n\t\tuint256 initialDeposit = accountDeposits[_depositor];\n\n\t\tif (totalDebt == 0 || initialDeposit == 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tuint256 esPropelNumerator = (communityIssuance.pendingReward() * DECIMAL_PRECISION) + lastEsPropelError;\n\t\tuint256 esPropelPerUnitStaked = esPropelNumerator / totalDebt;\n\t\tuint256 marginalEsPropelGain = esPropelPerUnitStaked * P;\n\n\t\tSnapshots memory snapshots = depositSnapshots[_depositor];\n\t\tuint128 epochSnapshot = snapshots.epoch;\n\t\tuint128 scaleSnapshot = snapshots.scale;\n\t\tuint256 firstPortion;\n\t\tuint256 secondPortion;\n\t\tif (scaleSnapshot == currentScale) {\n\t\t\tfirstPortion = epochToScaleToG[epochSnapshot][scaleSnapshot] - snapshots.G + marginalEsPropelGain;\n\t\t\tsecondPortion = epochToScaleToG[epochSnapshot][scaleSnapshot + 1] / SCALE_FACTOR;\n\t\t} else {\n\t\t\tfirstPortion = epochToScaleToG[epochSnapshot][scaleSnapshot] - snapshots.G;\n\t\t\tsecondPortion = (epochToScaleToG[epochSnapshot][scaleSnapshot + 1] + marginalEsPropelGain) / SCALE_FACTOR;\n\t\t}\n\n\t\treturn (initialDeposit * (firstPortion + secondPortion)) / snapshots.P / DECIMAL_PRECISION;\n\t}\n\n\tfunction _claimableReward(address _depositor) private view returns (uint256) {\n\t\tuint256 initialDeposit = accountDeposits[_depositor];\n\t\tif (initialDeposit == 0) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tSnapshots memory snapshots = depositSnapshots[_depositor];\n\n\t\treturn _getEsPropelGainFromSnapshots(initialDeposit, snapshots);\n\t}\n\n\tfunction _getEsPropelGainFromSnapshots(uint256 initialStake, Snapshots memory snapshots) internal view returns (uint256) {\n\t\t/*\n\t\t * Grab the sum 'G' from the epoch at which the stake was made. The esPropel gain may span up to one scale change.\n\t\t * If it does, the second portion of the esPropel gain is scaled by 1e9.\n\t\t * If the gain spans no scale change, the second portion will be 0.\n\t\t */\n\t\tuint128 epochSnapshot = snapshots.epoch;\n\t\tuint128 scaleSnapshot = snapshots.scale;\n\t\tuint256 G_Snapshot = snapshots.G;\n\t\tuint256 P_Snapshot = snapshots.P;\n\n\t\tuint256 firstPortion = epochToScaleToG[epochSnapshot][scaleSnapshot] - G_Snapshot;\n\t\tuint256 secondPortion = epochToScaleToG[epochSnapshot][scaleSnapshot + 1] / SCALE_FACTOR;\n\n\t\tuint256 esPropelGain = (initialStake * (firstPortion + secondPortion)) / P_Snapshot / DECIMAL_PRECISION;\n\n\t\treturn esPropelGain;\n\t}\n\n\t// --- Compounded deposit and compounded front end stake ---\n\n\t/*\n\t * Return the user's compounded deposit. Given by the formula:  d = d0 * P/P(0)\n\t * where P(0) is the depositor's snapshot of the product P, taken when they last updated their deposit.\n\t */\n\tfunction getCompoundedDeposit(address _depositor) public view returns (uint256) {\n\t\tuint256 initialDeposit = accountDeposits[_depositor];\n\t\tif (initialDeposit == 0) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tSnapshots memory snapshots = depositSnapshots[_depositor];\n\n\t\tuint256 compoundedDeposit = _getCompoundedStakeFromSnapshots(initialDeposit, snapshots);\n\t\treturn compoundedDeposit;\n\t}\n\n\t// Internal function, used to calculcate compounded deposits and compounded front end stakes.\n\tfunction _getCompoundedStakeFromSnapshots(uint256 initialStake, Snapshots memory snapshots) internal view returns (uint256) {\n\t\tuint256 snapshot_P = snapshots.P;\n\t\tuint128 scaleSnapshot = snapshots.scale;\n\t\tuint128 epochSnapshot = snapshots.epoch;\n\n\t\t// If stake was made before a pool-emptying event, then it has been fully cancelled with debt -- so, return 0\n\t\tif (epochSnapshot < currentEpoch) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tuint256 compoundedStake;\n\t\tuint128 scaleDiff = currentScale - scaleSnapshot;\n\n\t\t/* Compute the compounded stake. If a scale change in P was made during the stake's lifetime,\n\t\t * account for it. If more than one scale change was made, then the stake has decreased by a factor of\n\t\t * at least 1e-9 -- so return 0.\n\t\t */\n\t\tif (scaleDiff == 0) {\n\t\t\tcompoundedStake = (initialStake * P) / snapshot_P;\n\t\t} else if (scaleDiff == 1) {\n\t\t\tcompoundedStake = (initialStake * P) / snapshot_P / SCALE_FACTOR;\n\t\t} else {\n\t\t\t// if scaleDiff >= 2\n\t\t\tcompoundedStake = 0;\n\t\t}\n\n\t\t/*\n\t\t * If compounded deposit is less than a billionth of the initial deposit, return 0.\n\t\t *\n\t\t * NOTE: originally, this line was in place to stop rounding errors making the deposit too large. However, the error\n\t\t * corrections should ensure the error in P \"favors the Pool\", i.e. any given compounded deposit should slightly less\n\t\t * than it's theoretical value.\n\t\t *\n\t\t * Thus it's unclear whether this line is still really needed.\n\t\t */\n\t\tif (compoundedStake < initialStake / 1e9) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn compoundedStake;\n\t}\n\n\tfunction _claimCollateralGains(address recipient, uint256[] memory collateralIndexes) internal {\n\t\tuint256 loopEnd = collateralIndexes.length;\n\t\tuint256[] memory collateralGains = new uint256[](collateralTokens.length);\n\n\t\tuint256[256] storage depositorGains = collateralGainsByDepositor[msg.sender];\n\t\tfor (uint256 i; i < loopEnd; ) {\n\t\t\tuint256 collateralIndex = collateralIndexes[i];\n\t\t\tuint256 gains = depositorGains[collateralIndex];\n\t\t\tif (gains > 0) {\n\t\t\t\tcollateralGains[collateralIndex] = gains;\n\t\t\t\tdepositorGains[collateralIndex] = 0;\n\t\t\t\tcollateralTokens[collateralIndex].safeTransfer(recipient, gains);\n\t\t\t}\n\t\t\tunchecked {\n\t\t\t\t++i;\n\t\t\t}\n\t\t}\n\t\temit CollateralGainWithdrawn(msg.sender, collateralGains);\n\t}\n\n\t// --- Stability Pool Deposit Functionality ---\n\n\tfunction _updateSnapshots(address _depositor, uint256 _newValue) internal {\n\t\tuint256 length;\n\t\tif (_newValue == 0) {\n\t\t\tdelete depositSnapshots[_depositor];\n\n\t\t\tlength = collateralTokens.length;\n\t\t\tfor (uint256 i = 0; i < length; i++) {\n\t\t\t\tdepositSums[_depositor][i] = 0;\n\t\t\t}\n\t\t\temit DepositSnapshotUpdated(_depositor, 0, 0);\n\t\t\treturn;\n\t\t}\n\t\tuint128 currentScaleCached = currentScale;\n\t\tuint128 currentEpochCached = currentEpoch;\n\t\tuint256 currentP = P;\n\n\t\t// Get S and G for the current epoch and current scale\n\t\tuint256[256] storage currentS = epochToScaleToSums[currentEpochCached][currentScaleCached];\n\t\tuint256 currentG = epochToScaleToG[currentEpochCached][currentScaleCached];\n\n\t\t// Record new snapshots of the latest running product P, sum S, and sum G, for the depositor\n\t\tdepositSnapshots[_depositor].P = currentP;\n\t\tdepositSnapshots[_depositor].G = currentG;\n\t\tdepositSnapshots[_depositor].scale = currentScaleCached;\n\t\tdepositSnapshots[_depositor].epoch = currentEpochCached;\n\n\t\tlength = collateralTokens.length;\n\t\tfor (uint256 i = 0; i < length; i++) {\n\t\t\tdepositSums[_depositor][i] = currentS[i];\n\t\t}\n\n\t\temit DepositSnapshotUpdated(_depositor, currentP, currentG);\n\t}\n\n\t//This assumes the snapshot gets updated in the caller\n\tfunction _accrueRewards(address _depositor) internal {\n\t\tuint256 amount = _claimableReward(_depositor);\n\t\tstoredPendingReward[_depositor] = storedPendingReward[_depositor] + amount;\n\t}\n\n\tfunction _claimReward(address account) internal returns (uint256 amount) {\n\t\tuint256 initialDeposit = accountDeposits[account];\n\n\t\tif (initialDeposit > 0) {\n\t\t\t_triggerRewardIssuance();\n\t\t\tbool hasGains = _accrueDepositorCollateralGain(account);\n\n\t\t\tuint256 compoundedDeposit = getCompoundedDeposit(account);\n\t\t\tuint256 debtLoss = initialDeposit - compoundedDeposit;\n\n\t\t\tamount = _claimableReward(account);\n\t\t\t// we update only if the snapshot has changed\n\t\t\tif (debtLoss > 0 || hasGains || amount > 0) {\n\t\t\t\t// Update deposit\n\t\t\t\tuint256 newDeposit = compoundedDeposit;\n\t\t\t\taccountDeposits[account] = newDeposit;\n\t\t\t\t_updateSnapshots(account, newDeposit);\n\t\t\t}\n\t\t}\n\t\tuint256 pending = storedPendingReward[account];\n\t\tif (pending > 0) {\n\t\t\tamount += pending;\n\t\t\tstoredPendingReward[account] = 0;\n\t\t}\n\t}\n}\n"
    },
    "contracts/core/TroveManager.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"../interfaces/IBorrowerOperations.sol\";\nimport \"../interfaces/IPropelUSD.sol\";\nimport \"../interfaces/ITroveManager.sol\";\nimport \"../dependencies/PropelBase.sol\";\nimport \"../dependencies/BlastWrapper.sol\";\nimport \"../dependencies/SystemStart.sol\";\nimport \"../dependencies/PropelMath.sol\";\nimport \"./InterestDebtPool.sol\";\n\n/**\n    @title Propel Trove Manager\n    @notice Based on Liquity's `TroveManager`\n            https://github.com/liquity/dev/blob/main/packages/contracts/contracts/TroveManager.sol\n\n            Propel's implementation is modified so that multiple `TroveManager` and `SortedTroves`\n            contracts are deployed in tandem, with each pair managing troves of a single collateral\n            type.\n\n            Functionality related to liquidations has been moved to `LiquidationManager`. This was\n            necessary to avoid the restriction on deployed bytecode size.\n */\ncontract TroveManager is ITroveManager, InterestDebtPool, PropelBase, BlastWrapper, SystemStart {\n\tusing SafeERC20 for IERC20;\n\n\t// --- Connected contract declarations ---\n\taddress public immutable borrowerOperationsAddress;\n\taddress public immutable liquidationManager;\n\taddress public immutable gasPoolAddress;\n\n\tIPriceFeed public override priceFeed;\n\tIERC20 public collateralToken;\n\n\t// A doubly linked list of Troves, sorted by their collateral ratios\n\tISortedTroves public override sortedTroves;\n\n\t// Minimum collateral ratio for individual troves\n\tuint256 public MCR;\n\n\tuint256 internal constant SECONDS_IN_ONE_MINUTE = 60;\n\n\t// During bootsrap period redemptions are not allowed\n\tuint256 public constant BOOTSTRAP_PERIOD = 14 days;\n\tuint32 public constant SUNSETTING_INTEREST_RATE = 5e5; //50%\n\n\t/*\n\t * BETA: 18 digit decimal. Parameter by which to divide the redeemed fraction, in order to calc the new base rate from a redemption.\n\t * Corresponds to (1 / ALPHA) in the white paper.\n\t */\n\tuint256 internal constant BETA = 2;\n\n\t// commented values are Liquity's fixed settings for each parameter\n\tuint256 public minuteDecayFactor; // 999037758833783000  (half-life of 12 hours)\n\tuint256 public redemptionFeeFloor; // DECIMAL_PRECISION / 1000 * 5  (0.5%)\n\tuint256 public maxRedemptionFee; // DECIMAL_PRECISION  (100%)\n\tuint256 public borrowingFeeFloor; // DECIMAL_PRECISION / 1000 * 5  (0.5%)\n\tuint256 public maxBorrowingFee; // DECIMAL_PRECISION / 100 * 5  (5%)\n\tuint256 public maxSystemDebt;\n\n\tuint256 public systemDeploymentTime;\n\tbool public paused;\n\tbool public sunsetting;\n\n\tuint256 public baseRate;\n\n\t// The timestamp of the latest fee operation (redemption or new debt issuance)\n\tuint256 public lastFeeOperationTime;\n\n\tuint256 public totalStakes;\n\n\t// Snapshot of the value of totalStakes, taken immediately after the latest liquidation\n\tuint256 public totalStakesSnapshot;\n\n\t// Snapshot of the total collateral taken immediately after the latest liquidation.\n\tuint256 public totalCollateralSnapshot;\n\n\t/*\n\t * L_collateral and L_debt track the sums of accumulated liquidation rewards per unit staked. During its lifetime, each stake earns:\n\t *\n\t * An collateral gain of ( stake * [L_collateral - L_collateral(0)] )\n\t * A debt increase  of ( stake * [L_debt - L_debt(0)] )\n\t *\n\t * Where L_collateral(0) and L_debt(0) are snapshots of L_collateral and L_debt for the active Trove taken at the instant the stake was made\n\t */\n\tuint256 public L_collateral;\n\tuint256 public L_debt;\n\n\t// Error trackers for the trove redistribution calculation\n\tuint256 public lastCollateralError_Redistribution;\n\tuint256 public lastDebtError_Redistribution;\n\n\tuint256 internal totalActiveCollateral;\n\tuint256 internal totalActiveDebt;\n\tuint256 public interestPayable;\n\n\tuint256 public defaultedCollateral;\n\tuint256 public defaultedDebt;\n\n\tuint256 public rewardIntegral;\n\tuint128 public rewardRate;\n\tuint32 public periodFinish;\n\n\tmapping(address => Trove) internal Troves;\n\n\tmapping(address => RewardSnapshot) internal rewardSnapshots;\n\n\tmapping(address => uint256) public surplusBalances;\n\n\t// Map addresses with active troves to their RewardSnapshot\n\n\t// Array of all active trove addresses - used to to compute an approximate hint off-chain, for the sorted list insertion\n\taddress[] public TroveOwners;\n\n\tmodifier whenNotPaused() {\n\t\trequire(!paused, \"Collateral Paused\");\n\t\t_;\n\t}\n\n\tconstructor(\n\t\tIPropelCore _PropelCore,\n\t\taddress _gasPoolAddress,\n\t\taddress _PropelUSDAddress,\n\t\taddress _borrowerOperationsAddress,\n\t\taddress _liquidationManager,\n\t\tuint256 _gasCompensation\n\t) InterestDebtPool(_PropelUSDAddress) BlastWrapper(_PropelCore) PropelBase(_gasCompensation) SystemStart(_PropelCore) {\n\t\tgasPoolAddress = _gasPoolAddress;\n\t\tborrowerOperationsAddress = _borrowerOperationsAddress;\n\t\tliquidationManager = _liquidationManager;\n\t}\n\n\tfunction setAddresses(address _priceFeedAddress, address _sortedTrovesAddress, IERC20 _collateralToken) external override {\n\t\tassert(address(sortedTroves) == address(0));\n\t\tpriceFeed = IPriceFeed(_priceFeedAddress);\n\t\tsortedTroves = ISortedTroves(_sortedTrovesAddress);\n\t\tcollateralToken = IERC20(_collateralToken);\n\t\tsunsetting = false;\n\n\t\tsystemDeploymentTime = block.timestamp;\n\t}\n\n\tfunction feeReceiver() public view override returns (address) {\n\t\treturn PropelCore.feeReceiver();\n\t}\n\n\tfunction startSunset() external onlyOwner {\n\t\t_distributeInterestDebt();\n\t\tsunsetting = true;\n\t\tinterestRate = SUNSETTING_INTEREST_RATE;\n\t\tredemptionFeeFloor = 0;\n\t\tmaxSystemDebt = 0;\n\t}\n\n\t/**\n\t * @notice Sets the pause state for this trove manager\n\t *         Pausing is used to mitigate risks in exceptional circumstances\n\t *         Functionalities affected by pausing are:\n\t *         - New borrowing is not possible\n\t *         - New collateral deposits are not possible\n\t * @param _paused If true the protocol is paused\n\t */\n\tfunction setPaused(bool _paused) external {\n\t\trequire((_paused && msg.sender == guardian()) || msg.sender == owner(), \"Unauthorized\");\n\t\tpaused = _paused;\n\t}\n\n\t/**\n\t * @notice Sets a custom price feed for this trove manager\n\t * @param _priceFeedAddress Price feed address\n\t */\n\tfunction setPriceFeed(address _priceFeedAddress) external onlyOwner {\n\t\tpriceFeed = IPriceFeed(_priceFeedAddress);\n\t}\n\n\tfunction setInterestRate(uint32 _interestRate) external onlyOwner {\n\t\tassert(_interestRate <= MAXFP / 10);\n\t\t_distributeInterestDebt();\n\t\tinterestRate = _interestRate;\n\t}\n\n\tfunction setMCR(uint256 _MCR) external onlyOwner {\n\t\trequire(_MCR <= CCR && _MCR >= 1100000000000000000, \"MCR cannot be > CCR or < 110%\");\n\t\tMCR = _MCR;\n\t}\n\n\tfunction setMaxSystemDebt(uint256 _maxSystemDebt) external onlyOwner {\n\t\trequire(_maxSystemDebt > getEntireSystemDebt(), \"new max system debt must be greater than current system debt\");\n\t\tmaxSystemDebt = _maxSystemDebt;\n\t}\n\n\t/*\n        _minuteDecayFactor is calculated as\n\n            10**18 * (1/2)**(1/n)\n\n        where n = the half-life in minutes\n     */\n\tfunction setParameters(uint256 _minuteDecayFactor, uint256 _redemptionFeeFloor, uint256 _maxRedemptionFee, uint256 _borrowingFeeFloor, uint256 _maxBorrowingFee, uint256 _maxSystemDebt, uint256 _MCR, uint32 _interestRate) public {\n\t\trequire(!sunsetting, \"Cannot change after sunset\");\n\t\trequire(_MCR <= CCR && _MCR >= 1100000000000000000, \"MCR cannot be > CCR or < 110%\");\n\t\tif (minuteDecayFactor != 0) {\n\t\t\trequire(msg.sender == owner(), \"Only owner\");\n\t\t}\n\t\tassert(\n\t\t\t_minuteDecayFactor >= 977159968434245000 && // half-life of 30 minutes\n\t\t\t\t_minuteDecayFactor <= 999931237762985000 // half-life of 1 week\n\t\t);\n\t\tassert(_redemptionFeeFloor <= _maxRedemptionFee && _maxRedemptionFee <= DECIMAL_PRECISION);\n\t\tassert(_borrowingFeeFloor <= _maxBorrowingFee && _maxBorrowingFee <= DECIMAL_PRECISION);\n\t\tassert(_interestRate <= MAXFP / 10);\n\t\t_distributeInterestDebt();\n\t\t_decayBaseRate();\n\n\t\tminuteDecayFactor = _minuteDecayFactor;\n\t\tredemptionFeeFloor = _redemptionFeeFloor;\n\t\tmaxRedemptionFee = _maxRedemptionFee;\n\t\tborrowingFeeFloor = _borrowingFeeFloor;\n\t\tmaxBorrowingFee = _maxBorrowingFee;\n\t\tmaxSystemDebt = _maxSystemDebt;\n\n\t\tMCR = _MCR;\n\t\tinterestRate = _interestRate;\n\t}\n\n\tfunction distributeInterestDebt() public returns (uint256) {\n\t\treturn _distributeInterestDebt();\n\t}\n\n\t// --- Getters ---\n\n\tfunction fetchPrice() public returns (uint256) {\n\t\tIPriceFeed _priceFeed = priceFeed;\n\t\treturn _priceFeed.fetchPrice(address(collateralToken));\n\t}\n\n\tfunction getTrove(address _borrower) external view override returns (Trove memory) {\n\t\treturn Troves[_borrower];\n\t}\n\n\tfunction getRewardSnapshots(address _borrower) external view override returns (RewardSnapshot memory) {\n\t\treturn rewardSnapshots[_borrower];\n\t}\n\n\tfunction getTroveOwnersCount() external view returns (uint256) {\n\t\treturn TroveOwners.length;\n\t}\n\n\tfunction getTroveFromTroveOwnersArray(uint256 _index) external view returns (address) {\n\t\treturn TroveOwners[_index];\n\t}\n\n\tfunction getTroveStatus(address _borrower) external view returns (uint256) {\n\t\treturn uint256(Troves[_borrower].status);\n\t}\n\n\tfunction getTroveStake(address _borrower) external view returns (uint256) {\n\t\treturn Troves[_borrower].stake;\n\t}\n\n\t/**\n        @notice Get the current total collateral and debt amounts for a trove\n        @dev Also includes pending rewards from redistribution\n     */\n\tfunction getTroveCollAndDebt(address _borrower) public view returns (uint256 coll, uint256 debt) {\n\t\t(debt, coll, , ) = getEntireDebtAndColl(_borrower);\n\t\treturn (coll, debt);\n\t}\n\n\t/**\n        @notice Get the total and pending collateral and debt amounts for a trove\n        @dev Used by the liquidation manager\n     */\n\tfunction getEntireDebtAndColl(address _borrower) public view returns (uint256 debt, uint256 coll, uint256 pendingDebtReward, uint256 pendingCollateralReward) {\n\t\tTrove storage t = Troves[_borrower];\n\t\tdebt = t.debt;\n\t\tcoll = t.coll;\n\t\t(pendingCollateralReward, pendingDebtReward) = getPendingCollAndDebtRewards(_borrower);\n\t\tdebt = debt + pendingDebtReward;\n\t\tcoll = coll + pendingCollateralReward;\n\t}\n\n\tfunction getEntireSystemColl() public view returns (uint256) {\n\t\treturn totalActiveCollateral + defaultedCollateral;\n\t}\n\n\tfunction getEntireSystemDebt() public view override(ITroveManager, InterestDebtPool) returns (uint256) {\n\t\treturn totalActiveDebt + defaultedDebt;\n\t}\n\n\tfunction getGlobalSystemDebt() public view returns (uint256) {\n\t\treturn totalActiveDebt + defaultedDebt + outstandingInterestDebt + getPendingSystemInterestDebt();\n\t}\n\n\tfunction getEntireSystemBalances() external returns (uint256, uint256, uint256) {\n\t\treturn (getEntireSystemColl(), getGlobalSystemDebt(), fetchPrice());\n\t}\n\n\t// --- Helper functions ---\n\n\t// Return the nominal collateral ratio (ICR) of a given Trove, without the price. Takes a trove's pending coll and debt rewards from redistributions into account.\n\tfunction getNominalICR(address _borrower) public view returns (uint256) {\n\t\t(uint256 currentCollateral, uint256 currentDebt) = getTroveCollAndDebt(_borrower);\n\n\t\tuint256 NICR = PropelMath._computeNominalCR(currentCollateral, currentDebt);\n\t\treturn NICR;\n\t}\n\n\tfunction getRedemptionICR(address _borrower, uint256 _price) public view returns (uint256) {\n\t\t(uint256 currentCollateral, uint256 currentDebt) = getTroveCollAndDebt(_borrower);\n\t\tuint256 ICR = PropelMath._computeCR(currentCollateral, currentDebt, _price);\n\t\treturn ICR;\n\t}\n\n\t// Return the current collateral ratio (ICR) of a given Trove. Takes a trove's pending coll and debt rewards from redistributions into account.\n\tfunction getCurrentICR(address _borrower, uint256 _price) public view returns (uint256) {\n\t\t(uint256 currentCollateral, uint256 currentDebt) = getTroveCollAndDebt(_borrower);\n\t\tuint256 ICR = PropelMath._computeCR(currentCollateral, currentDebt + getTroveInterest(_borrower, currentDebt), _price);\n\t\treturn ICR;\n\t}\n\n\tfunction getTroveInterest(address _borrower, uint256 debt) public view returns (uint256) {\n\t\treturn (debt * (getPendingInterestDebt() - rewardSnapshots[_borrower].interest)) / DECIMAL_PRECISION;\n\t}\n\n\tfunction getTotalActiveCollateral() public view returns (uint256) {\n\t\treturn totalActiveCollateral;\n\t}\n\n\tfunction getTotalActiveDebt() public view returns (uint256) {\n\t\treturn totalActiveDebt;\n\t}\n\n\t// Get the borrower's pending accumulated collateral and debt rewards, earned by their stake\n\tfunction getPendingCollAndDebtRewards(address _borrower) public view returns (uint256, uint256) {\n\t\tRewardSnapshot memory snapshot = rewardSnapshots[_borrower];\n\n\t\tuint256 coll = L_collateral - snapshot.collateral;\n\t\tuint256 debt = L_debt - snapshot.debt;\n\n\t\tif (coll + debt == 0 || Troves[_borrower].status != Status.active) return (0, 0);\n\n\t\tuint256 stake = Troves[_borrower].stake;\n\t\treturn ((stake * coll) / DECIMAL_PRECISION, (stake * debt) / DECIMAL_PRECISION);\n\t}\n\n\tfunction hasPendingRewards(address _borrower) public view returns (bool) {\n\t\t/*\n\t\t * A Trove has pending rewards if its snapshot is less than the current rewards per-unit-staked sum:\n\t\t * this indicates that rewards have occured since the snapshot was made, and the user therefore has\n\t\t * pending rewards\n\t\t */\n\t\tif (Troves[_borrower].status != Status.active) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn (rewardSnapshots[_borrower].collateral < L_collateral);\n\t}\n\n\t// --- Redemption fee functions ---\n\n\t/*\n\t * This function has two impacts on the baseRate state variable:\n\t * 1) decays the baseRate based on time passed since last redemption or debt borrowing operation.\n\t * then,\n\t * 2) increases the baseRate based on the amount redeemed, as a proportion of total supply\n\t */\n\tfunction _updateBaseRateFromRedemption(uint256 _collateralDrawn, uint256 _price, uint256 _totalDebtSupply) internal returns (uint256) {\n\t\tuint256 decayedBaseRate = _calcDecayedBaseRate();\n\n\t\t/* Convert the drawn collateral back to debt at face value rate (1 debt:1 USD), in order to get\n\t\t * the fraction of total supply that was redeemed at face value. */\n\t\tuint256 redeemedDebtFraction = (_collateralDrawn * _price) / _totalDebtSupply;\n\t\tuint256 newBaseRate = decayedBaseRate + (redeemedDebtFraction / BETA);\n\t\tnewBaseRate = PropelMath._min(newBaseRate, DECIMAL_PRECISION); // cap baseRate at a maximum of 100%\n\n\t\t// Update the baseRate state variable\n\t\tbaseRate = newBaseRate;\n\t\temit BaseRateUpdated(newBaseRate);\n\n\t\t_updateLastFeeOpTime();\n\n\t\treturn newBaseRate;\n\t}\n\n\tfunction getRedemptionRate() public view returns (uint256) {\n\t\treturn _calcRedemptionRate(baseRate);\n\t}\n\n\tfunction getRedemptionRateWithDecay() public view returns (uint256) {\n\t\treturn _calcRedemptionRate(_calcDecayedBaseRate());\n\t}\n\n\tfunction _calcRedemptionRate(uint256 _baseRate) internal view returns (uint256) {\n\t\treturn\n\t\t\tPropelMath._min(\n\t\t\t\tredemptionFeeFloor + _baseRate,\n\t\t\t\tmaxRedemptionFee // cap at a maximum of 100%\n\t\t\t);\n\t}\n\n\tfunction getRedemptionFeeWithDecay(uint256 _collateralDrawn) external view returns (uint256) {\n\t\treturn _calcRedemptionFee(getRedemptionRateWithDecay(), _collateralDrawn);\n\t}\n\n\tfunction _calcRedemptionFee(uint256 _redemptionRate, uint256 _collateralDrawn) internal pure returns (uint256) {\n\t\tuint256 redemptionFee = (_redemptionRate * _collateralDrawn) / DECIMAL_PRECISION;\n\t\trequire(redemptionFee < _collateralDrawn, \"Fee exceeds returned collateral\");\n\t\treturn redemptionFee;\n\t}\n\n\t// --- Borrowing fee functions ---\n\n\tfunction getBorrowingRate() public view returns (uint256) {\n\t\treturn _calcBorrowingRate(baseRate);\n\t}\n\n\tfunction getBorrowingRateWithDecay() public view returns (uint256) {\n\t\treturn _calcBorrowingRate(_calcDecayedBaseRate());\n\t}\n\n\tfunction _calcBorrowingRate(uint256 _baseRate) internal view returns (uint256) {\n\t\treturn PropelMath._min(borrowingFeeFloor + _baseRate, maxBorrowingFee);\n\t}\n\n\tfunction getBorrowingFee(uint256 _debt) external view returns (uint256) {\n\t\treturn _calcBorrowingFee(getBorrowingRate(), _debt);\n\t}\n\n\tfunction getBorrowingFeeWithDecay(uint256 _debt) external view returns (uint256) {\n\t\treturn _calcBorrowingFee(getBorrowingRateWithDecay(), _debt);\n\t}\n\n\tfunction _calcBorrowingFee(uint256 _borrowingRate, uint256 _debt) internal pure returns (uint256) {\n\t\treturn (_borrowingRate * _debt) / DECIMAL_PRECISION;\n\t}\n\n\t// --- Internal fee functions ---\n\n\t// Update the last fee operation time only if time passed >= decay interval. This prevents base rate griefing.\n\tfunction _updateLastFeeOpTime() internal {\n\t\tuint256 timePassed = block.timestamp - lastFeeOperationTime;\n\n\t\tif (timePassed >= SECONDS_IN_ONE_MINUTE) {\n\t\t\tlastFeeOperationTime = block.timestamp;\n\t\t\temit LastFeeOpTimeUpdated(block.timestamp);\n\t\t}\n\t}\n\n\tfunction _calcDecayedBaseRate() internal view returns (uint256) {\n\t\tuint256 minutesPassed = (block.timestamp - lastFeeOperationTime) / SECONDS_IN_ONE_MINUTE;\n\t\tuint256 decayFactor = PropelMath._decPow(minuteDecayFactor, minutesPassed);\n\n\t\treturn (baseRate * decayFactor) / DECIMAL_PRECISION;\n\t}\n\n\t// --- Redemption functions ---\n\n\t/* Send _debtAmount debt to the system and redeem the corresponding amount of collateral from as many Troves as are needed to fill the redemption\n\t * request.  Applies pending rewards to a Trove before reducing its debt and coll.\n\t *\n\t * 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\t * splitting the total _amount in appropriate chunks and calling the function multiple times.\n\t *\n\t * 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\t * avoid OOG for the frontend, as only knowing approximately the average cost of an iteration is enough, without needing to know the “topology”\n\t * 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\t * costs can vary.\n\t *\n\t * 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\t * 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\t * 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\t * in the sortedTroves list along with the ICR value that the hint was found for.\n\t *\n\t * If another transaction modifies the list between calling getRedemptionHints() and passing the hints to redeemCollateral(), it\n\t * 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\t * redemption will stop after the last completely redeemed Trove and the sender will keep the remaining debt amount, which they can attempt\n\t * to redeem later.\n\t */\n\tfunction redeemCollateral(uint256 _debtAmount, address _firstRedemptionHint, address _upperPartialRedemptionHint, address _lowerPartialRedemptionHint, uint256 _partialRedemptionHintNICR, uint256 _maxIterations, uint256 _maxFeePercentage) external {\n\t\tISortedTroves _sortedTrovesCached = sortedTroves;\n\t\tRedemptionTotals memory totals;\n\n\t\trequire(_maxFeePercentage >= redemptionFeeFloor && _maxFeePercentage <= maxRedemptionFee, \"Max fee 0.5% to 100%\");\n\t\trequire(block.timestamp >= systemDeploymentTime + BOOTSTRAP_PERIOD, \"BOOTSTRAP_PERIOD\");\n\t\t_distributeInterestDebt();\n\t\ttotals.price = fetchPrice();\n\t\tuint256 _MCR = MCR;\n\t\trequire(IBorrowerOperations(borrowerOperationsAddress).getTCR() >= _MCR, \"Cannot redeem when TCR < MCR\");\n\t\trequire(_debtAmount > 0, \"Amount must be greater than zero\");\n\t\trequire(PropelUSD.balanceOf(msg.sender) >= _debtAmount, \"Insufficient balance\");\n\t\ttotals.totalDebtSupplyAtStart = getGlobalSystemDebt();\n\n\t\ttotals.remainingDebt = _debtAmount;\n\t\taddress currentBorrower;\n\n\t\tif (_isValidFirstRedemptionHint(_sortedTrovesCached, _firstRedemptionHint, totals.price, _MCR)) {\n\t\t\tcurrentBorrower = _firstRedemptionHint;\n\t\t} else {\n\t\t\tcurrentBorrower = _sortedTrovesCached.getLast();\n\t\t\t// Find the first trove with ICR >= MCR\n\t\t\twhile (currentBorrower != address(0) && getRedemptionICR(currentBorrower, totals.price) < _MCR) {\n\t\t\t\tcurrentBorrower = _sortedTrovesCached.getPrev(currentBorrower);\n\t\t\t}\n\t\t}\n\n\t\t// Loop through the Troves starting from the one with lowest collateral ratio until _amount of debt is exchanged for collateral\n\t\tif (_maxIterations == 0) {\n\t\t\t_maxIterations = type(uint256).max;\n\t\t}\n\t\twhile (currentBorrower != address(0) && totals.remainingDebt > 0 && _maxIterations > 0) {\n\t\t\t_maxIterations--;\n\t\t\t// Save the address of the Trove preceding the current one, before potentially modifying the list\n\t\t\taddress nextUserToCheck = _sortedTrovesCached.getPrev(currentBorrower);\n\n\t\t\t_applyPendingRewards(currentBorrower);\n\t\t\tSingleRedemptionValues memory singleRedemption = _redeemCollateralFromTrove(_sortedTrovesCached, currentBorrower, totals.remainingDebt, totals.price, _upperPartialRedemptionHint, _lowerPartialRedemptionHint, _partialRedemptionHintNICR);\n\n\t\t\tif (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\t\t\ttotals.totalDebtToRedeem = totals.totalDebtToRedeem + singleRedemption.debtLot;\n\t\t\ttotals.totalCollateralDrawn = totals.totalCollateralDrawn + singleRedemption.collateralLot;\n\t\t\ttotals.totalInterest = totals.totalInterest + singleRedemption.interestLot;\n\n\t\t\ttotals.remainingDebt = totals.remainingDebt - singleRedemption.debtLot;\n\t\t\tcurrentBorrower = nextUserToCheck;\n\t\t}\n\t\trequire(totals.totalCollateralDrawn > 0, \"Unable to redeem any amount\");\n\n\t\t// Decay the baseRate due to time passed, and then increase it according to the size of this redemption.\n\t\t// Use the saved total debt supply value, from before it was reduced by the redemption.\n\t\t_updateBaseRateFromRedemption(totals.totalCollateralDrawn, totals.price, totals.totalDebtSupplyAtStart);\n\t\t// Calculate the collateral fee\n\t\ttotals.collateralFee = sunsetting ? 0 : _calcRedemptionFee(getRedemptionRate(), totals.totalCollateralDrawn);\n\t\t_requireUserAcceptsFee(totals.collateralFee, totals.totalCollateralDrawn, _maxFeePercentage);\n\n\t\t_sendCollateral(feeReceiver(), totals.collateralFee);\n\n\t\ttotals.collateralToSendToRedeemer = totals.totalCollateralDrawn - totals.collateralFee;\n\n\t\temit Redemption(_debtAmount, totals.totalDebtToRedeem, totals.totalCollateralDrawn, totals.totalInterest, totals.collateralFee);\n\n\t\t// Burn the total debt that is cancelled with debt, and send the redeemed collateral to msg.sender\n\t\tPropelUSD.burn(msg.sender, totals.totalDebtToRedeem);\n\t\t// Update Trove Manager debt, and send collateral to account\n\t\ttotalActiveDebt = totalActiveDebt - totals.totalDebtToRedeem;\n\t\tdecreaseOutstandingInterestDebt(totals.totalInterest);\n\t\t_sendCollateral(msg.sender, totals.collateralToSendToRedeemer);\n\t\t_resetState();\n\t}\n\n\t// Redeem as much collateral as possible from _borrower's Trove in exchange for debt up to _maxDebtAmount\n\tfunction _redeemCollateralFromTrove(\n\t\tISortedTroves _sortedTrovesCached,\n\t\taddress _borrower,\n\t\tuint256 _maxDebtAmount,\n\t\tuint256 _price,\n\t\taddress _upperPartialRedemptionHint,\n\t\taddress _lowerPartialRedemptionHint,\n\t\tuint256 _partialRedemptionHintNICR\n\t) internal returns (SingleRedemptionValues memory singleRedemption) {\n\t\tTrove storage t = Troves[_borrower];\n\t\tuint256 interest = getTroveInterest(_borrower, t.debt);\n\t\tif (_maxDebtAmount < interest) {\n\t\t\tsingleRedemption.cancelledPartial = true;\n\t\t\treturn singleRedemption;\n\t\t}\n\t\tsingleRedemption.interestLot = interest;\n\t\t// Determine the remaining amount (lot) to be redeemed, capped by the entire debt of the Trove minus the liquidation reserve\n\t\tsingleRedemption.debtLot = PropelMath._min(_maxDebtAmount - singleRedemption.interestLot, t.debt - DEBT_GAS_COMPENSATION);\n\n\t\t// Get the CollateralLot of equivalent value in USD\n\t\tsingleRedemption.collateralLot = ((singleRedemption.debtLot + singleRedemption.interestLot) * DECIMAL_PRECISION) / _price;\n\t\t// Decrease the debt and collateral of the current Trove according to the debt lot and corresponding collateral to send\n\t\tuint256 newDebt = (t.debt) - singleRedemption.debtLot;\n\t\tuint256 newColl = (t.coll) - singleRedemption.collateralLot;\n\n\t\tif (newDebt == DEBT_GAS_COMPENSATION) {\n\t\t\t// No debt left in the Trove (except for the liquidation reserve), therefore the trove gets closed\n\t\t\t_removeStake(_borrower);\n\t\t\t_closeTrove(_borrower, Status.closedByRedemption);\n\t\t\t_redeemCloseTrove(_borrower, DEBT_GAS_COMPENSATION, newColl);\n\t\t\temit TroveUpdated(_borrower, 0, 0, 0, TroveManagerOperation.redeemCollateral);\n\t\t} else {\n\t\t\tuint256 newNICR = PropelMath._computeNominalCR(newColl, newDebt);\n\t\t\t/*\n\t\t\t * If the provided hint is out of date, we bail since trying to reinsert without a good hint will almost\n\t\t\t * certainly result in running out of gas.\n\t\t\t *\n\t\t\t * If the resultant net debt of the partial is less than the minimum, net debt we bail.\n\t\t\t */\n\n\t\t\t{\n\t\t\t\t// We check if the ICR hint is reasonable up to date, with continuous interest there might be slight differences (<1bps)\n\t\t\t\tuint256 icrError = _partialRedemptionHintNICR > newNICR ? _partialRedemptionHintNICR - newNICR : newNICR - _partialRedemptionHintNICR;\n\t\t\t\tif (icrError > 5e14 || _getNetDebt(newDebt) < IBorrowerOperations(borrowerOperationsAddress).minNetDebt()) {\n\t\t\t\t\tsingleRedemption.cancelledPartial = true;\n\t\t\t\t\treturn singleRedemption;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_sortedTrovesCached.reInsert(_borrower, newNICR, _upperPartialRedemptionHint, _lowerPartialRedemptionHint);\n\n\t\t\tt.debt = newDebt;\n\t\t\tt.coll = newColl;\n\t\t\t_updateStakeAndTotalStakes(t);\n\t\t\t_updateTroveRewardSnapshots(_borrower);\n\t\t\temit TroveUpdated(_borrower, newDebt, newColl, t.stake, TroveManagerOperation.redeemCollateral);\n\t\t}\n\n\t\treturn singleRedemption;\n\t}\n\n\t/*\n\t * Called when a full redemption occurs, and closes the trove.\n\t * The redeemer swaps (debt - liquidation reserve) debt for (debt - liquidation reserve) worth of collateral, so the debt liquidation reserve left corresponds to the remaining debt.\n\t * In order to close the trove, the debt liquidation reserve is burned, and the corresponding debt is removed.\n\t * The debt recorded on the trove's struct is zero'd elswhere, in _closeTrove.\n\t * Any surplus collateral left in the trove can be later claimed by the borrower.\n\t */\n\tfunction _redeemCloseTrove(address _borrower, uint256 _debt, uint256 _collateral) internal {\n\t\tPropelUSD.burn(gasPoolAddress, _debt);\n\t\ttotalActiveDebt = totalActiveDebt - _debt;\n\n\t\tsurplusBalances[_borrower] += _collateral;\n\t\ttotalActiveCollateral -= _collateral;\n\t}\n\n\tfunction _isValidFirstRedemptionHint(ISortedTroves _sortedTroves, address _firstRedemptionHint, uint256 _price, uint256 _MCR) internal view returns (bool) {\n\t\tif (_firstRedemptionHint == address(0) || !_sortedTroves.contains(_firstRedemptionHint) || getRedemptionICR(_firstRedemptionHint, _price) < _MCR) {\n\t\t\treturn false;\n\t\t}\n\n\t\taddress nextTrove = _sortedTroves.getNext(_firstRedemptionHint);\n\t\treturn nextTrove == address(0) || getRedemptionICR(nextTrove, _price) < _MCR;\n\t}\n\n\t/**\n\t * Claim remaining collateral from a redemption or from a liquidation with ICR > MCR in Recovery Mode\n\t */\n\tfunction claimCollateral(address _receiver) external {\n\t\tuint256 claimableColl = surplusBalances[msg.sender];\n\t\trequire(claimableColl > 0, \"No collateral available to claim\");\n\n\t\tsurplusBalances[msg.sender] = 0;\n\n\t\tcollateralToken.safeTransfer(_receiver, claimableColl);\n\t}\n\n\t// --- Trove Adjustment functions ---\n\n\tfunction openTrove(address _borrower, uint256 _collateralAmount, uint256 _compositeDebt, uint256 NICR, address _upperHint, address _lowerHint) external whenNotPaused returns (uint256 stake, uint256 arrayIndex) {\n\t\t_requireCallerIsBO();\n\t\trequire(!sunsetting, \"Cannot open while sunsetting\");\n\t\tuint256 supply = totalActiveDebt;\n\t\tTrove storage t = Troves[_borrower];\n\t\trequire(t.status != Status.active, \"BorrowerOps: Trove is active\");\n\t\tt.status = Status.active;\n\t\tt.coll = _collateralAmount;\n\t\tt.debt = _compositeDebt;\n\t\t_updateTroveRewardSnapshots(_borrower);\n\t\tstake = _updateStakeAndTotalStakes(t);\n\t\tsortedTroves.insert(_borrower, NICR, _upperHint, _lowerHint);\n\n\t\tTroveOwners.push(_borrower);\n\t\tarrayIndex = TroveOwners.length - 1;\n\t\tt.arrayIndex = uint128(arrayIndex);\n\n\t\ttotalActiveCollateral = totalActiveCollateral + _collateralAmount;\n\t\tuint256 _newTotalDebt = supply + _compositeDebt;\n\t\trequire(_newTotalDebt + defaultedDebt <= maxSystemDebt, \"Collateral debt limit reached\");\n\t\ttotalActiveDebt = _newTotalDebt;\n\t}\n\n\tfunction updateTroveFromAdjustment(bool _isDebtIncrease, uint256 _debtChange, uint256 _netDebtChange, bool _isCollIncrease, uint256 _collChange, address _upperHint, address _lowerHint, address _borrower, address _receiver) external returns (uint256, uint256, uint256) {\n\t\t_requireCallerIsBO();\n\t\tif (_isCollIncrease || _isDebtIncrease) {\n\t\t\trequire(!paused, \"Collateral Paused\");\n\t\t\trequire(!sunsetting, \"Cannot increase while sunsetting\");\n\t\t}\n\n\t\tTrove storage t = Troves[_borrower];\n\t\trequire(t.status == Status.active, \"Trove closed or does not exist\");\n\n\t\tuint256 newDebt = t.debt;\n\t\tif (_debtChange > 0) {\n\t\t\tif (_isDebtIncrease) {\n\t\t\t\tnewDebt = newDebt + _netDebtChange;\n\t\t\t\t_increaseDebt(_receiver, _netDebtChange, _debtChange);\n\t\t\t} else {\n\t\t\t\tnewDebt = newDebt - _netDebtChange;\n\t\t\t\t_decreaseDebt(_receiver, _debtChange);\n\t\t\t}\n\t\t\tt.debt = newDebt;\n\t\t}\n\n\t\tuint256 newColl = t.coll;\n\t\tif (_collChange > 0) {\n\t\t\tif (_isCollIncrease) {\n\t\t\t\tnewColl = newColl + _collChange;\n\t\t\t\ttotalActiveCollateral = totalActiveCollateral + _collChange;\n\t\t\t\t// trust that BorrowerOperations sent the collateral\n\t\t\t} else {\n\t\t\t\tnewColl = newColl - _collChange;\n\t\t\t\t_sendCollateral(_receiver, _collChange);\n\t\t\t}\n\t\t\tt.coll = newColl;\n\t\t}\n\n\t\tuint256 newNICR = PropelMath._computeNominalCR(newColl, newDebt);\n\t\tsortedTroves.reInsert(_borrower, newNICR, _upperHint, _lowerHint);\n\n\t\treturn (newColl, newDebt, _updateStakeAndTotalStakes(t));\n\t}\n\n\tfunction closeTrove(address _borrower, address _receiver, uint256 collAmount, uint256 debtAmount) external {\n\t\t_requireCallerIsBO();\n\t\trequire(Troves[_borrower].status == Status.active, \"Trove closed or does not exist\");\n\t\t_removeStake(_borrower);\n\t\t_closeTrove(_borrower, Status.closedByOwner);\n\t\ttotalActiveDebt = totalActiveDebt - debtAmount;\n\t\t_sendCollateral(_receiver, collAmount);\n\t\t_resetState();\n\t}\n\n\t/**\n        @dev Only called from `closeTrove` because liquidating the final trove is blocked in\n             `LiquidationManager`. Many liquidation paths involve redistributing debt and\n             collateral to existing troves. If the collateral is being sunset, the final trove\n             must be closed by repaying the debt or via a redemption.\n     */\n\tfunction _resetState() private {\n\t\tif (TroveOwners.length == 0) {\n\t\t\tlastInterestDebtUpdateTime = 0;\n\t\t\ttotalStakes = 0;\n\t\t\ttotalStakesSnapshot = 0;\n\t\t\ttotalCollateralSnapshot = 0;\n\t\t\tL_collateral = 0;\n\t\t\tL_debt = 0;\n\t\t\tL_Interest_Debt = 0;\n\t\t\tlastInterestDebtError_Redistribution = 0;\n\t\t\tlastCollateralError_Redistribution = 0;\n\t\t\tlastDebtError_Redistribution = 0;\n\t\t\ttotalActiveCollateral = 0;\n\t\t\ttotalActiveDebt = 0;\n\t\t\tdefaultedCollateral = 0;\n\t\t\tdefaultedDebt = 0;\n\t\t\toutstandingInterestDebt = 0;\n\t\t}\n\t}\n\n\tfunction _closeTrove(address _borrower, Status closedStatus) internal {\n\t\tuint256 TroveOwnersArrayLength = TroveOwners.length;\n\n\t\tTrove storage t = Troves[_borrower];\n\t\tt.status = closedStatus;\n\t\tt.coll = 0;\n\t\tt.debt = 0;\n\t\tISortedTroves sortedTrovesCached = sortedTroves;\n\t\trewardSnapshots[_borrower].collateral = 0;\n\t\trewardSnapshots[_borrower].debt = 0;\n\t\tif (TroveOwnersArrayLength > 1 && sortedTrovesCached.getSize() > 1) {\n\t\t\t// remove trove owner from the TroveOwners array, not preserving array order\n\t\t\tuint128 index = t.arrayIndex;\n\t\t\taddress addressToMove = TroveOwners[TroveOwnersArrayLength - 1];\n\t\t\tTroveOwners[index] = addressToMove;\n\t\t\tTroves[addressToMove].arrayIndex = index;\n\t\t\temit TroveIndexUpdated(addressToMove, index);\n\t\t}\n\n\t\tTroveOwners.pop();\n\n\t\tsortedTrovesCached.remove(_borrower);\n\t\tt.arrayIndex = 0;\n\t}\n\n\t// Updates the baseRate state variable based on time elapsed since the last redemption or debt borrowing operation.\n\tfunction decayBaseRateAndGetBorrowingFee(uint256 _debt) external returns (uint256) {\n\t\t_requireCallerIsBO();\n\t\tuint256 rate = _decayBaseRate();\n\n\t\treturn _calcBorrowingFee(_calcBorrowingRate(rate), _debt);\n\t}\n\n\tfunction _decayBaseRate() internal returns (uint256) {\n\t\tuint256 decayedBaseRate = _calcDecayedBaseRate();\n\n\t\tbaseRate = decayedBaseRate;\n\t\temit BaseRateUpdated(decayedBaseRate);\n\n\t\t_updateLastFeeOpTime();\n\n\t\treturn decayedBaseRate;\n\t}\n\n\tfunction applyPendingRewards(address _borrower) external returns (uint256 coll, uint256 debt) {\n\t\t_requireCallerIsBO();\n\t\treturn _applyPendingRewards(_borrower);\n\t}\n\n\t// Add the borrowers's coll and debt rewards earned from redistributions, to their Trove\n\tfunction _applyPendingRewards(address _borrower) internal returns (uint256, uint256) {\n\t\tTrove storage t = Troves[_borrower];\n\t\tif (t.status == Status.active) {\n\t\t\t(uint256 pendingCollateralReward, uint256 pendingDebtReward) = getPendingCollAndDebtRewards(_borrower);\n\t\t\t// Apply pending rewards to trove's state\n\t\t\tt.coll += pendingCollateralReward;\n\t\t\tt.debt += pendingDebtReward;\n\n\t\t\t_updateTroveRewardSnapshots(_borrower);\n\n\t\t\t_movePendingTroveRewardsToActiveBalance(pendingDebtReward, pendingCollateralReward);\n\n\t\t\temit TroveUpdated(_borrower, t.debt, t.coll, t.stake, TroveManagerOperation.applyPendingRewards);\n\t\t}\n\t\treturn (t.coll, t.debt);\n\t}\n\n\tfunction _updateTroveRewardSnapshots(address _borrower) internal {\n\t\tuint256 L_collateralCached = L_collateral;\n\t\tuint256 L_debtCached = L_debt;\n\t\tuint256 L_InterestDebtCached = L_Interest_Debt;\n\t\trewardSnapshots[_borrower] = RewardSnapshot(L_collateralCached, L_debtCached, L_InterestDebtCached);\n\t\temit TroveSnapshotsUpdated(L_collateralCached, L_debtCached, L_InterestDebtCached);\n\t}\n\n\tfunction repayInterestDebt(address _borrower) external {\n\t\t_distributeInterestDebt();\n\t\t_applyPendingRewards(_borrower);\n\t\t(uint256 debt, , , ) = getEntireDebtAndColl(_borrower);\n\t\t_repayInterest(msg.sender, _borrower, debt);\n\t}\n\n\tfunction repayInterest(address _account, address _borrower, uint256 _debt) public {\n\t\t_requireCallerIsBO();\n\t\t_repayInterest(_account, _borrower, _debt);\n\t}\n\n\tfunction _repayInterest(address _account, address _borrower, uint256 _debt) internal {\n\t\tuint256 interest = getTroveInterest(_borrower, _debt);\n\t\tif (PropelUSD.balanceOf(_account) >= interest) {\n\t\t\tPropelUSD.burn(_account, interest);\n\t\t} else {\n\t\t\ttotalActiveDebt += interest;\n\t\t\tTroves[_borrower].debt += interest;\n\t\t}\n\t\tdecreaseOutstandingInterestDebt(interest);\n\t\t_updateTroveRewardSnapshots(_borrower);\n\t\temit InsterstPaid(_account, _borrower, interest);\n\t}\n\n\t// Remove borrower's stake from the totalStakes sum, and set their stake to 0\n\tfunction _removeStake(address _borrower) internal {\n\t\tuint256 stake = Troves[_borrower].stake;\n\t\ttotalStakes = totalStakes - stake;\n\t\tTroves[_borrower].stake = 0;\n\t}\n\n\t// Update borrower's stake based on their latest collateral value\n\tfunction _updateStakeAndTotalStakes(Trove storage t) internal returns (uint256) {\n\t\tuint256 newStake = _computeNewStake(t.coll);\n\t\tuint256 oldStake = t.stake;\n\t\tt.stake = newStake;\n\t\tuint256 newTotalStakes = totalStakes - oldStake + newStake;\n\t\ttotalStakes = newTotalStakes;\n\t\temit TotalStakesUpdated(newTotalStakes);\n\n\t\treturn newStake;\n\t}\n\n\t// Calculate a new stake based on the snapshots of the totalStakes and totalCollateral taken at the last liquidation\n\tfunction _computeNewStake(uint256 _coll) internal view returns (uint256) {\n\t\tuint256 stake;\n\t\tuint256 totalCollateralSnapshotCached = totalCollateralSnapshot;\n\t\tif (totalCollateralSnapshotCached == 0) {\n\t\t\tstake = _coll;\n\t\t} else {\n\t\t\t/*\n\t\t\t * The following assert() holds true because:\n\t\t\t * - The system always contains >= 1 trove\n\t\t\t * - When we close or liquidate a trove, we redistribute the pending rewards, so if all troves were closed/liquidated,\n\t\t\t * rewards would’ve been emptied and totalCollateralSnapshot would be zero too.\n\t\t\t */\n\t\t\tuint256 totalStakesSnapshotCached = totalStakesSnapshot;\n\t\t\tassert(totalStakesSnapshotCached > 0);\n\t\t\tstake = (_coll * totalStakesSnapshotCached) / totalCollateralSnapshotCached;\n\t\t}\n\t\treturn stake;\n\t}\n\n\tfunction closeLastTroveWhenSunsetting() external onlyOwner {\n\t\trequire(sunsetting, \"Not in sunsetting\");\n\t\trequire(TroveOwners.length == 1, \"Can only force to close last trove\");\n\t\taddress _borrower = TroveOwners[0];\n\t\tuint256 ICR = getCurrentICR(_borrower, fetchPrice());\n\t\tuint256 TCR = IBorrowerOperations(borrowerOperationsAddress).getTCR();\n\t\trequire(ICR < 1e18 || TCR < MCR, \"Can only force close bad borrower\");\n\t\t(uint256 coll, uint256 debt) = getTroveCollAndDebt(_borrower);\n\t\tuint256 interest = getTroveInterest(_borrower, debt);\n\t\ttotalActiveDebt = totalActiveDebt - debt;\n\t\ttotalActiveCollateral = totalActiveCollateral - coll;\n\t\tPropelUSD.burn(msg.sender, debt + interest);\n\t\t_sendCollateral(msg.sender, coll);\n\t\t_removeStake(_borrower);\n\t\t_closeTrove(_borrower, Status.closedByOwner);\n\t\t_resetState();\n\t}\n\n\t// --- Liquidation Functions ---\n\n\tfunction closeTroveByLiquidation(address _borrower) external {\n\t\t_requireCallerIsLM();\n\t\t_removeStake(_borrower);\n\t\t_closeTrove(_borrower, Status.closedByLiquidation);\n\t}\n\n\tfunction movePendingTroveRewardsToActiveBalances(uint256 _debt, uint256 _collateral) external {\n\t\t_requireCallerIsLM();\n\t\t_movePendingTroveRewardsToActiveBalance(_debt, _collateral);\n\t}\n\n\tfunction _movePendingTroveRewardsToActiveBalance(uint256 _debt, uint256 _collateral) internal {\n\t\tdefaultedDebt -= _debt;\n\t\ttotalActiveDebt += _debt;\n\t\tdefaultedCollateral -= _collateral;\n\t\ttotalActiveCollateral += _collateral;\n\t}\n\n\tfunction addCollateralSurplus(address borrower, uint256 collSurplus) external {\n\t\t_requireCallerIsLM();\n\t\tsurplusBalances[borrower] += collSurplus;\n\t}\n\n\tfunction finalizeLiquidation(address _liquidator, uint256 _debt, uint256 _coll, uint256 _collSurplus, uint256 _debtGasComp, uint256 _collGasComp, uint256 _interest) external {\n\t\t_requireCallerIsLM();\n\t\t// redistribute debt and collateral\n\t\t_redistributeDebtAndColl(_debt, _coll);\n\n\t\tuint256 _activeColl = totalActiveCollateral;\n\t\tif (_collSurplus > 0) {\n\t\t\t_activeColl -= _collSurplus;\n\t\t\ttotalActiveCollateral = _activeColl;\n\t\t}\n\n\t\t// update system snapshos\n\t\ttotalStakesSnapshot = totalStakes;\n\t\ttotalCollateralSnapshot = _activeColl - _collGasComp + defaultedCollateral;\n\t\temit SystemSnapshotsUpdated(totalStakesSnapshot, totalCollateralSnapshot);\n\t\tdecreaseOutstandingInterestDebt(_interest);\n\t\t// send gas compensation\n\t\tPropelUSD.returnFromPool(gasPoolAddress, _liquidator, _debtGasComp);\n\t\t_sendCollateral(_liquidator, _collGasComp);\n\t}\n\n\tfunction _redistributeDebtAndColl(uint256 _debt, uint256 _coll) internal {\n\t\tif (_debt == 0) {\n\t\t\treturn;\n\t\t}\n\t\t/*\n\t\t * Add distributed coll and debt rewards-per-unit-staked to the running totals. Division uses a \"feedback\"\n\t\t * error correction, to keep the cumulative error low in the running totals L_collateral and L_debt:\n\t\t *\n\t\t * 1) Form numerators which compensate for the floor division errors that occurred the last time this\n\t\t * function was called.\n\t\t * 2) Calculate \"per-unit-staked\" ratios.\n\t\t * 3) Multiply each ratio back by its denominator, to reveal the current floor division error.\n\t\t * 4) Store these errors for use in the next correction when this function is called.\n\t\t * 5) Note: static analysis tools complain about this \"division before multiplication\", however, it is intended.\n\t\t */\n\t\tuint256 collateralNumerator = (_coll * DECIMAL_PRECISION) + lastCollateralError_Redistribution;\n\t\tuint256 debtNumerator = (_debt * DECIMAL_PRECISION) + lastDebtError_Redistribution;\n\t\tuint256 totalStakesCached = totalStakes;\n\t\t// Get the per-unit-staked terms\n\t\tuint256 collateralRewardPerUnitStaked = collateralNumerator / totalStakesCached;\n\t\tuint256 debtRewardPerUnitStaked = debtNumerator / totalStakesCached;\n\n\t\tlastCollateralError_Redistribution = collateralNumerator - (collateralRewardPerUnitStaked * totalStakesCached);\n\t\tlastDebtError_Redistribution = debtNumerator - (debtRewardPerUnitStaked * totalStakesCached);\n\n\t\t// Add per-unit-staked terms to the running totals\n\t\tuint256 new_L_collateral = L_collateral + collateralRewardPerUnitStaked;\n\t\tuint256 new_L_debt = L_debt + debtRewardPerUnitStaked;\n\t\tL_collateral = new_L_collateral;\n\t\tL_debt = new_L_debt;\n\n\t\temit LTermsUpdated(new_L_collateral, new_L_debt);\n\n\t\ttotalActiveDebt -= _debt;\n\t\tdefaultedDebt += _debt;\n\t\tdefaultedCollateral += _coll;\n\t\ttotalActiveCollateral -= _coll;\n\t}\n\n\t// --- Trove property setters ---\n\n\tfunction _sendCollateral(address _account, uint256 _amount) private {\n\t\tif (_amount > 0) {\n\t\t\ttotalActiveCollateral = totalActiveCollateral - _amount;\n\t\t\temit CollateralSent(_account, _amount);\n\n\t\t\tcollateralToken.safeTransfer(_account, _amount);\n\t\t}\n\t}\n\n\tfunction _increaseDebt(address account, uint256 netDebtAmount, uint256 debtAmount) internal {\n\t\tuint256 _newTotalDebt = totalActiveDebt + netDebtAmount;\n\t\trequire(_newTotalDebt + defaultedDebt <= maxSystemDebt, \"Collateral debt limit reached\");\n\t\ttotalActiveDebt = _newTotalDebt;\n\t\tPropelUSD.mint(account, debtAmount);\n\t}\n\n\tfunction decreaseDebtAndSendCollateral(address account, uint256 debt, uint256 coll) external {\n\t\t_requireCallerIsLM();\n\t\t_decreaseDebt(account, debt);\n\t\t_sendCollateral(account, coll);\n\t}\n\n\tfunction _decreaseDebt(address account, uint256 amount) internal {\n\t\tPropelUSD.burn(account, amount);\n\t\ttotalActiveDebt = totalActiveDebt - amount;\n\t}\n\n\t// --- Requires ---\n\n\tfunction _requireCallerIsBO() internal view {\n\t\trequire(msg.sender == borrowerOperationsAddress, \"Caller not BO\");\n\t}\n\n\tfunction _requireCallerIsLM() internal view {\n\t\trequire(msg.sender == liquidationManager, \"Not Liquidation Manager\");\n\t}\n}\n"
    },
    "contracts/core/Vest.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"../dependencies/PropelOwnableUpgradeable.sol\";\nimport \"../interfaces/IPropel.sol\";\nimport \"../interfaces/IEsPropel.sol\";\n\ncontract Vest is PropelOwnableUpgradeable {\n\tenum State {\n\t\tinCliff,\n\t\tinRelease,\n\t\toutOfRelease\n\t}\n\n\tstruct OrderInfo {\n\t\tuint64 start;\n\t\tuint64 cliffEnd;\n\t\tuint64 releaseEnd;\n\t\tuint64 released;\n\t\tuint256 amount;\n\t}\n\n\tIEsPropel public esPropel;\n\tIPropel public Propel;\n\n\tuint64 public cliffTime;\n\tuint64 public releaseTime;\n\tuint64 public minDeposits;\n\n\tmapping(address => uint256) public currentIds;\n\tmapping(address => mapping(uint256 => OrderInfo)) public orderInfos;\n\n\tevent Staked(address account, uint256 id, uint256 amount);\n\tevent Claimed(address account, uint256 id, uint256 amount);\n\n\tfunction initialize(IPropelCore _PropelCore, IPropel _Propel, IEsPropel _esPropel) external initializer {\n\t\t__InitCore(_PropelCore);\n\t\tPropel = _Propel;\n\t\tesPropel = _esPropel;\n\t\tcliffTime = 14 days;\n\t\treleaseTime = 14 days;\n\t\tminDeposits = 1e18;\n\t}\n\n\tfunction stake(uint256 amount) external {\n\t\trequire(amount >= minDeposits, \"Vest: too little deposits to stake\");\n\t\taddress account = msg.sender;\n\t\tesPropel.sendToken(account, amount);\n\t\tuint256 currentId = currentIds[account]++;\n\t\torderInfos[account][currentId] = OrderInfo({ start: uint64(block.timestamp), cliffEnd: uint64(block.timestamp + cliffTime), releaseEnd: uint64(block.timestamp + cliffTime + releaseTime), released: 0, amount: amount });\n\t\temit Staked(account, currentId, amount);\n\t}\n\n\tfunction stateOf(address account, uint256 id) public view returns (State) {\n\t\trequire(id < currentIds[account], \"Vest: invalid order id\");\n\t\tif (block.timestamp < orderInfos[account][id].cliffEnd) {\n\t\t\treturn State.inCliff;\n\t\t} else if (block.timestamp < orderInfos[account][id].releaseEnd) {\n\t\t\treturn State.inRelease;\n\t\t}\n\t\treturn State.outOfRelease;\n\t}\n\n\tfunction claimAll(uint256[] memory ids) external {\n\t\taddress account = msg.sender;\n\t\tfor (uint256 i = 0; i < ids.length; i++) {\n\t\t\tuint256 id = ids[i];\n\t\t\trequire(id < currentIds[account], \"Vest: invalid id\");\n\t\t\tState state = stateOf(account, id);\n\t\t\tuint64 total = orderInfos[account][id].releaseEnd - orderInfos[account][id].cliffEnd;\n\t\t\tif (orderInfos[account][id].released == total) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (state == State.inCliff) {\n\t\t\t\tcontinue;\n\t\t\t} else if (state == State.inRelease) {\n\t\t\t\tuint64 walked = uint64(block.timestamp - orderInfos[account][id].cliffEnd);\n\t\t\t\tuint256 amount = ((walked - orderInfos[account][id].released) * orderInfos[account][id].amount) / total;\n\t\t\t\torderInfos[account][id].released = walked;\n\t\t\t\tPropel.esPropel2Propel(account, amount);\n\t\t\t\temit Claimed(account, id, amount);\n\t\t\t} else {\n\t\t\t\tuint64 leftWalk = total - orderInfos[account][id].released;\n\t\t\t\tuint256 amount = (leftWalk * orderInfos[account][id].amount) / total;\n\t\t\t\torderInfos[account][id].released = total;\n\t\t\t\tPropel.esPropel2Propel(account, amount);\n\t\t\t\temit Claimed(account, id, amount);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction claim(uint256 id) external {\n\t\taddress account = msg.sender;\n\t\trequire(id < currentIds[account], \"Vest: invalid id\");\n\t\tState state = stateOf(account, id);\n\t\tuint64 total = orderInfos[account][id].releaseEnd - orderInfos[account][id].cliffEnd;\n\t\trequire(orderInfos[account][id].released < total, \"Vest: order claimed\");\n\t\tif (state == State.inCliff) {\n\t\t\trevert(\"Vest: in cliff\");\n\t\t} else if (state == State.inRelease) {\n\t\t\tuint64 walked = uint64(block.timestamp - orderInfos[account][id].cliffEnd);\n\t\t\tuint256 amount = ((walked - orderInfos[account][id].released) * orderInfos[account][id].amount) / total;\n\t\t\torderInfos[account][id].released = walked;\n\t\t\tPropel.esPropel2Propel(account, amount);\n\t\t\temit Claimed(account, id, amount);\n\t\t} else {\n\t\t\tuint64 leftWalk = total - orderInfos[account][id].released;\n\t\t\tuint256 amount = (leftWalk * orderInfos[account][id].amount) / total;\n\t\t\torderInfos[account][id].released = total;\n\t\t\tPropel.esPropel2Propel(account, amount);\n\t\t\temit Claimed(account, id, amount);\n\t\t}\n\t}\n\n\tfunction earned(address account, uint256 id) public view returns (uint256) {\n\t\trequire(id < currentIds[account], \"Vest: invalid id\");\n\t\tState state = stateOf(account, id);\n\t\tuint64 total = orderInfos[account][id].releaseEnd - orderInfos[account][id].cliffEnd;\n\t\tif (total == orderInfos[account][id].released) {\n\t\t\treturn 0;\n\t\t}\n\t\tif (state == State.inCliff) {\n\t\t\treturn 0;\n\t\t} else if (state == State.inRelease) {\n\t\t\tuint64 walked = uint64(block.timestamp - orderInfos[account][id].cliffEnd);\n\t\t\treturn ((walked - orderInfos[account][id].released) * orderInfos[account][id].amount) / total;\n\t\t} else {\n\t\t\tuint64 leftWalk = total - orderInfos[account][id].released;\n\t\t\treturn (leftWalk * orderInfos[account][id].amount) / total;\n\t\t}\n\t}\n\n\tfunction batchEarned(address account, uint256[] memory ids) public view returns (uint256[] memory earneds) {\n\t\tearneds = new uint256[](ids.length);\n\t\tfor (uint256 i = 0; i < ids.length; i++) {\n\t\t\tearneds[i] = earned(account, ids[i]);\n\t\t}\n\t}\n\n\tfunction totalEarned(address account, uint256[] memory ids) public view returns (uint256 total) {\n\t\tfor (uint256 i = 0; i < ids.length; i++) {\n\t\t\ttotal += earned(account, ids[i]);\n\t\t}\n\t}\n}\n"
    },
    "contracts/dependencies/BlastWrapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"./PropelOwnable.sol\";\nimport \"../interfaces/IBlast.sol\";\nimport \"../interfaces/IWETH.sol\";\n\ncontract BlastWrapper is PropelOwnable {\n\n\tconstructor(IPropelCore _propelCore) PropelOwnable(_propelCore) {\n\t\tblast().configureClaimableGas();\n\t\tWETH().configure(YieldMode.CLAIMABLE);\n\t}\n\n\tfunction getClaimableWETH() public view returns(uint256) {\n\t\treturn WETH().getClaimableAmount(address(this));\n\t}\n\n\tfunction claimAllYield(address to) external onlyOwner {\n\t\tuint256 amount = getClaimableWETH();\n\t\trequire(amount > 0, \"no claimable amount\");\n\t\tWETH().claim(to, amount);\n\t}\n\n\tfunction claimAllGas(address to) external onlyOwner {\n\t\tblast().claimAllGas(address(this), to);\n\t}\n}\n"
    },
    "contracts/dependencies/BlastWrapperUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"./PropelOwnableUpgradeable.sol\";\nimport \"../interfaces/IBlast.sol\";\nimport \"../interfaces/IWETH.sol\";\n\ncontract BlastWrapperUpgradeable is PropelOwnableUpgradeable {\n\n\tfunction __Init_Blast(IPropelCore _propelCore) internal {\n\t\t__InitCore(_propelCore);\n\t\tblast().configureClaimableGas();\n\t\tWETH().configure(YieldMode.CLAIMABLE);\n\t}\n\n\tfunction getClaimableWETH() public view returns(uint256) {\n\t\treturn WETH().getClaimableAmount(address(this));\n\t}\n\n\tfunction claimAllYield(address to) external onlyOwner {\n\t\tuint256 amount = getClaimableWETH();\n\t\trequire(amount > 0, \"no claimable amount\");\n\t\tWETH().claim(to, amount);\n\t}\n\n\tfunction claimAllGas(address to) external onlyOwner {\n\t\tblast().claimAllGas(address(this), to);\n\t}\n}\n"
    },
    "contracts/dependencies/console.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\n// Buidler's helper contract for console logging\nlibrary console {\n\taddress public constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);\n\n\tfunction log() internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log()\"));\n\t\tignored;\n\t}\n\n\tfunction logInt(int p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(int)\", p0));\n\t\tignored;\n\t}\n\n\tfunction loguint256(uint256 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logString(string memory p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBool(bool p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logAddress(address p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes(bytes memory p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logByte(bytes1 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(byte)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes1(bytes1 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes1)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes2(bytes2 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes2)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes3(bytes3 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes3)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes4(bytes4 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes4)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes5(bytes5 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes5)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes6(bytes6 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes6)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes7(bytes7 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes7)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes8(bytes8 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes8)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes9(bytes9 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes9)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes10(bytes10 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes10)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes11(bytes11 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes11)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes12(bytes12 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes12)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes13(bytes13 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes13)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes14(bytes14 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes14)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes15(bytes15 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes15)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes16(bytes16 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes16)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes17(bytes17 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes17)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes18(bytes18 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes18)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes19(bytes19 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes19)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes20(bytes20 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes20)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes21(bytes21 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes21)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes22(bytes22 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes22)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes23(bytes23 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes23)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes24(bytes24 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes24)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes25(bytes25 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes25)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes26(bytes26 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes26)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes27(bytes27 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes27)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes28(bytes28 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes28)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes29(bytes29 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes29)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes30(bytes30 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes30)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes31(bytes31 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes31)\", p0));\n\t\tignored;\n\t}\n\n\tfunction logBytes32(bytes32 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bytes32)\", p0));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256)\", p0));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string)\", p0));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool)\", p0));\n\t\tignored;\n\t}\n\n\tfunction log(address p0) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address)\", p0));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address)\", p0, p1));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,uint256)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, string memory p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,string)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, bool p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,bool)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, address p2) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,address)\", p0, p1, p2));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, uint256 p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,uint256,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, string memory p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,string,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, bool p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,bool,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(uint256 p0, address p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(uint256,address,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, uint256 p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,uint256,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, string memory p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,string,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, bool p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,bool,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(string memory p0, address p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(string,address,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, uint256 p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,uint256,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, string memory p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,string,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, bool p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,bool,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(bool p0, address p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(bool,address,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, uint256 p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,uint256,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, string memory p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,string,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, bool p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,bool,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,uint256,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,uint256,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,uint256,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, uint256 p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,uint256,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,string,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,string,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,string,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, string memory p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,string,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, bool p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,bool,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, bool p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,bool,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, bool p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,bool,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, bool p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,bool,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, address p2, uint256 p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,address,uint256)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, address p2, string memory p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,address,string)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, address p2, bool p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,address,bool)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n\n\tfunction log(address p0, address p1, address p2, address p3) internal view {\n\t\t(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature(\"log(address,address,address,address)\", p0, p1, p2, p3));\n\t\tignored;\n\t}\n}\n"
    },
    "contracts/dependencies/DelegatedOps.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\n/**\n    @title Propel Delegated Operations\n    @notice Allows delegation to specific contract functionality. Useful for creating\n            wrapper contracts to bundle multiple interactions into a single call.\n\n            Functions that supports delegation should include an `account` input allowing\n            the delegated caller to indicate who they are calling on behalf of. In executing\n            the call, all internal state updates should be applied for `account` and all\n            value transfers should occur to or from the caller.\n\n            For example: a delegated call to `openTrove` should transfer collateral\n            from the caller, create the debt position for `account`, and send newly\n            minted tokens to the caller.\n */\ncontract DelegatedOps {\n\tmapping(address => mapping(address => bool)) public isApprovedDelegate;\n\n\tmodifier callerOrDelegated(address _account) {\n\t\trequire(msg.sender == _account || isApprovedDelegate[_account][msg.sender], \"Delegate not approved\");\n\t\t_;\n\t}\n\n\tfunction setDelegateApproval(address _delegate, bool _isApproved) external {\n\t\tisApprovedDelegate[msg.sender][_delegate] = _isApproved;\n\t}\n}\n"
    },
    "contracts/dependencies/PropelBase.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\nimport \"../interfaces/IPropelBase.sol\";\n\n/*\n * Base contract for TroveManager, BorrowerOperations and StabilityPool. Contains global system constants and\n * common functions.\n */\ncontract PropelBase is IPropelBase {\n\tuint256 public constant override DECIMAL_PRECISION = 1e18;\n\n\t// Critical system collateral ratio. If the system's total collateral ratio (TCR) falls below the CCR, Recovery Mode is triggered.\n\tuint256 public constant override CCR = 1500000000000000000; // 150%\n\n\t// Amount of debt to be locked in gas pool on opening troves\n\tuint256 public immutable override DEBT_GAS_COMPENSATION;\n\n\tuint256 public constant override PERCENT_DIVISOR = 200; // dividing by 200 yields 0.5%\n\n\tconstructor(uint256 _gasCompensation) {\n\t\tDEBT_GAS_COMPENSATION = _gasCompensation;\n\t}\n\n\t// --- Gas compensation functions ---\n\n\t// Returns the composite debt (drawn debt + gas compensation) of a trove, for the purpose of ICR calculation\n\tfunction _getCompositeDebt(uint256 _debt) internal view returns (uint256) {\n\t\treturn _debt + DEBT_GAS_COMPENSATION;\n\t}\n\n\tfunction _getNetDebt(uint256 _debt) internal view returns (uint256) {\n\t\treturn _debt - DEBT_GAS_COMPENSATION;\n\t}\n\n\t// Return the amount of collateral to be drawn from a trove's collateral and sent as gas compensation.\n\tfunction _getCollGasCompensation(uint256 _entireColl) internal pure returns (uint256) {\n\t\treturn _entireColl / PERCENT_DIVISOR;\n\t}\n\n\tfunction _requireUserAcceptsFee(uint256 _fee, uint256 _amount, uint256 _maxFeePercentage) internal pure {\n\t\tuint256 feePercentage = (_fee * DECIMAL_PRECISION) / _amount;\n\t\trequire(feePercentage <= _maxFeePercentage, \"Fee exceeded provided maximum\");\n\t}\n}\n"
    },
    "contracts/dependencies/PropelMath.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nlibrary PropelMath {\n\tuint256 internal constant DECIMAL_PRECISION = 1e18;\n\n\t/* Precision for Nominal ICR (independent of price). Rationale for the value:\n\t *\n\t * - Making it “too high” could lead to overflows.\n\t * - Making it “too low” could lead to an ICR equal to zero, due to truncation from Solidity floor division.\n\t *\n\t * This value of 1e20 is chosen for safety: the NICR will only overflow for numerator > ~1e39,\n\t * and will only truncate to 0 if the denominator is at least 1e20 times greater than the numerator.\n\t *\n\t */\n\tuint256 internal constant NICR_PRECISION = 1e20;\n\n\tfunction _min(uint256 _a, uint256 _b) internal pure returns (uint256) {\n\t\treturn (_a < _b) ? _a : _b;\n\t}\n\n\tfunction _max(uint256 _a, uint256 _b) internal pure returns (uint256) {\n\t\treturn (_a >= _b) ? _a : _b;\n\t}\n\n\t/*\n\t * Multiply two decimal numbers and use normal rounding rules:\n\t * -round product up if 19'th mantissa digit >= 5\n\t * -round product down if 19'th mantissa digit < 5\n\t *\n\t * Used only inside the exponentiation, _decPow().\n\t */\n\tfunction decMul(uint256 x, uint256 y) internal pure returns (uint256 decProd) {\n\t\tuint256 prod_xy = x * y;\n\n\t\tdecProd = (prod_xy + (DECIMAL_PRECISION / 2)) / DECIMAL_PRECISION;\n\t}\n\n\t/*\n\t * _decPow: Exponentiation function for 18-digit decimal base, and integer exponent n.\n\t *\n\t * Uses the efficient \"exponentiation by squaring\" algorithm. O(log(n)) complexity.\n\t *\n\t * TroveManager._calcDecayedBaseRate\n\t *\n\t * The exponent is capped to avoid reverting due to overflow. The cap 525600000 equals\n\t * \"minutes in 1000 years\": 60 * 24 * 365 * 1000\n\t *\n\t * If a period of > 1000 years is ever used as an exponent in either of the above functions, the result will be\n\t * negligibly different from just passing the cap, since:\n\t *\n\t * the decayed base rate will be 0 for 1000 years or > 1000 years\n\t */\n\tfunction _decPow(uint256 _base, uint256 _minutes) internal pure returns (uint256) {\n\t\tif (_minutes > 525600000) {\n\t\t\t_minutes = 525600000;\n\t\t} // cap to avoid overflow\n\n\t\tif (_minutes == 0) {\n\t\t\treturn DECIMAL_PRECISION;\n\t\t}\n\n\t\tuint256 y = DECIMAL_PRECISION;\n\t\tuint256 x = _base;\n\t\tuint256 n = _minutes;\n\n\t\t// Exponentiation-by-squaring\n\t\twhile (n > 1) {\n\t\t\tif (n % 2 == 0) {\n\t\t\t\tx = decMul(x, x);\n\t\t\t\tn = n / 2;\n\t\t\t} else {\n\t\t\t\t// if (n % 2 != 0)\n\t\t\t\ty = decMul(x, y);\n\t\t\t\tx = decMul(x, x);\n\t\t\t\tn = (n - 1) / 2;\n\t\t\t}\n\t\t}\n\n\t\treturn decMul(x, y);\n\t}\n\n\tfunction _getAbsoluteDifference(uint256 _a, uint256 _b) internal pure returns (uint256) {\n\t\treturn (_a >= _b) ? _a - _b : _b - _a;\n\t}\n\n\tfunction _computeNominalCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) {\n\t\tif (_debt > 0) {\n\t\t\treturn (_coll * NICR_PRECISION) / _debt;\n\t\t}\n\t\t// Return the maximal value for uint256 if the Trove has a debt of 0. Represents \"infinite\" CR.\n\t\telse {\n\t\t\t// if (_debt == 0)\n\t\t\treturn 2 ** 256 - 1;\n\t\t}\n\t}\n\n\tfunction _computeCR(uint256 _coll, uint256 _debt, uint256 _price) internal pure returns (uint256) {\n\t\tif (_debt > 0) {\n\t\t\tuint256 newCollRatio = (_coll * _price) / _debt;\n\n\t\t\treturn newCollRatio;\n\t\t}\n\t\t// Return the maximal value for uint256 if the Trove has a debt of 0. Represents \"infinite\" CR.\n\t\telse {\n\t\t\t// if (_debt == 0)\n\t\t\treturn type(uint256).max;\n\t\t}\n\t}\n\n\tfunction _computeCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) {\n\t\tif (_debt > 0) {\n\t\t\tuint256 newCollRatio = (_coll) / _debt;\n\n\t\t\treturn newCollRatio;\n\t\t}\n\t\t// Return the maximal value for uint256 if the Trove has a debt of 0. Represents \"infinite\" CR.\n\t\telse {\n\t\t\t// if (_debt == 0)\n\t\t\treturn type(uint256).max;\n\t\t}\n\t}\n}\n"
    },
    "contracts/dependencies/PropelOwnable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"../interfaces/IPropelCore.sol\";\n\n/**\n    @title Propel Ownable\n    @notice Contracts inheriting `PropelOwnable` have the same owner as `PropelCore`.\n            The ownership cannot be independently modified or renounced.\n */\ncontract PropelOwnable {\n\tIPropelCore public immutable PropelCore;\n\n\tconstructor(IPropelCore _PropelCore) {\n\t\tPropelCore = _PropelCore;\n\t}\n\n\tmodifier onlyOwner() {\n\t\trequire(msg.sender == owner(), \"Only owner\");\n\t\t_;\n\t}\n\n\tmodifier onlyGuardian() {\n\t\trequire(msg.sender == guardian(), \"Only guardian\");\n\t\t_;\n\t}\n\n\tfunction owner() public view returns (address) {\n\t\treturn PropelCore.owner();\n\t}\n\n\tfunction guardian() public view returns (address) {\n\t\treturn PropelCore.guardian();\n\t}\n\n\tfunction WETH() public view returns(IWETH) {\n\t\treturn PropelCore.WETH();\n\t}\n\n\tfunction blast() public view returns(IBlast) {\n\t\treturn PropelCore.blast();\n\t}\n}\n"
    },
    "contracts/dependencies/PropelOwnableUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"../interfaces/IPropelCore.sol\";\n\n/**\n    @title Propel Ownable\n    @notice Contracts inheriting `PropelOwnable` have the same owner as `PropelCore`.\n            The ownership cannot be independently modified or renounced.\n */\ncontract PropelOwnableUpgradeable is Initializable {\n\tIPropelCore public PropelCore;\n\n\tfunction __InitCore(IPropelCore _PropelCore) internal {\n\t\tPropelCore = _PropelCore;\n\t}\n\n\tmodifier onlyOwner() {\n\t\trequire(msg.sender == owner(), \"Only owner\");\n\t\t_;\n\t}\n\n\tmodifier onlyGuardian() {\n\t\trequire(msg.sender == guardian(), \"Only guardian\");\n\t\t_;\n\t}\n\n\tfunction owner() public view returns (address) {\n\t\treturn PropelCore.owner();\n\t}\n\n\tfunction guardian() public view returns (address) {\n\t\treturn PropelCore.guardian();\n\t}\n\n\tfunction WETH() public view returns(IWETH) {\n\t\treturn PropelCore.WETH();\n\t}\n\n\tfunction blast() public view returns(IBlast) {\n\t\treturn PropelCore.blast();\n\t}\n}\n"
    },
    "contracts/dependencies/SystemStart.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"../interfaces/IPropelCore.sol\";\n\n/**\n    @title Propel System Start Time\n    @dev Provides a unified `startTime` and `getWeek`, used for emissions.\n */\ncontract SystemStart {\n\tuint256 public immutable startTime;\n\n\tconstructor(IPropelCore PropelCore) {\n\t\tstartTime = PropelCore.startTime();\n\t}\n}\n"
    },
    "contracts/interfaces/IBlast.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nenum YieldMode {\n\tAUTOMATIC,\n\tVOID,\n\tCLAIMABLE\n}\n\nenum GasMode {\n\tVOID,\n\tCLAIMABLE\n}\n\ninterface IERC20Rebasing {\n\t// changes the yield mode of the caller and update the balance\n\t// to reflect the configuration\n\tfunction configure(YieldMode) external returns (uint256);\n\n\t// \"claimable\" yield mode accounts can call this this claim their yield\n\t// to another address\n\tfunction claim(address recipient, uint256 amount) external returns (uint256);\n\n\t// read the claimable amount for an account\n\tfunction getClaimableAmount(address account) external view returns (uint256);\n}\n\ninterface IBlast {\n\t// configure\n\tfunction configureContract(address contractAddress, YieldMode _yield, GasMode gasMode, address governor) external;\n\n\tfunction configure(YieldMode _yield, GasMode gasMode, address governor) external;\n\n\t// base configuration options\n\tfunction configureClaimableYield() external;\n\n\tfunction configureClaimableYieldOnBehalf(address contractAddress) external;\n\n\tfunction configureAutomaticYield() external;\n\n\tfunction configureAutomaticYieldOnBehalf(address contractAddress) external;\n\n\tfunction configureVoidYield() external;\n\n\tfunction configureVoidYieldOnBehalf(address contractAddress) external;\n\n\tfunction configureClaimableGas() external;\n\n\tfunction configureClaimableGasOnBehalf(address contractAddress) external;\n\n\tfunction configureVoidGas() external;\n\n\tfunction configureVoidGasOnBehalf(address contractAddress) external;\n\n\tfunction configureGovernor(address _governor) external;\n\n\tfunction configureGovernorOnBehalf(address _newGovernor, address contractAddress) external;\n\n\t// claim yield\n\tfunction claimYield(address contractAddress, address recipientOfYield, uint256 amount) external returns (uint256);\n\n\tfunction claimAllYield(address contractAddress, address recipientOfYield) external returns (uint256);\n\n\t// claim gas\n\tfunction claimAllGas(address contractAddress, address recipientOfGas) external returns (uint256);\n\n\tfunction claimGasAtMinClaimRate(address contractAddress, address recipientOfGas, uint256 minClaimRateBips) external returns (uint256);\n\n\tfunction claimMaxGas(address contractAddress, address recipientOfGas) external returns (uint256);\n\n\tfunction claimGas(address contractAddress, address recipientOfGas, uint256 gasToClaim, uint256 gasSecondsToConsume) external returns (uint256);\n\n\t// read functions\n\tfunction readClaimableYield(address contractAddress) external view returns (uint256);\n\n\tfunction readYieldConfiguration(address contractAddress) external view returns (uint8);\n\n\tfunction readGasParams(address contractAddress) external view returns (uint256 etherSeconds, uint256 etherBalance, uint256 lastUpdated, GasMode);\n}\n"
    },
    "contracts/interfaces/IBorrowerOperations.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./ITroveManager.sol\";\n\ninterface IBorrowerOperations {\n\tstruct SystemBalances {\n\t\tuint256[] collaterals;\n\t\tuint256[] debts;\n\t\tuint256[] prices;\n\t}\n\n\tenum BorrowerOperation {\n\t\topenTrove,\n\t\tcloseTrove,\n\t\tadjustTrove\n\t}\n\n\tevent BorrowingFeePaid(address indexed borrower, uint256 amount);\n\tevent CollateralConfigured(ITroveManager troveManager, IERC20 collateralToken);\n\tevent TroveCreated(address indexed _borrower, uint256 arrayIndex);\n\tevent TroveManagerRemoved(ITroveManager troveManager);\n\tevent TroveUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 stake, BorrowerOperation operation);\n\n\tfunction addColl(ITroveManager troveManager, address account, uint256 _collateralAmount, address _upperHint, address _lowerHint) external;\n\n\tfunction adjustTrove(ITroveManager troveManager, address account, uint256 _maxFeePercentage, uint256 _collDeposit, uint256 _collWithdrawal, uint256 _debtChange, bool _isDebtIncrease, address _upperHint, address _lowerHint) external;\n\n\tfunction closeTrove(ITroveManager troveManager, address account) external;\n\n\tfunction configureCollateral(ITroveManager troveManager, IERC20 collateralToken) external;\n\n\tfunction fetchBalances() external returns (SystemBalances memory balances);\n\n\tfunction getGlobalSystemBalances() external returns (uint256 totalPricedCollateral, uint256 totalDebt);\n\n\tfunction getTCR() external returns (uint256 globalTotalCollateralRatio);\n\n\tfunction openTrove(ITroveManager troveManager, address account, uint256 _maxFeePercentage, uint256 _collateralAmount, uint256 _debtAmount, address _upperHint, address _lowerHint) external;\n\n\tfunction removeTroveManager(ITroveManager troveManager) external;\n\n\tfunction repayDebt(ITroveManager troveManager, address account, uint256 _debtAmount, address _upperHint, address _lowerHint) external;\n\n\tfunction setMinNetDebt(uint256 _minNetDebt) external;\n\n\tfunction withdrawColl(ITroveManager troveManager, address account, uint256 _collWithdrawal, address _upperHint, address _lowerHint) external;\n\n\tfunction withdrawDebt(ITroveManager troveManager, address account, uint256 _maxFeePercentage, uint256 _debtAmount, address _upperHint, address _lowerHint) external;\n\n\tfunction factory() external view returns (address);\n\n\tfunction getCompositeDebt(uint256 _debt) external view returns (uint256);\n\n\tfunction minNetDebt() external view returns (uint256);\n\n\tfunction checkRecoveryMode(uint256 TCR) external pure returns (bool);\n}\n"
    },
    "contracts/interfaces/ICommunityIssuance.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\ninterface ICommunityIssuance {\n\tevent EsPropelIssued(uint256 amount);\n\tevent EsPropelSent(address to, uint256 amount);\n\tevent RewardPerSecUpdated(uint256 _rewardPerSec);\n\n\tfunction issueEsPropel() external returns (uint256);\n\n\tfunction sendEsPropel(address to, uint256 amount) external;\n\n\tfunction pendingReward() external view returns (uint256 pending);\n}\n"
    },
    "contracts/interfaces/IEsPropel.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IEsPropel is IERC20 {\n\tevent SenderUpdated(address sender, bool enabled);\n\tevent ReceiverUpdated(address receiver, bool enabled);\n\n\tfunction mint(address account, uint256 amount) external;\n\n\tfunction burn(uint256 amount) external;\n\n\tfunction burnFrom(address account, uint256 amount) external;\n\n\tfunction burnFromPropel(address account, uint256 amount) external;\n\n\tfunction sendToken(address account, uint256 amount) external;\n}\n"
    },
    "contracts/interfaces/IEsPropelStaking.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"./IEsPropel.sol\";\n\ninterface IEsPropelStaking {\n\tevent TokenUpdated(address token);\n\tevent FeeIncreased(address token, uint256 amount);\n\tevent StakedWithLock(address user, uint256 id, uint256 lockIndex, uint256 amount);\n\tevent StakedWithoutLock(address user, uint256 id, uint256 amount);\n\tevent Claimed(address user, uint256 id, uint256 amount);\n\tevent Withdrawn(address user, uint256 id, uint256 amount);\n\n\tfunction tokensLength() external view returns (uint256);\n\n\tfunction tokenAt(uint256 i) external view returns (address, uint256);\n\n\tfunction earned(address user, address token, uint256 id) external view returns (uint256);\n\n\tfunction submit(address token, uint256 amount) external;\n\n\tfunction esPropel() external view returns (IEsPropel);\n\n\tfunction tokenExists(address _token) external view returns (bool);\n\n\tfunction totalStakes() external view returns (uint256);\n}\n"
    },
    "contracts/interfaces/ILiquidationManager.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\ninterface ILiquidationManager {\n\tevent Liquidation(uint256 _liquidatedDebt, uint256 _liquidatedColl, uint256 _collGasCompensation, uint256 _debtGasCompensation);\n\tevent TroveLiquidated(address indexed _borrower, uint256 _debt, uint256 _coll, uint8 _operation);\n\tevent TroveUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 _stake, uint8 _operation);\n\n\tfunction batchLiquidateTroves(address troveManager, address[] calldata _troveArray) external;\n\n\tfunction enableTroveManager(address _troveManager) external;\n\n\tfunction liquidate(address troveManager, address borrower) external;\n\n\tfunction liquidateTroves(address troveManager, uint256 maxTrovesToLiquidate, uint256 maxICR) external;\n\n\tfunction CCR() external view returns (uint256);\n\n\tfunction DEBT_GAS_COMPENSATION() external view returns (uint256);\n\n\tfunction DECIMAL_PRECISION() external view returns (uint256);\n\n\tfunction PERCENT_DIVISOR() external view returns (uint256);\n\n\tfunction borrowerOperations() external view returns (address);\n\n\tfunction factory() external view returns (address);\n\n\tfunction stabilityPool() external view returns (address);\n}\n"
    },
    "contracts/interfaces/IPriceFeed.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"../interfaces/IPyth.sol\";\n\ninterface IPriceFeed {\n\tstruct OracleRecord {\n\t\tIPyth pyth;\n\t\tuint32 decimals;\n\t\tuint32 heartbeat;\n\t\tbool isFeedWorking;\n\t}\n\n\tstruct PriceRecord {\n\t\tuint96 scaledPrice;\n\t\tuint32 timestamp;\n\t\tuint32 lastUpdated;\n\t}\n\n\tstruct FeedResponse {\n\t\tint64 price;\n\t\t// Confidence interval around the price\n\t\tuint64 conf;\n\t\t// Price exponent\n\t\tint32 expo;\n\t\t// Unix timestamp describing when the price was published\n\t\tuint publishTime;\n\t\tbool success;\n\t}\n\n\t// Custom Errors --------------------------------------------------------------------------------------------------\n\n\terror PriceFeed__InvalidFeedResponseError();\n\terror PriceFeed__FeedFrozenError();\n\terror PriceFeed__UnknownFeedError();\n\terror PriceFeed__HeartbeatOutOfBoundsError();\n\n\t// Events ---------------------------------------------------------------------------------------------------------\n\n\tevent NewOracleRegistered(address pyth);\n\tevent PriceFeedStatusUpdated(address oracle, bool isWorking);\n\tevent PriceRecordUpdated(uint256 _price);\n\n\tfunction fetchPrice(address _token) external returns (uint256);\n}\n"
    },
    "contracts/interfaces/IPropel.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IPropel is IERC20 {\n\tevent EsPropelToPropel(address account, uint256 amount);\n\n\tevent PropelToEsPropel(address account, uint256 amount);\n\n\tfunction propel2EsPropel(address account, uint256 amount) external;\n\n\tfunction esPropel2Propel(address account, uint256 amount) external;\n\n\tfunction burn(uint256 amount) external;\n\n\tfunction burnFrom(address account, uint256 amount) external;\n}\n"
    },
    "contracts/interfaces/IPropelBase.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\ninterface IPropelBase {\n\tfunction DECIMAL_PRECISION() external view returns (uint256);\n\n\t// Critical system collateral ratio. If the system's total collateral ratio (TCR) falls below the CCR, Recovery Mode is triggered.\n\tfunction CCR() external view returns (uint256); // 150%\n\n\t// Amount of debt to be locked in gas pool on opening troves\n\tfunction DEBT_GAS_COMPENSATION() external view returns (uint256);\n\n\tfunction PERCENT_DIVISOR() external view returns (uint256);\n}\n"
    },
    "contracts/interfaces/IPropelCore.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"../interfaces/IBlast.sol\";\nimport \"../interfaces/IWETH.sol\";\n\ninterface IPropelCore {\n\tevent FeeReceiverSet(address feeReceiver);\n\tevent GuardianSet(address guardian);\n\tevent NewOwnerAccepted(address oldOwner, address owner);\n\tevent NewOwnerCommitted(address owner, address pendingOwner, uint256 deadline);\n\tevent NewOwnerRevoked(address owner, address revokedOwner);\n\tevent Paused();\n\tevent PriceFeedSet(address priceFeed);\n\tevent Unpaused();\n\n\tfunction acceptTransferOwnership() external;\n\n\tfunction commitTransferOwnership(address newOwner) external;\n\n\tfunction revokeTransferOwnership() external;\n\n\tfunction setFeeReceiver(address _feeReceiver) external;\n\n\tfunction setGuardian(address _guardian) external;\n\n\tfunction setPaused(bool _paused) external;\n\n\tfunction setPriceFeed(address _priceFeed) external;\n\n\tfunction OWNERSHIP_TRANSFER_DELAY() external view returns (uint256);\n\n\tfunction feeReceiver() external view returns (address);\n\n\tfunction guardian() external view returns (address);\n\n\tfunction owner() external view returns (address);\n\n\tfunction WETH() external view returns(IWETH);\n\n\tfunction blast() external view returns(IBlast);\n\n\tfunction ownershipTransferDeadline() external view returns (uint256);\n\n\tfunction paused() external view returns (bool);\n\n\tfunction pendingOwner() external view returns (address);\n\n\tfunction startTime() external view returns (uint256);\n}\n"
    },
    "contracts/interfaces/IPropelUSD.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\ninterface IPropelUSD {\n\tevent Approval(address indexed owner, address indexed spender, uint256 value);\n\tevent MessageFailed(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes _payload, bytes _reason);\n\tevent OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\tevent ReceiveFromChain(uint16 indexed _srcChainId, address indexed _to, uint256 _amount);\n\tevent RetryMessageSuccess(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes32 _payloadHash);\n\tevent SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes _toAddress, uint256 _amount);\n\tevent SetMinDstGas(uint16 _dstChainId, uint16 _type, uint256 _minDstGas);\n\tevent SetPrecrime(address precrime);\n\tevent SetTrustedRemote(uint16 _remoteChainId, bytes _path);\n\tevent SetTrustedRemoteAddress(uint16 _remoteChainId, bytes _remoteAddress);\n\tevent SetUseCustomAdapterParams(bool _useCustomAdapterParams);\n\tevent Transfer(address indexed from, address indexed to, uint256 value);\n\n\tfunction approve(address spender, uint256 amount) external returns (bool);\n\n\tfunction burn(address _account, uint256 _amount) external;\n\n\tfunction burnWithGasCompensation(address _account, uint256 _amount) external returns (bool);\n\n\tfunction decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);\n\n\tfunction enableTroveManager(address _troveManager) external;\n\n\tfunction flashLoan(address receiver, address token, uint256 amount, bytes calldata data) external returns (bool);\n\n\tfunction forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;\n\n\tfunction increaseAllowance(address spender, uint256 addedValue) external returns (bool);\n\n\tfunction lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external;\n\n\tfunction mint(address _account, uint256 _amount) external;\n\n\tfunction mintWithGasCompensation(address _account, uint256 _amount) external returns (bool);\n\n\tfunction nonblockingLzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external;\n\n\tfunction permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;\n\n\tfunction renounceOwnership() external;\n\n\tfunction returnFromPool(address _poolAddress, address _receiver, uint256 _amount) external;\n\n\tfunction sendToSP(address _sender, uint256 _amount) external;\n\n\tfunction setConfig(uint16 _version, uint16 _chainId, uint256 _configType, bytes calldata _config) external;\n\n\tfunction setMinDstGas(uint16 _dstChainId, uint16 _packetType, uint256 _minGas) external;\n\n\tfunction setPayloadSizeLimit(uint16 _dstChainId, uint256 _size) external;\n\n\tfunction setPrecrime(address _precrime) external;\n\n\tfunction setReceiveVersion(uint16 _version) external;\n\n\tfunction setSendVersion(uint16 _version) external;\n\n\tfunction setTrustedRemote(uint16 _srcChainId, bytes calldata _path) external;\n\n\tfunction setTrustedRemoteAddress(uint16 _remoteChainId, bytes calldata _remoteAddress) external;\n\n\tfunction setUseCustomAdapterParams(bool _useCustomAdapterParams) external;\n\n\tfunction transfer(address recipient, uint256 amount) external returns (bool);\n\n\tfunction transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\n\tfunction transferOwnership(address newOwner) external;\n\n\tfunction retryMessage(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external payable;\n\n\tfunction sendFrom(address _from, uint16 _dstChainId, bytes calldata _toAddress, uint256 _amount, address _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable;\n\n\tfunction DEBT_GAS_COMPENSATION() external view returns (uint256);\n\n\tfunction DEFAULT_PAYLOAD_SIZE_LIMIT() external view returns (uint256);\n\n\tfunction FLASH_LOAN_FEE() external view returns (uint256);\n\n\tfunction NO_EXTRA_GAS() external view returns (uint256);\n\n\tfunction PT_SEND() external view returns (uint16);\n\n\tfunction allowance(address owner, address spender) external view returns (uint256);\n\n\tfunction balanceOf(address account) external view returns (uint256);\n\n\tfunction borrowerOperationsAddress() external view returns (address);\n\n\tfunction circulatingSupply() external view returns (uint256);\n\n\tfunction decimals() external view returns (uint8);\n\n\tfunction domainSeparator() external view returns (bytes32);\n\n\tfunction estimateSendFee(uint16 _dstChainId, bytes calldata _toAddress, uint256 _amount, bool _useZro, bytes calldata _adapterParams) external view returns (uint256 nativeFee, uint256 zroFee);\n\n\tfunction factory() external view returns (address);\n\n\tfunction failedMessages(uint16, bytes calldata, uint64) external view returns (bytes32);\n\n\tfunction flashFee(address token, uint256 amount) external view returns (uint256);\n\n\tfunction gasPool() external view returns (address);\n\n\tfunction getConfig(uint16 _version, uint16 _chainId, address, uint256 _configType) external view returns (bytes memory);\n\n\tfunction getTrustedRemoteAddress(uint16 _remoteChainId) external view returns (bytes memory);\n\n\tfunction isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);\n\n\tfunction lzEndpoint() external view returns (address);\n\n\tfunction maxFlashLoan(address token) external view returns (uint256);\n\n\tfunction minDstGasLookup(uint16, uint16) external view returns (uint256);\n\n\tfunction name() external view returns (string memory);\n\n\tfunction nonces(address owner) external view returns (uint256);\n\n\tfunction owner() external view returns (address);\n\n\tfunction payloadSizeLimitLookup(uint16) external view returns (uint256);\n\n\tfunction permitTypeHash() external view returns (bytes32);\n\n\tfunction precrime() external view returns (address);\n\n\tfunction stabilityPoolAddress() external view returns (address);\n\n\tfunction supportsInterface(bytes4 interfaceId) external view returns (bool);\n\n\tfunction symbol() external view returns (string memory);\n\n\tfunction token() external view returns (address);\n\n\tfunction totalSupply() external view returns (uint256);\n\n\tfunction troveManager(address) external view returns (bool);\n\n\tfunction trustedRemoteLookup(uint16) external view returns (bytes memory);\n\n\tfunction useCustomAdapterParams() external view returns (bool);\n\n\tfunction version() external view returns (string memory);\n}\n"
    },
    "contracts/interfaces/IPyth.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\ninterface IPyth {\n\tstruct Price {\n\t\t// Price\n\t\tint64 price;\n\t\t// Confidence interval around the price\n\t\tuint64 conf;\n\t\t// Price exponent\n\t\tint32 expo;\n\t\t// Unix timestamp describing when the price was published\n\t\tuint publishTime;\n\t}\n\n\tfunction getPrice(bytes32 id) external view returns (Price memory);\n\n\tfunction getPriceUnsafe(bytes32 id) external view returns (Price memory price);\n}\n"
    },
    "contracts/interfaces/ISortedTroves.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\ninterface ISortedTroves {\n\tevent NodeAdded(address _id, uint256 _NICR);\n\tevent NodeRemoved(address _id);\n\n\tfunction insert(address _id, uint256 _NICR, address _prevId, address _nextId) external;\n\n\tfunction reInsert(address _id, uint256 _newNICR, address _prevId, address _nextId) external;\n\n\tfunction remove(address _id) external;\n\n\tfunction setAddresses(address _troveManagerAddress) external;\n\n\tfunction contains(address _id) external view returns (bool);\n\n\tfunction data() external view returns (address head, address tail, uint256 size);\n\n\tfunction findInsertPosition(uint256 _NICR, address _prevId, address _nextId) external view returns (address, address);\n\n\tfunction getFirst() external view returns (address);\n\n\tfunction getLast() external view returns (address);\n\n\tfunction getNext(address _id) external view returns (address);\n\n\tfunction getPrev(address _id) external view returns (address);\n\n\tfunction getSize() external view returns (uint256);\n\n\tfunction isEmpty() external view returns (bool);\n\n\tfunction troveManager() external view returns (address);\n\n\tfunction validInsertPosition(uint256 _NICR, address _prevId, address _nextId) external view returns (bool);\n}\n"
    },
    "contracts/interfaces/IStabilityPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IStabilityPool {\n\tevent CollateralGainWithdrawn(address indexed _depositor, uint256[] _collateral);\n\tevent CollateralOverwritten(address oldCollateral, address newCollateral);\n\tevent DepositSnapshotUpdated(address indexed _depositor, uint256 _P, uint256 _G);\n\tevent EpochUpdated(uint128 _currentEpoch);\n\tevent G_Updated(uint256 _G, uint128 _epoch, uint128 _scale);\n\tevent P_Updated(uint256 _P);\n\tevent RewardClaimed(address indexed account, address indexed recipient, uint256 claimed);\n\tevent S_Updated(uint256 idx, uint256 _S, uint128 _epoch, uint128 _scale);\n\tevent ScaleUpdated(uint128 _currentScale);\n\tevent StabilityPoolPropelUSDBalanceUpdated(uint256 _newBalance);\n\tevent UserDepositChanged(address indexed _depositor, uint256 _newDeposit);\n\n\t// function claimCollateralGains(address recipient, uint256[] calldata collateralIndexes) external;\n\n\t// function claimReward(address recipient) external returns (uint256 amount);\n\n\tfunction enableCollateral(IERC20 _collateral) external;\n\n\tfunction offset(IERC20 collateral, uint256 _debtToOffset, uint256 _collToAdd) external;\n\n\tfunction provideToSP(uint256 _amount) external;\n\n\tfunction startCollateralSunset(IERC20 collateral) external;\n\n\tfunction withdrawFromSP(uint256 _amount) external;\n\n\tfunction DECIMAL_PRECISION() external view returns (uint256);\n\n\tfunction P() external view returns (uint256);\n\n\tfunction SCALE_FACTOR() external view returns (uint256);\n\n\tfunction SUNSET_DURATION() external view returns (uint128);\n\n\tfunction claimableReward(address _depositor) external view returns (uint256);\n\n\tfunction currentEpoch() external view returns (uint128);\n\n\tfunction currentScale() external view returns (uint128);\n\n\tfunction depositSnapshots(address) external view returns (uint256 P, uint256 G, uint128 scale, uint128 epoch);\n\n\tfunction depositSums(address, uint256) external view returns (uint256);\n\n\tfunction epochToScaleToG(uint128, uint128) external view returns (uint256);\n\n\tfunction epochToScaleToSums(uint128, uint128, uint256) external view returns (uint256);\n\n\tfunction factory() external view returns (address);\n\n\tfunction getCompoundedDeposit(address _depositor) external view returns (uint256);\n\n\tfunction getDepositorCollateralGain(address _depositor) external view returns (uint256[] memory collateralGains);\n\n\tfunction getTotalPropelUSDDeposits() external view returns (uint256);\n\n\tfunction lastDebtLossError_Offset() external view returns (uint256);\n\n\tfunction lastEsPropelError() external view returns (uint256);\n\n\tfunction liquidationManager() external view returns (address);\n}\n"
    },
    "contracts/interfaces/ITroveManager.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./IPropelBase.sol\";\nimport \"./ISortedTroves.sol\";\nimport \"./IPriceFeed.sol\";\n\ninterface ITroveManager is IPropelBase {\n\t// Store the necessary data for a trove\n\tstruct Trove {\n\t\tuint256 debt;\n\t\tuint256 coll;\n\t\tuint256 stake;\n\t\tStatus status;\n\t\tuint128 arrayIndex;\n\t}\n\n\tstruct RedemptionTotals {\n\t\tuint256 remainingDebt;\n\t\tuint256 totalDebtToRedeem;\n\t\tuint256 totalCollateralDrawn;\n\t\tuint256 totalInterest;\n\t\tuint256 collateralFee;\n\t\tuint256 collateralToSendToRedeemer;\n\t\tuint256 decayedBaseRate;\n\t\tuint256 price;\n\t\tuint256 totalDebtSupplyAtStart;\n\t}\n\n\tstruct SingleRedemptionValues {\n\t\tuint256 debtLot;\n\t\tuint256 collateralLot;\n\t\tuint256 interestLot;\n\t\tbool cancelledPartial;\n\t}\n\n\t// Object containing the collateral and debt snapshots for a given active trove\n\tstruct RewardSnapshot {\n\t\tuint256 collateral;\n\t\tuint256 debt;\n\t\tuint256 interest;\n\t}\n\n\tenum TroveManagerOperation {\n\t\tapplyPendingRewards,\n\t\tliquidateInNormalMode,\n\t\tliquidateInRecoveryMode,\n\t\tredeemCollateral\n\t}\n\n\tenum Status {\n\t\tnonExistent,\n\t\tactive,\n\t\tclosedByOwner,\n\t\tclosedByLiquidation,\n\t\tclosedByRedemption\n\t}\n\n\tevent InsterstPaid(address _account, address _borrower, uint256 _interest);\n\tevent TroveUpdated(address indexed _borrower, uint256 _debt, uint256 _coll, uint256 _stake, TroveManagerOperation _operation);\n\tevent Redemption(uint256 _attemptedDebtAmount, uint256 _actualDebtAmount, uint256 _collateralSent, uint256 _InterestDebt, uint256 _collateralFee);\n\tevent BaseRateUpdated(uint256 _baseRate);\n\tevent LastFeeOpTimeUpdated(uint256 _lastFeeOpTime);\n\tevent TotalStakesUpdated(uint256 _newTotalStakes);\n\tevent SystemSnapshotsUpdated(uint256 _totalStakesSnapshot, uint256 _totalCollateralSnapshot);\n\tevent LTermsUpdated(uint256 _L_collateral, uint256 _L_debt);\n\tevent TroveSnapshotsUpdated(uint256 _L_collateral, uint256 _L_debt, uint256 _L_Interest_Debt);\n\tevent TroveIndexUpdated(address _borrower, uint256 _newIndex);\n\tevent CollateralSent(address _to, uint256 _amount);\n\tevent RewardClaimed(address indexed account, address indexed recipient, uint256 claimed);\n\n\tfunction addCollateralSurplus(address borrower, uint256 collSurplus) external;\n\n\tfunction applyPendingRewards(address _borrower) external returns (uint256 coll, uint256 debt);\n\n\tfunction claimCollateral(address _receiver) external;\n\n\tfunction closeTrove(address _borrower, address _receiver, uint256 collAmount, uint256 debtAmount) external;\n\n\tfunction closeTroveByLiquidation(address _borrower) external;\n\n\tfunction decayBaseRateAndGetBorrowingFee(uint256 _debt) external returns (uint256);\n\n\tfunction decreaseDebtAndSendCollateral(address account, uint256 debt, uint256 coll) external;\n\n\tfunction finalizeLiquidation(address _liquidator, uint256 _debt, uint256 _coll, uint256 _collSurplus, uint256 _debtGasComp, uint256 _collGasComp, uint256 _interest) external;\n\n\tfunction getEntireSystemBalances() external returns (uint256, uint256, uint256);\n\n\tfunction movePendingTroveRewardsToActiveBalances(uint256 _debt, uint256 _collateral) external;\n\n\tfunction openTrove(address _borrower, uint256 _collateralAmount, uint256 _compositeDebt, uint256 NICR, address _upperHint, address _lowerHint) external returns (uint256 stake, uint256 arrayIndex);\n\n\tfunction redeemCollateral(uint256 _debtAmount, address _firstRedemptionHint, address _upperPartialRedemptionHint, address _lowerPartialRedemptionHint, uint256 _partialRedemptionHintNICR, uint256 _maxIterations, uint256 _maxFeePercentage) external;\n\n\tfunction setAddresses(address _priceFeedAddress, address _sortedTrovesAddress, IERC20 _collateralToken) external;\n\n\tfunction setParameters(uint256 _minuteDecayFactor, uint256 _redemptionFeeFloor, uint256 _maxRedemptionFee, uint256 _borrowingFeeFloor, uint256 _maxBorrowingFee, uint256 _maxSystemDebt, uint256 _MCR, uint32 _interestRate) external;\n\n\tfunction setPaused(bool _paused) external;\n\n\tfunction setPriceFeed(address _priceFeedAddress) external;\n\n\tfunction updateTroveFromAdjustment(bool _isDebtIncrease, uint256 _debtChange, uint256 _netDebtChange, bool _isCollIncrease, uint256 _collChange, address _upperHint, address _lowerHint, address _borrower, address _receiver) external returns (uint256, uint256, uint256);\n\n\tfunction fetchPrice() external returns (uint256);\n\n\tfunction distributeInterestDebt() external returns (uint256);\n\n\tfunction repayInterest(address _account, address _borrower, uint256 _debt) external;\n\n\tfunction BOOTSTRAP_PERIOD() external view returns (uint256);\n\n\tfunction L_collateral() external view returns (uint256);\n\n\tfunction L_debt() external view returns (uint256);\n\n\tfunction MCR() external view returns (uint256);\n\n\tfunction getTrove(address _borrower) external view returns (Trove memory);\n\n\tfunction baseRate() external view returns (uint256);\n\n\tfunction borrowerOperationsAddress() external view returns (address);\n\n\tfunction borrowingFeeFloor() external view returns (uint256);\n\n\tfunction collateralToken() external view returns (IERC20);\n\n\tfunction defaultedCollateral() external view returns (uint256);\n\n\tfunction defaultedDebt() external view returns (uint256);\n\n\tfunction getBorrowingFee(uint256 _debt) external view returns (uint256);\n\n\tfunction getBorrowingFeeWithDecay(uint256 _debt) external view returns (uint256);\n\n\tfunction getBorrowingRate() external view returns (uint256);\n\n\tfunction getBorrowingRateWithDecay() external view returns (uint256);\n\n\tfunction getCurrentICR(address _borrower, uint256 _price) external view returns (uint256);\n\n\tfunction getEntireDebtAndColl(address _borrower) external view returns (uint256 debt, uint256 coll, uint256 pendingDebtReward, uint256 pendingCollateralReward);\n\n\tfunction getEntireSystemColl() external view returns (uint256);\n\n\tfunction getEntireSystemDebt() external view returns (uint256);\n\n\tfunction getGlobalSystemDebt() external view returns (uint256);\n\n\tfunction getTroveInterest(address _borrower, uint256 _debt) external view returns (uint256);\n\n\tfunction getRedemptionICR(address _borrower, uint256 _price) external view returns (uint256);\n\n\tfunction getNominalICR(address _borrower) external view returns (uint256);\n\n\tfunction getPendingCollAndDebtRewards(address _borrower) external view returns (uint256, uint256);\n\n\tfunction getRedemptionFeeWithDecay(uint256 _collateralDrawn) external view returns (uint256);\n\n\tfunction getRedemptionRate() external view returns (uint256);\n\n\tfunction getRedemptionRateWithDecay() external view returns (uint256);\n\n\tfunction getTotalActiveCollateral() external view returns (uint256);\n\n\tfunction getTotalActiveDebt() external view returns (uint256);\n\n\tfunction getTroveCollAndDebt(address _borrower) external view returns (uint256 coll, uint256 debt);\n\n\tfunction getTroveFromTroveOwnersArray(uint256 _index) external view returns (address);\n\n\tfunction getTroveOwnersCount() external view returns (uint256);\n\n\tfunction getTroveStake(address _borrower) external view returns (uint256);\n\n\tfunction getTroveStatus(address _borrower) external view returns (uint256);\n\n\tfunction hasPendingRewards(address _borrower) external view returns (bool);\n\n\tfunction lastCollateralError_Redistribution() external view returns (uint256);\n\n\tfunction lastDebtError_Redistribution() external view returns (uint256);\n\n\tfunction lastFeeOperationTime() external view returns (uint256);\n\n\tfunction liquidationManager() external view returns (address);\n\n\tfunction maxBorrowingFee() external view returns (uint256);\n\n\tfunction maxRedemptionFee() external view returns (uint256);\n\n\tfunction maxSystemDebt() external view returns (uint256);\n\n\tfunction minuteDecayFactor() external view returns (uint256);\n\n\tfunction paused() external view returns (bool);\n\n\tfunction redemptionFeeFloor() external view returns (uint256);\n\n\tfunction getRewardSnapshots(address) external view returns (RewardSnapshot memory);\n\n\tfunction priceFeed() external view returns (IPriceFeed);\n\n\tfunction sortedTroves() external view returns (ISortedTroves);\n\n\tfunction sunsetting() external view returns (bool);\n\n\tfunction surplusBalances(address) external view returns (uint256);\n\n\tfunction systemDeploymentTime() external view returns (uint256);\n\n\tfunction totalCollateralSnapshot() external view returns (uint256);\n\n\tfunction totalStakes() external view returns (uint256);\n\n\tfunction totalStakesSnapshot() external view returns (uint256);\n}\n"
    },
    "contracts/interfaces/IWETH.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"../interfaces/IBlast.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IWETH is IERC20, IERC20Rebasing {\n\tfunction deposit() external payable;\n}\n"
    },
    "contracts/stake/EsPropelStaking.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\nimport \"@openzeppelin/contracts/utils/structs/EnumerableMap.sol\";\nimport \"./StakingBoost.sol\";\nimport \"../interfaces/IEsPropelStaking.sol\";\nimport \"../dependencies/BlastWrapperUpgradeable.sol\";\n\ncontract EsPropelStaking is IEsPropelStaking, StakingBoost, BlastWrapperUpgradeable {\n\tusing EnumerableMap for EnumerableMap.AddressToUintMap;\n\tuint256 public immutable PRECISION = 1e18;\n\tIEsPropel public override esPropel;\n\tuint256 public override totalStakes;\n\tEnumerableMap.AddressToUintMap internal tokens;\n\n\tmapping(address => uint256) public F_Tokens; // token => tokenPerUnitStake\n\tmapping(address => mapping(address => mapping(uint256 => uint256))) public snapshots; // user => token => id => shares\n\tmapping(address => mapping(uint256 => uint256)) public stakes; // user => id => stake\n\n\tfunction initialize(IPropelCore _core, address _esPropel) external initializer {\n\t\t__Init_Blast(_core);\n\t\tinitLockSettings();\n\t\tesPropel = IEsPropel(_esPropel);\n\t}\n\n\tfunction tokensLength() public view override returns (uint256) {\n\t\treturn tokens.length();\n\t}\n\n\tfunction tokenAt(uint256 i) public view override returns (address, uint256) {\n\t\treturn tokens.at(i);\n\t}\n\n\tfunction addToken(address _token) external onlyOwner {\n\t\ttokens.set(_token, tokensLength());\n\t\temit TokenUpdated(_token);\n\t}\n\n\tfunction removeToken(address _token) external onlyOwner {\n\t\ttokens.remove(_token);\n\t\temit TokenUpdated(_token);\n\t}\n\n\tfunction stakeWithLock(uint256 amount, uint256 lockIndex) external {\n\t\tesPropel.sendToken(msg.sender, amount);\n\t\tuint256 id = currentId[msg.sender]++;\n\t\t_updateSnapshot(msg.sender, id, stakes[msg.sender][id]);\n\t\tstakes[msg.sender][id] += amount;\n\t\tstakeSharesByTokenAmountWithLock(msg.sender, id, lockIndex, amount);\n\t\ttotalStakes += amount;\n\t\temit StakedWithLock(msg.sender, id, lockIndex, amount);\n\t}\n\n\tfunction stakeWithoutLock(uint256 amount) external {\n\t\tuint256 id = _MaxId;\n\t\t_updateSnapshot(msg.sender, _MaxId, stakes[msg.sender][id]);\n\t\tesPropel.sendToken(msg.sender, amount);\n\t\tstakes[msg.sender][id] += amount;\n\t\tstakeSharesByTokenAmountWithoutLock(msg.sender, id, amount);\n\t\ttotalStakes += amount;\n\t\temit StakedWithoutLock(msg.sender, id, amount);\n\t}\n\n\tfunction unstake(uint256 id) external {\n\t\tif (id != _MaxId) {\n\t\t\trequire(block.timestamp > unlockTime(msg.sender, id), \"EsPropelStaking: token is in lock period\");\n\t\t}\n\t\tuint256 amount = stakeOf(msg.sender, id);\n\t\trequire(amount > 0, \"EsPropelStaking: zero stakes\");\n\t\t_updateSnapshot(msg.sender, id, stakes[msg.sender][id]);\n\t\tburnSharesByTokenAmount(msg.sender, id, amount);\n\t\tstakes[msg.sender][id] -= amount;\n\t\ttotalStakes -= amount;\n\t\tesPropel.transfer(msg.sender, amount);\n\t\temit Withdrawn(msg.sender, id, amount);\n\t}\n\n\tfunction stakeOf(address user, uint256 id) public view override returns (uint256) {\n\t\treturn stakes[user][id];\n\t}\n\n\tfunction claim(uint256 id) external {\n\t\t_updateSnapshot(msg.sender, id, stakes[msg.sender][id]);\n\t}\n\n\tfunction totalEarned(address account, address[] memory _tokens, uint256[] memory ids) public view returns (uint256[] memory totals) {\n\t\ttotals = new uint256[](_tokens.length);\n\t\tfor (uint256 i = 0; i < _tokens.length; i++) {\n\t\t\taddress token = _tokens[i];\n\t\t\trequire(tokenExists(token), \"EsPropelStaking: nonexistent token\");\n\t\t\tfor (uint256 j = 0; j < ids.length; j++) {\n\t\t\t\ttotals[i] += earned(account, token, ids[j]);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction batchEarned(address account, address[] memory _tokens, uint256[] memory ids) public view returns (uint256[][] memory earneds) {\n\t\tearneds = new uint256[][](_tokens.length);\n\t\tfor (uint256 i = 0; i < _tokens.length; i++) {\n\t\t\taddress token = _tokens[i];\n\t\t\trequire(tokenExists(token), \"EsPropelStaking: nonexistent token\");\n\t\t\tearneds[i] = new uint256[](ids.length);\n\t\t\tfor (uint256 j = 0; j < ids.length; j++) {\n\t\t\t\tearneds[i][j] = earned(account, token, ids[j]);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction earned(address user, address token, uint256 id) public view override returns (uint256) {\n\t\treturn (shareOf(user, id) * (F_Tokens[token] - snapshots[user][token][id])) / PRECISION;\n\t}\n\n\tfunction _updateSnapshot(address user, uint256 id, uint256 currentStakes) internal {\n\t\tfor (uint256 i = 0; i < tokensLength(); i++) {\n\t\t\t(address token, ) = tokenAt(i);\n\t\t\tif (currentStakes > 0) {\n\t\t\t\tuint256 amount = earned(user, token, id);\n\t\t\t\tif (amount > 0) {\n\t\t\t\t\tIERC20(token).transfer(user, amount);\n\t\t\t\t\temit Claimed(user, id, amount);\n\t\t\t\t}\n\t\t\t}\n\t\t\tsnapshots[user][token][id] = F_Tokens[token];\n\t\t}\n\t}\n\n\tfunction submit(address token, uint256 amount) external override {\n\t\trequire(amount > 0, \"EsPropelStaking: zero amount\");\n\t\trequire(totalShares() > 0, \"EsPropelStaking: zero stakes\");\n\t\trequire(tokenExists(token), \"EsPropelStaking: nonexistent token\");\n\t\tIERC20(token).transferFrom(msg.sender, address(this), amount);\n\t\tF_Tokens[token] += (amount * PRECISION) / totalShares();\n\t\temit FeeIncreased(token, amount);\n\t}\n\n\tfunction tokenExists(address _token) public view override returns (bool) {\n\t\treturn tokens.contains(_token);\n\t}\n}\n"
    },
    "contracts/stake/ILPStakingPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\ninterface ILPStakingPool {\n\tfunction stakeWithLock(address account, uint256 amount, uint256 lockIndex) external;\n\n\tfunction stakeWithoutLock(address account, uint256 amount) external;\n\n\tfunction LPToken() external view returns(address);\n\n}"
    },
    "contracts/stake/LPStakingPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"./LPTokenWrapper.sol\";\nimport \"./StakingBoost.sol\";\nimport \"./ILPStakingPool.sol\";\nimport \"../interfaces/IEsPropel.sol\";\nimport \"../dependencies/PropelMath.sol\";\nimport \"../dependencies/BlastWrapperUpgradeable.sol\";\n\ncontract LPStakingPool is ILPStakingPool, LPTokenWrapper, StakingBoost, BlastWrapperUpgradeable {\n\tuint256 public constant PRECISION = 1e18;\n\tIEsPropel public esPropel;\n\tuint256 public lastUpdateTime;\n\tuint256 public rewardPerSec;\n\tuint256 public rewardEndTime;\n\tuint256 public duration;\n\tuint256 public accRewardPerShare;\n\n\tmapping(address => mapping(uint256 => int256)) public rewardDebt;\n\tmapping(address => mapping(uint256 => uint256)) public rewards;\n\n\tevent RewardPerSecUpdated(uint256 rewardPerSec);\n\tevent RewardEndTimeUpdated(uint256 rewardEndTime);\n\tevent StakedWithLock(address user, uint256 id, uint256 lockIndex, uint256 amount);\n\tevent StakedWithoutLock(address user, uint256 id, uint256 amount);\n\tevent Withdrawn(address user, uint256 id, uint256 amount);\n\tevent RewardPaid(address user, uint256 id, uint256 reward);\n\n\tmodifier onlyInitialized() {\n\t\trequire(address(lpToken) != address(0), \"Liquidity Pool Token has not been set yet\");\n\t\t_;\n\t}\n\n\t// Returns current timestamp if the rewards program has not finished yet, end time otherwise\n\tfunction lastTimeRewardApplicable() public view returns (uint256) {\n\t\treturn PropelMath._min(block.timestamp, rewardEndTime);\n\t}\n\n\tfunction setRewardPerSec(uint256 _rewardPerSec) external onlyOwner {\n\t\tupdatePool();\n\t\trewardPerSec = _rewardPerSec;\n\t\temit RewardPerSecUpdated(_rewardPerSec);\n\t}\n\n\tfunction setRewardEndTime(uint256 _rewardEndTime) external onlyOwner {\n\t\trequire(block.timestamp >= rewardEndTime, \"must be after last reward end time\");\n\t\trequire(_rewardEndTime > block.timestamp, \"invalid rewardEndTime\");\n\t\tupdatePool();\n\t\trewardEndTime = _rewardEndTime;\n\t\temit RewardEndTimeUpdated(_rewardEndTime);\n\t}\n\n\tfunction updatePool() internal {\n\t\tif (lastUpdateTime == 0) {\n\t\t\tlastUpdateTime = block.timestamp;\n\t\t\trewardEndTime = block.timestamp + duration;\n\t\t}\n\t\tif (totalShares() == 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (lastTimeRewardApplicable() == lastUpdateTime) {\n\t\t\treturn;\n\t\t}\n\t\tif (lastTimeRewardApplicable() > lastUpdateTime) {\n\t\t\tuint256 pending = (lastTimeRewardApplicable() - lastUpdateTime) * rewardPerSec;\n\t\t\taccRewardPerShare += (pending * PRECISION) / totalShares();\n\t\t\tlastUpdateTime = lastTimeRewardApplicable();\n\t\t}\n\t}\n\n\tfunction totalEarned(address account, uint256[] memory ids) public view returns (uint256 total) {\n\t\tfor (uint256 i = 0; i < ids.length; i++) {\n\t\t\ttotal += earned(account, ids[i]);\n\t\t}\n\t}\n\n\tfunction batchEarned(address account, uint256[] memory ids) public view returns (uint256[] memory earneds) {\n\t\tearneds = new uint256[](ids.length);\n\t\tfor (uint256 i = 0; i < ids.length; i++) {\n\t\t\tearneds[i] = earned(account, ids[i]);\n\t\t}\n\t}\n\n\t// Returns the amount that an account can claim\n\tfunction earned(address account, uint256 id) public view returns (uint256) {\n\t\tif (totalShares() == 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tuint256 pending = (lastTimeRewardApplicable() - lastUpdateTime) * rewardPerSec;\n\t\tuint256 newAccRewardPerShare = accRewardPerShare + (pending * PRECISION) / totalShares();\n\t\treturn uint256(int256(shareOf(account, id) * newAccRewardPerShare) - rewardDebt[account][id]) / PRECISION;\n\t}\n\n\tfunction stakeWithLock(address account, uint256 amount, uint256 lockIndex) external override onlyInitialized {\n\t\trequire(amount > 0, \"Cannot stake 0\");\n\t\tupdatePool();\n\t\tuint256 id = currentId[account]++;\n\t\tsuper.stake(amount, id);\n\t\tstakeSharesByTokenAmountWithLock(account, id, lockIndex, amount);\n\t\trewardDebt[account][id] = int256(shareOf(account, id) * accRewardPerShare);\n\t\temit StakedWithLock(account, id, lockIndex, amount);\n\t}\n\n\tfunction stakeWithoutLock(address account, uint256 amount) external override onlyInitialized {\n\t\trequire(amount > 0, \"Cannot stake 0\");\n\t\tupdatePool();\n\t\tuint256 id = _MaxId;\n\t\tsuper.stake(amount, id);\n\t\tuint256 reward = uint256(int256(shareOf(msg.sender, id) * accRewardPerShare) - rewardDebt[msg.sender][id]) / PRECISION;\n\t\tstakeSharesByTokenAmountWithoutLock(account, id, amount);\n\t\trewardDebt[msg.sender][id] = int256(shareOf(msg.sender, id) * accRewardPerShare);\n\t\tif (reward > 0) {\n\t\t\tesPropel.transfer(msg.sender, reward);\n\t\t\temit RewardPaid(msg.sender, id, reward);\n\t\t}\n\t\temit StakedWithoutLock(account, id, amount);\n\t}\n\n\tfunction stakeOf(address user, uint256 id) public view override returns (uint256) {\n\t\treturn balanceOf(user, id);\n\t}\n\n\t// Shortcut to be able to unstake tokens and claim rewards in one transaction\n\tfunction withdrawAndClaim(uint256 id) external onlyInitialized {\n\t\tuint256 amount = balanceOf(msg.sender, id);\n\t\tif (id != _MaxId) {\n\t\t\trequire(id < currentId[msg.sender], \"nonexistent id\");\n\t\t\trequire(block.timestamp > unlockTime(msg.sender, id), \"Liquidity Pool Token has been locked\");\n\t\t}\n\t\tupdatePool();\n\t\tuint256 burnt = burnSharesByTokenAmount(msg.sender, id, amount);\n\t\trewardDebt[msg.sender][id] -= int256(accRewardPerShare * burnt);\n\t\tuint256 reward = uint256(int256(shareOf(msg.sender, id) * accRewardPerShare) - rewardDebt[msg.sender][id]) / PRECISION;\n\t\trewardDebt[msg.sender][id] = int256(shareOf(msg.sender, id) * accRewardPerShare);\n\t\tif (reward > 0) {\n\t\t\tesPropel.transfer(msg.sender, reward);\n\t\t\temit RewardPaid(msg.sender, id, reward);\n\t\t}\n\t\tsuper.withdraw(amount, id);\n\t\temit Withdrawn(msg.sender, id, amount);\n\t}\n\n\tfunction claimReward(uint256 id) public onlyInitialized {\n\t\tif (id != _MaxId) {\n\t\t\trequire(id < currentId[msg.sender], \"nonexistent id\");\n\t\t}\n\t\tupdatePool();\n\t\tuint256 reward = uint256(int256(shareOf(msg.sender, id) * accRewardPerShare) - rewardDebt[msg.sender][id]) / PRECISION;\n\t\trewardDebt[msg.sender][id] = int256(shareOf(msg.sender, id) * accRewardPerShare);\n\t\trequire(reward > 0, \"Nothing to claim\");\n\t\tesPropel.transfer(msg.sender, reward);\n\t\temit RewardPaid(msg.sender, id, reward);\n\t}\n\n\tfunction LPToken() external view override returns (address) {\n\t\treturn address(lpToken);\n\t}\n}\n"
    },
    "contracts/stake/LPTokenWrapper.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nabstract contract LPTokenWrapper {\n\tIERC20 public lpToken;\n\n\tuint256 private _totalSupply;\n\tmapping(address => mapping(uint256 => uint256)) private _balances;\n\n\tfunction totalSupply() public view returns (uint256) {\n\t\treturn _totalSupply;\n\t}\n\n\tfunction balanceOf(address account, uint256 id) public view returns (uint256) {\n\t\treturn _balances[account][id];\n\t}\n\n\tfunction stake(uint256 amount, uint256 id) internal virtual {\n\t\t_totalSupply += amount;\n\t\t_balances[msg.sender][id] += amount;\n\t\tlpToken.transferFrom(msg.sender, address(this), amount);\n\t}\n\n\tfunction withdraw(uint256 amount, uint256 id) internal virtual {\n\t\t_totalSupply -= amount;\n\t\t_balances[msg.sender][id] -= amount;\n\t\tlpToken.transfer(msg.sender, amount);\n\t}\n}"
    },
    "contracts/stake/PropelQETHPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"./LPStakingPool.sol\";\n\ncontract PropelQETHPool is LPStakingPool {\n\tfunction initialize(IPropelCore _core, address _lpToken, address _esPropel, uint256 _rewardPerSec, uint256 _duration) external initializer {\n\t\t__Init_Blast(_core);\n\t\tinitLockSettings();\n\t\tlpToken = IERC20(_lpToken);\n\t\tesPropel = IEsPropel(_esPropel);\n\t\tduration = _duration;\n\t\trewardPerSec = _rewardPerSec;\n\t}\n}\n"
    },
    "contracts/stake/PropelUSDQUSDCPool.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\nimport \"./LPStakingPool.sol\";\n\ncontract PropelUSDQUSDCPool is LPStakingPool {\n\tfunction initialize(IPropelCore _core, address _lpToken, address _esPropel, uint256 _rewardPerSec, uint256 _duration) external initializer {\n\t\t__Init_Blast(_core);\n\t\tinitLockSettings();\n\t\tlpToken = IERC20(_lpToken);\n\t\tesPropel = IEsPropel(_esPropel);\n\t\tduration = _duration;\n\t\trewardPerSec = _rewardPerSec;\n\t}\n}\n"
    },
    "contracts/stake/StakingBoost.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\n/// @notice boost for esPropel\nabstract contract StakingBoost {\n\tstruct LockSetting {\n\t\tuint256 duration;\n\t\tuint256 miningBoost;\n\t}\n\n\tstruct UserBoostState {\n\t\tuint256 shares;\n\t\tuint256 unlockTime;\n\t\tuint256 duration;\n\t\tuint256 miningBoost;\n\t}\n\n\tmapping(address => mapping(uint256 => UserBoostState)) public states;\n\tmapping(address => uint256) public currentId;\n\tLockSetting[] public LockSettings;\n\n\tuint256 internal _totalShares;\n\tuint256 internal _MaxId;\n\n\tfunction initLockSettings() internal {\n\t\t_MaxId = type(uint256).max;\n\t\tLockSettings.push(LockSetting(30 days, 10));\n\t\tLockSettings.push(LockSetting(90 days, 20));\n\t\tLockSettings.push(LockSetting(183 days, 50));\n\t\tLockSettings.push(LockSetting(365 days, 100));\n\t}\n\n\t/// @dev total shares in the pool\n\tfunction totalShares() public view returns (uint256) {\n\t\treturn _totalShares;\n\t}\n\n\t/// @dev user's share\n\tfunction shareOf(address user, uint256 id) public view returns (uint256) {\n\t\treturn states[user][id].shares;\n\t}\n\n\tfunction stakeSharesByTokenAmountWithLock(address user, uint256 id, uint256 lockIndex, uint256 amount) internal {\n\t\trequire(lockIndex < 4, \"StakingBoost: index out of range\");\n\t\tuint256 share = shareStaked(id, lockIndex, amount);\n\t\tLockSetting memory setting = LockSettings[lockIndex];\n\t\tstates[user][id] = UserBoostState({ shares: share, unlockTime: block.timestamp + setting.duration, duration: setting.duration, miningBoost: setting.miningBoost });\n\t\t_totalShares += share;\n\t}\n\n\tfunction stakeSharesByTokenAmountWithoutLock(address user, uint256 id, uint256 amount) internal {\n\t\tuint256 oldShare = shareOf(user, id);\n\t\tuint256 newShare = oldShare + shareStaked(id, 0, amount);\n\t\tstates[user][id] = UserBoostState({ shares: newShare, unlockTime: block.timestamp, duration: 0, miningBoost: 0 });\n\t\t_totalShares = _totalShares + newShare - oldShare;\n\t}\n\n\tfunction burnSharesByTokenAmount(address user, uint256 id, uint256 amount) internal returns (uint256) {\n\t\tuint256 share = shareBurnt(user, id, amount, stakeOf(user, id));\n\t\tstates[user][id].shares -= share;\n\t\t_totalShares -= share;\n\t\treturn share;\n\t}\n\n\t/// @dev get user's share for staking\n\tfunction shareStaked(uint256 id, uint256 index, uint256 amount) public view returns (uint256) {\n\t\treturn (amount * getBoost(id, index)) / 100;\n\t}\n\n\t/// @dev get user's burning share\n\tfunction shareBurnt(address user, uint256 id, uint256 amount, uint256 stakes) public view returns (uint256) {\n\t\tif (stakes == 0) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn (amount * shareOf(user, id)) / stakes;\n\t}\n\n\tfunction unlockTime(address user, uint256 id) public view returns (uint256) {\n\t\treturn states[user][id].unlockTime;\n\t}\n\n\t/// @dev get user's boost\n\tfunction getBoost(uint256 id, uint256 index) public view returns (uint256) {\n\t\tif (id == _MaxId) {\n\t\t\treturn 100;\n\t\t}\n\t\treturn (100 + LockSettings[index].miningBoost);\n\t}\n\n\tfunction stakeOf(address user, uint256 id) public view virtual returns (uint256);\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 2000
    },
    "outputSelection": {
      "*": {
        "*": [
          "storageLayout",
          "abi",
          "evm.bytecode",
          "evm.deployedBytecode",
          "evm.methodIdentifiers",
          "metadata",
          "devdoc",
          "userdoc",
          "evm.gasEstimates",
          "storageLayout"
        ],
        "": [
          "ast"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    }
  }
}