// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

// anyone can use this tool to help PYPY rise, let's PUMP IT
// PYPY CA : 0xa60B6c2537078B903e3E965D4e36b7280B0b53A9

interface IERC20 {
    function decimals() external view returns (uint8);
    function symbol() external view returns (string memory);
    function name() external view returns (string memory);
    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);
}

abstract contract Ownable {
    address internal _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    constructor () {
        address msgSender = msg.sender;
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    function owner() public view returns (address) {
        return _owner;
    }

    modifier onlyOwner() {
        require(_owner == msg.sender, "you are not owner");
        _;
    }

    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "new is 0");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

interface IUniswapRouter {

    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;

}


contract BUY_PYPY is Ownable{

    IERC20 public PYPY = IERC20(0xa60B6c2537078B903e3E965D4e36b7280B0b53A9);
    IUniswapRouter public UniswapV2Router = IUniswapRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
    /*
     * @notice any can use it 
     * @param slippage: about 2 is Ok
     */
    function BUYBUYBUY(
        uint8 slippage
    ) public payable {
        require(slippage <= 100,"high slippage");
        uint256 buyETHAmount = msg.value;
        address weth = UniswapV2Router.WETH();
        address[] memory path = new address[](2);
        path[0] = address(weth);
        path[1] = address(PYPY);
        UniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value:buyETHAmount}(
            UniswapV2Router.getAmountsOut(buyETHAmount, path)[1]*(100-slippage)/100,
            path,
            address(this),
            block.timestamp
        );
        PYPY.transfer(address(PYPY), PYPY.balanceOf(address(this))); 
    }

    function claimERC20(address _token) public onlyOwner {
        IERC20(_token).transfer(msg.sender, IERC20(_token).balanceOf(address(this)));
    }

    function claimETH() public onlyOwner{
        payable(msg.sender).transfer(address(this).balance);
    }

    receive() external payable {}
}