ETH Price: $3,307.18 (-1.02%)

Transaction Decoder

Block:
19203315 at Feb-11-2024 07:22:47 AM +UTC
Transaction Fee:
0.00569183857102419 ETH $18.82
Gas Used:
247,845 Gas / 22.965315302 Gwei

Emitted Events:

12 SaitaRealtyV2.Approval( owner=[Receiver] SaitaStakingFactory, spender=SaitaProxy, value=10914041203940000 )
13 SaitaRealtyV2.Transfer( from=0x60d2e86F2a8e66bF047207FA7C45Bd223Ed3B8B4, to=[Sender] 0xbe20fe6c1108baa59712f1b086e8a8958ad794cb, value=430581351607495 )
14 SaitaRealtyV2.Approval( owner=0x60d2e86F2a8e66bF047207FA7C45Bd223Ed3B8B4, spender=SaitaProxy, value=1461501637330902918203684832715944449226660852042 )
15 SaitaRealtyV2.Transfer( from=SaitaProxy, to=0xabE6fd21403c5F6134FD316A155720c378f20C65, value=21828082407880 )
16 SaitaRealtyV2.Transfer( from=SaitaProxy, to=[Sender] 0xbe20fe6c1108baa59712f1b086e8a8958ad794cb, value=10892213121532120 )
17 SaitaProxy.0x2528cc6d36234aa26163e47f01b34b9b6d4a224fb3bdbb856b43ced06826c16e( 0x2528cc6d36234aa26163e47f01b34b9b6d4a224fb3bdbb856b43ced06826c16e, 0x000000000000000000000000be20fe6c1108baa59712f1b086e8a8958ad794cb, 0000000000000000000000000000000000000000000000000026b268fded40d8, 0000000000000000000000000000000000000000000000000000000000000003, 0000000000000000000000000000000000000000000000000001879c88826cc7, 0000000000000000000000000000000000000000000000000000000065c875c7, 00000000000000000000000000000000000000000000000039312d92f7a168a7 )
18 SaitaStakingFactory.Withdraw( stakeProxy=SaitaProxy, amount=10892213121532120, stakeType=3, user=[Sender] 0xbe20fe6c1108baa59712f1b086e8a8958ad794cb, blockTimestamp=1707636167, period=172800, totalStakedInPool=4121125243263740071 )

Account State Difference:

  Address   Before After State Difference Code
0x142a774E...5acB646D0
0x2f981072...eD8238d42
(Fee Recipient: 0x7fbe...c64)
0.090983212157590127 Eth0.091602824657590127 Eth0.0006196125
0xabE6fd21...378f20C65 1.274041697592133466 Eth1.274891697592133466 Eth0.00085
0xBE20Fe6c...58ad794CB
0.053020899773690981 Eth
Nonce: 14
0.046479061202666791 Eth
Nonce: 15
0.00654183857102419

Execution Trace

