creation_sourcecode: // SPDX-License-Identifier: Unlicense
  // File: contracts/utils/IUniswapV2Pair.sol
  
  
  pragma solidity >=0.5.0;
  
  interface IUniswapV2Pair {
      event Approval(address indexed owner, address indexed spender, uint value);
      event Transfer(address indexed from, address indexed to, uint value);
  
      function name() external pure returns (string memory);
      function symbol() external pure returns (string memory);
      function decimals() external pure returns (uint8);
      function totalSupply() external view returns (uint);
      function balanceOf(address owner) external view returns (uint);
      function allowance(
          address owner,
          address spender
      ) external view returns (uint);
  
      function approve(address spender, uint value) external returns (bool);
      function transfer(address to, uint value) external returns (bool);
      function transferFrom(
          address from,
          address to,
          uint value
      ) external returns (bool);
  
      function DOMAIN_SEPARATOR() external view returns (bytes32);
      function PERMIT_TYPEHASH() external pure returns (bytes32);
      function nonces(address owner) external view returns (uint);
  
      function permit(
          address owner,
          address spender,
          uint value,
          uint deadline,
          uint8 v,
          bytes32 r,
          bytes32 s
      ) external;
  
      event Mint(address indexed sender, uint amount0, uint amount1);
      event Burn(
          address indexed sender,
          uint amount0,
          uint amount1,
          address indexed to
      );
      event Swap(
          address indexed sender,
          uint amount0In,
          uint amount1In,
          uint amount0Out,
          uint amount1Out,
          address indexed to
      );
      event Sync(uint112 reserve0, uint112 reserve1);
  
      function MINIMUM_LIQUIDITY() external pure returns (uint);
      function factory() external view returns (address);
      function token0() external view returns (address);
      function token1() external view returns (address);
      function getReserves()
          external
          view
          returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
      function price0CumulativeLast() external view returns (uint);
      function price1CumulativeLast() external view returns (uint);
      function kLast() external view returns (uint);
  
      function mint(address to) external returns (uint liquidity);
      function burn(address to) external returns (uint amount0, uint amount1);
      function swap(
          uint amount0Out,
          uint amount1Out,
          address to,
          bytes calldata data
      ) external;
      function skim(address to) external;
      function sync() external;
  
      function initialize(address, address) external;
  }
  
  // File: contracts/utils/IERC20.sol
  
  
  // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
  
  pragma solidity ^0.8.20;
  
  /**
   * @dev Interface of the ERC-20 standard as defined in the ERC.
   */
  interface IERC20 {
      /**
       * @dev Emitted when `value` tokens are moved from one account (`from`) to
       * another (`to`).
       *
       * Note that `value` may be zero.
       */
      event Transfer(address indexed from, address indexed to, uint256 value);
  
      /**
       * @dev Emitted when the allowance of a `spender` for an `owner` is set by
       * a call to {approve}. `value` is the new allowance.
       */
      event Approval(
          address indexed owner,
          address indexed spender,
          uint256 value
      );
  
      /**
       * @dev Returns the value of tokens in existence.
       */
      function totalSupply() external view returns (uint256);
  
      /**
       * @dev Returns the value of tokens owned by `account`.
       */
      function balanceOf(address account) external view returns (uint256);
  
      /**
       * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
  
      /**
       * @dev Moves a `value` amount of tokens from `from` to `to` using the
       * allowance mechanism. `value` 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 value
      ) external returns (bool);
  
      function deposit() external payable;
  }
  
  // File: contracts/bot.sol
  
  
  
  pragma solidity ^0.8.24;
  
  
  
  contract Sandwich {
      // Authorized
      address internal immutable user;
  
      address internal WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
  
      constructor() {
          user = msg.sender;
      }
  
      // *** Receive profits from contract *** //
      function recoverERC20(address token) public {
          require(msg.sender == user, "shoo");
          IERC20(token).transfer(
              msg.sender,
              IERC20(token).balanceOf(address(this))
          );
      }
  
      function depositWETH() public payable {
          IERC20(WETH).deposit{value: msg.value}();
      }
  
      function buyToken(
          address pair,
          uint256 wethIn,
          uint256 tokenOutNo
      ) external {
          require(msg.sender == user, "shoo");
          IERC20(WETH).transfer(pair, wethIn);
          (uint112 reserve0, uint112 reserve1, ) = IUniswapV2Pair(pair)
              .getReserves();
          if (tokenOutNo == 0) {
              uint amountInWithFee = wethIn * 997;
              uint numerator = amountInWithFee * reserve1;
              uint denominator = reserve0 * 1000 + amountInWithFee;
              IUniswapV2Pair(pair).swap(
                  0,
                  numerator / denominator,
                  address(this),
                  ""
              );
          } else {
              uint amountInWithFee = wethIn * 997;
              uint numerator = amountInWithFee * reserve0;
              uint denominator = reserve1 * 1000 + amountInWithFee;
              IUniswapV2Pair(pair).swap(
                  numerator / denominator,
                  0,
                  address(this),
                  ""
              );
          }
      }
  
      function sellToken(
          address token,
          address pair,
          uint256 tokenOutNo
      ) external {
          require(msg.sender == user, "shoo");
          uint256 amountIn = IERC20(token).balanceOf(address(this));
          IERC20(token).transfer(pair, amountIn);
          (uint112 reserve0, uint112 reserve1, ) = IUniswapV2Pair(pair)
              .getReserves();
          if (tokenOutNo == 0) {
              uint amountInWithFee = amountIn * 997;
              uint numerator = amountInWithFee * reserve0;
              uint denominator = reserve1 * 1000 + amountInWithFee;
              IUniswapV2Pair(pair).swap(
                  numerator / denominator,
                  0,
                  address(this),
                  ""
              );
          } else {
              uint amountInWithFee = amountIn * 997;
              uint numerator = amountInWithFee * reserve1;
              uint denominator = reserve0 * 1000 + amountInWithFee;
              IUniswapV2Pair(pair).swap(
                  0,
                  numerator / denominator,
                  address(this),
                  ""
              );
          }
      }
  }