[SOLVED] How to use Uniswap Router v2?

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;

    }

I think I found the problem; itโ€™s the deadline. They suggested sending deadline from frontend, but now Iโ€™m not sure what should I throw? Like a hundred?

I donโ€™t know either what it should be an expected value for that deadline

The deadline is a point in time after which the swap will be canceled to protect against unusually long pending periods and the changes in price that typically accompany the passage of time.

You can check out their docs or ask on their Discord.