ETH 0.00085 SaitaStakingFactory.withdraw( _stakedToken=0x142a774E8b52550E88E196CedD7A5835acB646D0, _amount=10914041203940000, _stakeType=3 )
  • SaitaRealtyV2.approve( spender=0x2f981072362f58c6597762382c24C0DeD8238d42, amount=10914041203940000 ) => ( True )
  • ETH 0.00085 SaitaProxy.b25b8a7b( )
    • SaitaStakingFactory.STATICCALL( )
    • ETH 0.00085 NewStake.withdraw( user=0xBE20Fe6c1108BAA59712f1b086e8a8958ad794CB, _amount=10914041203940000, _stakeType=3 ) => ( 10892213121532120, 172800, 4121125243263740071 )
      • ETH 0.00085 0xabe6fd21403c5f6134fd316a155720c378f20c65.CALL( )
      • SaitaRealtyV2.balanceOf( account=0x60d2e86F2a8e66bF047207FA7C45Bd223Ed3B8B4 ) => ( 19829652067142109 )
      • SaitaRealtyV2.transferFrom( sender=0x60d2e86F2a8e66bF047207FA7C45Bd223Ed3B8B4, recipient=0xBE20Fe6c1108BAA59712f1b086e8a8958ad794CB, amount=430581351607495 ) => ( True )
      • SaitaRealtyV2.transfer( recipient=0xabE6fd21403c5F6134FD316A155720c378f20C65, amount=21828082407880 ) => ( True )
      • SaitaRealtyV2.transfer( recipient=0xBE20Fe6c1108BAA59712f1b086e8a8958ad794CB, amount=10892213121532120 ) => ( True )
        File 1 of 4: SaitaStakingFactory
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
        pragma solidity ^0.8.0;
        import "../utils/ContextUpgradeable.sol";
        import "../proxy/utils/Initializable.sol";
        /**
         * @dev Contract module which provides a basic access control mechanism, where
         * there is an account (an owner) that can be granted exclusive access to
         * specific functions.
         *
         * By default, the owner account will be the one that deploys the contract. This
         * can later be changed with {transferOwnership}.
         *
         * This module is used through inheritance. It will make available the modifier
         * `onlyOwner`, which can be applied to your functions to restrict their use to
         * the owner.
         */
        abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
            address private _owner;
            event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
            /**
             * @dev Initializes the contract setting the deployer as the initial owner.
             */
            function __Ownable_init() internal onlyInitializing {
                __Ownable_init_unchained();
            }
            function __Ownable_init_unchained() internal onlyInitializing {
                _transferOwnership(_msgSender());
            }
            /**
             * @dev Throws if called by any account other than the owner.
             */
            modifier onlyOwner() {
                _checkOwner();
                _;
            }
            /**
             * @dev Returns the address of the current owner.
             */
            function owner() public view virtual returns (address) {
                return _owner;
            }
            /**
             * @dev Throws if the sender is not the owner.
             */
            function _checkOwner() internal view virtual {
                require(owner() == _msgSender(), "Ownable: caller is not the owner");
            }
            /**
             * @dev Leaves the contract without owner. It will not be possible to call
             * `onlyOwner` functions anymore. Can only be called by the current owner.
             *
             * NOTE: Renouncing ownership will leave the contract without an owner,
             * thereby removing any functionality that is only available to the owner.
             */
            function renounceOwnership() public virtual onlyOwner {
                _transferOwnership(address(0));
            }
            /**
             * @dev Transfers ownership of the contract to a new account (`newOwner`).
             * Can only be called by the current owner.
             */
            function transferOwnership(address newOwner) public virtual onlyOwner {
                require(newOwner != address(0), "Ownable: new owner is the zero address");
                _transferOwnership(newOwner);
            }
            /**
             * @dev Transfers ownership of the contract to a new account (`newOwner`).
             * Internal function without access restriction.
             */
            function _transferOwnership(address newOwner) internal virtual {
                address oldOwner = _owner;
                _owner = newOwner;
                emit OwnershipTransferred(oldOwner, newOwner);
            }
            /**
             * @dev This empty reserved space is put in place to allow future versions to add new
             * variables without shifting down storage in the inheritance chain.
             * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
             */
            uint256[49] private __gap;
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)
        pragma solidity ^0.8.2;
        import "../../utils/AddressUpgradeable.sol";
        /**
         * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
         * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
         * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
         * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
         *
         * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
         * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
         * case an upgrade adds a module that needs to be initialized.
         *
         * For example:
         *
         * [.hljs-theme-light.nopadding]
         * ```
         * contract MyToken is ERC20Upgradeable {
         *     function initialize() initializer public {
         *         __ERC20_init("MyToken", "MTK");
         *     }
         * }
         * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
         *     function initializeV2() reinitializer(2) public {
         *         __ERC20Permit_init("MyToken");
         *     }
         * }
         * ```
         *
         * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
         * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
         *
         * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
         * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
         *
         * [CAUTION]
         * ====
         * Avoid leaving a contract uninitialized.
         *
         * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
         * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
         * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
         *
         * [.hljs-theme-light.nopadding]
         * ```
         * /// @custom:oz-upgrades-unsafe-allow constructor
         * constructor() {
         *     _disableInitializers();
         * }
         * ```
         * ====
         */
        abstract contract Initializable {
            /**
             * @dev Indicates that the contract has been initialized.
             * @custom:oz-retyped-from bool
             */
            uint8 private _initialized;
            /**
             * @dev Indicates that the contract is in the process of being initialized.
             */
            bool private _initializing;
            /**
             * @dev Triggered when the contract has been initialized or reinitialized.
             */
            event Initialized(uint8 version);
            /**
             * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
             * `onlyInitializing` functions can be used to initialize parent contracts.
             *
             * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
             * constructor.
             *
             * Emits an {Initialized} event.
             */
            modifier initializer() {
                bool isTopLevelCall = !_initializing;
                require(
                    (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
                    "Initializable: contract is already initialized"
                );
                _initialized = 1;
                if (isTopLevelCall) {
                    _initializing = true;
                }
                _;
                if (isTopLevelCall) {
                    _initializing = false;
                    emit Initialized(1);
                }
            }
            /**
             * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
             * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
             * used to initialize parent contracts.
             *
             * A reinitializer may be used after the original initialization step. This is essential to configure modules that
             * are added through upgrades and that require initialization.
             *
             * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
             * cannot be nested. If one is invoked in the context of another, execution will revert.
             *
             * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
             * a contract, executing them in the right order is up to the developer or operator.
             *
             * WARNING: setting the version to 255 will prevent any future reinitialization.
             *
             * Emits an {Initialized} event.
             */
            modifier reinitializer(uint8 version) {
                require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
                _initialized = version;
                _initializing = true;
                _;
                _initializing = false;
                emit Initialized(version);
            }
            /**
             * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
             * {initializer} and {reinitializer} modifiers, directly or indirectly.
             */
            modifier onlyInitializing() {
                require(_initializing, "Initializable: contract is not initializing");
                _;
            }
            /**
             * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
             * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
             * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
             * through proxies.
             *
             * Emits an {Initialized} event the first time it is successfully executed.
             */
            function _disableInitializers() internal virtual {
                require(!_initializing, "Initializable: contract is initializing");
                if (_initialized < type(uint8).max) {
                    _initialized = type(uint8).max;
                    emit Initialized(type(uint8).max);
                }
            }
            /**
             * @dev Internal function that returns the initialized version. Returns `_initialized`
             */
            function _getInitializedVersion() internal view returns (uint8) {
                return _initialized;
            }
            /**
             * @dev Internal function that returns the initialized version. Returns `_initializing`
             */
            function _isInitializing() internal view returns (bool) {
                return _initializing;
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
        pragma solidity ^0.8.1;
        /**
         * @dev Collection of functions related to the address type
         */
        library AddressUpgradeable {
            /**
             * @dev Returns true if `account` is a contract.
             *
             * [IMPORTANT]
             * ====
             * It is unsafe to assume that an address for which this function returns
             * false is an externally-owned account (EOA) and not a contract.
             *
             * Among others, `isContract` will return false for the following
             * types of addresses:
             *
             *  - an externally-owned account
             *  - a contract in construction
             *  - an address where a contract will be created
             *  - an address where a contract lived, but was destroyed
             * ====
             *
             * [IMPORTANT]
             * ====
             * You shouldn't rely on `isContract` to protect against flash loan attacks!
             *
             * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
             * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
             * constructor.
             * ====
             */
            function isContract(address account) internal view returns (bool) {
                // This method relies on extcodesize/address.code.length, which returns 0
                // for contracts in construction, since the code is only stored at the end
                // of the constructor execution.
                return account.code.length > 0;
            }
            /**
             * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
             * `recipient`, forwarding all available gas and reverting on errors.
             *
             * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
             * of certain opcodes, possibly making contracts go over the 2300 gas limit
             * imposed by `transfer`, making them unable to receive funds via
             * `transfer`. {sendValue} removes this limitation.
             *
             * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
             *
             * IMPORTANT: because control is transferred to `recipient`, care must be
             * taken to not create reentrancy vulnerabilities. Consider using
             * {ReentrancyGuard} or the
             * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
             */
            function sendValue(address payable recipient, uint256 amount) internal {
                require(address(this).balance >= amount, "Address: insufficient balance");
                (bool success, ) = recipient.call{value: amount}("");
                require(success, "Address: unable to send value, recipient may have reverted");
            }
            /**
             * @dev Performs a Solidity function call using a low level `call`. A
             * plain `call` is an unsafe replacement for a function call: use this
             * function instead.
             *
             * If `target` reverts with a revert reason, it is bubbled up by this
             * function (like regular Solidity function calls).
             *
             * Returns the raw returned data. To convert to the expected return value,
             * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
             *
             * Requirements:
             *
             * - `target` must be a contract.
             * - calling `target` with `data` must not revert.
             *
             * _Available since v3.1._
             */
            function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                return functionCallWithValue(target, data, 0, "Address: low-level call failed");
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
             * `errorMessage` as a fallback revert reason when `target` reverts.
             *
             * _Available since v3.1._
             */
            function functionCall(
                address target,
                bytes memory data,
                string memory errorMessage
            ) internal returns (bytes memory) {
                return functionCallWithValue(target, data, 0, errorMessage);
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
             * but also transferring `value` wei to `target`.
             *
             * Requirements:
             *
             * - the calling contract must have an ETH balance of at least `value`.
             * - the called Solidity function must be `payable`.
             *
             * _Available since v3.1._
             */
            function functionCallWithValue(
                address target,
                bytes memory data,
                uint256 value
            ) internal returns (bytes memory) {
                return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
            }
            /**
             * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
             * with `errorMessage` as a fallback revert reason when `target` reverts.
             *
             * _Available since v3.1._
             */
            function functionCallWithValue(
                address target,
                bytes memory data,
                uint256 value,
                string memory errorMessage
            ) internal returns (bytes memory) {
                require(address(this).balance >= value, "Address: insufficient balance for call");
                (bool success, bytes memory returndata) = target.call{value: value}(data);
                return verifyCallResultFromTarget(target, success, returndata, errorMessage);
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
             * but performing a static call.
             *
             * _Available since v3.3._
             */
            function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                return functionStaticCall(target, data, "Address: low-level static call failed");
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
             * but performing a static call.
             *
             * _Available since v3.3._
             */
            function functionStaticCall(
                address target,
                bytes memory data,
                string memory errorMessage
            ) internal view returns (bytes memory) {
                (bool success, bytes memory returndata) = target.staticcall(data);
                return verifyCallResultFromTarget(target, success, returndata, errorMessage);
            }
            /**
             * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
             * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
             *
             * _Available since v4.8._
             */
            function verifyCallResultFromTarget(
                address target,
                bool success,
                bytes memory returndata,
                string memory errorMessage
            ) internal view returns (bytes memory) {
                if (success) {
                    if (returndata.length == 0) {
                        // only check isContract if the call was successful and the return data is empty
                        // otherwise we already know that it was a contract
                        require(isContract(target), "Address: call to non-contract");
                    }
                    return returndata;
                } else {
                    _revert(returndata, errorMessage);
                }
            }
            /**
             * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
             * revert reason or using the provided one.
             *
             * _Available since v4.3._
             */
            function verifyCallResult(
                bool success,
                bytes memory returndata,
                string memory errorMessage
            ) internal pure returns (bytes memory) {
                if (success) {
                    return returndata;
                } else {
                    _revert(returndata, errorMessage);
                }
            }
            function _revert(bytes memory returndata, string memory errorMessage) private pure {
                // Look for revert reason and bubble it up if present
                if (returndata.length > 0) {
                    // The easiest way to bubble the revert reason is using memory via assembly
                    /// @solidity memory-safe-assembly
                    assembly {
                        let returndata_size := mload(returndata)
                        revert(add(32, returndata), returndata_size)
                    }
                } else {
                    revert(errorMessage);
                }
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
        pragma solidity ^0.8.0;
        import "../proxy/utils/Initializable.sol";
        /**
         * @dev Provides information about the current execution context, including the
         * sender of the transaction and its data. While these are generally available
         * via msg.sender and msg.data, they should not be accessed in such a direct
         * manner, since when dealing with meta-transactions the account sending and
         * paying for execution may not be the actual sender (as far as an application
         * is concerned).
         *
         * This contract is only required for intermediate, library-like contracts.
         */
        abstract contract ContextUpgradeable is Initializable {
            function __Context_init() internal onlyInitializing {
            }
            function __Context_init_unchained() internal onlyInitializing {
            }
            function _msgSender() internal view virtual returns (address) {
                return msg.sender;
            }
            function _msgData() internal view virtual returns (bytes calldata) {
                return msg.data;
            }
            /**
             * @dev This empty reserved space is put in place to allow future versions to add new
             * variables without shifting down storage in the inheritance chain.
             * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
             */
            uint256[50] private __gap;
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
        pragma solidity ^0.8.0;
        /**
         * @dev Interface of the ERC20 standard as defined in the EIP.
         */
        interface IERC20 {
            /**
             * @dev Emitted when `value` tokens are moved from one account (`from`) to
             * another (`to`).
             *
             * Note that `value` may be zero.
             */
            event Transfer(address indexed from, address indexed to, uint256 value);
            /**
             * @dev Emitted when the allowance of a `spender` for an `owner` is set by
             * a call to {approve}. `value` is the new allowance.
             */
            event Approval(address indexed owner, address indexed spender, uint256 value);
            /**
             * @dev Returns the amount of tokens in existence.
             */
            function totalSupply() external view returns (uint256);
            /**
             * @dev Returns the amount of tokens owned by `account`.
             */
            function balanceOf(address account) external view returns (uint256);
            /**
             * @dev Moves `amount` tokens from the caller's account to `to`.
             *
             * Returns a boolean value indicating whether the operation succeeded.
             *
             * Emits a {Transfer} event.
             */
            function transfer(address to, uint256 amount) external returns (bool);
            /**
             * @dev Returns the remaining number of tokens that `spender` will be
             * allowed to spend on behalf of `owner` through {transferFrom}. This is
             * zero by default.
             *
             * This value changes when {approve} or {transferFrom} are called.
             */
            function allowance(address owner, address spender) external view returns (uint256);
            /**
             * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
             *
             * Returns a boolean value indicating whether the operation succeeded.
             *
             * IMPORTANT: Beware that changing an allowance with this method brings the risk
             * that someone may use both the old and the new allowance by unfortunate
             * transaction ordering. One possible solution to mitigate this race
             * condition is to first reduce the spender's allowance to 0 and set the
             * desired value afterwards:
             * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
             *
             * Emits an {Approval} event.
             */
            function approve(address spender, uint256 amount) external returns (bool);
            /**
             * @dev Moves `amount` tokens from `from` to `to` using the
             * allowance mechanism. `amount` is then deducted from the caller's
             * allowance.
             *
             * Returns a boolean value indicating whether the operation succeeded.
             *
             * Emits a {Transfer} event.
             */
            function transferFrom(
                address from,
                address to,
                uint256 amount
            ) external returns (bool);
        }
        // SPDX-License-Identifier: UNLICENSED
        pragma solidity ^0.8.0;
        interface IStakeFactory {
            function impl() external view returns(address);
        }// SPDX-License-Identifier: UNLICENSED
        pragma solidity ^0.8.0;
        interface IStaking3 {
            function deposit(address _user, uint128 _amount, uint128 _stakeType) external payable returns(uint128,uint128, uint128);
            function compound(address _user, uint128 _stakeType) external payable returns(uint128,uint128, uint128);
            function withdraw(address _user, uint128 _amount, uint128 _stakeType) external payable returns(uint128,uint128, uint128);
            function claim(address _user, uint128 _stakeType) external payable returns(uint128,uint128);
            function addStakedType(uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawalFees, uint128 _rewardRate) external returns(uint128);
            function updateStakeType(uint128 _stakeType, uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawalFees, uint128 _rewardRate) external;
            function deleteStakeType(uint128 _stakeType) external returns(bool);
            function emergencyWithdraw(address _user, uint128 _stakeType) external payable returns(uint128,uint128,uint128);
            function updateEmergencyFees(uint128 newFee) external ;
            function updatePlatformFee(uint128 newFee) external;
            function updateOwnerWallet(address newOwnerWallet) external;
            function updateTreasuryWallet(address newTreasurywallet) external;
            function updateStakeLimit(uint128 _newLimit) external;
            function getPoolLength() external view returns(uint128);
        }   // SPDX-License-Identifier: UNLICENSED
        pragma solidity ^0.8.0;
        interface IToken {
            function name() external view returns(string memory);
                function symbol() external view returns(string memory);
        }// SPDX-License-Identifier: Unlicensed
        pragma solidity ^0.8.0;
        import "./interface/IStakeFactory.sol";
        contract SaitaProxy {
            
                bytes32 private constant proxyOwnerPosition = keccak256("com.saitama.proxy.owner");
                bytes32 private constant factory = keccak256("com.saitama.proxy.factory");
            constructor(address owner) {
                setProxyOwner(owner);
            }
            function setProxyOwner(address newProxyOwner) private  {
                bytes32 position = proxyOwnerPosition;
                assembly {
                    sstore(position, newProxyOwner)
                }
            }
            function setFactory(address _factory) public  {
                require(msg.sender == proxyOwner(), "ONLY_OWNER_CAN_CHANGE");
                bytes32 position = factory;
                assembly {
                    sstore(position, _factory)
                }
            }
            function getFactory() public view returns (address _factory) {
                bytes32 position = factory;
                assembly {
                    _factory := sload(position)
                }
            }
            function proxyOwner() public view returns (address owner) {
                bytes32 position = proxyOwnerPosition;
                assembly {
                    owner := sload(position)
                }
            }
            function implementation() public view returns (address) {
                return IStakeFactory(getFactory()).impl();
            }
            
            fallback() external payable {
                address _impl = implementation();
                    assembly 
                        {
                        let ptr := mload(0x40)
                        // (1) copy incoming call data
                        calldatacopy(ptr, 0, calldatasize())
                        // (2) forward call to logic contract
                        let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0)
                        let size := returndatasize()
                        // (3) retrieve return data
                        returndatacopy(ptr, 0, size)
                        // (4) forward return data back to caller
                        switch result
                        case 0 { revert(ptr, size) }
                        default { return(ptr, size) }
                        }
            }
        }// SPDX-License-Identifier: UNLICENSED
        pragma solidity ^0.8.0;
        import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
        import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
        import "./SaitaProxy.sol";
        import "./interface/IStaking3.sol";
        import "./interface/IToken.sol";
        contract SaitaStakingFactory is OwnableUpgradeable{
            address internal imp;
            address[] public totalStakingInstances;
            mapping(address => address) public tokenAddrToStakingAddr;
            event Deposit(address indexed stakeProxy, uint128 stakeAmount, uint128 stakeType, address indexed user, uint256 blockTimestamp, uint128 period, uint128 totalStakedInPool);
            event Compound(address indexed stakeProxy, uint128 amount, uint128 stakeType, address indexed user, uint256 blockTimestamp, uint128 period, uint128 totalStakedInPool);
            event Withdraw(address indexed stakeProxy, uint128 amount, uint128 stakeType, address indexed user, uint256 blockTimestamp, uint128 period, uint128 totalStakedInPool);
            event Claim(address indexed stakeProxy,  uint128 amount, uint128 stakeType, address indexed user, uint256 blockTimestamp, uint128 period);
            event AddStakeType(address indexed stakeProxy, uint128 stakeType, uint128 stakePeriod, uint128 depositFees, uint128 withdrawalFees, uint128 rewardRate, address indexed caller, uint256 blockTimestamp);
            event UpdateStakeType(address indexed stakeProxy, uint128 stakeType, uint128 stakePeriod, uint128 depositFees, uint128 withdrawalFees, uint128 rewardRate, address indexed caller, uint256 blockTimestamp);
            event DeleteStakeType(address indexed stakeProxy, uint128 stakeType, address indexed caller, uint256 blockTimestamp, bool active);
            event EmergencyWithdrawn(address indexed stakeProxy,  uint128 amount, uint128 stakeType, address indexed user, uint256 blockTimestamp, uint128 period, uint128 totalStakedInPool);
            event UpdateEmergencyFees(address indexed _owner, uint128 newFees, uint256 time);
            event UpdatePlatformFee(address indexed stakeProxy, uint128 newFee);
            event UpdateOwnerWallet(address indexed stakeProxy, address indexed newOwnerWallet);
            event UpdateTreasuryWallet(address indexed stakeProxy, address indexed newTreasuryWallet);
            event UpdateStakeLimit(address indexed stakeProxy, uint128 _newLimit);
            event Deployed(address indexed instance);
            event StakingInitialized(address indexed proxyInstance, address indexed stakedToken, uint128 stakePeriod, uint128 depositFees, uint128 withdrawlsFees, uint128 rewardRate, string name, string _symbol, uint256 blockTimestamp, string uri);
            function initialize(address _imp) external initializer {
                __Ownable_init();
                imp = _imp;
            }
            function deposit(address _stakedToken, uint128 _stakeAmount, uint128 _stakeType) external payable {
                IERC20(_stakedToken).approve(tokenAddrToStakingAddr[_stakedToken], _stakeAmount);
                (uint128 amount, uint128 period, uint128 totalStakedInPool) = IStaking3(tokenAddrToStakingAddr[_stakedToken]).deposit{value:msg.value}(msg.sender, _stakeAmount, _stakeType);
                emit Deposit(tokenAddrToStakingAddr[_stakedToken], amount, _stakeType, msg.sender, block.timestamp, period, totalStakedInPool);
            }
            
            function compound(address _stakedToken, uint128 _stakeType) external payable {
                (uint128 amount, uint128 period, uint128 totalStakedInPool) = IStaking3(tokenAddrToStakingAddr[_stakedToken]).compound{value:msg.value}(msg.sender, _stakeType);
                emit Compound(tokenAddrToStakingAddr[_stakedToken], amount, _stakeType, msg.sender, block.timestamp, period, totalStakedInPool);
            }
            function withdraw(address _stakedToken, uint128 _amount, uint128 _stakeType) external payable {
                IERC20(_stakedToken).approve(tokenAddrToStakingAddr[_stakedToken], _amount);
                (uint128 amount, uint128 period, uint128 totalStakedInPool) = IStaking3(tokenAddrToStakingAddr[_stakedToken]).withdraw{value:msg.value}(msg.sender, _amount, _stakeType);
                emit Withdraw(tokenAddrToStakingAddr[_stakedToken], amount, _stakeType, msg.sender, block.timestamp, period, totalStakedInPool);
            }
            function claim(address _stakedToken, uint128 _stakeType) external payable {
                (uint128 amount, uint128 period) = IStaking3(tokenAddrToStakingAddr[_stakedToken]).claim{value:msg.value}(msg.sender, _stakeType);
                emit Claim(tokenAddrToStakingAddr[_stakedToken], amount, _stakeType, msg.sender, block.timestamp, period);
            }
            function emergencyWithdraw(address _stakedToken, uint128 _stakeType) external payable {
                (uint128 amount, uint128 period, uint128 totalStakedInPool) = IStaking3(tokenAddrToStakingAddr[_stakedToken]).emergencyWithdraw{value:msg.value}(msg.sender, _stakeType);
                emit EmergencyWithdrawn(tokenAddrToStakingAddr[_stakedToken], amount, _stakeType, msg.sender, block.timestamp, period, totalStakedInPool);
            }
            function addStakedType(address _stakedToken, uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawalFees, uint128 _rewardRate) external onlyOwner{
                uint128 _stakeType = IStaking3(tokenAddrToStakingAddr[_stakedToken]).addStakedType(_stakePeriod,_depositFees,_withdrawalFees,_rewardRate);
                emit AddStakeType(tokenAddrToStakingAddr[_stakedToken], _stakeType, _stakePeriod, _depositFees, _withdrawalFees, _rewardRate, msg.sender, block.timestamp);
            }
            function updateStakeType(address _stakedToken, uint128 _stakeType, uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawalFees, uint128 _rewardRate) external onlyOwner{
                IStaking3(tokenAddrToStakingAddr[_stakedToken]).updateStakeType(_stakeType,_stakePeriod,_depositFees,_withdrawalFees,_rewardRate);
                emit UpdateStakeType(tokenAddrToStakingAddr[_stakedToken], _stakeType, _stakePeriod, _depositFees, _withdrawalFees, _rewardRate,msg.sender, block.timestamp);
            }
            function deleteStakeType(address _stakedToken, uint128 _stakeType) external onlyOwner {
                bool active = IStaking3(tokenAddrToStakingAddr[_stakedToken]).deleteStakeType(_stakeType);
                emit DeleteStakeType(tokenAddrToStakingAddr[_stakedToken], _stakeType,msg.sender, block.timestamp, active);
            }
            function updateEmergencyFees(address _stakedToken, uint128 newFees) external onlyOwner {
                IStaking3(tokenAddrToStakingAddr[_stakedToken]).updateEmergencyFees(newFees);
                emit UpdateEmergencyFees(msg.sender, newFees, block.timestamp);
            }
            function updatePlatformFee(address _stakedToken, uint128 newFee) external onlyOwner {
                IStaking3(tokenAddrToStakingAddr[_stakedToken]).updatePlatformFee(newFee);
                emit UpdatePlatformFee(tokenAddrToStakingAddr[_stakedToken], newFee);
            }
            function updateOwnerWallet(address _stakedToken, address newOwnerWallet) external onlyOwner {
               IStaking3(tokenAddrToStakingAddr[_stakedToken]).updateOwnerWallet(newOwnerWallet);
                emit UpdateOwnerWallet(tokenAddrToStakingAddr[_stakedToken], newOwnerWallet);
            }
            function updateTreasuryWallet(address _stakedToken, address newTreasuryWallet) external onlyOwner {
                IStaking3(tokenAddrToStakingAddr[_stakedToken]).updateTreasuryWallet(newTreasuryWallet);
                emit UpdateTreasuryWallet(tokenAddrToStakingAddr[_stakedToken], newTreasuryWallet);
            }
            function getPoolLength(address _stakedToken) external view returns(uint128) {
                return IStaking3(tokenAddrToStakingAddr[_stakedToken]).getPoolLength();
            }
            function deployInstance() external onlyOwner returns(address addr) {
                addr = address(new SaitaProxy(address(this)));
                require(addr!=address(0), "NULL_CONTRACT_ADDRESS_CREATED");
                totalStakingInstances.push(addr);
                
                emit Deployed(addr);
                return addr;
            }
            function initializeProxyInstance(address _proxyInstance, 
                                            address _ownerWallet, 
                                            address _stakedToken, 
                                            uint128 _stakePeriod, 
                                            uint128 _depositFees, 
                                            uint128 _withdrawalFees, 
                                            uint128 _rewardRate, 
                                            uint128 _emergencyFees, 
                                            uint128 _platformFee, 
                                            address _treasury, 
                                            uint128 _maxStakeLimit, 
                                            string memory uri) external onlyOwner {
                
                    tokenAddrToStakingAddr[_stakedToken] = _proxyInstance;
                {
                    string memory _name = IToken(_stakedToken).name();
                    string memory _symbol = IToken(_stakedToken).symbol();
                    // initialize pool
                    SaitaProxy proxyInstance = SaitaProxy(payable(_proxyInstance));
                    {
                        bytes memory init = returnHash(_ownerWallet, _stakedToken, _stakePeriod, _depositFees, _withdrawalFees, _rewardRate, _emergencyFees, _platformFee, _treasury, _maxStakeLimit);
                        if (init.length > 0)
                            
                            assembly 
                            {
                                if eq(call(gas(), proxyInstance, 0, add(init, 0x20), mload(init), 0, 0), 0) {
                                    revert(0, 0)
                                }
                            }
                    }
                    emit StakingInitialized(_proxyInstance, _stakedToken, _stakePeriod, _depositFees, _withdrawalFees, _rewardRate, _name, _symbol, block.timestamp, uri);
                }
            }
            function setFactoryProxyInstance(address _proxyInstance) external onlyOwner {
                        // set factory in deployed proxy instance
                        SaitaProxy proxyInstance = SaitaProxy(payable(_proxyInstance));
                        proxyInstance.setFactory(address(this));
            }
            function returnHash(address _ownerWallet, address _stakedToken, 
                                uint128 _stakePeriod, uint128 _depositFees, 
                                uint128 _withdrawalFees, uint128 _rewardRate, uint128 _emergencyFees, uint128 _platformFee, address _treasury, uint128 _maxStakeLimit) internal pure returns(bytes memory data) {
                data = abi.encodeWithSignature("initialize(address,address,uint128,uint128,uint128,uint128,uint128,uint128,address,uint128)", _ownerWallet,_stakedToken,_stakePeriod,_depositFees,_withdrawalFees,_rewardRate, _emergencyFees,_platformFee,_treasury, _maxStakeLimit);
            }
            function updateImp(address _newImp) external onlyOwner {
                imp = _newImp;
            }
            function impl() external view returns(address) {
                return imp;
            }
            function totalStakingNo() external view returns(uint256) {
                return totalStakingInstances.length;
            }
            function updateStakeLimit(address _stakedToken, uint128 _newLimit) external onlyOwner {
                IStaking3(tokenAddrToStakingAddr[_stakedToken]).updateStakeLimit(_newLimit);
                emit UpdateStakeLimit(tokenAddrToStakingAddr[_stakedToken], _newLimit);
            }
            
        }

        File 2 of 4: SaitaRealtyV2
        // SPDX-License-Identifier: NOLICENSE
        pragma solidity ^0.8.10;
        interface IERC20 {
            function totalSupply() external view returns (uint256);
            function balanceOf(address account) external view returns (uint256);
            function transfer(address recipient, uint256 amount) external returns (bool);
            function allowance(address owner, address spender) external view returns (uint256);
            function approve(address spender, uint256 amount) external returns (bool);
            function transferFrom(
                address sender,
                address recipient,
                uint256 amount
            ) external returns (bool);
            event Transfer(address indexed from, address indexed to, uint256 value);
            event Approval(address indexed owner, address indexed spender, uint256 value);
        }
        abstract contract Context {
            function _msgSender() internal view virtual returns (address) {
                return msg.sender;
            }
            function _msgData() internal view virtual returns (bytes calldata) {
                this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
                return msg.data;
            }
        }
        abstract contract Ownable is Context {
            address private _owner;
            event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
            constructor() {
                _setOwner(_msgSender());
            }
            function owner() public view virtual returns (address) {
                return _owner;
            }
            modifier onlyOwner() {
                require(owner() == _msgSender(), "Ownable: caller is not the owner");
                _;
            }
            function renounceOwnership() public virtual onlyOwner {
                _setOwner(address(0));
            }
            function transferOwnership(address newOwner) public virtual onlyOwner {
                require(newOwner != address(0), "Ownable: new owner is the zero address");
                _setOwner(newOwner);
            }
            function _setOwner(address newOwner) internal {
                address oldOwner = _owner;
                _owner = newOwner;
                emit OwnershipTransferred(oldOwner, newOwner);
            }
        }
        interface IFactory{
                function createPair(address tokenA, address tokenB) external returns (address pair);
        }
        interface IRouter {
            function factory() external pure returns (address);
            function WETH() external pure returns (address);
            function addTreasuryETH(
                address token,
                uint amountTokenDesired,
                uint amountTokenMin,
                uint amountETHMin,
                address to,
                uint deadline
            ) external payable returns (uint amountToken, uint amountETH, uint treasury);
            function swapExactTokensForETHSupportingFeeOnTransferTokens(
                uint amountIn,
                uint amountOutMin,
                address[] calldata path,
                address to,
                uint deadline) external;
            function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
        }
        contract SaitaRealtyV2 is IERC20, Ownable {
            mapping(address => uint256) private _rOwned;
            mapping(address => uint256) private _tOwned;
            mapping(address => mapping(address => uint256)) private _allowances;
            mapping(address => bool) private _isExcludedFromFee;
            mapping(address => bool) private _isExcluded;
            mapping(address => bool) private _isBot;
            mapping(address => bool) private _isPair;
            address[] private _excluded;
            
            bool private swapping;
            IRouter public router;
            address public pair;
            uint8 private constant _decimals = 9;
            uint256 private constant MAX = ~uint256(0);
            uint256 private _tTotal = 12e10 * 10**_decimals;
            uint256 private _rTotal = (MAX - (MAX % _tTotal));
            
            uint256 public swapTokensAtAmount = 1_000 * 10 ** 6;
            uint256 public maxTxAmount = 100_000_000_000 * 10**_decimals;
            
            // Anti Dump //
            mapping (address => uint256) public _lastTrade;
            bool public coolDownEnabled = true;
            uint256 public coolDownTime = 30 seconds;
            address public capitalAddress = 0x22D5c2837FFB86392C81D3Be0aDe307F81AF10C1;
            address public marketingAddress = 0x2084f438b1EFf6Bd5FbdE57215eaB741CAC7aDb7;
            address public burnAddress = 0x000000000000000000000000000000000000dEaD;
            address public USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
            string private constant _name = "SaitaRealtyV2";
            string private constant _symbol = "SRLTY";
            struct Taxes {
              uint256 reflection;
              uint256 capital;
              uint256 marketing;
              uint256 burn;
              uint256 treasury;
            }
            Taxes private taxes = Taxes(10,10,10,10,50);
            struct TotFeesPaidStruct {
                uint256 reflection;
                uint256 capital;
                uint256 marketing;
                uint256 burn;
                uint256 treasury;
            }
            TotFeesPaidStruct public totFeesPaid;
            struct valuesFromGetValues{
              uint256 rAmount;
              uint256 rTransferAmount;
              uint256 rReflection;
              uint256 rCapital;
              uint256 rMarketing;
              uint256 rBurn;
              uint256 rTreasury;
              uint256 tTransferAmount;
              uint256 tReflection;
              uint256 tCapital;
              uint256 tMarketing;
              uint256 tBurn;
              uint256 tTreasury;
            }
            
            struct splitETHStruct{
                uint256 capital;
                uint256 marketing;
            }
            splitETHStruct private splitETH = splitETHStruct(40,10);
            struct ETHAmountStruct{
                uint256 capital;
                uint256 marketing;
            }
            ETHAmountStruct public ETHAmount;
            event FeesChanged();
            modifier lockTheSwap {
                swapping = true;
                _;
                swapping = false;
            }
            modifier addressValidation(address _addr) {
                require(_addr != address(0), 'SaitaRealty: Zero address');
                _;
            }
            constructor (address routerAddress, address owner_) {
                IRouter _router = IRouter(routerAddress);
                address _pair = IFactory(_router.factory())
                    .createPair(address(this), _router.WETH());
                router = _router;
                pair = _pair;
                
                addPair(pair);
            
                excludeFromReward(pair);
                _setOwner(owner_);
                _rOwned[owner()] = _rTotal;
                _isExcludedFromFee[owner()] = true;
                _isExcludedFromFee[address(this)] = true;
                _isExcludedFromFee[capitalAddress] = true;
                _isExcludedFromFee[burnAddress] = true;
                _isExcludedFromFee[marketingAddress] = true;
                emit Transfer(address(0), owner(), _tTotal);
            }
            function name() public pure returns (string memory) {
                return _name;
            }
            function symbol() public pure returns (string memory) {
                return _symbol;
            }
            function decimals() public pure returns (uint8) {
                return _decimals;
            }
            function totalSupply() public view override returns (uint256) {
                return _tTotal;
            }
            function balanceOf(address account) public view override returns (uint256) {
                if (_isExcluded[account]) return _tOwned[account];
                return tokenFromReflection(_rOwned[account]);
            }
            function transfer(address recipient, uint256 amount) public override returns (bool) {
                _transfer(_msgSender(), recipient, amount);
                return true;
            }
            function allowance(address owner, address spender) public view override returns (uint256) {
                return _allowances[owner][spender];
            }
            function approve(address spender, uint256 amount) public override returns (bool) {
                _approve(_msgSender(), spender, amount);
                return true;
            }
            function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
                uint256 currentAllowance = _allowances[sender][_msgSender()];
                require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
                _transfer(sender, recipient, amount);
                _approve(sender, _msgSender(), currentAllowance - amount);
                return true;
            }
            function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
                _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
                return true;
            }
            function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
                uint256 currentAllowance = _allowances[_msgSender()][spender];
                require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
                _approve(_msgSender(), spender, currentAllowance - subtractedValue);
                return true;
            }
            function isExcludedFromReward(address account) public view returns (bool) {
                return _isExcluded[account];
            }
            function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
                require(rAmount <= _rTotal, "Amount must be less than total reflections");
                uint256 currentRate =  _getRate();
                return rAmount/currentRate;
            }
            function excludeFromReward(address account) public onlyOwner {
                require(!_isExcluded[account], "Account is already excluded");
                require(_excluded.length <= 200, "Invalid length");
                require(account != owner(), "Owner cannot be excluded");
                if(_rOwned[account] > 0) {
                    _tOwned[account] = tokenFromReflection(_rOwned[account]);
                }
                _isExcluded[account] = true;
                _excluded.push(account);
            }
            function includeInReward(address account) external onlyOwner() {
                require(_isExcluded[account], "Account is not excluded");
                for (uint256 i = 0; i < _excluded.length; i++) {
                    if (_excluded[i] == account) {
                        _excluded[i] = _excluded[_excluded.length - 1];
                        _tOwned[account] = 0;
                        _isExcluded[account] = false;
                        _excluded.pop();
                        break;
                    }
                }
            }
            function excludeFromFee(address account) public onlyOwner {
                _isExcludedFromFee[account] = true;
            }
            function includeInFee(address account) public onlyOwner {
                _isExcludedFromFee[account] = false;
            }
            function isExcludedFromFee(address account) public view returns(bool) {
                return _isExcludedFromFee[account];
            }
            function addPair(address _pair) public onlyOwner {
                _isPair[_pair] = true;
            }
            function removePair(address _pair) public onlyOwner {
                _isPair[_pair] = false;
            }
            function isPair(address account) public view returns(bool){
                return _isPair[account];
            }
            function setTaxes(uint256 _reflection, uint256 _capital, uint256 _marketing, uint256 _burn, uint256 _treasury) public onlyOwner {
                taxes.reflection = _reflection;
                taxes.capital = _capital;
                taxes.marketing = _marketing;
                taxes.burn = _burn;
                taxes.treasury = _treasury;
                emit FeesChanged();
            }
            function setSplitETH(uint256 _capital, uint256 _marketing) public onlyOwner {
                splitETH.capital = _capital;
                splitETH.marketing = _marketing;
                emit FeesChanged();
            }
            function _reflectReflection(uint256 rReflection, uint256 tReflection) private {
                _rTotal -=rReflection;
                totFeesPaid.reflection += tReflection;
            }
            function _takeTreasury(uint256 rTreasury, uint256 tTreasury) private {
                totFeesPaid.treasury += tTreasury;
                if(_isExcluded[address(this)]) _tOwned[address(this)] += tTreasury;
                _rOwned[address(this)] += rTreasury;
            }
            function _takeCapital(uint256 rCapital, uint256 tCapital) private {
                totFeesPaid.capital += tCapital;
                if(_isExcluded[capitalAddress]) _tOwned[capitalAddress] += tCapital;
                _rOwned[capitalAddress] +=rCapital;
            }
            
            function _takeMarketing(uint256 rMarketing, uint256 tMarketing) private{
                totFeesPaid.marketing += tMarketing;
                if(_isExcluded[marketingAddress]) _tOwned[marketingAddress] += tMarketing;
                _rOwned[marketingAddress] += rMarketing;
            }
            function _takeBurn(uint256 rBurn, uint256 tBurn) private {
                totFeesPaid.burn += tBurn;
                if(_isExcluded[marketingAddress])_tOwned[burnAddress] += tBurn;
                _rOwned[burnAddress] += rBurn;
            }
            function _getValues(uint256 tAmount, uint8 takeFee) private  returns (valuesFromGetValues memory to_return) {
                to_return = _getTValues(tAmount, takeFee);
                (to_return.rAmount, to_return.rTransferAmount, to_return.rReflection, to_return.rCapital,to_return.rMarketing, to_return.rBurn, to_return.rTreasury) = _getRValues(to_return, tAmount, takeFee, _getRate());
                return to_return;
            }
            function _getTValues(uint256 tAmount, uint8 takeFee) private returns (valuesFromGetValues memory s) {
                if(takeFee == 0) {
                  s.tTransferAmount = tAmount;
                  return s;
                } else if(takeFee == 1){
                    s.tReflection = (tAmount*taxes.reflection)/1000;
                    s.tCapital = (tAmount*taxes.capital)/1000;
                    s.tMarketing = tAmount*taxes.marketing/1000;
                    s.tBurn = tAmount*taxes.burn/1000;
                    s.tTreasury = tAmount*taxes.treasury/1000;
                    ETHAmount.capital += s.tTreasury*splitETH.capital/taxes.treasury;
                    ETHAmount.marketing += s.tTreasury*splitETH.marketing/taxes.treasury;
                    s.tTransferAmount = tAmount-s.tReflection-s.tCapital-s.tTreasury-s.tMarketing-s.tBurn;
                    return s;
                } else {
                    s.tReflection = tAmount*taxes.reflection/1000;
                    s.tMarketing = tAmount*taxes.marketing/1000;
                    s.tBurn = tAmount*taxes.burn/1000;
                    s.tTreasury = tAmount*splitETH.marketing/1000;
                    ETHAmount.marketing += s.tTreasury;
                    s.tTransferAmount = tAmount-s.tReflection-s.tTreasury-s.tMarketing-s.tBurn;
                    return s;
                }
                
            }
            function _getRValues(valuesFromGetValues memory s, uint256 tAmount, uint8 takeFee, uint256 currentRate) private pure returns (uint256 rAmount, uint256 rTransferAmount, uint256 rReflection,uint256 rCapital,uint256 rMarketing,uint256 rBurn,uint256 rTreasury) {
                rAmount = tAmount*currentRate;
                if(takeFee == 0) {
                  return(rAmount, rAmount, 0,0,0,0,0);
                }else if(takeFee == 1){
                    rReflection = s.tReflection*currentRate;
                    rCapital = s.tCapital*currentRate;
                    rTreasury = s.tTreasury*currentRate;
                    rMarketing = s.tMarketing*currentRate;
                    rBurn = s.tBurn*currentRate;
                    rTransferAmount =  rAmount-rReflection-rCapital-rTreasury-rMarketing-rBurn;
                    return (rAmount, rTransferAmount, rReflection,rCapital,rMarketing,rBurn,rTreasury);
                }
                else{
                    rReflection = s.tReflection*currentRate;
                    rTreasury = s.tTreasury*currentRate;
                    rMarketing = s.tMarketing*currentRate;
                    rBurn = s.tBurn*currentRate;
                    rTransferAmount =  rAmount-rReflection-rTreasury-rMarketing-rBurn;
                    return (rAmount, rTransferAmount, rReflection,0,rMarketing,rBurn,rTreasury);
                }
            }
            function _getRate() private view returns(uint256) {
                (uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
                return rSupply/tSupply;
            }
            function _getCurrentSupply() private view returns(uint256, uint256) {
                uint256 rSupply = _rTotal;
                uint256 tSupply = _tTotal;
                for (uint256 i = 0; i < _excluded.length; i++) {
                    if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
                    rSupply = rSupply-_rOwned[_excluded[i]];
                    tSupply = tSupply-_tOwned[_excluded[i]];
                }
                if (rSupply < _rTotal/_tTotal) return (_rTotal, _tTotal);
                return (rSupply, tSupply);
            }
            function _approve(address owner, address spender, uint256 amount) private {
                require(owner != address(0), "ERC20: approve from the zero address");
                require(spender != address(0), "ERC20: approve to the zero address");
                _allowances[owner][spender] = amount;
                emit Approval(owner, spender, amount);
            }
            function _transfer(address from, address to, uint256 amount) private {
                require(from != address(0), "ERC20: transfer from the zero address");
                require(to != address(0), "ERC20: transfer to the zero address");
                require(amount > 0, "Zero amount");
                require(amount <= balanceOf(from),"Insufficient balance");
                require(!_isBot[from] && !_isBot[to], "You are a bot");
                require(amount <= maxTxAmount ,"Amount is exceeding maxTxAmount");
                if (coolDownEnabled) {
                    uint256 timePassed = block.timestamp - _lastTrade[from];
                    require(timePassed > coolDownTime, "You must wait coolDownTime");
                }
                
                if(!_isExcludedFromFee[from] && !_isExcludedFromFee[to] && !swapping) {//check this !swapping
                    if(_isPair[from] || _isPair[to]) {
                        _tokenTransfer(from, to, amount, 1);
                    } else {
                        _tokenTransfer(from, to, amount, 2);
                    }
                } else {
                    _tokenTransfer(from, to, amount, 0);
                }
                _lastTrade[from] = block.timestamp;
                
                if(!swapping && from != pair && to != pair && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]){
                    address[] memory path = new address[](3);
                        path[0] = address(this);
                        path[1] = router.WETH();
                        path[2] = USDT;
                    uint _amount = router.getAmountsOut(balanceOf(address(this)), path)[2];
                    if(_amount >= swapTokensAtAmount) swapTokensForETH(balanceOf(address(this)));
                }
            }
            //this method is responsible for taking all fee, if takeFee is true
            function _tokenTransfer(address sender, address recipient, uint256 tAmount, uint8 takeFee) private {
                valuesFromGetValues memory s = _getValues(tAmount, takeFee);
                if (_isExcluded[sender] ) {  //from excluded
                        _tOwned[sender] = _tOwned[sender] - tAmount;
                }
                if (_isExcluded[recipient]) { //to excluded
                        _tOwned[recipient] = _tOwned[recipient] + s.tTransferAmount;
                }
                _rOwned[sender] = _rOwned[sender]-s.rAmount;
                _rOwned[recipient] = _rOwned[recipient]+s.rTransferAmount;
                
                if(s.rReflection > 0 || s.tReflection > 0) _reflectReflection(s.rReflection, s.tReflection);
                if(s.rTreasury > 0 || s.tTreasury > 0) {
                    _takeTreasury(s.rTreasury,s.tTreasury);
                }
                if(s.rCapital > 0 || s.tCapital > 0){
                    _takeCapital(s.rCapital, s.tCapital);
                    emit Transfer(sender, capitalAddress, s.tMarketing);
                }
                if(s.rMarketing > 0 || s.tMarketing > 0){
                    _takeMarketing(s.rMarketing, s.tMarketing);
                    emit Transfer(sender, marketingAddress, s.tMarketing);
                }
                if(s.rBurn > 0 || s.tBurn > 0){
                    _takeBurn(s.rBurn, s.tBurn);
                    emit Transfer(sender, burnAddress, s.tBurn);
                }
                
                emit Transfer(sender, recipient, s.tTransferAmount);
                if(s.tTreasury > 0){
                emit Transfer(sender, address(this), s.tTreasury);
                }
            }
            function swapTokensForETH(uint256 tokenAmount) private lockTheSwap {
                // generate the uniswap pair path of token -> weth
                address[] memory path = new address[](2);
                        path[0] = address(this);
                        path[1] = router.WETH();
                _approve(address(this), address(router), tokenAmount);
                // make the swap
                router.swapExactTokensForETHSupportingFeeOnTransferTokens(
                    tokenAmount,
                    0, // accept any amount of ETH
                    path,
                    address(this),
                    block.timestamp
                );
                (bool success, ) = capitalAddress.call{value: (ETHAmount.capital * address(this).balance)/tokenAmount}("");
                require(success, 'ETH_TRANSFER_FAILED');
                ETHAmount.capital = 0;
                (success, ) = marketingAddress.call{value: (ETHAmount.marketing * address(this).balance)/tokenAmount}("");
                require(success, 'ETH_TRANSFER_FAILED');
                ETHAmount.marketing = 0;
            }
            function updateCapitalWallet(address newWallet) external onlyOwner addressValidation(newWallet) {
                require(capitalAddress != newWallet, 'SaitaRealty: Wallet already set');
                capitalAddress = newWallet;
                _isExcludedFromFee[capitalAddress];
            }
            function updateBurnWallet(address newWallet) external onlyOwner addressValidation(newWallet) {
                require(burnAddress != newWallet, 'SaitaRealty: Wallet already set');
                burnAddress = newWallet;
                _isExcludedFromFee[burnAddress];
            }
            function updateMarketingWallet(address newWallet) external onlyOwner addressValidation(newWallet) {
                require(marketingAddress != newWallet, 'SaitaRealty: Wallet already set');
                marketingAddress = newWallet;
                _isExcludedFromFee[marketingAddress];
            }
            function updateStableCoin(address _usdt) external onlyOwner  addressValidation(_usdt) {
                require(USDT != _usdt, 'SaitaRealty: Wallet already set');
                USDT = _usdt;
            }
            function updateMaxTxAmt(uint256 amount) external onlyOwner {
                require(amount >= 100);
                maxTxAmount = amount * 10**_decimals;
            }
            function updateSwapTokensAtAmount(uint256 amount) external onlyOwner {
                require(amount > 0);
                swapTokensAtAmount = amount * 10**6;
            }
            function updateCoolDownSettings(bool _enabled, uint256 _timeInSeconds) external onlyOwner{
                coolDownEnabled = _enabled;
                coolDownTime = _timeInSeconds * 1 seconds;
            }
            function setAntibot(address account, bool state) external onlyOwner{
                require(_isBot[account] != state, 'SaitaRealty: Value already set');
                _isBot[account] = state;
            }
            
            function bulkAntiBot(address[] memory accounts, bool state) external onlyOwner {
                require(accounts.length <= 100, "SaitaRealty: Invalid");
                for(uint256 i = 0; i < accounts.length; i++){
                    _isBot[accounts[i]] = state;
                }
            }
            
            function updateRouterAndPair(address newRouter, address newPair) external onlyOwner {
                router = IRouter(newRouter);
                pair = newPair;
                addPair(pair);
            }
            
            function isBot(address account) public view returns(bool){
                return _isBot[account];
            }
            
            function airdropTokens(address[] memory recipients, uint256[] memory amounts) external onlyOwner {
                require(recipients.length == amounts.length,"Invalid size");
                 address sender = msg.sender;
                 for(uint256 i; i<recipients.length; i++){
                    address recipient = recipients[i];
                    uint256 rAmount = amounts[i]*_getRate();
                    _rOwned[sender] = _rOwned[sender]- rAmount;
                    _rOwned[recipient] = _rOwned[recipient] + rAmount;
                    emit Transfer(sender, recipient, amounts[i]);
                 }
                }
            //Use this in case ETH are sent to the contract by mistake
            function rescueETH(uint256 weiAmount) external onlyOwner{
                require(address(this).balance >= weiAmount, "insufficient ETH balance");
                payable(owner()).transfer(weiAmount);
            }
            
            // Function to allow admin to claim *other* ERC20 tokens sent to this contract (by mistake)
            // Owner cannot transfer out catecoin from this smart contract
            function rescueAnyERC20Tokens(address _tokenAddr, address _to, uint _amount) public onlyOwner {
                IERC20(_tokenAddr).transfer(_to, _amount);
            }
            receive() external payable {
            }
        }

        File 3 of 4: SaitaProxy
        // SPDX-License-Identifier: UNLICENSED
        pragma solidity ^0.8.0;
        interface IStakeFactory {
            function impl() external view returns(address);
        }// SPDX-License-Identifier: Unlicensed
        pragma solidity ^0.8.0;
        import "./interface/IStakeFactory.sol";
        contract SaitaProxy {
            
                bytes32 private constant proxyOwnerPosition = keccak256("com.saitama.proxy.owner");
                bytes32 private constant factory = keccak256("com.saitama.proxy.factory");
            constructor(address owner) {
                setProxyOwner(owner);
            }
            function setProxyOwner(address newProxyOwner) private  {
                bytes32 position = proxyOwnerPosition;
                assembly {
                    sstore(position, newProxyOwner)
                }
            }
            function setFactory(address _factory) public  {
                require(msg.sender == proxyOwner(), "ONLY_OWNER_CAN_CHANGE");
                bytes32 position = factory;
                assembly {
                    sstore(position, _factory)
                }
            }
            function getFactory() public view returns (address _factory) {
                bytes32 position = factory;
                assembly {
                    _factory := sload(position)
                }
            }
            function proxyOwner() public view returns (address owner) {
                bytes32 position = proxyOwnerPosition;
                assembly {
                    owner := sload(position)
                }
            }
            function implementation() public view returns (address) {
                return IStakeFactory(getFactory()).impl();
            }
            
            fallback() external payable {
                address _impl = implementation();
                    assembly 
                        {
                        let ptr := mload(0x40)
                        // (1) copy incoming call data
                        calldatacopy(ptr, 0, calldatasize())
                        // (2) forward call to logic contract
                        let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0)
                        let size := returndatasize()
                        // (3) retrieve return data
                        returndatacopy(ptr, 0, size)
                        // (4) forward return data back to caller
                        switch result
                        case 0 { revert(ptr, size) }
                        default { return(ptr, size) }
                        }
            }
        }

        File 4 of 4: NewStake
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
        pragma solidity ^0.8.0;
        import "../utils/ContextUpgradeable.sol";
        import "../proxy/utils/Initializable.sol";
        /**
         * @dev Contract module which provides a basic access control mechanism, where
         * there is an account (an owner) that can be granted exclusive access to
         * specific functions.
         *
         * By default, the owner account will be the one that deploys the contract. This
         * can later be changed with {transferOwnership}.
         *
         * This module is used through inheritance. It will make available the modifier
         * `onlyOwner`, which can be applied to your functions to restrict their use to
         * the owner.
         */
        abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
            address private _owner;
            event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
            /**
             * @dev Initializes the contract setting the deployer as the initial owner.
             */
            function __Ownable_init() internal onlyInitializing {
                __Ownable_init_unchained();
            }
            function __Ownable_init_unchained() internal onlyInitializing {
                _transferOwnership(_msgSender());
            }
            /**
             * @dev Throws if called by any account other than the owner.
             */
            modifier onlyOwner() {
                _checkOwner();
                _;
            }
            /**
             * @dev Returns the address of the current owner.
             */
            function owner() public view virtual returns (address) {
                return _owner;
            }
            /**
             * @dev Throws if the sender is not the owner.
             */
            function _checkOwner() internal view virtual {
                require(owner() == _msgSender(), "Ownable: caller is not the owner");
            }
            /**
             * @dev Leaves the contract without owner. It will not be possible to call
             * `onlyOwner` functions. Can only be called by the current owner.
             *
             * NOTE: Renouncing ownership will leave the contract without an owner,
             * thereby disabling any functionality that is only available to the owner.
             */
            function renounceOwnership() public virtual onlyOwner {
                _transferOwnership(address(0));
            }
            /**
             * @dev Transfers ownership of the contract to a new account (`newOwner`).
             * Can only be called by the current owner.
             */
            function transferOwnership(address newOwner) public virtual onlyOwner {
                require(newOwner != address(0), "Ownable: new owner is the zero address");
                _transferOwnership(newOwner);
            }
            /**
             * @dev Transfers ownership of the contract to a new account (`newOwner`).
             * Internal function without access restriction.
             */
            function _transferOwnership(address newOwner) internal virtual {
                address oldOwner = _owner;
                _owner = newOwner;
                emit OwnershipTransferred(oldOwner, newOwner);
            }
            /**
             * @dev This empty reserved space is put in place to allow future versions to add new
             * variables without shifting down storage in the inheritance chain.
             * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
             */
            uint256[49] private __gap;
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
        pragma solidity ^0.8.2;
        import "../../utils/AddressUpgradeable.sol";
        /**
         * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
         * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
         * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
         * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
         *
         * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
         * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
         * case an upgrade adds a module that needs to be initialized.
         *
         * For example:
         *
         * [.hljs-theme-light.nopadding]
         * ```solidity
         * contract MyToken is ERC20Upgradeable {
         *     function initialize() initializer public {
         *         __ERC20_init("MyToken", "MTK");
         *     }
         * }
         *
         * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
         *     function initializeV2() reinitializer(2) public {
         *         __ERC20Permit_init("MyToken");
         *     }
         * }
         * ```
         *
         * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
         * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
         *
         * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
         * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
         *
         * [CAUTION]
         * ====
         * Avoid leaving a contract uninitialized.
         *
         * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
         * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
         * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
         *
         * [.hljs-theme-light.nopadding]
         * ```
         * /// @custom:oz-upgrades-unsafe-allow constructor
         * constructor() {
         *     _disableInitializers();
         * }
         * ```
         * ====
         */
        abstract contract Initializable {
            /**
             * @dev Indicates that the contract has been initialized.
             * @custom:oz-retyped-from bool
             */
            uint8 private _initialized;
            /**
             * @dev Indicates that the contract is in the process of being initialized.
             */
            bool private _initializing;
            /**
             * @dev Triggered when the contract has been initialized or reinitialized.
             */
            event Initialized(uint8 version);
            /**
             * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
             * `onlyInitializing` functions can be used to initialize parent contracts.
             *
             * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
             * constructor.
             *
             * Emits an {Initialized} event.
             */
            modifier initializer() {
                bool isTopLevelCall = !_initializing;
                require(
                    (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
                    "Initializable: contract is already initialized"
                );
                _initialized = 1;
                if (isTopLevelCall) {
                    _initializing = true;
                }
                _;
                if (isTopLevelCall) {
                    _initializing = false;
                    emit Initialized(1);
                }
            }
            /**
             * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
             * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
             * used to initialize parent contracts.
             *
             * A reinitializer may be used after the original initialization step. This is essential to configure modules that
             * are added through upgrades and that require initialization.
             *
             * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
             * cannot be nested. If one is invoked in the context of another, execution will revert.
             *
             * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
             * a contract, executing them in the right order is up to the developer or operator.
             *
             * WARNING: setting the version to 255 will prevent any future reinitialization.
             *
             * Emits an {Initialized} event.
             */
            modifier reinitializer(uint8 version) {
                require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
                _initialized = version;
                _initializing = true;
                _;
                _initializing = false;
                emit Initialized(version);
            }
            /**
             * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
             * {initializer} and {reinitializer} modifiers, directly or indirectly.
             */
            modifier onlyInitializing() {
                require(_initializing, "Initializable: contract is not initializing");
                _;
            }
            /**
             * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
             * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
             * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
             * through proxies.
             *
             * Emits an {Initialized} event the first time it is successfully executed.
             */
            function _disableInitializers() internal virtual {
                require(!_initializing, "Initializable: contract is initializing");
                if (_initialized != type(uint8).max) {
                    _initialized = type(uint8).max;
                    emit Initialized(type(uint8).max);
                }
            }
            /**
             * @dev Returns the highest version that has been initialized. See {reinitializer}.
             */
            function _getInitializedVersion() internal view returns (uint8) {
                return _initialized;
            }
            /**
             * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
             */
            function _isInitializing() internal view returns (bool) {
                return _initializing;
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
        pragma solidity ^0.8.0;
        import "../proxy/utils/Initializable.sol";
        /**
         * @dev Contract module that helps prevent reentrant calls to a function.
         *
         * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
         * available, which can be applied to functions to make sure there are no nested
         * (reentrant) calls to them.
         *
         * Note that because there is a single `nonReentrant` guard, functions marked as
         * `nonReentrant` may not call one another. This can be worked around by making
         * those functions `private`, and then adding `external` `nonReentrant` entry
         * points to them.
         *
         * TIP: If you would like to learn more about reentrancy and alternative ways
         * to protect against it, check out our blog post
         * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
         */
        abstract contract ReentrancyGuardUpgradeable is Initializable {
            // Booleans are more expensive than uint256 or any type that takes up a full
            // word because each write operation emits an extra SLOAD to first read the
            // slot's contents, replace the bits taken up by the boolean, and then write
            // back. This is the compiler's defense against contract upgrades and
            // pointer aliasing, and it cannot be disabled.
            // The values being non-zero value makes deployment a bit more expensive,
            // but in exchange the refund on every call to nonReentrant will be lower in
            // amount. Since refunds are capped to a percentage of the total
            // transaction's gas, it is best to keep them low in cases like this one, to
            // increase the likelihood of the full refund coming into effect.
            uint256 private constant _NOT_ENTERED = 1;
            uint256 private constant _ENTERED = 2;
            uint256 private _status;
            function __ReentrancyGuard_init() internal onlyInitializing {
                __ReentrancyGuard_init_unchained();
            }
            function __ReentrancyGuard_init_unchained() internal onlyInitializing {
                _status = _NOT_ENTERED;
            }
            /**
             * @dev Prevents a contract from calling itself, directly or indirectly.
             * Calling a `nonReentrant` function from another `nonReentrant`
             * function is not supported. It is possible to prevent this from happening
             * by making the `nonReentrant` function external, and making it call a
             * `private` function that does the actual work.
             */
            modifier nonReentrant() {
                _nonReentrantBefore();
                _;
                _nonReentrantAfter();
            }
            function _nonReentrantBefore() private {
                // On the first call to nonReentrant, _status will be _NOT_ENTERED
                require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
                // Any calls to nonReentrant after this point will fail
                _status = _ENTERED;
            }
            function _nonReentrantAfter() private {
                // By storing the original value once again, a refund is triggered (see
                // https://eips.ethereum.org/EIPS/eip-2200)
                _status = _NOT_ENTERED;
            }
            /**
             * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
             * `nonReentrant` function in the call stack.
             */
            function _reentrancyGuardEntered() internal view returns (bool) {
                return _status == _ENTERED;
            }
            /**
             * @dev This empty reserved space is put in place to allow future versions to add new
             * variables without shifting down storage in the inheritance chain.
             * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
             */
            uint256[49] private __gap;
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
        pragma solidity ^0.8.1;
        /**
         * @dev Collection of functions related to the address type
         */
        library AddressUpgradeable {
            /**
             * @dev Returns true if `account` is a contract.
             *
             * [IMPORTANT]
             * ====
             * It is unsafe to assume that an address for which this function returns
             * false is an externally-owned account (EOA) and not a contract.
             *
             * Among others, `isContract` will return false for the following
             * types of addresses:
             *
             *  - an externally-owned account
             *  - a contract in construction
             *  - an address where a contract will be created
             *  - an address where a contract lived, but was destroyed
             *
             * Furthermore, `isContract` will also return true if the target contract within
             * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
             * which only has an effect at the end of a transaction.
             * ====
             *
             * [IMPORTANT]
             * ====
             * You shouldn't rely on `isContract` to protect against flash loan attacks!
             *
             * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
             * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
             * constructor.
             * ====
             */
            function isContract(address account) internal view returns (bool) {
                // This method relies on extcodesize/address.code.length, which returns 0
                // for contracts in construction, since the code is only stored at the end
                // of the constructor execution.
                return account.code.length > 0;
            }
            /**
             * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
             * `recipient`, forwarding all available gas and reverting on errors.
             *
             * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
             * of certain opcodes, possibly making contracts go over the 2300 gas limit
             * imposed by `transfer`, making them unable to receive funds via
             * `transfer`. {sendValue} removes this limitation.
             *
             * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
             *
             * IMPORTANT: because control is transferred to `recipient`, care must be
             * taken to not create reentrancy vulnerabilities. Consider using
             * {ReentrancyGuard} or the
             * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
             */
            function sendValue(address payable recipient, uint256 amount) internal {
                require(address(this).balance >= amount, "Address: insufficient balance");
                (bool success, ) = recipient.call{value: amount}("");
                require(success, "Address: unable to send value, recipient may have reverted");
            }
            /**
             * @dev Performs a Solidity function call using a low level `call`. A
             * plain `call` is an unsafe replacement for a function call: use this
             * function instead.
             *
             * If `target` reverts with a revert reason, it is bubbled up by this
             * function (like regular Solidity function calls).
             *
             * Returns the raw returned data. To convert to the expected return value,
             * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
             *
             * Requirements:
             *
             * - `target` must be a contract.
             * - calling `target` with `data` must not revert.
             *
             * _Available since v3.1._
             */
            function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                return functionCallWithValue(target, data, 0, "Address: low-level call failed");
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
             * `errorMessage` as a fallback revert reason when `target` reverts.
             *
             * _Available since v3.1._
             */
            function functionCall(
                address target,
                bytes memory data,
                string memory errorMessage
            ) internal returns (bytes memory) {
                return functionCallWithValue(target, data, 0, errorMessage);
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
             * but also transferring `value` wei to `target`.
             *
             * Requirements:
             *
             * - the calling contract must have an ETH balance of at least `value`.
             * - the called Solidity function must be `payable`.
             *
             * _Available since v3.1._
             */
            function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
                return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
            }
            /**
             * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
             * with `errorMessage` as a fallback revert reason when `target` reverts.
             *
             * _Available since v3.1._
             */
            function functionCallWithValue(
                address target,
                bytes memory data,
                uint256 value,
                string memory errorMessage
            ) internal returns (bytes memory) {
                require(address(this).balance >= value, "Address: insufficient balance for call");
                (bool success, bytes memory returndata) = target.call{value: value}(data);
                return verifyCallResultFromTarget(target, success, returndata, errorMessage);
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
             * but performing a static call.
             *
             * _Available since v3.3._
             */
            function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                return functionStaticCall(target, data, "Address: low-level static call failed");
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
             * but performing a static call.
             *
             * _Available since v3.3._
             */
            function functionStaticCall(
                address target,
                bytes memory data,
                string memory errorMessage
            ) internal view returns (bytes memory) {
                (bool success, bytes memory returndata) = target.staticcall(data);
                return verifyCallResultFromTarget(target, success, returndata, errorMessage);
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
             * but performing a delegate call.
             *
             * _Available since v3.4._
             */
            function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
                return functionDelegateCall(target, data, "Address: low-level delegate call failed");
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
             * but performing a delegate call.
             *
             * _Available since v3.4._
             */
            function functionDelegateCall(
                address target,
                bytes memory data,
                string memory errorMessage
            ) internal returns (bytes memory) {
                (bool success, bytes memory returndata) = target.delegatecall(data);
                return verifyCallResultFromTarget(target, success, returndata, errorMessage);
            }
            /**
             * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
             * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
             *
             * _Available since v4.8._
             */
            function verifyCallResultFromTarget(
                address target,
                bool success,
                bytes memory returndata,
                string memory errorMessage
            ) internal view returns (bytes memory) {
                if (success) {
                    if (returndata.length == 0) {
                        // only check isContract if the call was successful and the return data is empty
                        // otherwise we already know that it was a contract
                        require(isContract(target), "Address: call to non-contract");
                    }
                    return returndata;
                } else {
                    _revert(returndata, errorMessage);
                }
            }
            /**
             * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
             * revert reason or using the provided one.
             *
             * _Available since v4.3._
             */
            function verifyCallResult(
                bool success,
                bytes memory returndata,
                string memory errorMessage
            ) internal pure returns (bytes memory) {
                if (success) {
                    return returndata;
                } else {
                    _revert(returndata, errorMessage);
                }
            }
            function _revert(bytes memory returndata, string memory errorMessage) private pure {
                // Look for revert reason and bubble it up if present
                if (returndata.length > 0) {
                    // The easiest way to bubble the revert reason is using memory via assembly
                    /// @solidity memory-safe-assembly
                    assembly {
                        let returndata_size := mload(returndata)
                        revert(add(32, returndata), returndata_size)
                    }
                } else {
                    revert(errorMessage);
                }
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
        pragma solidity ^0.8.0;
        import "../proxy/utils/Initializable.sol";
        /**
         * @dev Provides information about the current execution context, including the
         * sender of the transaction and its data. While these are generally available
         * via msg.sender and msg.data, they should not be accessed in such a direct
         * manner, since when dealing with meta-transactions the account sending and
         * paying for execution may not be the actual sender (as far as an application
         * is concerned).
         *
         * This contract is only required for intermediate, library-like contracts.
         */
        abstract contract ContextUpgradeable is Initializable {
            function __Context_init() internal onlyInitializing {
            }
            function __Context_init_unchained() internal onlyInitializing {
            }
            function _msgSender() internal view virtual returns (address) {
                return msg.sender;
            }
            function _msgData() internal view virtual returns (bytes calldata) {
                return msg.data;
            }
            /**
             * @dev This empty reserved space is put in place to allow future versions to add new
             * variables without shifting down storage in the inheritance chain.
             * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
             */
            uint256[50] private __gap;
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)
        pragma solidity ^0.8.0;
        // CAUTION
        // This version of SafeMath should only be used with Solidity 0.8 or later,
        // because it relies on the compiler's built in overflow checks.
        /**
         * @dev Wrappers over Solidity's arithmetic operations.
         *
         * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
         * now has built in overflow checking.
         */
        library SafeMathUpgradeable {
            /**
             * @dev Returns the addition of two unsigned integers, with an overflow flag.
             *
             * _Available since v3.4._
             */
            function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
                unchecked {
                    uint256 c = a + b;
                    if (c < a) return (false, 0);
                    return (true, c);
                }
            }
            /**
             * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
             *
             * _Available since v3.4._
             */
            function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
                unchecked {
                    if (b > a) return (false, 0);
                    return (true, a - b);
                }
            }
            /**
             * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
             *
             * _Available since v3.4._
             */
            function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
                unchecked {
                    // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
                    // benefit is lost if 'b' is also tested.
                    // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
                    if (a == 0) return (true, 0);
                    uint256 c = a * b;
                    if (c / a != b) return (false, 0);
                    return (true, c);
                }
            }
            /**
             * @dev Returns the division of two unsigned integers, with a division by zero flag.
             *
             * _Available since v3.4._
             */
            function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
                unchecked {
                    if (b == 0) return (false, 0);
                    return (true, a / b);
                }
            }
            /**
             * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
             *
             * _Available since v3.4._
             */
            function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
                unchecked {
                    if (b == 0) return (false, 0);
                    return (true, a % b);
                }
            }
            /**
             * @dev Returns the addition of two unsigned integers, reverting on
             * overflow.
             *
             * Counterpart to Solidity's `+` operator.
             *
             * Requirements:
             *
             * - Addition cannot overflow.
             */
            function add(uint256 a, uint256 b) internal pure returns (uint256) {
                return a + b;
            }
            /**
             * @dev Returns the subtraction of two unsigned integers, reverting on
             * overflow (when the result is negative).
             *
             * Counterpart to Solidity's `-` operator.
             *
             * Requirements:
             *
             * - Subtraction cannot overflow.
             */
            function sub(uint256 a, uint256 b) internal pure returns (uint256) {
                return a - b;
            }
            /**
             * @dev Returns the multiplication of two unsigned integers, reverting on
             * overflow.
             *
             * Counterpart to Solidity's `*` operator.
             *
             * Requirements:
             *
             * - Multiplication cannot overflow.
             */
            function mul(uint256 a, uint256 b) internal pure returns (uint256) {
                return a * b;
            }
            /**
             * @dev Returns the integer division of two unsigned integers, reverting on
             * division by zero. The result is rounded towards zero.
             *
             * Counterpart to Solidity's `/` operator.
             *
             * Requirements:
             *
             * - The divisor cannot be zero.
             */
            function div(uint256 a, uint256 b) internal pure returns (uint256) {
                return a / b;
            }
            /**
             * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
             * reverting when dividing by zero.
             *
             * Counterpart to Solidity's `%` operator. This function uses a `revert`
             * opcode (which leaves remaining gas untouched) while Solidity uses an
             * invalid opcode to revert (consuming all remaining gas).
             *
             * Requirements:
             *
             * - The divisor cannot be zero.
             */
            function mod(uint256 a, uint256 b) internal pure returns (uint256) {
                return a % b;
            }
            /**
             * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
             * overflow (when the result is negative).
             *
             * CAUTION: This function is deprecated because it requires allocating memory for the error
             * message unnecessarily. For custom revert reasons use {trySub}.
             *
             * Counterpart to Solidity's `-` operator.
             *
             * Requirements:
             *
             * - Subtraction cannot overflow.
             */
            function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
                unchecked {
                    require(b <= a, errorMessage);
                    return a - b;
                }
            }
            /**
             * @dev Returns the integer division of two unsigned integers, reverting with custom message on
             * division by zero. The result is rounded towards zero.
             *
             * Counterpart to Solidity's `/` operator. Note: this function uses a
             * `revert` opcode (which leaves remaining gas untouched) while Solidity
             * uses an invalid opcode to revert (consuming all remaining gas).
             *
             * Requirements:
             *
             * - The divisor cannot be zero.
             */
            function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
                unchecked {
                    require(b > 0, errorMessage);
                    return a / b;
                }
            }
            /**
             * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
             * reverting with custom message when dividing by zero.
             *
             * CAUTION: This function is deprecated because it requires allocating memory for the error
             * message unnecessarily. For custom revert reasons use {tryMod}.
             *
             * Counterpart to Solidity's `%` operator. This function uses a `revert`
             * opcode (which leaves remaining gas untouched) while Solidity uses an
             * invalid opcode to revert (consuming all remaining gas).
             *
             * Requirements:
             *
             * - The divisor cannot be zero.
             */
            function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
                unchecked {
                    require(b > 0, errorMessage);
                    return a % b;
                }
            }
        }
        // SPDX-License-Identifier: UNLICENSED
        pragma solidity ^0.8.0;
        interface IStakedToken {
            function transfer(address to, uint256 amount) external returns(bool);
            function transferFrom(address from, address to, uint256 amount) external returns(bool);
            function balanceOf(address owner) external returns(uint256);
            function name() external returns(string memory);
            function symbol() external returns(string memory);
        }//SPDX-License-Identifier: UNLICENSED
        pragma solidity ^0.8.0;
        library StructLibrary {
            
            struct eachTransaction {
                
                uint128 stakeAmount;
                uint128 depositTime;
                uint128 fullWithdrawlTime;
                uint128 lastClaimTime;
                bool accumulated;
                
                
            }
            struct StakeTypeData {
                uint128 stakeType;
                uint128 stakePeriod;
                uint128 depositFees;
                uint128 withdrawlFees;
                uint128 rewardRate;
                uint128 totalStakedIn;
                bool isActive;
            }
            
        }// SPDX-License-Identifier: UNLICENSED
        pragma solidity ^0.8.0;
        import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
        import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
        import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
        import "./interface/IStakedToken.sol";
        import "./library/StructLibrary.sol";
        contract NewStake is OwnableUpgradeable, ReentrancyGuardUpgradeable {
            using SafeMathUpgradeable for uint128;
            using StructLibrary for StructLibrary.eachTransaction;
            using StructLibrary for StructLibrary.StakeTypeData;
            IStakedToken public stakedToken;
            string public name;
            string public symbol;
            address public ownerWallet;
            address public treasury;
            uint128 public totalStaked;
            uint128 public emergencyFees;
            uint128 public platformFee;
            uint128 public maxStakeLimit;
            bool public claimAndWithdrawFreeze;
            StructLibrary.StakeTypeData[] public stakeTypesList;
            mapping(address => mapping(uint128 => StructLibrary.eachTransaction)) public userStakesData;
            mapping(address => mapping(uint128 => StructLibrary.eachTransaction[])) public userAllStakesData;
            event Deposit(uint128 stakeAmount, uint128 stakeType, uint128 stakePeriod, uint256 time, uint128 poolTotalStaked);
            event Withdraw(address indexed user, uint128 stakeAmount, uint128 stakeType, uint128 rewardAmount, uint256 time, uint128 poolTotalStaked);
            event Compound(address indexed user, uint128 rewardAmount, uint128 stakeType, uint256 time, uint128 poolTotalStaked);
            event Claim(address indexed user, uint128 rewardAmount, uint128 stakeType, uint256 time);
            event AddStakeType(uint128 _stakeType, uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawlFees, uint128 _rewardRate);
            event UpdateStakeType(uint128 _stakeType, uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawlFees, uint128 _rewardRate);
            event DeleteStakeType(uint128 _stakeType);
            event UpdateStakeToken(address indexed newTokenAddr);
            event EmergencyWithdrawn(address indexed user, uint128 amount, uint128 stakeType, uint256 time, uint128 poolTotalStaked);
            event UpdateEmergencyFee(address indexed _stakeToken, uint128 oldFee, uint128 newFee);
            event UpdatePlatformFee(address indexed _stakeToken, uint128 oldFee, uint128 newFee);
            event UpdateOwnerWallet(address indexed _stakeToken, address indexed oldOwnerWallet, address indexed newOwnerWallet);
            event UpdateTreasuryWallet(address indexed _stakeToken, address indexed oldTreasuryWallet, address indexed newTreasuryWallet);
            /// @custom:oz-upgrades-unsafe-allow constructor
            constructor() {
                _disableInitializers();
            }
            function initialize(address _ownerWallet, address _stakedToken, 
                                uint128 _stakePeriod, uint128 _depositFees, 
                                uint128 _withdrawlsFees, uint128 _rewardRate, uint128 _emergencyFees, uint128 _platformFee, address _treasury, uint128 _maxStakeLimit) 
                                public initializer {
                require(_treasury != address(0), "TREASURY_WALLET_CANT_BE_NULL_ADDRESS");
                require(_emergencyFees > 0, "EMERGENCY_FEES_CANT_BE_ZERO");
                require(_platformFee > 0, "PLATFORM_FEE_CANT_BE_NULL");
                require(_ownerWallet !=address(0), "OWNER_WALLET_CANT_BE_NULL_ADDRESS");
                require(_stakedToken !=address(0), "TOKEN_ADDRESS_CANT_BE_NULL_ADDRESS");
                require(_depositFees < 10000 && _withdrawlsFees < 10000, "FEES_CANNOT_BE_EQUAL_OR_MORE_THAN_100%");             // FOR DEPOSIT AND WITHDRAWL FESS
                                                                                                                                // 0.01 % -----> input is 1
                                                                                                                                // 0.1% ------> input is 10
                                                                                                                                // 1% -------> input is 100
                require(_rewardRate > 0, "INTEREST_RATE_CANNOT_BE_ZERO");
                __Ownable_init();
                stakedToken = IStakedToken(_stakedToken);
                ownerWallet = _ownerWallet;    
                name = IStakedToken(_stakedToken).name();
                symbol = IStakedToken(_stakedToken).symbol();
                emergencyFees = _emergencyFees;
                platformFee = _platformFee;
                treasury = _treasury;
                maxStakeLimit = _maxStakeLimit;
                stakeTypesList.push(StructLibrary.StakeTypeData(0,_stakePeriod,_depositFees,_withdrawlsFees,_rewardRate,0, true));
            }
            
            function deposit(address user,uint128 _amount, uint128 _stakeType) external payable nonReentrant onlyOwner returns(uint128 emitAmount, uint128 _period, uint128 _totalPoolStaked) {
                require(_amount>0, "STAKE_MORE_THAN_ZERO");
                require(_stakeType < uint128(stakeTypesList.length), "INVALID_STAKE_TYPE");
                transferPlatformFee(treasury, user, uint128(msg.value));
                StructLibrary.StakeTypeData storage stakeType = stakeTypesList[_stakeType];
                require(stakeType.isActive, "POOL_DISABLED");
                StructLibrary.eachTransaction storage stakes = userStakesData[user][_stakeType];
                {
                uint128 limitLeft;
                if(stakes.stakeAmount > 0 && !stakes.accumulated) {
                    if(maxStakeLimit > stakes.stakeAmount) limitLeft = maxStakeLimit - stakes.stakeAmount;
                    require(limitLeft > 0,"MAX_STAKE_LIMIT_REACHED");
                    if(_amount > limitLeft) _amount = limitLeft;
                } else {
                    if(userAllStakesData[user][_stakeType].length > 0) {
                        uint128 stakedAmount;
                        for(uint128 i=0; i < uint128(userAllStakesData[user][_stakeType].length); ++i) {
                            stakedAmount += userAllStakesData[user][_stakeType][i].stakeAmount;
                        }
                        if(maxStakeLimit > stakedAmount) limitLeft = maxStakeLimit - stakedAmount;
                        require(limitLeft > 0,"MAX_STAKE_LIMIT_REACHED");
                        if(_amount > limitLeft) _amount = limitLeft;
                    } else {
                        if(_amount > maxStakeLimit) _amount = maxStakeLimit;
                    }
                }
                }
                _period = stakeType.stakePeriod;
                uint128 fees;
                uint128 actualAmount = _amount;
                if(stakeType.depositFees !=0) {
                    fees = _amount * stakeType.depositFees *100 / 1000000;
                    actualAmount = _amount - fees;
                }
                if(fees > 0) stakedToken.transferFrom(user, treasury, fees);
                uint128 beforeAmount = uint128(stakedToken.balanceOf(address(this)));
                stakedToken.transferFrom(user, address(this), actualAmount);
                uint128 realAmount = uint128(stakedToken.balanceOf(address(this))) - beforeAmount;
                if(stakes.stakeAmount > 0 && !stakes.accumulated) {
                    stakes.accumulated = true;
                    userAllStakesData[user][_stakeType].push(StructLibrary.eachTransaction(stakes.stakeAmount, stakes.depositTime, stakes.fullWithdrawlTime, stakes.lastClaimTime, true));
                    userAllStakesData[user][_stakeType].push(StructLibrary.eachTransaction(realAmount, uint128(block.timestamp), uint128(uint128(block.timestamp).add(stakeType.stakePeriod * 60)), uint128(block.timestamp), true));
                    stakeType.totalStakedIn = uint128(stakeType.totalStakedIn.add(realAmount));
                    // userTotalPerPool[user][_stakeType] +=  realAmount;
                    totalStaked += realAmount;
                    emit Deposit(realAmount, _stakeType, stakeType.stakePeriod, block.timestamp, stakeType.totalStakedIn);
                    emitAmount = realAmount;
                    _totalPoolStaked = stakeType.totalStakedIn;
                } else {
                    stakes.accumulated = true;
                    userAllStakesData[user][_stakeType].push(StructLibrary.eachTransaction(realAmount, uint128(block.timestamp), uint128(uint128(block.timestamp).add(stakeType.stakePeriod * 60)), uint128(block.timestamp), true));
                    
                    stakeType.totalStakedIn = uint128(stakeType.totalStakedIn.add(realAmount));
                    // userTotalPerPool[user][_stakeType] +=  realAmount;
                    totalStaked += realAmount;
                    emit Deposit(realAmount, _stakeType, stakeType.stakePeriod, block.timestamp, stakeType.totalStakedIn);
                    emitAmount = realAmount;
                    _totalPoolStaked = stakeType.totalStakedIn;
                }
            }
            function compound(address user, uint128 _stakeType) external payable nonReentrant onlyOwner returns(uint128, uint128, uint128) {
                require(_stakeType < uint128(stakeTypesList.length), "INVALID_STAKE_TYPE");
                StructLibrary.eachTransaction storage stakes = userStakesData[user][_stakeType];
                // require(stakes.stakeAmount > 0, "NOTHING_AT_STAKE");
                transferPlatformFee(treasury, user, uint128(msg.value));
                StructLibrary.StakeTypeData storage stakeType = stakeTypesList[_stakeType];
                // require(stakeType.isActive, "POOL_DISABLED");
            
                uint128 totalRewardTillNow;
                
                uint128 stakeTimeTillNow;
                // uint128 totalStakes = uint128(userAllStakesData[user][_stakeType].length);
                
                if(!stakes.accumulated) {
                    require(stakes.stakeAmount > 0, "NOTHING_AT_STAKE");
                    uint128 actualAmount = stakes.stakeAmount;
                    if(uint128(block.timestamp) < stakes.fullWithdrawlTime) {
                        stakeTimeTillNow = uint128(block.timestamp) - stakes.lastClaimTime;
                        totalRewardTillNow = rewardCalculation(actualAmount, _stakeType, stakeTimeTillNow); 
                        stakes.lastClaimTime = uint128(block.timestamp);
                    } else {
                        if(stakeType.stakePeriod == 0) {
                            stakeTimeTillNow = uint128(block.timestamp) - stakes.lastClaimTime;
                            stakes.lastClaimTime = uint128(block.timestamp);
                            }
                        else {
                            stakeTimeTillNow = stakes.fullWithdrawlTime - stakes.lastClaimTime;
                            stakes.lastClaimTime = stakes.fullWithdrawlTime;
                            }
                        if(stakeTimeTillNow > 0)
                        totalRewardTillNow = rewardCalculation(actualAmount, _stakeType, stakeTimeTillNow);                
                    }
                    uint128 beforeAmount = uint128(stakedToken.balanceOf(address(this)));
                    if(totalRewardTillNow > 0)
                    claimReward(address(this), totalRewardTillNow);
            
                    uint128 realAmount = uint128(stakedToken.balanceOf(address(this))) - beforeAmount;
                    stakes.stakeAmount += realAmount;
                    stakeType.totalStakedIn +=  realAmount;
                    totalStaked += realAmount;
                    emit Compound(user, realAmount, _stakeType, block.timestamp, stakeType.totalStakedIn);
                    return (realAmount, stakeType.stakePeriod, stakeType.totalStakedIn);
                } else {
                        require(uint128(userAllStakesData[user][_stakeType].length) > 0, "NOTHING_AT_STAKE");
                        uint128 totalCompounded;
                        for(uint128 i=0; i<uint128(userAllStakesData[user][_stakeType].length); ++i) {
                            if(userAllStakesData[user][_stakeType][i].stakeAmount == 0) continue;
                            if(uint128(block.timestamp) < userAllStakesData[user][_stakeType][i].fullWithdrawlTime) {
                                stakeTimeTillNow = uint128(block.timestamp) - userAllStakesData[user][_stakeType][i].lastClaimTime;
                                totalRewardTillNow = rewardCalculation(userAllStakesData[user][_stakeType][i].stakeAmount, _stakeType, stakeTimeTillNow); 
                                userAllStakesData[user][_stakeType][i].lastClaimTime = uint128(block.timestamp);
                            } else {
                                if(stakeType.stakePeriod == 0) {
                                    stakeTimeTillNow = uint128(block.timestamp) - userAllStakesData[user][_stakeType][i].lastClaimTime;
                                    userAllStakesData[user][_stakeType][i].lastClaimTime = uint128(block.timestamp);
                                }
                                else {
                                    stakeTimeTillNow = userAllStakesData[user][_stakeType][i].fullWithdrawlTime - userAllStakesData[user][_stakeType][i].lastClaimTime;
                                    userAllStakesData[user][_stakeType][i].lastClaimTime = userAllStakesData[user][_stakeType][i].fullWithdrawlTime;
                                }
                                if(stakeTimeTillNow > 0)
                                totalRewardTillNow = rewardCalculation(userAllStakesData[user][_stakeType][i].stakeAmount, _stakeType, stakeTimeTillNow);                
                            }
                            uint128 beforeAmount = uint128(stakedToken.balanceOf(address(this)));
                            if(totalRewardTillNow > 0) claimReward(address(this), totalRewardTillNow);
                            uint128 realAmount = uint128(stakedToken.balanceOf(address(this))) - beforeAmount;
                            userAllStakesData[user][_stakeType][i].stakeAmount += realAmount;
                            totalCompounded += realAmount;
                            stakeType.totalStakedIn +=  realAmount;
                            totalStaked += realAmount;
                            
                        }
                    emit Compound(user, totalCompounded, _stakeType, block.timestamp, stakeType.totalStakedIn);
                    return (totalCompounded, stakeType.stakePeriod, stakeType.totalStakedIn);
                }
                    
            }
            function withdraw(address user, uint128 _amount, uint128 _stakeType) external payable nonReentrant onlyOwner returns(uint128, uint128, uint128) {
                StructLibrary.StakeTypeData storage stakeType = stakeTypesList[_stakeType];
                // require(stakeType.isActive, "POOL_DISABLED");
                require(_amount > 0, "WITHDRAW_MORE_THAN_ZERO");
                require(_stakeType < uint128(stakeTypesList.length), "INVALID_STAKE_TYPE");
                StructLibrary.eachTransaction storage stakes = userStakesData[user][_stakeType];
                
                transferPlatformFee(treasury, user, uint128(msg.value));
                uint128 totalStakes = uint128(userAllStakesData[user][_stakeType].length);
                if(!stakes.accumulated) {
                    require(_amount <= stakes.stakeAmount, "CANT_WITHDRAW_MORE_THAN_STAKED");
                    require(uint128(block.timestamp) > stakes.fullWithdrawlTime, "CANT_UNSTAKE_BEFORE_LOCKUP_TIME");
                    uint128 stakeTimeTillNow;
                    if(stakeType.stakePeriod == 0) {
                        stakeTimeTillNow = uint128(block.timestamp) - stakes.lastClaimTime;
                        stakes.lastClaimTime = uint128(block.timestamp);
                        }
                    else {
                        stakeTimeTillNow = stakes.fullWithdrawlTime - stakes.lastClaimTime;
                        stakes.lastClaimTime = stakes.fullWithdrawlTime;
                        }
                    uint128 rewardTillNow;
                    if(stakeTimeTillNow > 0) rewardTillNow = rewardCalculation(stakes.stakeAmount, _stakeType, stakeTimeTillNow);
                    
                    uint128 actualAmount = _amount;
                    stakes.stakeAmount -= actualAmount;
                    if(stakes.stakeAmount == 0) stakes.accumulated = true;
                    stakeType.totalStakedIn -=  actualAmount;
                    totalStaked -= actualAmount;
                    bool success;
                {
                    uint128 _withdrawlFees = stakeType.withdrawlFees;
                    uint128 fees;
                    if(_withdrawlFees !=0) {
                        fees = _amount * _withdrawlFees *100 / 1000000;
                        actualAmount = _amount - fees;
                    }
                    if(rewardTillNow > 0) claimReward(user, rewardTillNow);
                    
                    if(fees > 0)
                    {
                        success = stakedToken.transfer(treasury, fees);
                        if(!success) revert();
                    }
                }
                    if(actualAmount > 0) {
                        success = stakedToken.transfer(user, actualAmount);
                        if(!success) revert();
                    }
                
                    emit Withdraw(user, actualAmount, _stakeType, rewardTillNow, block.timestamp, stakeType.totalStakedIn);
                    return (actualAmount, stakeType.stakePeriod, stakeType.totalStakedIn);
                } else {
                    require(uint128(block.timestamp) > userAllStakesData[user][_stakeType][0].fullWithdrawlTime, "CANT_UNSTAKE_BEFORE_LOCKUP_TIME");
                    // require(_amount <= userAllStakesData[user][_stakeType][0].stakeAmount, "WITHDRAW_LESS_AMOUNT");
                    uint128 unlockedAmount;
                
                    uint128 rewardTillNow;
                    for(uint128 i=0; i<totalStakes; ++i) {
                        uint128 totalStakeTimeTillNow;
                        {
                        // uint128 calcAmount;
                        if(userAllStakesData[user][_stakeType][i].stakeAmount == 0) continue;
                        // time check for each deposits
                        if(_amount <= userAllStakesData[user][_stakeType][i].stakeAmount) {
                            if(uint128(block.timestamp) < userAllStakesData[user][_stakeType][i].fullWithdrawlTime) break;
                            unlockedAmount += _amount;
                            // calcAmount = _amount;
                            userAllStakesData[user][_stakeType][i].stakeAmount -= _amount;
                            totalStakeTimeTillNow += userAllStakesData[user][_stakeType][i].fullWithdrawlTime - userAllStakesData[user][_stakeType][i].lastClaimTime;
                            if(unlockedAmount > 0 && totalStakeTimeTillNow > 0) rewardTillNow += rewardCalculation(_amount, _stakeType, totalStakeTimeTillNow);
                            // userAllStakesData[user][_stakeType][i].lastClaimTime = userAllStakesData[user][_stakeType][i].fullWithdrawlTime;
                            break;
                        } else {
                            if(uint128(block.timestamp) < userAllStakesData[user][_stakeType][i].fullWithdrawlTime) break;
                            unlockedAmount += userAllStakesData[user][_stakeType][i].stakeAmount;
                            _amount -= userAllStakesData[user][_stakeType][i].stakeAmount;
                            // calcAmount = userAllStakesData[user][_stakeType][i].stakeAmount;
                            totalStakeTimeTillNow += userAllStakesData[user][_stakeType][i].fullWithdrawlTime - userAllStakesData[user][_stakeType][i].lastClaimTime;
                            if(unlockedAmount > 0 && totalStakeTimeTillNow > 0) rewardTillNow += rewardCalculation(userAllStakesData[user][_stakeType][i].stakeAmount, _stakeType, totalStakeTimeTillNow);
                            userAllStakesData[user][_stakeType][i].stakeAmount = 0;
                            
                            // userAllStakesData[user][_stakeType][i].lastClaimTime = userAllStakesData[user][_stakeType][i].fullWithdrawlTime;
                        }   
                        }
                    }
                    // if(unlockedAmount > 0 && totalStakeTimeTillNow > 0) {
                    // rewardTillNow = rewardCalculation(unlockedAmount, _stakeType, totalStakeTimeTillNow);
                    if(rewardTillNow > 0) claimReward(user, rewardTillNow);
                    // }
                
                    stakeType.totalStakedIn -=  unlockedAmount;
                    totalStaked -= unlockedAmount;
                    
                    uint128 actualAmount = unlockedAmount;
                    // bool success;
                
                    uint128 _withdrawlFees = stakeType.withdrawlFees;
                    {
                    uint128 fees;
                    if(_withdrawlFees !=0) {
                        fees = unlockedAmount * _withdrawlFees *100 / 1000000;
                        actualAmount = unlockedAmount - fees;
                    }
                
                    if(fees > 0){
                        stakedToken.transfer(treasury, fees);
                        // if(!success) revert();
                    }
                    }
                    if(actualAmount > 0) {
                        stakedToken.transfer(user, actualAmount);
                        // if(!success) revert();
                    }
                
                    emit Withdraw(user, actualAmount, _stakeType, rewardTillNow, block.timestamp, stakeType.totalStakedIn);
                    return (actualAmount, stakeType.stakePeriod, stakeType.totalStakedIn);
                }
                
            }
            function claim(address user, uint128 _stakeType) external payable nonReentrant onlyOwner returns(uint128, uint128) {
                // require(stakeTypeExist[_stakeType], "STAKE_TYPE_DOES_NOT_EXIST");
                require(_stakeType < uint128(stakeTypesList.length), "INVALID_STAKE_TYPE");
                StructLibrary.StakeTypeData storage stakeType = stakeTypesList[_stakeType];
                // require(stakeType.isActive, "POOL_DISABLED");
                require(stakeType.stakePeriod == 0, "CANT_CLAIM_FOR_THIS_TYPE");
                StructLibrary.eachTransaction storage stakes = userStakesData[user][_stakeType];
                require(uint128(block.timestamp) > stakes.fullWithdrawlTime, "WAIT_TO_CLAIM");
                uint128 totalRewardTillNow;
                uint128 actualAmount = stakes.stakeAmount;
                require(actualAmount > 0, "NOTHING_AT_STAKE");
                transferPlatformFee(treasury, user, uint128(msg.value));
                uint128 stakeTimeTillNow;
            
                stakeTimeTillNow = uint128(block.timestamp) - stakes.lastClaimTime;
                if(stakeTimeTillNow > 0) totalRewardTillNow = rewardCalculation(actualAmount, _stakeType, stakeTimeTillNow); 
                stakes.lastClaimTime = uint128(block.timestamp);
                    
                   
                if(totalRewardTillNow > 0)
                claimReward(user, totalRewardTillNow);
                emit Claim(user, totalRewardTillNow, _stakeType, block.timestamp);
                return (totalRewardTillNow, stakeType.stakePeriod);
            }
            function rewardCalculation(uint128 _amount, uint128 _stakeType, uint128 _time) public view returns(uint128) {
                StructLibrary.StakeTypeData memory stakeType = stakeTypesList[_stakeType];
                require(_amount > 0, "AMOUNT_SHOULD_BE_GREATER_THAN_ZERO");
                require(_stakeType < uint128(stakeTypesList.length), "INVALID_STAKE_TYPE");
                require(_time > 0, "INVALID_TIME");
                uint128 rate = stakeType.rewardRate;
                uint128 interest = (_amount * rate * _time) / (100 * 365 days);
                return interest;
            }
            function claimReward(address to, uint128 _rewardAmount) private {
                require(to != address(0), "INVALID_CLAIMER");
                require(_rewardAmount > 0, "INVALID_REWARD_AMOUNT");
                uint128 ownerBal = uint128(stakedToken.balanceOf(ownerWallet));
                if(_rewardAmount > ownerBal) claimAndWithdrawFreeze = true;
                require(!claimAndWithdrawFreeze, "CLAIM_AND_WITHDRAW_FREEZED");
                bool success = stakedToken.transferFrom(ownerWallet, to, _rewardAmount);
                if(!success) revert();
            }
            // FOR DEPOSIT AND WITHDRAWL FEES
            // 0.01 % -----> input is 1
            // 0.1% ------> input is 10
            // 1% -------> input is 100
            function addStakedType(uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawlFees, uint128 _rewardRate) external onlyOwner returns(uint128){
                // require(!stakeTypeExist[_stakeType], "STAKE_TYPE_EXISTS");
                require(_depositFees < 10000 && _withdrawlFees < 10000, "FEES_CANNOT_BE_EQUAL_OR_MORE_THAN_100");
                require(_rewardRate > 0, "INTEREST_RATE_CANNOT_BE_ZERO");
                // stakeTypeExist[_stakeType] = true;
                uint128 poolType = uint128(stakeTypesList.length);
                stakeTypesList.push(StructLibrary.StakeTypeData(poolType,_stakePeriod,_depositFees,_withdrawlFees,_rewardRate,0, true));
                emit AddStakeType(poolType, _stakePeriod, _depositFees, _withdrawlFees, _rewardRate);
                return poolType;
            }
            // FOR DEPOSIT AND WITHDRAWL FESS
            // 0.01 % -----> input is 1
            // 0.1% ------> input is 10
            // 1% -------> input is 100
            function updateStakeType(uint128 _stakeType, uint128 _stakePeriod, uint128 _depositFees, uint128 _withdrawlFees, uint128 _rewardRate) external onlyOwner {
                // require(stakeTypeExist[_stakeType], "STAKE_TYPE_DOES_NOT_EXIST");
                require(_stakeType < uint128(stakeTypesList.length), "INVALID_STAKE_TYPE");
                require(_depositFees < 10000 && _withdrawlFees < 10000, "FEES_CANNOT_BE_EQUAL_OR_MORE_THAN_100");
                require(_rewardRate > 0, "INTEREST_RATE_CANNOT_BE_ZERO");
                StructLibrary.StakeTypeData storage stakeType = stakeTypesList[_stakeType];
                stakeType.stakeType = _stakeType;
                stakeType.stakePeriod = _stakePeriod;
                stakeType.depositFees = _depositFees;
                stakeType.withdrawlFees = _withdrawlFees;
                stakeType.rewardRate = _rewardRate;
                emit UpdateStakeType(_stakeType, _stakePeriod, _depositFees, _withdrawlFees, _rewardRate);
            }
            function getPoolData(uint128 _stakeType) external view returns(StructLibrary.StakeTypeData memory) {
                // require(stakeTypeExist[_stakeType], "INVALID_STAKE_TYPE");
                require(_stakeType < uint128(stakeTypesList.length), "INVALID_STAKE_TYPE");
                require(stakeTypesList[_stakeType].isActive, "POOL_DISABLED");
                return stakeTypesList[_stakeType];
            }
            function deleteStakeType(uint128 _stakeType) external onlyOwner returns(bool) {
                require(_stakeType < uint128(stakeTypesList.length), "INVALID_STAKE_TYPE");
                // require(stakeTypesList[_stakeType].totalStakedIn == 0, "CANT_DELETE");
                stakeTypesList[_stakeType].isActive = false;
                emit DeleteStakeType(_stakeType);
                return false;
            }    
            function getPoolLength() external view returns(uint128) {
                return uint128(stakeTypesList.length);
            }
            function emergencyWithdraw(address user, uint128 _stakeType) external payable onlyOwner returns(uint128, uint128, uint128){
                require(_stakeType < uint128(stakeTypesList.length), "INVALID_STAKE_TYPE");
                StructLibrary.StakeTypeData storage stakeType = stakeTypesList[_stakeType];
                StructLibrary.eachTransaction storage stakes = userStakesData[user][_stakeType];
                transferPlatformFee(treasury, user, uint128(msg.value));
                uint128 fees;
                bool success;
                if(!stakes.accumulated) {
                uint128 amount = stakes.stakeAmount;
                require( amount > 0, "NOTHING_TO_WITHDRAW");
                stakes.stakeAmount = 0;
                stakes.lastClaimTime = uint128(block.timestamp);
                stakes.accumulated = true;
                stakeType.totalStakedIn -=  amount;
                totalStaked -= amount;
                fees = (amount * emergencyFees) / 100 ;
                if(fees > 0 ) {
                    success = stakedToken.transfer(treasury, fees);
                    if(!success) revert();
                    amount -= fees;
                }
                success = stakedToken.transfer(user, amount);
                if(!success) revert();
                emit EmergencyWithdrawn(user, amount, _stakeType, block.timestamp, stakeType.totalStakedIn);
                return (amount, stakeType.stakePeriod, stakeType.totalStakedIn);
                } else {
                    uint128 totalStakes = uint128(userAllStakesData[user][_stakeType].length);
                    uint128 _amount;
                    for(uint128 i =0; i<totalStakes; ++i) {
                        if(userAllStakesData[user][_stakeType][i].stakeAmount == 0) continue;
                       _amount += userAllStakesData[user][_stakeType][i].stakeAmount;
                       userAllStakesData[user][_stakeType][i].stakeAmount = 0;
                       userAllStakesData[user][_stakeType][i].lastClaimTime = uint128(block.timestamp);
                    }
                    stakeType.totalStakedIn -=  _amount;
                    totalStaked -= _amount;
                    fees = (_amount * emergencyFees) / 100 ;
                    if(fees > 0 ) {
                        success = stakedToken.transfer(treasury, fees);
                        if(!success) revert();
                        _amount -= fees;
                    }
                    if(_amount > 0) {
                    success = stakedToken.transfer(user, _amount);
                    if(!success) revert();
                    }
                    emit EmergencyWithdrawn(user, _amount, _stakeType, block.timestamp, stakeType.totalStakedIn);
                    return (_amount, stakeType.stakePeriod, stakeType.totalStakedIn);
                }
            }
            function updateEmergencyFees(uint128 newFees) external onlyOwner {
                require(newFees > 0, "EMERGENCY_FEES_CANT_BE_ZERO");
                require(newFees != emergencyFees, "CANT_SET SAME_FEES");
                uint128 oldFee = emergencyFees;
                emergencyFees = newFees;
                
                emit UpdateEmergencyFee(address(stakedToken), oldFee, newFees);
            }
            function transferPlatformFee(address to, address _user,  uint128 _value) private {
                require(to != address(0), "CANT_SEND_TO_NULL_ADDRESS");
                require(_value >= platformFee, "INCREASE_PLATFORM_FEE");
                (bool success, ) = payable(to).call{value:platformFee}("");
                require(success, "PLATFORM_FEE_TRANSFER_FAILED");
                uint128 remainingEth = _value - platformFee;
                if (remainingEth > 0) {
                    (success,) = payable(_user).call{value: remainingEth}("");
                    require(success, "REFUND_REMAINING_ETHER_SENT_FAILED");
                }
            }
            function updatePlatformFee(uint128 newFee) external onlyOwner {
                require(newFee > 0, "PLATFORM_FEE_CANT_BE_NULL");
                require(newFee != platformFee, "PLATFORM_FEE_CANT_BE_SAME");
                uint128 oldFee = platformFee;
                platformFee = newFee;
                emit UpdatePlatformFee(address(stakedToken), oldFee, newFee);
            }
            function updateOwnerWallet(address newOwnerWallet) external onlyOwner {
                require(newOwnerWallet != address(0), "OWNER_CANT_BE_ZERO_ADDRESS");
                require(newOwnerWallet != ownerWallet, "ALREADY_SET_THIS OWNER");
                address oldOwnerWallet = ownerWallet;
                ownerWallet = newOwnerWallet;
                emit UpdateOwnerWallet(address(stakedToken), oldOwnerWallet, newOwnerWallet);
            }
            function updateTreasuryWallet(address newTreasuryWallet) external onlyOwner {
                require(newTreasuryWallet != address(0), "TREASURY_WALLET_CANT_BE_NULL");
                require(newTreasuryWallet != treasury, "ALREADY_SET_THS_WALLET");
                address oldTreasuryWallet = ownerWallet;
                treasury = newTreasuryWallet;
                emit UpdateTreasuryWallet(address(stakedToken), oldTreasuryWallet, newTreasuryWallet);
            }
            function updateStakeLimit(uint128 _newLimit) external onlyOwner {
                require(maxStakeLimit != _newLimit);
                maxStakeLimit = _newLimit;
            }
            function userUnlockAmount(address user, uint128 _stakeType) external view returns(uint128 unlockAmount, uint128 lockAmount) {
                uint128 totalStakes = uint128(userAllStakesData[user][_stakeType].length);
            
                for(uint128 i=0; i < totalStakes; ++i) {
                    if(userAllStakesData[user][_stakeType][i].stakeAmount == 0) continue;
                    if(uint128(block.timestamp) > userAllStakesData[user][_stakeType][i].fullWithdrawlTime) unlockAmount += userAllStakesData[user][_stakeType][i].stakeAmount;
                    else lockAmount += userAllStakesData[user][_stakeType][i].stakeAmount;
                    
                }
            }
            function userTotalTxPerPool(address user, uint128 _stakeType) external view returns(StructLibrary.eachTransaction[] memory userAllStakes, uint128 len) {
                len = uint128(userAllStakesData[user][_stakeType].length);
                userAllStakes = new StructLibrary.eachTransaction[](uint128(userAllStakesData[user][_stakeType].length));
                for(uint128 i=0; i < uint128(userAllStakesData[user][_stakeType].length); i++) {
                    userAllStakes[i] = userAllStakesData[user][_stakeType][i];
                }
                return (userAllStakes, len);
            }
            function enableStakeType(uint128 _stakeType) external returns(bool) {
                require(msg.sender == ownerWallet, "INVALID_CALLER");
                require(_stakeType < uint128(stakeTypesList.length), "INVALID_STAKE_TYPE");
                // require(!stakeTypesList[_stakeType].isActive, "ALREADY_ENABLED");
                // require(stakeTypesList[_stakeType].totalStakedIn == 0, "CANT_DELETE");
                stakeTypesList[_stakeType].isActive = true;
                // emit EnabledStakeType(_stakeType);
                return true;
            }    
        }