// 

/**

███╗   ███╗ ██████╗  ██████╗ ███╗   ██╗███████╗██╗     ██╗██████╗  ██████╗ ██████╗  ██████╗       ██╗    ██╗       █████╗ ██╗    ██████╗ ███████╗██╗  ██╗
████╗ ████║██╔═══██╗██╔═══██╗████╗  ██║██╔════╝██║     ██║██╔══██╗██╔═══██╗██╔══██╗██╔════╝      ██╔╝    ╚██╗     ██╔══██╗██║    ██╔══██╗██╔════╝╚██╗██╔╝
██╔████╔██║██║   ██║██║   ██║██╔██╗ ██║█████╗  ██║     ██║██████╔╝██║   ██║██████╔╝██║  ███╗    ██╔╝█████╗╚██╗    ███████║██║    ██║  ██║█████╗   ╚███╔╝ 
██║╚██╔╝██║██║   ██║██║   ██║██║╚██╗██║██╔══╝  ██║     ██║██╔═══╝ ██║   ██║██╔══██╗██║   ██║    ╚██╗╚════╝██╔╝    ██╔══██║██║    ██║  ██║██╔══╝   ██╔██╗ 
██║ ╚═╝ ██║╚██████╔╝╚██████╔╝██║ ╚████║██║     ███████╗██║██║██╗  ╚██████╔╝██║  ██║╚██████╔╝     ╚██╗    ██╔╝     ██║  ██║██║    ██████╔╝███████╗██╔╝ ██╗
╚═╝     ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═══╝╚═╝     ╚══════╝╚═╝╚═╝╚═╝   ╚═════╝ ╚═╝  ╚═╝ ╚═════╝       ╚═╝    ╚═╝      ╚═╝  ╚═╝╚═╝    ╚═════╝ ╚══════╝╚═╝  ╚═╝
                                                                                                                                                           
   
   */                                                                       

// 

// 

// SPDX-License-Identifier:MIT
pragma solidity ^0.8.22;

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
    );
}

// Dex Factory contract interface
interface IDexFactory {
    function createPair(
        address tokenA,
        address tokenB
    ) external returns (address pair);
}

// Dex Router contract interface
interface IDexRouter {
    function factory() external pure returns (address);

    function WETH() external pure returns (address);

    function addLiquidityETH(
        address token,
        uint256 amountTokenDesired,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    )
        external
        payable
        returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);

    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;
}

abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return payable(msg.sender);
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(
        address indexed previousOwner,
        address indexed newOwner
    );

    constructor() {
        _owner = _msgSender();
        emit OwnershipTransferred(address(0), _owner);
    }

    function owner() public view returns (address) {
        return _owner;
    }

    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = payable(address(0));
    }

    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(
            newOwner != address(0),
            "Ownable: new owner is the zero address"
        );
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

contract Moon_Flip is Context, IERC20, Ownable {
    using SafeMath for uint256;

    mapping(address => uint256) private _balances;
    mapping(address => mapping(address => uint256)) private _allowances;
    mapping(address => bool) public isBot;

    string private _name = "Moon Flip";
    string private _symbol = "MFL";
    uint8 private _decimals = 18;
    uint256 private _totalSupply = 700_000_000 * 1e18;

    address public dexPair;
    uint256 public snipingTime = 100 seconds;
    uint256 public launchedAt;

    bool public trading; // once enable can't be disable afterwards

    event SwapAndLiquify(
        uint256 tokensSwapped,
        uint256 ethReceived,
        uint256 tokensIntoLiqudity
    );

    constructor() {
        _balances[owner()] = _totalSupply;
        emit Transfer(address(0), owner(), _totalSupply);
    }

    //to receive ETH from dexRouter when swapping
    receive() external payable {}

    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 _totalSupply;
    }

    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,
                "MFL: transfer amount exceeds allowance"
            )
        );
        return true;
    }

    function increaseAllowance(
        address spender,
        uint256 addedValue
    ) public virtual returns (bool) {
        _approve(
            _msgSender(),
            spender,
            _allowances[_msgSender()][spender].add(addedValue)
        );
        return true;
    }

    function decreaseAllowance(
        address spender,
        uint256 subtractedValue
    ) public virtual returns (bool) {
        _approve(
            _msgSender(),
            spender,
            _allowances[_msgSender()][spender].sub(
                subtractedValue,
                "MFL: decreased allowance or below zero"
            )
        );
        return true;
    }

    function addOrRemoveBots(address account, bool state) external onlyOwner {
        isBot[account] = state;
    }

    function removeStuckEth(address _receiver) public onlyOwner {
        payable(_receiver).transfer(address(this).balance);
    }

    function setPair(address _pair) public onlyOwner {
        dexPair = _pair;
    }

    function enableTrading() external onlyOwner {
        require(!trading, "MFL: already enabled");
        trading = true;
        launchedAt = block.timestamp;
    }

    function _approve(address owner, address spender, uint256 amount) private {
        require(owner != address(0), "MFL: approve from the zero address");
        require(spender != address(0), "MFL: approve to 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), "MFL: transfer from the zero address");
        require(to != address(0), "MFL: transfer to the zero address");
        require(amount > 0, "MFL: Amount must be greater than zero");
        require(!isBot[from], "MFL: Bot detected");

        if (from != owner() && to != owner()) {
            // trading disable till launch
            require(trading, "MFL: trading is disable");
            // antibot
            if (
                block.timestamp < launchedAt + snipingTime
            ) {
                if (dexPair == from) {
                    isBot[to] = true;
                } else if (dexPair == to) {
                    isBot[from] = true;
                }
            }
        }

        _balances[from] = _balances[from].sub(
            amount,
            "MFL: insufficient balance"
        );
        _balances[to] = _balances[to].add(amount);

        emit Transfer(from, to, amount);
    }
}

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) {
        // 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 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;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}