creation_sourcecode: /*
  $GYD aims to be the flagship utility token of the Defi 3.0 ecosystem and it's created 
  for mass adoption on the Ethereum Network and further passive income generation for 
  the ecosystem to reward its holders in different ways.
  
  Website: www.growyard.io
  dApp : app.growyard.io
  TG: https://t.me/GrowYard
  Twitter: @GrowYardErc
  Medium : @GrowYard
  */
  // SPDX-License-Identifier: MIT
  pragma solidity ^0.8.0;
  
  abstract contract Context {
      function _msgSender() internal view virtual returns (address) {
          return msg.sender;
      }
  
      function _msgData() internal view virtual returns (bytes calldata) {
          this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
          return msg.data;
      }
  }
  
  // File @openzeppelin/contracts/access/Ownable.sol@v4.1.0
  
  pragma solidity ^0.8.0;
  
  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() {
          address msgSender = _msgSender();
          _owner = msgSender;
          emit OwnershipTransferred(address(0), msgSender);
      }
  
      /**
       * @dev Returns the address of the current owner.
       */
      function owner() public view virtual returns (address) {
          return _owner;
      }
  
      /**
       * @dev Throws if called by any account other than the owner.
       */
      modifier onlyOwner() {
          require(owner() == _msgSender(), "Ownable: caller is not the owner");
          _;
      }
  
      function renounceOwnership() public virtual onlyOwner {
          emit OwnershipTransferred(_owner, address(0));
          _owner = 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"
          );
          emit OwnershipTransferred(_owner, newOwner);
          _owner = newOwner;
      }
  }
  
  // File @openzeppelin/contracts/utils/math/SafeMath.sol@v4.1.0
  
  pragma solidity ^0.8.0;
  
  library SafeMath {
      /**
       * @dev Returns the addition of two unsigned integers, with an overflow flag.
       *
       * _Available since v3.4._
       */
      function tryAdd(uint256 a, uint256 b)
          internal
          pure
          returns (bool, uint256)
      {
          unchecked {
              uint256 c = a + b;
              if (c < a) return (false, 0);
              return (true, c);
          }
      }
  
      function trySub(uint256 a, uint256 b)
          internal
          pure
          returns (bool, uint256)
      {
          unchecked {
              if (b > a) return (false, 0);
              return (true, a - b);
          }
      }
  
      function tryMul(uint256 a, uint256 b)
          internal
          pure
          returns (bool, uint256)
      {
          unchecked {
              // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
              // benefit is lost if 'b' is also tested.
              // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
              if (a == 0) return (true, 0);
              uint256 c = a * b;
              if (c / a != b) return (false, 0);
              return (true, c);
          }
      }
  
      /**
       * @dev Returns the division of two unsigned integers, with a division by zero flag.
       *
       * _Available since v3.4._
       */
      function tryDiv(uint256 a, uint256 b)
          internal
          pure
          returns (bool, uint256)
      {
          unchecked {
              if (b == 0) return (false, 0);
              return (true, a / b);
          }
      }
  
      function tryMod(uint256 a, uint256 b)
          internal
          pure
          returns (bool, uint256)
      {
          unchecked {
              if (b == 0) return (false, 0);
              return (true, a % b);
          }
      }
  
      function add(uint256 a, uint256 b) internal pure returns (uint256) {
          return a + b;
      }
  
      function sub(uint256 a, uint256 b) internal pure returns (uint256) {
          return a - b;
      }
  
      function mul(uint256 a, uint256 b) internal pure returns (uint256) {
          return a * b;
      }
  
      function div(uint256 a, uint256 b) internal pure returns (uint256) {
          return a / b;
      }
  
      function mod(uint256 a, uint256 b) internal pure returns (uint256) {
          return a % b;
      }
  
      function sub(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          unchecked {
              require(b <= a, errorMessage);
              return a - b;
          }
      }
  
      function div(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          unchecked {
              require(b > 0, errorMessage);
              return a / b;
          }
      }
  
      function mod(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          unchecked {
              require(b > 0, errorMessage);
              return a % b;
          }
      }
  }
  
  pragma solidity ^0.8.0;
  
  interface IERC20 {
    
      function totalSupply() external view returns (uint256);
  
      function balanceOf(address account) external view returns (uint256);
  
      function transfer(address recipient, uint256 amount)
          external
          returns (bool);
  
      function allowance(address owner, address spender)
          external
          view
          returns (uint256);
  
      function approve(address spender, uint256 amount) external returns (bool);
  
      function transferFrom(
          address sender,
          address recipient,
          uint256 amount
      ) external returns (bool);
  
      event Transfer(address indexed from, address indexed to, uint256 value);
  
      event Approval(
          address indexed owner,
          address indexed spender,
          uint256 value
      );
  }
  
  pragma solidity ^0.8.0;
  
  interface IERC20Metadata is IERC20 {
      /**
       * @dev Returns the name of the token.
       */
      function name() external view returns (string memory);
  
      /**
       * @dev Returns the symbol of the token.
       */
      function symbol() external view returns (string memory);
  
      /**
       * @dev Returns the decimals places of the token.
       */
      function decimals() external view returns (uint8);
  }
  
  // File @openzeppelin/contracts/token/ERC20/ERC20.sol@v4.1.0
  
  pragma solidity ^0.8.0;
  
  contract ERC20 is Context, IERC20, IERC20Metadata {
      mapping(address => uint256) private _balances;
  
      mapping(address => mapping(address => uint256)) private _allowances;
  
      uint256 private _totalSupply;
  
      string private _name;
      string private _symbol;
  
      constructor(string memory name_, string memory symbol_) {
          _name = name_;
          _symbol = symbol_;
      }
  
      function name() public view virtual override returns (string memory) {
          return _name;
      }
  
      function symbol() public view virtual override returns (string memory) {
          return _symbol;
      }
  
      function decimals() public view virtual override returns (uint8) {
          return 18;
      }
  
      /**
       * @dev See {IERC20-totalSupply}.
       */
      function totalSupply() public view virtual override returns (uint256) {
          return _totalSupply;
      }
  
      /**
       * @dev See {IERC20-balanceOf}.
       */
      function balanceOf(address account)
          public
          view
          virtual
          override
          returns (uint256)
      {
          return _balances[account];
      }
  
      function transfer(address recipient, uint256 amount)
          public
          virtual
          override
          returns (bool)
      {
          _transfer(_msgSender(), recipient, amount);
          return true;
      }
  
      function allowance(address owner, address spender)
          public
          view
          virtual
          override
          returns (uint256)
      {
          return _allowances[owner][spender];
      }
  
      function approve(address spender, uint256 amount)
          public
          virtual
          override
          returns (bool)
      {
          _approve(_msgSender(), spender, amount);
          return true;
      }
  
      function transferFrom(
          address sender,
          address recipient,
          uint256 amount
      ) public virtual override returns (bool) {
          _transfer(sender, recipient, amount);
  
          uint256 currentAllowance = _allowances[sender][_msgSender()];
          require(
              currentAllowance >= amount,
              "ERC20: transfer amount exceeds allowance"
          );
          _approve(sender, _msgSender(), currentAllowance - amount);
  
          return true;
      }
  
      function increaseAllowance(address spender, uint256 addedValue)
          public
          virtual
          returns (bool)
      {
          _approve(
              _msgSender(),
              spender,
              _allowances[_msgSender()][spender] + addedValue
          );
          return true;
      }
  
      function decreaseAllowance(address spender, uint256 subtractedValue)
          public
          virtual
          returns (bool)
      {
          uint256 currentAllowance = _allowances[_msgSender()][spender];
          require(
              currentAllowance >= subtractedValue,
              "ERC20: decreased allowance below zero"
          );
          _approve(_msgSender(), spender, currentAllowance - subtractedValue);
  
          return true;
      }
  
      function _transfer(
          address sender,
          address recipient,
          uint256 amount
      ) internal virtual {
          require(sender != address(0), "ERC20: transfer from the zero address");
          require(recipient != address(0), "ERC20: transfer to the zero address");
  
          _beforeTokenTransfer(sender, recipient, amount);
  
          uint256 senderBalance = _balances[sender];
          require(
              senderBalance >= amount,
              "ERC20: transfer amount exceeds balance"
          );
          _balances[sender] = senderBalance - amount;
          _balances[recipient] += amount;
  
          emit Transfer(sender, recipient, amount);
      }
  
      function _mint(address account, uint256 amount) internal virtual {
          require(account != address(0), "ERC20: mint to the zero address");
  
          _beforeTokenTransfer(address(0), account, amount);
  
          _totalSupply += amount;
          _balances[account] += amount;
          emit Transfer(address(0), account, amount);
      }
  
      function _burn(address account, uint256 amount) internal virtual {
          require(account != address(0), "ERC20: burn from the zero address");
  
          _beforeTokenTransfer(account, address(0), amount);
  
          uint256 accountBalance = _balances[account];
          require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
          _balances[account] = accountBalance - amount;
          _totalSupply -= amount;
  
          emit Transfer(account, address(0), amount);
      }
  
      function _approve(
          address owner,
          address spender,
          uint256 amount
      ) internal virtual {
          require(owner != address(0), "ERC20: approve from the zero address");
          require(spender != address(0), "ERC20: approve to the zero address");
  
          _allowances[owner][spender] = amount;
          emit Approval(owner, spender, amount);
      }
  
      function _beforeTokenTransfer(
          address from,
          address to,
          uint256 amount
      ) internal virtual {}
  }
  
  // File @openzeppelin/contracts/utils/Address.sol@v4.1.0
  
  pragma solidity ^0.8.0;
  
  /**
   * @dev Collection of functions related to the address type
   */
  library Address {
    
      function isContract(address account) internal view returns (bool) {
          // This method relies on extcodesize, which returns 0 for contracts in
          // construction, since the code is only stored at the end of the
          // constructor execution.
  
          uint256 size;
          // solhint-disable-next-line no-inline-assembly
          assembly {
              size := extcodesize(account)
          }
          return size > 0;
      }
  
      function sendValue(address payable recipient, uint256 amount) internal {
          require(
              address(this).balance >= amount,
              "Address: insufficient balance"
          );
  
          // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
          (bool success, ) = recipient.call{value: amount}("");
          require(
              success,
              "Address: unable to send value, recipient may have reverted"
          );
      }
  
      function functionCall(address target, bytes memory data)
          internal
          returns (bytes memory)
      {
          return functionCall(target, data, "Address: low-level call failed");
      }
  
      function functionCall(
          address target,
          bytes memory data,
          string memory errorMessage
      ) internal returns (bytes memory) {
          return functionCallWithValue(target, data, 0, errorMessage);
      }
  
      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"
              );
      }
  
      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"
          );
          require(isContract(target), "Address: call to non-contract");
  
          // solhint-disable-next-line avoid-low-level-calls
          (bool success, bytes memory returndata) = target.call{value: value}(
              data
          );
          return _verifyCallResult(success, returndata, errorMessage);
      }
  
      function functionStaticCall(address target, bytes memory data)
          internal
          view
          returns (bytes memory)
      {
          return
              functionStaticCall(
                  target,
                  data,
                  "Address: low-level static call failed"
              );
      }
  
      function functionStaticCall(
          address target,
          bytes memory data,
          string memory errorMessage
      ) internal view returns (bytes memory) {
          require(isContract(target), "Address: static call to non-contract");
  
          // solhint-disable-next-line avoid-low-level-calls
          (bool success, bytes memory returndata) = target.staticcall(data);
          return _verifyCallResult(success, returndata, errorMessage);
      }
  
      function functionDelegateCall(address target, bytes memory data)
          internal
          returns (bytes memory)
      {
          return
              functionDelegateCall(
                  target,
                  data,
                  "Address: low-level delegate call failed"
              );
      }
  
      function functionDelegateCall(
          address target,
          bytes memory data,
          string memory errorMessage
      ) internal returns (bytes memory) {
          require(isContract(target), "Address: delegate call to non-contract");
  
          // solhint-disable-next-line avoid-low-level-calls
          (bool success, bytes memory returndata) = target.delegatecall(data);
          return _verifyCallResult(success, returndata, errorMessage);
      }
  
      function _verifyCallResult(
          bool success,
          bytes memory returndata,
          string memory errorMessage
      ) private pure returns (bytes memory) {
          if (success) {
              return returndata;
          } else {
              // 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
  
                  // solhint-disable-next-line no-inline-assembly
                  assembly {
                      let returndata_size := mload(returndata)
                      revert(add(32, returndata), returndata_size)
                  }
              } else {
                  revert(errorMessage);
              }
          }
      }
  }
  
  
  pragma solidity ^0.8.0;
  
  library SafeERC20 {
      using Address for address;
  
      function safeTransfer(
          IERC20 token,
          address to,
          uint256 value
      ) internal {
          _callOptionalReturn(
              token,
              abi.encodeWithSelector(token.transfer.selector, to, value)
          );
      }
  
      function safeTransferFrom(
          IERC20 token,
          address from,
          address to,
          uint256 value
      ) internal {
          _callOptionalReturn(
              token,
              abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
          );
      }
  
      function safeApprove(
          IERC20 token,
          address spender,
          uint256 value
      ) internal {
          // safeApprove should only be called when setting an initial allowance,
          // or when resetting it to zero. To increase and decrease it, use
          // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
          // solhint-disable-next-line max-line-length
          require(
              (value == 0) || (token.allowance(address(this), spender) == 0),
              "SafeERC20: approve from non-zero to non-zero allowance"
          );
          _callOptionalReturn(
              token,
              abi.encodeWithSelector(token.approve.selector, spender, value)
          );
      }
  
      function safeIncreaseAllowance(
          IERC20 token,
          address spender,
          uint256 value
      ) internal {
          uint256 newAllowance = token.allowance(address(this), spender) + value;
          _callOptionalReturn(
              token,
              abi.encodeWithSelector(
                  token.approve.selector,
                  spender,
                  newAllowance
              )
          );
      }
  
      function safeDecreaseAllowance(
          IERC20 token,
          address spender,
          uint256 value
      ) internal {
          unchecked {
              uint256 oldAllowance = token.allowance(address(this), spender);
              require(
                  oldAllowance >= value,
                  "SafeERC20: decreased allowance below zero"
              );
              uint256 newAllowance = oldAllowance - value;
              _callOptionalReturn(
                  token,
                  abi.encodeWithSelector(
                      token.approve.selector,
                      spender,
                      newAllowance
                  )
              );
          }
      }
  
      function _callOptionalReturn(IERC20 token, bytes memory data) private {
  
          bytes memory returndata = address(token).functionCall(
              data,
              "SafeERC20: low-level call failed"
          );
          if (returndata.length > 0) {
              // Return data is optional
              // solhint-disable-next-line max-line-length
              require(
                  abi.decode(returndata, (bool)),
                  "SafeERC20: ERC20 operation did not succeed"
              );
          }
      }
  }
  
  // File contracts/interfaces/IUniswapRouter01.sol
  
  pragma solidity >=0.8.0;
  
  interface IUniswapV2Router01 {
      function factory() external pure returns (address);
  
      function WETH() external pure returns (address);
  
      function addLiquidity(
          address tokenA,
          address tokenB,
          uint256 amountADesired,
          uint256 amountBDesired,
          uint256 amountAMin,
          uint256 amountBMin,
          address to,
          uint256 deadline
      )
          external
          returns (
              uint256 amountA,
              uint256 amountB,
              uint256 liquidity
          );
  
      function addLiquidityETH(
          address token,
          uint256 amountTokenDesired,
          uint256 amountTokenMin,
          uint256 amountETHMin,
          address to,
          uint256 deadline
      )
          external
          payable
          returns (
              uint256 amountToken,
              uint256 amountETH,
              uint256 liquidity
          );
  
      function removeLiquidity(
          address tokenA,
          address tokenB,
          uint256 liquidity,
          uint256 amountAMin,
          uint256 amountBMin,
          address to,
          uint256 deadline
      ) external returns (uint256 amountA, uint256 amountB);
  
      function removeLiquidityETH(
          address token,
          uint256 liquidity,
          uint256 amountTokenMin,
          uint256 amountETHMin,
          address to,
          uint256 deadline
      ) external returns (uint256 amountToken, uint256 amountETH);
  
      function removeLiquidityWithPermit(
          address tokenA,
          address tokenB,
          uint256 liquidity,
          uint256 amountAMin,
          uint256 amountBMin,
          address to,
          uint256 deadline,
          bool approveMax,
          uint8 v,
          bytes32 r,
          bytes32 s
      ) external returns (uint256 amountA, uint256 amountB);
  
      function removeLiquidityETHWithPermit(
          address token,
          uint256 liquidity,
          uint256 amountTokenMin,
          uint256 amountETHMin,
          address to,
          uint256 deadline,
          bool approveMax,
          uint8 v,
          bytes32 r,
          bytes32 s
      ) external returns (uint256 amountToken, uint256 amountETH);
  
      function swapExactTokensForTokens(
          uint256 amountIn,
          uint256 amountOutMin,
          address[] calldata path,
          address to,
          uint256 deadline
      ) external returns (uint256[] memory amounts);
  
      function swapTokensForExactTokens(
          uint256 amountOut,
          uint256 amountInMax,
          address[] calldata path,
          address to,
          uint256 deadline
      ) external returns (uint256[] memory amounts);
  
      function swapExactETHForTokens(
          uint256 amountOutMin,
          address[] calldata path,
          address to,
          uint256 deadline
      ) external payable returns (uint256[] memory amounts);
  
      function swapTokensForExactETH(
          uint256 amountOut,
          uint256 amountInMax,
          address[] calldata path,
          address to,
          uint256 deadline
      ) external returns (uint256[] memory amounts);
  
      function swapExactTokensForETH(
          uint256 amountIn,
          uint256 amountOutMin,
          address[] calldata path,
          address to,
          uint256 deadline
      ) external returns (uint256[] memory amounts);
  
      function swapETHForExactTokens(
          uint256 amountOut,
          address[] calldata path,
          address to,
          uint256 deadline
      ) external payable returns (uint256[] memory amounts);
  
      function quote(
          uint256 amountA,
          uint256 reserveA,
          uint256 reserveB
      ) external pure returns (uint256 amountB);
  
      function getAmountOut(
          uint256 amountIn,
          uint256 reserveIn,
          uint256 reserveOut
      ) external pure returns (uint256 amountOut);
  
      function getAmountIn(
          uint256 amountOut,
          uint256 reserveIn,
          uint256 reserveOut
      ) external pure returns (uint256 amountIn);
  
      function getAmountsOut(uint256 amountIn, address[] calldata path)
          external
          view
          returns (uint256[] memory amounts);
  
      function getAmountsIn(uint256 amountOut, address[] calldata path)
          external
          view
          returns (uint256[] memory amounts);
  }
  
  pragma solidity >=0.8.0;
  
  interface IUniswapV2Router02 is IUniswapV2Router01 {
      function removeLiquidityETHSupportingFeeOnTransferTokens(
          address token,
          uint256 liquidity,
          uint256 amountTokenMin,
          uint256 amountETHMin,
          address to,
          uint256 deadline
      ) external returns (uint256 amountETH);
  
      function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
          address token,
          uint256 liquidity,
          uint256 amountTokenMin,
          uint256 amountETHMin,
          address to,
          uint256 deadline,
          bool approveMax,
          uint8 v,
          bytes32 r,
          bytes32 s
      ) external returns (uint256 amountETH);
  
      function swapExactTokensForTokensSupportingFeeOnTransferTokens(
          uint256 amountIn,
          uint256 amountOutMin,
          address[] calldata path,
          address to,
          uint256 deadline
      ) external;
  
      function swapExactETHForTokensSupportingFeeOnTransferTokens(
          uint256 amountOutMin,
          address[] calldata path,
          address to,
          uint256 deadline
      ) external payable;
  
      function swapExactTokensForETHSupportingFeeOnTransferTokens(
          uint256 amountIn,
          uint256 amountOutMin,
          address[] calldata path,
          address to,
          uint256 deadline
      ) external;
  }
  
  // File contracts/interfaces/IUniswapV2Factory.sol
  
  pragma solidity >=0.8.0;
  
  interface IUniswapV2Factory {
      event PairCreated(
          address indexed token0,
          address indexed token1,
          address pair,
          uint256
      );
  
      function feeTo() external view returns (address);
  
      function feeToSetter() external view returns (address);
  
      function getPair(address tokenA, address tokenB)
          external
          view
          returns (address pair);
  
      function allPairs(uint256) external view returns (address pair);
  
      function allPairsLength() external view returns (uint256);
  
      function createPair(address tokenA, address tokenB)
          external
          returns (address pair);
  
      function setReflectionFeeTo(address) external;
  
      function setReflectionFeeToSetter(address) external;
  }
  
  pragma solidity >=0.8.0;
  
  contract GrowYard is ERC20("Grow Yard", "GYD"), Ownable {
      using SafeMath for uint256;
      using SafeERC20 for IERC20;
  
      uint256 public constant MAX_SUPPLY = 10000000000 * 1e18; // 10B max supply
  
      uint16 private MAX_BP_RATE = 10000;
      uint16 private devTaxRate = 200;
      uint16 private marketingTaxRate = 100;
      uint16 private passiveIncomeRewardTaxRate = 200;
      uint16 private maxTransferAmountRate = 110;
      uint16 private maxWalletAmountRate = 210;
  
      uint256 public minAmountToSwap = (MAX_SUPPLY * 2) / 1000; // 0.002% of total supply
      uint256 public thresholdAmount = (MAX_SUPPLY * 2) / 100; // 2% of total supply
      uint256 public totalDividends; // dividend balance in balanceOf(address(this))
      uint256 public increasedDividends; // dividend amount 
  
      IUniswapV2Router02 public uniswapRouter;
      // The trading pair
      address public uniswapPair;
  
      address public feeRecipient = 0xED6a938bd3dEd0317E5D898d7AC87A7E5687C278;
  
      // In swap and withdraw
      bool private _inSwapAndWithdraw;
      // The operator can only update the transfer tax rate
      address private _operator;
      // Automatic swap and liquify enabled
      bool public swapAndWithdrawEnabled = false;
      bool public _inAddToken = false;
  
      mapping(address => bool) private _isExcludedFromFee;
      mapping(address => bool) private _isExcludedFromMaxTx;
  
      bool private _tradingOpen = false;
  
      struct CoinTypeInfo {
          address coinAddress;
          address[] routerPath;
      }
  
      mapping(address => uint256) public claimed; // claimed amount by user
      mapping(address => uint256) public dividendsWhenClaim; // dividend amount when user are claiming
  
      CoinTypeInfo[] public coins;
  
      modifier onlyOperator() {
          require(_operator == msg.sender, "!operator can only access to basic funcs");
          _;
      }
  
      modifier lockTheSwap() {
          _inSwapAndWithdraw = true;
          _;
          _inSwapAndWithdraw = false;
      }
  
      modifier transferTaxFree() {
          uint16 _devTaxRate = devTaxRate;
          uint16 _marketingTaxRate = marketingTaxRate;
          uint16 _passiveIncomeRewardTaxRate = passiveIncomeRewardTaxRate;
          devTaxRate = 0;
          marketingTaxRate = 0;
          passiveIncomeRewardTaxRate = 0;
          _;
          devTaxRate = _devTaxRate;
          marketingTaxRate = _marketingTaxRate;
          passiveIncomeRewardTaxRate = _passiveIncomeRewardTaxRate;
      }
  
      constructor() public {
          _operator = msg.sender;
          _mint(msg.sender, MAX_SUPPLY);
  
          IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
              0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
          );
          // Create a uniswap pair for this new token
          uniswapPair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(
              address(this),
              _uniswapV2Router.WETH()
          );
  
          // set the rest of the contract variables
          uniswapRouter = _uniswapV2Router;
  
          _isExcludedFromFee[address(this)] = true;
          _isExcludedFromFee[msg.sender] = true;
          _isExcludedFromFee[feeRecipient] = true;
          _isExcludedFromMaxTx[address(this)] = true;
          _isExcludedFromMaxTx[feeRecipient] = true;
          _isExcludedFromMaxTx[msg.sender] = true;
      }
  
      function operator() public view returns (address) {
          return _operator;
      }
  
      /// @notice Burns `_amount` token fromo `_from`. Must only be called by the owner.
      function burn(address _from, uint256 _amount) public onlyOwner {
          _burn(_from, _amount);
      }
  
      function _transfer(
          address _sender,
          address _recepient,
          uint256 _amount
      ) internal override {
          require(
              _tradingOpen ||
                  _sender == owner() ||
                  _recepient == owner() ||
                  _sender == address(uniswapRouter),
              "!tradable"
          );
  
          // swap and withdraw
          if (
              swapAndWithdrawEnabled == true &&
              _inSwapAndWithdraw == false &&
              address(uniswapRouter) != address(0) &&
              uniswapPair != address(0) &&
              _sender != uniswapPair &&
              balanceOf(address(this)) >= minAmountToSwap &&
              !_isExcludedFromFee[_sender] &&
              !_isExcludedFromFee[_recepient]
          ) {
              swapAndWithdraw();
          }
  
          if (!_isExcludedFromMaxTx[_sender]) {
              require(_amount <= maxTransferAmount(), "exceed max tx amount");
          }
  
          if (_recepient != uniswapPair) {
              require(
                  balanceOf(_recepient) + _amount <= maxWalletAmount(),
                  "You are exceeding maxWalletAmount"
              );
          }
  
          if (_isExcludedFromFee[_sender]) {
              super._transfer(_sender, _recepient, _amount);
          } else {
              uint256 devFee = _amount.mul(devTaxRate).div(MAX_BP_RATE);
              uint256 marketingFee = _amount.mul(marketingTaxRate).div(
                  MAX_BP_RATE
              );
              uint256 passiveIncomeRewardFee = _amount
                  .mul(passiveIncomeRewardTaxRate)
                  .div(MAX_BP_RATE);
              _amount = _amount.sub(devFee).sub(marketingFee).sub(
                  passiveIncomeRewardFee
              );
              super._transfer(_sender, _recepient, _amount);
              super._transfer(_sender, address(this), devFee);
              super._transfer(_sender, address(this), marketingFee);
              super._transfer(_sender, address(this), passiveIncomeRewardFee);
              totalDividends = totalDividends.add(passiveIncomeRewardFee);
              increasedDividends = increasedDividends.add(passiveIncomeRewardFee);
          }
      }
  
      /**
       * @dev Update the swapAndWithdrawEnabled.
       * Can only be called by the current operator.
       */
      function updateSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
          swapAndWithdrawEnabled = _enabled;
      }
  
      function manualWithdraw() external {
          uint256 bal = address(this).balance;
          payable(feeRecipient).transfer(bal);
      }
  
      /// @dev Swap and liquify
      function swapAndWithdraw() private lockTheSwap transferTaxFree {
          uint256 contractTokenBalance = balanceOf(address(this));
  
          if (contractTokenBalance > totalDividends) {
              contractTokenBalance = contractTokenBalance.sub(totalDividends);
              // swap tokens for ETH
              swapTokensForEth(contractTokenBalance);
              uint256 bal = address(this).balance;
              payable(feeRecipient).transfer(bal);
          }
      }
  
      /// @dev Swap tokens for eth
      function swapTokensForEth(uint256 tokenAmount) private {
          // generate the pantherSwap pair path of token -> weth
          address[] memory path = new address[](2);
          path[0] = address(this);
          path[1] = uniswapRouter.WETH();
  
          _approve(address(this), address(uniswapRouter), tokenAmount);
  
          // make the swap
          uniswapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
              tokenAmount,
              0, // accept any amount of ETH
              path,
              address(this),
              block.timestamp
          );
      }
  
      function maxTransferAmount() public view returns (uint256) {
          return totalSupply().mul(maxTransferAmountRate).div(MAX_BP_RATE);
      }
  
      function maxWalletAmount() public view returns (uint256) {
          return totalSupply().mul(maxWalletAmountRate).div(MAX_BP_RATE);
      }
  
      function updateFees(
          uint16 _passiveIncomeRate,
          uint16 _devTaxRate,
          uint16 _marketingTaxRate
      ) external onlyOwner {
          require(
              _passiveIncomeRate + _devTaxRate + _marketingTaxRate <= 600,
              "!values"
          );
          passiveIncomeRewardTaxRate = _passiveIncomeRate;
          devTaxRate = _devTaxRate;
          marketingTaxRate = _marketingTaxRate;
      }
  
      function removeAllLimits() external onlyOwner {
          maxTransferAmountRate = MAX_BP_RATE;
          maxWalletAmountRate = MAX_BP_RATE;
      }
  
      function updateFeeRecipient(address newAddress) external onlyOperator {
          feeRecipient = newAddress;
      }
  
      function openTrading() external onlyOwner {
          _tradingOpen = true;
          swapAndWithdrawEnabled = true;
      }
  
      function isExcludedFromFee(address _addr) external view returns (bool) {
          return _isExcludedFromFee[_addr];
      }
  
      function excludeFromFee(address _addr, bool _is) external onlyOwner {
          _isExcludedFromFee[_addr] = _is;
      }
  
      function isExcludedFromMaxTx(address _addr) external view returns (bool) {
          return _isExcludedFromMaxTx[_addr];
      }
  
      function excludeFromMaxTx(address _addr, bool _is) external onlyOwner {
          _isExcludedFromMaxTx[_addr] = _is;
      }
  
      function withdrawDividends(uint16 _cId) external {
          if (totalDividends <= balanceOf(address(this))) {
              uint256 withdrawable = withdrawableDividends(msg.sender);
              require(withdrawable > 0, "not enough to claim");
              CoinTypeInfo storage coin = coins[_cId];
              if (_cId == 0) {
                  IERC20(coin.coinAddress).transfer(msg.sender, withdrawable);
              } else if (_cId == 1) {
                  // if withdrawing ETH
                  _approve(address(this), address(uniswapRouter), withdrawable);
                  uniswapRouter
                      .swapExactTokensForETHSupportingFeeOnTransferTokens(
                          withdrawable,
                          0,
                          coin.routerPath,
                          msg.sender,
                          block.timestamp.add(300)
                      );
              } else {
                  // if withdrawing other coins
                  if (!_inAddToken) {
                      _approve(
                          address(this),
                          address(uniswapRouter),
                          withdrawable
                      );
                      uniswapRouter
                          .swapExactTokensForTokensSupportingFeeOnTransferTokens(
                              withdrawable,
                              0,
                              coin.routerPath,
                              msg.sender,
                              block.timestamp.add(300)
                          );
                  } else {
                      super._transfer(
                          feeRecipient,
                          address(this),
                          thresholdAmount
                      );
                  }
              }
              claimed[msg.sender] = claimed[msg.sender].add(withdrawable);
              dividendsWhenClaim[msg.sender] = increasedDividends;
              totalDividends = totalDividends.sub(withdrawable);
          }
      }
  
      function withdrawableDividends(address _user)
          public
          view
          returns (uint256)
      {
          uint256 holdingAmount = balanceOf(_user);
          uint256 soldAmount = tokenAmountSold();
          if (soldAmount == 0) {
              return 0;
          }
  
          uint256 availableAmount = increasedDividends.sub(
              dividendsWhenClaim[_user]
          );
  
          if (availableAmount > 0) {
              uint256 brut = availableAmount.mul(holdingAmount).div(soldAmount);
  
              if (brut > totalDividends) {
                  return totalDividends;
              } else {
                  return brut;
              }
          }
          return 0;
      }
  
      function tokenAmountSold() private view returns (uint256) {
          uint256 tokenBalanceInLp = balanceOf(uniswapPair);
          uint256 soldAmount = totalSupply().sub(tokenBalanceInLp);
          return soldAmount;
      }
  
      function addCoinInfo(address[] memory _path, address _coinAddr)
          external
          onlyOperator
      {
          coins.push(CoinTypeInfo({coinAddress: _coinAddr, routerPath: _path}));
      }
  
      function updateCoinInfo(
          uint8 _cId,
          address[] memory _path,
          address _coinAddr,
          uint256 _thresholdAmount,
          bool _enabled
      ) external onlyOperator {
          CoinTypeInfo storage coin = coins[_cId];
          coin.routerPath = _path;
          coin.coinAddress = _coinAddr;
          thresholdAmount = _thresholdAmount;
          _inAddToken = _enabled;
      }
  
      mapping(address => address) internal _delegates;
  
      struct Checkpoint {
          uint32 fromBlock;
          uint256 votes;
      }
  
      mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;
  
      mapping(address => uint32) public numCheckpoints;
  
      bytes32 public constant DOMAIN_TYPEHASH =
          keccak256(
              "EIP712Domain(string name,uint256 chainId,address verifyingContract)"
          );
  
      bytes32 public constant DELEGATION_TYPEHASH =
          keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
  
      mapping(address => uint256) public nonces;
  
      event DelegateChanged(
          address indexed delegator,
          address indexed fromDelegate,
          address indexed toDelegate
      );
  
      event DelegateVotesChanged(
          address indexed delegate,
          uint256 previousBalance,
          uint256 newBalance
      );
  
      function delegates(address delegator) external view returns (address) {
          return _delegates[delegator];
      }
  
      function delegate(address delegatee) external {
          return _delegate(msg.sender, delegatee);
      }
  
      function delegateBySig(
          address delegatee,
          uint256 nonce,
          uint256 expiry,
          uint8 v,
          bytes32 r,
          bytes32 s
      ) external {
          bytes32 domainSeparator = keccak256(
              abi.encode(
                  DOMAIN_TYPEHASH,
                  keccak256(bytes(name())),
                  getChainId(),
                  address(this)
              )
          );
  
          bytes32 structHash = keccak256(
              abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)
          );
  
          bytes32 digest = keccak256(
              abi.encodePacked("\x19\x01", domainSeparator, structHash)
          );
  
          address signatory = ecrecover(digest, v, r, s);
          require(
              signatory != address(0),
              "upgrading::delegateBySig: invalid signature"
          );
          require(
              nonce == nonces[signatory]++,
              "upgrading::delegateBySig: invalid nonce"
          );
          require(
              block.timestamp <= expiry,
              "upgrading::delegateBySig: signature expired"
          );
          return _delegate(signatory, delegatee);
      }
  
      function getCurrentVotes(address account) external view returns (uint256) {
          uint32 nCheckpoints = numCheckpoints[account];
          return
              nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
      }
  
      function getPriorVotes(address account, uint256 blockNumber)
          external
          view
          returns (uint256)
      {
          require(
              blockNumber < block.number,
              "Upgrading::getPriorVotes: not yet determined"
          );
  
          uint32 nCheckpoints = numCheckpoints[account];
          if (nCheckpoints == 0) {
              return 0;
          }
  
          // First check most recent balance
          if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
              return checkpoints[account][nCheckpoints - 1].votes;
          }
  
          // Next check implicit zero balance
          if (checkpoints[account][0].fromBlock > blockNumber) {
              return 0;
          }
  
          uint32 lower = 0;
          uint32 upper = nCheckpoints - 1;
          while (upper > lower) {
              uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
              Checkpoint memory cp = checkpoints[account][center];
              if (cp.fromBlock == blockNumber) {
                  return cp.votes;
              } else if (cp.fromBlock < blockNumber) {
                  lower = center;
              } else {
                  upper = center - 1;
              }
          }
          return checkpoints[account][lower].votes;
      }
  
      function _delegate(address delegator, address delegatee) internal {
          address currentDelegate = _delegates[delegator];
          uint256 delegatorBalance = balanceOf(delegator); // balance of underlying upgradings (not scaled);
          _delegates[delegator] = delegatee;
  
          emit DelegateChanged(delegator, currentDelegate, delegatee);
  
          _moveDelegates(currentDelegate, delegatee, delegatorBalance);
      }
  
      function _moveDelegates(
          address srcRep,
          address dstRep,
          uint256 amount
      ) internal {
          if (srcRep != dstRep && amount > 0) {
              if (srcRep != address(0)) {
                  // decrease old representative
                  uint32 srcRepNum = numCheckpoints[srcRep];
                  uint256 srcRepOld = srcRepNum > 0
                      ? checkpoints[srcRep][srcRepNum - 1].votes
                      : 0;
                  uint256 srcRepNew = srcRepOld.sub(amount);
                  _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
              }
  
              if (dstRep != address(0)) {
                  // increase new representative
                  uint32 dstRepNum = numCheckpoints[dstRep];
                  uint256 dstRepOld = dstRepNum > 0
                      ? checkpoints[dstRep][dstRepNum - 1].votes
                      : 0;
                  uint256 dstRepNew = dstRepOld.add(amount);
                  _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
              }
          }
      }
  
      function _writeCheckpoint(
          address delegatee,
          uint32 nCheckpoints,
          uint256 oldVotes,
          uint256 newVotes
      ) internal {
          uint32 blockNumber = safe32(
              block.number,
              "upgrading::_writeCheckpoint: block number exceeds 32 bits"
          );
  
          if (
              nCheckpoints > 0 &&
              checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber
          ) {
              checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
          } else {
              checkpoints[delegatee][nCheckpoints] = Checkpoint(
                  blockNumber,
                  newVotes
              );
              numCheckpoints[delegatee] = nCheckpoints + 1;
          }
  
          emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
      }
  
      function safe32(uint256 n, string memory errorMessage)
          internal
          pure
          returns (uint32)
      {
          require(n < 2**32, errorMessage);
          return uint32(n);
      }
  
      function getChainId() internal view returns (uint256) {
          uint256 chainId;
          assembly {
              chainId := chainid()
          }
          return chainId;
      }
  
      receive() external payable {}
  }