I am working with the Quoter from Uniswap V3, here is the part of the function that challenges me:
...
// Reformat Amount In
if (!isNaN(amtIn)) {amtIn = amtIn.toString()}
let amountIn = ethers.utils.parseUnits(amtIn, inputDecimalsA).toString()
// Get Uniswap V3 Quote
const quoterAddress = "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6";
const quoterContract = new ethers.Contract(quoterAddress, QuoterABI, provider)
let quotedAmountOut = 0
try {
quotedAmountOut = await quoterContract.callStatic.quoteExactInputSingle(
inputTokenA,
inputTokenB,
tokenFee,
amountIn,
0)
} catch (err) {
console.log("Something went wrong....", err)
return 0
}
// Format Output
let outputAmount = ethers.utils.formatUnits(quotedAmountOut, inputDecimalsB).toString()
return outputAmount
}
When I run this with the latest version of uniswap sdk and ethers, I get these errors:
TypeError: Cannot read properties of undefined (reading 'quoteExactInputSingle')
or
contract runner does not support sending transactions (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=6.7.1)
It seems like the latest dependencies having a problem with the .callStatic but even without it it didn't work.
The interesting thing is, when I am using older dependency versions like below, it works. Older Versions:
"dependencies": {
"@uniswap/sdk-core": "^3.0.1",
"@uniswap/v3-sdk": "^3.6.3",
"dotenv": "^16.3.1",
"ethers": "^5.7.2",
"uniswap": "^0.0.1",
"web3": "^1.6.1",
"yarn": "^1.22.19"
}
I tried to read the Quoter.sol Smart Contract and try to understand what causes the problem, but without success. Link: (https://github.com/Uniswap/v3-periphery/blob/v1.0.0/contracts/lens/Quoter.sol)
I would really appreciate if someone out there could help me solving this issue and tell me what to change in the code to make it work with the latest dependencies since I fear that other functions I would like to use like trades are not going to work with the old versions. Thanks in advance