-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathengine_standart_input.json
76 lines (76 loc) · 108 KB
/
engine_standart_input.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{
"language": "Solidity",
"sources": {
"src/SphereXEngine.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\n// (c) SphereX 2023 Terms&Conditions\n\npragma solidity ^0.8.17;\n\nimport {AccessControlDefaultAdminRules} from \"openzeppelin/access/AccessControlDefaultAdminRules.sol\";\nimport {ISphereXEngine} from \"./ISphereXEngine.sol\";\n\n/**\n * @title SphereX Engine\n * @notice Gathers information about an ongoing transaction and reverts if it seems malicious\n */\ncontract SphereXEngine is ISphereXEngine, AccessControlDefaultAdminRules {\n // the following are packed together for slot optimization and gas saving\n struct FlowConfiguration {\n uint16 depth;\n uint16 reserved;\n bool enforce;\n uint216 pattern;\n }\n\n // the following are packed together for slot optimization and gas saving\n struct EngineConfig {\n bytes8 rules;\n // The next variable is not a config but we place it here to save gas\n // Represent bytes16(keccak256(abi.encode(block.number, tx.origin, block.difficulty, block.timestamp)))\n bytes16 txBoundaryHash;\n bytes8 reserved;\n }\n\n EngineConfig internal _engineConfig = EngineConfig(0, bytes16(uint128(1)), 0);\n mapping(address => bool) internal _allowedSenders;\n mapping(uint216 => bool) internal _allowedPatterns;\n\n FlowConfiguration internal _flowConfig = FlowConfiguration(DEPTH_START, 0, false, PATTERN_START);\n\n mapping(uint256 => bool) internal _enforceFunction;\n\n uint216 internal constant PATTERN_START = 1;\n uint16 internal constant DEPTH_START = 1;\n bytes8 internal constant DEACTIVATED = bytes8(0);\n bytes8 internal constant CF = bytes8(uint64(1));\n bytes8 internal constant TXF = bytes8(uint64(2));\n bytes8 internal constant SELECTIVE_TXF = bytes8(uint64(4));\n bytes8 internal constant CF_AND_TXF_TOGETHER = CF | TXF;\n bytes8 internal constant CF_AND_SELECTIVE_TXF_TOGETHER = CF | SELECTIVE_TXF;\n bytes8 internal constant TXF_AND_SELECTIVE_TXF_TOGETHER = TXF | SELECTIVE_TXF;\n\n // the index of the addAllowedSenderOnChain in the call flow\n int256 internal constant ADD_ALLOWED_SENDER_ONCHAIN_INDEX = int256(uint256(keccak256(\"factory.allowed.sender\")));\n\n bytes32 public constant OPERATOR_ROLE = keccak256(\"OPERATOR_ROLE\");\n bytes32 public constant SENDER_ADDER_ROLE = keccak256(\"SENDER_ADDER_ROLE\");\n\n constructor() AccessControlDefaultAdminRules(1 days, msg.sender) {\n grantRole(OPERATOR_ROLE, msg.sender);\n }\n\n modifier onlyOperator() {\n require(hasRole(OPERATOR_ROLE, msg.sender), \"SphereX error: operator required\");\n _;\n }\n\n modifier onlySenderAdderRole() {\n require(hasRole(SENDER_ADDER_ROLE, msg.sender), \"SphereX error: sender adder required\");\n _;\n }\n\n event TxStartedAtIrregularDepth();\n event ConfigureRules(bytes8 oldRules, bytes8 newRules);\n event AddedAllowedSenders(address[] senders);\n event AddedAllowedSenderOnchain(address sender);\n event RemovedAllowedSenders(address[] senders);\n event AddedAllowedPatterns(uint216[] patterns);\n event RemovedAllowedPatterns(uint216[] patterns);\n event AddedEnforcedFunctions(uint256[] functions);\n event RemovedEnforcedFunctions(uint256[] functions);\n\n modifier returnsIfNotActivated() {\n if (_engineConfig.rules == DEACTIVATED) {\n return;\n }\n\n _;\n }\n\n modifier onlyApprovedSenders() {\n require(_allowedSenders[msg.sender], \"SphereX error: disallowed sender\");\n _;\n }\n\n // ============ Management ============\n\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(AccessControlDefaultAdminRules, ISphereXEngine)\n returns (bool)\n {\n return interfaceId == type(ISphereXEngine).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * Activate the guardian rules\n * @param rules bytes8 representing the new rules to activate.\n */\n function configureRules(bytes8 rules) external onlyOperator {\n require(CF_AND_TXF_TOGETHER & rules != CF_AND_TXF_TOGETHER, \"SphereX error: illegal rules combination\");\n require(\n CF_AND_SELECTIVE_TXF_TOGETHER & rules != CF_AND_SELECTIVE_TXF_TOGETHER,\n \"SphereX error: illegal rules combination\"\n );\n require(\n TXF_AND_SELECTIVE_TXF_TOGETHER & rules != TXF_AND_SELECTIVE_TXF_TOGETHER,\n \"SphereX error: illegal rules combination\"\n );\n require(uint64(rules) <= uint64(SELECTIVE_TXF), \"SphereX error: illegal rules combination\");\n bytes8 oldRules = _engineConfig.rules;\n _engineConfig.rules = rules;\n emit ConfigureRules(oldRules, rules);\n }\n\n /**\n * Deactivates the engine, the calls will return without being checked\n */\n function deactivateAllRules() external onlyOperator {\n bytes8 oldRules = _engineConfig.rules;\n _engineConfig.rules = DEACTIVATED;\n emit ConfigureRules(oldRules, 0);\n }\n\n /**\n * Adds addresses that will be served by this engine. An address that was never added will get a revert if it tries to call the engine.\n * @param senders list of address to add to the set of allowed addresses\n */\n function addAllowedSender(address[] calldata senders) external onlyOperator {\n for (uint256 i = 0; i < senders.length; ++i) {\n _allowedSenders[senders[i]] = true;\n }\n emit AddedAllowedSenders(senders);\n }\n\n /**\n * Adds address that will be served by this engine. An address that was never added will get a revert if it tries to call the engine.\n * @param sender address to add to the set of allowed addresses\n * @notice This function adds elements to the current pattern in order to guard itself from unwanted calls.\n * Lets say the client has a contract with SENDER_ADDER role and we approve only function indexed 1 to call addAllowedSenderOnChain.\n * We will allow the pattern [1, addAllowedSenderOnChain, -addAllowedSenderOnChain ,-1] and by doing so we guarantee no other function\n * will call addAllowedSenderOnChain.\n */\n function addAllowedSenderOnChain(address sender) external onlySenderAdderRole {\n _allowedSenders[sender] = true;\n emit AddedAllowedSenderOnchain(sender);\n }\n\n /**\n * Removes address so that they will not get served when calling the engine. Transaction from these addresses will get reverted.\n * @param senders list of address to stop service.\n */\n function removeAllowedSender(address[] calldata senders) external onlyOperator {\n for (uint256 i = 0; i < senders.length; ++i) {\n _allowedSenders[senders[i]] = false;\n }\n emit RemovedAllowedSenders(senders);\n }\n\n /**\n * Add allowed patterns - these are representation of allowed flows of transactions, and prefixes of these flows\n * @param patterns list of flows to allow as valid and non-malicious flows\n */\n function addAllowedPatterns(uint216[] calldata patterns) external onlyOperator {\n for (uint256 i = 0; i < patterns.length; ++i) {\n _allowedPatterns[patterns[i]] = true;\n }\n emit AddedAllowedPatterns(patterns);\n }\n\n /**\n * Remove allowed patterns - these are representation flows of transactions, and prefixes of these flows,\n * that are no longer considered valid and benign\n * @param patterns list of flows that no longer considered valid and non-malicious\n */\n function removeAllowedPatterns(uint216[] calldata patterns) external onlyOperator {\n for (uint256 i = 0; i < patterns.length; ++i) {\n _allowedPatterns[patterns[i]] = false;\n }\n emit RemovedAllowedPatterns(patterns);\n }\n\n /**\n * Add functions for enforcment (apply to selective txf)\n * @param functions function indexes to enforce flows\n */\n function includeEnforcedFunctions(uint256[] calldata functions) external onlyOperator {\n for (uint256 i = 0; i < functions.length; ++i) {\n _enforceFunction[functions[i]] = true;\n }\n emit AddedEnforcedFunctions(functions);\n }\n\n /**\n * Remove functions for enforcment (apply to selective txf)\n * @param functions function indexes to stop enforcing flows\n */\n function excludeEnforcedFunctions(uint256[] calldata functions) external onlyOperator {\n for (uint256 i = 0; i < functions.length; ++i) {\n _enforceFunction[functions[i]] = false;\n }\n emit RemovedEnforcedFunctions(functions);\n }\n\n function grantSenderAdderRole(address newSenderAdder) external onlyOperator {\n _grantRole(SENDER_ADDER_ROLE, newSenderAdder);\n }\n\n // ============ Guardians logic ============\n\n /**\n * Checks if CF is activated.\n */\n function _isCFActivated(bytes8 rules) internal view returns (bool) {\n return (rules & bytes8(CF)) > 0;\n }\n\n /**\n * Checks if selective txf is activated.\n */\n function _isSelectiveTxfActivated(bytes8 rules) internal view returns (bool) {\n return (rules & bytes8(SELECTIVE_TXF)) > 0;\n }\n\n /**\n * update the current CF pattern with a new positive number (signifying function entry),\n * @param num element to add to the flow.\n */\n function _addCfElementFunctionEntry(int256 num) internal {\n require(num > 0, \"SphereX error: expected positive num\");\n FlowConfiguration memory flowConfig = _flowConfig;\n EngineConfig memory engineConfig = _engineConfig;\n\n // Upon entry to a new function we should check if we are at the same transaction\n // or a new one. \n bytes16 currentTxBoundaryHash =\n bytes16(keccak256(abi.encode(block.number, tx.origin, block.timestamp, block.difficulty)));\n if (currentTxBoundaryHash != engineConfig.txBoundaryHash) {\n // in case of a new one we need to reinit the currentPattern, and save\n // the new transaction \"boundry\" (block.number+tx.origin+block.timestamp+block.difficulty)\n flowConfig.pattern = PATTERN_START;\n engineConfig.txBoundaryHash = currentTxBoundaryHash;\n flowConfig.enforce = false;\n if (flowConfig.depth != DEPTH_START) {\n // This is an edge case we (and the client) should be able to monitor easily.\n emit TxStartedAtIrregularDepth();\n flowConfig.depth = DEPTH_START;\n }\n\n _engineConfig.txBoundaryHash = engineConfig.txBoundaryHash;\n }\n\n if (_isSelectiveTxfActivated(engineConfig.rules)) {\n // if we are not in enforment mode then check if the current function turn it on\n if (!flowConfig.enforce && _enforceFunction[uint256(num)]) {\n flowConfig.enforce = true;\n }\n }\n\n flowConfig.pattern = uint216(bytes27(keccak256(abi.encode(num, flowConfig.pattern))));\n ++flowConfig.depth;\n\n _flowConfig = flowConfig;\n }\n\n /**\n * update the current CF pattern with a new negative number (signfying function exit),\n * under some conditions, this will also check the validity of the pattern.\n * @param num element to add to the flow. should be negative.\n * @param forceCheck force the check of the current pattern, even if normal test conditions don't exist.\n */\n function _addCfElementFunctionExit(int256 num, bool forceCheck) internal {\n require(num < 0, \"SphereX error: expected negative num\");\n FlowConfiguration memory flowConfig = _flowConfig;\n bytes8 rules = _engineConfig.rules;\n\n flowConfig.pattern = uint216(bytes27(keccak256(abi.encode(num, flowConfig.pattern))));\n --flowConfig.depth;\n\n if ((forceCheck) || (flowConfig.depth == DEPTH_START)) {\n if (_isSelectiveTxfActivated(rules)) {\n if (flowConfig.enforce) {\n _checkCallFlow(flowConfig.pattern);\n }\n } else {\n _checkCallFlow(flowConfig.pattern);\n }\n }\n\n // If we are configured to CF then if we reach depth == DEPTH_START we should reinit the\n // currentPattern\n if (flowConfig.depth == DEPTH_START && _isCFActivated(rules)) {\n flowConfig.pattern = PATTERN_START;\n }\n\n _flowConfig = flowConfig;\n }\n\n /**\n * Check if the current call flow pattern (that is, the result of the rolling hash) is an allowed pattern.\n */\n function _checkCallFlow(uint216 pattern) internal view {\n require(_allowedPatterns[pattern], \"SphereX error: disallowed tx pattern\");\n }\n\n /**\n * This is the function that is actually called by the modifier of the protected contract before the body of the function.\n * This is used only for external call functions.\n * @param num id of function to add. Should be positive\n * @param sender For future use\n * @param data For future use\n * @return result in the future will return instruction on what storage slots to gather, but not used for now\n */\n function sphereXValidatePre(int256 num, address sender, bytes calldata data)\n external\n override\n returnsIfNotActivated // may return empty bytes32[]\n onlyApprovedSenders\n returns (bytes32[] memory result)\n {\n _addCfElementFunctionEntry(num);\n return result;\n }\n\n /**\n * This is the function that is actually called by the modifier of the protected contract after the body of the function.\n * This is used only for external call functions (that is, external, and public when called outside the contract).\n * @param num id of function to add. Should be negative\n * @param valuesBefore For future use\n * @param valuesAfter For future use\n */\n function sphereXValidatePost(\n int256 num,\n uint256 gas,\n bytes32[] calldata valuesBefore,\n bytes32[] calldata valuesAfter\n ) external override returnsIfNotActivated onlyApprovedSenders {\n _addCfElementFunctionExit(num, true);\n }\n\n /**\n * This is the function that is actually called by the modifier of the protected contract before and after the body of the function.\n * This is used only for internal function calls (internal and private functions).\n * @param num id of function to add.\n */\n function sphereXValidateInternalPre(int256 num)\n external\n override\n returnsIfNotActivated\n onlyApprovedSenders\n returns (bytes32[] memory result)\n {\n _addCfElementFunctionEntry(num);\n }\n\n /**\n * This is the function that is actually called by the modifier of the protected contract before and after the body of the function.\n * This is used only for internal function calls (internal and private functions).\n * @param num id of function to add.\n */\n function sphereXValidateInternalPost(\n int256 num,\n uint256 gas,\n bytes32[] calldata valuesBefore,\n bytes32[] calldata valuesAfter\n ) external override returnsIfNotActivated onlyApprovedSenders {\n _addCfElementFunctionExit(num, false);\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/access/AccessControlDefaultAdminRules.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControlDefaultAdminRules.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./AccessControl.sol\";\nimport \"./IAccessControlDefaultAdminRules.sol\";\nimport \"../utils/math/SafeCast.sol\";\nimport \"../interfaces/IERC5313.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows specifying special rules to manage\n * the `DEFAULT_ADMIN_ROLE` holder, which is a sensitive role with special permissions\n * over other roles that may potentially have privileged rights in the system.\n *\n * If a specific role doesn't have an admin role assigned, the holder of the\n * `DEFAULT_ADMIN_ROLE` will have the ability to grant it and revoke it.\n *\n * This contract implements the following risk mitigations on top of {AccessControl}:\n *\n * * Only one account holds the `DEFAULT_ADMIN_ROLE` since deployment until it's potentially renounced.\n * * Enforces a 2-step process to transfer the `DEFAULT_ADMIN_ROLE` to another account.\n * * Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted.\n * * The delay can be changed by scheduling, see {changeDefaultAdminDelay}.\n * * It is not possible to use another role to manage the `DEFAULT_ADMIN_ROLE`.\n *\n * Example usage:\n *\n * ```solidity\n * contract MyToken is AccessControlDefaultAdminRules {\n * constructor() AccessControlDefaultAdminRules(\n * 3 days,\n * msg.sender // Explicit initial `DEFAULT_ADMIN_ROLE` holder\n * ) {}\n * }\n * ```\n *\n * _Available since v4.9._\n */\nabstract contract AccessControlDefaultAdminRules is IAccessControlDefaultAdminRules, IERC5313, AccessControl {\n // pending admin pair read/written together frequently\n address private _pendingDefaultAdmin;\n uint48 private _pendingDefaultAdminSchedule; // 0 == unset\n\n uint48 private _currentDelay;\n address private _currentDefaultAdmin;\n\n // pending delay pair read/written together frequently\n uint48 private _pendingDelay;\n uint48 private _pendingDelaySchedule; // 0 == unset\n\n /**\n * @dev Sets the initial values for {defaultAdminDelay} and {defaultAdmin} address.\n */\n constructor(uint48 initialDelay, address initialDefaultAdmin) {\n require(initialDefaultAdmin != address(0), \"AccessControl: 0 default admin\");\n _currentDelay = initialDelay;\n _grantRole(DEFAULT_ADMIN_ROLE, initialDefaultAdmin);\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlDefaultAdminRules).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC5313-owner}.\n */\n function owner() public view virtual returns (address) {\n return defaultAdmin();\n }\n\n ///\n /// Override AccessControl role management\n ///\n\n /**\n * @dev See {AccessControl-grantRole}. Reverts for `DEFAULT_ADMIN_ROLE`.\n */\n function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {\n require(role != DEFAULT_ADMIN_ROLE, \"AccessControl: can't directly grant default admin role\");\n super.grantRole(role, account);\n }\n\n /**\n * @dev See {AccessControl-revokeRole}. Reverts for `DEFAULT_ADMIN_ROLE`.\n */\n function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {\n require(role != DEFAULT_ADMIN_ROLE, \"AccessControl: can't directly revoke default admin role\");\n super.revokeRole(role, account);\n }\n\n /**\n * @dev See {AccessControl-renounceRole}.\n *\n * For the `DEFAULT_ADMIN_ROLE`, it only allows renouncing in two steps by first calling\n * {beginDefaultAdminTransfer} to the `address(0)`, so it's required that the {pendingDefaultAdmin} schedule\n * has also passed when calling this function.\n *\n * After its execution, it will not be possible to call `onlyRole(DEFAULT_ADMIN_ROLE)` functions.\n *\n * NOTE: Renouncing `DEFAULT_ADMIN_ROLE` will leave the contract without a {defaultAdmin},\n * thereby disabling any functionality that is only available for it, and the possibility of reassigning a\n * non-administrated role.\n */\n function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {\n if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) {\n (address newDefaultAdmin, uint48 schedule) = pendingDefaultAdmin();\n require(\n newDefaultAdmin == address(0) && _isScheduleSet(schedule) && _hasSchedulePassed(schedule),\n \"AccessControl: only can renounce in two delayed steps\"\n );\n delete _pendingDefaultAdminSchedule;\n }\n super.renounceRole(role, account);\n }\n\n /**\n * @dev See {AccessControl-_grantRole}.\n *\n * For `DEFAULT_ADMIN_ROLE`, it only allows granting if there isn't already a {defaultAdmin} or if the\n * role has been previously renounced.\n *\n * NOTE: Exposing this function through another mechanism may make the `DEFAULT_ADMIN_ROLE`\n * assignable again. Make sure to guarantee this is the expected behavior in your implementation.\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n if (role == DEFAULT_ADMIN_ROLE) {\n require(defaultAdmin() == address(0), \"AccessControl: default admin already granted\");\n _currentDefaultAdmin = account;\n }\n super._grantRole(role, account);\n }\n\n /**\n * @dev See {AccessControl-_revokeRole}.\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) {\n delete _currentDefaultAdmin;\n }\n super._revokeRole(role, account);\n }\n\n /**\n * @dev See {AccessControl-_setRoleAdmin}. Reverts for `DEFAULT_ADMIN_ROLE`.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual override {\n require(role != DEFAULT_ADMIN_ROLE, \"AccessControl: can't violate default admin rules\");\n super._setRoleAdmin(role, adminRole);\n }\n\n ///\n /// AccessControlDefaultAdminRules accessors\n ///\n\n /**\n * @inheritdoc IAccessControlDefaultAdminRules\n */\n function defaultAdmin() public view virtual returns (address) {\n return _currentDefaultAdmin;\n }\n\n /**\n * @inheritdoc IAccessControlDefaultAdminRules\n */\n function pendingDefaultAdmin() public view virtual returns (address newAdmin, uint48 schedule) {\n return (_pendingDefaultAdmin, _pendingDefaultAdminSchedule);\n }\n\n /**\n * @inheritdoc IAccessControlDefaultAdminRules\n */\n function defaultAdminDelay() public view virtual returns (uint48) {\n uint48 schedule = _pendingDelaySchedule;\n return (_isScheduleSet(schedule) && _hasSchedulePassed(schedule)) ? _pendingDelay : _currentDelay;\n }\n\n /**\n * @inheritdoc IAccessControlDefaultAdminRules\n */\n function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule) {\n schedule = _pendingDelaySchedule;\n return (_isScheduleSet(schedule) && !_hasSchedulePassed(schedule)) ? (_pendingDelay, schedule) : (0, 0);\n }\n\n /**\n * @inheritdoc IAccessControlDefaultAdminRules\n */\n function defaultAdminDelayIncreaseWait() public view virtual returns (uint48) {\n return 5 days;\n }\n\n ///\n /// AccessControlDefaultAdminRules public and internal setters for defaultAdmin/pendingDefaultAdmin\n ///\n\n /**\n * @inheritdoc IAccessControlDefaultAdminRules\n */\n function beginDefaultAdminTransfer(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {\n _beginDefaultAdminTransfer(newAdmin);\n }\n\n /**\n * @dev See {beginDefaultAdminTransfer}.\n *\n * Internal function without access restriction.\n */\n function _beginDefaultAdminTransfer(address newAdmin) internal virtual {\n uint48 newSchedule = SafeCast.toUint48(block.timestamp) + defaultAdminDelay();\n _setPendingDefaultAdmin(newAdmin, newSchedule);\n emit DefaultAdminTransferScheduled(newAdmin, newSchedule);\n }\n\n /**\n * @inheritdoc IAccessControlDefaultAdminRules\n */\n function cancelDefaultAdminTransfer() public virtual onlyRole(DEFAULT_ADMIN_ROLE) {\n _cancelDefaultAdminTransfer();\n }\n\n /**\n * @dev See {cancelDefaultAdminTransfer}.\n *\n * Internal function without access restriction.\n */\n function _cancelDefaultAdminTransfer() internal virtual {\n _setPendingDefaultAdmin(address(0), 0);\n }\n\n /**\n * @inheritdoc IAccessControlDefaultAdminRules\n */\n function acceptDefaultAdminTransfer() public virtual {\n (address newDefaultAdmin, ) = pendingDefaultAdmin();\n require(_msgSender() == newDefaultAdmin, \"AccessControl: pending admin must accept\");\n _acceptDefaultAdminTransfer();\n }\n\n /**\n * @dev See {acceptDefaultAdminTransfer}.\n *\n * Internal function without access restriction.\n */\n function _acceptDefaultAdminTransfer() internal virtual {\n (address newAdmin, uint48 schedule) = pendingDefaultAdmin();\n require(_isScheduleSet(schedule) && _hasSchedulePassed(schedule), \"AccessControl: transfer delay not passed\");\n _revokeRole(DEFAULT_ADMIN_ROLE, defaultAdmin());\n _grantRole(DEFAULT_ADMIN_ROLE, newAdmin);\n delete _pendingDefaultAdmin;\n delete _pendingDefaultAdminSchedule;\n }\n\n ///\n /// AccessControlDefaultAdminRules public and internal setters for defaultAdminDelay/pendingDefaultAdminDelay\n ///\n\n /**\n * @inheritdoc IAccessControlDefaultAdminRules\n */\n function changeDefaultAdminDelay(uint48 newDelay) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {\n _changeDefaultAdminDelay(newDelay);\n }\n\n /**\n * @dev See {changeDefaultAdminDelay}.\n *\n * Internal function without access restriction.\n */\n function _changeDefaultAdminDelay(uint48 newDelay) internal virtual {\n uint48 newSchedule = SafeCast.toUint48(block.timestamp) + _delayChangeWait(newDelay);\n _setPendingDelay(newDelay, newSchedule);\n emit DefaultAdminDelayChangeScheduled(newDelay, newSchedule);\n }\n\n /**\n * @inheritdoc IAccessControlDefaultAdminRules\n */\n function rollbackDefaultAdminDelay() public virtual onlyRole(DEFAULT_ADMIN_ROLE) {\n _rollbackDefaultAdminDelay();\n }\n\n /**\n * @dev See {rollbackDefaultAdminDelay}.\n *\n * Internal function without access restriction.\n */\n function _rollbackDefaultAdminDelay() internal virtual {\n _setPendingDelay(0, 0);\n }\n\n /**\n * @dev Returns the amount of seconds to wait after the `newDelay` will\n * become the new {defaultAdminDelay}.\n *\n * The value returned guarantees that if the delay is reduced, it will go into effect\n * after a wait that honors the previously set delay.\n *\n * See {defaultAdminDelayIncreaseWait}.\n */\n function _delayChangeWait(uint48 newDelay) internal view virtual returns (uint48) {\n uint48 currentDelay = defaultAdminDelay();\n\n // When increasing the delay, we schedule the delay change to occur after a period of \"new delay\" has passed, up\n // to a maximum given by defaultAdminDelayIncreaseWait, by default 5 days. For example, if increasing from 1 day\n // to 3 days, the new delay will come into effect after 3 days. If increasing from 1 day to 10 days, the new\n // delay will come into effect after 5 days. The 5 day wait period is intended to be able to fix an error like\n // using milliseconds instead of seconds.\n //\n // When decreasing the delay, we wait the difference between \"current delay\" and \"new delay\". This guarantees\n // that an admin transfer cannot be made faster than \"current delay\" at the time the delay change is scheduled.\n // For example, if decreasing from 10 days to 3 days, the new delay will come into effect after 7 days.\n return\n newDelay > currentDelay\n ? uint48(Math.min(newDelay, defaultAdminDelayIncreaseWait())) // no need to safecast, both inputs are uint48\n : currentDelay - newDelay;\n }\n\n ///\n /// Private setters\n ///\n\n /**\n * @dev Setter of the tuple for pending admin and its schedule.\n *\n * May emit a DefaultAdminTransferCanceled event.\n */\n function _setPendingDefaultAdmin(address newAdmin, uint48 newSchedule) private {\n (, uint48 oldSchedule) = pendingDefaultAdmin();\n\n _pendingDefaultAdmin = newAdmin;\n _pendingDefaultAdminSchedule = newSchedule;\n\n // An `oldSchedule` from `pendingDefaultAdmin()` is only set if it hasn't been accepted.\n if (_isScheduleSet(oldSchedule)) {\n // Emit for implicit cancellations when another default admin was scheduled.\n emit DefaultAdminTransferCanceled();\n }\n }\n\n /**\n * @dev Setter of the tuple for pending delay and its schedule.\n *\n * May emit a DefaultAdminDelayChangeCanceled event.\n */\n function _setPendingDelay(uint48 newDelay, uint48 newSchedule) private {\n uint48 oldSchedule = _pendingDelaySchedule;\n\n if (_isScheduleSet(oldSchedule)) {\n if (_hasSchedulePassed(oldSchedule)) {\n // Materialize a virtual delay\n _currentDelay = _pendingDelay;\n } else {\n // Emit for implicit cancellations when another delay was scheduled.\n emit DefaultAdminDelayChangeCanceled();\n }\n }\n\n _pendingDelay = newDelay;\n _pendingDelaySchedule = newSchedule;\n }\n\n ///\n /// Private helpers\n ///\n\n /**\n * @dev Defines if an `schedule` is considered set. For consistency purposes.\n */\n function _isScheduleSet(uint48 schedule) private pure returns (bool) {\n return schedule != 0;\n }\n\n /**\n * @dev Defines if an `schedule` is considered passed. For consistency purposes.\n */\n function _hasSchedulePassed(uint48 schedule) private view returns (bool) {\n return schedule < block.timestamp;\n }\n}\n"
},
"src/ISphereXEngine.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\n// (c) SphereX 2023 Terms&Conditions\n\npragma solidity ^0.8.0;\n\n/**\n * @title Interface for SphereXEngine - definitions of core functionality\n * @author SphereX Technologies ltd\n * @notice This interface is imported by SphereXProtected, so that SphereXProtected can call functions from SphereXEngine\n * @dev Full docs of these functions can be found in SphereXEngine\n */\n\ninterface ISphereXEngine {\n function sphereXValidatePre(int256 num, address sender, bytes calldata data) external returns (bytes32[] memory);\n function sphereXValidatePost(\n int256 num,\n uint256 gas,\n bytes32[] calldata valuesBefore,\n bytes32[] calldata valuesAfter\n ) external;\n function sphereXValidateInternalPre(int256 num) external returns (bytes32[] memory);\n function sphereXValidateInternalPost(\n int256 num,\n uint256 gas,\n bytes32[] calldata valuesBefore,\n bytes32[] calldata valuesAfter\n ) external;\n\n function addAllowedSenderOnChain(address sender) external;\n\n /**\n * This function is taken as is from OZ IERC165, we don't inherit from OZ\n * to avoid collisions with the customer OZ version.\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\n/**\n * @dev this struct is used to reduce the stack usage of the modifiers.\n */\nstruct ModifierLocals {\n bytes32[] storageSlots;\n bytes32[] valuesBefore;\n uint256 gas;\n}\n"
},
"lib/openzeppelin-contracts/contracts/access/AccessControl.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(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 _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(account),\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 _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/access/IAccessControlDefaultAdminRules.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/IAccessControlDefaultAdminRules.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlDefaultAdminRules declared to support ERC165 detection.\n *\n * _Available since v4.9._\n */\ninterface IAccessControlDefaultAdminRules is IAccessControl {\n /**\n * @dev Emitted when a {defaultAdmin} transfer is started, setting `newAdmin` as the next\n * address to become the {defaultAdmin} by calling {acceptDefaultAdminTransfer} only after `acceptSchedule`\n * passes.\n */\n event DefaultAdminTransferScheduled(address indexed newAdmin, uint48 acceptSchedule);\n\n /**\n * @dev Emitted when a {pendingDefaultAdmin} is reset if it was never accepted, regardless of its schedule.\n */\n event DefaultAdminTransferCanceled();\n\n /**\n * @dev Emitted when a {defaultAdminDelay} change is started, setting `newDelay` as the next\n * delay to be applied between default admin transfer after `effectSchedule` has passed.\n */\n event DefaultAdminDelayChangeScheduled(uint48 newDelay, uint48 effectSchedule);\n\n /**\n * @dev Emitted when a {pendingDefaultAdminDelay} is reset if its schedule didn't pass.\n */\n event DefaultAdminDelayChangeCanceled();\n\n /**\n * @dev Returns the address of the current `DEFAULT_ADMIN_ROLE` holder.\n */\n function defaultAdmin() external view returns (address);\n\n /**\n * @dev Returns a tuple of a `newAdmin` and an accept schedule.\n *\n * After the `schedule` passes, the `newAdmin` will be able to accept the {defaultAdmin} role\n * by calling {acceptDefaultAdminTransfer}, completing the role transfer.\n *\n * A zero value only in `acceptSchedule` indicates no pending admin transfer.\n *\n * NOTE: A zero address `newAdmin` means that {defaultAdmin} is being renounced.\n */\n function pendingDefaultAdmin() external view returns (address newAdmin, uint48 acceptSchedule);\n\n /**\n * @dev Returns the delay required to schedule the acceptance of a {defaultAdmin} transfer started.\n *\n * This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set\n * the acceptance schedule.\n *\n * NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this\n * function returns the new delay. See {changeDefaultAdminDelay}.\n */\n function defaultAdminDelay() external view returns (uint48);\n\n /**\n * @dev Returns a tuple of `newDelay` and an effect schedule.\n *\n * After the `schedule` passes, the `newDelay` will get into effect immediately for every\n * new {defaultAdmin} transfer started with {beginDefaultAdminTransfer}.\n *\n * A zero value only in `effectSchedule` indicates no pending delay change.\n *\n * NOTE: A zero value only for `newDelay` means that the next {defaultAdminDelay}\n * will be zero after the effect schedule.\n */\n function pendingDefaultAdminDelay() external view returns (uint48 newDelay, uint48 effectSchedule);\n\n /**\n * @dev Starts a {defaultAdmin} transfer by setting a {pendingDefaultAdmin} scheduled for acceptance\n * after the current timestamp plus a {defaultAdminDelay}.\n *\n * Requirements:\n *\n * - Only can be called by the current {defaultAdmin}.\n *\n * Emits a DefaultAdminRoleChangeStarted event.\n */\n function beginDefaultAdminTransfer(address newAdmin) external;\n\n /**\n * @dev Cancels a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}.\n *\n * A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function.\n *\n * Requirements:\n *\n * - Only can be called by the current {defaultAdmin}.\n *\n * May emit a DefaultAdminTransferCanceled event.\n */\n function cancelDefaultAdminTransfer() external;\n\n /**\n * @dev Completes a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}.\n *\n * After calling the function:\n *\n * - `DEFAULT_ADMIN_ROLE` should be granted to the caller.\n * - `DEFAULT_ADMIN_ROLE` should be revoked from the previous holder.\n * - {pendingDefaultAdmin} should be reset to zero values.\n *\n * Requirements:\n *\n * - Only can be called by the {pendingDefaultAdmin}'s `newAdmin`.\n * - The {pendingDefaultAdmin}'s `acceptSchedule` should've passed.\n */\n function acceptDefaultAdminTransfer() external;\n\n /**\n * @dev Initiates a {defaultAdminDelay} update by setting a {pendingDefaultAdminDelay} scheduled for getting\n * into effect after the current timestamp plus a {defaultAdminDelay}.\n *\n * This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this\n * method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay}\n * set before calling.\n *\n * The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then\n * calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin}\n * complete transfer (including acceptance).\n *\n * The schedule is designed for two scenarios:\n *\n * - When the delay is changed for a larger one the schedule is `block.timestamp + newDelay` capped by\n * {defaultAdminDelayIncreaseWait}.\n * - When the delay is changed for a shorter one, the schedule is `block.timestamp + (current delay - new delay)`.\n *\n * A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change.\n *\n * Requirements:\n *\n * - Only can be called by the current {defaultAdmin}.\n *\n * Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event.\n */\n function changeDefaultAdminDelay(uint48 newDelay) external;\n\n /**\n * @dev Cancels a scheduled {defaultAdminDelay} change.\n *\n * Requirements:\n *\n * - Only can be called by the current {defaultAdmin}.\n *\n * May emit a DefaultAdminDelayChangeCanceled event.\n */\n function rollbackDefaultAdminDelay() external;\n\n /**\n * @dev Maximum time in seconds for an increase to {defaultAdminDelay} (that is scheduled using {changeDefaultAdminDelay})\n * to take effect. Default to 5 days.\n *\n * When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with\n * the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds)\n * that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can\n * be overrode for a custom {defaultAdminDelay} increase scheduling.\n *\n * IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise,\n * there's a risk of setting a high new delay that goes into effect almost immediately without the\n * possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds).\n */\n function defaultAdminDelayIncreaseWait() external view returns (uint48);\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/interfaces/IERC5313.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5313.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface for the Light Contract Ownership Standard.\n *\n * A standardized minimal interface required to identify an account that controls a contract\n *\n * _Available since v4.9._\n */\ninterface IERC5313 {\n /**\n * @dev Gets the address of the owner.\n */\n function owner() external view returns (address);\n}\n"
},
"lib/openzeppelin-contracts/contracts/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(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n"
},
"lib/openzeppelin-contracts/contracts/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"
},
"lib/openzeppelin-contracts/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toString(int256 value) internal pure returns (string memory) {\n return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value))));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/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"
},
"lib/openzeppelin-contracts/contracts/utils/math/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1, \"Math: mulDiv overflow\");\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/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"
}
},
"settings": {
"remappings": [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
],
"optimizer": { "enabled": true, "runs": 200 },
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata"
]
}
},
"evmVersion": "paris",
"viaIR": false,
"libraries": {}
}
}