// File: src/pkexec/PurpFaucet.sol



// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.20;

/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
library SafeTransferLib {
    /*//////////////////////////////////////////////////////////////
                             ETH OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function safeTransferETH(address to, uint256 amount) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Transfer the ETH and store if it succeeded or not.
            success := call(gas(), to, amount, 0, 0, 0, 0)
        }

        require(success, "ETH_TRANSFER_FAILED");
    }
}

interface IArcade {
    function buyCreatorToken(address _creatorToken, uint256 tokenAmount) payable external;
    function tokenPrices(address a) external returns (uint256);
}

interface IERC20 {
    function transfer(address to, uint256 value) external returns (bool);
}

contract PurpFaucet {

    address constant ARCADE = 0xab79C816da5CFC71127da3aDe3e9604112348196;
    address constant PURP = 0x2199FF95d6c9c7649724F781d948049f815EDd03;

    receive() payable external  {
        uint256 price = IArcade(ARCADE).tokenPrices(PURP);
        uint256 tokenAmount = msg.value / price;
        IArcade(ARCADE).buyCreatorToken{value: msg.value}(PURP, tokenAmount);
        IERC20(PURP).transfer(msg.sender, tokenAmount);
    }   
}