creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/dependencies/chainlink/AggregatorV3Interface.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// Chainlink Contracts v0.4.0 (v0.8/interfaces/AggregatorV3Interface.sol)\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n    function decimals() external view returns (uint8);\n\n    function description() external view returns (string memory);\n\n    function version() external view returns (uint256);\n\n    // getRoundData and latestRoundData should both raise \"No data present\"\n    // if they do not have data to report, instead of returning unset values\n    // which could be misinterpreted as actual reported values.\n    function getRoundData(\n        uint80 _roundId\n    )\n        external\n        view\n        returns (\n            uint80 roundId,\n            int256 answer,\n            uint256 startedAt,\n            uint256 updatedAt,\n            uint80 answeredInRound\n        );\n\n    function latestRoundData()\n        external\n        view\n        returns (\n            uint80 roundId,\n            int256 answer,\n            uint256 startedAt,\n            uint256 updatedAt,\n            uint80 answeredInRound\n        );\n}\n"
      },
      "contracts/dependencies/openzeppelin/access/IAccessControl.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 IAccessControl {\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(\n        bytes32 indexed role,\n        bytes32 indexed previousAdminRole,\n        bytes32 indexed newAdminRole\n    );\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"
      },
      "contracts/dependencies/openzeppelin/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/Address.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) ||\n                (!Address.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(\n            !_initializing && _initialized < version,\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        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"
      },
      "contracts/dependencies/openzeppelin/token/ERC20/extensions/IERC20Permit.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 IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    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"
      },
      "contracts/dependencies/openzeppelin/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "contracts/dependencies/openzeppelin/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return\n            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(\n        address target,\n        bytes memory data\n    ) 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(\n        address target,\n        bytes memory data\n    ) 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"
      },
      "contracts/dependencies/openzeppelin/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
      },
      "contracts/dependencies/openzeppelin/utils/introspection/ERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.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 ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
      },
      "contracts/dependencies/openzeppelin/utils/introspection/IERC165.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 IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "contracts/dependencies/openzeppelin/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(\n        uint256 x,\n        uint256 y,\n        uint256 denominator\n    ) 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(\n        uint256 x,\n        uint256 y,\n        uint256 denominator,\n        Rounding rounding\n    ) 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"
      },
      "contracts/dependencies/openzeppelin/utils/math/SignedMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // must be unchecked in order to support `n = type(int256).min`\n            return uint256(n >= 0 ? n : -n);\n        }\n    }\n}\n"
      },
      "contracts/dependencies/openzeppelin/utils/Multicall.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Multicall.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./Address.sol\";\n\n/**\n * @dev Provides a function to batch together multiple calls in a single external call.\n *\n * _Available since v4.1._\n */\nabstract contract Multicall {\n    /**\n     * @dev Receives and executes a batch of function calls on this contract.\n     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall\n     */\n    function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {\n        results = new bytes[](data.length);\n        for (uint256 i = 0; i < data.length; i++) {\n            results[i] = Address.functionDelegateCall(address(this), data[i]);\n        }\n        return results;\n    }\n}\n"
      },
      "contracts/dependencies/openzeppelin/utils/StorageSlot.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n *     function _getImplementation() internal view returns (address) {\n *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n *     }\n *\n *     function _setImplementation(address newImplementation) internal {\n *         require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\n * _Available since v4.9 for `string`, `bytes`._\n */\nlibrary StorageSlot {\n    struct AddressSlot {\n        address value;\n    }\n\n    struct BooleanSlot {\n        bool value;\n    }\n\n    struct Bytes32Slot {\n        bytes32 value;\n    }\n\n    struct Uint256Slot {\n        uint256 value;\n    }\n\n    struct StringSlot {\n        string value;\n    }\n\n    struct BytesSlot {\n        bytes value;\n    }\n\n    /**\n     * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n     */\n    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` with member `value` located at `slot`.\n     */\n    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n     */\n    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n     */\n    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n     */\n    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n}\n"
      },
      "contracts/dependencies/openzeppelin/utils/Strings.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = Math.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            /// @solidity memory-safe-assembly\n            assembly {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                /// @solidity memory-safe-assembly\n                assembly {\n                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toString(int256 value) internal pure returns (string memory) {\n        return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value))));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, Math.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"
      },
      "contracts/dependencies/openzeppelin/utils/structs/EnumerableSet.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n *     // Add the library methods\n *     using EnumerableSet for EnumerableSet.AddressSet;\n *\n *     // Declare a set state variable\n *     EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Set type with\n    // bytes32 values.\n    // The Set implementation uses private functions, and user-facing\n    // implementations (such as AddressSet) are just wrappers around the\n    // underlying Set.\n    // This means that we can only create new EnumerableSets for types that fit\n    // in bytes32.\n\n    struct Set {\n        // Storage of set values\n        bytes32[] _values;\n        // Position of the value in the `values` array, plus 1 because index 0\n        // means a value is not in the set.\n        mapping(bytes32 => uint256) _indexes;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            // The value is stored at length-1, but we add 1 to all indexes\n            // and use 0 as a sentinel value\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        // We read and store the value's index to prevent multiple reads from the same storage slot\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) {\n            // Equivalent to contains(set, value)\n            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n            // the array, and then remove the last element (sometimes called as 'swap and pop').\n            // This modifies the order of the array, as noted in {at}.\n\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            if (lastIndex != toDeleteIndex) {\n                bytes32 lastValue = set._values[lastIndex];\n\n                // Move the last value to the index where the value to delete is\n                set._values[toDeleteIndex] = lastValue;\n                // Update the index for the moved value\n                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n            }\n\n            // Delete the slot where the moved value was stored\n            set._values.pop();\n\n            // Delete the index for the deleted slot\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        return set._values[index];\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function _values(Set storage set) private view returns (bytes32[] memory) {\n        return set._values;\n    }\n\n    // Bytes32Set\n\n    struct Bytes32Set {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _add(set._inner, value);\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(Bytes32Set storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n        return _at(set._inner, index);\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        bytes32[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(AddressSet storage set) internal view returns (address[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        address[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // UintSet\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(UintSet storage set, uint256 value) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(UintSet storage set) internal view returns (uint256[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"
      },
      "contracts/protocol/interfaces/IAddressResolver.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\ninterface IAddressResolver {\n    error UnmatchedInputs();\n\n    event AddressImported(bytes32 name, address destination);\n\n    function getAddress(bytes32 name, string calldata reason) external view returns (address);\n\n    function getAddress(bytes32 name) external view returns (address);\n\n    function getAddresses() external view returns (address[] memory);\n\n    function getNames() external view returns (bytes32[] memory);\n}\n"
      },
      "contracts/protocol/interfaces/IBeaconProxyController.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\ninterface IBeaconProxyController {\n    error NoBeaconProxyContract();\n    error InvalidProxyContract();\n\n    event BeaconProxyUpdated(\n        bytes32 indexed id,\n        address indexed proxyAddress,\n        address indexed newImplementationAddress,\n        address oldImplementationAddress\n    );\n\n    function getBeaconProxyAddress(bytes32 beaconName) external view returns (address);\n\n    function setFutureValueVaultImpl(address newImpl) external;\n\n    function setLendingMarketImpl(address newImpl) external;\n\n    function setZCTokenImpl(address newImpl) external;\n\n    function deployFutureValueVault() external returns (address futureValueVault);\n\n    function deployLendingMarket(\n        bytes32 ccy,\n        uint256 orderFeeRate,\n        uint256 cbLimitRange\n    ) external returns (address market);\n\n    function deployZCToken(\n        string memory name,\n        string memory symbol,\n        uint8 decimals,\n        address asset,\n        uint256 maturity\n    ) external returns (address futureValueToken);\n}\n"
      },
      "contracts/protocol/interfaces/ICurrencyController.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {PriceFeed} from \"../storages/CurrencyControllerStorage.sol\";\n\n/**\n * @dev Currency Controller contract is responsible for managing supported\n * currencies in Secured Finance Protocol\n *\n * Contract links new currencies to ETH Chainlink price feeds, without existing price feed\n * contract owner is not able to add a new currency into the protocol\n */\ninterface ICurrencyController {\n    error InvalidCurrency();\n    error InvalidHaircut();\n    error InvalidPriceFeed();\n    error InvalidDecimals(address priceFeed, uint8 decimals);\n    error InvalidPriceFeedInputs();\n    error StalePriceFeed(\n        address priceFeed,\n        uint256 heartbeat,\n        uint256 updatedAt,\n        uint256 blockTimestamp\n    );\n\n    event CurrencyAdded(bytes32 indexed ccy, uint256 haircut);\n    event CurrencyRemoved(bytes32 indexed ccy);\n\n    event HaircutUpdated(bytes32 indexed ccy, uint256 haircut);\n\n    event PriceFeedUpdated(bytes32 ccy, uint256 decimals, address[] indexed priceFeeds);\n\n    function convert(\n        bytes32 _fromCcy,\n        bytes32 _toCcy,\n        uint256 _amount\n    ) external view returns (uint256 amount);\n\n    function convert(\n        bytes32 _fromCcy,\n        bytes32 _toCcy,\n        uint256[] calldata _amounts\n    ) external view returns (uint256[] memory amounts);\n\n    function convertToBaseCurrency(\n        bytes32 _ccy,\n        uint256 _amount\n    ) external view returns (uint256 amount);\n\n    function convertToBaseCurrency(\n        bytes32 _ccy,\n        int256 _amount\n    ) external view returns (int256 amount);\n\n    function convertToBaseCurrency(\n        bytes32 _ccy,\n        uint256[] calldata _amounts\n    ) external view returns (uint256[] memory amounts);\n\n    function convertFromBaseCurrency(\n        bytes32 _ccy,\n        uint256 _amountETH\n    ) external view returns (uint256 amount);\n\n    function convertFromBaseCurrency(\n        bytes32 _ccy,\n        uint256[] calldata _amounts\n    ) external view returns (uint256[] memory amounts);\n\n    function getDecimals(bytes32) external view returns (uint8);\n\n    function getCurrencies() external view returns (bytes32[] memory);\n\n    function getHaircut(bytes32 _ccy) external view returns (uint256);\n\n    function getPriceFeed(bytes32 _ccy) external view returns (PriceFeed memory);\n\n    function getLastPrice(bytes32 _ccy) external view returns (int256 price);\n\n    function getAggregatedLastPrice(bytes32 _ccy) external view returns (int256);\n\n    function currencyExists(bytes32 _ccy) external view returns (bool);\n\n    function updatePriceFeed(\n        bytes32 _ccy,\n        uint8 _decimals,\n        address[] calldata _priceFeeds,\n        uint256[] calldata _heartbeats\n    ) external;\n\n    function addCurrency(\n        bytes32 _ccy,\n        uint8 _decimals,\n        uint256 _haircut,\n        address[] calldata _priceFeeds,\n        uint256[] calldata _heartbeats\n    ) external;\n\n    function updateHaircut(bytes32 _ccy, uint256 _haircut) external;\n\n    function removeCurrency(bytes32 _ccy) external;\n}\n"
      },
      "contracts/protocol/interfaces/IGenesisValueVault.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {AutoRollLog} from \"../storages/GenesisValueVaultStorage.sol\";\n\ninterface IGenesisValueVault {\n    error NoCompoundFactorExists(uint256 maturity);\n    error CompoundFactorIsZero();\n    error ResidualAmountIsNotZero();\n    error UnitPriceIsZero();\n    error InvalidMaturity();\n    error InvalidAmount();\n    error InvalidOrderFeeRate();\n    error CurrencyAlreadyInitialized();\n    error InitialCompoundFactorAlreadyFinalized();\n    error AutoRollLogAlreadyUpdated(uint256 currentMaturity, uint256 nextMaturity);\n    error InsufficientBalance();\n    error InsufficientLockedBalance();\n\n    event Transfer(bytes32 indexed ccy, address indexed from, address indexed to, int256 value);\n    event AutoRollExecuted(\n        bytes32 indexed ccy,\n        uint256 lendingCompoundFactor,\n        uint256 borrowingCompoundFactor,\n        uint256 unitPrice,\n        uint256 currentMaturity,\n        uint256 previousMaturity\n    );\n    event BalanceLocked(bytes32 indexed ccy, address indexed user, uint256 value);\n    event BalanceUnlocked(bytes32 indexed ccy, address indexed user, uint256 value);\n\n    function isAutoRolled(bytes32 _ccy, uint256 _maturity) external view returns (bool);\n\n    function isInitialized(bytes32 ccy) external view returns (bool);\n\n    function decimals(bytes32 ccy) external view returns (uint8);\n\n    function getTotalLendingSupply(bytes32 ccy) external view returns (uint256);\n\n    function getTotalBorrowingSupply(bytes32 ccy) external view returns (uint256);\n\n    function getBalance(bytes32 ccy, address user) external view returns (int256);\n\n    function getMaturityGenesisValue(bytes32 ccy, uint256 maturity) external view returns (int256);\n\n    function getCurrentMaturity(bytes32 ccy) external view returns (uint256);\n\n    function getLendingCompoundFactor(bytes32 ccy) external view returns (uint256);\n\n    function getBorrowingCompoundFactor(bytes32 ccy) external view returns (uint256);\n\n    function getAutoRollLog(\n        bytes32 ccy,\n        uint256 maturity\n    ) external view returns (AutoRollLog memory);\n\n    function getLatestAutoRollLog(bytes32 ccy) external view returns (AutoRollLog memory);\n\n    function getTotalLockedBalance(bytes32 ccy) external view returns (uint256);\n\n    function calculateFVFromFV(\n        bytes32 ccy,\n        uint256 basisMaturity,\n        uint256 destinationMaturity,\n        int256 futureValue\n    ) external view returns (int256);\n\n    function calculateGVFromFV(\n        bytes32 ccy,\n        uint256 basisMaturity,\n        int256 futureValue\n    ) external view returns (int256);\n\n    function calculateFVFromGV(\n        bytes32 ccy,\n        uint256 basisMaturity,\n        int256 genesisValue\n    ) external view returns (int256);\n\n    function getBalanceFluctuationByAutoRolls(\n        bytes32 ccy,\n        address user,\n        uint256 maturity\n    ) external view returns (int256 fluctuation);\n\n    function calculateBalanceFluctuationByAutoRolls(\n        bytes32 ccy,\n        int256 balance,\n        uint256 fromMaturity,\n        uint256 toMaturity\n    ) external view returns (int256 fluctuation);\n\n    function initializeCurrencySetting(\n        bytes32 ccy,\n        uint8 decimals,\n        uint256 compoundFactor,\n        uint256 maturity\n    ) external;\n\n    function updateInitialCompoundFactor(bytes32 ccy, uint256 unitPrice) external;\n\n    function updateDecimals(bytes32 _ccy, uint8 _decimals) external;\n\n    function executeAutoRoll(\n        bytes32 ccy,\n        uint256 maturity,\n        uint256 nextMaturity,\n        uint256 unitPrice,\n        uint256 orderFeeRate\n    ) external;\n\n    function updateGenesisValueWithFutureValue(\n        bytes32 ccy,\n        address user,\n        uint256 basisMaturity,\n        int256 fvAmount\n    ) external;\n\n    function updateGenesisValueWithResidualAmount(\n        bytes32 ccy,\n        address user,\n        uint256 basisMaturity\n    ) external;\n\n    function lock(\n        bytes32 ccy,\n        address user,\n        uint256 amount\n    ) external returns (uint256 lockedAmount);\n\n    function unlock(bytes32 ccy, address user, uint256 amount) external;\n\n    function transferFrom(bytes32 ccy, address sender, address receiver, int256 amount) external;\n\n    function cleanUpBalance(bytes32 ccy, address user, uint256 maturity) external;\n\n    function executeForcedReset(bytes32 _ccy, address _user) external;\n\n    function executeForcedReset(\n        bytes32 _ccy,\n        uint256 _maturity,\n        address _user,\n        int256 _amountInFV\n    ) external returns (int256 removedAmount, int256 balance);\n}\n"
      },
      "contracts/protocol/interfaces/ILendingMarketController.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {ProtocolTypes} from \"../types/ProtocolTypes.sol\";\nimport {ZCTokenInfo, TerminationCurrencyCache} from \"../storages/LendingMarketControllerStorage.sol\";\n\ninterface ILendingMarketController {\n    error InvalidMaturity();\n    error InvalidCurrency();\n    error MarketTerminated();\n    error NotTerminated();\n    error AlreadyInitialized();\n\n    struct AdditionalFunds {\n        bytes32 ccy;\n        uint256 workingLendOrdersAmount;\n        uint256 claimableAmount;\n        uint256 workingBorrowOrdersAmount;\n        uint256 debtAmount;\n        uint256 lentAmount;\n        uint256 borrowedAmount;\n    }\n\n    struct CalculatedTotalFunds {\n        uint256 plusDepositAmountInAdditionalFundsCcy;\n        uint256 minusDepositAmountInAdditionalFundsCcy;\n        uint256 workingLendOrdersAmount;\n        uint256 claimableAmount;\n        uint256 collateralAmount;\n        uint256 lentAmount;\n        uint256 workingBorrowOrdersAmount;\n        uint256 debtAmount;\n        uint256 borrowedAmount;\n    }\n\n    struct CalculatedFunds {\n        uint256 workingLendOrdersAmount;\n        uint256 claimableAmount;\n        uint256 collateralAmount;\n        uint256 unallocatedCollateralAmount;\n        uint256 lentAmount;\n        uint256 workingBorrowOrdersAmount;\n        uint256 debtAmount;\n        uint256 borrowedAmount;\n    }\n\n    struct GetOrderEstimationParams {\n        bytes32 ccy;\n        uint256 maturity;\n        address user;\n        ProtocolTypes.Side side;\n        uint256 amount;\n        uint256 unitPrice;\n        uint256 additionalDepositAmount;\n        bool ignoreBorrowedAmount;\n    }\n\n    function isValidMaturity(bytes32 _ccy, uint256 _maturity) external view returns (bool);\n\n    function isTerminated() external view returns (bool);\n\n    function isRedemptionRequired(address _user) external view returns (bool);\n\n    function getMarketBasePeriod() external view returns (uint256);\n\n    function getTerminationDate() external view returns (uint256);\n\n    function getTerminationCurrencyCache(\n        bytes32 _ccy\n    ) external view returns (TerminationCurrencyCache memory);\n\n    function getTerminationCollateralRatio(bytes32 _ccy) external view returns (uint256);\n\n    function getMinDebtUnitPrice(bytes32 _ccy) external view returns (uint256);\n\n    function getCurrentMinDebtUnitPrice(\n        bytes32 _ccy,\n        uint256 _maturity\n    ) external view returns (uint256);\n\n    function getGenesisDate(bytes32 ccy) external view returns (uint256);\n\n    function getLendingMarket(bytes32 ccy) external view returns (address);\n\n    function getFutureValueVault(bytes32 ccy) external view returns (address);\n\n    function getOrderBookId(bytes32 _ccy, uint256 _maturity) external view returns (uint8);\n\n    function getPendingOrderAmount(bytes32 _ccy, uint256 _maturity) external view returns (uint256);\n\n    function getOrderEstimation(\n        GetOrderEstimationParams calldata params\n    )\n        external\n        view\n        returns (\n            uint256 lastUnitPrice,\n            uint256 filledAmount,\n            uint256 filledAmountInFV,\n            uint256 orderFeeInFV,\n            uint256 placedAmount,\n            uint256 coverage,\n            bool isInsufficientDepositAmount\n        );\n\n    function getMaturities(bytes32 ccy) external view returns (uint256[] memory);\n\n    function getOrderBookIds(bytes32 ccy) external view returns (uint8[] memory);\n\n    function getUsedCurrencies(address user) external view returns (bytes32[] memory);\n\n    function getTotalPresentValue(bytes32 ccy, address user) external view returns (int256);\n\n    function getTotalPresentValueInBaseCurrency(\n        address user\n    ) external view returns (int256 totalPresentValue);\n\n    function getGenesisValue(\n        bytes32 ccy,\n        address user\n    ) external view returns (int256 amount, int256 amountInPV, int256 amountInFV);\n\n    function getPosition(\n        bytes32 _ccy,\n        uint256 _maturity,\n        address _user\n    ) external view returns (int256 presentValue, int256 futureValue);\n\n    function getZCToken(bytes32 ccy, uint256 maturity) external view returns (address);\n\n    function getZCTokenInfo(address zcToken) external view returns (ZCTokenInfo memory);\n\n    function getWithdrawableZCTokenAmount(\n        bytes32 ccy,\n        uint256 maturity,\n        address user\n    ) external view returns (uint256 amount);\n\n    function calculateFunds(\n        bytes32 ccy,\n        address user,\n        uint256 liquidationThresholdRate\n    ) external view returns (CalculatedFunds memory funds);\n\n    function calculateTotalFundsInBaseCurrency(\n        address user,\n        AdditionalFunds calldata _additionalFunds,\n        uint256 liquidationThresholdRate\n    ) external view returns (CalculatedTotalFunds memory calculatedFunds);\n\n    function isInitializedLendingMarket(bytes32 ccy) external view returns (bool);\n\n    function initializeLendingMarket(\n        bytes32 ccy,\n        uint256 genesisDate,\n        uint256 compoundFactor,\n        uint256 orderFeeRate,\n        uint256 circuitBreakerLimitRange,\n        uint256 minDebtUnitPrice\n    ) external;\n\n    function createOrderBook(bytes32 ccy, uint256 openingDate, uint256 preOpeningDate) external;\n\n    function executeOrder(\n        bytes32 ccy,\n        uint256 maturity,\n        ProtocolTypes.Side side,\n        uint256 amount,\n        uint256 unitPrice\n    ) external returns (bool);\n\n    function depositAndExecuteOrder(\n        bytes32 ccy,\n        uint256 maturity,\n        ProtocolTypes.Side side,\n        uint256 amount,\n        uint256 unitPrice\n    ) external payable returns (bool);\n\n    function depositWithPermitAndExecuteOrder(\n        bytes32 ccy,\n        uint256 maturity,\n        ProtocolTypes.Side side,\n        uint256 amount,\n        uint256 unitPrice,\n        uint256 deadline,\n        uint8 permitV,\n        bytes32 permitR,\n        bytes32 permitS\n    ) external returns (bool);\n\n    function executePreOrder(\n        bytes32 ccy,\n        uint256 maturity,\n        ProtocolTypes.Side side,\n        uint256 amount,\n        uint256 unitPrice\n    ) external returns (bool);\n\n    function depositAndExecutesPreOrder(\n        bytes32 ccy,\n        uint256 maturity,\n        ProtocolTypes.Side side,\n        uint256 amount,\n        uint256 unitPrice\n    ) external payable returns (bool);\n\n    function depositWithPermitAndExecutePreOrder(\n        bytes32 _ccy,\n        uint256 _maturity,\n        ProtocolTypes.Side _side,\n        uint256 _amount,\n        uint256 _unitPrice,\n        uint256 _deadline,\n        uint8 _permitV,\n        bytes32 _permitR,\n        bytes32 _permitS\n    ) external returns (bool);\n\n    function unwindPosition(bytes32 ccy, uint256 maturity) external returns (bool);\n\n    function executeItayoseCall(bytes32 ccy, uint256 maturity) external returns (bool);\n\n    function executeRedemption(bytes32 _ccy, uint256 _maturity) external returns (bool);\n\n    function executeRepayment(bytes32 _ccy, uint256 _maturity) external returns (bool);\n\n    function executeEmergencySettlement() external returns (bool);\n\n    function executeLiquidationCall(\n        bytes32 collateralCcy,\n        bytes32 debtCcy,\n        uint256 debtMaturity,\n        address user\n    ) external returns (bool);\n\n    function executeForcedRepayment(\n        bytes32 _collateralCcy,\n        bytes32 _debtCcy,\n        uint256 _debtMaturity,\n        address _user\n    ) external returns (bool);\n\n    function cancelOrder(bytes32 ccy, uint256 maturity, uint48 orderId) external returns (bool);\n\n    function rotateOrderBooks(bytes32 ccy) external;\n\n    function executeEmergencyTermination() external;\n\n    function pauseLendingMarket(bytes32 ccy) external returns (bool);\n\n    function unpauseLendingMarket(bytes32 ccy) external returns (bool);\n\n    function cleanUpAllFunds(address user) external returns (bool);\n\n    function cleanUpFunds(bytes32 ccy, address user) external returns (uint256 activeOrderCount);\n\n    function updateMinDebtUnitPrice(bytes32 _ccy, uint256 _minDebtUnitPrice) external;\n\n    function withdrawZCToken(bytes32 _ccy, uint256 _maturity, uint256 _amount) external;\n\n    function depositZCToken(bytes32 _ccy, uint256 _maturity, uint256 _amount) external;\n}\n"
      },
      "contracts/protocol/interfaces/INativeToken.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport \"../../dependencies/openzeppelin/token/ERC20/IERC20.sol\";\n\ninterface INativeToken is IERC20 {\n    event Deposit(address user, uint256 amount);\n    event Withdrawal(address user, uint256 amount);\n\n    function deposit() external payable;\n\n    function withdraw(uint256 amount) external;\n}\n"
      },
      "contracts/protocol/interfaces/IReserveFund.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\ninterface IReserveFund {\n    event Pause(address account);\n    event Unpause(address account);\n\n    function isPaused() external view returns (bool);\n\n    function pause() external;\n\n    function unpause() external;\n\n    function deposit(bytes32 ccy, uint256 amount) external payable;\n\n    function withdraw(bytes32 ccy, uint256 amount) external;\n}\n"
      },
      "contracts/protocol/interfaces/ITokenVault.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {ProtocolTypes} from \"../types/ProtocolTypes.sol\";\nimport {ILendingMarketController} from \"../interfaces/ILendingMarketController.sol\";\n\ninterface ITokenVault {\n    error UnregisteredCurrency();\n    error InvalidCurrency();\n    error InvalidToken();\n    error InvalidAmount(bytes32 ccy, uint256 amount, uint256 msgValue);\n    error AmountIsZero();\n    error CallerNotBaseCurrency(address caller);\n    error MarketTerminated();\n    error RedemptionIsRequired();\n\n    event Deposit(address indexed user, bytes32 ccy, uint256 amount, address caller);\n    event Withdraw(address indexed user, bytes32 ccy, uint256 amount);\n    event Transfer(bytes32 indexed ccy, address indexed from, address indexed to, uint256 amount);\n    event CurrencyRegistered(bytes32 ccy, address tokenAddress, bool isCollateral);\n    event CurrencyUpdated(bytes32 ccy, bool isCollateral);\n\n    function isCovered(\n        address user,\n        bytes32 ccy\n    ) external view returns (bool isEnoughCollateral, bool isEnoughDepositInOrderCcy);\n\n    function isCollateral(bytes32 ccy) external view returns (bool);\n\n    function isCollateral(bytes32[] calldata ccys) external view returns (bool[] memory);\n\n    function isRegisteredCurrency(bytes32 ccy) external view returns (bool);\n\n    function getTokenAddress(bytes32 ccy) external view returns (address);\n\n    function getCollateralCurrencies() external view returns (bytes32[] memory);\n\n    function getWithdrawableCollateral(address user) external view returns (uint256);\n\n    function getWithdrawableCollateral(bytes32 ccy, address user) external view returns (uint256);\n\n    function getCoverage(address user) external view returns (uint256);\n\n    function getTotalUnusedCollateralAmount(address user) external view returns (uint256);\n\n    function getTotalCollateralAmount(address user) external view returns (uint256);\n\n    function getCollateralDetail(\n        address user\n    )\n        external\n        view\n        returns (uint256 totalCollateral, uint256 totalUsedCollateral, uint256 totalDeposit);\n\n    function getCollateralAmount(address user, bytes32 ccy) external view returns (uint256);\n\n    function getBorrowableAmount(address user, bytes32 ccy) external view returns (uint256);\n\n    function getLiquidationAmount(\n        address user,\n        bytes32 liquidationCcy,\n        uint256 liquidationAmountMaximum\n    ) external view returns (uint256 liquidationAmount, uint256 protocolFee, uint256 liquidatorFee);\n\n    function getTotalDepositAmount(bytes32 ccy) external view returns (uint256);\n\n    function getDepositAmount(address user, bytes32 ccy) external view returns (uint256);\n\n    function getUsedCurrencies(address user) external view returns (bytes32[] memory);\n\n    function calculateCoverage(\n        address user,\n        ILendingMarketController.AdditionalFunds memory funds\n    ) external view returns (uint256 coverage, bool isInsufficientDepositAmount);\n\n    function calculateLiquidationFees(\n        uint256 liquidationAmount\n    ) external view returns (uint256 protocolFee, uint256 liquidatorFee);\n\n    function registerCurrency(bytes32 ccy, address tokenAddress, bool isCollateral) external;\n\n    function updateCurrency(bytes32 ccy, bool isCollateral) external;\n\n    function deposit(bytes32 ccy, uint256 amount) external payable;\n\n    function depositTo(bytes32 ccy, uint256 amount, address onBehalfOf) external payable;\n\n    function depositFrom(address user, bytes32 ccy, uint256 amount) external payable;\n\n    function depositWithPermitTo(\n        bytes32 ccy,\n        uint256 amount,\n        address onBehalfOf,\n        uint256 deadline,\n        uint8 permitV,\n        bytes32 permitR,\n        bytes32 permitS\n    ) external;\n\n    function depositWithPermitFrom(\n        address user,\n        bytes32 ccy,\n        uint256 amount,\n        uint256 deadline,\n        uint8 permitV,\n        bytes32 permitR,\n        bytes32 permitS\n    ) external;\n\n    function withdraw(bytes32 ccy, uint256 amount) external;\n\n    function addDepositAmount(address user, bytes32 ccy, uint256 amount) external;\n\n    function removeDepositAmount(address user, bytes32 ccy, uint256 amount) external;\n\n    function cleanUpUsedCurrencies(address user, bytes32 ccy) external;\n\n    function executeForcedReset(address user, bytes32 ccy) external returns (uint256 removedAmount);\n\n    function transferFrom(\n        bytes32 ccy,\n        address sender,\n        address receiver,\n        uint256 amount\n    ) external returns (uint256 untransferredAmount);\n\n    function pause() external;\n\n    function unpause() external;\n\n    function getLiquidationThresholdRate() external view returns (uint256 rate);\n}\n"
      },
      "contracts/protocol/libraries/AddressResolverLib.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {Contracts} from \"../libraries/Contracts.sol\";\nimport {IBeaconProxyController} from \"../interfaces/IBeaconProxyController.sol\";\nimport {ICurrencyController} from \"../interfaces/ICurrencyController.sol\";\nimport {IGenesisValueVault} from \"../interfaces/IGenesisValueVault.sol\";\nimport {ILendingMarketController} from \"../interfaces/ILendingMarketController.sol\";\nimport {IReserveFund} from \"../interfaces/IReserveFund.sol\";\nimport {ITokenVault} from \"../interfaces/ITokenVault.sol\";\nimport {MixinAddressResolverStorage as Storage} from \"../storages/mixins/MixinAddressResolverStorage.sol\";\n\nlibrary AddressResolverLib {\n    error MissingAddress(string name);\n\n    function getAddress(bytes32 name) internal view returns (address) {\n        address _foundAddress = Storage.slot().addressCache[name];\n        if (_foundAddress == address(0)) revert MissingAddress(string(abi.encodePacked(name)));\n        return _foundAddress;\n    }\n\n    function beaconProxyController() internal view returns (IBeaconProxyController) {\n        return IBeaconProxyController(getAddress(Contracts.BEACON_PROXY_CONTROLLER));\n    }\n\n    function currencyController() internal view returns (ICurrencyController) {\n        return ICurrencyController(getAddress(Contracts.CURRENCY_CONTROLLER));\n    }\n\n    function genesisValueVault() internal view returns (IGenesisValueVault) {\n        return IGenesisValueVault(getAddress(Contracts.GENESIS_VALUE_VAULT));\n    }\n\n    function lendingMarketController() internal view returns (ILendingMarketController) {\n        return ILendingMarketController(getAddress(Contracts.LENDING_MARKET_CONTROLLER));\n    }\n\n    function reserveFund() internal view returns (IReserveFund) {\n        return IReserveFund(getAddress(Contracts.RESERVE_FUND));\n    }\n\n    function tokenVault() internal view returns (ITokenVault) {\n        return ITokenVault(getAddress(Contracts.TOKEN_VAULT));\n    }\n}\n"
      },
      "contracts/protocol/libraries/Constants.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nlibrary Constants {\n    /// @dev Used for price digits in the basis (10000 -> 1)\n    uint256 internal constant PRICE_DIGIT = 10000;\n\n    /// @dev Used for percentage digits in the basis (10000 -> 100%)\n    uint256 internal constant PCT_DIGIT = 10000;\n\n    /// @dev Used for seconds in year (60 * 60 * 24 * 365)\n    uint256 internal constant SECONDS_IN_YEAR = 31536000;\n\n    /// @dev Used for maximum order count per currency\n    uint256 internal constant MAXIMUM_ORDER_COUNT = 20;\n}\n"
      },
      "contracts/protocol/libraries/Contracts.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nlibrary Contracts {\n    bytes32 internal constant BEACON_PROXY_CONTROLLER = \"BeaconProxyController\";\n    bytes32 internal constant CURRENCY_CONTROLLER = \"CurrencyController\";\n    bytes32 internal constant GENESIS_VALUE_VAULT = \"GenesisValueVault\";\n    bytes32 internal constant LENDING_MARKET_CONTROLLER = \"LendingMarketController\";\n    bytes32 internal constant RESERVE_FUND = \"ReserveFund\";\n    bytes32 internal constant TOKEN_VAULT = \"TokenVault\";\n}\n\nlibrary BeaconContracts {\n    bytes32 internal constant FUTURE_VALUE_VAULT = \"FutureValueVault\";\n    bytes32 internal constant LENDING_MARKET = \"LendingMarket\";\n    bytes32 internal constant ZC_TOKEN = \"ZCToken\";\n}\n"
      },
      "contracts/protocol/libraries/logics/DepositManagementLogic.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\n// dependencies\nimport {EnumerableSet} from \"../../../dependencies/openzeppelin/utils/structs/EnumerableSet.sol\";\n// interfaces\nimport {ILendingMarketController} from \"../../interfaces/ILendingMarketController.sol\";\n// libraries\nimport {AddressResolverLib} from \"../AddressResolverLib.sol\";\nimport {TransferHelper} from \"../TransferHelper.sol\";\nimport {Constants} from \"../Constants.sol\";\nimport {RoundingUint256} from \"../math/RoundingUint256.sol\";\n// storages\nimport {TokenVaultStorage as Storage} from \"../../storages/TokenVaultStorage.sol\";\n\nlibrary DepositManagementLogic {\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n    using RoundingUint256 for uint256;\n\n    error NotEnoughDeposit(bytes32 ccy);\n    error ProtocolIsInsolvent(bytes32 ccy);\n\n    struct CalculatedFundVars {\n        uint256 plusDepositAmountInAdditionalFundsCcy;\n        uint256 minusDepositAmountInAdditionalFundsCcy;\n        uint256 workingLendOrdersAmount;\n        uint256 collateralAmount;\n        uint256 lentAmount;\n        uint256 workingBorrowOrdersAmount;\n        uint256 debtAmount;\n        uint256 borrowedAmount;\n    }\n\n    function isCovered(\n        address _user,\n        bytes32 _orderCcy\n    ) public view returns (bool isEnoughCollateral, bool isEnoughDepositInOrderCcy) {\n        ILendingMarketController.AdditionalFunds memory _funds;\n        _funds.ccy = _orderCcy;\n\n        (\n            uint256 totalCollateral,\n            uint256 totalUsedCollateral,\n            ,\n            bool isInsufficientDepositAmount\n        ) = _calculateCollateral(_user, _funds);\n\n        isEnoughDepositInOrderCcy = !isInsufficientDepositAmount;\n        isEnoughCollateral =\n            totalUsedCollateral == 0 ||\n            (totalCollateral * Constants.PCT_DIGIT >=\n                totalUsedCollateral * Storage.slot().liquidationThresholdRate);\n    }\n\n    function getUsedCurrencies(address _user) public view returns (bytes32[] memory) {\n        return Storage.slot().usedCurrencies[_user].values();\n    }\n\n    function getDepositAmount(address _user, bytes32 _ccy) public view returns (uint256) {\n        ILendingMarketController.CalculatedFunds memory funds = AddressResolverLib\n            .lendingMarketController()\n            .calculateFunds(_ccy, _user, Storage.slot().liquidationThresholdRate);\n\n        return\n            Storage.slot().depositAmounts[_user][_ccy] +\n            funds.borrowedAmount -\n            funds.lentAmount -\n            funds.workingLendOrdersAmount;\n    }\n\n    function getTotalCollateralAmount(\n        address _user\n    )\n        public\n        view\n        returns (uint256 totalCollateral, uint256 totalUsedCollateral, uint256 totalDeposit)\n    {\n        ILendingMarketController.AdditionalFunds memory _funds;\n        (totalCollateral, totalUsedCollateral, totalDeposit, ) = _calculateCollateral(\n            _user,\n            _funds\n        );\n    }\n\n    function getCollateralAmount(\n        address _user,\n        bytes32 _ccy\n    )\n        public\n        view\n        returns (uint256 totalCollateral, uint256 totalUsedCollateral, uint256 totalDeposit)\n    {\n        ILendingMarketController.CalculatedFunds memory funds = AddressResolverLib\n            .lendingMarketController()\n            .calculateFunds(_ccy, _user, Storage.slot().liquidationThresholdRate);\n\n        uint256 plusDeposit = Storage.slot().depositAmounts[_user][_ccy] + funds.borrowedAmount;\n        uint256 minusDeposit = funds.workingLendOrdersAmount + funds.lentAmount;\n        uint256 plusCollateral = plusDeposit + funds.collateralAmount;\n\n        totalCollateral = plusCollateral >= minusDeposit ? plusCollateral - minusDeposit : 0;\n        totalUsedCollateral = funds.workingBorrowOrdersAmount + funds.debtAmount;\n        totalDeposit = plusDeposit >= minusDeposit ? plusDeposit - minusDeposit : 0;\n    }\n\n    function getCoverage(address _user) external view returns (uint256 coverage) {\n        ILendingMarketController.AdditionalFunds memory _emptyAdditionalFunds;\n        (coverage, ) = calculateCoverage(_user, _emptyAdditionalFunds);\n    }\n\n    function getTotalUnusedCollateralAmount(address _user) public view returns (uint256) {\n        (uint256 totalCollateral, uint256 totalUsedCollateral, ) = getTotalCollateralAmount(_user);\n\n        return totalCollateral > totalUsedCollateral ? totalCollateral - totalUsedCollateral : 0;\n    }\n\n    function getBorrowableAmount(address _user, bytes32 _ccy) external view returns (uint256) {\n        uint256[] memory amounts = new uint256[](2);\n        (amounts[0], amounts[1], ) = getTotalCollateralAmount(_user);\n        amounts = AddressResolverLib.currencyController().convertFromBaseCurrency(_ccy, amounts);\n\n        uint256 totalCollateralAmount = amounts[0];\n        uint256 totalUsedCollateral = amounts[1];\n        uint256 liquidationThresholdRate = Storage.slot().liquidationThresholdRate;\n\n        ILendingMarketController.CalculatedFunds memory funds = AddressResolverLib\n            .lendingMarketController()\n            .calculateFunds(_ccy, _user, liquidationThresholdRate);\n\n        uint256 unusedCollateralAmount = funds.claimableAmount > funds.collateralAmount\n            ? funds.claimableAmount - funds.collateralAmount\n            : 0;\n\n        uint256 borrowableAmount = ((totalCollateralAmount + unusedCollateralAmount) *\n            Constants.PCT_DIGIT).div(liquidationThresholdRate);\n\n        return borrowableAmount > totalUsedCollateral ? borrowableAmount - totalUsedCollateral : 0;\n    }\n\n    function calculateCoverage(\n        address _user,\n        ILendingMarketController.AdditionalFunds memory _additionalFunds\n    ) public view returns (uint256 coverage, bool isInsufficientDepositAmount) {\n        uint256 totalCollateral;\n        uint256 totalUsedCollateral;\n\n        (\n            totalCollateral,\n            totalUsedCollateral,\n            ,\n            isInsufficientDepositAmount\n        ) = _calculateCollateral(_user, _additionalFunds);\n\n        if (totalCollateral == 0) {\n            coverage = totalUsedCollateral == 0 ? 0 : type(uint256).max;\n        } else {\n            coverage = (totalUsedCollateral * Constants.PCT_DIGIT) / totalCollateral;\n        }\n    }\n\n    function _calculateCollateral(\n        address _user,\n        ILendingMarketController.AdditionalFunds memory _funds\n    )\n        internal\n        view\n        returns (\n            uint256 totalCollateral,\n            uint256 totalUsedCollateral,\n            uint256 totalDeposit,\n            bool isInsufficientDepositAmount\n        )\n    {\n        CalculatedFundVars memory vars;\n\n        ILendingMarketController.CalculatedTotalFunds memory funds = AddressResolverLib\n            .lendingMarketController()\n            .calculateTotalFundsInBaseCurrency(\n                _user,\n                _funds,\n                Storage.slot().liquidationThresholdRate\n            );\n\n        vars.plusDepositAmountInAdditionalFundsCcy = funds.plusDepositAmountInAdditionalFundsCcy;\n        vars.minusDepositAmountInAdditionalFundsCcy = funds.minusDepositAmountInAdditionalFundsCcy;\n        vars.workingLendOrdersAmount = funds.workingLendOrdersAmount;\n        vars.collateralAmount = funds.collateralAmount;\n        vars.lentAmount = funds.lentAmount;\n        vars.workingBorrowOrdersAmount = funds.workingBorrowOrdersAmount;\n        vars.debtAmount = funds.debtAmount;\n        vars.borrowedAmount = funds.borrowedAmount;\n\n        // Check if the user has enough deposit amount in the selected currency.\n        if (\n            vars.plusDepositAmountInAdditionalFundsCcy +\n                Storage.slot().depositAmounts[_user][_funds.ccy] <\n            vars.minusDepositAmountInAdditionalFundsCcy\n        ) {\n            isInsufficientDepositAmount = true;\n        }\n\n        uint256 totalInternalDepositAmount = _getTotalInternalDepositAmountInBaseCurrency(_user);\n\n        uint256 plusDeposit = totalInternalDepositAmount + vars.borrowedAmount;\n        uint256 minusDeposit = vars.workingLendOrdersAmount + vars.lentAmount;\n        uint256 plusCollateral = plusDeposit + vars.collateralAmount;\n\n        totalCollateral = plusCollateral >= minusDeposit ? plusCollateral - minusDeposit : 0;\n        totalUsedCollateral = vars.workingBorrowOrdersAmount + vars.debtAmount;\n        totalDeposit = plusDeposit >= minusDeposit ? plusDeposit - minusDeposit : 0;\n    }\n\n    function getWithdrawableCollateral(address _user) public view returns (uint256) {\n        (\n            uint256 totalCollateral,\n            uint256 totalUsedCollateral,\n            uint256 totalDeposit\n        ) = getTotalCollateralAmount(_user);\n\n        if (totalUsedCollateral == 0) {\n            return totalDeposit;\n        } else if (\n            totalCollateral * Constants.PCT_DIGIT >\n            totalUsedCollateral * Storage.slot().liquidationThresholdRate\n        ) {\n            // NOTE: The formula is:\n            // maxWithdraw = totalCollateral - (totalUsedCollateral * liquidationThresholdRate)\n            uint256 maxWithdraw = (totalCollateral *\n                Constants.PCT_DIGIT -\n                totalUsedCollateral *\n                Storage.slot().liquidationThresholdRate).div(Constants.PCT_DIGIT);\n\n            return maxWithdraw >= totalDeposit ? totalDeposit : maxWithdraw;\n        } else {\n            return 0;\n        }\n    }\n\n    function getWithdrawableCollateral(\n        bytes32 _ccy,\n        address _user\n    ) public view returns (uint256 withdrawableAmount) {\n        uint256 depositAmount = getDepositAmount(_user, _ccy);\n        if (Storage.slot().collateralCurrencies.contains(_ccy)) {\n            uint256 maxWithdrawInBaseCurrency = getWithdrawableCollateral(_user);\n            uint256 maxWithdraw = AddressResolverLib.currencyController().convertFromBaseCurrency(\n                _ccy,\n                maxWithdrawInBaseCurrency\n            );\n\n            withdrawableAmount = depositAmount >= maxWithdraw ? maxWithdraw : depositAmount;\n        } else {\n            withdrawableAmount = depositAmount;\n        }\n    }\n\n    function addDepositAmount(address _user, bytes32 _ccy, uint256 _amount) public {\n        Storage.slot().depositAmounts[_user][_ccy] += _amount;\n        Storage.slot().usedCurrencies[_user].add(_ccy);\n    }\n\n    function removeDepositAmount(address _user, bytes32 _ccy, uint256 _amount) public {\n        if (Storage.slot().depositAmounts[_user][_ccy] < _amount) {\n            revert NotEnoughDeposit({ccy: _ccy});\n        }\n\n        Storage.slot().depositAmounts[_user][_ccy] -= _amount;\n    }\n\n    function executeForcedReset(\n        address _user,\n        bytes32 _ccy\n    ) external returns (uint256 removedAmount) {\n        removedAmount = Storage.slot().depositAmounts[_user][_ccy];\n        Storage.slot().depositAmounts[_user][_ccy] = 0;\n\n        Storage.slot().usedCurrencies[_user].remove(_ccy);\n    }\n\n    function deposit(address _caller, bytes32 _ccy, uint256 _amount, address _onBehalfOf) public {\n        TransferHelper.depositAssets(\n            Storage.slot().tokenAddresses[_ccy],\n            _caller,\n            address(this),\n            _amount\n        );\n\n        addDepositAmount(_onBehalfOf, _ccy, _amount);\n        Storage.slot().totalDepositAmount[_ccy] += _amount;\n    }\n\n    function withdraw(\n        address _user,\n        bytes32 _ccy,\n        uint256 _amount\n    ) public returns (uint256 withdrawableAmount) {\n        withdrawableAmount = getWithdrawableCollateral(_ccy, _user);\n        withdrawableAmount = _amount > withdrawableAmount ? withdrawableAmount : _amount;\n\n        if (Storage.slot().totalDepositAmount[_ccy] < withdrawableAmount) {\n            revert ProtocolIsInsolvent({ccy: _ccy});\n        }\n\n        Storage.slot().totalDepositAmount[_ccy] -= withdrawableAmount;\n        removeDepositAmount(_user, _ccy, withdrawableAmount);\n\n        TransferHelper.withdrawAssets(\n            Storage.slot().tokenAddresses[_ccy],\n            _user,\n            withdrawableAmount\n        );\n\n        return withdrawableAmount;\n    }\n\n    function getLiquidationAmount(\n        address _user,\n        bytes32 _liquidationCcy,\n        uint256 _liquidationAmountMaximum\n    ) public view returns (uint256 liquidationAmount, uint256 protocolFee, uint256 liquidatorFee) {\n        (\n            uint256 totalCollateralInBaseCcy,\n            uint256 totalUsedCollateralInBaseCcy,\n\n        ) = getTotalCollateralAmount(_user);\n\n        if (totalUsedCollateralInBaseCcy == 0) {\n            return (0, 0, 0);\n        }\n\n        (uint256 collateralAmount, , ) = getCollateralAmount(_user, _liquidationCcy);\n\n        if (collateralAmount == 0) {\n            return (0, 0, 0);\n        }\n\n        uint256 liquidationAmountInBaseCcy = 0;\n        uint256 coveredRatio = (totalCollateralInBaseCcy * Constants.PCT_DIGIT).div(\n            totalUsedCollateralInBaseCcy\n        );\n\n        if (coveredRatio < Storage.slot().fullLiquidationThresholdRate) {\n            liquidationAmountInBaseCcy = totalUsedCollateralInBaseCcy;\n        } else if (coveredRatio < Storage.slot().liquidationThresholdRate) {\n            liquidationAmountInBaseCcy = totalUsedCollateralInBaseCcy.div(2);\n        }\n\n        uint256[] memory amountsInBaseCcy = new uint256[](2);\n        amountsInBaseCcy[0] = liquidationAmountInBaseCcy;\n        amountsInBaseCcy[1] = totalCollateralInBaseCcy;\n\n        uint256[] memory amounts = AddressResolverLib.currencyController().convertFromBaseCurrency(\n            _liquidationCcy,\n            amountsInBaseCcy\n        );\n\n        liquidationAmount = amounts[0];\n        uint256 totalCollateralAmount = amounts[1];\n\n        if (liquidationAmount > _liquidationAmountMaximum) {\n            liquidationAmount = _liquidationAmountMaximum;\n        }\n\n        (protocolFee, liquidatorFee) = calculateLiquidationFees(liquidationAmount);\n\n        uint256 liquidationTotalAmount = liquidationAmount + protocolFee + liquidatorFee;\n\n        // NOTE: If `totalCollateralAmount > collateralAmount` is true, it means that a user has collateral in other currencies\n        // In this case, this liquidation is not covered by the reserve fund.\n        // Therefore, we need to keep the total liquidation amount within the maximum amount.\n        if (liquidationTotalAmount > collateralAmount && totalCollateralAmount > collateralAmount) {\n            liquidationTotalAmount = collateralAmount;\n            uint256 liquidatorFeeRate = Storage.slot().liquidatorFeeRate;\n            uint256 liquidationProtocolFeeRate = Storage.slot().liquidationProtocolFeeRate;\n\n            protocolFee = (liquidationTotalAmount * liquidationProtocolFeeRate).div(\n                Constants.PCT_DIGIT + liquidatorFeeRate + liquidationProtocolFeeRate\n            );\n            liquidatorFee = (liquidationTotalAmount * liquidatorFeeRate).div(\n                Constants.PCT_DIGIT + liquidatorFeeRate + liquidationProtocolFeeRate\n            );\n            liquidationAmount = liquidationTotalAmount - protocolFee - liquidatorFee;\n        }\n    }\n\n    function calculateLiquidationFees(\n        uint256 _amount\n    ) public view returns (uint256 protocolFee, uint256 liquidatorFee) {\n        protocolFee = (_amount * Storage.slot().liquidationProtocolFeeRate).div(\n            Constants.PCT_DIGIT\n        );\n        liquidatorFee = (_amount * Storage.slot().liquidatorFeeRate).div(Constants.PCT_DIGIT);\n    }\n\n    function transferFrom(\n        bytes32 _ccy,\n        address _from,\n        address _to,\n        uint256 _amount\n    ) external returns (uint256 untransferredAmount) {\n        uint256 depositAmount = getDepositAmount(_from, _ccy);\n        uint256 amount = depositAmount >= _amount ? _amount : depositAmount;\n        untransferredAmount = _amount - amount;\n\n        removeDepositAmount(_from, _ccy, amount);\n        addDepositAmount(_to, _ccy, amount);\n    }\n\n    function cleanUpUsedCurrencies(address _user, bytes32 _ccy) external {\n        if (Storage.slot().depositAmounts[_user][_ccy] == 0) {\n            Storage.slot().usedCurrencies[_user].remove(_ccy);\n        }\n    }\n\n    /**\n     * @notice Gets the total of amount deposited in the user's collateral of all currencies\n     *  in this contract by converting it to ETH.\n     * @param _user Address of collateral user\n     * @return totalDepositAmount The total deposited amount in the base currency\n     */\n    function _getTotalInternalDepositAmountInBaseCurrency(\n        address _user\n    ) internal view returns (uint256 totalDepositAmount) {\n        EnumerableSet.Bytes32Set storage currencies = Storage.slot().usedCurrencies[_user];\n        uint256 length = currencies.length();\n\n        for (uint256 i; i < length; i++) {\n            bytes32 ccy = currencies.at(i);\n            if (Storage.slot().collateralCurrencies.contains(ccy)) {\n                uint256 depositAmount = Storage.slot().depositAmounts[_user][ccy];\n                totalDepositAmount += AddressResolverLib.currencyController().convertToBaseCurrency(\n                    ccy,\n                    depositAmount\n                );\n            }\n        }\n\n        return totalDepositAmount;\n    }\n}\n"
      },
      "contracts/protocol/libraries/math/RoundingUint256.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nlibrary RoundingUint256 {\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b > 0);\n\n        if ((a * 10) / b - (a / b) * 10 < 5) {\n            return a / b;\n        } else {\n            return (a / b) + 1;\n        }\n    }\n}\n"
      },
      "contracts/protocol/libraries/TransferHelper.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {INativeToken} from \"../interfaces/INativeToken.sol\";\nimport {TransferHelperStorage as Storage} from \"../storages/libraries/TransferHelperStorage.sol\";\n\nlibrary TransferHelper {\n    function initialize(address _nativeToken) internal {\n        require(Storage.slot().nativeToken == address(0), \"TransferHelper: Already initialized\");\n        Storage.slot().nativeToken = _nativeToken;\n    }\n\n    function nativeToken() internal view returns (address) {\n        return Storage.slot().nativeToken;\n    }\n\n    function isNative(address _token) internal view returns (bool) {\n        return _token == Storage.slot().nativeToken;\n    }\n\n    function depositAssets(\n        address _token,\n        address _payer,\n        address _receiver,\n        uint256 _amount\n    ) internal {\n        if (address(_token) == Storage.slot().nativeToken) {\n            convertToWrappedToken(_receiver, _amount);\n        } else {\n            safeTransferFrom(_token, _payer, _receiver, _amount);\n        }\n    }\n\n    function withdrawAssets(address _token, address _receiver, uint256 _amount) internal {\n        if (address(_token) == Storage.slot().nativeToken) {\n            convertFromWrappedToken(_receiver, _amount);\n        } else {\n            safeTransfer(_token, _receiver, _amount);\n        }\n    }\n\n    function convertToWrappedToken(address _receiver, uint256 _amount) internal {\n        require(address(this).balance >= _amount, \"TransferHelper: Insufficient balance\");\n\n        INativeToken(Storage.slot().nativeToken).deposit{value: _amount}();\n        safeTransfer(Storage.slot().nativeToken, _receiver, _amount);\n    }\n\n    function convertFromWrappedToken(address _receiver, uint256 _amount) internal {\n        uint256 balance = INativeToken(Storage.slot().nativeToken).balanceOf(address(this));\n        require(balance >= _amount, \"TransferHelper: Insufficient balance\");\n\n        if (balance > 0) {\n            INativeToken(Storage.slot().nativeToken).withdraw(_amount);\n            safeTransferETH(_receiver, _amount);\n        }\n    }\n\n    /// @dev Transfer helper from UniswapV2 Router\n    function safeApprove(address token, address to, uint256 value) internal {\n        // bytes4(keccak256(bytes('approve(address,uint256)')));\n        (bool success, bytes memory data) = token.call(\n            abi.encodeWithSelector(0x095ea7b3, to, value)\n        );\n        require(\n            success && (data.length == 0 || abi.decode(data, (bool))),\n            \"TransferHelper: APPROVE_FAILED\"\n        );\n    }\n\n    /**\n     * There are many non-compliant ERC20 tokens... this can handle most, adapted from UniSwap V2\n     * Im trying to make it a habit to put external calls last (reentrancy)\n     * You can put this in an internal function if you like.\n     */\n    function safeTransfer(address token, address to, uint256 amount) internal {\n        // solium-disable-next-line security/no-low-level-calls\n        (bool success, bytes memory data) = token.call(\n            // 0xa9059cbb = bytes4(keccak256(\"transfer(address,uint256)\"))\n            abi.encodeWithSelector(0xa9059cbb, to, amount)\n        );\n        require(\n            success && (data.length == 0 || abi.decode(data, (bool))),\n            \"TransferHelper: TRANSFER_FAILED\"\n        ); // ERC20 Transfer failed\n    }\n\n    function safeTransferFrom(address token, address from, address to, uint256 value) internal {\n        (bool success, bytes memory data) = token.call(\n            abi.encodeWithSelector(0x23b872dd, from, to, value)\n        );\n        require(\n            success && (data.length == 0 || abi.decode(data, (bool))),\n            \"TransferHelper: TRANSFER_FROM_FAILED\"\n        );\n    }\n\n    function safeTransferETH(address to, uint256 value) internal {\n        (bool success, ) = to.call{value: value}(new bytes(0));\n        require(success, \"TransferHelper: ETH_TRANSFER_FAILED\");\n    }\n}\n"
      },
      "contracts/protocol/mixins/MixinAccessControl.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {AccessControl} from \"../utils/AccessControl.sol\";\n\n/**\n * @notice Implements functions to add  role-based access control mechanisms.\n */\ncontract MixinAccessControl is AccessControl {\n    error CallerNotOperator();\n    error NotAllowedAccess(bytes32 role, address account);\n\n    bytes32 public constant OPERATOR_ROLE = keccak256(\"OPERATOR_ROLE\");\n\n    /**\n     * @dev Throws if called by any account other than the admin.\n     */\n    modifier onlyOperator() {\n        if (!hasRole(OPERATOR_ROLE, msg.sender)) revert CallerNotOperator();\n        _;\n    }\n\n    /**\n     * @dev Initializes the roles.\n     * @param _admin The address of the admin role\n     */\n    function _setupInitialRoles(address _admin) internal {\n        _grantRole(DEFAULT_ADMIN_ROLE, _admin);\n        _grantRole(OPERATOR_ROLE, _admin);\n    }\n\n    /**\n     * @notice Adds a new admin as Operator\n     * @param admin The address of the new admin\n     */\n    function addOperator(address admin) external {\n        super.grantRole(OPERATOR_ROLE, admin);\n    }\n\n    /**\n     * @notice Removes an admin as Operator\n     * @param admin The address of the admin to remove\n     */\n    function removeOperator(address admin) external {\n        revokeRole(OPERATOR_ROLE, admin);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     * @param role The role to be revoked\n     * @param account The address of the account to revoke the role from\n     */\n    function revokeRole(bytes32 role, address account) public override {\n        if (account == msg.sender) revert NotAllowedAccess(role, account);\n\n        super.revokeRole(role, account);\n    }\n\n    /**\n     * @notice Revokes `role` from the calling account. This function is disabled by overriding it with a revert.\n     * @param role The role to be revoked\n     * @param account The address of the account to revoke the role from\n     */\n    function renounceRole(bytes32 role, address account) public pure override {\n        revert NotAllowedAccess(role, account);\n    }\n}\n"
      },
      "contracts/protocol/mixins/MixinAddressResolver.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {AddressResolverLib} from \"../libraries/AddressResolverLib.sol\";\nimport {IAddressResolver} from \"../interfaces/IAddressResolver.sol\";\nimport {IBeaconProxyController} from \"../interfaces/IBeaconProxyController.sol\";\nimport {ICurrencyController} from \"../interfaces/ICurrencyController.sol\";\nimport {IGenesisValueVault} from \"../interfaces/IGenesisValueVault.sol\";\nimport {ILendingMarketController} from \"../interfaces/ILendingMarketController.sol\";\nimport {IReserveFund} from \"../interfaces/IReserveFund.sol\";\nimport {ITokenVault} from \"../interfaces/ITokenVault.sol\";\nimport {MixinAddressResolverStorage as Storage} from \"../storages/mixins/MixinAddressResolverStorage.sol\";\n\ncontract MixinAddressResolver {\n    event CacheUpdated(bytes32 name, address destination);\n\n    error OnlyAcceptedContract(string name);\n    error ResolverAlreadyRegistered();\n\n    modifier onlyLendingMarketController() {\n        if (msg.sender != address(AddressResolverLib.lendingMarketController()))\n            revert OnlyAcceptedContract(\"LendingMarketController\");\n        _;\n    }\n\n    /**\n     * @notice Returns the contract names used in this contract.\n     * @dev The contract name list is in `./libraries/Contracts.sol`.\n     */\n    function requiredContracts() public pure virtual returns (bytes32[] memory contracts) {}\n\n    function buildCache() public {\n        // The resolver must call this function whenever it updates its state\n        bytes32[] memory contractNames = requiredContracts();\n        for (uint256 i; i < contractNames.length; i++) {\n            bytes32 name = contractNames[i];\n            // Note: can only be invoked once the resolver has all the targets needed added\n            address destination = Storage.slot().resolver.getAddress(\n                name,\n                string(abi.encodePacked(\"Resolver missing target: \", name))\n            );\n            Storage.slot().addressCache[name] = destination;\n            emit CacheUpdated(name, destination);\n        }\n    }\n\n    function isResolverCached() external view returns (bool) {\n        bytes32[] memory contractNames = requiredContracts();\n        for (uint256 i; i < contractNames.length; i++) {\n            bytes32 name = contractNames[i];\n            // false if our cache is invalid or if the resolver doesn't have the required address\n            if (\n                Storage.slot().resolver.getAddress(name) != Storage.slot().addressCache[name] ||\n                Storage.slot().addressCache[name] == address(0)\n            ) {\n                return false;\n            }\n        }\n\n        return true;\n    }\n\n    /**\n     * @dev Register the Address Resolver contract\n     * @param _resolver The address of the Address Resolver contract\n     */\n    function registerAddressResolver(address _resolver) internal {\n        if (address(Storage.slot().resolver) != address(0)) revert ResolverAlreadyRegistered();\n        Storage.slot().resolver = IAddressResolver(_resolver);\n    }\n\n    function getAddress(bytes32 name) internal view returns (address) {\n        return AddressResolverLib.getAddress(name);\n    }\n\n    function resolver() public view returns (IAddressResolver) {\n        return Storage.slot().resolver;\n    }\n\n    function beaconProxyController() internal view returns (IBeaconProxyController) {\n        return AddressResolverLib.beaconProxyController();\n    }\n\n    function currencyController() internal view returns (ICurrencyController) {\n        return AddressResolverLib.currencyController();\n    }\n\n    function genesisValueVault() internal view returns (IGenesisValueVault) {\n        return AddressResolverLib.genesisValueVault();\n    }\n\n    function reserveFund() internal view returns (IReserveFund) {\n        return AddressResolverLib.reserveFund();\n    }\n\n    function lendingMarketController() internal view returns (ILendingMarketController) {\n        return AddressResolverLib.lendingMarketController();\n    }\n\n    function tokenVault() internal view returns (ITokenVault) {\n        return AddressResolverLib.tokenVault();\n    }\n}\n"
      },
      "contracts/protocol/mixins/MixinLiquidationConfiguration.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\n// libraries\nimport {Constants} from \"../libraries/Constants.sol\";\n// utils\nimport {Ownable} from \"../utils/Ownable.sol\";\n// storages\nimport {TokenVaultStorage as Storage} from \"../storages/TokenVaultStorage.sol\";\n\ncontract MixinLiquidationConfiguration is Ownable {\n    error InvalidLiquidationThresholdRate();\n    error InvalidFullLiquidationThresholdRate();\n    error InvalidLiquidationProtocolFeeRate();\n    error InvalidLiquidatorFeeRate();\n\n    event LiquidationThresholdRateUpdated(uint256 previousRate, uint256 ratio);\n    event FullLiquidationThresholdRateUpdated(uint256 previousRate, uint256 ratio);\n    event LiquidationProtocolFeeRateUpdated(uint256 previousRate, uint256 ratio);\n    event LiquidatorFeeRateUpdated(uint256 previousRate, uint256 ratio);\n\n    function _initialize(\n        address _owner,\n        uint256 _liquidationThresholdRate,\n        uint256 _fullLiquidationThresholdRate,\n        uint256 _liquidationProtocolFeeRate,\n        uint256 _liquidatorFeeRate\n    ) internal {\n        _transferOwnership(_owner);\n        _updateLiquidationConfiguration(\n            _liquidationThresholdRate,\n            _fullLiquidationThresholdRate,\n            _liquidationProtocolFeeRate,\n            _liquidatorFeeRate\n        );\n    }\n\n    /**\n     * @dev Gets the liquidation configuration\n     * @return liquidationThresholdRate The liquidation threshold rate\n     * @return fullLiquidationThresholdRate The full liquidation threshold rate\n     * @return liquidationProtocolFeeRate The liquidation fee received by liquidators\n     * @return liquidatorFeeRate The liquidation protocol fee received by protocol\n     */\n    function getLiquidationConfiguration()\n        public\n        view\n        returns (\n            uint256 liquidationThresholdRate,\n            uint256 fullLiquidationThresholdRate,\n            uint256 liquidationProtocolFeeRate,\n            uint256 liquidatorFeeRate\n        )\n    {\n        liquidationThresholdRate = Storage.slot().liquidationThresholdRate;\n        fullLiquidationThresholdRate = Storage.slot().fullLiquidationThresholdRate;\n        liquidationProtocolFeeRate = Storage.slot().liquidationProtocolFeeRate;\n        liquidatorFeeRate = Storage.slot().liquidatorFeeRate;\n    }\n\n    /**\n     * @dev Update the liquidation configuration\n     * @param _liquidationThresholdRate The liquidation threshold rate\n     * @param _liquidationProtocolFeeRate The liquidation fee rate received by protocol\n     * @param _liquidatorFeeRate The liquidation fee rate received by liquidators\n     * @notice Triggers only be contract owner\n     */\n    function updateLiquidationConfiguration(\n        uint256 _liquidationThresholdRate,\n        uint256 _fullLiquidationThresholdRate,\n        uint256 _liquidationProtocolFeeRate,\n        uint256 _liquidatorFeeRate\n    ) external onlyOwner {\n        _updateLiquidationConfiguration(\n            _liquidationThresholdRate,\n            _fullLiquidationThresholdRate,\n            _liquidationProtocolFeeRate,\n            _liquidatorFeeRate\n        );\n    }\n\n    /**\n     * @dev Update the liquidation configuration\n     * @param _liquidationThresholdRate The liquidation threshold rate\n     * @param _liquidationProtocolFeeRate The liquidation fee rate received by protocol\n     * @param _liquidatorFeeRate The liquidation fee rate received by liquidators\n     * @notice Triggers only be contract owner\n     */\n    function _updateLiquidationConfiguration(\n        uint256 _liquidationThresholdRate,\n        uint256 _fullLiquidationThresholdRate,\n        uint256 _liquidationProtocolFeeRate,\n        uint256 _liquidatorFeeRate\n    ) private {\n        if (_liquidationThresholdRate <= Constants.PCT_DIGIT)\n            revert InvalidLiquidationThresholdRate();\n        if (\n            _fullLiquidationThresholdRate <= Constants.PCT_DIGIT ||\n            _fullLiquidationThresholdRate > _liquidationThresholdRate\n        ) revert InvalidFullLiquidationThresholdRate();\n        if (_liquidationProtocolFeeRate > Constants.PCT_DIGIT)\n            revert InvalidLiquidationProtocolFeeRate();\n        if (_liquidatorFeeRate > Constants.PCT_DIGIT) revert InvalidLiquidatorFeeRate();\n\n        if (_liquidationThresholdRate != Storage.slot().liquidationThresholdRate) {\n            emit LiquidationThresholdRateUpdated(\n                Storage.slot().liquidationThresholdRate,\n                _liquidationThresholdRate\n            );\n            Storage.slot().liquidationThresholdRate = _liquidationThresholdRate;\n        }\n\n        if (_fullLiquidationThresholdRate != Storage.slot().fullLiquidationThresholdRate) {\n            emit FullLiquidationThresholdRateUpdated(\n                Storage.slot().fullLiquidationThresholdRate,\n                _fullLiquidationThresholdRate\n            );\n            Storage.slot().fullLiquidationThresholdRate = _fullLiquidationThresholdRate;\n        }\n\n        if (_liquidationProtocolFeeRate != Storage.slot().liquidationProtocolFeeRate) {\n            emit LiquidationProtocolFeeRateUpdated(\n                Storage.slot().liquidationProtocolFeeRate,\n                _liquidationProtocolFeeRate\n            );\n            Storage.slot().liquidationProtocolFeeRate = _liquidationProtocolFeeRate;\n        }\n\n        if (_liquidatorFeeRate != Storage.slot().liquidatorFeeRate) {\n            emit LiquidatorFeeRateUpdated(Storage.slot().liquidatorFeeRate, _liquidatorFeeRate);\n            Storage.slot().liquidatorFeeRate = _liquidatorFeeRate;\n        }\n    }\n}\n"
      },
      "contracts/protocol/storages/CurrencyControllerStorage.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport \"../../dependencies/chainlink/AggregatorV3Interface.sol\";\nimport \"../../dependencies/openzeppelin/utils/structs/EnumerableSet.sol\";\n\nstruct PriceFeed {\n    AggregatorV3Interface[] instances;\n    uint256[] heartbeats;\n}\n\nlibrary CurrencyControllerStorage {\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n\n    bytes32 internal constant STORAGE_SLOT =\n        bytes32(uint256(keccak256(\"sf.storage.currencyController\")) - 1);\n\n    struct Storage {\n        // Protocol currencies\n        EnumerableSet.Bytes32Set currencies;\n        mapping(bytes32 ccy => uint256 haircut) haircuts;\n        // Total cached decimals of the price feeds\n        mapping(bytes32 ccy => uint8 decimals) decimalsCaches;\n        mapping(bytes32 ccy => PriceFeed priceFeed) priceFeeds;\n    }\n\n    function slot() internal pure returns (Storage storage r) {\n        bytes32 _slot = STORAGE_SLOT;\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := _slot\n        }\n    }\n}\n"
      },
      "contracts/protocol/storages/GenesisValueVaultStorage.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nstruct MaturityUnitPrice {\n    uint256 unitPrice;\n    uint256 compoundFactor;\n    uint256 next;\n    uint256 prev;\n}\n\nstruct AutoRollLog {\n    uint256 unitPrice;\n    uint256 lendingCompoundFactor;\n    uint256 borrowingCompoundFactor;\n    uint256 next;\n    uint256 prev;\n}\n\nlibrary GenesisValueVaultStorage {\n    bytes32 internal constant STORAGE_SLOT =\n        bytes32(uint256(keccak256(\"sf.storage.genesisValueVault\")) - 1);\n\n    struct Storage {\n        mapping(bytes32 ccy => bool isInitialized) isInitialized;\n        mapping(bytes32 ccy => uint256 compoundFactor) initialCompoundFactors;\n        mapping(bytes32 ccy => uint256 compoundFactor) lendingCompoundFactors;\n        mapping(bytes32 ccy => uint256 compoundFactor) borrowingCompoundFactors;\n        mapping(bytes32 ccy => uint256 maturity) currentMaturity;\n        mapping(bytes32 ccy => uint8 decimals) decimals;\n        mapping(bytes32 ccy => mapping(address user => int256 balance)) balances;\n        mapping(bytes32 ccy => uint256 amount) totalLendingSupplies;\n        mapping(bytes32 ccy => uint256 amount) totalBorrowingSupplies;\n        // Total amount supplied per maturity\n        mapping(bytes32 ccy => mapping(uint256 maturity => int256 balance)) maturityBalances;\n        mapping(bytes32 ccy => mapping(uint256 maturity => AutoRollLog log)) autoRollLogs;\n        // Maturity when the user receives the balance on the target currency\n        mapping(bytes32 ccy => mapping(address user => uint256 maturity)) userMaturities;\n        mapping(bytes32 ccy => uint256 balance) totalLockedBalances;\n    }\n\n    function slot() internal pure returns (Storage storage r) {\n        bytes32 _slot = STORAGE_SLOT;\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := _slot\n        }\n    }\n}\n"
      },
      "contracts/protocol/storages/LendingMarketControllerStorage.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport \"../../dependencies/openzeppelin/utils/structs/EnumerableSet.sol\";\n\nstruct ObservationPeriodLog {\n    uint256 totalAmount;\n    uint256 totalFutureValue;\n}\n\nstruct TerminationCurrencyCache {\n    int256 price;\n    uint8 decimals;\n}\n\nstruct ZCTokenInfo {\n    bytes32 ccy;\n    uint256 maturity;\n}\n\nlibrary LendingMarketControllerStorage {\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n    using EnumerableSet for EnumerableSet.UintSet;\n\n    bytes32 internal constant STORAGE_SLOT =\n        bytes32(uint256(keccak256(\"sf.storage.lendingMarketController\")) - 1);\n\n    struct Storage {\n        uint256 marketBasePeriod;\n        uint256 terminationDate;\n        mapping(bytes32 ccy => TerminationCurrencyCache currency) terminationCurrencyCaches;\n        mapping(bytes32 ccy => uint256 ratio) terminationCollateralRatios;\n        mapping(bytes32 ccy => uint8[] orderBookIds) orderBookIdLists;\n        mapping(bytes32 ccy => address lendingMarket) lendingMarkets;\n        mapping(bytes32 ccy => address futureValueVault) futureValueVaults;\n        mapping(bytes32 ccy => uint256 unitPrice) minDebtUnitPrices;\n        mapping(bytes32 ccy => uint256 genesisDate) genesisDates;\n        mapping(bytes32 ccy => mapping(uint256 maturity => uint256 amount)) pendingOrderAmounts;\n        // Order book id history to get order book id from maturity\n        mapping(bytes32 ccy => mapping(uint256 maturity => uint8 orderBookIds)) maturityOrderBookIds;\n        // List of maturity that the user has open orders or positions\n        mapping(bytes32 ccy => mapping(address user => EnumerableSet.UintSet maturities)) usedMaturities;\n        // Observation period logs that is used for auto-rolls\n        mapping(bytes32 ccy => mapping(uint256 maturity => ObservationPeriodLog log)) observationPeriodLogs;\n        // List of currency that the user has open orders or positions\n        mapping(address user => EnumerableSet.Bytes32Set currency) usedCurrencies;\n        mapping(address user => bool isRedeemed) isRedeemed;\n        mapping(bytes32 ccy => mapping(uint256 maturity => address token)) zcTokens;\n        mapping(address token => ZCTokenInfo) zcTokenInfo;\n    }\n\n    function slot() internal pure returns (Storage storage r) {\n        bytes32 _slot = STORAGE_SLOT;\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := _slot\n        }\n    }\n}\n"
      },
      "contracts/protocol/storages/libraries/TransferHelperStorage.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nlibrary TransferHelperStorage {\n    bytes32 internal constant STORAGE_SLOT =\n        bytes32(uint256(keccak256(\"sf.storage.transferHelper\")) - 1);\n\n    struct Storage {\n        address nativeToken;\n    }\n\n    function slot() internal pure returns (Storage storage r) {\n        bytes32 _slot = STORAGE_SLOT;\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := _slot\n        }\n    }\n}\n"
      },
      "contracts/protocol/storages/mixins/MixinAddressResolverStorage.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {IAddressResolver} from \"../../interfaces/IAddressResolver.sol\";\n\nlibrary MixinAddressResolverStorage {\n    bytes32 internal constant STORAGE_SLOT =\n        bytes32(uint256(keccak256(\"sf.storage.mixinAddressResolver\")) - 1);\n\n    struct Storage {\n        IAddressResolver resolver;\n        mapping(bytes32 contractName => address contractAddress) addressCache;\n    }\n\n    function slot() internal pure returns (Storage storage r) {\n        bytes32 _slot = STORAGE_SLOT;\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := _slot\n        }\n    }\n}\n"
      },
      "contracts/protocol/storages/TokenVaultStorage.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {EnumerableSet} from \"../../dependencies/openzeppelin/utils/structs/EnumerableSet.sol\";\n\nlibrary TokenVaultStorage {\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n\n    bytes32 internal constant STORAGE_SLOT =\n        bytes32(uint256(keccak256(\"sf.storage.tokenVault\")) - 1);\n\n    struct Storage {\n        // Liquidation threshold rate (in basis point)\n        uint256 liquidationThresholdRate;\n        // Liquidation fee rate received by protocol (in basis point)\n        uint256 liquidationProtocolFeeRate;\n        // Liquidation fee rate received by liquidators (in basis point)\n        uint256 liquidatorFeeRate;\n        // Currencies accepted as collateral\n        EnumerableSet.Bytes32Set collateralCurrencies;\n        mapping(bytes32 ccy => address tokenAddress) tokenAddresses;\n        // List of currency that the user has deposit amounts\n        mapping(address user => EnumerableSet.Bytes32Set currency) usedCurrencies;\n        mapping(bytes32 ccy => uint256 totalDepositAmount) totalDepositAmount;\n        mapping(address user => mapping(bytes32 currency => uint256 depositAmount)) depositAmounts;\n        // Full liquidation threshold rate (in basis point)\n        uint256 fullLiquidationThresholdRate;\n    }\n\n    function slot() internal pure returns (Storage storage r) {\n        bytes32 _slot = STORAGE_SLOT;\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := _slot\n        }\n    }\n}\n"
      },
      "contracts/protocol/storages/utils/AccessControlStorage.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nstruct RoleData {\n    mapping(address => bool) members;\n    bytes32 adminRole;\n}\n\nlibrary AccessControlStorage {\n    bytes32 internal constant STORAGE_SLOT =\n        bytes32(uint256(keccak256(\"sf.storage.accessControl\")) - 1);\n\n    struct Storage {\n        mapping(bytes32 role => RoleData roleData) roles;\n    }\n\n    function slot() internal pure returns (Storage storage r) {\n        bytes32 _slot = STORAGE_SLOT;\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := _slot\n        }\n    }\n}\n"
      },
      "contracts/protocol/storages/utils/OwnableStorage.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nlibrary OwnableStorage {\n    bytes32 internal constant STORAGE_SLOT = bytes32(uint256(keccak256(\"sf.storage.ownable\")) - 1);\n\n    struct Storage {\n        address owner;\n    }\n\n    function slot() internal pure returns (Storage storage r) {\n        bytes32 _slot = STORAGE_SLOT;\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := _slot\n        }\n    }\n}\n"
      },
      "contracts/protocol/storages/utils/PausableStorage.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nlibrary PausableStorage {\n    bytes32 internal constant STORAGE_SLOT = bytes32(uint256(keccak256(\"sf.storage.pausable\")) - 1);\n\n    struct Storage {\n        bool paused;\n    }\n\n    function slot() internal pure returns (Storage storage r) {\n        bytes32 _slot = STORAGE_SLOT;\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := _slot\n        }\n    }\n}\n"
      },
      "contracts/protocol/TokenVault.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\n// dependencies\nimport {IERC20Permit} from \"../dependencies/openzeppelin/token/ERC20/extensions/IERC20Permit.sol\";\nimport {EnumerableSet} from \"../dependencies/openzeppelin/utils/structs/EnumerableSet.sol\";\nimport {Multicall} from \"../dependencies/openzeppelin/utils/Multicall.sol\";\n// libraries\nimport {Contracts} from \"./libraries/Contracts.sol\";\nimport {Constants} from \"./libraries/Constants.sol\";\nimport {TransferHelper} from \"./libraries/TransferHelper.sol\";\nimport {DepositManagementLogic} from \"./libraries/logics/DepositManagementLogic.sol\";\n// interfaces\nimport {ITokenVault} from \"./interfaces/ITokenVault.sol\";\nimport {ILendingMarketController} from \"./interfaces/ILendingMarketController.sol\";\n// mixins\nimport {MixinAccessControl} from \"./mixins/MixinAccessControl.sol\";\nimport {MixinAddressResolver} from \"./mixins/MixinAddressResolver.sol\";\nimport {MixinLiquidationConfiguration} from \"./mixins/MixinLiquidationConfiguration.sol\";\n// types\nimport {ProtocolTypes} from \"./types/ProtocolTypes.sol\";\n// utils\nimport {Ownable} from \"./utils/Ownable.sol\";\nimport {Pausable} from \"./utils/Pausable.sol\";\nimport {Proxyable} from \"./utils/Proxyable.sol\";\n// storages\nimport {TokenVaultStorage as Storage} from \"./storages/TokenVaultStorage.sol\";\n\n/**\n * @notice Implements the management of the token in each currency for users.\n *\n * This contract manages the following data related to tokens.\n * - Deposited token amount as the collateral\n * - Parameters related to the liquidation\n *   - Liquidation threshold rate\n *   - Liquidation fee rate received by protocol\n *   - Liquidation fee rate received by liquidators\n */\ncontract TokenVault is\n    ITokenVault,\n    MixinLiquidationConfiguration,\n    MixinAccessControl,\n    MixinAddressResolver,\n    Pausable,\n    Proxyable,\n    Multicall\n{\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n\n    /**\n     * @notice Modifier to check if currency hasn't been registered yet\n     * @param _ccy Currency name in bytes32\n     */\n    modifier onlyRegisteredCurrency(bytes32 _ccy) {\n        if (!isRegisteredCurrency(_ccy)) revert UnregisteredCurrency();\n        _;\n    }\n\n    /**\n     * @notice Modifier to check if the protocol is active.\n     */\n    modifier ifActive() {\n        if (lendingMarketController().isTerminated()) revert MarketTerminated();\n        _;\n    }\n\n    /**\n     * @notice Initializes the contract.\n     * @dev Function is invoked by the proxy contract when the contract is added to the ProxyController.\n     * @param _owner The address of the contract owner\n     * @param _resolver The address of the Address Resolver contract\n     * @param _liquidationThresholdRate The liquidation threshold rate\n     * @param _fullLiquidationThresholdRate  The full liquidation threshold rate\n     * @param _liquidationProtocolFeeRate The liquidation fee rate received by protocol\n     * @param _liquidatorFeeRate The liquidation fee rate received by liquidators\n     * @param _nativeToken The address of wrapped token of native currency\n     */\n    function initialize(\n        address _owner,\n        address _resolver,\n        uint256 _liquidationThresholdRate,\n        uint256 _fullLiquidationThresholdRate,\n        uint256 _liquidationProtocolFeeRate,\n        uint256 _liquidatorFeeRate,\n        address _nativeToken\n    ) public initializer onlyProxy {\n        _transferOwnership(_owner);\n        registerAddressResolver(_resolver);\n\n        TransferHelper.initialize(_nativeToken);\n        MixinAccessControl._setupInitialRoles(_owner);\n        MixinLiquidationConfiguration._initialize(\n            _owner,\n            _liquidationThresholdRate,\n            _fullLiquidationThresholdRate,\n            _liquidationProtocolFeeRate,\n            _liquidatorFeeRate\n        );\n    }\n\n    // @inheritdoc MixinAddressResolver\n    function requiredContracts() public pure override returns (bytes32[] memory contracts) {\n        contracts = new bytes32[](3);\n        contracts[0] = Contracts.CURRENCY_CONTROLLER;\n        contracts[1] = Contracts.LENDING_MARKET_CONTROLLER;\n        contracts[2] = Contracts.RESERVE_FUND;\n    }\n\n    receive() external payable {\n        if (!TransferHelper.isNative(msg.sender)) {\n            revert CallerNotBaseCurrency({caller: msg.sender});\n        }\n    }\n\n    /**\n     * @notice Gets if the collateral is sufficient or not\n     * @param _user User's address\n     * @return isEnoughCollateral The boolean if the user has enough collateral or not\n     * @return isEnoughDepositInOrderCcy The boolean if the user has enough deposit in the order currency or not\n     */\n    function isCovered(\n        address _user,\n        bytes32 _orderCcy\n    ) public view override returns (bool isEnoughCollateral, bool isEnoughDepositInOrderCcy) {\n        return DepositManagementLogic.isCovered(_user, _orderCcy);\n    }\n\n    /**\n     * @notice Gets if the currency is acceptable as collateral\n     * @param _ccy Currency name in bytes32\n     * @return The boolean if the currency has been registered or not\n     */\n    function isCollateral(bytes32 _ccy) public view override returns (bool) {\n        return Storage.slot().collateralCurrencies.contains(_ccy);\n    }\n\n    /**\n     * @notice Gets if the currencies are acceptable as collateral\n     * @param _ccys Currency name list in bytes32\n     * @return isCollateralCurrencies Array of the boolean if the currency has been registered or not\n     */\n    function isCollateral(\n        bytes32[] calldata _ccys\n    ) external view override returns (bool[] memory isCollateralCurrencies) {\n        uint256 length = _ccys.length;\n        isCollateralCurrencies = new bool[](length);\n        for (uint256 i; i < length; i++) {\n            isCollateralCurrencies[i] = isCollateral(_ccys[i]);\n        }\n    }\n\n    /**\n     * @notice Gets if the currency has been registered\n     * @param _ccy Currency name in bytes32\n     * @return The boolean if the currency has been registered or not\n     */\n    function isRegisteredCurrency(bytes32 _ccy) public view override returns (bool) {\n        return Storage.slot().tokenAddresses[_ccy] != address(0);\n    }\n\n    // @inheritdoc Proxyable\n    function getRevision() external pure override returns (uint256) {\n        return 0x2;\n    }\n\n    /**\n     * @notice Gets the token contract address\n     * @param _ccy Currency name in bytes32\n     * @return The token contract address\n     */\n    function getTokenAddress(bytes32 _ccy) public view override returns (address) {\n        return Storage.slot().tokenAddresses[_ccy];\n    }\n\n    /**\n     * @notice Gets the currencies accepted as collateral\n     * @return Array of the currency accepted as collateral\n     */\n    function getCollateralCurrencies() external view override returns (bytes32[] memory) {\n        return Storage.slot().collateralCurrencies.values();\n    }\n\n    /**\n     * @notice Gets the maximum amount of the base currency that can be withdrawn from user collateral.\n     * @param _user User's address\n     * @return Maximum amount of the base currency that can be withdrawn\n     */\n    function getWithdrawableCollateral(address _user) external view override returns (uint256) {\n        return DepositManagementLogic.getWithdrawableCollateral(_user);\n    }\n\n    /**\n     * @notice Gets the maximum amount of the selected currency that can be withdrawn from user collateral.\n     * @param _ccy Currency name in bytes32\n     * @param _user User's address\n     * @return Maximum amount of the selected currency that can be withdrawn\n     */\n    function getWithdrawableCollateral(\n        bytes32 _ccy,\n        address _user\n    ) external view override returns (uint256) {\n        return DepositManagementLogic.getWithdrawableCollateral(_ccy, _user);\n    }\n\n    /**\n     * @notice Gets the rate of collateral used.\n     * @param _user User's address\n     * @return The rate of collateral used\n     */\n    function getCoverage(address _user) external view override returns (uint256) {\n        return DepositManagementLogic.getCoverage(_user);\n    }\n\n    /**\n     * @notice Gets the total amount of the unused collateral in the base currency\n     * @param _user User's address\n     * @return The total amount of unused collateral\n     */\n    function getTotalUnusedCollateralAmount(\n        address _user\n    ) external view override returns (uint256) {\n        return DepositManagementLogic.getTotalUnusedCollateralAmount(_user);\n    }\n\n    /**\n     * @notice Gets the total collateral amount.\n     * @param _user User's address\n     * @return totalCollateralAmount The total collateral amount in the base currency\n     */\n    function getTotalCollateralAmount(\n        address _user\n    ) external view override returns (uint256 totalCollateralAmount) {\n        (totalCollateralAmount, , ) = DepositManagementLogic.getTotalCollateralAmount(_user);\n    }\n\n    /**\n     * @notice Gets the collateral detail.\n     * @param _user User's address\n     * @return totalCollateral The total collateral amount in the base currency\n     * @return totalUsedCollateral The total used collateral amount in the base currency\n     * @return totalDeposit The total deposit amount in the base currency\n     */\n    function getCollateralDetail(\n        address _user\n    )\n        external\n        view\n        override\n        returns (uint256 totalCollateral, uint256 totalUsedCollateral, uint256 totalDeposit)\n    {\n        (totalCollateral, totalUsedCollateral, totalDeposit) = DepositManagementLogic\n            .getTotalCollateralAmount(_user);\n    }\n\n    /**\n     * @notice Gets the total collateral amount of the selected currency.\n     * @param _user User's address\n     * @param _ccy Currency name in bytes32\n     * @return amount The collateral amount\n     */\n    function getCollateralAmount(\n        address _user,\n        bytes32 _ccy\n    ) external view override returns (uint256 amount) {\n        (amount, , ) = DepositManagementLogic.getCollateralAmount(_user, _ccy);\n    }\n\n    /**\n     * @notice Gets the borrowable amount in the selected currency.\n     * @param _user User's address\n     * @param _ccy Currency name in bytes32\n     * @return amount The borrowable amount\n     */\n    function getBorrowableAmount(\n        address _user,\n        bytes32 _ccy\n    ) external view override returns (uint256) {\n        return DepositManagementLogic.getBorrowableAmount(_user, _ccy);\n    }\n\n    /**\n     * @notice Gets the amount to be liquidated.\n     * @param _user User's address\n     * @return liquidationAmount The the amount to be liquidated\n     */\n    function getLiquidationAmount(\n        address _user,\n        bytes32 _liquidationCcy,\n        uint256 _liquidationAmountMaximum\n    )\n        external\n        view\n        override\n        returns (uint256 liquidationAmount, uint256 protocolFee, uint256 liquidatorFee)\n    {\n        return\n            DepositManagementLogic.getLiquidationAmount(\n                _user,\n                _liquidationCcy,\n                _liquidationAmountMaximum\n            );\n    }\n\n    /**\n     * @notice Gets the total amount deposited of the selected currency\n     * @param _ccy Currency name in bytes32\n     * @return The total deposited amount\n     */\n    function getTotalDepositAmount(bytes32 _ccy) external view override returns (uint256) {\n        return Storage.slot().totalDepositAmount[_ccy];\n    }\n\n    /**\n     * @notice Gets the amount deposited in the user's collateral.\n     * @param _user User's address\n     * @param _ccy Currency name in bytes32\n     * @return The deposited amount\n     */\n    function getDepositAmount(\n        address _user,\n        bytes32 _ccy\n    ) external view override returns (uint256) {\n        return DepositManagementLogic.getDepositAmount(_user, _ccy);\n    }\n\n    /**\n     * @notice Gets the currencies that the user used as collateral.\n     * @param _user User's address\n     * @return The currency names in bytes32\n     */\n    function getUsedCurrencies(address _user) public view override returns (bytes32[] memory) {\n        return DepositManagementLogic.getUsedCurrencies(_user);\n    }\n\n    /**\n     * @notice Gets the liquidation threshold rate.\n     * @return rate The liquidation threshold rate\n     */\n    function getLiquidationThresholdRate() public view override returns (uint256 rate) {\n        (rate, , , ) = getLiquidationConfiguration();\n    }\n\n    /**\n     * @notice Calculates the collateral rate used when additional funds are had by the user.\n     * @param _user User's address\n     * @param _additionalFunds Additional funds for calculating the coverage\n     * @return coverage The rate of collateral used\n     * @return isInsufficientDepositAmount The boolean if the lent amount in the selected currency is insufficient for the deposit amount or not\n     */\n    function calculateCoverage(\n        address _user,\n        ILendingMarketController.AdditionalFunds memory _additionalFunds\n    ) external view override returns (uint256 coverage, bool isInsufficientDepositAmount) {\n        return DepositManagementLogic.calculateCoverage(_user, _additionalFunds);\n    }\n\n    /**\n     * @notice Gets the actual fee amounts calculated by rates.\n     * @param _amount Liquidation amount\n     * @return protocolFee Liquidation fee amount received by protocol\n     * @return liquidatorFee Liquidation fee amount received by liquidators\n     */\n    function calculateLiquidationFees(\n        uint256 _amount\n    ) external view override returns (uint256 protocolFee, uint256 liquidatorFee) {\n        return DepositManagementLogic.calculateLiquidationFees(_amount);\n    }\n\n    /**\n     * @notice Registers new currency and sets if it is acceptable as collateral.\n     * @param _ccy Currency name in bytes32\n     * @param _tokenAddress Token contract address of the selected currency\n     * @param _isCollateral Boolean if the selected currency is acceptable as collateral.\n     */\n    function registerCurrency(\n        bytes32 _ccy,\n        address _tokenAddress,\n        bool _isCollateral\n    ) external override ifActive onlyOwner {\n        if (!currencyController().currencyExists(_ccy) || isRegisteredCurrency(_ccy)) {\n            revert InvalidCurrency();\n        }\n\n        if (_tokenAddress == address(0)) {\n            revert InvalidToken();\n        }\n\n        Storage.slot().tokenAddresses[_ccy] = _tokenAddress;\n        if (_isCollateral) {\n            Storage.slot().collateralCurrencies.add(_ccy);\n        }\n\n        emit CurrencyRegistered(_ccy, _tokenAddress, _isCollateral);\n    }\n\n    /**\n     * @notice Updates the currency if it is acceptable as collateral.\n     * @param _ccy Currency name in bytes32\n     * @param _isCollateral Boolean if the selected currency is acceptable as collateral.\n     */\n    function updateCurrency(\n        bytes32 _ccy,\n        bool _isCollateral\n    ) external override ifActive onlyOwner onlyRegisteredCurrency(_ccy) {\n        if (_isCollateral) {\n            Storage.slot().collateralCurrencies.add(_ccy);\n        } else {\n            Storage.slot().collateralCurrencies.remove(_ccy);\n        }\n\n        emit CurrencyUpdated(_ccy, _isCollateral);\n    }\n\n    /**\n     * @dev Deposits funds by the caller into collateral.\n     * @param _ccy Currency name in bytes32\n     * @param _amount Amount of funds to deposit\n     */\n    function deposit(\n        bytes32 _ccy,\n        uint256 _amount\n    ) external payable override ifActive whenNotPaused onlyRegisteredCurrency(_ccy) {\n        _deposit(msg.sender, _ccy, _amount, msg.sender);\n    }\n\n    /**\n     * @dev Deposits funds by the caller into collateral.\n     * @param _ccy Currency name in bytes32\n     * @param _amount Amount of funds to deposit\n     * @param _onBehalfOf The beneficiary of the supplied deposits\n     */\n    function depositTo(\n        bytes32 _ccy,\n        uint256 _amount,\n        address _onBehalfOf\n    ) external payable override ifActive whenNotPaused onlyRegisteredCurrency(_ccy) {\n        _deposit(msg.sender, _ccy, _amount, _onBehalfOf);\n    }\n\n    /**\n     * @dev Deposits funds by the `from` into collateral.\n     * @param _from Address of the user\n     * @param _ccy Currency name in bytes32\n     * @param _amount Amount of funds to deposit\n     */\n    function depositFrom(\n        address _from,\n        bytes32 _ccy,\n        uint256 _amount\n    ) external payable override ifActive whenNotPaused onlyLendingMarketController {\n        _deposit(_from, _ccy, _amount, _from);\n    }\n\n    /**\n     * @dev Deposits funds by the caller into collateral with transfer approval of asset via permit function\n     * @param _ccy Currency name in bytes32\n     * @param _amount Amount of funds to deposit\n     * @param _onBehalfOf The beneficiary of the supplied deposits\n     * @param _deadline The deadline timestamp that the permit is valid\n     * @param _permitV The V parameter of ERC712 permit sig\n     * @param _permitR The R parameter of ERC712 permit sig\n     * @param _permitS The S parameter of ERC712 permit sig\n     */\n    function depositWithPermitTo(\n        bytes32 _ccy,\n        uint256 _amount,\n        address _onBehalfOf,\n        uint256 _deadline,\n        uint8 _permitV,\n        bytes32 _permitR,\n        bytes32 _permitS\n    ) external override ifActive whenNotPaused onlyRegisteredCurrency(_ccy) {\n        IERC20Permit(getTokenAddress(_ccy)).permit(\n            msg.sender,\n            address(this),\n            _amount,\n            _deadline,\n            _permitV,\n            _permitR,\n            _permitS\n        );\n\n        _deposit(msg.sender, _ccy, _amount, _onBehalfOf);\n    }\n\n    /**\n     * @dev Deposits funds by the `from` into collateral with transfer approval of asset via permit function\n     * @param _from Address of the user\n     * @param _ccy Currency name in bytes32\n     * @param _amount Amount of funds to deposit\n     * @param _deadline The deadline timestamp that the permit is valid\n     * @param _permitV The V parameter of ERC712 permit sig\n     * @param _permitR The R parameter of ERC712 permit sig\n     * @param _permitS The S parameter of ERC712 permit sig\n     */\n    function depositWithPermitFrom(\n        address _from,\n        bytes32 _ccy,\n        uint256 _amount,\n        uint256 _deadline,\n        uint8 _permitV,\n        bytes32 _permitR,\n        bytes32 _permitS\n    ) external override ifActive whenNotPaused onlyLendingMarketController {\n        IERC20Permit(getTokenAddress(_ccy)).permit(\n            _from,\n            address(this),\n            _amount,\n            _deadline,\n            _permitV,\n            _permitR,\n            _permitS\n        );\n\n        _deposit(_from, _ccy, _amount, _from);\n    }\n\n    /**\n     * @notice Withdraws funds by the caller from unused collateral.\n     * @param _ccy Currency name in bytes32\n     * @param _amount Amount of funds to withdraw.\n     */\n    function withdraw(\n        bytes32 _ccy,\n        uint256 _amount\n    ) external override whenNotPaused onlyRegisteredCurrency(_ccy) {\n        _withdraw(msg.sender, _ccy, _amount);\n    }\n\n    /**\n     * @dev Adds deposit amount.\n     * @param _user User's address\n     * @param _amount Amount of funds to deposit\n     * @param _ccy Currency name in bytes32\n     */\n    function addDepositAmount(\n        address _user,\n        bytes32 _ccy,\n        uint256 _amount\n    ) external override whenNotPaused onlyLendingMarketController onlyRegisteredCurrency(_ccy) {\n        DepositManagementLogic.addDepositAmount(_user, _ccy, _amount);\n    }\n\n    /**\n     * @notice Removes deposit amount.\n     * @param _user User's address\n     * @param _ccy Currency name in bytes32\n     * @param _amount Amount of funds to withdraw.\n     */\n    function removeDepositAmount(\n        address _user,\n        bytes32 _ccy,\n        uint256 _amount\n    ) external override whenNotPaused onlyLendingMarketController onlyRegisteredCurrency(_ccy) {\n        DepositManagementLogic.removeDepositAmount(_user, _ccy, _amount);\n    }\n\n    /**\n     * @notice Clean up the used currencies of the user.\n     * @param _user User's address\n     * @param _ccy Currency name in bytes32\n     */\n    function cleanUpUsedCurrencies(\n        address _user,\n        bytes32 _ccy\n    ) external override whenNotPaused onlyLendingMarketController {\n        DepositManagementLogic.cleanUpUsedCurrencies(_user, _ccy);\n    }\n\n    /**\n     * @notice Forces a reset of the user's deposit amount.\n     * @param _user User's address\n     * @param _ccy Currency name in bytes32\n     */\n    function executeForcedReset(\n        address _user,\n        bytes32 _ccy\n    ) external override onlyLendingMarketController onlyRegisteredCurrency(_ccy) returns (uint256) {\n        return DepositManagementLogic.executeForcedReset(_user, _ccy);\n    }\n\n    /**\n     * @notice Transfers the token from sender to receiver.\n     * @param _ccy Currency name in bytes32\n     * @param _from Sender's address\n     * @param _to Receiver's address\n     * @param _amount Amount of funds to sent\n     */\n    function transferFrom(\n        bytes32 _ccy,\n        address _from,\n        address _to,\n        uint256 _amount\n    )\n        external\n        override\n        whenNotPaused\n        onlyLendingMarketController\n        onlyRegisteredCurrency(_ccy)\n        returns (uint256 untransferredAmount)\n    {\n        untransferredAmount = DepositManagementLogic.transferFrom(_ccy, _from, _to, _amount);\n        emit Transfer(_ccy, _from, _to, _amount - untransferredAmount);\n    }\n\n    /**\n     * @notice Pauses the token vault.\n     */\n    function pause() external override onlyOperator {\n        _pause();\n    }\n\n    /**\n     * @notice Unpauses the token vault.\n     */\n    function unpause() external override onlyOperator {\n        _unpause();\n    }\n\n    function _deposit(\n        address _caller,\n        bytes32 _ccy,\n        uint256 _amount,\n        address _onBehalfOf\n    ) internal {\n        if (_amount == 0) revert AmountIsZero();\n\n        address tokenAddress = Storage.slot().tokenAddresses[_ccy];\n        if (\n            (TransferHelper.isNative(tokenAddress) && msg.value != _amount) ||\n            (!TransferHelper.isNative(tokenAddress) && msg.value != 0)\n        ) {\n            revert InvalidAmount(_ccy, _amount, msg.value);\n        }\n\n        DepositManagementLogic.deposit(_caller, _ccy, _amount, _onBehalfOf);\n\n        emit Deposit(_onBehalfOf, _ccy, _amount, _caller);\n    }\n\n    function _withdraw(address _user, bytes32 _ccy, uint256 _amount) internal {\n        if (_amount == 0) revert AmountIsZero();\n        if (lendingMarketController().isRedemptionRequired(_user)) revert RedemptionIsRequired();\n\n        lendingMarketController().cleanUpFunds(_ccy, _user);\n        uint256 withdrawableAmount = DepositManagementLogic.withdraw(_user, _ccy, _amount);\n\n        emit Withdraw(_user, _ccy, withdrawableAmount);\n    }\n}\n"
      },
      "contracts/protocol/types/ProtocolTypes.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\n/**\n * @dev ProtocolTypes is a base-level contract that holds common Secured Finance protocol types\n * @author Secured Finance\n */\nlibrary ProtocolTypes {\n    enum Side {\n        LEND,\n        BORROW\n    }\n}\n"
      },
      "contracts/protocol/utils/AccessControl.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\n// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../dependencies/openzeppelin/access/IAccessControl.sol\";\nimport \"../../dependencies/openzeppelin/utils/Context.sol\";\nimport \"../../dependencies/openzeppelin/utils/Strings.sol\";\nimport \"../../dependencies/openzeppelin/utils/introspection/ERC165.sol\";\nimport \"../storages/utils/AccessControlStorage.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 * ```\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 * ```\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.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\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\n            interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n        return AccessControlStorage.slot().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                        Strings.toHexString(uint160(account), 20),\n                        \" is missing role \",\n                        Strings.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 AccessControlStorage.slot().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(\n        bytes32 role,\n        address account\n    ) 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(\n        bytes32 role,\n        address account\n    ) 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        AccessControlStorage.slot().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            AccessControlStorage.slot().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            AccessControlStorage.slot().roles[role].members[account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n        }\n    }\n}\n"
      },
      "contracts/protocol/utils/Ownable.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\n\npragma solidity 0.8.19;\n\nimport \"../../dependencies/openzeppelin/utils/Context.sol\";\nimport \"../storages/utils/OwnableStorage.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return OwnableStorage.slot().owner;\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = OwnableStorage.slot().owner;\n        OwnableStorage.slot().owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "contracts/protocol/utils/Pausable.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\n\npragma solidity ^0.8.0;\n\nimport \"../../dependencies/openzeppelin/utils/Context.sol\";\nimport \"../storages/utils/PausableStorage.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return PausableStorage.slot().paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        require(!paused(), \"Pausable: paused\");\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        require(paused(), \"Pausable: not paused\");\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        PausableStorage.slot().paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        PausableStorage.slot().paused = false;\n        emit Unpaused(_msgSender());\n    }\n}\n"
      },
      "contracts/protocol/utils/Proxyable.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport \"../../dependencies/openzeppelin/utils/StorageSlot.sol\";\nimport \"../../dependencies/openzeppelin/proxy/utils/Initializable.sol\";\n\nabstract contract Proxyable is Initializable {\n    bytes32 internal constant _IMPLEMENTATION_SLOT =\n        0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n    bytes32 internal constant _BEACON_SLOT =\n        0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n    modifier onlyProxy() {\n        require(_getImplementation() != address(0), \"Must be called from proxy contract\");\n        _;\n    }\n\n    modifier onlyBeacon() {\n        require(_getBeacon() != address(0), \"Must be called from beacon contract\");\n        _;\n    }\n\n    /**\n     * @notice Gets the revision number of the contract\n     * @return The revision number\n     */\n    function getRevision() external pure virtual returns (uint256) {\n        return 0x1;\n    }\n\n    function _getImplementation() private view returns (address) {\n        return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n    }\n\n    function _getBeacon() internal view returns (address) {\n        return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "metadata": {
        "useLiteralContent": true
      },
      "libraries": {
        "contracts/protocol/libraries/logics/DepositManagementLogic.sol": {
          "DepositManagementLogic": "0xd60551dc2e7d13fce88aca2c63e6b63be3fd9765"
        }
      }
    }
  }}