contract PayVariaETH {

    address constant USDC_TOKEN_ADDR = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; // USDC mainnet token contract address
    address constant SUSHI_ROUTER_ADDR = 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F; // Sushiswap router contract address
    address constant VARIA_ADDR = 0xD4B2747e87e7bE8CA0d68A249b90738b5aB2E85a; // varia.eth EOA address

    IUniswapV2Router02 public sushiRouter;
    IUSDC public iUSDCToken;

    error NoETHSent();
    error NoUSDC();

    constructor() payable {
        sushiRouter = IUniswapV2Router02(SUSHI_ROUTER_ADDR);
        iUSDCToken = IUSDC(USDC_TOKEN_ADDR);
    }

    /// @notice receives ETH payment and swaps to USDC via Sushiswap router, which is then sent to varia.eth. Intended only as a payment option for clients of Varia LLC.
    function payInETH() public payable {
        if (msg.value == 0) revert NoETHSent();
        sushiRouter.swapExactETHForTokens{ value: msg.value }(0, _getPathForETHtoUSDC(), address(this), block.timestamp+100);
        _sendUSDC();
    }

    function _sendUSDC() internal {
        if (iUSDCToken.balanceOf(address(this)) == 0) revert NoUSDC();
        iUSDCToken.transfer(VARIA_ADDR, iUSDCToken.balanceOf(address(this)));
    }
    
    /// @return the router path for ETH/USDC swap for the payInETH() function
    function _getPathForETHtoUSDC() internal view returns (address[] memory) {
        address[] memory path = new address[](2);
        path[0] = sushiRouter.WETH(); //0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
        path[1] = USDC_TOKEN_ADDR;
        return path;
    }

    receive() payable external {}
}
function _getPathForETHtoUSDC() internal view returns (address[] memory) {
        address[] memory path = new address[](2);
        path[0] = sushiRouter.WETH(); //0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
        path[1] = USDC_TOKEN_ADDR;
        return path;
    }
/// @return the router path for ETH/USDC swap for the payInETH() function