|
{
|
|
"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.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\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 Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\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-upgradeable/utils/math/SafeMathUpgradeable.sol": {
|
|
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler's built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\n * now has built in overflow checking.\n */\nlibrary SafeMathUpgradeable {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the 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 return a + b;\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 a - b;\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 return a * b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator.\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting 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 a % b;\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 * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\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 unchecked {\n require(b <= a, errorMessage);\n return a - b;\n }\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting 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 unchecked {\n require(b > 0, errorMessage);\n return a / b;\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\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 unchecked {\n require(b > 0, errorMessage);\n return a % b;\n }\n }\n}\n"
|
|
},
|
|
"contracts/interface/IStakedToken.sol": {
|
|
"content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\ninterface IStakedToken {\n function transfer(address to, uint256 amount) external returns(bool);\n function transferFrom(address from, address to, uint256 amount) external returns(bool);\n function balanceOf(address owner) external returns(uint256);\n function name() external returns(string memory);\n function symbol() external returns(string memory);\n\n}"
|
|
},
|
|
"contracts/library/DetailsLibraryUpdated.sol": {
|
|
"content": "//SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nlibrary DetailsLibraryUpdated {\n \n struct eachTransaction {\n \n uint128 stakeAmount;\n uint128 depositTime;\n uint128 fullWithdrawlTime;\n uint128 lastClaimTime;\n \n \n }\n\n struct StakeTypeData {\n uint128 stakeType;\n uint128 stakePeriod;\n uint128 depositFees;\n uint128 withdrawlFees;\n uint128 rewardRate;\n uint128 totalStakedIn;\n bool isActive;\n }\n\n \n}"
|
|
},
|
|
"contracts/SaitaStaking.sol": {
|
|
"content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol\";\nimport \"./interface/IStakedToken.sol\";\nimport \"./library/DetailsLibraryUpdated.sol\";\n\ncontract SaitaStaking is OwnableUpgradeable, ReentrancyGuardUpgradeable {\n using SafeMathUpgradeable for uint128;\n\n using DetailsLibraryUpdated for DetailsLibraryUpdated.eachTransaction;\n using DetailsLibraryUpdated for DetailsLibraryUpdated.StakeTypeData;\n\n IStakedToken public stakedToken;\n\n string public name;\n string public symbol;\n address public ownerWallet;\n address public treasury;\n uint128 public totalStaked;\n uint128 public emergencyFees;\n uint128 public platformFee;\n uint128 public maxStakeLimit;\n\n\n bool public claimAndWithdrawFreeze;\n\n DetailsLibraryUpdated.StakeTypeData[] public stakeTypesList;\n\n mapping(address => mapping(uint128 => DetailsLibraryUpdated.eachTransaction)) public userStakesData;\n\n event Deposit(uint128 stakeAmount, uint128 stakeType, uint128 stakePeriod, uint256 time, uint128 poolTotalStaked);\n event Withdraw(address indexed user, uint128 stakeAmount, uint128 stakeType, uint128 rewardAmount, uint256 time, uint128 poolTotalStaked);\n event Compound(address indexed user, uint128 rewardAmount, uint128 stakeType, uint256 time, uint128 poolTotalStaked);\n event Claim(address indexed user, uint128 rewardAmount, uint128 stakeType, uint256 time);\n event AddStakeType(uint128 _stakeType, uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawlFees, uint128 _rewardRate);\n event UpdateStakeType(uint128 _stakeType, uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawlFees, uint128 _rewardRate);\n event DeleteStakeType(uint128 _stakeType);\n event UpdateStakeToken(address indexed newTokenAddr);\n event EmergencyWithdrawn(address indexed user, uint128 amount, uint128 stakeType, uint256 time, uint128 poolTotalStaked);\n event UpdateEmergencyFee(address indexed _stakeToken, uint128 oldFee, uint128 newFee);\n event UpdatePlatformFee(address indexed _stakeToken, uint128 oldFee, uint128 newFee);\n event UpdateOwnerWallet(address indexed _stakeToken, address indexed oldOwnerWallet, address indexed newOwnerWallet);\n event UpdateTreasuryWallet(address indexed _stakeToken, address indexed oldTreasuryWallet, address indexed newTreasuryWallet);\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() {\n _disableInitializers();\n }\n\n function initialize(address _ownerWallet, address _stakedToken, \n uint128 _stakePeriod, uint128 _depositFees, \n uint128 _withdrawlsFees, uint128 _rewardRate, uint128 _emergencyFees, uint128 _platformFee, address _treasury, uint128 _maxStakeLimit) \n public initializer {\n require(_treasury != address(0), \"TREASURY_WALLET_CANT_BE_NULL_ADDRESS\");\n require(_emergencyFees > 0, \"EMERGENCY_FEES_CANT_BE_ZERO\");\n require(_platformFee > 0, \"PLATFORM_FEE_CANT_BE_NULL\");\n require(_ownerWallet !=address(0), \"OWNER_WALLET_CANT_BE_NULL_ADDRESS\");\n require(_stakedToken !=address(0), \"TOKEN_ADDRESS_CANT_BE_NULL_ADDRESS\");\n require(_depositFees < 10000 && _withdrawlsFees < 10000, \"FEES_CANNOT_BE_EQUAL_OR_MORE_THAN_100%\"); // FOR DEPOSIT AND WITHDRAWL FESS\n // 0.01 % -----> input is 1\n // 0.1% ------> input is 10\n // 1% -------> input is 100\n require(_rewardRate > 0, \"INTEREST_RATE_CANNOT_BE_ZERO\");\n __Ownable_init();\n\n stakedToken = IStakedToken(_stakedToken);\n ownerWallet = _ownerWallet; \n name = IStakedToken(_stakedToken).name();\n symbol = IStakedToken(_stakedToken).symbol();\n emergencyFees = _emergencyFees;\n platformFee = _platformFee;\n treasury = _treasury;\n maxStakeLimit = _maxStakeLimit;\n\n stakeTypesList.push(DetailsLibraryUpdated.StakeTypeData(0,_stakePeriod,_depositFees,_withdrawlsFees,_rewardRate,0, true));\n\n }\n \n function deposit(address user,uint128 _amount, uint128 _stakeType) external payable nonReentrant onlyOwner returns(uint128 emitAmount, uint128 _period, uint128 _totalPoolStaked) {\n require(_amount>0, \"STAKE_MORE_THAN_ZERO\");\n require(_stakeType < uint128(stakeTypesList.length), \"INVALID_STAKE_TYPE\");\n\n transferPlatformFee(treasury, user, uint128(msg.value));\n\n DetailsLibraryUpdated.StakeTypeData storage stakeType = stakeTypesList[_stakeType];\n require(stakeType.isActive, \"POOL_DISABLED\");\n DetailsLibraryUpdated.eachTransaction storage stakes = userStakesData[user][_stakeType];\n {\n uint128 limitLeft;\n if(maxStakeLimit > stakes.stakeAmount) limitLeft = maxStakeLimit - stakes.stakeAmount;\n require(limitLeft > 0,\"MAX_STAKE_LIMIT_REACHED\");\n if(_amount > limitLeft) _amount = limitLeft;\n }\n\n _period = stakeType.stakePeriod;\n uint128 fees;\n uint128 actualAmount = _amount;\n\n if(stakeType.depositFees !=0) {\n fees = _amount * stakeType.depositFees *100 / 1000000;\n actualAmount = _amount - fees;\n }\n\n if(fees > 0) stakedToken.transferFrom(user, ownerWallet, fees);\n uint128 beforeAmount = uint128(stakedToken.balanceOf(address(this)));\n stakedToken.transferFrom(user, address(this), actualAmount);\n\n uint128 realAmount = uint128(stakedToken.balanceOf(address(this))) - beforeAmount;\n\n if(stakes.stakeAmount == 0) {\n stakes.depositTime = uint128(block.timestamp);\n stakes.lastClaimTime = uint128(block.timestamp);\n stakes.fullWithdrawlTime = uint128(uint128(block.timestamp).add(stakeType.stakePeriod * 60)); \n stakes.stakeAmount = realAmount;\n\n stakeType.totalStakedIn = uint128(stakeType.totalStakedIn.add(realAmount));\n // userTotalPerPool[user][_stakeType] += realAmount;\n totalStaked += realAmount;\n emit Deposit(realAmount, _stakeType, stakeType.stakePeriod, block.timestamp, stakeType.totalStakedIn);\n emitAmount = realAmount;\n _totalPoolStaked = stakeType.totalStakedIn;\n } else {\n {\n uint128 stakeTimeTillNow;\n uint128 totalRewardTillNow;\n\n if(uint128(block.timestamp) < userStakesData[user][_stakeType].fullWithdrawlTime) {\n stakeTimeTillNow = uint128(block.timestamp) - userStakesData[user][_stakeType].lastClaimTime;\n totalRewardTillNow = rewardCalculation(actualAmount, _stakeType, stakeTimeTillNow); \n } else {\n if(stakeType.stakePeriod == 0) {\n stakeTimeTillNow = uint128(block.timestamp) - stakes.lastClaimTime;\n stakes.lastClaimTime = uint128(block.timestamp);\n }\n else {\n stakeTimeTillNow = stakes.fullWithdrawlTime - stakes.lastClaimTime;\n stakes.lastClaimTime = stakes.fullWithdrawlTime;\n }\n if(stakeTimeTillNow > 0 ) totalRewardTillNow = rewardCalculation(realAmount, _stakeType, stakeTimeTillNow); \n }\n stakes.stakeAmount += totalRewardTillNow;\n stakeType.totalStakedIn += realAmount + totalRewardTillNow;\n totalStaked += realAmount + totalRewardTillNow;\n stakes.stakeAmount += realAmount;\n stakes.depositTime = uint128(block.timestamp);\n stakes.lastClaimTime = uint128(block.timestamp);\n stakes.fullWithdrawlTime = uint128(block.timestamp) + (stakeType.stakePeriod * 60);\n if(totalRewardTillNow > 0) claimReward(address(this), totalRewardTillNow);\n emitAmount = totalRewardTillNow + realAmount;\n }\n _totalPoolStaked = stakeType.totalStakedIn;\n emit Deposit(emitAmount, _stakeType, stakeType.stakePeriod, block.timestamp, stakeType.totalStakedIn);\n }\n }\n\n function compound(address user, uint128 _stakeType) external payable nonReentrant onlyOwner returns(uint128, uint128, uint128) {\n require(_stakeType < uint128(stakeTypesList.length), \"INVALID_STAKE_TYPE\");\n\n DetailsLibraryUpdated.eachTransaction storage stakes = userStakesData[user][_stakeType];\n require(stakes.stakeAmount > 0, \"NOTHING_AT_STAKE\");\n\n transferPlatformFee(treasury, user, uint128(msg.value));\n\n DetailsLibraryUpdated.StakeTypeData storage stakeType = stakeTypesList[_stakeType];\n require(stakeType.isActive, \"POOL_DISABLED\");\n\n uint128 totalRewardTillNow;\n uint128 actualAmount = stakes.stakeAmount;\n uint128 stakeTimeTillNow;\n\n if(uint128(block.timestamp) < stakes.fullWithdrawlTime) {\n stakeTimeTillNow = uint128(block.timestamp) - stakes.lastClaimTime;\n totalRewardTillNow = rewardCalculation(actualAmount, _stakeType, stakeTimeTillNow); \n stakes.lastClaimTime = uint128(block.timestamp);\n } else {\n if(stakeType.stakePeriod == 0) {\n stakeTimeTillNow = uint128(block.timestamp) - stakes.lastClaimTime;\n stakes.lastClaimTime = uint128(block.timestamp);\n }\n else {\n stakeTimeTillNow = stakes.fullWithdrawlTime - stakes.lastClaimTime;\n stakes.lastClaimTime = stakes.fullWithdrawlTime;\n }\n\n if(stakeTimeTillNow > 0)\n totalRewardTillNow = rewardCalculation(actualAmount, _stakeType, stakeTimeTillNow); \n }\n\n uint128 beforeAmount = uint128(stakedToken.balanceOf(address(this)));\n\n if(totalRewardTillNow > 0)\n claimReward(address(this), totalRewardTillNow);\n\n uint128 realAmount = uint128(stakedToken.balanceOf(address(this))) - beforeAmount;\n\n stakes.stakeAmount += realAmount;\n\n stakeType.totalStakedIn += realAmount;\n totalStaked += realAmount;\n emit Compound(user, realAmount, _stakeType, block.timestamp, stakeType.totalStakedIn);\n return (realAmount, stakeType.stakePeriod, stakeType.totalStakedIn);\n }\n\n function withdraw(address user, uint128 _amount, uint128 _stakeType) external payable nonReentrant onlyOwner returns(uint128, uint128, uint128) {\n\n DetailsLibraryUpdated.StakeTypeData storage stakeType = stakeTypesList[_stakeType];\n require(stakeType.isActive, \"POOL_DISABLED\");\n\n require(_amount > 0, \"WITHDRAW_MORE_THAN_ZERO\");\n require(_stakeType < uint128(stakeTypesList.length), \"INVALID_STAKE_TYPE\");\n\n DetailsLibraryUpdated.eachTransaction storage stakes = userStakesData[user][_stakeType];\n require(_amount <= stakes.stakeAmount, \"CANT_WITHDRAW_MORE_THAN_STAKED\"); // --------\n\n require(uint128(block.timestamp) > stakes.fullWithdrawlTime, \"CANT_UNSTAKE_BEFORE_LOCKUP_TIME\");\n\n transferPlatformFee(treasury, user, uint128(msg.value));\n\n uint128 stakeTimeTillNow;\n if(stakeType.stakePeriod == 0) {\n stakeTimeTillNow = uint128(block.timestamp) - stakes.lastClaimTime;\n stakes.lastClaimTime = uint128(block.timestamp);\n\n }\n else {\n stakeTimeTillNow = stakes.fullWithdrawlTime - stakes.lastClaimTime;\n stakes.lastClaimTime = stakes.fullWithdrawlTime;\n }\n uint128 rewardTillNow;\n if(stakeTimeTillNow > 0) rewardTillNow = rewardCalculation(_amount, _stakeType, stakeTimeTillNow); \n\n uint128 _withdrawlFees = stakeType.withdrawlFees;\n uint128 fees;\n uint128 actualAmount = _amount;\n\n stakes.stakeAmount -= actualAmount;\n stakeType.totalStakedIn -= actualAmount;\n totalStaked -= actualAmount;\n\n if(_withdrawlFees !=0) {\n fees = _amount * _withdrawlFees *100 / 1000000;\n actualAmount = _amount - fees;\n }\n if(rewardTillNow > 0) claimReward(user, rewardTillNow);\n bool success;\n if(fees > 0)\n {\n success = stakedToken.transfer(ownerWallet, fees);\n if(!success) revert();\n }\n if(actualAmount > 0) {\n success = stakedToken.transfer(user, actualAmount);\n if(!success) revert();\n }\n emit Withdraw(user, actualAmount, _stakeType, rewardTillNow, block.timestamp, stakeType.totalStakedIn);\n return (actualAmount, stakeType.stakePeriod, stakeType.totalStakedIn);\n }\n\n function claim(address user, uint128 _stakeType) external payable nonReentrant onlyOwner returns(uint128, uint128) {\n // require(stakeTypeExist[_stakeType], \"STAKE_TYPE_DOES_NOT_EXIST\");\n require(_stakeType < uint128(stakeTypesList.length), \"INVALID_STAKE_TYPE\");\n\n DetailsLibraryUpdated.StakeTypeData storage stakeType = stakeTypesList[_stakeType];\n require(stakeType.isActive, \"POOL_DISABLED\");\n\n require(stakeType.stakePeriod == 0, \"CANT_CLAIM_FOR_THIS_TYPE\");\n\n DetailsLibraryUpdated.eachTransaction storage stakes = userStakesData[user][_stakeType];\n require(uint128(block.timestamp) > stakes.fullWithdrawlTime, \"WAIT_TO_CLAIM\");\n uint128 totalRewardTillNow;\n uint128 actualAmount = stakes.stakeAmount;\n require(actualAmount > 0, \"NOTHING_AT_STAKE\");\n\n transferPlatformFee(treasury, user, uint128(msg.value));\n\n uint128 stakeTimeTillNow;\n \n stakeTimeTillNow = uint128(block.timestamp) - stakes.lastClaimTime;\n\n if(stakeTimeTillNow > 0) totalRewardTillNow = rewardCalculation(actualAmount, _stakeType, stakeTimeTillNow); \n stakes.lastClaimTime = uint128(block.timestamp);\n \n \n if(totalRewardTillNow > 0)\n claimReward(user, totalRewardTillNow);\n\n emit Claim(user, totalRewardTillNow, _stakeType, block.timestamp);\n return (totalRewardTillNow, stakeType.stakePeriod);\n }\n\n function rewardCalculation(uint128 _amount, uint128 _stakeType, uint128 _time) public view returns(uint128) {\n DetailsLibraryUpdated.StakeTypeData memory stakeType = stakeTypesList[_stakeType];\n\n require(_amount > 0, \"AMOUNT_SHOULD_BE_GREATER_THAN_ZERO\");\n require(_stakeType < uint128(stakeTypesList.length), \"INVALID_STAKE_TYPE\");\n require(_time > 0, \"INVALID_TIME\");\n uint128 rate = stakeType.rewardRate;\n uint128 interest = (_amount * rate * _time) / (100 * 365 days);\n return interest;\n }\n\n function claimReward(address to, uint128 _rewardAmount) private {\n require(to != address(0), \"INVALID_CLAIMER\");\n require(_rewardAmount > 0, \"INVALID_REWARD_AMOUNT\");\n uint128 ownerBal = uint128(stakedToken.balanceOf(ownerWallet));\n if(_rewardAmount > ownerBal) claimAndWithdrawFreeze = true;\n require(!claimAndWithdrawFreeze, \"CLAIM_AND_WITHDRAW_FREEZED\");\n bool success = stakedToken.transferFrom(ownerWallet, to, _rewardAmount);\n if(!success) revert();\n }\n // FOR DEPOSIT AND WITHDRAWL FEES\n // 0.01 % -----> input is 1\n // 0.1% ------> input is 10\n // 1% -------> input is 100\n function addStakedType(uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawlFees, uint128 _rewardRate) external onlyOwner returns(uint128){\n // require(!stakeTypeExist[_stakeType], \"STAKE_TYPE_EXISTS\");\n require(_depositFees < 10000 && _withdrawlFees < 10000, \"FEES_CANNOT_BE_EQUAL_OR_MORE_THAN_100\");\n require(_rewardRate > 0, \"INTEREST_RATE_CANNOT_BE_ZERO\");\n // stakeTypeExist[_stakeType] = true;\n uint128 poolType = uint128(stakeTypesList.length);\n\n stakeTypesList.push(DetailsLibraryUpdated.StakeTypeData(poolType,_stakePeriod,_depositFees,_withdrawlFees,_rewardRate,0, true));\n\n emit AddStakeType(poolType, _stakePeriod, _depositFees, _withdrawlFees, _rewardRate);\n return poolType;\n }\n // FOR DEPOSIT AND WITHDRAWL FESS\n // 0.01 % -----> input is 1\n // 0.1% ------> input is 10\n // 1% -------> input is 100\n function updateStakeType(uint128 _stakeType, uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawlFees, uint128 _rewardRate) external onlyOwner {\n // require(stakeTypeExist[_stakeType], \"STAKE_TYPE_DOES_NOT_EXIST\");\n require(_stakeType < uint128(stakeTypesList.length), \"INVALID_STAKE_TYPE\");\n require(_depositFees < 10000 && _withdrawlFees < 10000, \"FEES_CANNOT_BE_EQUAL_OR_MORE_THAN_100\");\n require(_rewardRate > 0, \"INTEREST_RATE_CANNOT_BE_ZERO\");\n\n DetailsLibraryUpdated.StakeTypeData storage stakeType = stakeTypesList[_stakeType];\n\n stakeType.stakeType = _stakeType;\n stakeType.stakePeriod = _stakePeriod;\n stakeType.depositFees = _depositFees;\n stakeType.withdrawlFees = _withdrawlFees;\n stakeType.rewardRate = _rewardRate;\n\n emit UpdateStakeType(_stakeType, _stakePeriod, _depositFees, _withdrawlFees, _rewardRate);\n }\n\n function getPoolData(uint128 _stakeType) external view returns(DetailsLibraryUpdated.StakeTypeData memory) {\n // require(stakeTypeExist[_stakeType], \"INVALID_STAKE_TYPE\");\n require(_stakeType < uint128(stakeTypesList.length), \"INVALID_STAKE_TYPE\");\n require(stakeTypesList[_stakeType].isActive, \"POOL_DISABLED\");\n\n return stakeTypesList[_stakeType];\n }\n\n function deleteStakeType(uint128 _stakeType) external onlyOwner returns(bool) {\n require(_stakeType < uint128(stakeTypesList.length), \"INVALID_STAKE_TYPE\");\n require(stakeTypesList[_stakeType].totalStakedIn == 0, \"CANT_DELETE\");\n\n stakeTypesList[_stakeType].isActive = false;\n\n emit DeleteStakeType(_stakeType);\n return false;\n } \n\n function getPoolLength() external view returns(uint128) {\n return uint128(stakeTypesList.length);\n }\n\n function emergencyWithdraw(address user, uint128 _stakeType) external payable onlyOwner returns(uint128, uint128, uint128){\n require(_stakeType < uint128(stakeTypesList.length), \"INVALID_STAKE_TYPE\");\n DetailsLibraryUpdated.StakeTypeData storage stakeType = stakeTypesList[_stakeType];\n DetailsLibraryUpdated.eachTransaction storage stakes = userStakesData[user][_stakeType];\n uint128 amount = stakes.stakeAmount;\n require( amount > 0, \"NOTHING_TO_WITHDRAW\");\n\n transferPlatformFee(treasury, user, uint128(msg.value));\n\n\n stakes.stakeAmount = 0;\n stakes.lastClaimTime = uint128(block.timestamp);\n\n stakeType.totalStakedIn -= amount;\n totalStaked -= amount;\n\n uint128 fees = (amount * emergencyFees) / 100 ;\n bool success;\n if(fees > 0 ) {\n success = stakedToken.transfer(ownerWallet, fees);\n if(!success) revert();\n amount -= fees;\n }\n\n success = stakedToken.transfer(user, amount);\n if(!success) revert();\n\n emit EmergencyWithdrawn(user, amount, _stakeType, block.timestamp, stakeType.totalStakedIn);\n return (amount, stakeType.stakePeriod, stakeType.totalStakedIn);\n }\n\n function updateEmergencyFees(uint128 newFees) external onlyOwner {\n require(newFees > 0, \"EMERGENCY_FEES_CANT_BE_ZERO\");\n require(newFees != emergencyFees, \"CANT_SET SAME_FEES\");\n uint128 oldFee = emergencyFees;\n emergencyFees = newFees;\n \n emit UpdateEmergencyFee(address(stakedToken), oldFee, newFees);\n }\n\n function transferPlatformFee(address to, address _user, uint128 _value) private {\n require(to != address(0), \"CANT_SEND_TO_NULL_ADDRESS\");\n require(_value >= platformFee, \"INCREASE_PLATFORM_FEE\");\n (bool success, ) = payable(to).call{value:platformFee}(\"\");\n require(success, \"PLATFORM_FEE_TRANSFER_FAILED\");\n uint128 remainingEth = _value - platformFee;\n if (remainingEth > 0) {\n (success,) = payable(_user).call{value: remainingEth}(\"\");\n require(success, \"REFUND_REMAINING_ETHER_SENT_FAILED\");\n }\n }\n\n function updatePlatformFee(uint128 newFee) external onlyOwner {\n require(newFee > 0, \"PLATFORM_FEE_CANT_BE_NULL\");\n require(newFee != platformFee, \"PLATFORM_FEE_CANT_BE_SAME\");\n\n uint128 oldFee = platformFee;\n platformFee = newFee;\n\n emit UpdatePlatformFee(address(stakedToken), oldFee, newFee);\n }\n\n function updateOwnerWallet(address newOwnerWallet) external onlyOwner {\n require(newOwnerWallet != address(0), \"OWNER_CANT_BE_ZERO_ADDRESS\");\n require(newOwnerWallet != ownerWallet, \"ALREADY_SET_THIS OWNER\");\n\n address oldOwnerWallet = ownerWallet;\n ownerWallet = newOwnerWallet;\n\n emit UpdateOwnerWallet(address(stakedToken), oldOwnerWallet, newOwnerWallet);\n }\n\n function updateTreasuryWallet(address newTreasuryWallet) external onlyOwner {\n require(newTreasuryWallet != address(0), \"TREASURY_WALLET_CANT_BE_NULL\");\n require(newTreasuryWallet != treasury, \"ALREADY_SET_THS_WALLET\");\n\n address oldTreasuryWallet = ownerWallet;\n treasury = newTreasuryWallet;\n\n emit UpdateTreasuryWallet(address(stakedToken), oldTreasuryWallet, newTreasuryWallet);\n }\n\n function updateStakeLimit(uint128 _newLimit) external onlyOwner {\n require(maxStakeLimit != _newLimit);\n maxStakeLimit = _newLimit;\n\n }\n}"
|
|
}
|
|
},
|
|
"settings": {
|
|
"optimizer": {
|
|
"enabled": true,
|
|
"runs": 200
|
|
},
|
|
"outputSelection": {
|
|
"*": {
|
|
"*": [
|
|
"evm.bytecode",
|
|
"evm.deployedBytecode",
|
|
"devdoc",
|
|
"userdoc",
|
|
"metadata",
|
|
"abi"
|
|
]
|
|
}
|
|
},
|
|
"libraries": {}
|
|
}
|
|
} |