/**            
Bot:  https://t.me/incognitoeth_bot
Docs: https://docs.incognitoboteth.com/
Website: https://incognitoboteth.com/
Twitter: https://twitter.com/incognitoboteth
Telegram: https://t.me/incognitoboteth

**/

// SPDX-License-Identifier: MIT
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);
}

contract INCOG is IERC20 {
    address private _owner;
    string private _name = "Incognito Bot";
    uint8 private _decimals = 18;
    uint256 private _totalSupply = 100000000 * 10**18; // 100 million tokens
    string private _symbol = "INCOG";

    mapping(address => uint256) private _balances;
    mapping(address => mapping(address => uint256)) private _allowances;

    bool public tradingStarted = false;
    uint256 private _buyTax;
    uint256 private _sellTax;

    constructor() {
        _owner = msg.sender;
        _balances[msg.sender] = _totalSupply;
        emit Transfer(address(0), msg.sender, _totalSupply);
    }

    function totalSupply() public view override returns (uint256) {
        return _totalSupply;
    }

    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 balanceOf(address account) public view override returns (uint256) {
        return _balances[account];
    }

    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(msg.sender, spender, amount);
        return true;
    }

    function transfer(address recipient, uint256 amount) public override returns (bool) {
        _transfer(msg.sender, recipient, amount);
        return true;
    }

    function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, msg.sender, _allowances[sender][msg.sender] - amount);
        return true;
    }

    function _approve(address owner, address spender, uint256 amount) internal {
        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 _transfer(address sender, address recipient, uint256 amount) internal {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");
        require(amount > 0, "Transfer amount must be greater than zero");

        uint256 taxAmount;
        if (tradingStarted) {
            if (sender != _owner) {
                if (sender == address(this)) {
                    taxAmount = (amount * _sellTax) / 100;
                } else {
                    require(amount <= balanceOf(sender), "Insufficient balance");
                    taxAmount = (amount * _buyTax) / 100;
                }
            }
        } else {
            require(sender == _owner, "Trading has not started yet");
        }

        uint256 finalAmount = amount - taxAmount;

        _balances[sender] -= amount;
        _balances[recipient] += finalAmount;

        emit Transfer(sender, recipient, finalAmount);
        if (taxAmount > 0) {
            _balances[_owner] += taxAmount;
            emit Transfer(sender, _owner, taxAmount);
        }
    }

    function startTrading() public {
        require(msg.sender == _owner, "Only the owner can start trading");
        tradingStarted = true;
    }

    function setBuyTax(uint256 tax) public {
        require(msg.sender == _owner, "Only the owner can set the buy tax");
        require(tax <= 10, "Buy tax cannot exceed 10%");
        _buyTax = tax;
    }

    function setSellTax(uint256 tax) public {
        require(msg.sender == _owner, "Only the owner can set the sell tax");
        require(tax <= 10, "Sell tax cannot exceed 10%");
        _sellTax = tax;
    }

    function renounceOwnership() public {
        require(msg.sender == _owner, "Only the owner can renounce ownership");
        _owner = address(0);
    }
}