ETH Price: $2,394.70 (-5.04%)

Transaction Decoder

Block:
18007507 at Aug-27-2023 05:32:35 PM +UTC
Transaction Fee:
0.00287175167265852 ETH $6.88
Gas Used:
186,930 Gas / 15.362711564 Gwei

Emitted Events:

276 TransparentUpgradeableProxy.0xb9e788fc28e69f876035840c2b162474437d35622a8cfa689a88c04403bf7ee6( 0xb9e788fc28e69f876035840c2b162474437d35622a8cfa689a88c04403bf7ee6, 0x000000000000000000000000ccad56f464b8154e82cdcd4ca6414f2320358246, 0000000000000000000000000000000000000000000000000000000000000020, 0000000000000000000000000000000000000000000000000000000000000000 )
277 TetherToken.Transfer( from=[Sender] 0xccad56f464b8154e82cdcd4ca6414f2320358246, to=0xb5C8BC1Dc5e3cfcaf14D2d4c29Aa39eCce0c3642, value=90000000 )
278 TransparentUpgradeableProxy.0x4d8aead3491b7eba4b5c7a65fc17e493b9e63f9e433522fc5f6a85a168fc9d36( 0x4d8aead3491b7eba4b5c7a65fc17e493b9e63f9e433522fc5f6a85a168fc9d36, 0x000000000000000000000000ccad56f464b8154e82cdcd4ca6414f2320358246, 0x0000000000000000000000000000000000000000000000000000000000001d4c, 0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7, 00000000000000000000000000000000000000000000000000000000055d4a80, 000000000000000000000000000000000000000000000004e1003b28d9280000, 0000000000000000000000000000000000000000000000000000000064eb88b3 )

Account State Difference:

  Address   Before After State Difference Code
(beaverbuild)
16.309528654483060935 Eth16.309550331793593015 Eth0.00002167731053208
0xaD1bb321...98746548F
0xCcad56F4...320358246
0.017325699289710069 Eth
Nonce: 1
0.014453947617051549 Eth
Nonce: 2
0.00287175167265852
0xdAC17F95...13D831ec7

Execution Trace

