pragma solidity 0.8.17;






contract Token is ERC20, Ownable {
	using SafeMath for uint256;
	IUniswapV2Router02 private uniswapV2Router;
	address public uniswapV2Pair;
	address public tokenHolder = address(0x4475F70b104543F1274B2558384b894bCa8e8a64); // TBD;
	
	address public feeReceiver;
  
	mapping(address => bool) public blacklisted;
	mapping (address => bool) public isExcludedFromFee;
    mapping (address => bool) public isMarketingPairs;

	event BlacklistAdded(address indexed blacklistedAddress);
	event BlacklistRemoved(address indexed blacklistedAddress);
    event Log(string message);

	string private _name = 'Mortal Journey';
	string private _symbol = 'Mortjour';

	uint256 private maxSupply = 8000000000 * (10 ** 18);
	uint256 public minimumTokensBeforeSwap = maxSupply * 1 / 10000;
	uint256 private _buyTax = 0;
	uint256 private _sellTax = 20;
	bool public init = false;
	bool private onFees = true;
	bool private inSwap = false;
	bool public swapAndLiquifyByLimitOnly = false;
	
	modifier swapping() {
		inSwap = true;
		_;
		inSwap = false;
	}


	constructor(address _router) ERC20(_name, _symbol) {
		feeReceiver = owner();
		uniswapV2Router = IUniswapV2Router02(_router);
	
		uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(
		address(this),
		uniswapV2Router.WETH()
		);
		
		isExcludedFromFee[_msgSender()] = true;
        isExcludedFromFee[address(this)] = true;

        isMarketingPairs[uniswapV2Pair] = true;

		_mint(tokenHolder, maxSupply);
	}
  
	function addAddressToBlacklist(address _address) external onlyOwner {
		blacklisted[_address] = true;
		emit BlacklistAdded(_address);
	}

	function removeAddressFromBlacklist(address _address) external onlyOwner {
		blacklisted[_address] = false;
		emit BlacklistRemoved(_address);
	}

	function isBlacklisted(address _address) public view returns (bool) {
		return blacklisted[_address];
	}
  
	function autoFees() internal {
		// tax become 5 minute after 5 minutes
		if (block.timestamp >= 1679385901) {
            onFees = false;
            _buyTax = 0;
            _sellTax = 0;
		}
    }

  
	function _transfer(
		address sender,
		address recipient,
		uint256 amount
	) internal override {
		require(!blacklisted[sender], "Sender is blacklisted");
		require(!blacklisted[recipient], "Recipient is blacklisted");
		require(amount > 0, "ERC20: transfer amount is zero");
		autoFees();
		if (inSwap || isMarketingPairs[sender] || !onFees || isExcludedFromFee[sender] || isExcludedFromFee[recipient] || _sellTax == 0) {
			super._transfer(sender, recipient, amount);
			return;
		}
		
		uint256 contractTokenBalance = balanceOf(address(this));
		bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap;
			
		if (overMinimumTokenBalance) {
			if(swapAndLiquifyByLimitOnly) {
				contractTokenBalance = minimumTokensBeforeSwap;
				swapForEth(contractTokenBalance);
			} else {
				swapForEth(contractTokenBalance);
			}
		}

		uint256 feeAmount = takeFee(recipient, amount);
        if (feeAmount > 0) {
            super._transfer(sender, address(this), feeAmount);
            super._transfer(sender, recipient, amount.sub(feeAmount));
        } else {
            super._transfer(sender, recipient, amount);
        }
	}
	
	function takeFee(address recipient, uint256 amount) internal view returns (uint256) {
        uint256 feeAmount = 0;
        if(isMarketingPairs[recipient]) {
            feeAmount = amount.mul(_sellTax).div(100);
        }
        
        return feeAmount;
    }
	
	function swapForEth(uint256 tokenAmount) internal swapping {
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = uniswapV2Router.WETH();
		
		super._approve(address(this), address(uniswapV2Router), tokenAmount);

        try uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
				tokenAmount,
				0,
				path,
				feeReceiver,
				block.timestamp
			) 
        {
			emit Log('swap successful');
		} catch {
			emit Log('swap failed');
		}
    }

}
[{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"blacklistedAddress","type":"address"}],"name":"BlacklistAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"blacklistedAddress","type":"address"}],"name":"BlacklistRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"message","type":"string"}],"name":"Log","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"addAddressToBlacklist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"blacklisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"init","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"isBlacklisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isExcludedFromFee","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isMarketingPairs","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumTokensBeforeSwap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"removeAddressFromBlacklist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapAndLiquifyByLimitOnly","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenHolder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapV2Pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]