creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/RPG.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity 0.8.24;\n/* \n                      RRRRRRRRRRRRRRRRR    PPPPPPPPPPPPPPPPP            GGGGGGGGGGGGG\n                      R::::::::::::::::R   P::::::::::::::::P        GGG::::::::::::G\n                      R::::::RRRRRR:::::R  P::::::PPPPPP:::::P     GG:::::::::::::::G\n                      RR:::::R     R:::::R PP:::::P     P:::::P   G:::::GGGGGGGG::::G\n                        R::::R     R:::::R   P::::P     P:::::P  G:::::G       GGGGGG\n                        R::::R     R:::::R   P::::P     P:::::P G:::::G              \n                        R::::RRRRRR:::::R    P::::PPPPPP:::::P  G:::::G              \n                        R:::::::::::::RR     P:::::::::::::PP   G:::::G    GGGGGGGGGG\n                        R::::RRRRRR:::::R    P::::PPPPPPPPP     G:::::G    G::::::::G\n                        R::::R     R:::::R   P::::P             G:::::G    GGGGG::::G\n                        R::::R     R:::::R   P::::P             G:::::G        G::::G\n                        R::::R     R:::::R   P::::P              G:::::G       G::::G\n                      RR:::::R     R:::::R PP::::::PP             G:::::GGGGGGGG::::G\n                      R::::::R     R:::::R P::::::::P              GG:::::::::::::::G\n                      R::::::R     R:::::R P::::::::P                GGG::::::GGG:::G\n                      RRRRRRRR     RRRRRRR PPPPPPPPPP                   GGGGGG   GGGG\n*/ \n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n    /*//////////////////////////////////////////////////////////////\n                                 EVENTS\n    //////////////////////////////////////////////////////////////*/\n\n    event Transfer(address indexed from, address indexed to, uint256 amount);\n\n    event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n    /*//////////////////////////////////////////////////////////////\n                            METADATA STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    string public name;\n\n    string public symbol;\n\n    uint8 public immutable decimals;\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC20 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    uint256 public totalSupply;\n\n    mapping(address => uint256) public balanceOf;\n\n    mapping(address => mapping(address => uint256)) public allowance;\n\n    /*//////////////////////////////////////////////////////////////\n                            EIP-2612 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    uint256 internal immutable INITIAL_CHAIN_ID;\n\n    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n    mapping(address => uint256) public nonces;\n\n    /*//////////////////////////////////////////////////////////////\n                               CONSTRUCTOR\n    //////////////////////////////////////////////////////////////*/\n\n    constructor(\n        string memory _name,\n        string memory _symbol,\n        uint8 _decimals\n    ) {\n        name = _name;\n        symbol = _symbol;\n        decimals = _decimals;\n\n        INITIAL_CHAIN_ID = block.chainid;\n        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                               ERC20 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function approve(address spender, uint256 amount) public virtual returns (bool) {\n        allowance[msg.sender][spender] = amount;\n\n        emit Approval(msg.sender, spender, amount);\n\n        return true;\n    }\n\n    function transfer(address to, uint256 amount) public virtual returns (bool) {\n        balanceOf[msg.sender] -= amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(msg.sender, to, amount);\n\n        return true;\n    }\n\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) public virtual returns (bool) {\n        uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n        balanceOf[from] -= amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(from, to, amount);\n\n        return true;\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                             EIP-2612 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) public virtual {\n        require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n        // Unchecked because the only math done is incrementing\n        // the owner's nonce which cannot realistically overflow.\n        unchecked {\n            address recoveredAddress = ecrecover(\n                keccak256(\n                    abi.encodePacked(\n                        \"\\x19\\x01\",\n                        DOMAIN_SEPARATOR(),\n                        keccak256(\n                            abi.encode(\n                                keccak256(\n                                    \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n                                ),\n                                owner,\n                                spender,\n                                value,\n                                nonces[owner]++,\n                                deadline\n                            )\n                        )\n                    )\n                ),\n                v,\n                r,\n                s\n            );\n\n            require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n            allowance[recoveredAddress][spender] = value;\n        }\n\n        emit Approval(owner, spender, value);\n    }\n\n    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n    }\n\n    function computeDomainSeparator() internal view virtual returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n                    keccak256(bytes(name)),\n                    keccak256(\"1\"),\n                    block.chainid,\n                    address(this)\n                )\n            );\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                        INTERNAL MINT/BURN LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function _mint(address to, uint256 amount) internal virtual {\n        totalSupply += amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(address(0), to, amount);\n    }\n\n    function _burn(address from, uint256 amount) internal virtual {\n        balanceOf[from] -= amount;\n\n        // Cannot underflow because a user's balance\n        // will never be larger than the total supply.\n        unchecked {\n            totalSupply -= amount;\n        }\n\n        emit Transfer(from, address(0), amount);\n    }\n}\n\n\ninterface IUniswapV2Factory {\n    function createPair(address tokenA, address tokenB) external returns (address pair);\n}\n\ninterface IUniswapV2Router {\n    function WETH() external pure returns (address);\n    function factory() external pure returns (address);\n    function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n        ) external returns (uint[] memory amounts);\n    function swapExactTokensForETHSupportingFeeOnTransferTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n        ) external;\n}\n\ninterface IUniswapV2Pair {\n    function sync() external;\n}\n\ninterface IWETH {\n    function deposit() external payable;\n    function transfer(address to, uint value) external returns (bool);\n    function withdraw(uint) external;\n    function balanceOf(address) external returns (uint);\n}\n\ncontract RPG is ERC20 {\n    address payable public operations;\n    address public uniswapV2WETHPair;\n    uint public liquidityAdded;\n    bool antisnipe = true;\n    bool depth = false;\n    uint supplyDivisor = 1000;\n    bool sellSwap = true;\n    uint sellFee = 3;\n    bool buySwap = true;\n    uint buyFee = 3;\n    mapping(address => bool) public isUniswapPair;\n    address payable public feeReceiver = payable(0x0eC0c436640b698652dBF2ceaE0ffE9529B87Bd6);\n    mapping(address => bool) public isExcludedFromFee;\n\n    IWETH weth;\n    IUniswapV2Router uniswapV2Router;\n    \n    error OnlyOps();\n    error AntiSnipe();\n    error NoBalance();\n    error NotZero();\n    error NotGreaterThanFive();\n\n    receive() external payable {}\n\n    constructor() ERC20(\"RPG\", \"RPG\", 18) {\n        operations = payable(msg.sender);\n        uniswapV2Router = IUniswapV2Router(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n        uniswapV2WETHPair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH());\n        isUniswapPair[uniswapV2WETHPair] = true;\n        isExcludedFromFee[address(this)] = true;\n        isExcludedFromFee[operations] = true;\n        isExcludedFromFee[feeReceiver] = true;\n        weth = IWETH(uniswapV2Router.WETH());\n        _mint(feeReceiver, 1_000_000_000 * 10 ** 18);\n    }\n\n    function addUniswapPair(address pair) external {\n        if(msg.sender != operations) revert OnlyOps();\n        isUniswapPair[pair] = true;\n    }\n\n    function forceSwap() external {\n        if(msg.sender != operations) revert OnlyOps();\n        if(balanceOf[address(this)] == 0) revert NoBalance();\n        swapTokens(balanceOf[address(this)]);\n        IUniswapV2Pair(uniswapV2WETHPair).sync();\n    }\n\n    function changeOperations(address payable operations_) external {\n        if(msg.sender != operations) revert OnlyOps();\n        if(operations_ == address(0)) revert NotZero();\n        operations = operations_;\n    }\n\n    function changeSupplyDivisor(uint supplyDivisor_) external {\n        if(msg.sender != operations) revert OnlyOps();\n        if(supplyDivisor_ == 0) revert NotZero();\n        supplyDivisor = supplyDivisor_;\n    }\n\n    function changeFee(uint buyFee_, uint sellFee_) external {\n        if(msg.sender != operations) revert OnlyOps();\n        if(buyFee_ > 30 || sellFee_ > 30) revert NotGreaterThanFive();\n        buyFee = buyFee_;\n        sellFee = sellFee_;\n    }\n\n    function changeFeeReceiver(address payable feeReceiver_) external {\n        if(msg.sender != operations) revert OnlyOps();\n        if(feeReceiver_ == address(0)) revert NotZero();\n        feeReceiver = feeReceiver_;\n    }\n    function toggleBuySwap() external {\n        if(msg.sender != operations) revert OnlyOps();\n        buySwap = !buySwap;\n    }\n    function toggleSellSwap() external {\n        if(msg.sender != operations) revert OnlyOps();\n        sellSwap = !sellSwap;\n    }\n\n    function transfer(address to, uint256 amount) public virtual override returns (bool){\n        if(!isExcludedFromFee[msg.sender] && !isExcludedFromFee[to]){\n            if(isUniswapPair[msg.sender]) {\n                uint256 fee = (amount * buyFee) / 100;\n                super.transfer(address(this), fee);\n                if(antisnipe && liquidityAdded != 0) {\n                    if(block.number - liquidityAdded < 352) {\n                        if(amount > (totalSupply / 176) * ((block.number - liquidityAdded)/2)) revert AntiSnipe();\n                    }\n                    else {\n                        antisnipe = false;\n                    }\n                }\n                uint256 balance = balanceOf[address(this)];\n                if(sellSwap && balance > totalSupply / supplyDivisor && !depth)  {\n                    depth = true;\n                    swapTokens(balance);\n                    depth = false;\n                }                \n                return super.transfer(to, amount - fee);\n            }\n        }\n        return super.transfer(to, amount);\n    }\n\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) public virtual override returns (bool) {\n        if(isUniswapPair[to] ) {\n            if(liquidityAdded == 0) \n                liquidityAdded = block.number;\n            if(!isExcludedFromFee[from] && !isExcludedFromFee[to]){\n                uint256 fee = (amount * sellFee) / 100;\n                super.transferFrom(from, address(this), fee);\n                uint256 balance = balanceOf[address(this)];\n                if(buySwap && balance > totalSupply / supplyDivisor && !depth)  {\n                    depth = true;\n                    swapTokens(balance);\n                    depth = false;\n                }     \n                return super.transferFrom(from, to, amount - fee);\n            }\n        }\n        return super.transferFrom(from, to, amount);\n    }\n\n    function swapTokens(uint256 tokenAmount) private returns (bool) {\n        address[] memory path = new address[](2);\n        path[0] = address(this);\n        path[1] = address(weth);\n        ERC20(address(this)).approve(address(uniswapV2Router), tokenAmount);\n        uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n            tokenAmount,\n            0,\n            path,\n            address(this),\n            block.timestamp\n        );\n        weth.deposit{value: address(this).balance/2}();\n        weth.transfer(uniswapV2WETHPair, weth.balanceOf(address(this)));\n        (bool success,) = feeReceiver.call{value: address(this).balance}(\"\");\n        return success;\n    }\n}"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    }
  }}