0

I have the following function in JavaScript:

try {
    let tx = await router.connect(receiver).swapExactTokensForETH(
        tokenAmountToSwap,
        0,
        [token.address, await router.WETH()],
        receiver.address,
        Math.floor(Date.now() / 1000) + 60 * 20
    );
    const receipt = await tx.wait();
    console.log('Transaction successful:', receipt);
} catch (error) {
    console.error('Transaction failed:', error);
    console.log('Reverting at:', error.transactionHash);
}

In the transfer function of my contract, it subtracts a fee from the amount, and when I try to swap the remaining value, it returns the 'Uniswap: K' error. Is there any function to solve my problem?"

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.