TransparentUpgradeableProxy.625ae3da( )
  • PresaleEthV1.buyWithUSDT( amount=7500, promoCode=, referralCode= ) => ( True )
    • TetherToken.allowance( _owner=0xCcad56F464B8154e82CdCD4CA6414F2320358246, _spender=0xaD1bb32110B74bc5d7f32A0261aC0Ca98746548F ) => ( remaining=90000000 )
    • TetherToken.transferFrom( _from=0xCcad56F464B8154e82CdCD4CA6414F2320358246, _to=0xb5C8BC1Dc5e3cfcaf14D2d4c29Aa39eCce0c3642, _value=90000000 )
      File 1 of 3: TransparentUpgradeableProxy
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
      pragma solidity ^0.8.0;
      import "../utils/Context.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 Ownable is Context {
          address private _owner;
          event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
          /**
           * @dev Initializes the contract setting the deployer as the initial owner.
           */
          constructor() {
              _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);
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
      pragma solidity ^0.8.0;
      /**
       * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
       * proxy whose upgrades are fully controlled by the current implementation.
       */
      interface IERC1822Proxiable {
          /**
           * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
           * address.
           *
           * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
           * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
           * function revert if invoked through a proxy.
           */
          function proxiableUUID() external view returns (bytes32);
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.8.3) (interfaces/IERC1967.sol)
      pragma solidity ^0.8.0;
      /**
       * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
       *
       * _Available since v4.9._
       */
      interface IERC1967 {
          /**
           * @dev Emitted when the implementation is upgraded.
           */
          event Upgraded(address indexed implementation);
          /**
           * @dev Emitted when the admin account has changed.
           */
          event AdminChanged(address previousAdmin, address newAdmin);
          /**
           * @dev Emitted when the beacon is changed.
           */
          event BeaconUpgraded(address indexed beacon);
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.7.0) (proxy/beacon/BeaconProxy.sol)
      pragma solidity ^0.8.0;
      import "./IBeacon.sol";
      import "../Proxy.sol";
      import "../ERC1967/ERC1967Upgrade.sol";
      /**
       * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.
       *
       * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't
       * conflict with the storage layout of the implementation behind the proxy.
       *
       * _Available since v3.4._
       */
      contract BeaconProxy is Proxy, ERC1967Upgrade {
          /**
           * @dev Initializes the proxy with `beacon`.
           *
           * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
           * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
           * constructor.
           *
           * Requirements:
           *
           * - `beacon` must be a contract with the interface {IBeacon}.
           */
          constructor(address beacon, bytes memory data) payable {
              _upgradeBeaconToAndCall(beacon, data, false);
          }
          /**
           * @dev Returns the current beacon address.
           */
          function _beacon() internal view virtual returns (address) {
              return _getBeacon();
          }
          /**
           * @dev Returns the current implementation address of the associated beacon.
           */
          function _implementation() internal view virtual override returns (address) {
              return IBeacon(_getBeacon()).implementation();
          }
          /**
           * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.
           *
           * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.
           *
           * Requirements:
           *
           * - `beacon` must be a contract.
           * - The implementation returned by `beacon` must be a contract.
           */
          function _setBeacon(address beacon, bytes memory data) internal virtual {
              _upgradeBeaconToAndCall(beacon, data, false);
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
      pragma solidity ^0.8.0;
      /**
       * @dev This is the interface that {BeaconProxy} expects of its beacon.
       */
      interface IBeacon {
          /**
           * @dev Must return an address that can be used as a delegate call target.
           *
           * {BeaconProxy} will check that this address is a contract.
           */
          function implementation() external view returns (address);
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)
      pragma solidity ^0.8.0;
      import "./IBeacon.sol";
      import "../../access/Ownable.sol";
      import "../../utils/Address.sol";
      /**
       * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their
       * implementation contract, which is where they will delegate all function calls.
       *
       * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.
       */
      contract UpgradeableBeacon is IBeacon, Ownable {
          address private _implementation;
          /**
           * @dev Emitted when the implementation returned by the beacon is changed.
           */
          event Upgraded(address indexed implementation);
          /**
           * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the
           * beacon.
           */
          constructor(address implementation_) {
              _setImplementation(implementation_);
          }
          /**
           * @dev Returns the current implementation address.
           */
          function implementation() public view virtual override returns (address) {
              return _implementation;
          }
          /**
           * @dev Upgrades the beacon to a new implementation.
           *
           * Emits an {Upgraded} event.
           *
           * Requirements:
           *
           * - msg.sender must be the owner of the contract.
           * - `newImplementation` must be a contract.
           */
          function upgradeTo(address newImplementation) public virtual onlyOwner {
              _setImplementation(newImplementation);
              emit Upgraded(newImplementation);
          }
          /**
           * @dev Sets the implementation contract address for this beacon
           *
           * Requirements:
           *
           * - `newImplementation` must be a contract.
           */
          function _setImplementation(address newImplementation) private {
              require(Address.isContract(newImplementation), "UpgradeableBeacon: implementation is not a contract");
              _implementation = newImplementation;
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)
      pragma solidity ^0.8.0;
      import "../Proxy.sol";
      import "./ERC1967Upgrade.sol";
      /**
       * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
       * implementation address that can be changed. This address is stored in storage in the location specified by
       * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
       * implementation behind the proxy.
       */
      contract ERC1967Proxy is Proxy, ERC1967Upgrade {
          /**
           * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
           *
           * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
           * function call, and allows initializing the storage of the proxy like a Solidity constructor.
           */
          constructor(address _logic, bytes memory _data) payable {
              _upgradeToAndCall(_logic, _data, false);
          }
          /**
           * @dev Returns the current implementation address.
           */
          function _implementation() internal view virtual override returns (address impl) {
              return ERC1967Upgrade._getImplementation();
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.8.3) (proxy/ERC1967/ERC1967Upgrade.sol)
      pragma solidity ^0.8.2;
      import "../beacon/IBeacon.sol";
      import "../../interfaces/IERC1967.sol";
      import "../../interfaces/draft-IERC1822.sol";
      import "../../utils/Address.sol";
      import "../../utils/StorageSlot.sol";
      /**
       * @dev This abstract contract provides getters and event emitting update functions for
       * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
       *
       * _Available since v4.1._
       *
       * @custom:oz-upgrades-unsafe-allow delegatecall
       */
      abstract contract ERC1967Upgrade is IERC1967 {
          // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
          bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
          /**
           * @dev Storage slot with the address of the current implementation.
           * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
           * validated in the constructor.
           */
          bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
          /**
           * @dev Returns the current implementation address.
           */
          function _getImplementation() internal view returns (address) {
              return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
          }
          /**
           * @dev Stores a new address in the EIP1967 implementation slot.
           */
          function _setImplementation(address newImplementation) private {
              require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
              StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
          }
          /**
           * @dev Perform implementation upgrade
           *
           * Emits an {Upgraded} event.
           */
          function _upgradeTo(address newImplementation) internal {
              _setImplementation(newImplementation);
              emit Upgraded(newImplementation);
          }
          /**
           * @dev Perform implementation upgrade with additional setup call.
           *
           * Emits an {Upgraded} event.
           */
          function _upgradeToAndCall(
              address newImplementation,
              bytes memory data,
              bool forceCall
          ) internal {
              _upgradeTo(newImplementation);
              if (data.length > 0 || forceCall) {
                  Address.functionDelegateCall(newImplementation, data);
              }
          }
          /**
           * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
           *
           * Emits an {Upgraded} event.
           */
          function _upgradeToAndCallUUPS(
              address newImplementation,
              bytes memory data,
              bool forceCall
          ) internal {
              // Upgrades from old implementations will perform a rollback test. This test requires the new
              // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
              // this special case will break upgrade paths from old UUPS implementation to new ones.
              if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
                  _setImplementation(newImplementation);
              } else {
                  try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                      require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
                  } catch {
                      revert("ERC1967Upgrade: new implementation is not UUPS");
                  }
                  _upgradeToAndCall(newImplementation, data, forceCall);
              }
          }
          /**
           * @dev Storage slot with the admin of the contract.
           * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
           * validated in the constructor.
           */
          bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
          /**
           * @dev Returns the current admin.
           */
          function _getAdmin() internal view returns (address) {
              return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
          }
          /**
           * @dev Stores a new address in the EIP1967 admin slot.
           */
          function _setAdmin(address newAdmin) private {
              require(newAdmin != address(0), "ERC1967: new admin is the zero address");
              StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
          }
          /**
           * @dev Changes the admin of the proxy.
           *
           * Emits an {AdminChanged} event.
           */
          function _changeAdmin(address newAdmin) internal {
              emit AdminChanged(_getAdmin(), newAdmin);
              _setAdmin(newAdmin);
          }
          /**
           * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
           * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
           */
          bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
          /**
           * @dev Returns the current beacon.
           */
          function _getBeacon() internal view returns (address) {
              return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
          }
          /**
           * @dev Stores a new beacon in the EIP1967 beacon slot.
           */
          function _setBeacon(address newBeacon) private {
              require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
              require(
                  Address.isContract(IBeacon(newBeacon).implementation()),
                  "ERC1967: beacon implementation is not a contract"
              );
              StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
          }
          /**
           * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
           * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
           *
           * Emits a {BeaconUpgraded} event.
           */
          function _upgradeBeaconToAndCall(
              address newBeacon,
              bytes memory data,
              bool forceCall
          ) internal {
              _setBeacon(newBeacon);
              emit BeaconUpgraded(newBeacon);
              if (data.length > 0 || forceCall) {
                  Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
              }
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
      pragma solidity ^0.8.0;
      /**
       * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
       * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
       * be specified by overriding the virtual {_implementation} function.
       *
       * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
       * different contract through the {_delegate} function.
       *
       * The success and return data of the delegated call will be returned back to the caller of the proxy.
       */
      abstract contract Proxy {
          /**
           * @dev Delegates the current call to `implementation`.
           *
           * This function does not return to its internal call site, it will return directly to the external caller.
           */
          function _delegate(address implementation) internal virtual {
              assembly {
                  // Copy msg.data. We take full control of memory in this inline assembly
                  // block because it will not return to Solidity code. We overwrite the
                  // Solidity scratch pad at memory position 0.
                  calldatacopy(0, 0, calldatasize())
                  // Call the implementation.
                  // out and outsize are 0 because we don't know the size yet.
                  let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                  // Copy the returned data.
                  returndatacopy(0, 0, returndatasize())
                  switch result
                  // delegatecall returns 0 on error.
                  case 0 {
                      revert(0, returndatasize())
                  }
                  default {
                      return(0, returndatasize())
                  }
              }
          }
          /**
           * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
           * and {_fallback} should delegate.
           */
          function _implementation() internal view virtual returns (address);
          /**
           * @dev Delegates the current call to the address returned by `_implementation()`.
           *
           * This function does not return to its internal call site, it will return directly to the external caller.
           */
          function _fallback() internal virtual {
              _beforeFallback();
              _delegate(_implementation());
          }
          /**
           * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
           * function in the contract matches the call data.
           */
          fallback() external payable virtual {
              _fallback();
          }
          /**
           * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
           * is empty.
           */
          receive() external payable virtual {
              _fallback();
          }
          /**
           * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
           * call, or as part of the Solidity `fallback` or `receive` functions.
           *
           * If overridden should call `super._beforeFallback()`.
           */
          function _beforeFallback() internal virtual {}
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.8.3) (proxy/transparent/ProxyAdmin.sol)
      pragma solidity ^0.8.0;
      import "./TransparentUpgradeableProxy.sol";
      import "../../access/Ownable.sol";
      /**
       * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
       * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
       */
      contract ProxyAdmin is Ownable {
          /**
           * @dev Returns the current implementation of `proxy`.
           *
           * Requirements:
           *
           * - This contract must be the admin of `proxy`.
           */
          function getProxyImplementation(ITransparentUpgradeableProxy proxy) public view virtual returns (address) {
              // We need to manually run the static call since the getter cannot be flagged as view
              // bytes4(keccak256("implementation()")) == 0x5c60da1b
              (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
              require(success);
              return abi.decode(returndata, (address));
          }
          /**
           * @dev Returns the current admin of `proxy`.
           *
           * Requirements:
           *
           * - This contract must be the admin of `proxy`.
           */
          function getProxyAdmin(ITransparentUpgradeableProxy proxy) public view virtual returns (address) {
              // We need to manually run the static call since the getter cannot be flagged as view
              // bytes4(keccak256("admin()")) == 0xf851a440
              (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
              require(success);
              return abi.decode(returndata, (address));
          }
          /**
           * @dev Changes the admin of `proxy` to `newAdmin`.
           *
           * Requirements:
           *
           * - This contract must be the current admin of `proxy`.
           */
          function changeProxyAdmin(ITransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
              proxy.changeAdmin(newAdmin);
          }
          /**
           * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
           *
           * Requirements:
           *
           * - This contract must be the admin of `proxy`.
           */
          function upgrade(ITransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
              proxy.upgradeTo(implementation);
          }
          /**
           * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
           * {TransparentUpgradeableProxy-upgradeToAndCall}.
           *
           * Requirements:
           *
           * - This contract must be the admin of `proxy`.
           */
          function upgradeAndCall(
              ITransparentUpgradeableProxy proxy,
              address implementation,
              bytes memory data
          ) public payable virtual onlyOwner {
              proxy.upgradeToAndCall{value: msg.value}(implementation, data);
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.8.3) (proxy/transparent/TransparentUpgradeableProxy.sol)
      pragma solidity ^0.8.0;
      import "../ERC1967/ERC1967Proxy.sol";
      /**
       * @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}
       * does not implement this interface directly, and some of its functions are implemented by an internal dispatch
       * mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not
       * include them in the ABI so this interface must be used to interact with it.
       */
      interface ITransparentUpgradeableProxy is IERC1967 {
          function admin() external view returns (address);
          function implementation() external view returns (address);
          function changeAdmin(address) external;
          function upgradeTo(address) external;
          function upgradeToAndCall(address, bytes memory) external payable;
      }
      /**
       * @dev This contract implements a proxy that is upgradeable by an admin.
       *
       * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
       * clashing], which can potentially be used in an attack, this contract uses the
       * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
       * things that go hand in hand:
       *
       * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
       * that call matches one of the admin functions exposed by the proxy itself.
       * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
       * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
       * "admin cannot fallback to proxy target".
       *
       * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
       * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
       * to sudden errors when trying to call a function from the proxy implementation.
       *
       * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
       * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
       *
       * NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not
       * inherit from that interface, and instead the admin functions are implicitly implemented using a custom dispatch
       * mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to
       * fully implement transparency without decoding reverts caused by selector clashes between the proxy and the
       * implementation.
       *
       * WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler
       * will not check that there are no selector conflicts, due to the note above. A selector clash between any new function
       * and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could
       * render the admin operations inaccessible, which could prevent upgradeability. Transparency may also be compromised.
       */
      contract TransparentUpgradeableProxy is ERC1967Proxy {
          /**
           * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
           * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
           */
          constructor(
              address _logic,
              address admin_,
              bytes memory _data
          ) payable ERC1967Proxy(_logic, _data) {
              _changeAdmin(admin_);
          }
          /**
           * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
           *
           * CAUTION: This modifier is deprecated, as it could cause issues if the modified function has arguments, and the
           * implementation provides a function with the same selector.
           */
          modifier ifAdmin() {
              if (msg.sender == _getAdmin()) {
                  _;
              } else {
                  _fallback();
              }
          }
          /**
           * @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior
           */
          function _fallback() internal virtual override {
              if (msg.sender == _getAdmin()) {
                  bytes memory ret;
                  bytes4 selector = msg.sig;
                  if (selector == ITransparentUpgradeableProxy.upgradeTo.selector) {
                      ret = _dispatchUpgradeTo();
                  } else if (selector == ITransparentUpgradeableProxy.upgradeToAndCall.selector) {
                      ret = _dispatchUpgradeToAndCall();
                  } else if (selector == ITransparentUpgradeableProxy.changeAdmin.selector) {
                      ret = _dispatchChangeAdmin();
                  } else if (selector == ITransparentUpgradeableProxy.admin.selector) {
                      ret = _dispatchAdmin();
                  } else if (selector == ITransparentUpgradeableProxy.implementation.selector) {
                      ret = _dispatchImplementation();
                  } else {
                      revert("TransparentUpgradeableProxy: admin cannot fallback to proxy target");
                  }
                  assembly {
                      return(add(ret, 0x20), mload(ret))
                  }
              } else {
                  super._fallback();
              }
          }
          /**
           * @dev Returns the current admin.
           *
           * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
           * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
           * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
           */
          function _dispatchAdmin() private returns (bytes memory) {
              _requireZeroValue();
              address admin = _getAdmin();
              return abi.encode(admin);
          }
          /**
           * @dev Returns the current implementation.
           *
           * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
           * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
           * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
           */
          function _dispatchImplementation() private returns (bytes memory) {
              _requireZeroValue();
              address implementation = _implementation();
              return abi.encode(implementation);
          }
          /**
           * @dev Changes the admin of the proxy.
           *
           * Emits an {AdminChanged} event.
           */
          function _dispatchChangeAdmin() private returns (bytes memory) {
              _requireZeroValue();
              address newAdmin = abi.decode(msg.data[4:], (address));
              _changeAdmin(newAdmin);
              return "";
          }
          /**
           * @dev Upgrade the implementation of the proxy.
           */
          function _dispatchUpgradeTo() private returns (bytes memory) {
              _requireZeroValue();
              address newImplementation = abi.decode(msg.data[4:], (address));
              _upgradeToAndCall(newImplementation, bytes(""), false);
              return "";
          }
          /**
           * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
           * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
           * proxied contract.
           */
          function _dispatchUpgradeToAndCall() private returns (bytes memory) {
              (address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));
              _upgradeToAndCall(newImplementation, data, true);
              return "";
          }
          /**
           * @dev Returns the current admin.
           */
          function _admin() internal view virtual returns (address) {
              return _getAdmin();
          }
          /**
           * @dev To keep this contract fully transparent, all `ifAdmin` functions must be payable. This helper is here to
           * emulate some proxy functions being non-payable while still allowing value to pass through.
           */
          function _requireZeroValue() private {
              require(msg.value == 0);
          }
      }
      // 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 Address {
          /**
           * @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 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;
      /**
       * @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 Context {
          function _msgSender() internal view virtual returns (address) {
              return msg.sender;
          }
          function _msgData() internal view virtual returns (bytes calldata) {
              return msg.data;
          }
      }
      // SPDX-License-Identifier: MIT
      // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)
      pragma solidity ^0.8.0;
      /**
       * @dev Library for reading and writing primitive types to specific storage slots.
       *
       * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
       * This library helps with reading and writing to such slots without the need for inline assembly.
       *
       * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
       *
       * Example usage to set ERC1967 implementation slot:
       * ```
       * contract ERC1967 {
       *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
       *
       *     function _getImplementation() internal view returns (address) {
       *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
       *     }
       *
       *     function _setImplementation(address newImplementation) internal {
       *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
       *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
       *     }
       * }
       * ```
       *
       * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
       */
      library StorageSlot {
          struct AddressSlot {
              address value;
          }
          struct BooleanSlot {
              bool value;
          }
          struct Bytes32Slot {
              bytes32 value;
          }
          struct Uint256Slot {
              uint256 value;
          }
          /**
           * @dev Returns an `AddressSlot` with member `value` located at `slot`.
           */
          function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
              /// @solidity memory-safe-assembly
              assembly {
                  r.slot := slot
              }
          }
          /**
           * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
           */
          function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
              /// @solidity memory-safe-assembly
              assembly {
                  r.slot := slot
              }
          }
          /**
           * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
           */
          function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
              /// @solidity memory-safe-assembly
              assembly {
                  r.slot := slot
              }
          }
          /**
           * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
           */
          function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
              /// @solidity memory-safe-assembly
              assembly {
                  r.slot := slot
              }
          }
      }
      

      File 2 of 3: TetherToken
      pragma solidity ^0.4.17;
      
      /**
       * @title SafeMath
       * @dev Math operations with safety checks that throw on error
       */
      library SafeMath {
          function mul(uint256 a, uint256 b) internal pure returns (uint256) {
              if (a == 0) {
                  return 0;
              }
              uint256 c = a * b;
              assert(c / a == b);
              return c;
          }
      
          function div(uint256 a, uint256 b) internal pure returns (uint256) {
              // assert(b > 0); // Solidity automatically throws when dividing by 0
              uint256 c = a / b;
              // assert(a == b * c + a % b); // There is no case in which this doesn't hold
              return c;
          }
      
          function sub(uint256 a, uint256 b) internal pure returns (uint256) {
              assert(b <= a);
              return a - b;
          }
      
          function add(uint256 a, uint256 b) internal pure returns (uint256) {
              uint256 c = a + b;
              assert(c >= a);
              return c;
          }
      }
      
      /**
       * @title Ownable
       * @dev The Ownable contract has an owner address, and provides basic authorization control
       * functions, this simplifies the implementation of "user permissions".
       */
      contract Ownable {
          address public owner;
      
          /**
            * @dev The Ownable constructor sets the original `owner` of the contract to the sender
            * account.
            */
          function Ownable() public {
              owner = msg.sender;
          }
      
          /**
            * @dev Throws if called by any account other than the owner.
            */
          modifier onlyOwner() {
              require(msg.sender == owner);
              _;
          }
      
          /**
          * @dev Allows the current owner to transfer control of the contract to a newOwner.
          * @param newOwner The address to transfer ownership to.
          */
          function transferOwnership(address newOwner) public onlyOwner {
              if (newOwner != address(0)) {
                  owner = newOwner;
              }
          }
      
      }
      
      /**
       * @title ERC20Basic
       * @dev Simpler version of ERC20 interface
       * @dev see https://github.com/ethereum/EIPs/issues/20
       */
      contract ERC20Basic {
          uint public _totalSupply;
          function totalSupply() public constant returns (uint);
          function balanceOf(address who) public constant returns (uint);
          function transfer(address to, uint value) public;
          event Transfer(address indexed from, address indexed to, uint value);
      }
      
      /**
       * @title ERC20 interface
       * @dev see https://github.com/ethereum/EIPs/issues/20
       */
      contract ERC20 is ERC20Basic {
          function allowance(address owner, address spender) public constant returns (uint);
          function transferFrom(address from, address to, uint value) public;
          function approve(address spender, uint value) public;
          event Approval(address indexed owner, address indexed spender, uint value);
      }
      
      /**
       * @title Basic token
       * @dev Basic version of StandardToken, with no allowances.
       */
      contract BasicToken is Ownable, ERC20Basic {
          using SafeMath for uint;
      
          mapping(address => uint) public balances;
      
          // additional variables for use if transaction fees ever became necessary
          uint public basisPointsRate = 0;
          uint public maximumFee = 0;
      
          /**
          * @dev Fix for the ERC20 short address attack.
          */
          modifier onlyPayloadSize(uint size) {
              require(!(msg.data.length < size + 4));
              _;
          }
      
          /**
          * @dev transfer token for a specified address
          * @param _to The address to transfer to.
          * @param _value The amount to be transferred.
          */
          function transfer(address _to, uint _value) public onlyPayloadSize(2 * 32) {
              uint fee = (_value.mul(basisPointsRate)).div(10000);
              if (fee > maximumFee) {
                  fee = maximumFee;
              }
              uint sendAmount = _value.sub(fee);
              balances[msg.sender] = balances[msg.sender].sub(_value);
              balances[_to] = balances[_to].add(sendAmount);
              if (fee > 0) {
                  balances[owner] = balances[owner].add(fee);
                  Transfer(msg.sender, owner, fee);
              }
              Transfer(msg.sender, _to, sendAmount);
          }
      
          /**
          * @dev Gets the balance of the specified address.
          * @param _owner The address to query the the balance of.
          * @return An uint representing the amount owned by the passed address.
          */
          function balanceOf(address _owner) public constant returns (uint balance) {
              return balances[_owner];
          }
      
      }
      
      /**
       * @title Standard ERC20 token
       *
       * @dev Implementation of the basic standard token.
       * @dev https://github.com/ethereum/EIPs/issues/20
       * @dev Based oncode by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
       */
      contract StandardToken is BasicToken, ERC20 {
      
          mapping (address => mapping (address => uint)) public allowed;
      
          uint public constant MAX_UINT = 2**256 - 1;
      
          /**
          * @dev Transfer tokens from one address to another
          * @param _from address The address which you want to send tokens from
          * @param _to address The address which you want to transfer to
          * @param _value uint the amount of tokens to be transferred
          */
          function transferFrom(address _from, address _to, uint _value) public onlyPayloadSize(3 * 32) {
              var _allowance = allowed[_from][msg.sender];
      
              // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
              // if (_value > _allowance) throw;
      
              uint fee = (_value.mul(basisPointsRate)).div(10000);
              if (fee > maximumFee) {
                  fee = maximumFee;
              }
              if (_allowance < MAX_UINT) {
                  allowed[_from][msg.sender] = _allowance.sub(_value);
              }
              uint sendAmount = _value.sub(fee);
              balances[_from] = balances[_from].sub(_value);
              balances[_to] = balances[_to].add(sendAmount);
              if (fee > 0) {
                  balances[owner] = balances[owner].add(fee);
                  Transfer(_from, owner, fee);
              }
              Transfer(_from, _to, sendAmount);
          }
      
          /**
          * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
          * @param _spender The address which will spend the funds.
          * @param _value The amount of tokens to be spent.
          */
          function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) {
      
              // To change the approve amount you first have to reduce the addresses`
              //  allowance to zero by calling `approve(_spender, 0)` if it is not
              //  already 0 to mitigate the race condition described here:
              //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
              require(!((_value != 0) && (allowed[msg.sender][_spender] != 0)));
      
              allowed[msg.sender][_spender] = _value;
              Approval(msg.sender, _spender, _value);
          }
      
          /**
          * @dev Function to check the amount of tokens than an owner allowed to a spender.
          * @param _owner address The address which owns the funds.
          * @param _spender address The address which will spend the funds.
          * @return A uint specifying the amount of tokens still available for the spender.
          */
          function allowance(address _owner, address _spender) public constant returns (uint remaining) {
              return allowed[_owner][_spender];
          }
      
      }
      
      
      /**
       * @title Pausable
       * @dev Base contract which allows children to implement an emergency stop mechanism.
       */
      contract Pausable is Ownable {
        event Pause();
        event Unpause();
      
        bool public paused = false;
      
      
        /**
         * @dev Modifier to make a function callable only when the contract is not paused.
         */
        modifier whenNotPaused() {
          require(!paused);
          _;
        }
      
        /**
         * @dev Modifier to make a function callable only when the contract is paused.
         */
        modifier whenPaused() {
          require(paused);
          _;
        }
      
        /**
         * @dev called by the owner to pause, triggers stopped state
         */
        function pause() onlyOwner whenNotPaused public {
          paused = true;
          Pause();
        }
      
        /**
         * @dev called by the owner to unpause, returns to normal state
         */
        function unpause() onlyOwner whenPaused public {
          paused = false;
          Unpause();
        }
      }
      
      contract BlackList is Ownable, BasicToken {
      
          /////// Getters to allow the same blacklist to be used also by other contracts (including upgraded Tether) ///////
          function getBlackListStatus(address _maker) external constant returns (bool) {
              return isBlackListed[_maker];
          }
      
          function getOwner() external constant returns (address) {
              return owner;
          }
      
          mapping (address => bool) public isBlackListed;
          
          function addBlackList (address _evilUser) public onlyOwner {
              isBlackListed[_evilUser] = true;
              AddedBlackList(_evilUser);
          }
      
          function removeBlackList (address _clearedUser) public onlyOwner {
              isBlackListed[_clearedUser] = false;
              RemovedBlackList(_clearedUser);
          }
      
          function destroyBlackFunds (address _blackListedUser) public onlyOwner {
              require(isBlackListed[_blackListedUser]);
              uint dirtyFunds = balanceOf(_blackListedUser);
              balances[_blackListedUser] = 0;
              _totalSupply -= dirtyFunds;
              DestroyedBlackFunds(_blackListedUser, dirtyFunds);
          }
      
          event DestroyedBlackFunds(address _blackListedUser, uint _balance);
      
          event AddedBlackList(address _user);
      
          event RemovedBlackList(address _user);
      
      }
      
      contract UpgradedStandardToken is StandardToken{
          // those methods are called by the legacy contract
          // and they must ensure msg.sender to be the contract address
          function transferByLegacy(address from, address to, uint value) public;
          function transferFromByLegacy(address sender, address from, address spender, uint value) public;
          function approveByLegacy(address from, address spender, uint value) public;
      }
      
      contract TetherToken is Pausable, StandardToken, BlackList {
      
          string public name;
          string public symbol;
          uint public decimals;
          address public upgradedAddress;
          bool public deprecated;
      
          //  The contract can be initialized with a number of tokens
          //  All the tokens are deposited to the owner address
          //
          // @param _balance Initial supply of the contract
          // @param _name Token Name
          // @param _symbol Token symbol
          // @param _decimals Token decimals
          function TetherToken(uint _initialSupply, string _name, string _symbol, uint _decimals) public {
              _totalSupply = _initialSupply;
              name = _name;
              symbol = _symbol;
              decimals = _decimals;
              balances[owner] = _initialSupply;
              deprecated = false;
          }
      
          // Forward ERC20 methods to upgraded contract if this one is deprecated
          function transfer(address _to, uint _value) public whenNotPaused {
              require(!isBlackListed[msg.sender]);
              if (deprecated) {
                  return UpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value);
              } else {
                  return super.transfer(_to, _value);
              }
          }
      
          // Forward ERC20 methods to upgraded contract if this one is deprecated
          function transferFrom(address _from, address _to, uint _value) public whenNotPaused {
              require(!isBlackListed[_from]);
              if (deprecated) {
                  return UpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value);
              } else {
                  return super.transferFrom(_from, _to, _value);
              }
          }
      
          // Forward ERC20 methods to upgraded contract if this one is deprecated
          function balanceOf(address who) public constant returns (uint) {
              if (deprecated) {
                  return UpgradedStandardToken(upgradedAddress).balanceOf(who);
              } else {
                  return super.balanceOf(who);
              }
          }
      
          // Forward ERC20 methods to upgraded contract if this one is deprecated
          function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) {
              if (deprecated) {
                  return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value);
              } else {
                  return super.approve(_spender, _value);
              }
          }
      
          // Forward ERC20 methods to upgraded contract if this one is deprecated
          function allowance(address _owner, address _spender) public constant returns (uint remaining) {
              if (deprecated) {
                  return StandardToken(upgradedAddress).allowance(_owner, _spender);
              } else {
                  return super.allowance(_owner, _spender);
              }
          }
      
          // deprecate current contract in favour of a new one
          function deprecate(address _upgradedAddress) public onlyOwner {
              deprecated = true;
              upgradedAddress = _upgradedAddress;
              Deprecate(_upgradedAddress);
          }
      
          // deprecate current contract if favour of a new one
          function totalSupply() public constant returns (uint) {
              if (deprecated) {
                  return StandardToken(upgradedAddress).totalSupply();
              } else {
                  return _totalSupply;
              }
          }
      
          // Issue a new amount of tokens
          // these tokens are deposited into the owner address
          //
          // @param _amount Number of tokens to be issued
          function issue(uint amount) public onlyOwner {
              require(_totalSupply + amount > _totalSupply);
              require(balances[owner] + amount > balances[owner]);
      
              balances[owner] += amount;
              _totalSupply += amount;
              Issue(amount);
          }
      
          // Redeem tokens.
          // These tokens are withdrawn from the owner address
          // if the balance must be enough to cover the redeem
          // or the call will fail.
          // @param _amount Number of tokens to be issued
          function redeem(uint amount) public onlyOwner {
              require(_totalSupply >= amount);
              require(balances[owner] >= amount);
      
              _totalSupply -= amount;
              balances[owner] -= amount;
              Redeem(amount);
          }
      
          function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner {
              // Ensure transparency by hardcoding limit beyond which fees can never be added
              require(newBasisPoints < 20);
              require(newMaxFee < 50);
      
              basisPointsRate = newBasisPoints;
              maximumFee = newMaxFee.mul(10**decimals);
      
              Params(basisPointsRate, maximumFee);
          }
      
          // Called when new token are issued
          event Issue(uint amount);
      
          // Called when tokens are redeemed
          event Redeem(uint amount);
      
          // Called when contract is deprecated
          event Deprecate(address newAddress);
      
          // Called if contract ever adds fees
          event Params(uint feeBasisPoints, uint maxFee);
      }

      File 3 of 3: PresaleEthV1
      // 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.7.0) (security/Pausable.sol)
      pragma solidity ^0.8.0;
      import "../utils/ContextUpgradeable.sol";
      import "../proxy/utils/Initializable.sol";
      /**
       * @dev Contract module which allows children to implement an emergency stop
       * mechanism that can be triggered by an authorized account.
       *
       * This module is used through inheritance. It will make available the
       * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
       * the functions of your contract. Note that they will not be pausable by
       * simply including this module, only once the modifiers are put in place.
       */
      abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
          /**
           * @dev Emitted when the pause is triggered by `account`.
           */
          event Paused(address account);
          /**
           * @dev Emitted when the pause is lifted by `account`.
           */
          event Unpaused(address account);
          bool private _paused;
          /**
           * @dev Initializes the contract in unpaused state.
           */
          function __Pausable_init() internal onlyInitializing {
              __Pausable_init_unchained();
          }
          function __Pausable_init_unchained() internal onlyInitializing {
              _paused = false;
          }
          /**
           * @dev Modifier to make a function callable only when the contract is not paused.
           *
           * Requirements:
           *
           * - The contract must not be paused.
           */
          modifier whenNotPaused() {
              _requireNotPaused();
              _;
          }
          /**
           * @dev Modifier to make a function callable only when the contract is paused.
           *
           * Requirements:
           *
           * - The contract must be paused.
           */
          modifier whenPaused() {
              _requirePaused();
              _;
          }
          /**
           * @dev Returns true if the contract is paused, and false otherwise.
           */
          function paused() public view virtual returns (bool) {
              return _paused;
          }
          /**
           * @dev Throws if the contract is paused.
           */
          function _requireNotPaused() internal view virtual {
              require(!paused(), "Pausable: paused");
          }
          /**
           * @dev Throws if the contract is not paused.
           */
          function _requirePaused() internal view virtual {
              require(paused(), "Pausable: not paused");
          }
          /**
           * @dev Triggers stopped state.
           *
           * Requirements:
           *
           * - The contract must not be paused.
           */
          function _pause() internal virtual whenNotPaused {
              _paused = true;
              emit Paused(_msgSender());
          }
          /**
           * @dev Returns to normal state.
           *
           * Requirements:
           *
           * - The contract must be paused.
           */
          function _unpause() internal virtual whenPaused {
              _paused = false;
              emit Unpaused(_msgSender());
          }
          /**
           * @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) (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) (token/ERC20/IERC20.sol)
      pragma solidity ^0.8.0;
      /**
       * @dev Interface of the ERC20 standard as defined in the EIP.
       */
      interface IERC20Upgradeable {
          /**
           * @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: 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
      pragma solidity ^0.8.9;
      import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
      import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
      import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
      import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
      import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
      interface Aggregator {
          function latestRoundData()
              external
              view
              returns (
                  uint80 roundId,
                  int256 answer,
                  uint256 startedAt,
                  uint256 updatedAt,
                  uint80 answeredInRound
              );
      }
      contract PresaleEthV1 is
          Initializable,
          ReentrancyGuardUpgradeable,
          PausableUpgradeable,
          OwnableUpgradeable
      {
          uint256 public totalTokensSold;
          uint256 public startTime;
          uint256 public endTime;
          uint256 public claimStart;
          address public saleToken;
          uint256 public baseDecimals;
          uint256 public maxTokensToBuy;
          uint256 public currentStep;
          uint256 public checkPoint;
          uint256 public usdRaised;
          uint256[] public prevCheckpoints;
          uint256[] public remainingTokensTracker;
          uint256 public timeConstant;
          address public paymentWallet;
          bool public dynamicTimeFlag;
          bool public whitelistClaimOnly;
          uint256[][3] public rounds;
          IERC20Upgradeable public USDTInterface;
          Aggregator public aggregatorInterface;
          mapping(address => uint256) public userDeposits;
          mapping(address => bool) public hasClaimed;
          mapping(address => bool) public isBlacklisted;
          mapping(address => bool) public isWhitelisted;
          mapping(address => bool) public wertWhitelisted;
          struct PromoCodeDetails {
              uint256 expiryDate;
              uint256 usageLimit;
              uint256 usageCount;
              uint256 discountPercentage;
              bool isValid;
          }
          mapping(string => PromoCodeDetails) private promoCodes;
          string[] private promoCodeKeys;
          mapping(address => string) public referralCodes;
          mapping(string => address) public referrers;
          event SaleTimeSet(uint256 _start, uint256 _end, uint256 timestamp);
          event SaleTimeUpdated(
              bytes32 indexed key,
              uint256 prevValue,
              uint256 newValue,
              uint256 timestamp
          );
          event TokensBought(
              address indexed user,
              uint256 indexed tokensBought,
              address indexed purchaseToken,
              uint256 amountPaid,
              uint256 usdEq,
              uint256 timestamp
          );
          event TokensAdded(
              address indexed token,
              uint256 noOfTokens,
              uint256 timestamp
          );
          event TokensClaimed(
              address indexed user,
              uint256 amount,
              uint256 timestamp
          );
          event ClaimStartUpdated(
              uint256 prevValue,
              uint256 newValue,
              uint256 timestamp
          );
          event MaxTokensUpdated(
              uint256 prevValue,
              uint256 newValue,
              uint256 timestamp
          );
          event PromoCodeCreated(
              string code,
              uint256 expiryDate,
              uint256 usageLimit,
              uint256 discountPercentage
          );
          event PromoCodeDisabled(string code);
          event ReferralCodeSet(address indexed user, string referralCode);
          function initialize(
              address _oracle,
              address _usdt,
              uint256 _startTime,
              uint256 _endTime,
              uint256[][3] memory _rounds,
              uint256 _maxTokensToBuy,
              address _paymentWallet
          ) external initializer {
              require(_usdt != address(0), "0x123 USDT address");
              require(_oracle != address(0), "0x123 aggregator address");
              require(_endTime > _startTime, "Invalid time");
              __Pausable_init_unchained();
              __Ownable_init_unchained();
              __ReentrancyGuard_init_unchained();
              baseDecimals = 10 ** 18;
              aggregatorInterface = Aggregator(_oracle);
              USDTInterface = IERC20Upgradeable(_usdt);
              startTime = _startTime;
              endTime = _endTime;
              rounds = _rounds;
              maxTokensToBuy = _maxTokensToBuy;
              paymentWallet = _paymentWallet;
              timeConstant = 172800;
              emit SaleTimeSet(startTime, endTime, block.timestamp);
          }
          function pause() external onlyOwner {
              _pause();
          }
          function unpause() external onlyOwner {
              _unpause();
          }
          function calculatePrice(uint256 _amount) public view returns (uint256) {
              uint256 USDTAmount;
              uint256 total = checkPoint == 0 ? totalTokensSold : checkPoint;
              require(_amount <= maxTokensToBuy, "Amount exceeds max tokens to buy");
              if (
                  _amount + total > rounds[0][currentStep] ||
                  block.timestamp >= rounds[2][currentStep]
              ) {
                  require(currentStep < (rounds[0].length - 1), "Wrong params");
                  if (block.timestamp >= rounds[2][currentStep]) {
                      require(
                          rounds[0][currentStep] + _amount <=
                              rounds[0][currentStep + 1],
                          "Cant Purchase More in individual tx"
                      );
                      USDTAmount = _amount * rounds[1][currentStep + 1];
                  } else {
                      uint256 tokenAmountForCurrentPrice = rounds[0][currentStep] -
                          total;
                      USDTAmount =
                          tokenAmountForCurrentPrice *
                          rounds[1][currentStep] +
                          (_amount - tokenAmountForCurrentPrice) *
                          rounds[1][currentStep + 1];
                  }
              } else {
                  USDTAmount = _amount * rounds[1][currentStep];
              }
              return USDTAmount;
          }
          function changeSaleTimes(
              uint256 _startTime,
              uint256 _endTime
          ) external onlyOwner {
              if (_startTime > 0) {
                  uint256 prevValue = startTime;
                  startTime = _startTime;
                  emit SaleTimeUpdated(
                      bytes32("START"),
                      prevValue,
                      _startTime,
                      block.timestamp
                  );
              }
              if (_endTime > 0) {
                  uint256 prevValue = endTime;
                  endTime = _endTime;
                  emit SaleTimeUpdated(
                      bytes32("END"),
                      prevValue,
                      _endTime,
                      block.timestamp
                  );
              }
          }
          function getLatestPrice() public view returns (uint256) {
              (, int256 price, , , ) = aggregatorInterface.latestRoundData();
              price = (price * (10 ** 10));
              return uint256(price);
          }
          modifier checkSaleState(uint256 amount) {
              require(
                  block.timestamp >= startTime && block.timestamp <= endTime,
                  "Invalid time for buying"
              );
              require(amount > 0, "Invalid sale amount");
              _;
          }
          function buyWithUSDT(
              uint256 amount,
              string memory promoCode,
              string memory referralCode
          ) external checkSaleState(amount) whenNotPaused returns (bool) {
              uint256 usdPrice = calculatePrice(amount);
              uint256 referralBonus = uint(amount * 8) / 100;
              // Check if a promo code is provided and apply discount
              if (bytes(promoCode).length > 0) {
                  require(promoCodes[promoCode].isValid, "Invalid promo code");
                  require(
                      promoCodes[promoCode].expiryDate >= block.timestamp,
                      "Expired promo code"
                  );
                  require(
                      promoCodes[promoCode].usageCount <
                          promoCodes[promoCode].usageLimit,
                      "Promo code usage limit reached"
                  );
                  uint256 discountedAmount = amount;
                  // Apply discount from the promo code
                  discountedAmount +=
                      (amount * promoCodes[promoCode].discountPercentage) /
                      100;
                  amount = discountedAmount;
              }
              if (bytes(referralCodes[_msgSender()]).length == 0) {
                  string memory code = generateReferralCode();
                  referralCodes[_msgSender()] = code;
                  referrers[code] = _msgSender();
                  emit ReferralCodeSet(_msgSender(), referralCode);
              }
              totalTokensSold += amount;
              if (checkPoint != 0) checkPoint += amount;
              uint256 total = totalTokensSold > checkPoint
                  ? totalTokensSold
                  : checkPoint;
              if (
                  total > rounds[0][currentStep] ||
                  block.timestamp >= rounds[2][currentStep]
              ) {
                  if (block.timestamp >= rounds[2][currentStep]) {
                      checkPoint = rounds[0][currentStep] + amount;
                  } else {
                      if (dynamicTimeFlag) {
                          manageTimeDiff();
                      }
                  }
                  uint256 unsoldTokens = total > rounds[0][currentStep]
                      ? 0
                      : rounds[0][currentStep] - total;
                  remainingTokensTracker.push(unsoldTokens);
                  currentStep += 1;
              }
              if (bytes(referralCode).length > 0) {
                  address referralAddress = referrers[referralCode];
                  if (
                      referralAddress != address(0) && referralAddress != _msgSender()
                  ) {
                      userDeposits[referralAddress] += (referralBonus * baseDecimals);
                  }
              }
              userDeposits[_msgSender()] += (amount * baseDecimals);
              usdRaised += usdPrice;
              uint256 ourAllowance = USDTInterface.allowance(
                  _msgSender(),
                  address(this)
              );
              uint256 price = usdPrice / (10 ** 12);
              require(price <= ourAllowance, "Make sure to add enough allowance");
              (bool success, ) = address(USDTInterface).call(
                  abi.encodeWithSignature(
                      "transferFrom(address,address,uint256)",
                      _msgSender(),
                      paymentWallet,
                      price
                  )
              );
              require(success, "Token payment failed");
              emit TokensBought(
                  _msgSender(),
                  amount,
                  address(USDTInterface),
                  price,
                  usdPrice,
                  block.timestamp
              );
              return true;
          }
          function buyWithEth(
              uint256 amount,
              string memory promoCode,
              string memory referralCode
          )
              external
              payable
              checkSaleState(amount)
              whenNotPaused
              nonReentrant
              returns (bool)
          {
              uint256 usdPrice = calculatePrice(amount);
              uint256 referralBonus = uint(amount * 8) / 100;
              // Check if a promo code is provided and apply discount
              if (bytes(promoCode).length > 0) {
                  require(promoCodes[promoCode].isValid, "Invalid promo code");
                  require(
                      promoCodes[promoCode].expiryDate >= block.timestamp,
                      "Expired promo code"
                  );
                  require(
                      promoCodes[promoCode].usageCount <
                          promoCodes[promoCode].usageLimit,
                      "Promo code usage limit reached"
                  );
                  uint256 discountedAmount = amount;
                  // Apply discount from the promo code
                  discountedAmount +=
                      (amount * promoCodes[promoCode].discountPercentage) /
                      100;
                  amount = discountedAmount;
              }
              if (bytes(referralCodes[_msgSender()]).length == 0) {
                  string memory code = generateReferralCode();
                  referralCodes[_msgSender()] = code;
                  referrers[code] = _msgSender();
                  emit ReferralCodeSet(_msgSender(), referralCode);
              }
              uint256 ethAmount = (usdPrice * baseDecimals) / getLatestPrice();
              require(msg.value >= ethAmount, "Less payment");
              uint256 excess = msg.value - ethAmount;
              totalTokensSold += amount;
              if (checkPoint != 0) checkPoint += amount;
              uint256 total = totalTokensSold > checkPoint
                  ? totalTokensSold
                  : checkPoint;
              if (
                  total > rounds[0][currentStep] ||
                  block.timestamp >= rounds[2][currentStep]
              ) {
                  if (block.timestamp >= rounds[2][currentStep]) {
                      checkPoint = rounds[0][currentStep] + amount;
                  } else {
                      if (dynamicTimeFlag) {
                          manageTimeDiff();
                      }
                  }
                  uint256 unsoldTokens = total > rounds[0][currentStep]
                      ? 0
                      : rounds[0][currentStep] - total;
                  remainingTokensTracker.push(unsoldTokens);
                  currentStep += 1;
              }
              if (bytes(referralCode).length > 0) {
                  address referralAddress = referrers[referralCode];
                  if (
                      referralAddress != address(0) && referralAddress != _msgSender()
                  ) {
                      userDeposits[referralAddress] += (referralBonus * baseDecimals);
                  }
              }
              userDeposits[_msgSender()] += (amount * baseDecimals);
              usdRaised += usdPrice;
              sendValue(payable(paymentWallet), ethAmount);
              if (excess > 0) sendValue(payable(_msgSender()), excess);
              emit TokensBought(
                  _msgSender(),
                  amount,
                  address(0),
                  ethAmount,
                  usdPrice,
                  block.timestamp
              );
              return true;
          }
          function ethBuyHelper(
              uint256 amount
          ) external view returns (uint256 ethAmount) {
              uint256 usdPrice = calculatePrice(amount);
              ethAmount = (usdPrice * baseDecimals) / getLatestPrice();
          }
          function usdtBuyHelper(
              uint256 amount
          ) external view returns (uint256 usdPrice) {
              usdPrice = calculatePrice(amount);
              usdPrice = usdPrice / (10 ** 12);
          }
          function sendValue(address payable recipient, uint256 amount) internal {
              require(address(this).balance >= amount, "Low balance");
              (bool success, ) = recipient.call{value: amount}("");
              require(success, "ETH Payment failed");
          }
          function startClaim(
              uint256 _claimStart,
              uint256 noOfTokens,
              address _saleToken
          ) external onlyOwner returns (bool) {
              require(
                  _claimStart > endTime && _claimStart > block.timestamp,
                  "Invalid claim start time"
              );
              require(
                  noOfTokens >= (totalTokensSold * baseDecimals),
                  "Tokens less than sold"
              );
              require(_saleToken != address(0), "0x000 token address");
              require(claimStart == 0, "Claim already set");
              claimStart = _claimStart;
              saleToken = _saleToken;
              bool success = IERC20Upgradeable(_saleToken).transferFrom(
                  _msgSender(),
                  address(this),
                  noOfTokens
              );
              require(success, "Token transfer failed");
              emit TokensAdded(saleToken, noOfTokens, block.timestamp);
              return true;
          }
          function changeClaimStart(
              uint256 _claimStart
          ) external onlyOwner returns (bool) {
              require(claimStart > 0, "Initial claim data not set");
              require(_claimStart > endTime, "Sale in progress");
              require(_claimStart > block.timestamp, "Claim start in past");
              uint256 prevValue = claimStart;
              claimStart = _claimStart;
              emit ClaimStartUpdated(prevValue, _claimStart, block.timestamp);
              return true;
          }
          function claim() external whenNotPaused returns (bool) {
              require(saleToken != address(0), "Sale token not added");
              require(!isBlacklisted[_msgSender()], "This Address is Blacklisted");
              if (whitelistClaimOnly) {
                  require(
                      isWhitelisted[_msgSender()],
                      "User not whitelisted for claim"
                  );
              }
              require(block.timestamp >= claimStart, "Claim has not started yet");
              require(!hasClaimed[_msgSender()], "Already claimed");
              hasClaimed[_msgSender()] = true;
              uint256 amount = userDeposits[_msgSender()];
              require(amount > 0, "Nothing to claim");
              delete userDeposits[_msgSender()];
              bool success = IERC20Upgradeable(saleToken).transfer(
                  _msgSender(),
                  amount
              );
              require(success, "Token transfer failed");
              emit TokensClaimed(_msgSender(), amount, block.timestamp);
              return true;
          }
          function changeMaxTokensToBuy(uint256 _maxTokensToBuy) external onlyOwner {
              require(_maxTokensToBuy > 0, "0 max tokens to buy value");
              uint256 prevValue = maxTokensToBuy;
              maxTokensToBuy = _maxTokensToBuy;
              emit MaxTokensUpdated(prevValue, _maxTokensToBuy, block.timestamp);
          }
          function changeRoundsSaleTokens(
              uint256[] memory _rounds
          ) external onlyOwner {
              rounds[0] = _rounds;
          }
          function changeRoundsSalePrices(
              uint256[] memory _rounds
          ) external onlyOwner {
              rounds[1] = _rounds;
          }
          function changeRoundsSaleTimes(
              uint256[] memory _rounds
          ) external onlyOwner {
              rounds[2] = _rounds;
          }
          function blacklistUsers(
              address[] calldata _usersToBlacklist
          ) external onlyOwner {
              for (uint256 i = 0; i < _usersToBlacklist.length; i++) {
                  isBlacklisted[_usersToBlacklist[i]] = true;
              }
          }
          function removeFromBlacklist(
              address[] calldata _userToRemoveFromBlacklist
          ) external onlyOwner {
              for (uint256 i = 0; i < _userToRemoveFromBlacklist.length; i++) {
                  isBlacklisted[_userToRemoveFromBlacklist[i]] = false;
              }
          }
          function whitelistUsers(
              address[] calldata _usersToWhitelist
          ) external onlyOwner {
              for (uint256 i = 0; i < _usersToWhitelist.length; i++) {
                  isWhitelisted[_usersToWhitelist[i]] = true;
              }
          }
          function removeFromWhitelist(
              address[] calldata _userToRemoveFromWhitelist
          ) external onlyOwner {
              for (uint256 i = 0; i < _userToRemoveFromWhitelist.length; i++) {
                  isWhitelisted[_userToRemoveFromWhitelist[i]] = false;
              }
          }
          function setClaimWhitelistStatus(bool _status) external onlyOwner {
              whitelistClaimOnly = _status;
          }
          function changePaymentWallet(address _newPaymentWallet) external onlyOwner {
              require(_newPaymentWallet != address(0), "address cannot be zero");
              paymentWallet = _newPaymentWallet;
          }
          function manageTimeDiff() internal {
              for (uint256 i; i < rounds[2].length - currentStep; i++) {
                  rounds[2][currentStep + i] = block.timestamp + i * timeConstant;
              }
          }
          function setTimeConstant(uint256 _timeConstant) external onlyOwner {
              timeConstant = _timeConstant;
          }
          function roundDetails(
              uint256 _no
          ) external view returns (uint256[] memory) {
              return rounds[_no];
          }
          function updateFromBSC(
              address[] calldata _users,
              uint256[] calldata _userDeposits
          ) external onlyOwner {
              require(_users.length == _userDeposits.length, "Length mismatch");
              for (uint256 i = 0; i < _users.length; i++) {
                  userDeposits[_users[i]] += _userDeposits[i];
              }
          }
          function incrementCurrentStep() external onlyOwner {
              prevCheckpoints.push(checkPoint);
              if (dynamicTimeFlag) {
                  manageTimeDiff();
              }
              if (checkPoint < rounds[0][currentStep]) {
                  remainingTokensTracker.push(rounds[0][currentStep] - checkPoint);
                  checkPoint = rounds[0][currentStep];
              }
              currentStep++;
          }
          function increaseUsdRaised(uint256 amount) external onlyOwner {
              usdRaised += amount;
          }
          function setCurrentStep(
              uint256 _step,
              uint256 _checkpoint
          ) external onlyOwner {
              currentStep = _step;
              checkPoint = _checkpoint;
          }
          function setDynamicTimeFlag(bool _dynamicTimeFlag) external onlyOwner {
              dynamicTimeFlag = _dynamicTimeFlag;
          }
          function trackRemainingTokens() external view returns (uint256[] memory) {
              return remainingTokensTracker;
          }
          function updatePromoCode(
              string calldata code,
              uint256 expiryDate,
              uint256 usageLimit,
              uint256 discountPercentage
          ) external onlyOwner {
              promoCodes[code] = PromoCodeDetails({
                  expiryDate: expiryDate,
                  usageLimit: usageLimit,
                  usageCount: 0,
                  discountPercentage: discountPercentage,
                  isValid: true
              });
          }
          function createPromoCode(
              string memory code,
              uint256 expiryDate,
              uint256 usageLimit,
              uint256 discountPercentage
          ) external onlyOwner {
              require(!promoCodes[code].isValid, "Promo code already exists");
              PromoCodeDetails memory promoCode = PromoCodeDetails({
                  expiryDate: expiryDate,
                  usageLimit: usageLimit,
                  usageCount: 0,
                  discountPercentage: discountPercentage,
                  isValid: true
              });
              promoCodes[code] = promoCode;
              promoCodeKeys.push(code);
              emit PromoCodeCreated(code, expiryDate, usageLimit, discountPercentage);
          }
          function disablePromoCode(string memory code) external onlyOwner {
              require(promoCodes[code].isValid, "Promo code does not exist");
              promoCodes[code].isValid = false;
              // Remove the promo code key from promoCodeKeys array
              for (uint256 i = 0; i < promoCodeKeys.length; i++) {
                  if (keccak256(bytes(promoCodeKeys[i])) == keccak256(bytes(code))) {
                      // Shift elements to the left to remove the key
                      for (uint256 j = i; j < promoCodeKeys.length - 1; j++) {
                          promoCodeKeys[j] = promoCodeKeys[j + 1];
                      }
                      promoCodeKeys.pop();
                      break;
                  }
              }
              emit PromoCodeDisabled(code);
          }
          function validatePromoCode(
              string memory code
          ) external view returns (bool) {
              return (promoCodes[code].isValid &&
                  promoCodes[code].expiryDate >= block.timestamp &&
                  promoCodes[code].usageCount < promoCodes[code].usageLimit);
          }
          function getPromoCode(
              string memory code
          ) public view returns (uint256, uint256, uint256, uint256, bool) {
              PromoCodeDetails storage details = promoCodes[code];
              return (
                  details.expiryDate,
                  details.usageLimit,
                  details.usageCount,
                  details.discountPercentage,
                  details.isValid
              );
          }
          function getPromoCodes() public view returns (string[] memory) {
              return promoCodeKeys;
          }
          function generateReferralCode() internal view returns (string memory) {
              bytes
                  memory characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
              uint256 length = 12;
              bytes memory code = new bytes(length);
              for (uint256 i = 0; i < length; i++) {
                  code[i] = characters[random(i) % characters.length];
              }
              string memory referralCode = string(code);
              return referralCode;
          }
          // Internal function to generate a random number
          function random(uint256 seed) internal view returns (uint256) {
              return
                  uint256(
                      keccak256(abi.encodePacked(_msgSender(), block.timestamp, seed))
                  );
          }
      }