Hi! Iโm trying to use Uniswap Router2 but whenever I try to convert ETH to USDC, sometimes it works but most of the time it fails. How do I handle this?
function convertEthToUSD(uint256 usdAmount)
        public
        payable
        returns (bool)
    {
        uint256 deadline = block.timestamp + 15;
        uniswapRouter.swapETHForExactTokens{value: msg.value}(
            usdAmount,
            getPathForETHtoUSD(),
            treasuryAddress,
            deadline
        );
        (bool success, ) = msg.sender.call{value: address(this).balance}("");
        require(success, "refund failed");
        return true;
    }
