creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts-upgradeable-v4/access/AccessControlUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlUpgradeable.sol\";\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../utils/StringsUpgradeable.sol\";\nimport \"../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../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, IAccessControlUpgradeable, ERC165Upgradeable {\n    function __AccessControl_init() internal onlyInitializing {\n    }\n\n    function __AccessControl_init_unchained() internal onlyInitializing {\n    }\n    struct RoleData {\n        mapping(address => bool) members;\n        bytes32 adminRole;\n    }\n\n    mapping(bytes32 => RoleData) private _roles;\n\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n    /**\n     * @dev Modifier that checks that an account has a specific role. Reverts\n     * with a standardized message including the required role.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     *\n     * _Available since v4.1._\n     */\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role);\n        _;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IAccessControlUpgradeable).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 override returns (bool) {\n        return _roles[role].members[account];\n    }\n\n    /**\n     * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n     * Overriding this function changes the behavior of the {onlyRole} modifier.\n     *\n     * Format of the revert message is described in {_checkRole}.\n     *\n     * _Available since v4.6._\n     */\n    function _checkRole(bytes32 role) internal view virtual {\n        _checkRole(role, _msgSender());\n    }\n\n    /**\n     * @dev Revert with a standard message if `account` is missing `role`.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     */\n    function _checkRole(bytes32 role, address account) internal view virtual {\n        if (!hasRole(role, account)) {\n            revert(\n                string(\n                    abi.encodePacked(\n                        \"AccessControl: account \",\n                        StringsUpgradeable.toHexString(account),\n                        \" is missing role \",\n                        StringsUpgradeable.toHexString(uint256(role), 32)\n                    )\n                )\n            );\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 override returns (bytes32) {\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 override 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 override 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 `account`.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function renounceRole(bytes32 role, address account) public virtual override {\n        require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event. Note that unlike {grantRole}, this function doesn't perform any\n     * checks on the calling account.\n     *\n     * May emit a {RoleGranted} event.\n     *\n     * [WARNING]\n     * ====\n     * This function should only be called from the constructor when setting\n     * up the initial roles for the system.\n     *\n     * Using this function in any other way is effectively circumventing the admin\n     * system imposed by {AccessControl}.\n     * ====\n     *\n     * NOTE: This function is deprecated in favor of {_grantRole}.\n     */\n    function _setupRole(bytes32 role, address account) internal virtual {\n        _grantRole(role, account);\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        bytes32 previousAdminRole = getRoleAdmin(role);\n        _roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function _grantRole(bytes32 role, address account) internal virtual {\n        if (!hasRole(role, account)) {\n            _roles[role].members[account] = true;\n            emit RoleGranted(role, account, _msgSender());\n        }\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function _revokeRole(bytes32 role, address account) internal virtual {\n        if (hasRole(role, account)) {\n            _roles[role].members[account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n        }\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/access/IAccessControlUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControlUpgradeable {\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     * _Available since v3.1._\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 `account`.\n     */\n    function renounceRole(bytes32 role, address account) external;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n     * constructor.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: setting the version to 255 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     *\n     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized != type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint8) {\n        return _initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _initializing;\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/security/ReentrancyGuardUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../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    uint256 private _status;\n\n    function __ReentrancyGuard_init() internal onlyInitializing {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal onlyInitializing {\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        // On the first call to nonReentrant, _status will be _NOT_ENTERED\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\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        return _status == _ENTERED;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/token/ERC20/extensions/IERC20PermitUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/token/ERC20/IERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/token/ERC20/utils/SafeERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n    using AddressUpgradeable for address;\n\n    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n     * Revert on invalid signature.\n     */\n    function safePermit(\n        IERC20PermitUpgradeable token,\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal {\n        uint256 nonceBefore = token.nonces(owner);\n        token.permit(owner, spender, value, deadline, v, r, s);\n        uint256 nonceAfter = token.nonces(owner);\n        require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return\n            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token));\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/utils/AddressUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../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    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/utils/introspection/ERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../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 *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\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 override returns (bool) {\n        return interfaceId == type(IERC165Upgradeable).interfaceId;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/utils/introspection/IERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\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 IERC165Upgradeable {\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"
      },
      "@openzeppelin/contracts-upgradeable-v4/utils/math/MathUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod0 := mul(x, y)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1, \"Math: mulDiv overflow\");\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/utils/math/SafeCastUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\n    /**\n     * @dev Returns the downcasted uint248 from uint256, reverting on\n     * overflow (when the input is greater than largest uint248).\n     *\n     * Counterpart to Solidity's `uint248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint248(uint256 value) internal pure returns (uint248) {\n        require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n        return uint248(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint240 from uint256, reverting on\n     * overflow (when the input is greater than largest uint240).\n     *\n     * Counterpart to Solidity's `uint240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint240(uint256 value) internal pure returns (uint240) {\n        require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n        return uint240(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint232 from uint256, reverting on\n     * overflow (when the input is greater than largest uint232).\n     *\n     * Counterpart to Solidity's `uint232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint232(uint256 value) internal pure returns (uint232) {\n        require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n        return uint232(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint224 from uint256, reverting on\n     * overflow (when the input is greater than largest uint224).\n     *\n     * Counterpart to Solidity's `uint224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     *\n     * _Available since v4.2._\n     */\n    function toUint224(uint256 value) internal pure returns (uint224) {\n        require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n        return uint224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint216 from uint256, reverting on\n     * overflow (when the input is greater than largest uint216).\n     *\n     * Counterpart to Solidity's `uint216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint216(uint256 value) internal pure returns (uint216) {\n        require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n        return uint216(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint208 from uint256, reverting on\n     * overflow (when the input is greater than largest uint208).\n     *\n     * Counterpart to Solidity's `uint208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint208(uint256 value) internal pure returns (uint208) {\n        require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n        return uint208(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint200 from uint256, reverting on\n     * overflow (when the input is greater than largest uint200).\n     *\n     * Counterpart to Solidity's `uint200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint200(uint256 value) internal pure returns (uint200) {\n        require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n        return uint200(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint192 from uint256, reverting on\n     * overflow (when the input is greater than largest uint192).\n     *\n     * Counterpart to Solidity's `uint192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint192(uint256 value) internal pure returns (uint192) {\n        require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n        return uint192(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint184 from uint256, reverting on\n     * overflow (when the input is greater than largest uint184).\n     *\n     * Counterpart to Solidity's `uint184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint184(uint256 value) internal pure returns (uint184) {\n        require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n        return uint184(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint176 from uint256, reverting on\n     * overflow (when the input is greater than largest uint176).\n     *\n     * Counterpart to Solidity's `uint176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint176(uint256 value) internal pure returns (uint176) {\n        require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n        return uint176(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint168 from uint256, reverting on\n     * overflow (when the input is greater than largest uint168).\n     *\n     * Counterpart to Solidity's `uint168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint168(uint256 value) internal pure returns (uint168) {\n        require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n        return uint168(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint160 from uint256, reverting on\n     * overflow (when the input is greater than largest uint160).\n     *\n     * Counterpart to Solidity's `uint160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint160(uint256 value) internal pure returns (uint160) {\n        require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n        return uint160(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint152 from uint256, reverting on\n     * overflow (when the input is greater than largest uint152).\n     *\n     * Counterpart to Solidity's `uint152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint152(uint256 value) internal pure returns (uint152) {\n        require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n        return uint152(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint144 from uint256, reverting on\n     * overflow (when the input is greater than largest uint144).\n     *\n     * Counterpart to Solidity's `uint144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint144(uint256 value) internal pure returns (uint144) {\n        require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n        return uint144(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint136 from uint256, reverting on\n     * overflow (when the input is greater than largest uint136).\n     *\n     * Counterpart to Solidity's `uint136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint136(uint256 value) internal pure returns (uint136) {\n        require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n        return uint136(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n        return uint128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint120 from uint256, reverting on\n     * overflow (when the input is greater than largest uint120).\n     *\n     * Counterpart to Solidity's `uint120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint120(uint256 value) internal pure returns (uint120) {\n        require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n        return uint120(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint112 from uint256, reverting on\n     * overflow (when the input is greater than largest uint112).\n     *\n     * Counterpart to Solidity's `uint112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint112(uint256 value) internal pure returns (uint112) {\n        require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n        return uint112(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint104 from uint256, reverting on\n     * overflow (when the input is greater than largest uint104).\n     *\n     * Counterpart to Solidity's `uint104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint104(uint256 value) internal pure returns (uint104) {\n        require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n        return uint104(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint96 from uint256, reverting on\n     * overflow (when the input is greater than largest uint96).\n     *\n     * Counterpart to Solidity's `uint96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     *\n     * _Available since v4.2._\n     */\n    function toUint96(uint256 value) internal pure returns (uint96) {\n        require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n        return uint96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint88 from uint256, reverting on\n     * overflow (when the input is greater than largest uint88).\n     *\n     * Counterpart to Solidity's `uint88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint88(uint256 value) internal pure returns (uint88) {\n        require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n        return uint88(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint80 from uint256, reverting on\n     * overflow (when the input is greater than largest uint80).\n     *\n     * Counterpart to Solidity's `uint80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint80(uint256 value) internal pure returns (uint80) {\n        require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n        return uint80(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint72 from uint256, reverting on\n     * overflow (when the input is greater than largest uint72).\n     *\n     * Counterpart to Solidity's `uint72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint72(uint256 value) internal pure returns (uint72) {\n        require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n        return uint72(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint64 from uint256, reverting on\n     * overflow (when the input is greater than largest uint64).\n     *\n     * Counterpart to Solidity's `uint64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint64(uint256 value) internal pure returns (uint64) {\n        require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n        return uint64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint56 from uint256, reverting on\n     * overflow (when the input is greater than largest uint56).\n     *\n     * Counterpart to Solidity's `uint56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint56(uint256 value) internal pure returns (uint56) {\n        require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n        return uint56(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint48 from uint256, reverting on\n     * overflow (when the input is greater than largest uint48).\n     *\n     * Counterpart to Solidity's `uint48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint48(uint256 value) internal pure returns (uint48) {\n        require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n        return uint48(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint40 from uint256, reverting on\n     * overflow (when the input is greater than largest uint40).\n     *\n     * Counterpart to Solidity's `uint40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint40(uint256 value) internal pure returns (uint40) {\n        require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n        return uint40(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint32 from uint256, reverting on\n     * overflow (when the input is greater than largest uint32).\n     *\n     * Counterpart to Solidity's `uint32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint32(uint256 value) internal pure returns (uint32) {\n        require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n        return uint32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint24 from uint256, reverting on\n     * overflow (when the input is greater than largest uint24).\n     *\n     * Counterpart to Solidity's `uint24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint24(uint256 value) internal pure returns (uint24) {\n        require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n        return uint24(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint16 from uint256, reverting on\n     * overflow (when the input is greater than largest uint16).\n     *\n     * Counterpart to Solidity's `uint16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint16(uint256 value) internal pure returns (uint16) {\n        require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n        return uint16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint8 from uint256, reverting on\n     * overflow (when the input is greater than largest uint8).\n     *\n     * Counterpart to Solidity's `uint8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint8(uint256 value) internal pure returns (uint8) {\n        require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n        return uint8(value);\n    }\n\n    /**\n     * @dev Converts a signed int256 into an unsigned uint256.\n     *\n     * Requirements:\n     *\n     * - input must be greater than or equal to 0.\n     *\n     * _Available since v3.0._\n     */\n    function toUint256(int256 value) internal pure returns (uint256) {\n        require(value >= 0, \"SafeCast: value must be positive\");\n        return uint256(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int248 from int256, reverting on\n     * overflow (when the input is less than smallest int248 or\n     * greater than largest int248).\n     *\n     * Counterpart to Solidity's `int248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt248(int256 value) internal pure returns (int248 downcasted) {\n        downcasted = int248(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int240 from int256, reverting on\n     * overflow (when the input is less than smallest int240 or\n     * greater than largest int240).\n     *\n     * Counterpart to Solidity's `int240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt240(int256 value) internal pure returns (int240 downcasted) {\n        downcasted = int240(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int232 from int256, reverting on\n     * overflow (when the input is less than smallest int232 or\n     * greater than largest int232).\n     *\n     * Counterpart to Solidity's `int232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt232(int256 value) internal pure returns (int232 downcasted) {\n        downcasted = int232(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int224 from int256, reverting on\n     * overflow (when the input is less than smallest int224 or\n     * greater than largest int224).\n     *\n     * Counterpart to Solidity's `int224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt224(int256 value) internal pure returns (int224 downcasted) {\n        downcasted = int224(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int216 from int256, reverting on\n     * overflow (when the input is less than smallest int216 or\n     * greater than largest int216).\n     *\n     * Counterpart to Solidity's `int216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt216(int256 value) internal pure returns (int216 downcasted) {\n        downcasted = int216(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int208 from int256, reverting on\n     * overflow (when the input is less than smallest int208 or\n     * greater than largest int208).\n     *\n     * Counterpart to Solidity's `int208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt208(int256 value) internal pure returns (int208 downcasted) {\n        downcasted = int208(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int200 from int256, reverting on\n     * overflow (when the input is less than smallest int200 or\n     * greater than largest int200).\n     *\n     * Counterpart to Solidity's `int200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt200(int256 value) internal pure returns (int200 downcasted) {\n        downcasted = int200(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int192 from int256, reverting on\n     * overflow (when the input is less than smallest int192 or\n     * greater than largest int192).\n     *\n     * Counterpart to Solidity's `int192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt192(int256 value) internal pure returns (int192 downcasted) {\n        downcasted = int192(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int184 from int256, reverting on\n     * overflow (when the input is less than smallest int184 or\n     * greater than largest int184).\n     *\n     * Counterpart to Solidity's `int184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt184(int256 value) internal pure returns (int184 downcasted) {\n        downcasted = int184(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int176 from int256, reverting on\n     * overflow (when the input is less than smallest int176 or\n     * greater than largest int176).\n     *\n     * Counterpart to Solidity's `int176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt176(int256 value) internal pure returns (int176 downcasted) {\n        downcasted = int176(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int168 from int256, reverting on\n     * overflow (when the input is less than smallest int168 or\n     * greater than largest int168).\n     *\n     * Counterpart to Solidity's `int168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt168(int256 value) internal pure returns (int168 downcasted) {\n        downcasted = int168(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int160 from int256, reverting on\n     * overflow (when the input is less than smallest int160 or\n     * greater than largest int160).\n     *\n     * Counterpart to Solidity's `int160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt160(int256 value) internal pure returns (int160 downcasted) {\n        downcasted = int160(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int152 from int256, reverting on\n     * overflow (when the input is less than smallest int152 or\n     * greater than largest int152).\n     *\n     * Counterpart to Solidity's `int152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt152(int256 value) internal pure returns (int152 downcasted) {\n        downcasted = int152(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int144 from int256, reverting on\n     * overflow (when the input is less than smallest int144 or\n     * greater than largest int144).\n     *\n     * Counterpart to Solidity's `int144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt144(int256 value) internal pure returns (int144 downcasted) {\n        downcasted = int144(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int136 from int256, reverting on\n     * overflow (when the input is less than smallest int136 or\n     * greater than largest int136).\n     *\n     * Counterpart to Solidity's `int136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt136(int256 value) internal pure returns (int136 downcasted) {\n        downcasted = int136(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int128 from int256, reverting on\n     * overflow (when the input is less than smallest int128 or\n     * greater than largest int128).\n     *\n     * Counterpart to Solidity's `int128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt128(int256 value) internal pure returns (int128 downcasted) {\n        downcasted = int128(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int120 from int256, reverting on\n     * overflow (when the input is less than smallest int120 or\n     * greater than largest int120).\n     *\n     * Counterpart to Solidity's `int120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt120(int256 value) internal pure returns (int120 downcasted) {\n        downcasted = int120(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int112 from int256, reverting on\n     * overflow (when the input is less than smallest int112 or\n     * greater than largest int112).\n     *\n     * Counterpart to Solidity's `int112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt112(int256 value) internal pure returns (int112 downcasted) {\n        downcasted = int112(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int104 from int256, reverting on\n     * overflow (when the input is less than smallest int104 or\n     * greater than largest int104).\n     *\n     * Counterpart to Solidity's `int104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt104(int256 value) internal pure returns (int104 downcasted) {\n        downcasted = int104(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int96 from int256, reverting on\n     * overflow (when the input is less than smallest int96 or\n     * greater than largest int96).\n     *\n     * Counterpart to Solidity's `int96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt96(int256 value) internal pure returns (int96 downcasted) {\n        downcasted = int96(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int88 from int256, reverting on\n     * overflow (when the input is less than smallest int88 or\n     * greater than largest int88).\n     *\n     * Counterpart to Solidity's `int88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt88(int256 value) internal pure returns (int88 downcasted) {\n        downcasted = int88(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int80 from int256, reverting on\n     * overflow (when the input is less than smallest int80 or\n     * greater than largest int80).\n     *\n     * Counterpart to Solidity's `int80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt80(int256 value) internal pure returns (int80 downcasted) {\n        downcasted = int80(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int72 from int256, reverting on\n     * overflow (when the input is less than smallest int72 or\n     * greater than largest int72).\n     *\n     * Counterpart to Solidity's `int72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt72(int256 value) internal pure returns (int72 downcasted) {\n        downcasted = int72(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int64 from int256, reverting on\n     * overflow (when the input is less than smallest int64 or\n     * greater than largest int64).\n     *\n     * Counterpart to Solidity's `int64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt64(int256 value) internal pure returns (int64 downcasted) {\n        downcasted = int64(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int56 from int256, reverting on\n     * overflow (when the input is less than smallest int56 or\n     * greater than largest int56).\n     *\n     * Counterpart to Solidity's `int56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt56(int256 value) internal pure returns (int56 downcasted) {\n        downcasted = int56(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int48 from int256, reverting on\n     * overflow (when the input is less than smallest int48 or\n     * greater than largest int48).\n     *\n     * Counterpart to Solidity's `int48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt48(int256 value) internal pure returns (int48 downcasted) {\n        downcasted = int48(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int40 from int256, reverting on\n     * overflow (when the input is less than smallest int40 or\n     * greater than largest int40).\n     *\n     * Counterpart to Solidity's `int40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt40(int256 value) internal pure returns (int40 downcasted) {\n        downcasted = int40(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int32 from int256, reverting on\n     * overflow (when the input is less than smallest int32 or\n     * greater than largest int32).\n     *\n     * Counterpart to Solidity's `int32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt32(int256 value) internal pure returns (int32 downcasted) {\n        downcasted = int32(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int24 from int256, reverting on\n     * overflow (when the input is less than smallest int24 or\n     * greater than largest int24).\n     *\n     * Counterpart to Solidity's `int24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt24(int256 value) internal pure returns (int24 downcasted) {\n        downcasted = int24(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int16 from int256, reverting on\n     * overflow (when the input is less than smallest int16 or\n     * greater than largest int16).\n     *\n     * Counterpart to Solidity's `int16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt16(int256 value) internal pure returns (int16 downcasted) {\n        downcasted = int16(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int8 from int256, reverting on\n     * overflow (when the input is less than smallest int8 or\n     * greater than largest int8).\n     *\n     * Counterpart to Solidity's `int8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt8(int256 value) internal pure returns (int8 downcasted) {\n        downcasted = int8(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n    }\n\n    /**\n     * @dev Converts an unsigned uint256 into a signed int256.\n     *\n     * Requirements:\n     *\n     * - input must be less than or equal to maxInt256.\n     *\n     * _Available since v3.0._\n     */\n    function toInt256(uint256 value) internal pure returns (int256) {\n        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n        require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n        return int256(value);\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/utils/math/SignedMathUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMathUpgradeable {\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // must be unchecked in order to support `n = type(int256).min`\n            return uint256(n >= 0 ? n : -n);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/utils/StringsUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\nimport \"./math/SignedMathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n    bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = MathUpgradeable.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            /// @solidity memory-safe-assembly\n            assembly {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                /// @solidity memory-safe-assembly\n                assembly {\n                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toString(int256 value) internal pure returns (string memory) {\n        return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMathUpgradeable.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, MathUpgradeable.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable-v4/utils/structs/EnumerableSetUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n *     // Add the library methods\n *     using EnumerableSet for EnumerableSet.AddressSet;\n *\n *     // Declare a set state variable\n *     EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSetUpgradeable {\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Set type with\n    // bytes32 values.\n    // The Set implementation uses private functions, and user-facing\n    // implementations (such as AddressSet) are just wrappers around the\n    // underlying Set.\n    // This means that we can only create new EnumerableSets for types that fit\n    // in bytes32.\n\n    struct Set {\n        // Storage of set values\n        bytes32[] _values;\n        // Position of the value in the `values` array, plus 1 because index 0\n        // means a value is not in the set.\n        mapping(bytes32 => uint256) _indexes;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            // The value is stored at length-1, but we add 1 to all indexes\n            // and use 0 as a sentinel value\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        // We read and store the value's index to prevent multiple reads from the same storage slot\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) {\n            // Equivalent to contains(set, value)\n            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n            // the array, and then remove the last element (sometimes called as 'swap and pop').\n            // This modifies the order of the array, as noted in {at}.\n\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            if (lastIndex != toDeleteIndex) {\n                bytes32 lastValue = set._values[lastIndex];\n\n                // Move the last value to the index where the value to delete is\n                set._values[toDeleteIndex] = lastValue;\n                // Update the index for the moved value\n                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n            }\n\n            // Delete the slot where the moved value was stored\n            set._values.pop();\n\n            // Delete the index for the deleted slot\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        return set._values[index];\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function _values(Set storage set) private view returns (bytes32[] memory) {\n        return set._values;\n    }\n\n    // Bytes32Set\n\n    struct Bytes32Set {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _add(set._inner, value);\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(Bytes32Set storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n        return _at(set._inner, index);\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        bytes32[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(AddressSet storage set) internal view returns (address[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        address[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // UintSet\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(UintSet storage set, uint256 value) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(UintSet storage set) internal view returns (uint256[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"
      },
      "contracts/common/codec/WordCodec.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n// solhint-disable no-inline-assembly\n\n/// @dev A subset copied from the following contracts:\n///\n/// + `balancer-labs/v2-solidity-utils/contracts/helpers/WordCodec.sol`\n/// + `balancer-labs/v2-solidity-utils/contracts/helpers/WordCodecHelpers.sol`\nlibrary WordCodec {\n  /// @dev Inserts an unsigned integer of bitLength, shifted by an offset, into a 256 bit word,\n  /// replacing the old value. Returns the new word.\n  function insertUint(\n    bytes32 word,\n    uint256 value,\n    uint256 offset,\n    uint256 bitLength\n  ) internal pure returns (bytes32 result) {\n    // Equivalent to:\n    // uint256 mask = (1 << bitLength) - 1;\n    // bytes32 clearedWord = bytes32(uint256(word) & ~(mask << offset));\n    // result = clearedWord | bytes32(value << offset);\n    assembly {\n      let mask := sub(shl(bitLength, 1), 1)\n      let clearedWord := and(word, not(shl(offset, mask)))\n      result := or(clearedWord, shl(offset, value))\n    }\n  }\n\n  /// @dev Decodes and returns an unsigned integer with `bitLength` bits, shifted by an offset, from a 256 bit word.\n  function decodeUint(\n    bytes32 word,\n    uint256 offset,\n    uint256 bitLength\n  ) internal pure returns (uint256 result) {\n    // Equivalent to:\n    // result = uint256(word >> offset) & ((1 << bitLength) - 1);\n    assembly {\n      result := and(shr(offset, word), sub(shl(bitLength, 1), 1))\n    }\n  }\n\n  /// @dev Inserts a signed integer shifted by an offset into a 256 bit word, replacing the old value. Returns\n  /// the new word.\n  ///\n  /// Assumes `value` can be represented using `bitLength` bits.\n  function insertInt(\n    bytes32 word,\n    int256 value,\n    uint256 offset,\n    uint256 bitLength\n  ) internal pure returns (bytes32) {\n    unchecked {\n      uint256 mask = (1 << bitLength) - 1;\n      bytes32 clearedWord = bytes32(uint256(word) & ~(mask << offset));\n      // Integer values need masking to remove the upper bits of negative values.\n      return clearedWord | bytes32((uint256(value) & mask) << offset);\n    }\n  }\n\n  /// @dev Decodes and returns a signed integer with `bitLength` bits, shifted by an offset, from a 256 bit word.\n  function decodeInt(\n    bytes32 word,\n    uint256 offset,\n    uint256 bitLength\n  ) internal pure returns (int256 result) {\n    unchecked {\n      int256 maxInt = int256((1 << (bitLength - 1)) - 1);\n      uint256 mask = (1 << bitLength) - 1;\n\n      int256 value = int256(uint256(word >> offset) & mask);\n      // In case the decoded value is greater than the max positive integer that can be represented with bitLength\n      // bits, we know it was originally a negative integer. Therefore, we mask it to restore the sign in the 256 bit\n      // representation.\n      //\n      // Equivalent to:\n      // result = value > maxInt ? (value | int256(~mask)) : value;\n      assembly {\n        result := or(mul(gt(value, maxInt), not(mask)), value)\n      }\n    }\n  }\n\n  /// @dev Decodes and returns a boolean shifted by an offset from a 256 bit word.\n  function decodeBool(bytes32 word, uint256 offset) internal pure returns (bool result) {\n    // Equivalent to:\n    // result = (uint256(word >> offset) & 1) == 1;\n    assembly {\n      result := and(shr(offset, word), 1)\n    }\n  }\n\n  /// @dev Inserts a boolean value shifted by an offset into a 256 bit word, replacing the old value. Returns the new\n  /// word.\n  function insertBool(\n    bytes32 word,\n    bool value,\n    uint256 offset\n  ) internal pure returns (bytes32 result) {\n    // Equivalent to:\n    // bytes32 clearedWord = bytes32(uint256(word) & ~(1 << offset));\n    // bytes32 referenceInsertBool = clearedWord | bytes32(uint256(value ? 1 : 0) << offset);\n    assembly {\n      let clearedWord := and(word, not(shl(offset, 1)))\n      result := or(clearedWord, shl(offset, value))\n    }\n  }\n\n  function clearWordAtPosition(\n    bytes32 word,\n    uint256 offset,\n    uint256 bitLength\n  ) internal pure returns (bytes32 clearedWord) {\n    unchecked {\n      uint256 mask = (1 << bitLength) - 1;\n      clearedWord = bytes32(uint256(word) & ~(mask << offset));\n    }\n  }\n}\n"
      },
      "contracts/common/rewards/accumulator/IMultipleRewardAccumulator.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface IMultipleRewardAccumulator {\n  /**********\n   * Events *\n   **********/\n\n  /// @notice Emitted when user claim pending rewards.\n  /// @param account The address of user.\n  /// @param token The address of token claimed.\n  /// @param receiver The address of token receiver.\n  /// @param amount The amount of token claimed.\n  event Claim(address indexed account, address indexed token, address indexed receiver, uint256 amount);\n\n  /// @notice Emitted when the reward receiver is updated.\n  /// @param account The address of the account.\n  /// @param oldReceiver The address of the previous reward receiver.\n  /// @param newReceiver The address of the current reward receiver.\n  event UpdateRewardReceiver(address indexed account, address indexed oldReceiver, address indexed newReceiver);\n\n  /**********\n   * Errors *\n   **********/\n\n  /// @dev Thrown when caller claim others reward to another user.\n  error ClaimOthersRewardToAnother();\n\n  /*************************\n   * Public View Functions *\n   *************************/\n\n  /// @notice The address of default reward receiver for given user.\n  /// @param account The address of user to query.\n  function rewardReceiver(address account) external view returns (address);\n\n  /// @notice Get the amount of pending rewards.\n  /// @param account The address of user to query.\n  /// @param token The address of reward token to query.\n  /// @return amount The amount of pending rewards.\n  function claimable(address account, address token) external view returns (uint256 amount);\n\n  /// @notice Get the total amount of rewards claimed from this contract.\n  /// @param account The address of user to query.\n  /// @param token The address of reward token to query.\n  /// @return amount The amount of claimed rewards.\n  function claimed(address account, address token) external view returns (uint256 amount);\n\n  /****************************\n   * Public Mutated Functions *\n   ****************************/\n\n  /// @notice Set the default reward receiver for the caller.\n  /// @dev When set to address(0), rewards are sent to the caller.\n  /// @param _newReceiver The new receiver address for any rewards claimed via `claim`.\n  function setRewardReceiver(address _newReceiver) external;\n\n  /// @notice Update the global and user snapshot.\n  /// @param account The address of user to update.\n  function checkpoint(address account) external;\n\n  /// @notice Claim pending rewards of all active tokens for the caller.\n  function claim() external;\n\n  /// @notice Claim pending rewards of all active tokens for some user.\n  /// @param account The address of the user.\n  function claim(address account) external;\n\n  /// @notice Claim pending rewards of all active tokens for the user and transfer to others.\n  /// @param account The address of the user.\n  /// @param receiver The address of the recipient.\n  function claim(address account, address receiver) external;\n\n  /// @notice Claim pending rewards of historical reward tokens for the caller.\n  /// @param tokens The address list of historical reward tokens to claim.\n  function claimHistorical(address[] memory tokens) external;\n\n  /// @notice Claim pending rewards of historical reward tokens for some user.\n  /// @param account The address of the user.\n  /// @param tokens The address list of historical reward tokens to claim.\n  function claimHistorical(address account, address[] memory tokens) external;\n}\n"
      },
      "contracts/common/rewards/accumulator/MultipleRewardAccumulator.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable-v4/token/ERC20/IERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable-v4/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { ReentrancyGuardUpgradeable } from \"@openzeppelin/contracts-upgradeable-v4/security/ReentrancyGuardUpgradeable.sol\";\n\nimport { IMultipleRewardAccumulator } from \"./IMultipleRewardAccumulator.sol\";\n\nimport { LinearMultipleRewardDistributor } from \"../distributor/LinearMultipleRewardDistributor.sol\";\n\n// solhint-disable not-rely-on-time\n\n/// @title MultipleRewardAccumulator\n/// @notice `MultipleRewardAccumulator` is a reward accumulator for reward distribution in a staking pool.\n/// In the staking pool, the staker’s share won't change, unless the staker manually stakes or unstakes.\n/// The contract will distribute rewards in proportion to a staker’s share of total stakes with only\n/// O(1) complexity.\n///\n/// Assume that there are n events e[1], e[2], ..., and e[n]. The types of events are user stake,\n/// user unstake and reward distribution.\n/// Right after event e[i], let the total pool stakes be s[i], the user pool stakes be u[i],\n/// and the rewards distributed be r[i].\n///\n/// The basic assumptions are, if\n///   + e[i] is user stake, r[i] = 0, u[i] > u[i-1] and s[i] - s[i-1] = u[i] - u[i-1].\n///   + e[i] is user unstake, r[i] = 0, u[i] < u[i-1] and s[i] - s[i-1] = u[i] - u[i-1].\n///   + e[i] is reward distribution, r[i] > 0, u[i] = u[i-1] and s[i] = s[i-1].\n///\n/// So under the assumptions, we can maintain s[i] and u[i] easily.\n///\n/// Then, the total amount of rewards for the user after n events is:\n///                 u[0]          u[1]                u[n-1]\n///   g[n] = r[1] * ---- + r[2] * ---- + ... + r[n] * ------\n///                 s[0]          s[1]                s[n-1]\n///\n/// And, the rewards from event x to event y (both inclusive) for the user is:\n///                    u[x-1]            u[x]                u[y-1]\n///   g[x->y] = r[x] * ------ + r[x+1] * ---- + ... + r[y] * ------\n///                    s[x-1]            s[x]                s[y-1]\n///\n/// To check the accumulated total user rewards, we can maintain the value of\n///         r[1]   r[2]          r[n]\n///   acc = ---- + ---- + ... + ------\n///         s[0]   s[1]         s[n-1]\n///\n/// For each event, if\n///   + e[i] is user stake or unstake, new accumulated rewards is `gain += u[i-1] * (cur_acc - last_user_recorded_acc)`\n//      and update `last_user_recorded_acc` to `cur_acc`.\n///   + e[i] is reward distribution, update `cur_acc` to `cur_acc + r[i] / s[i-1]`.\nabstract contract MultipleRewardAccumulator is\n  ReentrancyGuardUpgradeable,\n  LinearMultipleRewardDistributor,\n  IMultipleRewardAccumulator\n{\n  using SafeERC20Upgradeable for IERC20Upgradeable;\n\n  /*************\n   * Constants *\n   *************/\n\n  /// @dev The precision used to calculate accumulated rewards.\n  uint256 internal constant REWARD_PRECISION = 1e18;\n\n  /***********\n   * Structs *\n   ***********/\n\n  /// @dev Compiler will pack this into single `uint256`.\n  struct RewardSnapshot {\n    // The timestamp when the snapshot is updated.\n    uint64 timestamp;\n    // The reward integral until now.\n    uint192 integral;\n  }\n\n  /// @dev Compiler will pack this into single `uint256`.\n  struct ClaimData {\n    // The number of pending rewards.\n    uint128 pending;\n    // The number of claimed rewards.\n    uint128 claimed;\n  }\n\n  /// @dev Compiler will pack this into two `uint256`.\n  struct UserRewardSnapshot {\n    // The claim data for the user.\n    ClaimData rewards;\n    // The reward snapshot for user.\n    RewardSnapshot checkpoint;\n  }\n\n  /*************\n   * Variables *\n   *************/\n\n  /// @inheritdoc IMultipleRewardAccumulator\n  mapping(address => address) public override rewardReceiver;\n\n  /// @notice Mapping from reward token address to global reward snapshot.\n  ///\n  /// @dev The integral is defined as 1e18 * ∫(rate(t) / totalPoolShare(t) dt).\n  mapping(address => RewardSnapshot) public rewardSnapshot;\n\n  /// @notice Mapping from user address to reward token address to user reward snapshot.\n  ///\n  /// @dev The integral is the value of `rewardSnapshot[token].integral` when the snapshot is taken.\n  mapping(address => mapping(address => UserRewardSnapshot)) public userRewardSnapshot;\n\n  /// @dev reserved slots.\n  uint256[47] private __gap;\n\n  /***************\n   * Constructor *\n   ***************/\n\n  // solhint-disable-next-line func-name-mixedcase\n  function __MultipleRewardAccumulator_init() internal onlyInitializing {\n    __LinearMultipleRewardDistributor_init();\n  }\n\n  /*************************\n   * Public View Functions *\n   *************************/\n\n  /// @inheritdoc IMultipleRewardAccumulator\n  function claimable(address _account, address _token) public view override returns (uint256) {\n    UserRewardSnapshot memory _userSnapshot = userRewardSnapshot[_account][_token];\n    uint256 _shares = _getUserPoolShare(_account);\n    return\n      uint256(_userSnapshot.rewards.pending) +\n      ((rewardSnapshot[_token].integral - _userSnapshot.checkpoint.integral) * _shares) /\n      REWARD_PRECISION;\n  }\n\n  /// @inheritdoc IMultipleRewardAccumulator\n  function claimed(address _account, address _token) external view returns (uint256) {\n    return userRewardSnapshot[_account][_token].rewards.claimed;\n  }\n\n  /****************************\n   * Public Mutated Functions *\n   ****************************/\n\n  /// @inheritdoc IMultipleRewardAccumulator\n  function setRewardReceiver(address _newReceiver) external {\n    address _caller = _msgSender();\n    address _oldReceiver = rewardReceiver[_caller];\n    rewardReceiver[_caller] = _newReceiver;\n\n    emit UpdateRewardReceiver(_caller, _oldReceiver, _newReceiver);\n  }\n\n  /// @inheritdoc IMultipleRewardAccumulator\n  function checkpoint(address _account) external virtual override nonReentrant {\n    _checkpoint(_account);\n  }\n\n  /// @inheritdoc IMultipleRewardAccumulator\n  function claim() external override {\n    address _sender = _msgSender();\n    claim(_sender, address(0));\n  }\n\n  /// @inheritdoc IMultipleRewardAccumulator\n  function claim(address _account) external override {\n    claim(_account, address(0));\n  }\n\n  /// @inheritdoc IMultipleRewardAccumulator\n  function claim(address _account, address _receiver) public override nonReentrant {\n    if (_account != _msgSender() && _receiver != address(0)) {\n      revert ClaimOthersRewardToAnother();\n    }\n\n    _checkpoint(_account);\n    _claim(_account, _receiver);\n  }\n\n  /// @inheritdoc IMultipleRewardAccumulator\n  function claimHistorical(address[] memory _tokens) external nonReentrant {\n    address _sender = _msgSender();\n    _checkpoint(_sender);\n\n    address _receiver = rewardReceiver[_sender];\n    if (_receiver == address(0)) _receiver = _sender;\n\n    for (uint256 i = 0; i < _tokens.length; i++) {\n      _claimSingle(_sender, _tokens[i], _receiver);\n    }\n  }\n\n  /// @inheritdoc IMultipleRewardAccumulator\n  function claimHistorical(address _account, address[] memory _tokens) external nonReentrant {\n    _checkpoint(_account);\n\n    address _receiver = rewardReceiver[_account];\n    if (_receiver == address(0)) _receiver = _account;\n\n    for (uint256 i = 0; i < _tokens.length; i++) {\n      _claimSingle(_account, _tokens[i], _receiver);\n    }\n  }\n\n  /**********************\n   * Internal Functions *\n   **********************/\n\n  /// @dev Internal function to update the global and user snapshot.\n  ///\n  /// @param _account The address of user to update. Use zero address\n  ///        if you only want to update global snapshot.\n  function _checkpoint(address _account) internal virtual {\n    _distributePendingReward();\n\n    if (_account != address(0)) {\n      // checkpoint active reward tokens\n      address[] memory _rewardTokens = getActiveRewardTokens();\n      for (uint256 i = 0; i < _rewardTokens.length; i++) {\n        _updateSnapshot(_account, _rewardTokens[i]);\n      }\n\n      // checkpoint historical reward tokens\n      _rewardTokens = getHistoricalRewardTokens();\n      for (uint256 i = 0; i < _rewardTokens.length; i++) {\n        _updateSnapshot(_account, _rewardTokens[i]);\n      }\n    }\n  }\n\n  /// @notice Internal function to update snapshot for single token.\n  /// @param _account The address of user to update.\n  /// @param _token The address of token to update.\n  function _updateSnapshot(address _account, address _token) internal {\n    UserRewardSnapshot memory _snapshot = userRewardSnapshot[_account][_token];\n    _snapshot.rewards.pending = uint128(claimable(_account, _token));\n    _snapshot.checkpoint = rewardSnapshot[_token];\n    _snapshot.checkpoint.timestamp = uint64(block.timestamp);\n    userRewardSnapshot[_account][_token] = _snapshot;\n  }\n\n  /// @dev Internal function to claim active reward tokens.\n  ///\n  /// @param _account The address of user to claim.\n  /// @param _receiver The address of recipient of the reward token.\n  function _claim(address _account, address _receiver) internal virtual {\n    address _receiverStored = rewardReceiver[_account];\n    if (_receiverStored != address(0) && _receiver == address(0)) {\n      _receiver = _receiverStored;\n    }\n    if (_receiver == address(0)) _receiver = _account;\n\n    address[] memory _activeRewardTokens = getActiveRewardTokens();\n    for (uint256 i = 0; i < _activeRewardTokens.length; i++) {\n      _claimSingle(_account, _activeRewardTokens[i], _receiver);\n    }\n  }\n\n  /// @dev Internal function to claim single reward token.\n  /// Caller should make sure `_checkpoint` is called before this function.\n  ///\n  /// @param _account The address of user to claim.\n  /// @param _token The address of reward token.\n  /// @param _receiver The address of recipient of the reward token.\n  function _claimSingle(\n    address _account,\n    address _token,\n    address _receiver\n  ) internal virtual returns (uint256) {\n    ClaimData memory _rewards = userRewardSnapshot[_account][_token].rewards;\n    uint256 _amount = _rewards.pending;\n    if (_amount > 0) {\n      _rewards.claimed += _rewards.pending;\n      _rewards.pending = 0;\n      userRewardSnapshot[_account][_token].rewards = _rewards;\n\n      IERC20Upgradeable(_token).safeTransfer(_receiver, _amount);\n\n      emit Claim(_account, _token, _receiver, _amount);\n    }\n    return _amount;\n  }\n\n  /// @inheritdoc LinearMultipleRewardDistributor\n  function _accumulateReward(address _token, uint256 _amount) internal virtual override {\n    if (_amount == 0) return;\n\n    uint256 totalShare = _getTotalPoolShare();\n    if (totalShare == 0) {\n      // no deposits, queue rewards\n      rewardData[_token].queued += uint96(_amount);\n      return;\n    }\n\n    RewardSnapshot memory _snapshot = rewardSnapshot[_token];\n    _snapshot.timestamp = uint64(block.timestamp);\n    _snapshot.integral = uint192(uint256(_snapshot.integral) + (_amount * REWARD_PRECISION) / _getTotalPoolShare());\n    rewardSnapshot[_token] = _snapshot;\n  }\n\n  /// @dev Internal function to get the total pool shares.\n  function _getTotalPoolShare() internal view virtual returns (uint256);\n\n  /// @dev Internal function to get the amount of user shares.\n  ///\n  /// @param _account The address of user to query.\n  function _getUserPoolShare(address _account) internal view virtual returns (uint256);\n}\n"
      },
      "contracts/common/rewards/distributor/IMultipleRewardDistributor.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface IMultipleRewardDistributor {\n  /**********\n   * Events *\n   **********/\n\n  /// @notice Emitted when new reward token is registered.\n  ///\n  /// @param token The address of reward token.\n  /// @param distributor The address of reward distributor.\n  event RegisterRewardToken(address indexed token, address indexed distributor);\n\n  /// @notice Emitted when the reward distributor is updated.\n  ///\n  /// @param token The address of reward token.\n  /// @param oldDistributor The address of previous reward distributor.\n  /// @param newDistributor The address of current reward distributor.\n  event UpdateRewardDistributor(address indexed token, address indexed oldDistributor, address indexed newDistributor);\n\n  /// @notice Emitted when a reward token is unregistered.\n  ///\n  /// @param token The address of reward token.\n  event UnregisterRewardToken(address indexed token);\n\n  /// @notice Emitted when a reward token is deposited.\n  ///\n  /// @param token The address of reward token.\n  /// @param amount The amount of reward token deposited.\n  event DepositReward(address indexed token, uint256 amount);\n\n  /**********\n   * Errors *\n   **********/\n\n  /// @dev Thrown when caller access an unactive reward token.\n  error NotActiveRewardToken();\n\n  /// @dev Thrown when the address of reward distributor is `address(0)`.\n  error RewardDistributorIsZero();\n\n  /// @dev Thrown when caller is not reward distributor.\n  error NotRewardDistributor();\n\n  /// @dev Thrown when caller try to register an existing reward token.\n  error DuplicatedRewardToken();\n\n  /// @dev Thrown when caller try to unregister a reward with pending rewards.\n  error RewardDistributionNotFinished();\n\n  /*************************\n   * Public View Functions *\n   *************************/\n\n  /// @notice Return the address of reward distributor.\n  ///\n  /// @param token The address of reward token.\n  function distributors(address token) external view returns (address);\n\n  /// @notice Return the list of active reward tokens.\n  function getActiveRewardTokens() external view returns (address[] memory);\n\n  /// @notice Return the list of historical reward tokens.\n  function getHistoricalRewardTokens() external view returns (address[] memory);\n\n  /// @notice Return the amount of pending distributed rewards in current period.\n  ///\n  /// @param token The address of reward token.\n  /// @return distributable The amount of reward token can be distributed in current period.\n  /// @return undistributed The amount of reward token still locked in current period.\n  function pendingRewards(address token) external view returns (uint256 distributable, uint256 undistributed);\n\n  /****************************\n   * Public Mutated Functions *\n   ****************************/\n\n  /// @notice Deposit new rewards to this contract.\n  ///\n  /// @param token The address of reward token.\n  /// @param amount The amount of new rewards.\n  function depositReward(address token, uint256 amount) external;\n}\n"
      },
      "contracts/common/rewards/distributor/LinearMultipleRewardDistributor.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { AccessControlUpgradeable } from \"@openzeppelin/contracts-upgradeable-v4/access/AccessControlUpgradeable.sol\";\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable-v4/token/ERC20/IERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable-v4/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { EnumerableSetUpgradeable } from \"@openzeppelin/contracts-upgradeable-v4/utils/structs/EnumerableSetUpgradeable.sol\";\n\nimport { IMultipleRewardDistributor } from \"./IMultipleRewardDistributor.sol\";\nimport { LinearReward } from \"./LinearReward.sol\";\n\n// solhint-disable no-empty-blocks\n// solhint-disable not-rely-on-time\n\nabstract contract LinearMultipleRewardDistributor is AccessControlUpgradeable, IMultipleRewardDistributor {\n  using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n  using SafeERC20Upgradeable for IERC20Upgradeable;\n\n  using LinearReward for LinearReward.RewardData;\n\n  /*************\n   * Constants *\n   *************/\n\n  /// @notice The role used to manage rewards.\n  bytes32 public constant REWARD_MANAGER_ROLE = keccak256(\"REWARD_MANAGER_ROLE\");\n\n  /// @notice The length of reward period in seconds.\n  /// @dev If the value is zero, the reward will be distributed immediately.\n  /// @dev It is either zero or at least 1 day (which is 86400).\n  uint40 public immutable periodLength;\n\n  /*************\n   * Variables *\n   *************/\n\n  /// @inheritdoc IMultipleRewardDistributor\n  mapping(address => address) public override distributors;\n\n  /// @notice Mapping from reward token address to linear distribution reward data.\n  mapping(address => LinearReward.RewardData) public rewardData;\n\n  /// @dev The list of active reward tokens.\n  EnumerableSetUpgradeable.AddressSet internal activeRewardTokens;\n\n  /// @dev The list of historical reward tokens.\n  EnumerableSetUpgradeable.AddressSet private historicalRewardTokens;\n\n  /// @dev reserved slots.\n  uint256[46] private __gap;\n\n  /***************\n   * Constructor *\n   ***************/\n\n  constructor(uint40 _periodLength) {\n    require(_periodLength == 0 || (_periodLength >= 1 days && _periodLength <= 28 days), \"invalid period length\");\n\n    periodLength = _periodLength;\n  }\n\n  // solhint-disable-next-line func-name-mixedcase\n  function __LinearMultipleRewardDistributor_init() internal onlyInitializing {}\n\n  /*************************\n   * Public View Functions *\n   *************************/\n\n  /// @inheritdoc IMultipleRewardDistributor\n  function getActiveRewardTokens() public view override returns (address[] memory _rewardTokens) {\n    uint256 _length = activeRewardTokens.length();\n    _rewardTokens = new address[](_length);\n\n    for (uint256 i = 0; i < _length; i++) {\n      _rewardTokens[i] = activeRewardTokens.at(i);\n    }\n  }\n\n  /// @inheritdoc IMultipleRewardDistributor\n  function getHistoricalRewardTokens() public view override returns (address[] memory _rewardTokens) {\n    uint256 _length = historicalRewardTokens.length();\n    _rewardTokens = new address[](_length);\n\n    for (uint256 i = 0; i < _length; i++) {\n      _rewardTokens[i] = historicalRewardTokens.at(i);\n    }\n  }\n\n  /// @inheritdoc IMultipleRewardDistributor\n  function pendingRewards(address _token) external view override returns (uint256, uint256) {\n    return rewardData[_token].pending();\n  }\n\n  /****************************\n   * Public Mutated Functions *\n   ****************************/\n\n  /// @inheritdoc IMultipleRewardDistributor\n  function depositReward(address _token, uint256 _amount) external override {\n    address _distributor = _msgSender();\n    if (!activeRewardTokens.contains(_token)) revert NotActiveRewardToken();\n    if (distributors[_token] != _distributor) revert NotRewardDistributor();\n\n    if (_amount > 0) {\n      IERC20Upgradeable(_token).safeTransferFrom(_distributor, address(this), _amount);\n    }\n\n    _distributePendingReward();\n\n    _notifyReward(_token, _amount);\n\n    emit DepositReward(_token, _amount);\n  }\n\n  /************************\n   * Restricted Functions *\n   ************************/\n\n  /// @notice Register a new reward token.\n  /// @dev Make sure no fee on transfer token is added as reward token.\n  ///\n  /// @param _token The address of reward token.\n  /// @param _distributor The address of reward distributor.\n  function registerRewardToken(address _token, address _distributor) external onlyRole(REWARD_MANAGER_ROLE) {\n    if (_distributor == address(0)) revert RewardDistributorIsZero();\n    if (activeRewardTokens.contains(_token)) revert DuplicatedRewardToken();\n\n    activeRewardTokens.add(_token);\n    distributors[_token] = _distributor;\n    historicalRewardTokens.remove(_token);\n\n    emit RegisterRewardToken(_token, _distributor);\n  }\n\n  /// @notice Update the distributor for reward token.\n  ///\n  /// @param _token The address of reward token.\n  /// @param _newDistributor The address of new reward distributor.\n  function updateRewardDistributor(address _token, address _newDistributor) external onlyRole(REWARD_MANAGER_ROLE) {\n    if (_newDistributor == address(0)) revert RewardDistributorIsZero();\n    if (!activeRewardTokens.contains(_token)) revert NotActiveRewardToken();\n\n    address _oldDistributor = distributors[_token];\n    distributors[_token] = _newDistributor;\n\n    emit UpdateRewardDistributor(_token, _oldDistributor, _newDistributor);\n  }\n\n  /// @notice Unregister an existing reward token.\n  ///\n  /// @param _token The address of reward token.\n  function unregisterRewardToken(address _token) external onlyRole(REWARD_MANAGER_ROLE) {\n    if (!activeRewardTokens.contains(_token)) revert NotActiveRewardToken();\n\n    LinearReward.RewardData memory _data = rewardData[_token];\n    unchecked {\n      (uint256 _distributable, uint256 _undistributed) = _data.pending();\n      if (_data.queued < periodLength) _data.queued = 0; // ignore round error\n      if (_data.queued + _distributable + _undistributed > 0) revert RewardDistributionNotFinished();\n    }\n\n    activeRewardTokens.remove(_token);\n    distributors[_token] = address(0);\n    historicalRewardTokens.add(_token);\n\n    emit UnregisterRewardToken(_token);\n  }\n\n  /**********************\n   * Internal Functions *\n   **********************/\n\n  /// @dev Internal function to notify new rewards.\n  ///\n  /// @param _token The address of token.\n  /// @param _amount The amount of new rewards.\n  function _notifyReward(address _token, uint256 _amount) internal {\n    if (periodLength == 0) {\n      _accumulateReward(_token, _amount);\n    } else {\n      LinearReward.RewardData memory _data = rewardData[_token];\n      _data.increase(periodLength, _amount);\n      rewardData[_token] = _data;\n    }\n  }\n\n  /// @dev Internal function to distribute all pending reward tokens.\n  function _distributePendingReward() internal {\n    if (periodLength == 0 || activeRewardTokens.length() == 0) return;\n\n    address[] memory _activeRewardTokens = getActiveRewardTokens();\n    for (uint256 i = 0; i < _activeRewardTokens.length; i++) {\n      address _token = _activeRewardTokens[i];\n      (uint256 _pending, ) = rewardData[_token].pending();\n      rewardData[_token].lastUpdate = uint40(block.timestamp);\n\n      if (_pending > 0) {\n        _accumulateReward(_token, _pending);\n      }\n    }\n  }\n\n  /// @dev Internal function to accumulate distributed rewards.\n  ///\n  /// @param _token The address of token.\n  /// @param _amount The amount of rewards to accumulate.\n  function _accumulateReward(address _token, uint256 _amount) internal virtual;\n}\n"
      },
      "contracts/common/rewards/distributor/LinearReward.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { SafeCastUpgradeable } from \"@openzeppelin/contracts-upgradeable-v4/utils/math/SafeCastUpgradeable.sol\";\n\n// solhint-disable not-rely-on-time\n\nlibrary LinearReward {\n  using SafeCastUpgradeable for uint256;\n\n  /// @dev Compiler will pack this into single `uint256`.\n  /// Usually, we assume the amount of rewards won't exceed `uint96.max`.\n  /// In such case, the rate won't exceed `uint80.max`, since `periodLength` is at least `86400`.\n  /// Also `uint40.max` is enough for timestamp, which is about 30000 years.\n  struct RewardData {\n    // The amount of rewards pending to distribute.\n    uint96 queued;\n    // The current reward rate per second.\n    uint80 rate;\n    // The last timestamp when the reward is distributed.\n    uint40 lastUpdate;\n    // The timestamp when this period will finish.\n    uint40 finishAt;\n  }\n\n  /// @dev Add new rewards to current one. It is possible that the rewards will not distribute immediately.\n  /// The rewards will be only distributed when current period is end or the current increase or\n  /// decrease no more than 10%.\n  ///\n  /// @param _data The struct of reward data, will be modified inplace.\n  /// @param _periodLength The length of a period, caller should make sure it is at least `86400`.\n  /// @param _amount The amount of new rewards to distribute.\n  function increase(\n    RewardData memory _data,\n    uint256 _periodLength,\n    uint256 _amount\n  ) internal view {\n    _amount = _amount + _data.queued;\n    _data.queued = 0;\n\n    if (block.timestamp >= _data.finishAt) {\n      // period finished, distribute to next period\n      _data.rate = (_amount / _periodLength).toUint80();\n      _data.queued = uint96(_amount - (_data.rate * _periodLength)); // keep rounding error\n      _data.lastUpdate = uint40(block.timestamp);\n      _data.finishAt = uint40(block.timestamp + _periodLength);\n    } else {\n      uint256 _elapsed = block.timestamp - (_data.finishAt - _periodLength);\n      uint256 _distributed = uint256(_data.rate) * _elapsed;\n      if (_distributed * 9 <= _amount * 10) {\n        // APR increase or drop no more than 10%, distribute\n        _amount = _amount + uint256(_data.rate) * (_data.finishAt - _data.lastUpdate);\n        _data.rate = (_amount / _periodLength).toUint80();\n        _data.queued = uint96(_amount - (_data.rate * _periodLength)); // keep rounding error\n        _data.lastUpdate = uint40(block.timestamp);\n        _data.finishAt = uint40(block.timestamp + _periodLength);\n        _data.lastUpdate = uint40(block.timestamp);\n      } else {\n        // APR drop more than 10%, wait for more rewards\n        _data.queued = _amount.toUint96();\n      }\n    }\n  }\n\n  /// @dev Return the amount of pending distributed rewards in current period.\n  ///\n  /// @param _data The struct of reward data.\n  function pending(RewardData memory _data) internal view returns (uint256, uint256) {\n    uint256 _elapsed;\n    uint256 _left;\n    if (block.timestamp > _data.finishAt) {\n      // finishAt >= lastUpdate will happen, if `_notifyReward` is not called during current period.\n      _elapsed = _data.finishAt >= _data.lastUpdate ? _data.finishAt - _data.lastUpdate : 0;\n    } else {\n      unchecked {\n        _elapsed = block.timestamp - _data.lastUpdate;\n        _left = uint256(_data.finishAt) - block.timestamp;\n      }\n    }\n\n    return (uint256(_data.rate) * _elapsed, uint256(_data.rate) * _left);\n  }\n}\n"
      },
      "contracts/concentrator/ConcentratorBaseV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { AccessControlUpgradeable } from \"@openzeppelin/contracts-upgradeable-v4/access/AccessControlUpgradeable.sol\";\n\nimport { WordCodec } from \"../common/codec/WordCodec.sol\";\n\nimport { IConcentratorBase } from \"../interfaces/concentrator/IConcentratorBase.sol\";\n\n// solhint-disable func-name-mixedcase\n// solhint-disable no-inline-assembly\n\nabstract contract ConcentratorBaseV2 is AccessControlUpgradeable, IConcentratorBase {\n  using WordCodec for bytes32;\n\n  /*************\n   * Constants *\n   *************/\n\n  /// @dev The fee denominator used for rate calculation.\n  uint256 internal constant RATE_PRECISION = 1e9;\n\n  /// @dev The maximum expense ratio.\n  uint256 private constant MAX_EXPENSE_RATIO = 5e8; // 50%\n\n  /// @dev The maximum harvester ratio.\n  uint256 private constant MAX_HARVESTER_RATIO = 1e8; // 20%\n\n  /// @dev The maximum withdraw fee percentage.\n  uint256 private constant MAX_WITHDRAW_FEE_PERCENTAGE = 1e8; // 10%\n\n  /// @dev The offset of expense ratio in `_miscData`.\n  uint256 private constant EXPENSE_RATIO_OFFSET = 0;\n\n  /// @dev The offset of harvester ratio in `_miscData`.\n  uint256 private constant HARVESTER_RATIO_OFFSET = 30;\n\n  /// @dev The offset of withdraw fee percentage in `_miscData`.\n  uint256 private constant WITHDRAW_FEE_PERCENTAGE_OFFSET = 60;\n\n  /*************\n   * Variables *\n   *************/\n\n  /// @inheritdoc IConcentratorBase\n  address public treasury;\n\n  /// @inheritdoc IConcentratorBase\n  address public harvester;\n\n  /// @inheritdoc IConcentratorBase\n  address public converter;\n\n  /// @dev `_miscData` is a storage slot that can be used to store unrelated pieces of information.\n  /// All pools store the *expense ratio*, *harvester ratio* and *withdraw fee percentage*, but\n  /// the `miscData`can be extended to store more pieces of information.\n  ///\n  /// The *expense ratio* is stored in the first most significant 32 bits, and the *harvester ratio* is\n  /// stored in the next most significant 32 bits, and the *withdraw fee percentage* is stored in the\n  /// next most significant 32 bits, leaving the remaining 160 bits free to store any other information\n  /// derived pools might need.\n  ///\n  /// - The *expense ratio* and *harvester ratio* are charged each time when harvester harvest the pool revenue.\n  /// - The *withdraw fee percentage* is charged each time when user try to withdraw assets from the pool.\n  ///\n  /// [ expense ratio | harvester ratio | withdraw fee | available ]\n  /// [    30 bits    |     30 bits     |   30  bits   |  166 bits ]\n  /// [ MSB                                                    LSB ]\n  bytes32 internal _miscData;\n\n  /// @dev reserved slots.\n  uint256[46] private __gap;\n\n  /*************\n   * Modifiers *\n   *************/\n\n  modifier onlyHarvester() {\n    address _harvester = harvester;\n    if (_harvester != address(0) && _harvester != _msgSender()) {\n      revert CallerIsNotHarvester();\n    }\n    _;\n  }\n\n  /***************\n   * Constructor *\n   ***************/\n\n  function __ConcentratorBaseV2_init(\n    address _treasury,\n    address _harvester,\n    address _converter\n  ) internal onlyInitializing {\n    _updateTreasury(_treasury);\n    _updateHarvester(_harvester);\n    _updateConverter(_converter);\n  }\n\n  /*************************\n   * Public View Functions *\n   *************************/\n\n  /// @inheritdoc IConcentratorBase\n  function getExpenseRatio() public view override returns (uint256) {\n    return _miscData.decodeUint(EXPENSE_RATIO_OFFSET, 30);\n  }\n\n  /// @inheritdoc IConcentratorBase\n  function getHarvesterRatio() public view override returns (uint256) {\n    return _miscData.decodeUint(HARVESTER_RATIO_OFFSET, 30);\n  }\n\n  /// @inheritdoc IConcentratorBase\n  function getWithdrawFeePercentage() public view override returns (uint256) {\n    return _miscData.decodeUint(WITHDRAW_FEE_PERCENTAGE_OFFSET, 30);\n  }\n\n  /************************\n   * Restricted Functions *\n   ************************/\n\n  /// @notice Update the address of treasury contract.\n  ///\n  /// @param _newTreasury The address of the new treasury contract.\n  function updateTreasury(address _newTreasury) external onlyRole(DEFAULT_ADMIN_ROLE) {\n    _updateTreasury(_newTreasury);\n  }\n\n  /// @notice Update the address of harvester contract.\n  ///\n  /// @param _newHarvester The address of the new harvester contract.\n  function updateHarvester(address _newHarvester) external onlyRole(DEFAULT_ADMIN_ROLE) {\n    _updateHarvester(_newHarvester);\n  }\n\n  /// @notice Update the address of converter contract.\n  ///\n  /// @param _newConverter The address of the new converter contract.\n  function updateConverter(address _newConverter) external onlyRole(DEFAULT_ADMIN_ROLE) {\n    _updateConverter(_newConverter);\n  }\n\n  /// @notice Update the fee ratio distributed to treasury.\n  /// @param _newRatio The new ratio to update, multipled by 1e9.\n  function updateExpenseRatio(uint32 _newRatio) external onlyRole(DEFAULT_ADMIN_ROLE) {\n    if (uint256(_newRatio) > MAX_EXPENSE_RATIO) {\n      revert ExpenseRatioTooLarge();\n    }\n\n    bytes32 _data = _miscData;\n    uint256 _oldRatio = _miscData.decodeUint(EXPENSE_RATIO_OFFSET, 30);\n    _miscData = _data.insertUint(_newRatio, EXPENSE_RATIO_OFFSET, 30);\n\n    emit UpdateExpenseRatio(_oldRatio, _newRatio);\n  }\n\n  /// @notice Update the fee ratio distributed to harvester.\n  /// @param _newRatio The new ratio to update, multipled by 1e9.\n  function updateHarvesterRatio(uint32 _newRatio) external onlyRole(DEFAULT_ADMIN_ROLE) {\n    if (uint256(_newRatio) > MAX_HARVESTER_RATIO) {\n      revert HarvesterRatioTooLarge();\n    }\n\n    bytes32 _data = _miscData;\n    uint256 _oldRatio = _miscData.decodeUint(HARVESTER_RATIO_OFFSET, 30);\n    _miscData = _data.insertUint(_newRatio, HARVESTER_RATIO_OFFSET, 30);\n\n    emit UpdateHarvesterRatio(_oldRatio, _newRatio);\n  }\n\n  /// @notice Update the withdraw fee percentage\n  /// @param _newPercentage The new ratio to update, multipled by 1e9.\n  function updateWithdrawFeePercentage(uint32 _newPercentage) external onlyRole(DEFAULT_ADMIN_ROLE) {\n    if (uint256(_newPercentage) > MAX_WITHDRAW_FEE_PERCENTAGE) {\n      revert WithdrawFeePercentageTooLarge();\n    }\n\n    bytes32 _data = _miscData;\n    uint256 _oldPercentage = _miscData.decodeUint(WITHDRAW_FEE_PERCENTAGE_OFFSET, 30);\n    _miscData = _data.insertUint(_newPercentage, WITHDRAW_FEE_PERCENTAGE_OFFSET, 30);\n\n    emit UpdateWithdrawFeePercentage(_oldPercentage, _newPercentage);\n  }\n\n  /**********************\n   * Internal Functions *\n   **********************/\n\n  /// @dev Internal function to update the address of treasury contract.\n  ///\n  /// @param _newTreasury The address of the new treasury contract.\n  function _updateTreasury(address _newTreasury) private {\n    if (_newTreasury == address(0)) revert TreasuryIsZero();\n\n    address _oldTreasury = treasury;\n    treasury = _newTreasury;\n\n    emit UpdateTreasury(_oldTreasury, _newTreasury);\n  }\n\n  /// @dev Internal function to update the address of harvester contract.\n  ///\n  /// @param _newHarvester The address of the new harvester contract.\n  function _updateHarvester(address _newHarvester) private {\n    address _oldHarvester = harvester;\n    harvester = _newHarvester;\n\n    emit UpdateHarvester(_oldHarvester, _newHarvester);\n  }\n\n  /// @dev Internal function to update the address of converter contract.\n  ///\n  /// @param _newConverter The address of the new converter contract.\n  function _updateConverter(address _newConverter) private {\n    if (_newConverter == address(0)) revert ConverterIsZero();\n\n    address _oldConverter = converter;\n    converter = _newConverter;\n\n    emit UpdateConverter(_oldConverter, _newConverter);\n  }\n}\n"
      },
      "contracts/concentrator/stakedao/ConcentratorSdCrvGaugeWrapper.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity =0.8.20;\n\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable-v4/token/ERC20/IERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable-v4/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { EnumerableSetUpgradeable } from \"@openzeppelin/contracts-upgradeable-v4/utils/structs/EnumerableSetUpgradeable.sol\";\n\nimport { IConcentratorSdCrvGaugeWrapper } from \"../../interfaces/concentrator/IConcentratorSdCrvGaugeWrapper.sol\";\nimport { IConcentratorStakeDAOLocker } from \"../../interfaces/concentrator/IConcentratorStakeDAOLocker.sol\";\nimport { ISdCRVLocker } from \"../../interfaces/concentrator/ISdCRVLocker.sol\";\nimport { IStakeDAOCRVDepositor } from \"../../interfaces/stakedao/IStakeDAOCRVDepositor.sol\";\nimport { ICurveFactoryPlainPool } from \"../../interfaces/ICurveFactoryPlainPool.sol\";\n\nimport { LinearMultipleRewardDistributor } from \"../../common/rewards/distributor/LinearMultipleRewardDistributor.sol\";\nimport { ConcentratorStakeDAOGaugeWrapper } from \"./ConcentratorStakeDAOGaugeWrapper.sol\";\n\ncontract ConcentratorSdCrvGaugeWrapper is ConcentratorStakeDAOGaugeWrapper, IConcentratorSdCrvGaugeWrapper {\n  using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n  using SafeERC20Upgradeable for IERC20Upgradeable;\n\n  /*************\n   * Constants *\n   *************/\n\n  /// @dev The address of CRV Token.\n  address private constant CRV = 0xD533a949740bb3306d119CC777fa900bA034cd52;\n\n  /// @dev The address of legacy sdveCRV Token.\n  address private constant SD_VE_CRV = 0x478bBC744811eE8310B461514BDc29D03739084D;\n\n  /// @dev The address of StakeDAO CRV Depositor contract.\n  address private constant DEPOSITOR = 0x88C88Aa6a9cedc2aff9b4cA6820292F39cc64026;\n\n  /// @dev The address of Curve CRV/sdCRV factory plain pool.\n  address private constant CURVE_POOL = 0xCA0253A98D16e9C1e3614caFDA19318EE69772D0;\n\n  /***************\n   * Constructor *\n   ***************/\n\n  constructor(\n    address _gauge,\n    address _locker,\n    address _delegation\n  ) LinearMultipleRewardDistributor(7 days) ConcentratorStakeDAOGaugeWrapper(_gauge, _locker, _delegation) {}\n\n  /// @param _treasury The address of treasury contract for holding platform revenue.\n  /// @param _burner The address of bribe burner contract.\n  function initialize(address _treasury, address _burner) external initializer {\n    __Context_init(); // from ContextUpgradeable\n    __ERC165_init(); // from ERC165Upgradeable\n    __AccessControl_init(); // from AccessControlUpgradeable\n    __ReentrancyGuard_init(); // from ReentrancyGuardUpgradeable\n\n    __ConcentratorBaseV2_init(_treasury, address(0), _burner); // from ConcentratorBaseV2\n    __LinearMultipleRewardDistributor_init(); // from LinearMultipleRewardDistributor\n    __MultipleRewardAccumulator_init(); // from MultipleRewardAccumulator\n    __ConcentratorStakeDAOGaugeWrapper_init(); // from ConcentratorStakeDAOGaugeWrapper\n\n    if (activeRewardTokens.add(stakingToken)) {\n      emit RegisterRewardToken(stakingToken, address(this));\n    }\n\n    // sync state from old vault\n    address legacyVault = 0x2b3e72f568F96d7209E20C8B8f4F2A363ee1E3F6;\n    address asdCRV = 0x43E54C2E7b3e294De3A155785F52AB49d87B9922;\n    balanceOf[asdCRV] = IERC20Upgradeable(legacyVault).balanceOf(asdCRV);\n    totalSupply = IERC20Upgradeable(legacyVault).totalSupply();\n    ISdCRVLocker.LockedBalance[] memory _locks = ISdCRVLocker(legacyVault).getUserLocks(asdCRV);\n    uint256 _totalLocked;\n    for (uint256 i = 0; i < _locks.length; i++) {\n      _totalLocked += _locks[i].amount;\n    }\n    IConcentratorStakeDAOLocker(locker).withdraw(gauge, stakingToken, _totalLocked, asdCRV);\n\n    // grant role\n    _grantRole(DEFAULT_ADMIN_ROLE, _msgSender());\n  }\n\n  /****************************\n   * Public Mutated Functions *\n   ****************************/\n\n  /// @inheritdoc IConcentratorSdCrvGaugeWrapper\n  function depositWithCRV(\n    uint256 _amount,\n    address _receiver,\n    uint256 _minOut\n  ) external override nonReentrant returns (uint256 _amountOut) {\n    address _owner = _msgSender();\n    if (_amount == type(uint256).max) {\n      _amount = IERC20Upgradeable(CRV).balanceOf(_owner);\n    }\n    if (_amount == 0) revert ErrorDepositZeroAssets();\n\n    IERC20Upgradeable(CRV).safeTransferFrom(_owner, address(this), _amount);\n\n    // swap CRV to sdCRV\n    uint256 _lockReturn = _amount + IStakeDAOCRVDepositor(DEPOSITOR).incentiveToken();\n    uint256 _swapReturn = ICurveFactoryPlainPool(CURVE_POOL).get_dy(0, 1, _amount);\n    if (_lockReturn >= _swapReturn) {\n      IERC20Upgradeable(CRV).safeApprove(DEPOSITOR, 0);\n      IERC20Upgradeable(CRV).safeApprove(DEPOSITOR, _amount);\n      IStakeDAOCRVDepositor(DEPOSITOR).deposit(_amount, true, false, locker);\n      _amountOut = _lockReturn;\n    } else {\n      IERC20Upgradeable(CRV).safeApprove(CURVE_POOL, 0);\n      IERC20Upgradeable(CRV).safeApprove(CURVE_POOL, _amount);\n      _amountOut = ICurveFactoryPlainPool(CURVE_POOL).exchange(0, 1, _amount, 0, locker);\n    }\n    if (_amountOut < _minOut) revert ErrorInsufficientAmountOut();\n\n    _deposit(_amountOut, _owner, _receiver);\n  }\n\n  /// @inheritdoc IConcentratorSdCrvGaugeWrapper\n  function depositWithSdVeCRV(uint256 _amount, address _receiver) external override nonReentrant {\n    address _owner = _msgSender();\n    if (_amount == type(uint256).max) {\n      _amount = IERC20Upgradeable(SD_VE_CRV).balanceOf(_owner);\n    }\n    IERC20Upgradeable(SD_VE_CRV).safeTransferFrom(_owner, address(this), _amount);\n\n    // lock to sdCRV\n    IERC20Upgradeable(SD_VE_CRV).safeApprove(DEPOSITOR, 0);\n    IERC20Upgradeable(SD_VE_CRV).safeApprove(DEPOSITOR, _amount);\n    IStakeDAOCRVDepositor(DEPOSITOR).lockSdveCrvToSdCrv(_amount);\n\n    // transfer to locker\n    IERC20Upgradeable(stakingToken).safeTransfer(locker, _amount);\n\n    // deposit\n    _deposit(_amount, _owner, _receiver);\n  }\n}\n"
      },
      "contracts/concentrator/stakedao/ConcentratorStakeDAOGaugeWrapper.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\nimport { ReentrancyGuardUpgradeable } from \"@openzeppelin/contracts-upgradeable-v4/security/ReentrancyGuardUpgradeable.sol\";\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable-v4/token/ERC20/IERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable-v4/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport { EnumerableSetUpgradeable } from \"@openzeppelin/contracts-upgradeable-v4/utils/structs/EnumerableSetUpgradeable.sol\";\n\nimport { IConcentratorStakeDAOGaugeWrapper } from \"../../interfaces/concentrator/IConcentratorStakeDAOGaugeWrapper.sol\";\nimport { IConcentratorStakeDAOLocker } from \"../../interfaces/concentrator/IConcentratorStakeDAOLocker.sol\";\nimport { ICurveGauge } from \"../../interfaces/ICurveGauge.sol\";\nimport { IMultiMerkleStash } from \"../../interfaces/IMultiMerkleStash.sol\";\n\nimport { WordCodec } from \"../../common/codec/WordCodec.sol\";\nimport { MultipleRewardAccumulator } from \"../../common/rewards/accumulator/MultipleRewardAccumulator.sol\";\nimport { ConcentratorBaseV2 } from \"../ConcentratorBaseV2.sol\";\n\nimport { StakeDAOGaugeWrapperStash } from \"../stash/StakeDAOGaugeWrapperStash.sol\";\n\n// solhint-disable func-name-mixedcase\n\nabstract contract ConcentratorStakeDAOGaugeWrapper is\n  ReentrancyGuardUpgradeable,\n  ConcentratorBaseV2,\n  MultipleRewardAccumulator,\n  IConcentratorStakeDAOGaugeWrapper\n{\n  using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n  using SafeERC20Upgradeable for IERC20Upgradeable;\n\n  using WordCodec for bytes32;\n\n  /*************\n   * Constants *\n   *************/\n\n  /// @dev The maximum booster ratio.\n  uint256 private constant MAX_BOOSTER_RATIO = 2e8; // 20%\n\n  /// @dev The offset of booster ratio in `_miscData`.\n  uint256 private constant BOOSTER_RATIO_OFFSET = 90;\n\n  /// @dev The address of Stake DAO: SDT Token.\n  address internal constant SDT = 0x73968b9a57c6E53d41345FD57a6E6ae27d6CDB2F;\n\n  /// @inheritdoc IConcentratorStakeDAOGaugeWrapper\n  address public immutable override gauge;\n\n  /// @inheritdoc IConcentratorStakeDAOGaugeWrapper\n  address public immutable override stakingToken;\n\n  /// @notice The address of StakeDaoLockerProxy contract.\n  address public immutable locker;\n\n  /// @notice The address of VeSDTDelegation contract.\n  address public immutable delegation;\n\n  /*************\n   * Variables *\n   *************/\n\n  /// @inheritdoc IConcentratorStakeDAOGaugeWrapper\n  uint256 public override totalSupply;\n\n  /// @inheritdoc IConcentratorStakeDAOGaugeWrapper\n  mapping(address => uint256) public override balanceOf;\n\n  /// @notice The address of stash contract.\n  address public stash;\n\n  /// @dev reserved slots.\n  uint256[47] private __gap;\n\n  /***************\n   * Constructor *\n   ***************/\n\n  constructor(\n    address _gauge,\n    address _locker,\n    address _delegation\n  ) {\n    gauge = _gauge;\n    stakingToken = ICurveGauge(_gauge).staking_token();\n    locker = _locker;\n    delegation = _delegation;\n  }\n\n  function __ConcentratorStakeDAOGaugeWrapper_init() internal onlyInitializing {\n    syncActiveRewardTokens();\n\n    stash = address(new StakeDAOGaugeWrapperStash(address(this)));\n  }\n\n  /*************************\n   * Public View Functions *\n   *************************/\n\n  /// @inheritdoc IConcentratorStakeDAOGaugeWrapper\n  function getBoosterRatio() public view override returns (uint256) {\n    return _miscData.decodeUint(BOOSTER_RATIO_OFFSET, 30);\n  }\n\n  /****************************\n   * Public Mutated Functions *\n   ****************************/\n\n  /// @inheritdoc IConcentratorStakeDAOGaugeWrapper\n  function deposit(uint256 _amount, address _receiver) external override nonReentrant {\n    address _owner = _msgSender();\n    if (_amount == type(uint256).max) {\n      _amount = IERC20Upgradeable(stakingToken).balanceOf(_owner);\n    }\n    IERC20Upgradeable(stakingToken).safeTransferFrom(_owner, locker, _amount);\n\n    _deposit(_amount, _owner, _receiver);\n  }\n\n  /// @inheritdoc IConcentratorStakeDAOGaugeWrapper\n  function depositWithGauge(uint256 _amount, address _receiver) external override nonReentrant {\n    address _owner = _msgSender();\n    if (_amount == type(uint256).max) {\n      _amount = IERC20Upgradeable(gauge).balanceOf(_owner);\n    }\n    IERC20Upgradeable(gauge).safeTransferFrom(_owner, locker, _amount);\n\n    _deposit(_amount, address(0), _receiver);\n  }\n\n  /// @inheritdoc IConcentratorStakeDAOGaugeWrapper\n  function withdraw(uint256 _amount, address _receiver) external override nonReentrant {\n    address _owner = _msgSender();\n    uint256 _balance = balanceOf[_owner];\n    if (_amount == type(uint256).max) {\n      _amount = _balance;\n    }\n    if (_amount == 0) revert ErrorWithdrawZeroAssets();\n    if (_amount > _balance) revert ErrorInsufficientStakedToken();\n\n    _checkpoint(_owner);\n\n    unchecked {\n      balanceOf[_owner] = _balance - _amount;\n      totalSupply -= _amount;\n    }\n\n    IConcentratorStakeDAOLocker(locker).withdraw(gauge, stakingToken, _amount, _receiver);\n\n    emit Withdraw(_owner, _receiver, _amount);\n  }\n\n  /// @inheritdoc IConcentratorStakeDAOGaugeWrapper\n  function harvest(address _receiver) external override nonReentrant {\n    _checkpoint(address(0));\n\n    address[] memory _tokens = getActiveRewardTokens();\n    // claim rewards from locker and stash\n    IConcentratorStakeDAOLocker(locker).claimRewards(gauge, new address[](0));\n    uint256[] memory _amounts = StakeDAOGaugeWrapperStash(stash).withdrawTokens(_tokens);\n\n    address _treasury = treasury;\n    uint256 _expenseRatio = getExpenseRatio();\n    uint256 _harvesterRatio = getHarvesterRatio();\n    uint256 _boosterRatio = getBoosterRatio();\n    for (uint256 i = 0; i < _tokens.length; i++) {\n      uint256 _assets = _amounts[i];\n      if (_assets == 0) continue; // save gas\n\n      address _token = _tokens[i];\n      uint256 _performanceFee;\n      uint256 _harvesterBounty;\n      uint256 _boosterFee;\n      if (_expenseRatio > 0) {\n        _performanceFee = (_assets * _expenseRatio) / RATE_PRECISION;\n        IERC20Upgradeable(_token).safeTransfer(_treasury, _performanceFee);\n      }\n      if (_harvesterRatio > 0) {\n        _harvesterBounty = (_assets * _harvesterRatio) / RATE_PRECISION;\n        IERC20Upgradeable(_token).safeTransfer(_receiver, _harvesterBounty);\n      }\n      if (_tokens[i] == SDT && _boosterRatio > 0) {\n        _boosterFee = (_assets * _boosterRatio) / RATE_PRECISION;\n        IERC20Upgradeable(_token).safeTransfer(delegation, _boosterFee);\n      }\n\n      emit Harvest(_token, _msgSender(), _receiver, _assets, _performanceFee, _harvesterBounty, _boosterFee);\n      unchecked {\n        _notifyReward(_token, _assets - _performanceFee - _harvesterBounty - _boosterFee);\n      }\n    }\n  }\n\n  /// @inheritdoc IConcentratorStakeDAOGaugeWrapper\n  function harvestBribes(IMultiMerkleStash.claimParam[] memory _claims) external override nonReentrant {\n    IConcentratorStakeDAOLocker(locker).claimBribeRewards(_claims, address(this));\n\n    address _treasury = treasury;\n    address _burner = converter;\n    uint256 _expenseRatio = getExpenseRatio();\n    uint256 _boosterRatio = getBoosterRatio();\n    for (uint256 i = 0; i < _claims.length; i++) {\n      address _token = _claims[i].token;\n      uint256 _assets = _claims[i].amount;\n      uint256 _performanceFee = (_assets * _expenseRatio) / RATE_PRECISION;\n      uint256 _boosterFee = (_assets * _boosterRatio) / RATE_PRECISION;\n\n      // For non-SDT rewards, it will be transfered to BribeBurner contract waiting for burn.\n      // For SDT rewards, it will be distributed intermediately.\n      if (_token == SDT) {\n        if (_performanceFee > 0) {\n          IERC20Upgradeable(_token).safeTransfer(_treasury, _performanceFee);\n        }\n        if (_boosterFee > 0) {\n          IERC20Upgradeable(_token).safeTransfer(delegation, _boosterFee);\n        }\n        _notifyReward(_token, _assets - _performanceFee - _boosterFee);\n      } else {\n        IERC20Upgradeable(_token).safeTransfer(_burner, _assets);\n      }\n\n      emit HarvestBribe(_token, _assets, _performanceFee, _boosterFee);\n    }\n  }\n\n  /// @notice Helper function to sync active reward tokens from StakeDAO gauge.\n  function syncActiveRewardTokens() public {\n    uint256 _count = ICurveGauge(gauge).reward_count();\n    for (uint256 i = 0; i < _count; i++) {\n      address _token = ICurveGauge(gauge).reward_tokens(i);\n      bool _added = activeRewardTokens.add(_token);\n      if (_added) {\n        emit RegisterRewardToken(_token, address(this));\n\n        // it is a new token, check balance and distribute\n        uint256 _balance = IERC20Upgradeable(_token).balanceOf(address(this));\n        if (_balance > 0) {\n          _notifyReward(_token, _balance);\n        }\n      }\n    }\n  }\n\n  /************************\n   * Restricted Functions *\n   ************************/\n\n  /// @notice Update the fee ratio distributed to treasury.\n  /// @param _newRatio The new ratio to update, multipled by 1e9.\n  function updateBoosterRatio(uint32 _newRatio) external onlyRole(DEFAULT_ADMIN_ROLE) {\n    if (uint256(_newRatio) > MAX_BOOSTER_RATIO) {\n      revert ErrorBoosterRatioTooLarge();\n    }\n\n    bytes32 _data = _miscData;\n    uint256 _oldRatio = _miscData.decodeUint(BOOSTER_RATIO_OFFSET, 30);\n    _miscData = _data.insertUint(_newRatio, BOOSTER_RATIO_OFFSET, 30);\n\n    emit UpdateBoosterRatio(_oldRatio, _newRatio);\n  }\n\n  /**********************\n   * Internal Functions *\n   **********************/\n\n  /// @dev Internal function to deposit and alloc pool share to depositor.\n  /// If `_owner=address(0)` it means the token is already deposited to gauge through locker.\n  ///\n  /// @param _amount The amount of the token.\n  /// @param _owner The owner of the deposited token.\n  /// @param _receiver The address of pool share recipient.\n  function _deposit(\n    uint256 _amount,\n    address _owner,\n    address _receiver\n  ) internal {\n    if (_amount == 0) revert ErrorDepositZeroAssets();\n\n    _checkpoint(_receiver);\n\n    if (_owner != address(0)) {\n      uint256 _staked = IConcentratorStakeDAOLocker(locker).deposit(gauge, stakingToken);\n      if (_staked < _amount) revert ErrorStakedAmountMismatch();\n    }\n\n    // normally won't overflow\n    unchecked {\n      balanceOf[_receiver] += _amount;\n      totalSupply += _amount;\n    }\n\n    emit Deposit(_msgSender(), _receiver, _amount);\n  }\n\n  /// @inheritdoc MultipleRewardAccumulator\n  function _getTotalPoolShare() internal view virtual override returns (uint256) {\n    return totalSupply;\n  }\n\n  /// @inheritdoc MultipleRewardAccumulator\n  function _getUserPoolShare(address _account) internal view virtual override returns (uint256) {\n    return balanceOf[_account];\n  }\n}\n"
      },
      "contracts/concentrator/stash/StakeDAOGaugeWrapperStash.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity =0.8.20;\n\nimport { IERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable-v4/token/ERC20/IERC20Upgradeable.sol\";\nimport { SafeERC20Upgradeable } from \"@openzeppelin/contracts-upgradeable-v4/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\ncontract StakeDAOGaugeWrapperStash {\n  using SafeERC20Upgradeable for IERC20Upgradeable;\n\n  /**********\n   * Errors *\n   **********/\n\n  /// @dev Thrown when call is not wrapper contract.\n  error ErrorCallerIsNotWrapper();\n\n  /*************\n   * Constants *\n   *************/\n\n  /// @notice The address of wrapper contract.\n  address public immutable wrapper;\n\n  /***************\n   * Constructor *\n   ***************/\n\n  constructor(address _wrapper) {\n    wrapper = _wrapper;\n  }\n\n  /****************************\n   * Public Mutated Functions *\n   ****************************/\n\n  /// @notice Withdraw tokens from this contract.\n  /// @param _tokens The address lists of the tokens.\n  /// @return _balances The amount of tokens transfered to wrapper.\n  function withdrawTokens(address[] memory _tokens) external returns (uint256[] memory _balances) {\n    if (msg.sender != wrapper) revert ErrorCallerIsNotWrapper();\n\n    _balances = new uint256[](_tokens.length);\n    for (uint256 i = 0; i < _tokens.length; ++i) {\n      address _token = _tokens[i];\n      uint256 _balance = IERC20Upgradeable(_token).balanceOf(address(this));\n      if (_balance > 0) {\n        IERC20Upgradeable(_token).safeTransfer(wrapper, _balance);\n      }\n      _balances[i] = _balance;\n    }\n  }\n}\n"
      },
      "contracts/interfaces/concentrator/IConcentratorBase.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface IConcentratorBase {\n  /**********\n   * Events *\n   **********/\n\n  /// @notice Emitted when the treasury contract is updated.\n  ///\n  /// @param oldTreasury The address of the previous treasury contract.\n  /// @param newTreasury The address of the current treasury contract.\n  event UpdateTreasury(address indexed oldTreasury, address indexed newTreasury);\n\n  /// @notice Emitted when the harvester contract is updated.\n  ///\n  /// @param oldHarvester The address of the previous harvester contract.\n  /// @param newHarvester The address of the current harvester contract.\n  event UpdateHarvester(address indexed oldHarvester, address indexed newHarvester);\n\n  /// @notice Emitted when the converter contract is updated.\n  ///\n  /// @param oldConverter The address of the previous converter contract.\n  /// @param newConverter The address of the current converter contract.\n  event UpdateConverter(address indexed oldConverter, address indexed newConverter);\n\n  /// @notice Emitted when the ratio for treasury is updated.\n  /// @param oldRatio The value of the previous ratio, multipled by 1e9.\n  /// @param newRatio The value of the current ratio, multipled by 1e9.\n  event UpdateExpenseRatio(uint256 oldRatio, uint256 newRatio);\n\n  /// @notice Emitted when the ratio for harvester is updated.\n  /// @param oldRatio The value of the previous ratio, multipled by 1e9.\n  /// @param newRatio The value of the current ratio, multipled by 1e9.\n  event UpdateHarvesterRatio(uint256 oldRatio, uint256 newRatio);\n\n  /// @notice Emitted when the fee percentage for withdrawal is updated.\n  /// @param oldPercentage The value of the previous fee percentage, multipled by 1e9.\n  /// @param newPercentage The value of the current fee percentage, multipled by 1e9.\n  event UpdateWithdrawFeePercentage(uint256 oldPercentage, uint256 newPercentage);\n\n  /**********\n   * Errors *\n   **********/\n\n  /// @dev Thrown when caller is not harvester and try to call some harvester only functions.\n  error CallerIsNotHarvester();\n\n  /// @dev Thrown when the address of converter contract is zero.\n  error ConverterIsZero();\n\n  /// @dev Thrown when the address of treasury contract is zero.\n  error TreasuryIsZero();\n\n  /// @dev Thrown when the expense ratio exceeds `MAX_EXPENSE_RATIO`.\n  error ExpenseRatioTooLarge();\n\n  /// @dev Thrown when the harvester ratio exceeds `MAX_HARVESTER_RATIO`.\n  error HarvesterRatioTooLarge();\n\n  /// @dev Thrown when the withdraw fee percentage exceeds `MAX_WITHDRAW_FEE_PERCENTAGE`.\n  error WithdrawFeePercentageTooLarge();\n\n  /*************************\n   * Public View Functions *\n   *************************/\n\n  /// @notice The address of protocol revenue holder.\n  function treasury() external view returns (address);\n\n  /// @notice The address of harvester contract.\n  function harvester() external view returns (address);\n\n  /// @notice The address of converter contract.\n  function converter() external view returns (address);\n\n  /// @notice Return the fee ratio distributed to treasury, multipled by 1e9.\n  function getExpenseRatio() external view returns (uint256);\n\n  /// @notice Return the fee ratio distributed to harvester, multipled by 1e9.\n  function getHarvesterRatio() external view returns (uint256);\n\n  /// @notice Return the withdraw fee percentage, multipled by 1e9.\n  function getWithdrawFeePercentage() external view returns (uint256);\n}\n"
      },
      "contracts/interfaces/concentrator/IConcentratorSdCrvGaugeWrapper.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0 || ^0.8.0;\npragma abicoder v2;\n\nimport { IConcentratorStakeDAOGaugeWrapper } from \"./IConcentratorStakeDAOGaugeWrapper.sol\";\n\ninterface IConcentratorSdCrvGaugeWrapper is IConcentratorStakeDAOGaugeWrapper {\n  /**********\n   * Errors *\n   **********/\n\n  /// @dev Thrown when the output amount is not enough.\n  error ErrorInsufficientAmountOut();\n\n  /****************************\n   * Public Mutated Functions *\n   ****************************/\n\n  /// @notice Deposit some CRV to the contract.\n  ///\n  /// @param amount The amount of staking token to deposit.\n  /// @param receiver The address of recipient who will receive the deposited staking token.\n  /// @param minOut The minimum amount of sdCRV should received.\n  /// @return amountOut The amount of sdCRV received.\n  function depositWithCRV(\n    uint256 amount,\n    address receiver,\n    uint256 minOut\n  ) external returns (uint256 amountOut);\n\n  /// @notice Deposit some CRV to the contract.\n  ///\n  /// @param amount The amount of staking token to deposit.\n  /// @param receiver The address of recipient who will receive the deposited staking token.\n  function depositWithSdVeCRV(uint256 amount, address receiver) external;\n}\n"
      },
      "contracts/interfaces/concentrator/IConcentratorStakeDAOGaugeWrapper.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\npragma abicoder v2;\n\nimport { IMultipleRewardAccumulator } from \"../../common/rewards/accumulator/IMultipleRewardAccumulator.sol\";\nimport { IMultipleRewardDistributor } from \"../../common/rewards/distributor/IMultipleRewardDistributor.sol\";\n\nimport { IMultiMerkleStash } from \"../IMultiMerkleStash.sol\";\nimport { IConcentratorBase } from \"./IConcentratorBase.sol\";\n\ninterface IConcentratorStakeDAOGaugeWrapper is\n  IConcentratorBase,\n  IMultipleRewardDistributor,\n  IMultipleRewardAccumulator\n{\n  /**********\n   * Events *\n   **********/\n\n  /// @notice Emitted when the ratio for booster is updated.\n  /// @param oldRatio The value of the previous ratio, multipled by 1e9.\n  /// @param newRatio The value of the current ratio, multipled by 1e9.\n  event UpdateBoosterRatio(uint256 oldRatio, uint256 newRatio);\n\n  /// @notice Emitted when the address of burner is updated.\n  event UpdateBurner(address indexed oldBurner, address indexed newBurner);\n\n  /// @notice Emitted when user deposit staking token to the contract.\n  ///\n  /// @param owner The address of the owner of the staking token.\n  /// @param receiver The address of the recipient of the staking token.\n  /// @param amount The amount of staking token deposited.\n  event Deposit(address indexed owner, address indexed receiver, uint256 amount);\n\n  /// @notice Emitted when user withdraw staking token from the contract.\n  ///\n  /// @param owner The address of the owner of the staking token.\n  /// @param receiver The address of the recipient of the staking token.\n  /// @param amount The amount of staking token withdrawn.\n  event Withdraw(address indexed owner, address indexed receiver, uint256 amount);\n\n  /// @notice Emitted when someone harvests pending rewards.\n  /// @param token The address of token harvested.\n  /// @param caller The address who call the function.\n  /// @param receiver The address of account to recieve the harvest bounty.\n  /// @param assets The total amount of underlying asset harvested.\n  /// @param performanceFee The amount of harvested assets as performance fee.\n  /// @param harvesterBounty The amount of harvested assets as harvester bounty.\n  /// @param boosterFee The amount SDT for veSDT delegation booster, when the token is SDT.\n  event Harvest(\n    address indexed token,\n    address indexed caller,\n    address indexed receiver,\n    uint256 assets,\n    uint256 performanceFee,\n    uint256 harvesterBounty,\n    uint256 boosterFee\n  );\n\n  /// @notice Emitted when someone harvest pending bribe rewards.\n  ///\n  /// @param token The address of the reward token.\n  /// @param assets The amount of harvested rewards.\n  /// @param performanceFee The amount of platform fee taken.\n  /// @param boosterFee The amount SDT for veSDT delegation booster, when the token is SDT.\n  event HarvestBribe(address indexed token, uint256 assets, uint256 performanceFee, uint256 boosterFee);\n\n  /**********\n   * Errors *\n   **********/\n\n  /// @dev Thrown when the deposit amount is zero.\n  error ErrorDepositZeroAssets();\n\n  /// @dev Thrown when the actual staked amount is not enough.\n  error ErrorStakedAmountMismatch();\n\n  /// @dev Thrown when the withdrawal amount is zero.\n  error ErrorWithdrawZeroAssets();\n\n  /// @dev Thrown when withdraw more then staked.\n  error ErrorInsufficientStakedToken();\n\n  /// @dev Thrown when the booster ratio is too large.\n  error ErrorBoosterRatioTooLarge();\n\n  /*************************\n   * Public View Functions *\n   *************************/\n\n  /// @notice The address of gauge contract.\n  function gauge() external view returns (address);\n\n  /// @notice The address of staking token.\n  function stakingToken() external view returns (address);\n\n  /// @notice Return the amount of staking token staked in the contract.\n  function totalSupply() external view returns (uint256);\n\n  /// @notice Return the amount of staking token staked in the contract for some user.\n  ///\n  /// @param _user The address of user to query.\n  function balanceOf(address _user) external view returns (uint256);\n\n  /// @notice The fee ratio distributed to veSDT delegation booster, multipled by 1e9.\n  function getBoosterRatio() external view returns (uint256);\n\n  /****************************\n   * Public Mutated Functions *\n   ****************************/\n\n  /// @notice Deposit some staking token to the contract.\n  ///\n  /// @param amount The amount of staking token to deposit.\n  /// @param receiver The address of recipient who will receive the deposited staking token.\n  function deposit(uint256 amount, address receiver) external;\n\n  /// @notice Deposit some gauge token to the contract.\n  ///\n  /// @param amount The amount of gauge token to deposit.\n  /// @param receiver The address of recipient who will receive the deposited gauge token.\n  function depositWithGauge(uint256 amount, address receiver) external;\n\n  /// @notice Withdraw some staking token from the contract.\n  ///\n  /// @param amount The amount of staking token to withdraw.\n  /// @param receiver The address of recipient who will receive the withdrawn staking token.\n  function withdraw(uint256 amount, address receiver) external;\n\n  /// @notice Harvest pending reward from the contract.\n  ///\n  /// @param receiver The address of recipient who will receive the harvest bounty.\n  function harvest(address receiver) external;\n\n  /// @notice Harvest StakeDAO gauge bribes.\n  ///\n  /// @dev No harvest bounty when others call this function.\n  ///\n  /// @param _claims The claim parameters passing to StakeDAOMultiMerkleStash contract.\n  function harvestBribes(IMultiMerkleStash.claimParam[] memory _claims) external;\n}\n"
      },
      "contracts/interfaces/concentrator/IConcentratorStakeDAOLocker.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0 || ^0.8.0;\npragma abicoder v2;\n\nimport { IMultiMerkleStash } from \"../IMultiMerkleStash.sol\";\n\ninterface IConcentratorStakeDAOLocker {\n  /// @notice Deposit staked token to StakeDAO gauge.\n  /// @dev The caller should make sure the token is already transfered to the contract.\n  /// @param _gauge The address of gauge.\n  /// @param _token The address token to deposit.\n  /// @return _amount The amount of token deposited. This can be used for cross validation.\n  function deposit(address _gauge, address _token) external returns (uint256 _amount);\n\n  /// @notice Withdraw staked token from StakeDAO gauge.\n  /// @param _gauge The address of gauge.\n  /// @param _token The address token to withdraw.\n  /// @param _amount The amount of token to withdraw.\n  /// @param _recipient The address of recipient who will receive the staked token.\n  function withdraw(\n    address _gauge,\n    address _token,\n    uint256 _amount,\n    address _recipient\n  ) external;\n\n  /// @notice Claim pending rewards from StakeDAO gauge.\n  /// @dev Be careful that the StakeDAO gauge supports `claim_rewards_for`. Currently,\n  /// it is fine since only owner can call the function through `ClaimRewards` contract.\n  /// @param _gauge The address of gauge to claim.\n  /// @param _tokens The list of reward tokens to claim.\n  /// @return _amounts The list of amount of rewards claim for corresponding tokens.\n  function claimRewards(address _gauge, address[] calldata _tokens) external returns (uint256[] memory _amounts);\n\n  /// @notice Claim bribe rewards for sdCRV.\n  /// @param _claims The claim parameters passing to StakeDAOMultiMerkleStash contract.\n  /// @param _recipient The address of recipient who will receive the bribe rewards.\n  function claimBribeRewards(IMultiMerkleStash.claimParam[] memory _claims, address _recipient) external;\n}\n"
      },
      "contracts/interfaces/concentrator/ISdCRVLocker.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0 || ^0.8.0;\npragma abicoder v2;\n\ninterface ISdCRVLocker {\n  /// @notice Emmited when someone withdraw staking token from contract.\n  /// @param _owner The address of the owner of the staking token.\n  /// @param _recipient The address of the recipient of the locked staking token.\n  /// @param _amount The amount of staking token withdrawn.\n  /// @param _expiredAt The timestamp in second then the lock expired\n  event Lock(address indexed _owner, address indexed _recipient, uint256 _amount, uint256 _expiredAt);\n\n  /// @notice Emitted when someone withdraw expired locked staking token.\n  /// @param _owner The address of the owner of the locked staking token.\n  /// @param _recipient The address of the recipient of the staking token.\n  /// @param _amount The amount of staking token withdrawn.\n  event WithdrawExpired(address indexed _owner, address indexed _recipient, uint256 _amount);\n\n  struct LockedBalance {\n    // The amount of staking token locked.\n    uint128 amount;\n    // The timestamp in seconds when the lock expired.\n    uint128 expireAt;\n  }\n\n  /// @notice Return the list of locked staking token in the contract.\n  /// @param user The address of user to query.\n  /// @return locks The list of `LockedBalance` of the user.\n  function getUserLocks(address user) external view returns (LockedBalance[] memory locks);\n\n  /// @notice Withdraw all expired locks from contract.\n  /// @param user The address of user to withdraw.\n  /// @param recipient The address of recipient who will receive the token.\n  /// @return amount The amount of staking token withdrawn.\n  function withdrawExpired(address user, address recipient) external returns (uint256 amount);\n}\n"
      },
      "contracts/interfaces/ICurveFactoryPlainPool.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0 || ^0.8.0;\n\n// solhint-disable var-name-mixedcase, func-name-mixedcase\ninterface ICurveFactoryPlainPool {\n  function remove_liquidity_one_coin(\n    uint256 token_amount,\n    int128 i,\n    uint256 min_amount\n  ) external returns (uint256);\n\n  function calc_withdraw_one_coin(uint256 _token_amount, int128 i) external view returns (uint256);\n\n  function exchange(\n    int128 i,\n    int128 j,\n    uint256 _dx,\n    uint256 _min_dy,\n    address _receiver\n  ) external returns (uint256);\n\n  function get_dy(\n    int128 i,\n    int128 j,\n    uint256 dx\n  ) external view returns (uint256);\n\n  function coins(uint256 index) external view returns (address);\n\n  function balances(uint256 index) external view returns (uint256);\n\n  function A_precise() external view returns (uint256);\n\n  function fee() external view returns (uint256);\n}\n\n/// @dev This is the interface of Curve Factory Plain Pool with 2 tokens, examples:\ninterface ICurveFactoryPlain2Pool is ICurveFactoryPlainPool {\n  function add_liquidity(uint256[2] memory amounts, uint256 min_mint_amount) external returns (uint256);\n\n  function calc_token_amount(uint256[2] memory amounts, bool _is_deposit) external view returns (uint256);\n}\n\n/// @dev This is the interface of Curve Factory Plain Pool with 3 tokens, examples:\ninterface ICurveFactoryPlain3Pool is ICurveFactoryPlainPool {\n  function add_liquidity(uint256[3] memory amounts, uint256 min_mint_amount) external returns (uint256);\n\n  function calc_token_amount(uint256[3] memory amounts, bool _is_deposit) external view returns (uint256);\n}\n\n/// @dev This is the interface of Curve Factory Plain Pool with 4 tokens, examples:\ninterface ICurveFactoryPlain4Pool is ICurveFactoryPlainPool {\n  function add_liquidity(uint256[4] memory amounts, uint256 min_mint_amount) external returns (uint256);\n\n  function calc_token_amount(uint256[4] memory amounts, bool _is_deposit) external view returns (uint256);\n}\n"
      },
      "contracts/interfaces/ICurveGauge.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0 || ^0.8.0;\n\n// solhint-disable func-name-mixedcase\n\ninterface ICurveGauge {\n  /*************************\n   * Public View Functions *\n   *************************/\n\n  function staking_token() external view returns (address);\n\n  function totalSupply() external view returns (uint256);\n\n  function balanceOf(address account) external view returns (uint256);\n\n  function rewarded_token() external view returns (address); //v1\n\n  function reward_count() external view returns (uint256); // v2\n\n  function reward_tokens(uint256 index) external view returns (address); // v2\n\n  function rewards_receiver(address account) external view returns (address); // v3\n\n  /****************************\n   * Public Mutated Functions *\n   ****************************/\n\n  /// @notice Deposit `value` LP tokens.\n  ///\n  /// @param value Number of tokens to deposit\n  function deposit(uint256 value) external;\n\n  /// @notice Deposit `value` LP tokens.\n  ///\n  /// @param value Number of tokens to deposit\n  /// @param addr Address to deposit for\n  function deposit(uint256 value, address addr) external;\n\n  /// @notice Deposit `value` LP tokens.\n  ///\n  /// @param value Number of tokens to deposit.\n  /// @param addr Address to deposit for.\n  /// @param _claim_rewards Whether to claim pending reward tokens.\n  function deposit(\n    uint256 value,\n    address addr,\n    bool _claim_rewards\n  ) external;\n\n  /// @notice Withdraw `value` LP tokens\n  ///\n  /// @param value Number of tokens to withdraw\n  function withdraw(uint256 value) external;\n\n  /// @notice Withdraw `value` LP tokens\n  ///\n  /// @param value Number of tokens to withdraw.\n  /// @param _claim_rewards Whether to claim pending reward tokens.\n  function withdraw(uint256 value, bool _claim_rewards) external;\n\n  /// @notice Claim available reward tokens for `msg.sender`.\n  function claim_rewards() external;\n\n  /// @notice Claim available reward tokens for `addr`.\n  ///\n  /// @param addr Address to claim for.\n  function claim_rewards(address addr) external;\n\n  /// @notice Claim available reward tokens for `addr`.\n  ///\n  /// @param addr Address to claim for.\n  /// @param receiver Address to transfer rewards to. If set to `address(0)`,\n  /// uses the default reward receiver for the caller\n  function claim_rewards(address addr, address receiver) external;\n\n  /// @notice Set the default reward receiver for the caller.\n  ///\n  /// @dev When set to `address(0), rewards are sent to the caller.\n  ///\n  /// @param receiver Receiver address for any rewards claimed via `claim_rewards`\n  function set_rewards_receiver(address receiver) external;\n}\n"
      },
      "contracts/interfaces/IMultiMerkleStash.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0 || ^0.8.0;\npragma abicoder v2;\n\ninterface IMultiMerkleStash {\n  // solhint-disable-next-line contract-name-camelcase\n  struct claimParam {\n    address token;\n    uint256 index;\n    uint256 amount;\n    bytes32[] merkleProof;\n  }\n\n  function isClaimed(address token, uint256 index) external view returns (bool);\n\n  function merkleRoot(address token) external returns (bytes32);\n\n  function claim(\n    address token,\n    uint256 index,\n    address account,\n    uint256 amount,\n    bytes32[] calldata merkleProof\n  ) external;\n\n  function claimMulti(address account, claimParam[] calldata claims) external;\n\n  function updateMerkleRoot(address token, bytes32 _merkleRoot) external;\n}\n"
      },
      "contracts/interfaces/stakedao/IStakeDAOCRVDepositor.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0 || ^0.8.0;\n\ninterface IStakeDAOCRVDepositor {\n  function incentiveToken() external view returns (uint256);\n\n  /// @notice Deposit & Lock Token\n  /// @dev User needs to approve the contract to transfer the token\n  /// @param _amount The amount of token to deposit\n  /// @param _lock Whether to lock the token\n  /// @param _stake Whether to stake the token\n  /// @param _user User to deposit for\n  function deposit(\n    uint256 _amount,\n    bool _lock,\n    bool _stake,\n    address _user\n  ) external;\n\n  /// @notice Deposits all the token of a user & locks them based on the options choosen\n  /// @dev User needs to approve the contract to transfer Token tokens\n  /// @param _lock Whether to lock the token\n  /// @param _stake Whether to stake the token\n  /// @param _user User to deposit for\n  function depositAll(\n    bool _lock,\n    bool _stake,\n    address _user\n  ) external;\n\n  /// @notice Lock forever (irreversible action) old sdveCrv to sdCrv with 1:1 rate\n  /// @dev User needs to approve the contract to transfer Token tokens\n  /// @param _amount amount to lock\n  function lockSdveCrvToSdCrv(uint256 _amount) external;\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "evmVersion": "shanghai",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}