File size: 82,865 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
77
78
{
  "language": "Solidity",
  "sources": {
    "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    function __Ownable_init() internal onlyInitializing {\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal onlyInitializing {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n     * constructor.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: setting the version to 255 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     *\n     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized < type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint8) {\n        return _initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _initializing;\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    function __ReentrancyGuard_init() internal onlyInitializing {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        // On the first call to nonReentrant, _status will be _NOT_ENTERED\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
    },
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
    },
    "@openzeppelin/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"
    },
    "contracts/DividendPayingToken.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"./interfaces/DividendPayingTokenInterface.sol\";\nimport \"./interfaces/DividendPayingTokenOptionalInterface.sol\";\nimport \"./interfaces/IERC20.sol\";\nimport \"./library/SafeMath.sol\";\nimport \"./library/SafeMathUint.sol\";\nimport \"./library/SafeMathInt.sol\";\n\ncontract DividendPayingToken is DividendPayingTokenInterface, DividendPayingTokenOptionalInterface, Ownable {\n  using SafeMath for uint256;\n  using SafeMathUint for uint256;\n  using SafeMathInt for int256;\n\n  // With `magnitude`, we can properly distribute dividends even if the amount of received ether is small.\n  // For more discussion about choosing the value of `magnitude`,\n  //  see https://github.com/ethereum/EIPs/issues/1726#issuecomment-472352728\n  uint256 constant internal magnitude = 2**128;\n\n  uint256 internal magnifiedDividendPerShare;\n \n  address public token;\n                                                                                    \n  // About dividendCorrection:\n  // If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with:\n  //   `dividendOf(_user) = dividendPerShare * balanceOf(_user)`.\n  // When `balanceOf(_user)` is changed (via minting/burning/transferring tokens),\n  //   `dividendOf(_user)` should not be changed,\n  //   but the computed value of `dividendPerShare * balanceOf(_user)` is changed.\n  // To keep the `dividendOf(_user)` unchanged, we add a correction term:\n  //   `dividendOf(_user) = dividendPerShare * balanceOf(_user) + dividendCorrectionOf(_user)`,\n  //   where `dividendCorrectionOf(_user)` is updated whenever `balanceOf(_user)` is changed:\n  //   `dividendCorrectionOf(_user) = dividendPerShare * (old balanceOf(_user)) - (new balanceOf(_user))`.\n  // So now `dividendOf(_user)` returns the same value before and after `balanceOf(_user)` is changed.\n  mapping(address => int256) internal magnifiedDividendCorrections;\n  mapping(address => uint256) internal withdrawnDividends;\n  \n  mapping (address => uint256) public holderBalance;\n  uint256 public totalBalance;\n\n  uint256 public totalDividendsDistributed;\n  uint256 public totalDividendsWaitingToSend;\n\n  /// @dev Distributes dividends whenever ether is paid to this contract.\n  receive() external payable {\n    distributeDividends();\n  }\n\n  /// @notice Distributes ether to token holders as dividends.\n  /// @dev It reverts if the total supply of tokens is 0.\n  /// It emits the `DividendsDistributed` event if the amount of received ether is greater than 0.\n  /// About undistributed ether:\n  ///   In each distribution, there is a small amount of ether not distributed,\n  ///     the magnified amount of which is\n  ///     `(msg.value * magnitude) % totalSupply()`.\n  ///   With a well-chosen `magnitude`, the amount of undistributed ether\n  ///     (de-magnified) in a distribution can be less than 1 wei.\n  ///   We can actually keep track of the undistributed ether in a distribution\n  ///     and try to distribute it in the next distribution,\n  ///     but keeping track of such data on-chain costs much more than\n  ///     the saved ether, so we don't do that.\n    \n  function distributeDividends() public override payable {\n    require(false, \"Cannot send BNB directly to tracker as it is unrecoverable\"); // \n  }\n  \n  function distributeTokenDividends() external onlyOwner {\n    if(totalBalance > 0){\n        uint256 tokensToAdd;\n        uint256 balance = IERC20(token).balanceOf(address(this));\n\n        if(totalDividendsWaitingToSend < balance){\n            tokensToAdd = balance - totalDividendsWaitingToSend;\n        } else {\n            tokensToAdd = 0;\n        }\n\n        if (tokensToAdd > 0) {\n          magnifiedDividendPerShare = magnifiedDividendPerShare.add(\n            (tokensToAdd).mul(magnitude) / totalBalance\n        );\n        emit DividendsDistributed(msg.sender, tokensToAdd);\n\n        totalDividendsDistributed = totalDividendsDistributed.add(tokensToAdd);\n        totalDividendsWaitingToSend = totalDividendsWaitingToSend.add(tokensToAdd);\n        }\n    }\n  }\n\n  /// @notice Withdraws the ether distributed to the sender.\n  /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0.\n  function withdrawDividend() external virtual override {\n    _withdrawDividendOfUser(payable(msg.sender));\n  }\n\n  /// @notice Withdraws the ether distributed to the sender.\n  /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0.\n  function _withdrawDividendOfUser(address payable user) internal returns (uint256) {\n    uint256 _withdrawableDividend = withdrawableDividendOf(user);\n    if (_withdrawableDividend > 0) {\n      withdrawnDividends[user] = withdrawnDividends[user].add(_withdrawableDividend);\n      if(totalDividendsWaitingToSend >= _withdrawableDividend){\n        totalDividendsWaitingToSend -= _withdrawableDividend;\n      }\n      else {\n        totalDividendsWaitingToSend = 0;  \n      }\n      emit DividendWithdrawn(user, _withdrawableDividend);\n      bool success = IERC20(token).transfer(user, _withdrawableDividend);\n\n      if(!success) {\n        withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend);\n        return 0;\n      }\n\n      return _withdrawableDividend;\n    }\n    return 0;\n  }\n\n\n  /// @notice View the amount of dividend in wei that an address can withdraw.\n  /// @param _owner The address of a token holder.\n  /// @return The amount of dividend in wei that `_owner` can withdraw.\n  function dividendOf(address _owner) external view override returns(uint256) {\n    return withdrawableDividendOf(_owner);\n  }\n\n  /// @notice View the amount of dividend in wei that an address can withdraw.\n  /// @param _owner The address of a token holder.\n  /// @return The amount of dividend in wei that `_owner` can withdraw.\n  function withdrawableDividendOf(address _owner) public view override returns(uint256) {\n    return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]);\n  }\n\n  /// @notice View the amount of dividend in wei that an address has withdrawn.\n  /// @param _owner The address of a token holder.\n  /// @return The amount of dividend in wei that `_owner` has withdrawn.\n  function withdrawnDividendOf(address _owner) external view override returns(uint256) {\n    return withdrawnDividends[_owner];\n  }\n\n\n  /// @notice View the amount of dividend in wei that an address has earned in total.\n  /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner)\n  /// = (magnifiedDividendPerShare * balanceOf(_owner) + magnifiedDividendCorrections[_owner]) / magnitude\n  /// @param _owner The address of a token holder.\n  /// @return The amount of dividend in wei that `_owner` has earned in total.\n  function accumulativeDividendOf(address _owner) public view override returns(uint256) {\n\n    return magnifiedDividendPerShare.mul(holderBalance[_owner]).toInt256Safe()\n      .add(magnifiedDividendCorrections[_owner]).toUint256Safe() / magnitude;\n  }\n\n  /// @dev Internal function that increases tokens to an account.\n  /// Update magnifiedDividendCorrections to keep dividends unchanged.\n  /// @param account The account that will receive the created tokens.\n  /// @param value The amount that will be created.\n  function _increase(address account, uint256 value) internal {\n    magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account]\n      .sub( (magnifiedDividendPerShare.mul(value)).toInt256Safe() );\n  }\n\n  /// @dev Internal function that reduces an amount of the token of a given account.\n  /// Update magnifiedDividendCorrections to keep dividends unchanged.\n  /// @param account The account whose tokens will be burnt.\n  /// @param value The amount that will be burnt.\n  function _reduce(address account, uint256 value) internal {\n    magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account]\n      .add( (magnifiedDividendPerShare.mul(value)).toInt256Safe() );\n  }\n\n  function _setBalance(address account, uint256 newBalance) internal {\n    uint256 currentBalance = holderBalance[account];\n    holderBalance[account] = newBalance;\n    if(newBalance > currentBalance) {\n      uint256 increaseAmount = newBalance.sub(currentBalance);\n\n      _increase(account, increaseAmount);\n      totalBalance += increaseAmount;\n    } else if(newBalance < currentBalance) {\n      uint256 reduceAmount = currentBalance.sub(newBalance);\n      _reduce(account, reduceAmount);\n      totalBalance -= reduceAmount;\n    }\n  }\n}"
    },
    "contracts/DividendTracker.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nimport \"./DividendPayingToken.sol\";\n\ncontract DividendTrackers is DividendPayingToken {\n    using SafeMath for uint256;\n    using SafeMathInt for int256;\n\n    struct Map {\n        address[] keys;\n        mapping(address => uint) values;\n        mapping(address => uint) indexOf;\n        mapping(address => bool) inserted;\n    }\n\n    function get(address key) private view returns (uint) {\n        return tokenHoldersMap.values[key];\n    }\n\n    function getIndexOfKey(address key) private view returns (int) {\n        if(!tokenHoldersMap.inserted[key]) {\n            return -1;\n        }\n        return int(tokenHoldersMap.indexOf[key]);\n    }\n\n    function getKeyAtIndex(uint index) private view returns (address) {\n        return tokenHoldersMap.keys[index];\n    }\n\n    function size() private view returns (uint) {\n        return tokenHoldersMap.keys.length;\n    }\n\n    function set(address key, uint val) private {\n        if (tokenHoldersMap.inserted[key]) {\n            tokenHoldersMap.values[key] = val;\n        } else {\n\n            tokenHoldersMap.inserted[key] = true;\n            tokenHoldersMap.values[key] = val;\n            tokenHoldersMap.indexOf[key] = tokenHoldersMap.keys.length;\n            tokenHoldersMap.keys.push(key);\n        }\n    }\n\n    function remove(address key) private {\n        if (!tokenHoldersMap.inserted[key]) {\n            return;\n        }\n\n        delete tokenHoldersMap.inserted[key];\n        delete tokenHoldersMap.values[key];\n\n        uint index = tokenHoldersMap.indexOf[key];\n        uint lastIndex = tokenHoldersMap.keys.length - 1;\n        address lastKey = tokenHoldersMap.keys[lastIndex];\n\n        tokenHoldersMap.indexOf[lastKey] = index;\n        delete tokenHoldersMap.indexOf[key];\n\n        tokenHoldersMap.keys[index] = lastKey;\n        tokenHoldersMap.keys.pop();\n    }\n\n    Map tokenHoldersMap;\n    uint256 public lastProcessedIndex;\n\n    mapping (address => bool) public excludedFromDividends;\n    mapping (address=> uint256) public amountEarn;\n    mapping (address => uint256) public lastClaimTimes;\n\n    uint256 public claimWait;\n    uint256 public immutable minimumTokenBalanceForDividends;\n\n    event ExcludeFromDividends(address indexed account);\n    event IncludeInDividends(address indexed account);\n    event ClaimWaitUpdated(uint256 indexed newValue, uint256 indexed oldValue);\n    event Claim(address indexed account, uint256 amount, bool indexed automatic);\n\n    constructor(address _token) {\n    \tclaimWait = 1;\n        minimumTokenBalanceForDividends = 1;\n        token = _token;\n    }\n\n    function excludeFromDividends(address account) external onlyOwner {\n    \texcludedFromDividends[account] = true;\n\n    \t_setBalance(account, 0);\n    \tremove(account);\n\n    \temit ExcludeFromDividends(account);\n    }\n    \n    function includeInDividends(address account) external onlyOwner {\n    \trequire(excludedFromDividends[account]);\n    \texcludedFromDividends[account] = false;\n\n    \temit IncludeInDividends(account);\n    }\n\n    function updateClaimWait(uint256 newClaimWait) external onlyOwner {\n        require(newClaimWait >= 1200 && newClaimWait <= 86400, \"Dividend_Tracker: claimWait must be updated to between 1 and 24 hours\");\n        require(newClaimWait != claimWait, \"Dividend_Tracker: Cannot update claimWait to same value\");\n        emit ClaimWaitUpdated(newClaimWait, claimWait);\n        claimWait = newClaimWait;\n    }\n\n    function getLastProcessedIndex() external view returns(uint256) {\n    \treturn lastProcessedIndex;\n    }\n\n    function getNumberOfTokenHolders() external view returns(uint256) {\n        return tokenHoldersMap.keys.length;\n    }\n\n    // Check to see if I really made this contract or if it is a clone!\n    // @Sir_Tris on TG, @SirTrisCrypto on Twitter\n\n    function getAccount(address _account)\n        public view returns (\n            address account,\n            int256 index,\n            int256 iterationsUntilProcessed,\n            uint256 withdrawableDividends,\n            uint256 totalDividends,\n            uint256 lastClaimTime,\n            uint256 nextClaimTime,\n            uint256 secondsUntilAutoClaimAvailable) {\n        account = _account;\n\n        index = getIndexOfKey(account);\n\n        iterationsUntilProcessed = -1;\n\n        if(index >= 0) {\n            if(uint256(index) > lastProcessedIndex) {\n                iterationsUntilProcessed = index.sub(int256(lastProcessedIndex));\n            }\n            else {\n                uint256 processesUntilEndOfArray = tokenHoldersMap.keys.length > lastProcessedIndex ?\n                                                        tokenHoldersMap.keys.length.sub(lastProcessedIndex) :\n                                                        0;\n\n\n                iterationsUntilProcessed = index.add(int256(processesUntilEndOfArray));\n            }\n        }\n\n\n        withdrawableDividends = withdrawableDividendOf(account);\n        totalDividends = accumulativeDividendOf(account);\n\n        lastClaimTime = lastClaimTimes[account];\n\n        nextClaimTime = lastClaimTime > 0 ?\n                                    lastClaimTime.add(claimWait) :\n                                    0;\n\n        secondsUntilAutoClaimAvailable = nextClaimTime > block.timestamp ?\n                                                    nextClaimTime.sub(block.timestamp) :\n                                                    0;\n    }\n\n    function getAccountAtIndex(uint256 index)\n        external view returns (\n            address,\n            int256,\n            int256,\n            uint256,\n            uint256,\n            uint256,\n            uint256,\n            uint256) {\n    \tif(index >= size()) {\n            return (0x0000000000000000000000000000000000000000, -1, -1, 0, 0, 0, 0, 0);\n        }\n\n        address account = getKeyAtIndex(index);\n\n        return getAccount(account);\n    }\n\n    function canAutoClaim(uint256 lastClaimTime) private view returns (bool) {\n    \tif(lastClaimTime > block.timestamp)  {\n    \t\treturn false;\n    \t}\n\n    \treturn block.timestamp.sub(lastClaimTime) >= claimWait;\n    }\n\n    function setBalance(address payable account, uint256 newBalance) external onlyOwner {\n    \tif(excludedFromDividends[account]) {\n    \t\treturn;\n    \t}\n    \tif(newBalance >= minimumTokenBalanceForDividends) {\n            _setBalance(account, newBalance);\n    \t\tset(account, newBalance);\n    \t}\n    \telse {\n\n            _setBalance(account, 0);\n    \t\tremove(account);\n    \t}\n\n    \tprocessAccount(account, true);\n    }\n    \n    \n    function process(uint256 gas) external returns (uint256, uint256, uint256) {\n    \tuint256 numberOfTokenHolders = tokenHoldersMap.keys.length;\n\n    \tif(numberOfTokenHolders == 0) {\n    \t\treturn (0, 0, lastProcessedIndex);\n    \t}\n\n    \tuint256 _lastProcessedIndex = lastProcessedIndex;\n\n    \tuint256 gasUsed = 0;\n\n    \tuint256 gasLeft = gasleft();\n\n    \tuint256 iterations = 0;\n    \tuint256 claims = 0;\n\n    \twhile(gasUsed < gas && iterations < numberOfTokenHolders) {\n    \t\t_lastProcessedIndex++;\n\n    \t\tif(_lastProcessedIndex >= tokenHoldersMap.keys.length) {\n    \t\t\t_lastProcessedIndex = 0;\n    \t\t}\n\n    \t\taddress account = tokenHoldersMap.keys[_lastProcessedIndex];\n\n    \t\tif(canAutoClaim(lastClaimTimes[account])) {\n    \t\t\tif(processAccount(payable(account), true)) {\n    \t\t\t\tclaims++;\n    \t\t\t}\n    \t\t}\n\n    \t\titerations++;\n\n    \t\tuint256 newGasLeft = gasleft();\n\n    \t\tif(gasLeft > newGasLeft) {\n    \t\t\tgasUsed = gasUsed.add(gasLeft.sub(newGasLeft));\n    \t\t}\n    \t\tgasLeft = newGasLeft;\n    \t}\n\n    \tlastProcessedIndex = _lastProcessedIndex;\n    \treturn (iterations, claims, lastProcessedIndex);\n    }\n\n    function processAccount(address payable account, bool automatic) public onlyOwner returns (bool) {\n        uint256 amount = _withdrawDividendOfUser(account);\n        amountEarn[account] += amount;\n\n    \tif(amount > 0) {\n    \t\tlastClaimTimes[account] = block.timestamp;\n            // claimedAmount[account] = amount;\n            emit Claim(account, amount, automatic);\n    \t\treturn true;\n    \t}\n\n    \treturn false;\n    }\n}"
    },
    "contracts/EHXSoloStaking.sol": {
      "content": "//SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport \"./interfaces/IERC20.sol\";\nimport \"./interfaces/IEHXToken.sol\";\nimport \"./library/SafeMath.sol\";\nimport \"./library/EnumerableSet.sol\";\nimport \"./DividendTracker.sol\";\n\ncontract EHXSoloStaking is OwnableUpgradeable,ReentrancyGuardUpgradeable {\n    using SafeMath for uint256;\n\n    using EnumerableSet for EnumerableSet.AddressSet;\n\n    DividendTrackers public dividendTracker;\n\n    IERC20 public USDC;\n\n    // Info of each user.\n    struct UserInfo {\n        uint256 amount;     // How many staking tokens the user has provided.\n        uint256 rewardDebt; // Reward debt. See explanation below.\n        uint256 unstakeUnlock;\n        uint256 stakeCollected;  //amount of stake collected by the user\n        uint256 unstakeAmount;\n        uint256 rewardsClaimTime;\n        uint256 stakingTime;\n        uint256 unstakingTime;\n    }\n\n    // Info of each pool.\n    struct PoolInfo {\n        IERC20 lpToken;           // Address of staking token contract.\n        uint256 allocPoint;       // How many allocation points assigned to this pool. Tokens to distribute per block.\n        uint256 lastRewardTimestamp;  // Last block number that Tokens distribution occurs.\n        uint256 accTokensPerShare; // Accumulated Tokens per share, times 1e12. See below.\n    }\n\n    bool public claimPaused = false;\n\n    EnumerableSet.AddressSet private walletsOutstanding;\n    mapping(address => uint256) public totalAmount;\n    mapping(address => uint256) public claimedAmount;\n    mapping(address => uint256) public lastClaim;\n    mapping(address => uint256) public totalClaimDuration;\n    mapping(address => uint256) public firstClaimPercent;\n    mapping(address => bool) public claimedFirst;\n    mapping(address => uint256) public rewardsPending;\n    mapping(address => uint256) public rewardsClaimed;      ////// mapping for storing rewards accumulated by the user\n\n    uint256 public totalPendingUnstakedTokens;\n    uint256 public unstakeLockDuration = 7 days;\n    uint256 public constant MAX_UNSTAKE_DURATION = 21 days;\n    \n    event AllocatedTokens(address indexed wallet, uint256 amount);\n    event ResetAllocation(address indexed wallet);\n    event ClaimedTokens(address indexed wallet,  uint256 amount);\n    event Initialized();\n\n\n    IERC20 public stakingToken;\n    IERC20 public rewardToken;\n    mapping (address => uint256) public holderUnlockTime;\n\n    uint256 public totalStaked;\n    uint256 public apy;\n    uint256 public lockDuration;\n    uint256 public exitPenaltyPerc;\n\n    // Info of each user that stakes LP tokens.\n    mapping (address => UserInfo) public userInfo;\n    \n    PoolInfo public pool;\n    // Total allocation poitns. Must be the sum of all allocation points in all pools.\n    uint256 private totalAllocPoint = 0;\n\n    event Deposit(address indexed user, uint256 amount);\n    event Withdraw(address indexed user, uint256 amount);\n    event WithdrawUnstakedTokens(address indexed user, uint256 amount);\n    event EmergencyWithdraw(address indexed user, uint256 amount);\n    event StakedNFT(address indexed nftAddress, uint256 indexed tokenId, address indexed sender);\n    event UnstakedNFT(address indexed nftAddress, uint256 indexed tokenId, address indexed sender);\n\n    function initialize(address _stakingToken, uint256 _apy, uint256 _lockDuration, uint256 _exitPenalty) external initializer{\n        stakingToken = IERC20(_stakingToken);\n        rewardToken = IERC20(_stakingToken);\n        address profitSharingToken;\n        __Ownable_init();\n        if(block.chainid == 1){\n            profitSharingToken = 0xdAC17F958D2ee523a2206206994597C13D831ec7; // USDT\n        }\n        // } else if(block.chainid == 4){\n        //     profitSharingToken  = 0xE7d541c18D6aDb863F4C570065c57b75a53a64d3; // Rinkeby Testnet USDC\n        // } else if(block.chainid == 56){\n        //     profitSharingToken  = 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56; // BUSD\n        // } else if(block.chainid == 97){\n        //     profitSharingToken  = 0xD0Db716Bff27bc4cDc9dD855Ed86f20c4390BEd6; // BSC Testnet BUSD\n        // } else {\n        //     profitSharingToken  = 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512;\n        //     // revert(\"Chain not configured\");\n        // } \n\n        USDC = IERC20(address(profitSharingToken));\n\n        dividendTracker = new DividendTrackers(profitSharingToken);\n\n        apy = _apy;\n        lockDuration = _lockDuration;\n        exitPenaltyPerc = _exitPenalty;\n        pool.lpToken = IERC20(_stakingToken);\n        pool.allocPoint = 1000;\n        pool.lastRewardTimestamp = block.timestamp;\n        pool.accTokensPerShare = 0;\n        totalAllocPoint = 1000;\n        emit Initialized();\n    }\n\n    function stopReward() external onlyOwner {\n        updatePool();\n        apy = 0;\n    }\n\n    // View function to see pending Reward on frontend.\n    function pendingReward(address _user) public view returns (uint256) {\n        UserInfo storage user = userInfo[_user];\n        if(pool.lastRewardTimestamp == 99999999999){\n            return 0;\n        }\n        uint256 accTokensPerShare = pool.accTokensPerShare;\n        uint256 lpSupply = totalStaked;\n        if (block.timestamp > pool.lastRewardTimestamp && lpSupply != 0) {\n            uint256 tokenReward = calculateNewRewards().mul(pool.allocPoint).div(totalAllocPoint);\n            accTokensPerShare = accTokensPerShare.add(tokenReward.mul(1e12).div(lpSupply));\n        }\n        return user.amount.mul(accTokensPerShare).div(1e12).sub(user.rewardDebt);\n    }\n\n    // Update reward variables of the given pool to be up-to-date.\n    function updatePool() internal {\n        // transfer any accumulated tokens.\n        if(USDC.balanceOf(address(this)) > 0){\n            USDC.transfer(address(dividendTracker), USDC.balanceOf(address(this)));\n            dividendTracker.distributeTokenDividends();\n        }\n        // PoolInfo storage pool = poolInfo[_pid];\n        if (block.timestamp <= pool.lastRewardTimestamp) {\n            return;\n        }\n        uint256 lpSupply = totalStaked;\n        if (lpSupply == 0) { \n            pool.lastRewardTimestamp = block.timestamp;\n            return;\n        }\n\n        uint256 tokenReward = calculateNewRewards().mul(pool.allocPoint).div(totalAllocPoint);\n        IEHXToken(address(rewardToken)).mintTokens(address(this), tokenReward);\n        pool.accTokensPerShare = pool.accTokensPerShare.add(tokenReward.mul(1e12).div(lpSupply));\n        pool.lastRewardTimestamp = block.timestamp;\n    }\n\n    // Update reward variables for all pools. Be careful of gas spending!\n    function massUpdatePools() public onlyOwner {\n            updatePool();\n    }\n\n    // Stake primary tokens = IEHX token\n    function deposit(uint256 _amount) public nonReentrant {\n        if(holderUnlockTime[msg.sender] == 0){\n            holderUnlockTime[msg.sender] = block.timestamp + lockDuration;\n        }\n        UserInfo storage user = userInfo[msg.sender];\n\n        updatePool();\n        if (user.amount > 0) {\n            uint256 pending = user.amount.mul(pool.accTokensPerShare).div(1e12).sub(user.rewardDebt);\n            if(pending > 0) {\n                if(pending >= rewardsRemaining()){\n                    pending = rewardsRemaining();\n                }\n                rewardsPending[msg.sender] = pending;\n                user.rewardsClaimTime= block.timestamp;                \n                rewardToken.transfer(payable(address(msg.sender)), pending);\n            }\n        }\n\n        uint256 amountTransferred = 0;\n        if(_amount > 0) {\n            uint256 initialBalance = pool.lpToken.balanceOf(address(this));\n            user.stakingTime = block.timestamp;                    \n            pool.lpToken.transferFrom(address(msg.sender), address(this), _amount);\n            amountTransferred = pool.lpToken.balanceOf(address(this)) - initialBalance;\n            user.amount = user.amount.add(amountTransferred);\n            totalStaked += amountTransferred;\n        }\n\n        dividendTracker.setBalance(payable(msg.sender), user.amount);\n        user.rewardDebt = user.amount.mul(pool.accTokensPerShare).div(1e12);\n\n        emit Deposit(msg.sender, _amount);\n    }\n\n    function receivableReferrenceFees(address _user) public view returns(uint256){\n        UserInfo storage user = userInfo[_user];\n        if(user.amount == 0){\n            return 20;\n        }\n        else if(user.amount>=3000*10**18 && user.amount<16000*10**18){\n            return 50;\n        }\n        else if(user.amount>=16000*10**18 && user.amount<85000*10**18){\n            return 70;\n        }\n        else if(user.amount>=85000*10**18 && user.amount<250000*10**18){\n            return 80;\n        }\n        else{\n            return 100;\n        }\n    }\n    \n    // Withdraw primary tokens from STAKING.\n\n    function withdraw(uint256 _amount) public nonReentrant {\n\n        require(holderUnlockTime[msg.sender] <= block.timestamp, \"May not do normal withdraw early\");\n        \n        UserInfo storage user = userInfo[msg.sender];\n        \n        require(_amount <= amountWithdrawable(msg.sender) , \"Cannot withdraw vesting tokens.\");\n\n        updatePool();\n        uint256 pending = user.amount.mul(pool.accTokensPerShare).div(1e12).sub(user.rewardDebt);\n        if(pending > 0) {\n            if(pending >= rewardsRemaining()){\n                pending = rewardsRemaining();\n            }\n            rewardsClaimed[msg.sender]+=pending;  \n            rewardsPending[msg.sender]=0;  \n            user.rewardsClaimTime= block.timestamp;                \n            rewardToken.transfer(payable(address(msg.sender)), pending);\n        }\n\n        if(_amount > 0) {\n            user.amount -= _amount;\n            totalStaked -= _amount;\n            user.unstakeUnlock = block.timestamp + unstakeLockDuration;\n            user.unstakeAmount += _amount;\n            user.stakeCollected += _amount;\n            totalPendingUnstakedTokens += _amount;\n            // pool.lpToken.transfer(address(msg.sender),_amount);\n        }\n\n        dividendTracker.setBalance(payable(msg.sender), user.amount);\n        user.rewardDebt = user.amount.mul(pool.accTokensPerShare).div(1e12);\n        \n        if(user.amount > 0){\n            holderUnlockTime[msg.sender] = block.timestamp + lockDuration;\n        } else {\n            holderUnlockTime[msg.sender] = 0;\n        }\n        emit Withdraw(msg.sender, _amount);\n    }\n\n    function withdrawUnstakedTokens() external  nonReentrant {\n        UserInfo storage user = userInfo[msg.sender];\n        require(user.unstakeUnlock > 0, \"No tokens to unstake\");\n        require(user.unstakeUnlock <= block.timestamp, \"Tokens not unlocked yet\");\n        uint256 amountToWithdraw = user.unstakeAmount;\n        user.unstakeUnlock = 0;\n        user.unstakeAmount = 0;\n        totalPendingUnstakedTokens -= amountToWithdraw;\n        user.stakeCollected+=amountToWithdraw;\n        user.unstakingTime = block.timestamp;\n        pool.lpToken.transfer(address(msg.sender), amountToWithdraw);\n\n        emit WithdrawUnstakedTokens(msg.sender, amountToWithdraw);\n    }\n\n    // Withdraw without caring about rewards. EMERGENCY ONLY.\n    function emergencyWithdraw() external nonReentrant {\n        require(!isWalletVesting(msg.sender), \"Wallet is vesting and cannot emergency withdraw.\");\n        \n        UserInfo storage user = userInfo[msg.sender];\n        uint256 _amount = user.amount;\n        totalStaked -= _amount;\n        // exit penalty for early unstakers, penalty held on contract as rewards.\n        if(holderUnlockTime[msg.sender] >= block.timestamp){\n            _amount -= _amount * exitPenaltyPerc / 100;\n        }\n        holderUnlockTime[msg.sender] = 0;\n        user.unstakeUnlock = block.timestamp + unstakeLockDuration;\n        user.unstakeAmount += _amount;\n        totalPendingUnstakedTokens += _amount;\n        user.amount = 0;\n        user.rewardDebt = 0;\n        dividendTracker.setBalance(payable(msg.sender), 0);\n        emit EmergencyWithdraw(msg.sender, _amount);\n    }\n\n    function getUnstakeUnlockTime(address account) external view returns (uint256 secondsRemaining, uint256 unstakeTimestamp){\n        UserInfo memory user = userInfo[account];\n        if(user.unstakeUnlock == 0){\n            return (0, 0);\n        } else if (user.unstakeUnlock <= block.timestamp) {\n            return (0, user.unstakeUnlock);\n        } else {\n            return (user.unstakeUnlock - block.timestamp, user.unstakeUnlock);\n        }\n    }\n\n    // Withdraw reward. EMERGENCY ONLY. This allows the owner to migrate rewards to a new staking pool since we are not minting new tokens.\n    function emergencyRewardWithdraw(uint256 _amount) external onlyOwner {\n        require(_amount <= rewardsRemaining(), 'not enough tokens to take out');\n        UserInfo memory user = userInfo[msg.sender];\n\n        rewardsClaimed[msg.sender]+=_amount;      \n        user.rewardsClaimTime= block.timestamp;                \n        rewardToken.transfer(address(msg.sender), _amount);\n    }\n\n    function setUnstakeUnlockDuration(uint256 durationInSeconds) external onlyOwner {\n        require(durationInSeconds <= 21 days, \"Too high\");\n        unstakeLockDuration = durationInSeconds;\n    }\n\n    function calculateNewRewards() public view returns (uint256) {\n        if(pool.lastRewardTimestamp > block.timestamp){\n            return 0;\n        }\n        return (((block.timestamp - pool.lastRewardTimestamp) * totalStaked) * apy / 100 / 365 days);\n        \n    }\n\n    function rewardsRemaining() public view returns (uint256){\n        return rewardToken.balanceOf(address(this)) - totalStaked - totalPendingUnstakedTokens;\n    }\n\n    function updateApy(uint256 newApy) external onlyOwner {\n        require(newApy <= 10000, \"APY must be below 10000%\");\n        updatePool();\n        apy = newApy;\n    }\n\n    function updateExitPenalty(uint256 newPenaltyPerc) external onlyOwner {\n        require(newPenaltyPerc <= 20, \"May not set higher than 20%\");\n        exitPenaltyPerc = newPenaltyPerc;\n    }\n\n    function claim() external nonReentrant {\n        dividendTracker.processAccount(payable(msg.sender), false);\n    }\n\n    // Vesting information\n\n    function vestTokens(\n        address[] calldata wallets,     \n        uint256[] calldata amountsWithDecimals, \n        uint256[] calldata totalDurationInSeconds, \n        uint256[] calldata timeBeforeFirstClaim, \n        uint256[] calldata firstClaimInitialPercent) \n        external onlyOwner {\n        \n        updatePool(); // ensure no larger claims made based on new balances\n        require(wallets.length == amountsWithDecimals.length, \"array lengths must match\");\n        address wallet;\n        uint256 amount;\n        uint256 total;\n        for(uint256 i = 0; i < wallets.length; i++){\n            wallet = wallets[i];\n            amount = amountsWithDecimals[i];\n            total += amount;\n            UserInfo storage user = userInfo[wallet];\n            totalAmount[wallet] += amount;\n            user.amount += amount;\n            totalStaked += amount;\n            require(totalDurationInSeconds[i] > 0, \"Total Duration must be > 0\");\n            totalClaimDuration[wallet] = totalDurationInSeconds[i];\n            firstClaimPercent[wallet] = firstClaimInitialPercent[i];\n            if(lastClaim[wallet] == 0){\n                lastClaim[wallet] = block.timestamp + timeBeforeFirstClaim[i];\n            }\n            emit AllocatedTokens(wallet, amount);\n            if(!walletsOutstanding.contains(wallet)){\n                walletsOutstanding.add(wallet);\n            }\n        }\n\n        IEHXToken(address(stakingToken)).mintTokens(address(this), total);\n    }\n\n    // for resetting allocation in the event of a mistake\n    function resetAllocation(address[] calldata wallets) external onlyOwner {\n        for(uint256 i = 0; i < wallets.length; i++){\n            totalAmount[wallets[i]] = 0;\n            lastClaim[wallets[i]] = 0;\n            walletsOutstanding.remove(wallets[i]);\n            emit ResetAllocation(wallets[i]);\n        }\n    }\n\n    modifier notPaused {\n        require(!claimPaused, \"Claim is paused\");\n        _;\n    }\n\n    function setClaimPaused(bool paused) external onlyOwner {\n        claimPaused = paused;\n    }\n\n    function claimVestedTokens() external notPaused nonReentrant {\n        updatePool();\n        uint256 amountToClaim = currentClaimableAmount(msg.sender);\n        if(!claimedFirst[msg.sender]){\n            claimedFirst[msg.sender] = true;\n        }\n        lastClaim[msg.sender] = block.timestamp;\n        claimedAmount[msg.sender] += amountToClaim;\n\n        UserInfo storage user = userInfo[msg.sender];\n\n        uint256 pending = user.amount.mul(pool.accTokensPerShare).div(1e12).sub(user.rewardDebt);\n        if(pending > 0) {\n            if(pending >= rewardsRemaining()){\n                pending = rewardsRemaining();\n            }\n            rewardsClaimed[msg.sender]+=pending;  \n            user.rewardsClaimTime= block.timestamp;                           \n            rewardToken.transfer(payable(address(msg.sender)), pending);\n        }\n        user.amount -= amountToClaim;\n        totalStaked -= amountToClaim;\n        require(amountToClaim > 0, \"Cannot claim 0\");\n        require(walletsOutstanding.contains(msg.sender), \"Wallet cannot claim\");\n        require(stakingToken.balanceOf(address(this)) >= amountToClaim, \"Not enough tokens on contract to claim\");\n        stakingToken.transfer(msg.sender, amountToClaim);\n        emit ClaimedTokens(msg.sender, amountToClaim);\n        if(totalAmount[msg.sender] <= claimedAmount[msg.sender]){\n            walletsOutstanding.remove(msg.sender);\n        }\n    }\n\n    function isWalletVesting(address account) public view returns (bool){\n        return walletsOutstanding.contains(account);\n    }\n\n    function currentClaimableAmount(address wallet) public view returns (uint256 amountToClaim){\n        if(lastClaim[wallet] > block.timestamp) return 0;\n        if(!claimedFirst[wallet]){\n            amountToClaim = totalAmount[wallet] * firstClaimPercent[wallet] / 10000;\n        }\n        uint256 claimPeriods = (block.timestamp - lastClaim[wallet]);\n        amountToClaim += claimPeriods * totalAmount[wallet] / (totalClaimDuration[wallet]);\n        if(amountToClaim > totalAmount[wallet] - claimedAmount[wallet]){\n            amountToClaim = totalAmount[wallet] - claimedAmount[wallet];\n        }\n    }\n\n    function totalVestingRemainder(address wallet) public view returns (uint256){\n        return(totalAmount[wallet] - claimedAmount[wallet]);\n    }\n\n    function amountWithdrawable(address wallet) public view returns (uint256){\n        UserInfo storage user = userInfo[wallet];\n        return(user.amount - totalVestingRemainder(wallet));\n    }\n\n    function getTotalDividendsDistributed() external view returns (uint256) {\n        return dividendTracker.totalDividendsDistributed();\n    }\n\n    function withdrawableDividendOf(address account) public view returns(uint256) {\n    \treturn dividendTracker.withdrawableDividendOf(account);\n  \t}\n\n\tfunction dividendTokenBalanceOf(address account) public view returns (uint256) {\n\t\treturn dividendTracker.holderBalance(account);\n\t}\n\n    function getAccountDividendsInfo(address account)\n        external view returns (\n            address,\n            int256,\n            int256,\n            uint256,\n            uint256,\n            uint256,\n            uint256,\n            uint256) {\n        return dividendTracker.getAccount(account);\n    }\n\n    function getNumberOfDividendTokenHolders() external view returns(uint256) {\n        return dividendTracker.getNumberOfTokenHolders();\n    }\n    \n    function getNumberOfDividends() external view returns(uint256) {\n        return dividendTracker.totalBalance();\n    }\n}"
    },
    "contracts/interfaces/DividendPayingTokenInterface.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface DividendPayingTokenInterface {\n  /// @notice View the amount of dividend in wei that an address can withdraw.\n  /// @param _owner The address of a token holder.\n  /// @return The amount of dividend in wei that `_owner` can withdraw.\n  function dividendOf(address _owner) external view returns(uint256);\n\n  /// @notice Distributes ether to token holders as dividends.\n  /// @dev SHOULD distribute the paid ether to token holders as dividends.\n  ///  SHOULD NOT directly transfer ether to token holders in this function.\n  ///  MUST emit a `DividendsDistributed` event when the amount of distributed ether is greater than 0.\n  function distributeDividends() external payable;\n\n  /// @notice Withdraws the ether distributed to the sender.\n  /// @dev SHOULD transfer `dividendOf(msg.sender)` wei to `msg.sender`, and `dividendOf(msg.sender)` SHOULD be 0 after the transfer.\n  ///  MUST emit a `DividendWithdrawn` event if the amount of ether transferred is greater than 0.\n  function withdrawDividend() external;\n\n  /// @dev This event MUST emit when ether is distributed to token holders.\n  /// @param from The address which sends ether to this contract.\n  /// @param weiAmount The amount of distributed ether in wei.\n  event DividendsDistributed(\n    address indexed from,\n    uint256 weiAmount\n  );\n\n  /// @dev This event MUST emit when an address withdraws their dividend.\n  /// @param to The address which withdraws ether from this contract.\n  /// @param weiAmount The amount of withdrawn ether in wei.\n  event DividendWithdrawn(\n    address indexed to,\n    uint256 weiAmount\n  );\n}"
    },
    "contracts/interfaces/DividendPayingTokenOptionalInterface.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\n\ninterface DividendPayingTokenOptionalInterface {\n  /// @notice View the amount of dividend in wei that an address can withdraw.\n  /// @param _owner The address of a token holder.\n  /// @return The amount of dividend in wei that `_owner` can withdraw.\n  function withdrawableDividendOf(address _owner) external view returns(uint256);\n\n  /// @notice View the amount of dividend in wei that an address has withdrawn.\n  /// @param _owner The address of a token holder.\n  /// @return The amount of dividend in wei that `_owner` has withdrawn.\n  function withdrawnDividendOf(address _owner) external view returns(uint256);\n\n  /// @notice View the amount of dividend in wei that an address has earned in total.\n  /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner)\n  /// @param _owner The address of a token holder.\n  /// @return The amount of dividend in wei that `_owner` has earned in total.\n  function accumulativeDividendOf(address _owner) external view returns(uint256);\n}"
    },
    "contracts/interfaces/IEHXToken.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\n\ninterface IEHXToken {\n    function mintTokens(address account, uint256 amount) external;\n}"
    },
    "contracts/interfaces/IERC20.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address recipient, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `sender` to `recipient` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) external returns (bool);\n\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n}"
    },
    "contracts/library/EnumerableSet.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nlibrary EnumerableSet {\n\n    struct Set {\n        bytes32[] _values;\n        mapping(bytes32 => uint256) _indexes;\n    }\n\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) {\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            if (lastIndex != toDeleteIndex) {\n                bytes32 lastValue = set._values[lastIndex];\n                set._values[toDeleteIndex] = lastValue;\n                set._indexes[lastValue] = valueIndex;\n            }\n\n            set._values.pop();\n\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        return set._values[index];\n    }\n\n    function _values(Set storage set) private view returns (bytes32[] memory) {\n        return set._values;\n    }\n\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n    function values(AddressSet storage set) internal view returns (address[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        address[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}"
    },
    "contracts/library/SafeMath.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nlibrary SafeMath {\n    /**\n     * @dev Returns the addition of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     *\n     * - Addition cannot overflow.\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        uint256 c = a + b;\n        require(c >= a, 'SafeMath: addition overflow');\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        return sub(a, b, 'SafeMath: subtraction overflow');\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(\n        uint256 a,\n        uint256 b,\n        string memory errorMessage\n    ) internal pure returns (uint256) {\n        require(b <= a, errorMessage);\n        uint256 c = a - b;\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     *\n     * - Multiplication cannot overflow.\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n        // benefit is lost if 'b' is also tested.\n        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n        if (a == 0) {\n            return 0;\n        }\n\n        uint256 c = a * b;\n        require(c / a == b, 'SafeMath: multiplication overflow');\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers. Reverts on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        return div(a, b, 'SafeMath: division by zero');\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(\n        uint256 a,\n        uint256 b,\n        string memory errorMessage\n    ) internal pure returns (uint256) {\n        require(b > 0, errorMessage);\n        uint256 c = a / b;\n        // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * Reverts when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        return mod(a, b, 'SafeMath: modulo by zero');\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * Reverts with custom message when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(\n        uint256 a,\n        uint256 b,\n        string memory errorMessage\n    ) internal pure returns (uint256) {\n        require(b != 0, errorMessage);\n        return a % b;\n    }\n\n    function min(uint256 x, uint256 y) internal pure returns (uint256 z) {\n        z = x < y ? x : y;\n    }\n\n    // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)\n    function sqrt(uint256 y) internal pure returns (uint256 z) {\n        if (y > 3) {\n            z = y;\n            uint256 x = y / 2 + 1;\n            while (x < z) {\n                z = x;\n                x = (y / x + x) / 2;\n            }\n        } else if (y != 0) {\n            z = 1;\n        }\n    }\n}"
    },
    "contracts/library/SafeMathInt.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nlibrary SafeMathInt {\n    int256 private constant MIN_INT256 = int256(1) << 255;\n    int256 private constant MAX_INT256 = ~(int256(1) << 255);\n\n    /**\n     * @dev Multiplies two int256 variables and fails on overflow.\n     */\n    function mul(int256 a, int256 b) internal pure returns (int256) {\n        int256 c = a * b;\n\n        // Detect overflow when multiplying MIN_INT256 with -1\n        require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));\n        require((b == 0) || (c / b == a));\n        return c;\n    }\n\n    /**\n     * @dev Division of two int256 variables and fails on overflow.\n     */\n    function div(int256 a, int256 b) internal pure returns (int256) {\n        // Prevent overflow when dividing MIN_INT256 by -1\n        require(b != -1 || a != MIN_INT256);\n\n        // Solidity already throws when dividing by 0.\n        return a / b;\n    }\n\n    /**\n     * @dev Subtracts two int256 variables and fails on overflow.\n     */\n    function sub(int256 a, int256 b) internal pure returns (int256) {\n        int256 c = a - b;\n        require((b >= 0 && c <= a) || (b < 0 && c > a));\n        return c;\n    }\n\n    /**\n     * @dev Adds two int256 variables and fails on overflow.\n     */\n    function add(int256 a, int256 b) internal pure returns (int256) {\n        int256 c = a + b;\n        require((b >= 0 && c >= a) || (b < 0 && c < a));\n        return c;\n    }\n\n    /**\n     * @dev Converts to absolute value, and fails on overflow.\n     */\n    function abs(int256 a) internal pure returns (int256) {\n        require(a != MIN_INT256);\n        return a < 0 ? -a : a;\n    }\n\n\n    function toUint256Safe(int256 a) internal pure returns (uint256) {\n        require(a >= 0);\n        return uint256(a);\n    }\n}\n"
    },
    "contracts/library/SafeMathUint.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nlibrary SafeMathUint {\n  function toInt256Safe(uint256 a) internal pure returns (int256) {\n    int256 b = int256(a);\n    require(b >= 0);\n    return b;\n  }\n}"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "libraries": {}
  }
}