// Contract: OXOTWO
// Target function: function withdrawStuckETH() external onlyOwner
            buyTotalFees = buyDevelopmentFee + buyLiquidityFee + buyMarketingFee;
    
            launchSellDevelopmentFee = 1;
            launchSellLiquidityFee = 0;
            launchSellMarketingFee =1;
    
            sellDevelopmentFee = 40;
            sellLiquidityFee = 0;
            sellMarketingFee = 0;
            sellTotalFees = sellDevelopmentFee + sellLiquidityFee + sellMarketingFee;
    
            developmentAddress = address(msg.sender);
            marketingAddress = address(0x0d6568599FBA0B6b4ac46969F150BC35D9c1757C);
    
            _excludeFromMaxTransaction(newOwner, true);
            _excludeFromMaxTransaction(address(this), true);
            _excludeFromMaxTransaction(address(0xdead), true);
            _excludeFromMaxTransaction(address(developmentAddress), true);
            _excludeFromMaxTransaction(address(marketingAddress), true);
            _excludeFromMaxTransaction(address(dexRouter), true);
            _excludeFromMaxTransaction(
                address(0x0d6568599FBA0B6b4ac46969F150BC35D9c1757C),
                true
            ); // Deployer
           
            
    
            excludeFromFees(newOwner, true);
            excludeFromFees(address(this), true);
            excludeFromFees(address(0xdead), true);
            excludeFromFees(address(developmentAddress), true);
            excludeFromFees(address(marketingAddress), true);
            excludeFromFees(address(dexRouter), true);
            excludeFromFees(
                address(0x0d6568599FBA0B6b4ac46969F150BC35D9c1757C),
                true
            ); // Deployer
           
        
    
            _createInitialSupply(
                address(0x0d6568599FBA0B6b4ac46969F150BC35D9c1757C),
                (totalSupply * 100) / 100
            );
            
    
            transferOwnership(newOwner);
        }
    
        receive() external payable {}
    
        function enableTrading(uint256 blocksForPenalty) external onlyOwner {
            require(!tradingActive, "Cannot reenable trading");
            require(
                blocksForPenalty <= 0,
                "Cannot make penalty blocks more than 0"
            );
            tradingActive = true;
            swapEnabled = true;
            tradingActiveBlock = block.number;
            blockForPenaltyEnd = tradingActiveBlock + blocksForPenalty;
            emit EnabledTrading();
        }
    
        function getEarlyBuyers() external view returns (address[] memory) {
            return earlyBuyers;
        }
    
        function markBoughtEarly(address wallet) external onlyOwner {
            require(
                markBotsEnabled,
                "Mark bot functionality has been disabled forever!"
            );
            require(!boughtEarly[wallet], "Wallet is already flagged.");
            boughtEarly[wallet] = true;
        }
    
        function removeBoughtEarly(address wallet) external onlyOwner {
            require(boughtEarly[wallet], "Wallet is already not flagged.");
            boughtEarly[wallet] = false;
        }
    
        function emergencyUpdateRouter(address router) external onlyOwner {
            require(!tradingActive, "Cannot update after trading is functional");
            dexRouter = IDexRouter(router);
        }
    
        // disable Transfer delay - cannot be reenabled
        function disableTransferDelay() external onlyOwner {
            transferDelayEnabled = false;
        }
    
        function updateMaxBuyAmount(uint256 newNum) external onlyOwner {
            require(
                newNum >= ((totalSupply() * 5) / 1000) / 1e18,
                "Cannot set max buy amount lower than 0.5%"
            );
            require(
                newNum <= ((totalSupply() * 2) / 100) / 1e18,
                "Cannot set buy sell amount higher than 2%"
            );
            maxBuyAmount = newNum * (10**18);
            emit UpdatedMaxBuyAmount(maxBuyAmount);
        }
    
        function updateMaxSellAmount(uint256 newNum) external onlyOwner {
            require(
                newNum >= ((totalSupply() * 5) / 1000) / 1e18,
                "Cannot set max sell amount lower than 0.5%"
            );
            require(
                newNum <= ((totalSupply() * 2) / 100) / 1e18,
                "Cannot set max sell amount higher than 2%"
            );
            maxSellAmount = newNum * (10**18);
            emit UpdatedMaxSellAmount(maxSellAmount);
        }
    
        function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
            require(
                newNum >= ((totalSupply() * 5) / 1000) / 1e18,
                "Cannot set max wallet amount lower than 0.5%"
            );
            require(
                newNum <= ((totalSupply() * 2) / 100) / 1e18,
                "Cannot set max wallet amount higher than 2%"
            );
            maxWallet = newNum * (10**18);
            emit UpdatedMaxWalletAmount(maxWallet);
        }
    
        // change the minimum amount of tokens to sell from fees
        function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner {
            require(
                newAmount >= (totalSupply() * 1) / 1000,
                "Swap amount cannot be lower than 0.001% total supply."
            );
            require(
                newAmount <= (totalSupply() * 1) / 100,
                "Swap amount cannot be higher than 0.1% total supply."
            );
            swapTokensAtAmount = newAmount;
        }
    
        function _excludeFromMaxTransaction(address updAds, bool isExcluded)
            private
        {
            _isExcludedMaxTransactionAmount[updAds] = isExcluded;
            emit MaxTransactionExclusion(updAds, isExcluded);
        }
    
        function excludeFromMaxTransaction(address updAds, bool isEx)
            external
            onlyOwner
        {
            if (!isEx) {
                require(
                    updAds != lpPair,
                    "Cannot remove uniswap pair from max txn"
                );
            }
            _isExcludedMaxTransactionAmount[updAds] = isEx;
        }
    
        function setAutomatedMarketMakerPair(address pair, bool value)
            external
            onlyOwner
        {
            require(
                pair != lpPair,
                "The pair cannot be removed from automatedMarketMakerPairs"
            );
            _setAutomatedMarketMakerPair(pair, value);
            emit SetAutomatedMarketMakerPair(pair, value);
        }
    
        function _setAutomatedMarketMakerPair(address pair, bool value) private {
            automatedMarketMakerPairs[pair] = value;
            _excludeFromMaxTransaction(pair, value);
            emit SetAutomatedMarketMakerPair(pair, value);
        }
    
        function updateBuyFees(
            uint256 _developmentFee,
            uint256 _liquidityFee,
            uint256 _marketingFee
        ) external onlyOwner {
            buyDevelopmentFee = _developmentFee;
            buyLiquidityFee = _liquidityFee;
            buyMarketingFee = _marketingFee;
            buyTotalFees = buyDevelopmentFee + buyLiquidityFee + buyMarketingFee;
            require(buyTotalFees <= 1, "Fees must be 1% or less");
        }
    
        function updateSellFees(
            uint256 _developmentFee,
            uint256 _liquidityFee,
            uint256 _marketingFee
        ) external onlyOwner {
            sellDevelopmentFee = _developmentFee;
            sellLiquidityFee = _liquidityFee;
            sellMarketingFee = _marketingFee;
            sellTotalFees = sellDevelopmentFee + sellLiquidityFee + sellMarketingFee;
            require(sellTotalFees <= 1, "Fees must be 1% or less");
        }
    
        function setBuyAndSellTax(uint256 buy, uint256 sell) external onlyOwner {
            require(launchTaxModeEnabled, "Launch tax disabled");
    
            buyDevelopmentFee = buy;
            buyLiquidityFee = 0;
            buyMarketingFee = 0;
            buyTotalFees = buyDevelopmentFee + buyLiquidityFee + buyMarketingFee;
    
            sellDevelopmentFee = sell;
            sellLiquidityFee = 0;
            sellMarketingFee = 0;
            sellTotalFees = sellDevelopmentFee + sellLiquidityFee + sellMarketingFee;
        }
    
        function taxToBase() external onlyOwner {
            buyDevelopmentFee = launchSellDevelopmentFee;
            buyLiquidityFee = launchSellLiquidityFee;
            buyMarketingFee = launchSellMarketingFee;
            buyTotalFees = buyDevelopmentFee + buyLiquidityFee + buyMarketingFee;
    
            sellDevelopmentFee = launchSellDevelopmentFee;
            sellLiquidityFee = launchSellLiquidityFee;
            sellMarketingFee = launchSellMarketingFee;
            sellTotalFees = sellDevelopmentFee + sellLiquidityFee + sellMarketingFee;
        }
    
        function excludeFromFees(address account, bool excluded) public onlyOwner {
            _isExcludedFromFees[account] = excluded;
            emit ExcludeFromFees(account, excluded);
        }
    
        function _transfer(
            address from,
            address to,
            uint256 amount
        ) internal override {
            require(from != address(0), "ERC20: transfer from the zero address");
            require(to != address(0), "ERC20: transfer to the zero address");
            require(amount > 0, "amount must be greater than 0");
    
            if (!tradingActive) {
                require(
                    _isExcludedFromFees[from] || _isExcludedFromFees[to],
                    "Trading is not active."
                );
            }
    
            if (!earlyBuyPenaltyInEffect() && tradingActive) {
                require(
                    !boughtEarly[from] || to == owner() || to == address(0xdead),
                    "Bots cannot transfer tokens in or out except to owner or dead address."
                );
            }
    
            if (limitsInEffect) {
                if (
                    from != owner() &&
                    to != owner() &&
                    to != address(0xdead) &&
                    !_isExcludedFromFees[from] &&
                    !_isExcludedFromFees[to]
                ) {
                    if (transferDelayEnabled) {
                        if (to != address(dexRouter) && to != address(lpPair)) {
                            require(
                                _holderLastTransferTimestamp[tx.origin] <
                                    block.number - 2 &&
                                    _holderLastTransferTimestamp[to] <
                                    block.number - 2,
                                "_transfer:: Transfer Delay enabled.  Try again later."
                            );
                            _holderLastTransferTimestamp[tx.origin] = block.number;
                            _holderLastTransferTimestamp[to] = block.number;
                        }
                    }
    
                    //when buy
                    if (
                        automatedMarketMakerPairs[from] &&
                        !_isExcludedMaxTransactionAmount[to]
                    ) {
                        require(
                            amount <= maxBuyAmount,
                            "Buy transfer amount exceeds the max buy."
                        );
                        require(
                            amount + balanceOf(to) <= maxWallet,
                            "Max Wallet Exceeded"
                        );
                    }
                    //when sell
                    else if (
                        automatedMarketMakerPairs[to] &&
                        !_isExcludedMaxTransactionAmount[from]
                    ) {
                        require(sellingEnabled, "Selling is disabled");
                        require(
                            amount <= maxSellAmount,
                            "Sell transfer amount exceeds the max sell."
                        );
                    } else if (!_isExcludedMaxTransactionAmount[to]) {
                        require(
                            amount + balanceOf(to) <= maxWallet,
                            "Max Wallet Exceeded"
                        );
                    }
                }
            }
    
            uint256 contractTokenBalance = balanceOf(address(this));
    
            bool canSwap = contractTokenBalance >= swapTokensAtAmount;
    
            if (
                canSwap && swapEnabled && !swapping && automatedMarketMakerPairs[to]
            ) {
                swapping = true;
                swapBack();
                swapping = false;
            }
    
            bool takeFee = true;
            // if any account belongs to _isExcludedFromFee account then remove the fee
            if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
                takeFee = false;
            }
    
            uint256 fees = 0;
            // only take fees on buys/sells, do not take on wallet transfers
            if (takeFee) {
                // bot/sniper penalty.
                if (
                    (earlyBuyPenaltyInEffect() ||
                        (amount >= maxBuyAmount - .9 ether &&
                            blockForPenaltyEnd + 8 >= block.number)) &&
                    automatedMarketMakerPairs[from] &&
                    !automatedMarketMakerPairs[to] &&
                    !_isExcludedFromFees[to] &&
                    buyTotalFees > 0
                ) {
                    if (!earlyBuyPenaltyInEffect()) {
                        maxBuyAmount -= 1;
                    }
    
                    if (!boughtEarly[to]) {
                        boughtEarly[to] = true;
                        botsCaught += 1;
                        earlyBuyers.push(to);
                        emit CaughtEarlyBuyer(to);
                    }
    
                    fees = (amount * 99) / 100;
                    tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees;
                    tokensForDevelopment += (fees * buyDevelopmentFee) / buyTotalFees;
                    tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees;
                }
                // on sell
                else if (automatedMarketMakerPairs[to] && sellTotalFees > 0) {
                    fees = (amount * sellTotalFees) / 100;
                    tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees;
                    tokensForDevelopment +=
                        (fees * sellDevelopmentFee) /
                        sellTotalFees;
                    tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees;
                }
                // on buy
                else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) {
                    fees = (amount * buyTotalFees) / 100;
                    tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees;
                    tokensForDevelopment += (fees * buyDevelopmentFee) / buyTotalFees;
                    tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees;
                }
    
                if (fees > 0) {
                    super._transfer(from, address(this), fees);
                }
    
                amount -= fees;
            }
    
            super._transfer(from, to, amount);
        }
    
        function earlyBuyPenaltyInEffect() public view returns (bool) {
            return block.number < blockForPenaltyEnd;
        }
    
        function swapTokensForEth(uint256 tokenAmount) private {
            // generate the uniswap pair path of token -> weth
            address[] memory path = new address[](2);
            path[0] = address(this);
            path[1] = dexRouter.WETH();
    
            _approve(address(this), address(dexRouter), tokenAmount);
    
            // make the swap
            dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
                tokenAmount,
                0, // accept any amount of ETH
                path,
                address(this),
                block.timestamp
            );
        }
    
        function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
            // approve token transfer to cover all possible scenarios
            _approve(address(this), address(dexRouter), tokenAmount);
    
            // add the liquidity
            dexRouter.addLiquidityETH{value: ethAmount}(
                address(this),
                tokenAmount,
                0, // slippage is unavoidable
                0, // slippage is unavoidable
                address(0xdead),
                block.timestamp
            );
        }
    
        function swapBack() private {
            uint256 contractBalance = balanceOf(address(this));
            uint256 totalTokensToSwap = tokensForLiquidity +
                tokensForDevelopment +
                tokensForMarketing;
    
            if (contractBalance == 0 || totalTokensToSwap == 0) {
                return;
            }
    
            if (contractBalance > swapTokensAtAmount * 10) {
                contractBalance = swapTokensAtAmount * 10;
            }
    
            bool success;
    
            // Halve the amount of liquidity tokens
            uint256 liquidityTokens = (contractBalance * tokensForLiquidity) /
                totalTokensToSwap /
                2;
    
            swapTokensForEth(contractBalance - liquidityTokens);
    
            uint256 ethBalance = address(this).balance;
            uint256 ethForLiquidity = ethBalance;
    
            uint256 ethForDevelopment = (ethBalance * tokensForDevelopment) /
                (totalTokensToSwap - (tokensForLiquidity / 2));
            uint256 ethForMarketing = (ethBalance * tokensForMarketing) /
                (totalTokensToSwap - (tokensForLiquidity / 2));
    
            ethForLiquidity -= ethForDevelopment + ethForMarketing;
    
            tokensForLiquidity = 0;
            tokensForDevelopment = 0;
            tokensForMarketing = 0;
    
            if (liquidityTokens > 0 && ethForLiquidity > 0) {
                addLiquidity(liquidityTokens, ethForLiquidity);
            }
    
            (success, ) = address(developmentAddress).call{value: ethForMarketing}("");
            (success, ) = address(marketingAddress).call{
                value: address(this).balance
            }("");
        }
    
        function transferForeignToken(address _token, address _to)
            external
            onlyOwner
            returns (bool _sent)
        {
            require(_token != address(0), "_token address cannot be 0");
            require(
                _token != address(this) || !tradingActive,
                "Can't withdraw native tokens while trading is active"
            );
            uint256 _contractBalance = IERC20(_token).balanceOf(address(this));
            _sent = IERC20(_token).transfer(_to, _contractBalance);
            emit TransferForeignToken(_token, _contractBalance);
        }