Hi Community ,
I am trying multiCall to place multiple orders at the same time in MetaMask . The orders are getting placed , but its getting failed after some time . Iam not getting the error message too.
Iam using the goerli test network .
I have attached the code snippet below and the transaction reciept hash is
0x838983246d9ad43a6e37ef7f0397c88fb5afa4c59e912d7e27b49cbbbbf16a47
const V3SwapRouterAddress = "0xE592427A0AEce92De3Edee1F18E0157C05861564"; // 0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45
const GETHADDRESS = "0x2142EA5a7A922a3F5A98A81567FA691187E550B1";
const WETHAddress = "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6";
const USDCAddress = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F";
const UNIADDRESS = "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984";
const LINKADDRESS = "0x326C977E6efc84E512bB9C30f76E30c160eD06FB";
console.log(
V3SwapRouterABI.concat(PeripheryPaymentsABI).concat(MulticallABI)
);
const onLoads = async () => {
const uniswapContractInstance = new ethers.Contract(
V3SwapRouterAddress,
V3SwapRouterABI.concat(PeripheryPaymentsABI).concat(MulticallABI)
);
const param1 = {
tokenIn: WETHAddress,
tokenOut: UNIADDRESS,
fee: 3000,
recipient: accounts,
deadline: Math.floor(Date.now() / 1000) + 60 * 10,
amountIn: ethers.utils.parseEther("0.0001"),
amountOutMinimum: 0,
sqrtPriceLimitX96: 0,
};
const a = uniswapContractInstance.interface.encodeFunctionData(
"exactInputSingle",
[param1]
);
const param2 = {
tokenIn: WETHAddress,
tokenOut: USDCAddress,
fee: 3000,
recipient: accounts,
deadline: Math.floor(Date.now() / 1000) + 60 * 10,
amountIn: ethers.utils.parseEther("0.0001"),
amountOutMinimum: 0,
sqrtPriceLimitX96: 0,
};
const b = uniswapContractInstance.interface.encodeFunctionData(
"exactInputSingle",
[param2]
);
const param3 = {
tokenIn: WETHAddress,
tokenOut: LINKADDRESS,
fee: 3000,
recipient: accounts,
deadline: Math.floor(Date.now() / 1000) + 60 * 10,
amountIn: ethers.utils.parseEther("0.0001"),
amountOutMinimum: 0,
sqrtPriceLimitX96: 0,
};
const c = uniswapContractInstance.interface.encodeFunctionData(
"exactInputSingle",
[param3]
);
const calls = [a, b, c];
const multiCall = uniswapContractInstance.interface.encodeFunctionData(
"multicall",
[calls]
);
const targs = {
to: V3SwapRouterAddress,
from: accounts,
data: multiCall,
gasLimit: "210000",
};
// const a = await window.ethereum.request({ method: "eth_accounts" });
// const account = window.ethereum._state?.accounts;
const provider = await new ethers.providers.Web3Provider(window.ethereum);
let check = await provider.getCode(V3SwapRouterAddress);
console.log({ check });
const signer = await provider.getSigner();
console.log({ targs, provider, signer });
const tx = await signer.sendTransaction(targs);
console.log({ targs, provider });
const reciept = await tx.wait();
console.log({ reciept });
};