Open ubuntutest opened 1 year ago
i'm trying with another function:
const swapRouterContract = new ethers.Contract(
V3SwapRouterAddress,
V3SwapRouterABI.concat(PeripheryPaymentsABI).concat(V2Router02ABI).concat(MulticallABI)
)
const params3 = {
amountOut: ethers.utils.parseEther('0.0001'),
path: ["0x..08d6","0x..9195"],
to: "0x..398b",
deadline: expiryDate,
}
const encData2 = swapRouterContract.interface.encodeFunctionData("swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)", [params3])
const calls = [encData2]
const encMultiCall = swapRouterContract.interface.encodeFunctionData("multicall(bytes[] data)", [calls])
const txArgs = {
to: V3SwapRouterAddress,
data: encMultiCall,
gasLimit: 40000,
gasPrice: ethers.utils.parseUnits("100", "gwei"),
value: ethers.utils.parseEther('0.0001'),
}
const tx = await signer.sendTransaction(txArgs)
console.log('tx', tx)
const receipt = await tx.wait()
console.log('receipt', receipt)
I keep getting this error:
reason: 'types / values length mismatch',
code: 'INVALID_ARGUMENT',
count: {types: 4, values: 1},
value: {
types: [[ParamType], [ParamType], [ParamType], [ParamType]],
values: [[Object]]
}
If you find a solution I'm interested bro... I followed the same Youtube tutorial as you and I'm stuck too ;)
currently this code works fine if I try to swap V3 tokens like UNI or USDC and WETH in the Goerli testnet:
If I try with smart contracts like ZETA I get the following error:
I also use the
getPool()
function and with both UNI and ZETA it gives me the correct pairPool