// File: contracts/Snap.sol



//SPDX-License-Identifier: GPL-3.0-or-later

// www.snaptoken.finance

//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWWWWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMMMMMMMMMWX0kdooolllllooooodxOXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMMMMMWXkdlc:;:::cccccccc::;;;;cokXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMMMW0dc;:cccccccccccccccccccccc:;cdKWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMMWk::ccccccccccccccccccccccccccc:;;o0WMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMWk;:ccccccccccccccccccccccccccccccc;;oXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMMK:,ccccccccccccccccccccccccccccccccc:;:OWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMWd,:ccccccccccccccccccccccccccccccccccc:;xWMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMMO:;ccccccccccccccccccccccccccccccccccccc;:0MMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMMMXc,:cccccc::ccc::cccc:ccccccccccccccccccc::0MMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMMKdc,,::cccc:;::::::::c:;;:ccccccccccccccccc;cKMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMWo,::;,;ccc:;;::::::::cc:;;:cccccccccccccccc;dWMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMNo,;,;;';cc::;;,,;,,;;;::::;:cccccccccccccc:;kMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMO::;'.,;:ccc:;,;;;;;:;,,,::::c::::ccccc:::c;cKMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMO;::;,;c:::cccc::;,,,,,'.';::c:,,::::c:::::;oWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMNo,c;,:::::::cc:::,..''...,;;;;;;;;::::::::,dWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMWo'::,:c::;::::::cc:;,,..,;;,,;;,,;;:::;;;;;xMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMMMO,':::ccc:;;;:cccccc::::c:::;;;''',,,;;;;;':0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMMWO;';,,:ccccc:;::::cccccccccc;;c:,,,''...;::oKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMMMMMMMXx,,:c;,:c:cccc;,;:ccccc:::cc::cc;';::;;,';d0WMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//MMMMMWNK0kd;,,;c:,;c::::c:;;:cccc::,,;:ccc:;,,:cccc:;xWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//0Oxdooc::;,;:::c:',c;;:c:;;:cccccc:;;;;;ccc:,,;cccc;oXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//;,;;:cccc:::;;ccc,.';;:c;;:c::::::cccc;;;;;;;;:c:;;oKMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//ccc:::ccccc:;:ccc:. .';c;,::;,,;;;;::::::::cccc;':ONMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//cccccccccccc:::ccc'  .,c:;:c:::::::;,,;;:;;::;;,lXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//ccccccccccccc:;:cc,.  .:c:ccccc:;;;;,,::;,;;;,,oXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//ccccc;;:ccccc;;:cc;.   'cccccccc::;;,;::;:::;;oXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//cc:,,',:::cc:,;ccc:.   .;ccccccccccccccc:,,ckKNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//:,.',;:::::;,;cccc:.... .:cccccccc:::cc:'..l0XNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//..,:,:c:c:;,;ccccc:'';.  ...',,,;;;;:cc,.  .':lONMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//..,,;:cc:,,;cc;;:c:',c,.         ..'''..    ...,:d0NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//::;,,,,,',:cc:,,:c:,;c:;,,'....       .'''..''';;.,cdkKNNWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//..',:::;,,;;::;;:c:;::::;,,;,..  ..  ..;:cccc:::c:;;;,,;;coxONWMMMMMMMMMMMMMMMMMMMMMMMMMMM
//,,'',;::c:;;;,,',::;:c:,',:;...  ...',..;cccccccccc;,''''''';cdONMMMMMMMMMMMMMMMMMMMMMMMMM
//ccc::::cccccc:::;;,',c,.,::'.,;.  ';',;'.,,;;;;::cc:::cccc:::c:;lkXMMMMMMMMMMMMMMMMMMMMMMM
//ccccccccccccccccc:;'';',:;,'',;,..',,,,;,;;;:cc:::::ccccccccccccc:lOWMMMMMMMMMMMMMMMMMMMMM
//cccccccccccccccccccc;,,;,,::::::::::cc::;;;;,,,'...';:ccccc:ccccc:,,xWMMMMMMMMMMMMMMMMMMMM
//:::cccccccccccccccccc::::cccccccccccc:::::::::::;;;;;:::cccccccccc:',OMMMMMMMMMMMMMMMMMMMM
//:::cccccccccccccccccc::cccccccccccccccccccccccccccccc:;,;c:ccccccccc;c0WMMMMMMMMMMMMMMMMMM
//:::cccccccccccccccccc;,:c:cccccccccccccccccccccccccccc:,':cccccccccc:;:0WMMMMMMMMMMMMMMMMM
//::ccccccccccccccccccc;,:c:ccccccccccccccccccccccccccccc:',cccccccccc::;:OWMMMMMMMMMMMMMMMM
//::ccccccccccccccccccc;,::::ccccccccccccccccccccccccccccc,':c:ccccccc::c;cKMMMMMMMMMMMMMMMM

