I'am trying to swap multiple tokens in single transaction (multicall). The transaction is going into pending state and failing after some time. The code snippet and the transaction hash is attached below . https://goerli.etherscan.io/tx/0x12d2045c8d08f24baabecff7e27dc69b08a1fac628c4bb0c4c224cbd522173d3
Code Snippet:
const walletAddress = "0x2142EA5a7A922a3F5A98A81567FA691187E550B1";
const param1 = {
tokenIn: WETHAddress,
tokenOut: USDCAddress,
fee: 3000,
recipient: walletAddress,
deadline: Math.floor(Date.now() / 1000) + 60 * 10,
amountIn: ethers.utils.parseEther("0.00001"),
amountOutMinimum: 0,
sqrtPriceLimitX96: 0,
};
const a = uniswapContractInstance.interface.encodeFunctionData(
"exactInputSingle",
[param1]
);
const param2 = {
tokenIn: WETHAddress,
tokenOut: UNIADDRESS,
fee: 3000,
recipient: walletAddress,
deadline: Math.floor(Date.now() / 1000) + 60 * 10,
amountIn: ethers.utils.parseEther("0.00001"),
amountOutMinimum: 0,
sqrtPriceLimitX96: 0,
};
const b = uniswapContractInstance.interface.encodeFunctionData(
"exactInputSingle",
[param2]
);
const calls = [a, b];
const multiCall = uniswapContractInstance.interface.encodeFunctionData(
"multicall",
[calls]
);
const provider = await new ethers.providers.Web3Provider(window.ethereum);
const targs = {
to: V3SwapRouterAddress,
from: accounts,
data: multiCall,
gasLimit: "3456780",
// value: "100000000",
// // gasPrice: "345706",
// maxFeePerGas: "15000000000",
// maxPriorityFeePerGas: "1500000000",
};
// const a = await window.ethereum.request({ method: "eth_accounts" });
// const account = window.ethereum._state?.accounts;
// let check = await provider.getCode(V3SwapRouterAddress);
// console.log({ check });
const signer = await provider.getSigner();
const tx = await signer.sendTransaction(targs);
// const estimate = await signer.estimateGas(targs);
const reciept = await tx.wait();
console.log({ reciept });
}; ```