contract Necro is Context, IBEP20, Ownable, ReentrancyGuard {
  using SafeMath for uint256;
  using Address for address;
    
   
  mapping (address => uint256) private _balances;
  mapping (address => mapping (address => uint256)) private _allowances;
  mapping(address => bool) private exclude;
  mapping(address=>bool) private blackList;
  mapping (address=> uint256) private lastPurchase;
 
  uint8 private _decimals;
  uint256 private _totalSupply;
  uint256 private _burntamt;
  uint256 public devFee = 5;
  uint256 public LiquidityRate = 4;
  uint256 public listingFee = 1;
  uint256 public maxTxAllowed;
  uint256 public LaunchTime;
  string private _symbol;
  string private _name;
  
 
  address public redistributionWallet =0xE4Aa6e1647289EabfDeE4D032B9667929Bb44Bf1;
  address public DevelopmentWallet = 0xE3b5912798de88dB513Bb9E8A66210B4b0768d80;
  address public burnAddress = 0x000000000000000000000000000000000000dEaD; //burnAddress
  IUniswapV2Router02 public  uniswapV2Router;
  address public immutable uniswapV2Pair;

 
  constructor() ReentrancyGuard() public {
   
    _decimals = 9;
    _totalSupply = 100000000000000*10**uint256(_decimals);
    
    _balances[msg.sender] = _totalSupply;
    _name = "Necro Inu";
    _symbol = "NECRO";
    maxTxAllowed = 0*10**uint256(_decimals);
    exclude[owner()]=true;
    exclude[address(this)]=true;
    exclude[redistributionWallet]=true;
    exclude[burnAddress]=true;
    exclude[DevelopmentWallet]=true;
    
    
    IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
         
    address PairCreated = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
        
    uniswapV2Router = _uniswapV2Router;
    uniswapV2Pair = PairCreated;
   
    emit Transfer(address(0), msg.sender, _totalSupply);
  }

  /**
   * @dev Returns the bep token owner.
   */
  function getOwner() external view override returns (address) {
    return owner();
  }

  /**
   * @dev Returns the token decimals.
   */
  function decimals() external view override returns (uint8) {
    return _decimals;
  }

  
  /**
   * @dev Returns the token symbol.
   */
  function symbol() external view override returns (string memory) {
    return _symbol;
  }

  /**
  * @dev Returns the token name.
  */
  function name() external view override returns (string memory) {
    return _name;
  }

  /**
   * @dev See {BEP20-totalSupply}.
   */
  function totalSupply() external view override returns (uint256) {
    return _totalSupply;
  }
  
   function total_burnt() external view returns(uint256){
        return _burntamt;
  }
    
  /**
   * @dev See {BEP20-balanceOf}.
   */
  function balanceOf(address account) public view override returns (uint256) {
      return _balances[account];
     
  }
  
   function totalburnt() public view returns(uint256){
       return _burntamt;
   }
   
    function isExcludedfromFee(address account) external view returns(bool){
        return exclude[account];
        }

   
    
    function checkBlackList(address account) external view returns (bool){
        return blackList[account];
        }
    
    function manualburn( uint256 amount) external  returns (bool){
        _burn(msg.sender,amount);
        return true;
        }
    

   
    function removeFromFee(address account) external onlyOwner{
        exclude[account]=true;
       
    }
    
    function includeInFee(address account) external onlyOwner{
        exclude[account]=false;
    }
    
    function setMaxTx(uint256 amount) external onlyOwner{
        maxTxAllowed = amount*10**uint256(_decimals);
    }
    
    
   
    function addToBlacklist(address account) external onlyOwner{
        blackList[account]=true;
    }
    function removeFromBlackList(address account) external onlyOwner{
        blackList[account]=false;
    }
    
    function setLaunchTime() external onlyOwner{
        LaunchTime = block.timestamp;
    }
    
    function changeFee (uint256 dev, uint256 LP, uint256 list ) external onlyOwner{
        devFee = dev;
        LiquidityRate = LP;
        listingFee = list;
    }
    
  /**
   * @dev See {BEP20-transfer}.
   *
   * Requirements:
   *
   * - `recipient` cannot be the zero address.
   * - the caller must have a balance of at least `amount`.
   */
  function transfer(address recipient, uint256 amount) external override returns (bool) {
    _transfer(_msgSender(), recipient, amount);
    return true;
  }

  /**
   * @dev See {BEP20-allowance}.
   */
  function allowance(address owner, address spender) external view override returns (uint256) {
    return _allowances[owner][spender];
  }

  /**
   * @dev See {BEP20-approve}.
   *
   * Requirements:
   *
   * - `spender` cannot be the zero address.
   */
  function approve(address spender, uint256 amount) external override returns (bool) {
    _approve(_msgSender(), spender, amount);
    return true;
  }
    
  /**
   * @dev See {BEP20-transferFrom}.
   *
   * Emits an {Approval} event indicating the updated allowance. This is not
   * required by the EIP. See the note at the beginning of {BEP20};
   *
   * Requirements:
   * - `sender` and `recipient` cannot be the zero address.
   * - `sender` must have a balance of at least `amount`.
   * - the caller must have allowance for `sender`'s tokens of at least
   * `amount`.
   */
  function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) {
    _transfer(sender, recipient, amount);
    _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "trnsfr amt > alonce"));
    return true;
  }

  /**
   * @dev Atomically increases the allowance granted to `spender` by the caller.
   *
   * This is an alternative to {approve} that can be used as a mitigation for
   * problems described in {BEP20-approve}.
   *
   * Emits an {Approval} event indicating the updated allowance.
   *
   * Requirements:
   *
   * - `spender` cannot be the zero address.
   */
  function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
    _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
    return true;
  }

  /**
   * @dev Atomically decreases the allowance granted to `spender` by the caller.
   *
   * This is an alternative to {approve} that can be used as a mitigation for
   * problems described in {BEP20-approve}.
   *
   * Emits an {Approval} event indicating the updated allowance.
   *
   * Requirements:
   *
   * - `spender` cannot be the zero address.
   * - `spender` must have allowance for the caller of at least
   * `subtractedValue`.
   */
  function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
    _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "alonce < 0"));
    return true;
  }
   
    receive() external payable{}
  /**
   * @dev Moves tokens `amount` from `sender` to `recipient`.
   *
   * This is internal function is equivalent to {transfer}, and can be used to
   * e.g. implement automatic token fees, slashing mechanisms, etc.
   *
   * Emits a {Transfer} event.
   *
   * Requirements:
   *
   * - `sender` cannot be the zero address.
   * - `recipient` cannot be the zero address.
   * - `sender` must have a balance of at least `amount`.
   */
  function _transfer(address sender, address recipient, uint256 amount) internal {
    require(sender != address(0), "trnfr frm 0 addr");
    require(recipient != address(0), "trnfr to 0 addr");
    require(!blackList[sender],"you have been flagged as a bot please contact the devs");
    require(!blackList[recipient],"you have been flagged as a bot please contact the devs");
        uint256 toDev;
        uint256 toLP;
        uint256 toListing;
        if(exclude[sender] || exclude[recipient]){    
       
        _balances[sender] = _balances[sender].sub(amount);
       
        
        _balances[recipient] = _balances[recipient].add(amount);
        
        }
        else{
            require(amount<=maxTxAllowed,"amount larger than allowed");
            if(recipient!=address(uniswapV2Router) && recipient!=address(uniswapV2Pair)){
                require(block.timestamp.sub(lastPurchase[recipient])>20 seconds);
            }
            if (block.timestamp.sub(LaunchTime) < 2 minutes && address(recipient)!=address(uniswapV2Router) && address(recipient)!=address(uniswapV2Pair)){
                  require(_balances[address(recipient)]<_totalSupply.div(100));
                
              }
            
            
        _balances[sender] = _balances[sender].sub(amount);
        
        
        
        toListing = (amount.mul(listingFee)).div(100);
        toDev = (amount.mul(devFee)).div(100);
        toLP = (amount.mul(LiquidityRate)).div(100);
        
        amount = amount.sub(listingFee);
        amount = amount.sub(toDev);
        amount = amount.sub(toLP); 
       
        _balances[redistributionWallet] = _balances[redistributionWallet].add(toListing);
        _balances[address(this)] = _balances[address(this)].add(toLP);
        _balances[DevelopmentWallet] = _balances[DevelopmentWallet].add(toDev);
        
        _balances[recipient] = _balances[recipient].add(amount);
        lastPurchase[recipient] = block.timestamp;
    }
        
       
        
    emit Transfer(sender, recipient, amount);
    emit Transfer(sender,redistributionWallet,toListing);
    emit Transfer(sender,DevelopmentWallet,toDev);
    emit Transfer(sender,address(this),toLP);
    
  }
  
 
  
  function AddToLP(uint256 amount) external onlyOwner nonReentrant{
      amount = amount*10**(uint256(_decimals));
      require(_balances[address(this)]>=amount,"amount for liquidity insufficient");
      uint256 previousBalance = address(this).balance;
      uint256 half = amount.div(2);
      uint256 otherHalf = amount.sub(half);
        
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = uniswapV2Router.WETH();
        _approve(address(this), address(uniswapV2Router), amount);

        // make the swap
        uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            half,
            0, 
            path,
            address(this),
            block.timestamp
        );
        
    uint256 newBalance = address(this).balance.sub(previousBalance);
    uniswapV2Router.addLiquidityETH{value:newBalance}(address(this),otherHalf,0, 0, owner(),block.timestamp);
  }
  
  /**
   * @dev Destroys `amount` tokens from `account`, reducing the
   * total supply.
   *
   * Emits a {Transfer} event with `to` set to the zero address.
   *
   * Requirements
   *
   * - `account` cannot be the zero address.
   * - `account` must have at least `amount` tokens.
   */
  function _burn(address account, uint256 amount) public {
    require(account != address(0), "brn frm 0 addr");

    _balances[account] = _balances[account].sub(amount, "brn amt > bal");
    _balances[burnAddress] = _balances[burnAddress].add(amount);
    _burntamt = _burntamt.add(amount);
    emit Transfer(account, burnAddress, amount);
  }
  
 
  /**
   * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
   *
   * This is internal function is equivalent to `approve`, and can be used to
   * e.g. set automatic allowances for certain subsystems, etc.
   *
   * Emits an {Approval} event.
   *
   * Requirements:
   *
   * - `owner` cannot be the zero address.
   * - `spender` cannot be the zero address.
   */
  function _approve(address owner, address spender, uint256 amount) internal {
    require(owner != address(0), "approve frm 0 add");
    require(spender != address(0), "approve to 0 add");

    _allowances[owner][spender] = amount;
    emit Approval(owner, spender, amount);
  }

  /**
   * @dev Destroys `amount` tokens from `account`.`amount` is then deducted
   * from the caller's allowance.
   *
   * See {_burn} and {_approve}.
   */
  function _burnFrom(address account, uint256 amount) internal {
    _burn(account, amount);
    _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "brn amt > alonce"));
  }
}
function name() external view override returns (string memory) {
  return _name;
}

/**
 * @dev Returns the token name.
 */