// Next generation tokenomics:
//
// - Inflationary on buy pressure - 8% of the buy pressure rewards to holders in native tokens
// - Deflationary on sell pressure - 11% of the sell pressure is sold for eth and
//      - 8% + 1% (deflationary) is sold for buyback and burn of the native tokens to organically rising price floor
//      - 2% is sold for marketing to push this project further
//
// This token has rewards as RFI with 20% tax but in reality it has half that value.

pragma solidity ^0.8.7;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol';
import '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol';

contract Snap is Context, IERC20, Ownable {
    using SafeMath for uint256;
    using Address for address;

    string private _name = 'SNAP!';
    string private _symbol = 'SNAP!';
    uint8 private _decimals = 9;

    uint256 private constant MAX_UINT256 = ~uint256(0);
    uint256 private constant INITIAL_FRAGMENTS_SUPPLY = 100_000_000_000_000 * 10**9;
    uint256 private constant TOTAL_GONS = MAX_UINT256 - (MAX_UINT256 % INITIAL_FRAGMENTS_SUPPLY);

    uint256 public constant MAG = 10 ** 9;
    uint256 public rateOfChange = MAG;

    uint256 private _totalSupply;
    uint256 public _gonsPerFragment;

    mapping (address => uint256) public _gonBalances;
    mapping (address => uint256) public _excludedBalances;
    mapping (address => mapping (address => uint256)) private _allowances;
    mapping (address => bool) private _isExcludedFromFee;
    mapping (address => bool) private _isExcludedFromReward;
    mapping (address => bool) private _isBlackListedBot;
    mapping (address => bool) private uniswapV2Pairs;
    address[] private _blackListedBots;

    uint256 private _taxFee = 8;
    uint256 private _marketingFee = 2;
    uint256 private _buyBackFee = _taxFee + 1;
    uint256 private _swapEth = 1 * 10**16;
    uint256 private _swapImpact = 10;
    uint256 private launchTime;

    uint256 private _previousTaxFee = _taxFee;
    uint256 private _previousMarketingFee = _marketingFee;
    uint256 private _previousBuyBackFee = _buyBackFee;

    address payable private _marketingWalletAddress;
    address private immutable _deadWalletAddress = 0x000000000000000000000000000000000000dEaD;

    IUniswapV2Router02 public uniswapV2Router;

    bool inSwapAndLiquify = false;
    bool public swapAndLiquifyEnabled = true;

    bool public tradingOpen = false;

    uint256 private _maxTxAmount = INITIAL_FRAGMENTS_SUPPLY.div(200);

    event SwapAndLiquifyEnabledUpdated(bool enabled);
    event SwapAndLiquify(
        uint256 tokensSwapped,
        uint256 ethReceived,
        uint256 tokensIntoLiqudity
    );

    event SwapETHForTokens(
        uint256 amountIn,
        address[] path
    );

    event SwapTokensForETH(
        uint256 amountIn,
        address[] path
    );

    modifier lockTheSwap {
        inSwapAndLiquify = true;
        _;
        inSwapAndLiquify = false;
    }

    constructor (address marketingWalletAddress) {
        _totalSupply = INITIAL_FRAGMENTS_SUPPLY;
        _gonBalances[_msgSender()] = TOTAL_GONS;
        _gonsPerFragment = TOTAL_GONS.div(_totalSupply);

        // PancakeSwap: 0x10ED43C718714eb63d5aA57B78B54704E256024E
        // Uniswap V2: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
        // Sushi: 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506
        IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
        address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
        uniswapV2Pairs[_uniswapV2Pair] = true;
        uniswapV2Router = _uniswapV2Router;

        // Exclude owner and this contract from fee
        _marketingWalletAddress = payable(marketingWalletAddress);
        _isExcludedFromFee[owner()] = true;
        _isExcludedFromFee[address(this)] = true;
        _isExcludedFromFee[_marketingWalletAddress] = true;

        _isExcludedFromReward[_uniswapV2Pair] = true;
        _isExcludedFromReward[address(this)] = true;

        _isBlackListedBot[address(0xa1ceC245c456dD1bd9F2815a6955fEf44Eb4191b)] = true;
        _blackListedBots.push(address(0xa1ceC245c456dD1bd9F2815a6955fEf44Eb4191b));

        _isBlackListedBot[address(0x27F9Adb26D532a41D97e00206114e429ad58c679)] = true;
        _blackListedBots.push(address(0x27F9Adb26D532a41D97e00206114e429ad58c679));

        _isBlackListedBot[address(0x9282dc5c422FA91Ff2F6fF3a0b45B7BF97CF78E7)] = true;
        _blackListedBots.push(address(0x9282dc5c422FA91Ff2F6fF3a0b45B7BF97CF78E7));

        _isBlackListedBot[address(0xfad95B6089c53A0D1d861eabFaadd8901b0F8533)] = true;
        _blackListedBots.push(address(0xfad95B6089c53A0D1d861eabFaadd8901b0F8533));

        _isBlackListedBot[address(0xfe9d99ef02E905127239E85A611c29ad32c31c2F)] = true;
        _blackListedBots.push(address(0xfe9d99ef02E905127239E85A611c29ad32c31c2F));

        _isBlackListedBot[address(0x59341Bc6b4f3Ace878574b05914f43309dd678c7)] = true;
        _blackListedBots.push(address(0x59341Bc6b4f3Ace878574b05914f43309dd678c7));

        _isBlackListedBot[address(0x136F4B5b6A306091b280E3F251fa0E21b1280Cd5)] = true;
        _blackListedBots.push(address(0x136F4B5b6A306091b280E3F251fa0E21b1280Cd5));

        _isBlackListedBot[address(0xf1CA09CE745bfa38258b26cd839ef0E8DE062A40)] = true;
        _blackListedBots.push(address(0xf1CA09CE745bfa38258b26cd839ef0E8DE062A40));

        _isBlackListedBot[address(0x8719c2829944150F59E3428CA24f6Fc018E43890)] = true;
        _blackListedBots.push(address(0x8719c2829944150F59E3428CA24f6Fc018E43890));

        _isBlackListedBot[address(0xa8E0771582EA33A9d8e6d2Ccb65A8D10Bd0Ea517)] = true;
        _blackListedBots.push(address(0xa8E0771582EA33A9d8e6d2Ccb65A8D10Bd0Ea517));

        _isBlackListedBot[address(0xF3DaA7465273587aec8b2d2706335e06068ccce4)] = true;
        _blackListedBots.push(address(0xF3DaA7465273587aec8b2d2706335e06068ccce4));

        _isBlackListedBot[address(0x9272A2c7083Da2B1C2F0739d9655D1A09764DEAD)] = true;
        _blackListedBots.push(address(0x9272A2c7083Da2B1C2F0739d9655D1A09764DEAD));

        emit Transfer(address(0), _msgSender(), _totalSupply);
    }

    //to receive ETH from uniswapV2Router when swapping
    receive() external payable {}

    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 totalSupply() public view override returns (uint256) {
        return _totalSupply;
    }

    function balanceOf(address account) public view override returns (uint256) {
        if (_isExcludedFromReward[account]) {
            return _excludedBalances[account];
        } else {
            return _gonBalances[account].div(_gonsPerFragment);
        }
    }

    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 setExcludeFromFee(address account, bool excluded) external onlyOwner() {
        _isExcludedFromFee[account] = excluded;
    }

    function setExcludeFromReward(address account, bool excluded) public onlyOwner() {
        if (excluded) {
            require(!_isExcludedFromReward[account], "Account is already excluded");
            _isExcludedFromReward[account] = true;
            _excludedBalances[account] = _gonBalances[account].div(_gonsPerFragment);
            _gonBalances[account] = 0;
        } else {
            require(_isExcludedFromReward[account], "Account is not excluded");
            _isExcludedFromReward[account] = false;
            _gonBalances[account] = _excludedBalances[account].mul(_gonsPerFragment);
            _excludedBalances[account] = 0;
        }
    }

    function addBotToBlackList(address account) external onlyOwner() {
        require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap router.');
        require(!_isBlackListedBot[account], "Account is already blacklisted");
        _isBlackListedBot[account] = true;
        _blackListedBots.push(account);
    }

    function removeBotFromBlackList(address account) external onlyOwner() {
        require(_isBlackListedBot[account], "Account is not blacklisted");
        for (uint256 i = 0; i < _blackListedBots.length; i++) {
            if (_blackListedBots[i] == account) {
                _blackListedBots[i] = _blackListedBots[_blackListedBots.length - 1];
                _isBlackListedBot[account] = false;
                _blackListedBots.pop();
                break;
            }
        }
    }

    function removeAllFee() private {
        if (_taxFee == 0 && _marketingFee == 0 && _buyBackFee == 0) return;

        _previousTaxFee = _taxFee;
        _previousMarketingFee = _marketingFee;
        _previousBuyBackFee = _buyBackFee;

        _taxFee = 0;
        _marketingFee = 0;
        _buyBackFee = 0;
    }

    function restoreAllFee() private {
        _taxFee = _previousTaxFee;
        _marketingFee = _previousMarketingFee;
        _buyBackFee = _previousBuyBackFee;
    }

    function isExcludedFromFee(address account) public view returns(bool) {
        return _isExcludedFromFee[account];
    }

    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 rebasePlus(uint256 _amount) private {
        _totalSupply = _totalSupply.add(_amount.mul(_taxFee).div(100));
        _gonsPerFragment = TOTAL_GONS.div(_totalSupply);
    }

    function _transfer(address sender, address recipient, uint256 amount) private {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");
        require(amount > 0, "ERC20: Transfer amount must be greater than zero");
        require(!_isBlackListedBot[sender], "You have no power here!");
        require(!_isBlackListedBot[recipient], "You have no power here!");
        require(!_isBlackListedBot[tx.origin], "You have no power here!");

        if (sender != owner() && recipient != owner()) {
            require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
            // sorry about that, but sniper bots nowadays are buying multiple times, hope I have something more robust to prevent them to nuke the launch :-(
            if (uniswapV2Pairs[sender]) {
                require(tradingOpen, "Wait for opened trading");
                require(balanceOf(recipient) <= _maxTxAmount, "Already bought maxTxAmount, wait till check off");
                require(balanceOf(tx.origin) <= _maxTxAmount, "Already bought maxTxAmount, wait till check off");

                if (block.timestamp == launchTime) {
                    _isBlackListedBot[recipient] = true;
                    _blackListedBots.push(recipient);
                }
            }

            // do not trigger dext warning when transferring from deployer
            if (!inSwapAndLiquify && swapAndLiquifyEnabled && !uniswapV2Pairs[sender]) {
                swapTokens(amount, uniswapV2Pairs[recipient]);
            }
        }

        //indicates if fee should be deducted from transfer
        bool takeFee = true;

        //if any account belongs to _isExcludedFromFee account then remove the fee
        if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){
            takeFee = false;
        }

        if (sender != owner() && recipient != owner() && uniswapV2Pairs[sender]) {
            rebasePlus(amount);
            takeFee = false;
        }

        _tokenTransfer(sender, recipient, amount, takeFee);
    }

    function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) internal {
        if (!takeFee)
            removeAllFee();

        uint256 burnAmount = amount.mul(_buyBackFee.add(_marketingFee)).div(100);
        uint256 transferAmount = amount.sub(burnAmount);

        uint256 gonTotalValue = amount.mul(_gonsPerFragment);
        uint256 gonValue = transferAmount.mul(_gonsPerFragment);
        uint256 gonBurnValue = burnAmount.mul(_gonsPerFragment);

        if (!_isExcludedFromReward[sender]) {
            _gonBalances[sender] = _gonBalances[sender].sub(gonTotalValue);
        } else {
            _excludedBalances[sender] = _excludedBalances[sender].sub(amount);
        }

        if (!_isExcludedFromReward[recipient]) {
            _gonBalances[recipient] = _gonBalances[recipient].add(gonValue);
        } else {
            _excludedBalances[recipient] = _excludedBalances[recipient].add(transferAmount);
        }

        _excludedBalances[address(this)] = _excludedBalances[address(this)].add(burnAmount);

        emit Transfer(sender, recipient, transferAmount);
        emit Transfer(sender, address(this), burnAmount);

        if (!takeFee)
            restoreAllFee();
    }

    event SwapAndLiquifyFailed(bytes failErr);

    function swapTokens(uint256 amount, bool isSell) private lockTheSwap {
        uint256 contractTokenBalance = balanceOf(address(this));
        uint256 contractEthBalance = address(this).balance;

        uint256 maxAddedToSlipPage = amount.mul(_swapImpact).div(100);
        if (isSell && contractTokenBalance > maxAddedToSlipPage) {
            contractTokenBalance = maxAddedToSlipPage;
        }
        swapTokensForEth(contractTokenBalance);

        if (contractEthBalance > _swapEth) {
            uint256 toTransfer = contractEthBalance.mul(_marketingFee).div(_marketingFee.add(_buyBackFee));

            sendETHToWallet(toTransfer);
            swapEthForTokens(address(this), contractEthBalance.sub(toTransfer));
        }
    }

    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] = uniswapV2Router.WETH();

        _approve(address(this), address(uniswapV2Router), tokenAmount);

        // make the swap
        try uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            tokenAmount,
            0, // accept any amount of ETH
            path,
            address(this),
            block.timestamp
        ) {
            emit SwapTokensForETH(tokenAmount, path);
        } catch (bytes memory e) {
            emit SwapAndLiquifyFailed(e);
        }
    }

    function swapEthForTokens(address token, uint256 amount) private {
        // generate the uniswap pair path of weth -> token
        address[] memory path = new address[](2);
        path[0] = uniswapV2Router.WETH();
        path[1] = token;

        _approve(address(this), address(uniswapV2Router), amount);

        // make the swap
        try uniswapV2Router.swapExactETHForTokens{value: amount}(
            0, // accept any amount of Tokens
            path,
            _deadWalletAddress,
            block.timestamp.add(300)
        ) {
            emit SwapETHForTokens(amount, path);
        } catch (bytes memory e) {
            emit SwapAndLiquifyFailed(e);
        }
    }

    function sendETHToWallet(uint256 amount) private {
        _marketingWalletAddress.call{value: amount}("");
    }

    function openTrading() public onlyOwner() {
        tradingOpen = true;
        launchTime = block.timestamp;
    }

    // We are exposing these functions to be able to manual swap and send
    // in case the token is highly valued and 5M becomes too much
    function manualSwap() external onlyOwner() {
        uint256 contractBalance = balanceOf(address(this));
        swapTokensForEth(contractBalance);
    }

    function manualSwapAmount(uint256 amount) public onlyOwner() {
        uint256 contractBalance = balanceOf(address(this));
        require(contractBalance >= amount, 'contract balance should be greater then amount');

        swapTokensForEth(amount);
    }

    function manualSend() public onlyOwner() {
        uint256 contractETHBalance = address(this).balance;
        sendETHToWallet(contractETHBalance);
    }

    function manualSwapAndSend(uint256 amount) external onlyOwner() {
        manualSwapAmount(amount);
        manualSend();
    }

    function setSwapAndLiquifyEnabled(bool _swapAndLiquifyEnabled) external onlyOwner(){
        swapAndLiquifyEnabled = _swapAndLiquifyEnabled;
    }

    function _getMaxTxAmount() private view returns(uint256) {
        return _maxTxAmount;
    }

    function _getETHBalance() public view returns(uint256 balance) {
        return address(this).balance;
    }

    function _setTaxFee(uint256 taxFee) external onlyOwner() {
        require(taxFee >= 0 && taxFee <= 49, 'taxFee should be in 0 - 49');
        _taxFee = taxFee;
    }

    function _setMarketingFee(uint256 marketingFee) external onlyOwner() {
        require(marketingFee >= 0 && marketingFee <= 49, 'marketingFee should be in 0 - 49');
        _marketingFee = marketingFee;
    }

    function _setBuyBackFee(uint256 buyBackFee) external onlyOwner() {
        require(buyBackFee >= 0 && buyBackFee <= 49, 'buyBackFee should be in 0 - 49');
        _buyBackFee = buyBackFee;
    }

    function _setMarketingWallet(address payable marketingWalletAddress) external onlyOwner() {
        _marketingWalletAddress = marketingWalletAddress;
    }

    function _setSwapEthLimit(uint256 swapEthLimit) external onlyOwner() {
        _swapEth = swapEthLimit;
    }

    function _setSwapImpact(uint256 swapImpact) external onlyOwner() {
        _swapImpact = swapImpact;
    }

    function _setMainRouter(address router, address _uniswapV2Pair) external onlyOwner() {
        uniswapV2Pairs[_uniswapV2Pair] = true;
        uniswapV2Router = IUniswapV2Router02(router);
        setExcludeFromReward(_uniswapV2Pair, true);
    }

    function _setLiquidityPair(address _uniswapV2Pair, bool isPair) external onlyOwner() {
        uniswapV2Pairs[_uniswapV2Pair] = isPair;
        setExcludeFromReward(_uniswapV2Pair, isPair);
    }

    function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
        require(maxTxAmount >= 10**9 , 'maxTxAmount should be greater than total 1e9');
        _maxTxAmount = maxTxAmount;
    }

    function recoverTokens(uint256 tokenAmount) public virtual onlyOwner() {
        _approve(address(this), owner(), tokenAmount);
        _transfer(address(this), owner(), tokenAmount);
    }

}

// File: @openzeppelin/contracts/access/Ownable.sol



// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _setOwner(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// File: @openzeppelin/contracts/token/ERC20/IERC20.sol



// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

// File: @openzeppelin/contracts/utils/Address.sol



// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

// File: @openzeppelin/contracts/utils/math/SafeMath.sol



// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

// File: @uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol



pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

// File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol



pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

// File: @openzeppelin/contracts/utils/Context.sol



// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

// File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol



pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}