creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/MurePool.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.22;\n\nimport {PausableUpgradeable} from \"@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol\";\nimport {\n    ERC165Upgradeable, IERC165\n} from \"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\";\nimport {AccessControlUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport {ReentrancyGuardUpgradeable} from \"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\";\nimport {EIP712Upgradeable} from \"@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SignatureChecker} from \"@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol\";\nimport {PoolMetrics, PoolParameters, PoolParameter, PoolErrorReason, Poolable} from \"./interfaces/Poolable.sol\";\nimport {PoolMetadata, PoolState} from \"./interfaces/PoolMetadata.sol\";\nimport {DepositRecord} from \"./interfaces/Depositable.sol\";\nimport {Delegatable} from \"./interfaces/Delegatable.sol\";\nimport {PoolApp} from \"./interfaces/PoolApp.sol\";\nimport {Depositable} from \"./interfaces/Depositable.sol\";\nimport {Refundable} from \"./interfaces/Refundable.sol\";\nimport {Config} from \"./interfaces/Config.sol\";\nimport {MureErrors} from \"./libraries/MureErrors.sol\";\nimport {POOL_OPERATOR_ROLE} from \"./shared/Constants.sol\";\n\n/**\n * @title MurePool\n * @author Mure\n *\n * @notice Facilitates secure and configurable pool management, supporting operations such as\n * pool creation, deposits, withdrawals, and refunds.\n *\n * @dev Core implementation contract for pooled investments in the Mure protocol.\n * Utilizes the beacon proxy pattern to deploy multiple proxies, each representing\n * a distinct application within the protocol. The MureFactory contract handles\n * these deployments.\n *\n * Implements the EIP-712 standard for signature validation, preventing unauthorized access.\n * Relies on the MureConfig contract to verify EIP-712 signatures and manage the pool\n * creation process. Interaction with the MureConfig contract allows dynamic configuration\n * and signature validation.\n *\n * Security measures include the OpenZeppelin PausableUpgradeable pattern for emergency pausing,\n * ReentrancyGuardUpgradeable to prevent reentrancy attacks, and role based access control\n * through AccessControlUpgradeable.\n *\n * Flag-based functionality enables features like refundability, passthrough of funds, and more.\n * Provides hooks for custom functionality in pool-related operations\n *\n * Depending on the kind of application, the MurePool proxy instance could be linked to a MureDelegate\n * proxy instance for interacting with various plugins that the protocol provides.\n */\ncontract MurePool is\n    EIP712Upgradeable,\n    ReentrancyGuardUpgradeable,\n    PausableUpgradeable,\n    ERC165Upgradeable,\n    AccessControlUpgradeable,\n    PoolApp\n{\n    /// @custom:storage-location erc7201:mure.MurePool\n    struct MurePoolStorage {\n        mapping(string => PoolState) pools;\n        mapping(string => mapping(address => DepositRecord)) deposits;\n        uint24 nonce;\n    }\n\n    /// @custom:storage-location erc7201:mure.PoolMetrics\n    struct PoolMetricsStorage {\n        mapping(string => PoolMetrics) poolMetrics;\n    }\n\n    /**\n     * @dev Hash for storage location\n     * `keccak256(abi.encode(uint256(keccak256(\"mure.MurePool\")) - 1)) & ~bytes32(uint256(0xff))`\n     */\n    bytes32 private constant MurePoolStorageLocation =\n        0x79bd164051f83036bb52eee1d9b6be5ba887eaf3a9d8907adbaadfa56c970700;\n\n    /**\n     * @dev Hash for storage location\n     * `keccak256(abi.encode(uint256(keccak256(\"mure.PoolMetrics\")) - 1)) & ~bytes32(uint256(0xff))`\n     */\n    bytes32 private constant PoolMetricsStorageLocation =\n        0x1ca3e723ed845754b3d7cf12c13e1b284ab752e694e983a627f991c98b3a0700;\n\n    /**\n     * @dev Struct hash for validating deposits\n     * `keccak256(\"Deposit(uint256 amount,string pool,address depositor,uint8 nonce)\")`\n     */\n    bytes32 private constant DEPOSIT_HASH = 0xc5b44054231c7194afce4ed4062c5abd2c0cb26e0686f9ba69d2cfc04b490e33;\n\n    /**\n     * @dev Struct hash for validating pool creation\n     * `keccak256(\"CreatePool(string pool,uint32 endTime,uint24 nonce)\")`\n     */\n    bytes32 private constant CREATE_POOL_HASH = 0x38c6f9238aff6821963f06d84f958ebb018ff9e4343c962882ef7b3308ff1b4d;\n\n    /**\n     * @dev Address for the MureConfig contract\n     * @dev Update config address\n     */\n    address constant MURE_CONFIG = 0xDc86A042e7a49B60EC1022ec2169B62cc2750457;\n\n    /**\n     * @dev Defines if the pool is initialized\n     */\n    uint16 constant INITIALIZED = 0x01;\n\n    /**\n     * @dev Defines if the pool is paused from any interaction\n     */\n    uint16 constant PAUSED = 0x02;\n\n    /**\n     * @dev Defines if deposits should pass straight to associtated raising wallet upon deposit\n     * @notice `PASSTHROUGH_FUNDS` and `REFUNDABLE` cannot be set at the same time\n     */\n    uint16 constant PASSTHROUGH_FUNDS = 0x04;\n\n    /**\n     * @dev Defines if the pool is open for claiming refunds\n     * @notice `PASSTHROUGH_FUNDS` and `REFUNDABLE` cannot be set at the same time\n     */\n    uint16 constant REFUNDABLE = 0x08;\n\n    /**\n     * @dev Defines if the pool is having tiers and gating\n     */\n    uint16 constant TIERED = 0x10;\n\n    /**\n     * @dev Defines if the pool is cross-chain enabled, pooling funds across different networks\n     */\n    uint16 constant CROSS_CHAIN = 0x20;\n\n    /**\n     * @dev Defines if the pool allows for use of delegated wallets for security\n     */\n    uint16 constant DELEGATED = 0x40;\n\n    modifier poolValid(string calldata poolName) {\n        if (!_poolExists(poolName)) {\n            revert MureErrors.PoolNotFound();\n        }\n        _;\n    }\n\n    modifier poolActive(string calldata poolName) {\n        if (_hasFlag(_getStorage().pools[poolName].flags, PAUSED)) {\n            revert PoolPaused();\n        }\n        if (_poolComplete(poolName)) {\n            revert PoolClosed();\n        }\n        _;\n    }\n\n    modifier poolNotPaused(string calldata poolName) {\n        if (_hasFlag(_getStorage().pools[poolName].flags, PAUSED)) {\n            revert PoolPaused();\n        }\n        _;\n    }\n\n    modifier valid(PoolParameters calldata params) {\n        _verifyParams(params);\n        _;\n    }\n\n    modifier onlyDelegateOrOperator() {\n        address delegate = _getDelegateAddress();\n\n        if (_msgSender() != delegate && !hasRole(POOL_OPERATOR_ROLE, _msgSender())) {\n            revert MureErrors.Unauthorized();\n        }\n        _;\n    }\n\n    modifier onlyDelegate() {\n        address delegate = _getDelegateAddress();\n\n        if (_msgSender() != delegate) {\n            revert MureErrors.Unauthorized();\n        }\n        _;\n    }\n\n    modifier notDelegated() {\n        address delegate = _getDelegateAddress();\n\n        if (delegate != address(0)) {\n            revert MureErrors.Unauthorized();\n        }\n        _;\n    }\n\n    function initialize(string calldata name, string calldata version, address owner) external initializer {\n        __EIP712_init(name, version);\n        __AccessControl_init();\n        __ReentrancyGuard_init();\n        __Pausable_init();\n        _grantRole(DEFAULT_ADMIN_ROLE, owner);\n        _grantRole(POOL_OPERATOR_ROLE, owner);\n    }\n\n    /**\n     * @notice Creates a new pool with the specified parameters.\n     * @dev Requires the pool to not already exist. Can only be called by a pool operator.\n     * @param poolName the name of the pool to create\n     * @param params the parameters for the new pool\n     * @param sig the signature generated for pool creation for client\n     */\n    function createPool(string calldata poolName, PoolParameters calldata params, bytes memory sig)\n        external\n        onlyRole(POOL_OPERATOR_ROLE)\n        valid(params)\n    {\n        if (_poolExists(poolName)) {\n            revert PoolInitialized();\n        }\n\n        MurePoolStorage storage storage_ = _getStorage();\n\n        // The MureConfig checks the validity of the signature\n        Config(MURE_CONFIG).verifyMureSignature(_hashCreatePool(poolName, params.endTime), sig);\n\n        storage_.pools[poolName] = PoolState({\n            poolSize: params.poolSize,\n            totalCollected: 0,\n            endTime: params.endTime,\n            signer: params.signer,\n            depositors: 0,\n            currency: params.currency,\n            custodian: params.custodian,\n            flags: params.flags | INITIALIZED // Ensure pool is always marked as `initialized`\n        });\n\n        unchecked {\n            ++storage_.nonce;\n        }\n\n        emit PoolCreation(poolName);\n    }\n\n    /**\n     * @notice Updates the specified pool with the provided parameters.\n     * @dev Requires the pool to exist. Can only be called by a pool operator.\n     * @dev Requires the updated pool size to be greater than or equal to the total amount collected.\n     * @param poolName the name of the pool to update\n     * @param params the updated parameters for the pool\n     */\n    function updatePool(string calldata poolName, PoolParameters calldata params)\n        external\n        onlyRole(POOL_OPERATOR_ROLE)\n        valid(params)\n        poolValid(poolName)\n    {\n        MurePoolStorage storage storage_ = _getStorage();\n        PoolState storage state_ = storage_.pools[poolName];\n\n        _verifyPoolSize(state_.totalCollected, params.poolSize);\n\n        if (\n            state_.totalCollected > 0\n                && _hasFlag(state_.flags, PASSTHROUGH_FUNDS) != _hasFlag(params.flags, PASSTHROUGH_FUNDS)\n        ) {\n            revert IllegalPoolOperation(PoolErrorReason.ALREADY_INVESTED_POOL);\n        }\n\n        state_.poolSize = params.poolSize;\n        state_.endTime = params.endTime;\n        state_.signer = params.signer;\n        state_.currency = params.currency;\n        state_.custodian = params.custodian;\n        state_.flags = params.flags | INITIALIZED; // Ensure pool is always marked as `initialized`\n\n        emit PoolUpdate(poolName);\n    }\n\n    /**\n     * @notice Updates the size of the specified pool.\n     * @dev Requires the pool to exist. Can only be called by a pool operator.\n     * @dev Requires the new pool size to be greater than or equal to the total amount collected.\n     * @param poolName the name of the pool to update\n     * @param poolSize the updated size of the pool\n     */\n    function updatePoolSize(string calldata poolName, uint256 poolSize)\n        external\n        onlyRole(POOL_OPERATOR_ROLE)\n        poolValid(poolName)\n    {\n        PoolState storage pool = _getStorage().pools[poolName];\n\n        _verifyPoolSize(pool.totalCollected, uint112(poolSize));\n\n        pool.poolSize = uint112(poolSize);\n\n        emit PoolUpdate(poolName);\n    }\n\n    /**\n     * @notice Updates the end time of the specified pool.\n     * @dev Requires the pool to exist. Can only be called by a pool operator.\n     * @param poolName the name of the pool to update\n     * @param endTime the updated end time for the pool\n     */\n    function updatePoolEndTime(string calldata poolName, uint256 endTime)\n        external\n        onlyRole(POOL_OPERATOR_ROLE)\n        poolValid(poolName)\n    {\n        if (endTime < block.timestamp) {\n            revert IllegalPoolState(PoolParameter.END_TIME);\n        }\n\n        _getStorage().pools[poolName].endTime = uint32(endTime);\n\n        emit PoolUpdate(poolName);\n    }\n\n    /**\n     * @notice Updates the signer of the specified pool.\n     * @dev Requires the pool to exist. Can only be called by a pool operator.\n     * @param poolName the name of the pool to update\n     * @param _signer the updated signer for the pool\n     */\n    function updatePoolSigner(string calldata poolName, address _signer)\n        external\n        onlyRole(POOL_OPERATOR_ROLE)\n        poolValid(poolName)\n    {\n        if (_signer == address(0)) {\n            revert IllegalPoolState(PoolParameter.SIGNER);\n        }\n\n        _getStorage().pools[poolName].signer = _signer;\n\n        emit PoolUpdate(poolName);\n    }\n\n    /**\n     * @notice Pauses or unpauses the specified pool.\n     * @dev Requires the pool to exist. Can only be called by a pool operator or delegate.\n     * @param poolName the name of the pool to pause or unpause\n     * @param pause a boolean representing whether to pause or unpause the pool\n     */\n    function updatePoolPaused(string calldata poolName, bool pause)\n        external\n        onlyDelegateOrOperator\n        poolValid(poolName)\n    {\n        PoolState storage pool = _getStorage().pools[poolName];\n\n        pool.flags = pause ? _activateFlag(pool.flags, PAUSED) : _deactivateFlag(pool.flags, PAUSED);\n\n        emit PoolUpdate(poolName);\n    }\n\n    /**\n     * @notice Updates whether the specified pool allows refunds or not.\n     * @dev Requires the pool to exist. Can only be called by a pool operator.\n     * @dev Requires that the pool does not have the `PASSTHROUGH_FUNDS` flag set if enabling refunds.\n     * @param poolName the name of the pool to update\n     * @param refundable a boolean representing whether refunds should be enabled or not\n     */\n    function updatePoolRefundable(string calldata poolName, bool refundable)\n        external\n        onlyDelegateOrOperator\n        poolValid(poolName)\n    {\n        PoolState storage pool = _getStorage().pools[poolName];\n\n        if (_hasFlag(pool.flags, PASSTHROUGH_FUNDS) && refundable) {\n            revert IllegalPoolState(PoolParameter.FLAGS);\n        }\n\n        pool.flags = refundable ? _activateFlag(pool.flags, REFUNDABLE) : _deactivateFlag(pool.flags, REFUNDABLE);\n\n        emit PoolUpdate(poolName);\n    }\n\n    /**\n     * @notice Updates whether the specified pool passes funds through to the custodian directly or not.\n     * @dev Requires the pool to exist. Can only be called by a pool operator.\n     * @dev Requires that the pool does not have the `REFUNDABLE` flag set if enabling passthrough funds.\n     * @param poolName the name of the pool to update\n     * @param passthroughFunds a boolean representing whether to enable passthrough funds or not\n     */\n    function updatePoolPassthroughFunds(string calldata poolName, bool passthroughFunds)\n        external\n        onlyRole(POOL_OPERATOR_ROLE)\n        poolValid(poolName)\n    {\n        PoolState storage pool = _getStorage().pools[poolName];\n\n        if (_hasFlag(pool.flags, REFUNDABLE) && passthroughFunds) {\n            revert IllegalPoolState(PoolParameter.FLAGS);\n        }\n\n        if (pool.totalCollected > 0) {\n            revert IllegalPoolOperation(PoolErrorReason.ALREADY_INVESTED_POOL);\n        }\n\n        pool.flags = passthroughFunds\n            ? _activateFlag(pool.flags, PASSTHROUGH_FUNDS)\n            : _deactivateFlag(pool.flags, PASSTHROUGH_FUNDS);\n\n        emit PoolUpdate(poolName);\n    }\n\n    /**\n     * @notice Withdraws the total collected amount from the specified pool.\n     * @dev Requires the pool to exist. Can only be called by a pool operator or the delegate if it is set.\n     * @param poolName the name of the pool to withdraw from\n     */\n    function withdrawPoolFunds(string calldata poolName) external onlyDelegateOrOperator poolValid(poolName) {\n        PoolState storage pool = _getStorage().pools[poolName];\n        PoolMetrics storage poolMetrics = _getPoolMetricsStorage().poolMetrics[poolName];\n\n        if (_hasFlag(pool.flags, PASSTHROUGH_FUNDS) || _hasFlag(pool.flags, REFUNDABLE)) {\n            revert IllegalPoolOperation(PoolErrorReason.INVALID_POOL_TYPE);\n        }\n\n        uint256 amount = pool.totalCollected - poolMetrics.totalWithdrawn;\n        poolMetrics.totalWithdrawn += uint112(amount);\n\n        if (amount == 0) {\n            revert IllegalPoolOperation(PoolErrorReason.POOL_EMPTY);\n        }\n\n        (uint256 fee, address feeRecipient) = Config(MURE_CONFIG).getPoolFee(address(this), poolName, amount);\n\n        IERC20 currency = IERC20(pool.currency);\n        currency.transfer(address(pool.custodian), amount - fee);\n\n        if (fee > 0 && feeRecipient != address(0)) {\n            currency.transfer(address(feeRecipient), fee);\n        }\n\n        emit Withdrawal(poolName, amount, address(pool.custodian), \"\");\n    }\n\n    /**\n     * @notice Withdraw any token from the contract. This should only be used in emergencies\n     * as this can withdraw capital from any pool, be it active or not. Always prefer using `withdrawPoolFunds`\n     * over this function, unless you need clean up the contract by, e.g., burning garbage tokens.\n     * @param receiver the address to which the token will be transferred\n     * @param currency the address of the token contract\n     */\n    function withdrawCurrency(address receiver, address currency) external onlyRole(DEFAULT_ADMIN_ROLE) {\n        IERC20 currency_ = IERC20(currency);\n        uint256 balance = currency_.balanceOf(address(this));\n        currency_.transfer(receiver, balance);\n\n        emit Withdrawal(\"\", balance, receiver, \"\");\n    }\n\n    /**\n     * @notice Adds a deposit of the specified amount to the pool for the designated depositor.\n     * @dev Requires the pool to exist. Can only be called by a pool operator.\n     * @param poolName the name of the pool to add the deposit to\n     * @param depositor the address of the depositor\n     * @param amount the amount of the deposit\n     */\n    function addDeposit(string calldata poolName, address depositor, uint256 amount)\n        external\n        onlyRole(POOL_OPERATOR_ROLE)\n        poolValid(poolName)\n    {\n        _addDeposit(poolName, depositor, amount, \"\");\n        _getStorage().pools[poolName].totalCollected += uint112(amount);\n    }\n\n    /**\n     * @notice Deducts the specified amount from the deposit of the designated depositor in the pool.\n     * @dev Requires the pool to exist. Can only be called by a pool operator.\n     * @param poolName the name of the pool to deduct the deposit from\n     * @param depositor the address of the depositor\n     * @param amount the amount to deduct\n     */\n    function deductDeposit(string calldata poolName, address depositor, uint256 amount)\n        external\n        onlyRole(POOL_OPERATOR_ROLE)\n        poolValid(poolName)\n    {\n        _deductDeposit(poolName, depositor, amount, \"\");\n        _getStorage().pools[poolName].totalCollected -= uint112(amount);\n    }\n\n    /**\n     * @notice Moves the specified amount from one depositor's deposit to another in the pool.\n     * @dev Requires the pool to exist. Can only be called by a pool operator.\n     * @param poolName the name of the pool to move the deposit in\n     * @param from the address of the depositor to deduct the deposit from\n     * @param to the address of the depositor to add the deposit to\n     * @param amount the amount to move\n     */\n    function moveDeposit(string calldata poolName, address from, address to, uint256 amount)\n        external\n        onlyRole(POOL_OPERATOR_ROLE)\n        poolValid(poolName)\n    {\n        _deductDeposit(poolName, from, amount, \"\");\n        _addDeposit(poolName, to, amount, \"\");\n    }\n\n    /**\n     * @notice Adds or deducts balances on a per-depositor basis in batches.\n     * @dev Requires the pool to exist. Can only be called by the contract owner.\n     * @param poolName the name of the pool to move the deposit in\n     * @param transactions the set of `Transaction`s to execute on the provided `poolName`\n     */\n    function batchDeposit(string calldata poolName, Transaction[] calldata transactions)\n        external\n        onlyRole(POOL_OPERATOR_ROLE)\n        poolValid(poolName)\n    {\n        int256 totalDelta;\n\n        Transaction calldata transaction;\n        uint256 amount;\n\n        for (uint256 i = 0; i < transactions.length;) {\n            transaction = transactions[i];\n            amount = transaction.amount;\n            if (transaction.operation == Operation.Deposit) {\n                _addDeposit(poolName, transaction.depositor, amount, \"\");\n                unchecked {\n                    totalDelta += int256(amount);\n                }\n            } else {\n                _deductDeposit(poolName, transaction.depositor, amount, \"\");\n                unchecked {\n                    totalDelta -= int256(amount);\n                }\n            }\n\n            unchecked {\n                ++i;\n            }\n        }\n\n        PoolState storage pool = _getStorage().pools[poolName];\n        if (uint256(int256(int112(pool.totalCollected)) + totalDelta) > pool.poolSize) {\n            revert PoolFull();\n        }\n\n        unchecked {\n            if (totalDelta < 0) {\n                pool.totalCollected -= uint112(int112(totalDelta));\n            } else if (totalDelta > 0) {\n                pool.totalCollected += uint112(int112(totalDelta));\n            }\n        }\n    }\n\n    /**\n     * @notice Deposits `amount` of the relevant currency for the pool `poolName`.\n     * This operation assumes that the contract is an approved spender of the depositor.\n     * This operation is disabled for delegated pools, use depositFor instead\n     *\n     * @param poolName bytes32 representation of the pool name\n     * @param amount the amount the user want to invest. Need that for accounting\n     * @param sig the signatures generated for the user, including the amount.\n     * and verifying the signature.\n     */\n    function deposit(string calldata poolName, uint256 amount, bytes calldata sig) external notDelegated {\n        _deposit(poolName, amount, _msgSender(), \"\", sig);\n    }\n\n    /**\n     * @notice Deposits `amount` of the relevant currency for the pool `poolName`.\n     * This operation assumes that the contract is an approved spender of the depositor.\n     * This operation is disabled for delegated pools, use depositFor instead\n     *\n     * @param poolName bytes32 representation of the pool name\n     * @param amount the amount the user want to invest. Need that for accounting\n     * @param data additional data as contextual data for off-chain validation\n     * @param sig the signatures generated for the user, including the amount.\n     * and verifying the signature.\n     */\n    function deposit(string calldata poolName, uint256 amount, bytes calldata data, bytes calldata sig)\n        external\n        notDelegated\n    {\n        _deposit(poolName, amount, _msgSender(), data, sig);\n    }\n\n    /**\n     * @notice Deposits `amount` of the relevant currency for the pool `poolName`.\n     * This operation assumes that the contract is an approved spender of the depositor.\n     *\n     * @param poolName bytes32 representation of the pool name\n     * @param amount the amount the user want to invest. Need that for accounting\n     * @param depositor address of the depositor.\n     * @param sig the signatures generated for the user, including the amount.\n     */\n    function depositFor(string calldata poolName, uint256 amount, address depositor, bytes calldata sig)\n        external\n        onlyDelegate\n    {\n        _deposit(poolName, amount, depositor, \"\", sig);\n    }\n\n    /**\n     * @notice Allows a user to refund their deposited amount from the specified pool.\n     * This operation is disabled for delegated pools, use refundTo instead.\n     * @dev Requires the pool to exist.\n     * @dev Requires the pool to be not paused and must have the `REFUNDABLE` flag set.\n     * @param poolName the name of the pool from which to refund\n     */\n    function refund(string calldata poolName) external notDelegated {\n        uint256 amount = _getStorage().deposits[poolName][_msgSender()].amount;\n\n        if (amount == 0) {\n            revert DepositNotFound();\n        }\n\n        _refund(poolName, _msgSender(), amount, \"\");\n    }\n\n    /**\n     * @notice Allows a user to refund their deposited amount from the specified pool.\n     * This operation is disabled for delegated pools, use refundTo instead.\n     * @dev Requires the pool to exist.\n     * @dev Requires the pool to be not paused and must have the `REFUNDABLE` flag set.\n     * @param poolName the name of the pool from which to refund\n     * @param data additional data as contextual data for off-chain validation\n     */\n    function refund(string calldata poolName, bytes calldata data) external notDelegated {\n        MurePoolStorage storage storage_ = _getStorage();\n        uint256 amount = storage_.deposits[poolName][_msgSender()].amount;\n\n        if (amount == 0) {\n            revert DepositNotFound();\n        }\n\n        _refund(poolName, _msgSender(), amount, data);\n    }\n\n    /**\n     * @notice Allows a refund of the deposited amount from the specified pool.\n     * @dev Requires the pool to exist.\n     * @dev Requires the pool to be not paused and must have the `REFUNDABLE` flag set.\n     * @param poolName the name of the pool from which to refund\n     * @param depositor address of the depositor\n     */\n    function refundTo(string calldata poolName, address depositor, uint256 amount) external onlyDelegate {\n        _refund(poolName, depositor, amount, \"\");\n    }\n\n    /**\n     * @notice Deposits the withdrawn pool funds back.\n     * This operation assumes that the contract is an approved spender of the depositor.\n     * @dev Transfers the original collected funds back to the pool app\n     * @param poolName name of the pool\n     * @param depositor the address of the depositor\n     * @param amount the amount to be deposited back to the pool\n     */\n    function depositPoolFunds(string calldata poolName, address depositor, uint256 amount) external onlyDelegate {\n        _depositPoolFunds(poolName, depositor, amount);\n    }\n\n    /**\n     * @notice Retrieves the state of the specified pool.\n     * @dev Requires the pool to exist.\n     * @param poolName the name of the pool to retrieve the state of\n     */\n    function poolState(string calldata poolName) external view poolValid(poolName) returns (PoolState memory) {\n        return _getStorage().pools[poolName];\n    }\n\n    /**\n     * @notice Retrieves the metrics of the specified pool.\n     * @dev Requires the pool to exist.\n     * @param poolName the name of the pool to retrieve the metrics of\n     */\n    function poolMetrics(string calldata poolName) external view poolValid(poolName) returns (PoolMetrics memory) {\n        return _getPoolMetricsStorage().poolMetrics[poolName];\n    }\n\n    /**\n     * @notice Retrieves the amount deposited by the specified depositor in the specified pool.\n     * @dev Requires the pool to exist.\n     * @param poolName the name of the pool to retrieve the deposit from\n     * @param depositor the address of the depositor\n     */\n    function deposited(string calldata poolName, address depositor)\n        external\n        view\n        poolValid(poolName)\n        returns (uint256)\n    {\n        return _getStorage().deposits[poolName][depositor].amount;\n    }\n\n    /**\n     * @notice Retrieves the nonce of the specified depositor in the specified pool.\n     * @dev Requires the pool to exist.\n     * @param poolName the name of the pool to retrieve the nonce from\n     * @param depositor the address of the depositor\n     */\n    function nonce(string calldata poolName, address depositor) external view poolValid(poolName) returns (uint8) {\n        return _getStorage().deposits[poolName][depositor].nonce;\n    }\n\n    /**\n     * @notice Retrieves the nonce for create pool signature generation.\n     */\n    function nonce() external view returns (uint24) {\n        return _getStorage().nonce;\n    }\n\n    /**\n     * @notice Checks if the specified pool exists.\n     * @param pool the name of the pool to check for existence\n     */\n    function poolExists(string calldata pool) external view returns (bool) {\n        return _poolExists(pool);\n    }\n\n    /**\n     * @notice Checks if the specified pool is active.\n     * @param poolName the name of the pool to check if it is active\n     */\n    function isPoolActive(string calldata poolName) external view returns (bool) {\n        PoolState storage pool = _getStorage().pools[poolName];\n        return (!_hasFlag(pool.flags, PAUSED) && pool.endTime > block.timestamp);\n    }\n\n    /**\n     * @notice Checks if the specified pool is active.\n     * @param poolName the name of the pool to check if it is active\n     */\n    function withdrawableAmount(string calldata poolName) external view returns (uint112) {\n        return\n            _getStorage().pools[poolName].totalCollected - _getPoolMetricsStorage().poolMetrics[poolName].totalWithdrawn;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        virtual\n        override(ERC165Upgradeable, IERC165, AccessControlUpgradeable)\n        returns (bool)\n    {\n        return interfaceId == type(PoolApp).interfaceId || interfaceId == type(PoolMetadata).interfaceId\n            || interfaceId == type(Poolable).interfaceId || interfaceId == type(Refundable).interfaceId\n            || interfaceId == type(Depositable).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @notice Deposits `amount` of the relevant currency for the pool `poolName`.\n     * This operation assumes that the contract is an approved spender of the depositor.\n     * @param poolName bytes32 representation of the pool name\n     * @param amount the amount the user want to invest. Need that for accounting\n     * @param depositor address of the depositor.\n     * @param data additional data as contextual data for off-chain validation\n     * @param sig the signatures generated for the user, including the amount.\n     * and verifying the signature.\n     */\n    function _deposit(\n        string calldata poolName,\n        uint256 amount,\n        address depositor,\n        bytes memory data,\n        bytes calldata sig\n    ) private whenNotPaused nonReentrant poolValid(poolName) poolActive(poolName) {\n        PoolState storage pool = _getStorage().pools[poolName];\n\n        _verifySignature(amount, poolName, depositor, pool.signer, sig);\n\n        if (_hasFlag(pool.flags, PASSTHROUGH_FUNDS)) {\n            amount -= _deductFee(poolName, depositor, pool.currency, amount);\n        }\n\n        _beforeDeposit(_getDelegateAddress(), poolName, amount, depositor, sig);\n        _addDeposit(poolName, depositor, amount, data);\n        pool.totalCollected += uint112(amount);\n        // Add scope to avoid stack too deep\n        {\n            address destinationAddress = _hasFlag(pool.flags, PASSTHROUGH_FUNDS) ? pool.custodian : address(this);\n            _transferUpdate(depositor, destinationAddress, amount, pool.currency);\n        }\n\n        _afterDeposit(_getDelegateAddress(), poolName, amount, depositor, sig);\n    }\n\n    /**\n     * @notice Allows a user to refund their deposited amount from the specified pool.\n     * @dev Requires the pool to exist.\n     * @dev Requires the pool to be not paused and must have the `REFUNDABLE` flag set.\n     * @param poolName the name of the pool from which to refund\n     * @param depositor address of the depositor to refund from\n     * @param amount the amount to refund\n     * @param data additional data as contextual data for off-chain validation\n     */\n    function _refund(string calldata poolName, address depositor, uint256 amount, bytes memory data)\n        private\n        nonReentrant\n        whenNotPaused\n        poolNotPaused(poolName)\n        poolValid(poolName)\n    {\n        PoolState storage pool = _getStorage().pools[poolName];\n\n        address delegateAddress = _getDelegateAddress();\n        _beforeRefund(delegateAddress, poolName, depositor);\n\n        if (!_hasFlag(pool.flags, REFUNDABLE)) {\n            revert MureErrors.Unauthorized();\n        }\n\n        _deductDeposit(poolName, depositor, amount, data);\n        pool.totalCollected -= uint112(amount);\n\n        _transferUpdate(address(this), depositor, amount, pool.currency);\n\n        _afterRefund(delegateAddress, poolName, depositor, amount);\n\n        emit Refund(poolName, amount, depositor, data);\n    }\n\n    /**\n     * @notice Deposits the withdrawn pool funds back.\n     * @dev Transfers the original collected funds back to the pool app\n     * @param poolName name of the pool\n     * @param depositor the address of the depositor\n     * @param amount the amount to be deposited back to the pool\n     */\n    function _depositPoolFunds(string calldata poolName, address depositor, uint256 amount) private nonReentrant {\n        PoolState storage pool = _getStorage().pools[poolName];\n        PoolMetrics storage poolMetrics = _getPoolMetricsStorage().poolMetrics[poolName];\n\n        poolMetrics.totalWithdrawn -= uint112(amount);\n\n        _transferUpdate(depositor, address(this), amount, pool.currency);\n    }\n\n    /**\n     * @dev Adds deposit `amount` to designated `poolName` under `depositor`.\n     * As `totalCollected` is bound by `poolSize`, overflow is not possible unless `poolSize`\n     * is in a disallowed state to begin with.\n     */\n    function _addDeposit(string calldata poolName, address depositor, uint256 amount, bytes memory data) private {\n        MurePoolStorage storage storage_ = _getStorage();\n        PoolState storage state_ = storage_.pools[poolName];\n        DepositRecord storage deposit_ = storage_.deposits[poolName][depositor];\n\n        if (state_.totalCollected + amount > state_.poolSize) {\n            revert PoolFull();\n        }\n\n        unchecked {\n            deposit_.amount += uint112(amount);\n            ++deposit_.nonce;\n            if (deposit_.amount == uint112(amount)) {\n                ++state_.depositors;\n            }\n        }\n\n        emit Deposit(poolName, amount, depositor, data);\n    }\n\n    /**\n     * @dev Deducts deposit `amount` from designated `poolName` under `depositor`.\n     * As `totalCollected` is the cumulative sum of all `depositor`s under `poolName`,\n     * underflow is not possible unless `totalCollected` is in a disallowed state to begin with.\n     */\n    function _deductDeposit(string calldata poolName, address depositor, uint256 amount, bytes memory data) private {\n        MurePoolStorage storage storage_ = _getStorage();\n        PoolState storage state_ = storage_.pools[poolName];\n        DepositRecord storage deposit_ = storage_.deposits[poolName][depositor];\n\n        if (deposit_.amount < amount) {\n            revert PoolError(PoolErrorReason.ARITHMETIC_OUT_OF_BOUNDS);\n        }\n\n        unchecked {\n            deposit_.amount -= uint112(amount);\n            ++deposit_.nonce;\n            if (deposit_.amount == 0) {\n                --state_.depositors;\n            }\n        }\n\n        emit Withdrawal(poolName, amount, depositor, data);\n    }\n\n    /**\n     * @dev Determines and transfers the mure fee on deposits.\n     * @param poolName name of the pool\n     * @param depositor the address of the depositor\n     * @param currency the address of the currency being transferred\n     * @param amount the amount of the currency being transferred\n     */\n    function _deductFee(string calldata poolName, address depositor, address currency, uint256 amount)\n        private\n        returns (uint256)\n    {\n        (uint256 fee, address feeRecipient) = Config(MURE_CONFIG).getPoolFee(address(this), poolName, amount);\n\n        if (fee > 0 && feeRecipient != address(0)) {\n            _transferUpdate(depositor, feeRecipient, fee, currency);\n        }\n\n        return fee;\n    }\n\n    /**\n     * @dev Updates the transfer between two addresses with a specified amount of a given currency.\n     * @param from the address from which the transfer is initiated\n     * @param to the address to which the transfer is made\n     * @param amount the amount of the currency being transferred\n     * @param currency the address of the currency being transferred\n     */\n    function _transferUpdate(address from, address to, uint256 amount, address currency) private {\n        IERC20 currency_ = IERC20(currency);\n        bool success;\n        if (from == address(this)) {\n            success = currency_.transfer(to, amount);\n        } else {\n            success = currency_.transferFrom(from, to, amount);\n        }\n\n        if (!success) {\n            revert PoolError(PoolErrorReason.TRANSFER_FAILURE);\n        }\n    }\n\n    /**\n     * @dev Checks whether a pool with the specified name exists.\n     * @param pool the name of the pool being checked\n     */\n    function _poolExists(string calldata pool) private view returns (bool) {\n        return _hasFlag(_getStorage().pools[pool].flags, INITIALIZED);\n    }\n\n    /**\n     * @dev Verifies the validity of the specified pool parameters.\n     * @param config the parameters of the pool being verified\n     */\n    function _verifyParams(PoolParameters calldata config) private view {\n        if (config.endTime < block.timestamp) {\n            revert IllegalPoolState(PoolParameter.END_TIME);\n        }\n        if (config.signer == address(0)) {\n            revert IllegalPoolState(PoolParameter.SIGNER);\n        }\n        if (config.currency == address(0)) {\n            revert IllegalPoolState(PoolParameter.CURRENCY);\n        }\n        if (config.custodian == address(0)) {\n            revert IllegalPoolState(PoolParameter.CUSTODIAN);\n        }\n        if (_hasFlag(config.flags, PASSTHROUGH_FUNDS) && _hasFlag(config.flags, REFUNDABLE)) {\n            revert IllegalPoolState(PoolParameter.FLAGS);\n        }\n    }\n\n    /**\n     * @dev Checks whether the specified pool has been completed.\n     * @param poolName the name of the pool being checked\n     */\n    function _poolComplete(string calldata poolName) private view returns (bool) {\n        PoolState storage state_ = _getStorage().pools[poolName];\n        return state_.totalCollected == state_.poolSize || state_.endTime < block.timestamp;\n    }\n\n    /**\n     * @dev Generates a hashed representation of the specified amount and pool name, along with the sender's nonce.\n     * @param amount the amount of the deposit\n     * @param poolName the name of the pool\n     * @param depositor address of the depositor\n     */\n    function _hashDeposit(uint256 amount, string calldata poolName, address depositor) private view returns (bytes32) {\n        return _hashTypedDataV4(\n            keccak256(\n                abi.encode(\n                    DEPOSIT_HASH,\n                    amount,\n                    keccak256(bytes(poolName)),\n                    depositor,\n                    _getStorage().deposits[poolName][depositor].nonce\n                )\n            )\n        );\n    }\n\n    /**\n     * @dev Generates a struct hash of the specified pool name and end time, along with the nonce.\n     * @param poolName the name of the pool\n     * @param endTime the endtime block timestamp for the pool\n     */\n    function _hashCreatePool(string calldata poolName, uint32 endTime) private view returns (bytes32) {\n        return keccak256(abi.encode(CREATE_POOL_HASH, keccak256(bytes(poolName)), endTime, _getStorage().nonce));\n    }\n\n    /**\n     * @dev Verifies the validity of the pool size for an existing pool.\n     * @param totalCollected total collected amount for the pool being updated\n     * @param newPoolSize new pool size for the pool being updated\n     */\n    function _verifyPoolSize(uint112 totalCollected, uint112 newPoolSize) private pure {\n        if (totalCollected > newPoolSize) {\n            revert IllegalPoolState(PoolParameter.POOL_SIZE);\n        }\n    }\n\n    /**\n     * @dev Checks whether a specific flag is activated within a set of flags.\n     * @param flags the set of flags being checked\n     * @param flag the flag being checked for activation\n     */\n    function _hasFlag(uint16 flags, uint16 flag) private pure returns (bool) {\n        return flags & flag != 0;\n    }\n\n    /**\n     * @dev Activates the specified flag within a set of flags.\n     * @param flags the set of flags being modified\n     * @param flag the flag being activated\n     */\n    function _activateFlag(uint16 flags, uint16 flag) private pure returns (uint16) {\n        return flags | flag;\n    }\n\n    /**\n     * @dev Deactivates the specified flag within a set of flags.\n     * @param flags the set of flags being modified\n     * @param flag the flag being deactivated\n     */\n    function _deactivateFlag(uint16 flags, uint16 flag) private pure returns (uint16) {\n        return flags & ~flag;\n    }\n\n    /**\n     * @dev Retrieves the delegate address from config.\n     */\n    function _getDelegateAddress() private returns (address delegate) {\n        delegate = Config(MURE_CONFIG).getAppDelegate(address(this));\n    }\n\n    /**\n     * @dev Performs delegate operations before deposit operation.\n     * @param delegateAddress address of the delegate contract\n     * @param poolName name of the pool\n     * @param amount deposit amount\n     * @param sig deposit signature\n     */\n    function _beforeDeposit(\n        address delegateAddress,\n        string calldata poolName,\n        uint256 amount,\n        address depositor,\n        bytes calldata sig\n    ) private {\n        if (delegateAddress != address(0)) {\n            Delegatable(delegateAddress).beforeDeposit(poolName, amount, depositor, sig);\n        }\n    }\n\n    /**\n     * @dev Performs delegate operations after deposit operation.\n     * @param delegateAddress address of the delegate contract\n     * @param poolName name of the pool\n     * @param amount deposit amount\n     * @param sig deposit signature\n     */\n    function _afterDeposit(\n        address delegateAddress,\n        string calldata poolName,\n        uint256 amount,\n        address depositor,\n        bytes calldata sig\n    ) private {\n        if (delegateAddress != address(0)) {\n            Delegatable(delegateAddress).afterDeposit(poolName, amount, depositor, sig);\n        }\n    }\n\n    /**\n     * @dev Performs delegate operations before refund operation.\n     * @param delegateAddress address of the delegate contract\n     * @param poolName name of the pool\n     * @param depositor address of the depositor\n     */\n    function _beforeRefund(address delegateAddress, string calldata poolName, address depositor) private {\n        if (delegateAddress != address(0)) {\n            Delegatable(delegateAddress).beforeRefund(poolName, depositor);\n        }\n    }\n\n    /**\n     * @dev Performs delegate operations after refund operation.\n     * @param delegateAddress address of the delegate contract\n     * @param poolName name of the pool\n     * @param depositor address of the depositor\n     * @param amount the refund amount\n     */\n    function _afterRefund(address delegateAddress, string calldata poolName, address depositor, uint256 amount)\n        private\n    {\n        if (delegateAddress != address(0)) {\n            Delegatable(delegateAddress).afterRefund(poolName, depositor, amount);\n        }\n    }\n\n    /**\n     * @dev Retrieves the storage for the MurePool contract.\n     */\n    function _getStorage() private pure returns (MurePoolStorage storage $) {\n        assembly {\n            $.slot := MurePoolStorageLocation\n        }\n    }\n\n    /**\n     * @dev Retrieves the storage for the pool metrics.\n     */\n    function _getPoolMetricsStorage() private pure returns (PoolMetricsStorage storage $) {\n        assembly {\n            $.slot := PoolMetricsStorageLocation\n        }\n    }\n\n    function _verifySignature(\n        uint256 amount,\n        string calldata poolName,\n        address depositor,\n        address signer,\n        bytes calldata sig\n    ) private view {\n        if (!SignatureChecker.isValidSignatureNow(signer, _hashDeposit(amount, poolName, depositor), sig)) {\n            revert MureErrors.Unauthorized();\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/utils/PausableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)\n\npragma solidity ^0.8.20;\n\nimport {ContextUpgradeable} from \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n    /// @custom:storage-location erc7201:openzeppelin.storage.Pausable\n    struct PausableStorage {\n        bool _paused;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Pausable\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;\n\n    function _getPausableStorage() private pure returns (PausableStorage storage $) {\n        assembly {\n            $.slot := PausableStorageLocation\n        }\n    }\n\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    /**\n     * @dev The operation failed because the contract is paused.\n     */\n    error EnforcedPause();\n\n    /**\n     * @dev The operation failed because the contract is not paused.\n     */\n    error ExpectedPause();\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    function __Pausable_init() internal onlyInitializing {\n        __Pausable_init_unchained();\n    }\n\n    function __Pausable_init_unchained() internal onlyInitializing {\n        PausableStorage storage $ = _getPausableStorage();\n        $._paused = false;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        PausableStorage storage $ = _getPausableStorage();\n        return $._paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        if (paused()) {\n            revert EnforcedPause();\n        }\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        if (!paused()) {\n            revert ExpectedPause();\n        }\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        PausableStorage storage $ = _getPausableStorage();\n        $._paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        PausableStorage storage $ = _getPausableStorage();\n        $._paused = false;\n        emit Unpaused(_msgSender());\n    }\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n    function __ERC165_init() internal onlyInitializing {\n    }\n\n    function __ERC165_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.20;\n\nimport {IAccessControl} from \"@openzeppelin/contracts/access/IAccessControl.sol\";\nimport {ContextUpgradeable} from \"../utils/ContextUpgradeable.sol\";\nimport {ERC165Upgradeable} from \"../utils/introspection/ERC165Upgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n *     require(hasRole(MY_ROLE, msg.sender));\n *     ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n    struct RoleData {\n        mapping(address account => bool) hasRole;\n        bytes32 adminRole;\n    }\n\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n\n    /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n    struct AccessControlStorage {\n        mapping(bytes32 role => RoleData) _roles;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n    function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n        assembly {\n            $.slot := AccessControlStorageLocation\n        }\n    }\n\n    /**\n     * @dev Modifier that checks that an account has a specific role. Reverts\n     * with an {AccessControlUnauthorizedAccount} error including the required role.\n     */\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role);\n        _;\n    }\n\n    function __AccessControl_init() internal onlyInitializing {\n    }\n\n    function __AccessControl_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n        AccessControlStorage storage $ = _getAccessControlStorage();\n        return $._roles[role].hasRole[account];\n    }\n\n    /**\n     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n     */\n    function _checkRole(bytes32 role) internal view virtual {\n        _checkRole(role, _msgSender());\n    }\n\n    /**\n     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n     * is missing `role`.\n     */\n    function _checkRole(bytes32 role, address account) internal view virtual {\n        if (!hasRole(role, account)) {\n            revert AccessControlUnauthorizedAccount(account, role);\n        }\n    }\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n        AccessControlStorage storage $ = _getAccessControlStorage();\n        return $._roles[role].adminRole;\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been revoked `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `callerConfirmation`.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n        if (callerConfirmation != _msgSender()) {\n            revert AccessControlBadConfirmation();\n        }\n\n        _revokeRole(role, callerConfirmation);\n    }\n\n    /**\n     * @dev Sets `adminRole` as ``role``'s admin role.\n     *\n     * Emits a {RoleAdminChanged} event.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        AccessControlStorage storage $ = _getAccessControlStorage();\n        bytes32 previousAdminRole = getRoleAdmin(role);\n        $._roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\n    }\n\n    /**\n     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n        AccessControlStorage storage $ = _getAccessControlStorage();\n        if (!hasRole(role, account)) {\n            $._roles[role].hasRole[account] = true;\n            emit RoleGranted(role, account, _msgSender());\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n        AccessControlStorage storage $ = _getAccessControlStorage();\n        if (hasRole(role, account)) {\n            $._roles[role].hasRole[account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n            return true;\n        } else {\n            return false;\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/utils/ReentrancyGuardUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)\n\npragma solidity ^0.8.20;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant NOT_ENTERED = 1;\n    uint256 private constant ENTERED = 2;\n\n    /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard\n    struct ReentrancyGuardStorage {\n        uint256 _status;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.ReentrancyGuard\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;\n\n    function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {\n        assembly {\n            $.slot := ReentrancyGuardStorageLocation\n        }\n    }\n\n    /**\n     * @dev Unauthorized reentrant call.\n     */\n    error ReentrancyGuardReentrantCall();\n\n    function __ReentrancyGuard_init() internal onlyInitializing {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n        $._status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n        // On the first call to nonReentrant, _status will be NOT_ENTERED\n        if ($._status == ENTERED) {\n            revert ReentrancyGuardReentrantCall();\n        }\n\n        // Any calls to nonReentrant after this point will fail\n        $._status = ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        $._status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();\n        return $._status == ENTERED;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/utils/cryptography/EIP712Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)\n\npragma solidity ^0.8.20;\n\nimport {MessageHashUtils} from \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\nimport {IERC5267} from \"@openzeppelin/contracts/interfaces/IERC5267.sol\";\nimport {Initializable} from \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose\n * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract\n * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to\n * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain\n * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the\n * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.\n */\nabstract contract EIP712Upgradeable is Initializable, IERC5267 {\n    bytes32 private constant TYPE_HASH =\n        keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n    /// @custom:storage-location erc7201:openzeppelin.storage.EIP712\n    struct EIP712Storage {\n        /// @custom:oz-renamed-from _HASHED_NAME\n        bytes32 _hashedName;\n        /// @custom:oz-renamed-from _HASHED_VERSION\n        bytes32 _hashedVersion;\n\n        string _name;\n        string _version;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.EIP712\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100;\n\n    function _getEIP712Storage() private pure returns (EIP712Storage storage $) {\n        assembly {\n            $.slot := EIP712StorageLocation\n        }\n    }\n\n    /**\n     * @dev Initializes the domain separator and parameter caches.\n     *\n     * The meaning of `name` and `version` is specified in\n     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n     *\n     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n     * - `version`: the current major version of the signing domain.\n     *\n     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n     * contract upgrade].\n     */\n    function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n        __EIP712_init_unchained(name, version);\n    }\n\n    function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n        EIP712Storage storage $ = _getEIP712Storage();\n        $._name = name;\n        $._version = version;\n\n        // Reset prior values in storage if upgrading\n        $._hashedName = 0;\n        $._hashedVersion = 0;\n    }\n\n    /**\n     * @dev Returns the domain separator for the current chain.\n     */\n    function _domainSeparatorV4() internal view returns (bytes32) {\n        return _buildDomainSeparator();\n    }\n\n    function _buildDomainSeparator() private view returns (bytes32) {\n        return keccak256(abi.encode(TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this)));\n    }\n\n    /**\n     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n     * function returns the hash of the fully encoded EIP712 message for this domain.\n     *\n     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n     *\n     * ```solidity\n     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n     *     keccak256(\"Mail(address to,string contents)\"),\n     *     mailTo,\n     *     keccak256(bytes(mailContents))\n     * )));\n     * address signer = ECDSA.recover(digest, signature);\n     * ```\n     */\n    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n        return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n    }\n\n    /**\n     * @dev See {IERC-5267}.\n     */\n    function eip712Domain()\n        public\n        view\n        virtual\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        )\n    {\n        EIP712Storage storage $ = _getEIP712Storage();\n        // If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized\n        // and the EIP712 domain is not reliable, as it will be missing name and version.\n        require($._hashedName == 0 && $._hashedVersion == 0, \"EIP712: Uninitialized\");\n\n        return (\n            hex\"0f\", // 01111\n            _EIP712Name(),\n            _EIP712Version(),\n            block.chainid,\n            address(this),\n            bytes32(0),\n            new uint256[](0)\n        );\n    }\n\n    /**\n     * @dev The name parameter for the EIP712 domain.\n     *\n     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n     * are a concern.\n     */\n    function _EIP712Name() internal view virtual returns (string memory) {\n        EIP712Storage storage $ = _getEIP712Storage();\n        return $._name;\n    }\n\n    /**\n     * @dev The version parameter for the EIP712 domain.\n     *\n     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n     * are a concern.\n     */\n    function _EIP712Version() internal view virtual returns (string memory) {\n        EIP712Storage storage $ = _getEIP712Storage();\n        return $._version;\n    }\n\n    /**\n     * @dev The hash of the name parameter for the EIP712 domain.\n     *\n     * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead.\n     */\n    function _EIP712NameHash() internal view returns (bytes32) {\n        EIP712Storage storage $ = _getEIP712Storage();\n        string memory name = _EIP712Name();\n        if (bytes(name).length > 0) {\n            return keccak256(bytes(name));\n        } else {\n            // If the name is empty, the contract may have been upgraded without initializing the new storage.\n            // We return the name hash in storage if non-zero, otherwise we assume the name is empty by design.\n            bytes32 hashedName = $._hashedName;\n            if (hashedName != 0) {\n                return hashedName;\n            } else {\n                return keccak256(\"\");\n            }\n        }\n    }\n\n    /**\n     * @dev The hash of the version parameter for the EIP712 domain.\n     *\n     * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead.\n     */\n    function _EIP712VersionHash() internal view returns (bytes32) {\n        EIP712Storage storage $ = _getEIP712Storage();\n        string memory version = _EIP712Version();\n        if (bytes(version).length > 0) {\n            return keccak256(bytes(version));\n        } else {\n            // If the version is empty, the contract may have been upgraded without initializing the new storage.\n            // We return the version hash in storage if non-zero, otherwise we assume the version is empty by design.\n            bytes32 hashedVersion = $._hashedVersion;\n            if (hashedVersion != 0) {\n                return hashedVersion;\n            } else {\n                return keccak256(\"\");\n            }\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\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 value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 value) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/cryptography/SignatureChecker.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/SignatureChecker.sol)\n\npragma solidity ^0.8.20;\n\nimport {ECDSA} from \"./ECDSA.sol\";\nimport {IERC1271} from \"../../interfaces/IERC1271.sol\";\n\n/**\n * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA\n * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like\n * Argent and Safe Wallet (previously Gnosis Safe).\n */\nlibrary SignatureChecker {\n    /**\n     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the\n     * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.\n     *\n     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n     * change through time. It could return true at block N and false at block N+1 (or the opposite).\n     */\n    function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {\n        (address recovered, ECDSA.RecoverError error, ) = ECDSA.tryRecover(hash, signature);\n        return\n            (error == ECDSA.RecoverError.NoError && recovered == signer) ||\n            isValidERC1271SignatureNow(signer, hash, signature);\n    }\n\n    /**\n     * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated\n     * against the signer smart contract using ERC1271.\n     *\n     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n     * change through time. It could return true at block N and false at block N+1 (or the opposite).\n     */\n    function isValidERC1271SignatureNow(\n        address signer,\n        bytes32 hash,\n        bytes memory signature\n    ) internal view returns (bool) {\n        (bool success, bytes memory result) = signer.staticcall(\n            abi.encodeCall(IERC1271.isValidSignature, (hash, signature))\n        );\n        return (success &&\n            result.length >= 32 &&\n            abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));\n    }\n}\n"
      },
      "src/interfaces/Poolable.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.22;\n\n/**\n * @dev Structure of parameters of a pool\n */\nstruct PoolParameters {\n    uint112 poolSize;\n    uint32 endTime; // uint32 => year 2106\n    uint16 flags;\n    address currency;\n    address custodian;\n    address signer;\n}\n\n/**\n * @dev Structure for pool metrics. Could be updated in future\n */\nstruct PoolMetrics {\n    uint112 totalWithdrawn;\n}\n\nenum PoolParameter {\n    POOL_SIZE,\n    END_TIME, // UINT32 => YEAR 2106\n    FLAGS,\n    DEPOSITORS,\n    CURRENCY,\n    CUSTODIAN,\n    SIGNER\n}\n\nenum PoolErrorReason {\n    POOL_SIZE_TOO_SMALL,\n    TRANSFER_FAILURE,\n    ARITHMETIC_OUT_OF_BOUNDS,\n    ALREADY_INVESTED_POOL,\n    INVALID_POOL_TYPE,\n    POOL_EMPTY\n}\n\n/**\n * @dev Interface for pool administration functionality and pool errors.\n * @author Mure\n */\ninterface Poolable {\n    error PoolClosed();\n    error PoolOpen();\n    error PoolError(PoolErrorReason reason);\n    error IllegalPoolState(PoolParameter param);\n    error IllegalPoolOperation(PoolErrorReason reason);\n    error PoolInitialized();\n    error PoolFull();\n    error PoolPaused();\n    error PoolNotEmpty();\n\n    event PoolCreation(string poolName);\n    event PoolUpdate(string poolName);\n    event Withdrawal(string poolName, uint256 indexed amount, address indexed to, bytes data);\n\n    function createPool(string calldata poolName, PoolParameters calldata params, bytes calldata sig) external;\n\n    function updatePool(string calldata poolName, PoolParameters calldata params) external;\n\n    function poolMetrics(string calldata poolName) external view returns (PoolMetrics memory);\n}\n"
      },
      "src/interfaces/PoolMetadata.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.22;\n\n/**\n * @dev Structure of a pool\n */\nstruct PoolState {\n    uint112 totalCollected;\n    uint112 poolSize;\n    uint16 flags;\n    uint16 depositors;\n    uint32 endTime; // uint32 => year 2106\n    address currency;\n    address custodian;\n    address signer;\n}\n\n/**\n * @dev Interface for pool information like its state and existence\n * @author Mure\n */\ninterface PoolMetadata {\n    function isPoolActive(string calldata poolName) external view returns (bool);\n\n    function poolExists(string calldata pool) external view returns (bool);\n\n    function poolState(string calldata poolName) external view returns (PoolState memory);\n\n    function withdrawableAmount(string calldata poolName) external view returns (uint112);\n}\n"
      },
      "src/interfaces/Depositable.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.22;\n\n/**\n * @dev Structure of a deposit\n */\nstruct DepositRecord {\n    uint112 amount;\n    uint8 nonce;\n}\n\n/**\n * @dev Interface for deposit functionality of pools.\n * @author Mure\n */\ninterface Depositable {\n    event Deposit(string poolName, uint256 indexed amount, address indexed from, bytes data);\n\n    function deposit(string calldata poolName, uint256 amount, bytes calldata sig) external;\n\n    function deposit(string calldata poolName, uint256 amount, bytes calldata data, bytes calldata sig) external;\n\n    function deposited(string calldata poolName, address depositor) external view returns (uint256);\n}\n"
      },
      "src/interfaces/Delegatable.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.22;\n\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport {PoolMetadata} from \"./PoolMetadata.sol\";\n\nstruct PoolConfig {\n    uint256 claimReserves;\n    uint256 depositReserves;\n    uint256 supply;\n    uint16 plugins;\n    uint16 feePercentage; // 0 to 10000\n    address claimCurrency;\n}\n\nenum DelegateErrorReason {\n    TRANSFER_FAILURE,\n    INVALID_PERCENTAGE,\n    ALREADY_DEPOSITED_FUNDS\n}\n\n/**\n * @dev Interface for Delegate core with support for ERC-165 detection.\n * @author Mure\n */\ninterface Delegatable is IERC165, PoolMetadata {\n    error PluginDisabled(uint16 plugin);\n    error PluginEnabled(uint16 plugin);\n    error InvalidAmount();\n    error DelegateError(DelegateErrorReason reason);\n\n    event PoolFundsDeposit(string poolName, uint256 indexed refundFunds, uint256 indexed claimFunds);\n    event FundTransfer(address indexed to, uint256 indexed amount, address indexed currency);\n    event ConfigUpdate(string poolName);\n    event PoolContractUpdate(address indexed poolContract);\n\n    function beforeDeposit(string calldata poolName, uint256 amount, address depositor, bytes memory sig) external;\n\n    function afterDeposit(string calldata poolName, uint256 amount, address depositor, bytes memory sig) external;\n\n    function beforeRefund(string calldata poolName, address depositor) external;\n\n    function afterRefund(string calldata poolName, address depositor, uint256 amount) external;\n\n    function withdrawPoolFunds(string calldata poolName) external;\n\n    function depositPoolFunds(string calldata poolName, uint256 refundFunds, uint256 claimFunds) external;\n\n    function deposit(string calldata poolName, uint256 amount, bytes memory sig) external;\n\n    function refund(string calldata poolName) external;\n\n    function refund(string calldata poolName, address depositor, uint256 amount) external;\n\n    function claim(string calldata poolName) external;\n\n    function sendFunds(address to, uint256 amount, address currency) external;\n\n    function poolConfig(string calldata poolName) external view returns (PoolConfig memory);\n\n    function poolAddress() external view returns (address);\n\n    function deposited(string calldata poolName, address depositor) external view returns (uint256);\n\n    function getClaimCurrency(string calldata poolName) external view returns (address);\n}\n"
      },
      "src/interfaces/PoolApp.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.22;\n\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport {Poolable} from \"./Poolable.sol\";\nimport {Depositable} from \"./Depositable.sol\";\nimport {Refundable} from \"./Refundable.sol\";\nimport {PoolMetadata} from \"./PoolMetadata.sol\";\n\n/**\n * @dev Interface for MurePool core with support for ERC-165 detection.\n * @author Mure\n */\ninterface PoolApp is IERC165, Poolable, Depositable, Refundable, PoolMetadata {\n    enum Operation {\n        Deposit,\n        Withdrawal\n    }\n\n    struct Transaction {\n        address depositor;\n        uint112 amount;\n        Operation operation;\n    }\n\n    function withdrawPoolFunds(string calldata poolName) external;\n\n    function depositFor(string calldata poolName, uint256 amount, address depositor, bytes memory sig) external;\n\n    function refundTo(string calldata poolName, address depositor, uint256 amount) external;\n\n    function nonce(string calldata poolName, address depositor) external view returns (uint8);\n\n    function updatePoolPaused(string calldata poolName, bool pause) external;\n\n    function updatePoolRefundable(string calldata poolName, bool refundable) external;\n\n    function depositPoolFunds(string calldata poolName, address depositor, uint256 amount) external;\n}\n"
      },
      "src/interfaces/Refundable.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.22;\n\n/**\n * @dev Interface for refund fuctioanlity for pools with support for ERC-165 detection.\n * @author Mure\n */\ninterface Refundable {\n    error DepositNotFound();\n\n    event Refund(string poolName, uint256 indexed amount, address indexed depositor, bytes data);\n\n    function refund(string calldata poolName) external;\n\n    function updatePoolRefundable(string calldata poolName, bool refundable) external;\n}\n"
      },
      "src/interfaces/Config.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.22;\n\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for MureConfig core with support for ERC-165 detection.\n * @author Mure\n */\ninterface Config is IERC165 {\n    /// @dev Must not revert, should return address(0) incase delegate does not exist\n    function getAppDelegate(address poolApp) external returns (address);\n\n    function setAppDelegate(address poolApp, address delegate) external;\n\n    function verifyMureSignature(bytes32 structHash, bytes memory signature) external;\n\n    function toggleWhitelistedSigner(address mureSigner_) external;\n\n    function getFeeContractAddress() external view returns (address);\n\n    function setMureFeeContract(address feeContractAddress) external;\n\n    function getPoolFee(address poolApp, string calldata poolName, uint256 amount)\n        external\n        returns (uint256 feeAmount, address recipient);\n}\n"
      },
      "src/libraries/MureErrors.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity 0.8.22;\n\n/**\n * @dev Library with global errors for Mure\n * @author Mure\n */\nlibrary MureErrors {\n    /**\n     * @dev thrown when address is invalid, eg: zero address\n     */\n    error InvalidAddress(address addr);\n\n    /**\n     * @dev thrown when a signature has expired before verification\n     */\n    error SignatureExpired();\n\n    /**\n     * @dev thrown when any restricted operation is performed by an unauthorized entity\n     */\n    error Unauthorized();\n\n    /**\n     * @dev thrown when address is not a valid delegate\n     */\n    error InvalidDelegate();\n\n    /**\n     * @dev thrown when pool with given parameters is not found\n     */\n    error PoolNotFound();\n\n    /**\n     * @dev thrown when fee is invalid\n     */\n    error InvalidFee();\n}\n"
      },
      "src/shared/Constants.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.22;\n\n/**\n * @dev Role allows user to create and update pools along with pool administration\n */\nbytes32 constant POOL_OPERATOR_ROLE = keccak256(\"POOL_OPERATOR\");\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\n\npragma solidity ^0.8.20;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Storage of the initializable contract.\n     *\n     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n     * when using with upgradeable contracts.\n     *\n     * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n     */\n    struct InitializableStorage {\n        /**\n         * @dev Indicates that the contract has been initialized.\n         */\n        uint64 _initialized;\n        /**\n         * @dev Indicates that the contract is in the process of being initialized.\n         */\n        bool _initializing;\n    }\n\n    // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) & ~bytes32(uint256(0xff))\n    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n    /**\n     * @dev The contract is already initialized.\n     */\n    error InvalidInitialization();\n\n    /**\n     * @dev The contract is not initializing.\n     */\n    error NotInitializing();\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint64 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n     * production.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        // Cache values to avoid duplicated sloads\n        bool isTopLevelCall = !$._initializing;\n        uint64 initialized = $._initialized;\n\n        // Allowed calls:\n        // - initialSetup: the contract is not in the initializing state and no previous version was\n        //                 initialized\n        // - construction: the contract is initialized at version 1 (no reininitialization) and the\n        //                 current contract is just being deployed\n        bool initialSetup = initialized == 0 && isTopLevelCall;\n        bool construction = initialized == 1 && address(this).code.length == 0;\n\n        if (!initialSetup && !construction) {\n            revert InvalidInitialization();\n        }\n        $._initialized = 1;\n        if (isTopLevelCall) {\n            $._initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            $._initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint64 version) {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        if ($._initializing || $._initialized >= version) {\n            revert InvalidInitialization();\n        }\n        $._initialized = version;\n        $._initializing = true;\n        _;\n        $._initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        _checkInitializing();\n        _;\n    }\n\n    /**\n     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n     */\n    function _checkInitializing() internal view virtual {\n        if (!_isInitializing()) {\n            revert NotInitializing();\n        }\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     *\n     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        // solhint-disable-next-line var-name-mixedcase\n        InitializableStorage storage $ = _getInitializableStorage();\n\n        if ($._initializing) {\n            revert InvalidInitialization();\n        }\n        if ($._initialized != type(uint64).max) {\n            $._initialized = type(uint64).max;\n            emit Initialized(type(uint64).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint64) {\n        return _getInitializableStorage()._initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _getInitializableStorage()._initializing;\n    }\n\n    /**\n     * @dev Returns a pointer to the storage namespace.\n     */\n    // solhint-disable-next-line var-name-mixedcase\n    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n        assembly {\n            $.slot := INITIALIZABLE_STORAGE\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/access/IAccessControl.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n    /**\n     * @dev The `account` is missing a role.\n     */\n    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n    /**\n     * @dev The caller of a function is not the expected one.\n     *\n     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n     */\n    error AccessControlBadConfirmation();\n\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `callerConfirmation`.\n     */\n    function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n    /**\n     * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n     * `0x45` (`personal_sign` messages).\n     *\n     * The digest is calculated by prefixing a bytes32 `messageHash` with\n     * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n     *\n     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n     * keccak256, although any bytes32 value can be safely used because the final digest will\n     * be re-hashed.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n        }\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n     * `0x45` (`personal_sign` messages).\n     *\n     * The digest is calculated by prefixing an arbitrary `message` with\n     * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n        return\n            keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n     * `0x00` (data with intended validator).\n     *\n     * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n     * `validator` address. Then hashing the result.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\n     *\n     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n     * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let ptr := mload(0x40)\n            mstore(ptr, hex\"19_01\")\n            mstore(add(ptr, 0x02), domainSeparator)\n            mstore(add(ptr, 0x22), structHash)\n            digest := keccak256(ptr, 0x42)\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/interfaces/IERC5267.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n    /**\n     * @dev MAY be emitted to signal that the domain could have changed.\n     */\n    event EIP712DomainChanged();\n\n    /**\n     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n     * signature.\n     */\n    function eip712Domain()\n        external\n        view\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        );\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS\n    }\n\n    /**\n     * @dev The signature derives the `address(0)`.\n     */\n    error ECDSAInvalidSignature();\n\n    /**\n     * @dev The signature has an invalid length.\n     */\n    error ECDSAInvalidSignatureLength(uint256 length);\n\n    /**\n     * @dev The signature has an S value that is in the upper half order.\n     */\n    error ECDSAInvalidSignatureS(bytes32 s);\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n     * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n     * and a bytes32 providing additional information about the error.\n     *\n     * If no error is returned, then the address can be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     */\n    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\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, bytes32(signature.length));\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n     */\n    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n        unchecked {\n            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n            // We do not check for an overflow here since the shift operation results in 0 or 1.\n            uint8 v = uint8((uint256(vs) >> 255) + 27);\n            return tryRecover(hash, v, r, s);\n        }\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     */\n    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function tryRecover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address, RecoverError, bytes32) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS, s);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature, bytes32(0));\n        }\n\n        return (signer, RecoverError.NoError, bytes32(0));\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n     */\n    function _throwError(RecoverError error, bytes32 errorArg) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert ECDSAInvalidSignature();\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert ECDSAInvalidSignatureLength(uint256(errorArg));\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert ECDSAInvalidSignatureS(errorArg);\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/interfaces/IERC1271.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1271.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n */\ninterface IERC1271 {\n    /**\n     * @dev Should return whether the signature provided is valid for the provided data\n     * @param hash      Hash of the data to be signed\n     * @param signature Signature byte array associated with _data\n     */\n    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/Strings.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n    uint8 private constant ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev The `value` string doesn't fit in the specified `length`.\n     */\n    error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n    /**\n     * @dev 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), HEX_DIGITS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toStringSigned(int256 value) internal pure returns (string memory) {\n        return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, Math.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        uint256 localValue = value;\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = HEX_DIGITS[localValue & 0xf];\n            localValue >>= 4;\n        }\n        if (localValue != 0) {\n            revert StringsInsufficientHexLength(value, length);\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n     * representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    /**\n     * @dev Muldiv operation overflow.\n     */\n    error MathOverflowedMulDiv();\n\n    enum Rounding {\n        Floor, // Toward negative infinity\n        Ceil, // Toward positive infinity\n        Trunc, // Toward zero\n        Expand // Away from zero\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, with an overflow flag.\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            uint256 c = a + b;\n            if (c < a) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b > a) return (false, 0);\n            return (true, a - b);\n        }\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n            // benefit is lost if 'b' is also tested.\n            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n            if (a == 0) return (true, 0);\n            uint256 c = a * b;\n            if (c / a != b) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a division by zero flag.\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a / b);\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a % b);\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return 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 towards infinity instead\n     * of rounding towards zero.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (b == 0) {\n            // Guarantee the same behavior as in a regular Solidity division.\n            return a / b;\n        }\n\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\n     * denominator == 0.\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n     * Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^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 = x * y; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            if (denominator <= prod1) {\n                revert MathOverflowedMulDiv();\n            }\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n            uint256 twos = denominator & (0 - denominator);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^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\n            // works 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 (unsignedRoundsUp(rounding) && 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\n     * towards zero.\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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        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 + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n     */\n    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n        return uint8(rounding) % 2 == 1;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\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"
      }
    },
    "settings": {
      "remappings": [
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
        "forge-std/=lib/forge-std/src/",
        "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
        "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
        "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
        "solidity-examples/=lib/solidity-examples/contracts/",
        "lib/forge-std:ds-test/=lib/forge-std/lib/ds-test/src/",
        "lib/openzeppelin-contracts-upgradeable:ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",
        "lib/openzeppelin-contracts-upgradeable:erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
        "lib/openzeppelin-contracts-upgradeable:forge-std/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/src/",
        "lib/openzeppelin-contracts-upgradeable:openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/",
        "erc4973o/=lib/erc4973o/src/",
        "openzeppelin/=lib/erc4973o/lib/openzeppelin-contracts/contracts/",
        "lib/openzeppelin-contracts:ds-test/=lib/erc4973o/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
        "lib/openzeppelin-contracts:erc4626-tests/=lib/erc4973o/lib/openzeppelin-contracts/lib/erc4626-tests/",
        "lib/openzeppelin-contracts:forge-std/=lib/erc4973o/lib/openzeppelin-contracts/lib/forge-std/src/",
        "lib/openzeppelin-contracts:openzeppelin/=lib/erc4973o/lib/openzeppelin-contracts/contracts/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs",
        "appendCBOR": true
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "paris",
      "viaIR": false,
      "libraries": {}
    }
  }}