this error Error: invalid address or ENS name (argument="name",…
- User
this error Error: invalid address or ENS name (argument="name", value={"chainId":1,"decimals":18,"symbol":"WETH","name":"Wrapped Ether","isNative":false,"isToken":true,"address":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"}, code=INVALID_ARGUMENT, version=contracts/5.7.0) at Logger.makeError (C:\Users\lidor\Desktop\Trade Bot\node_modules@ethersproject\logger\lib\index.js:238:21) at Logger.throwError (C:\Users\lidor\Desktop\Trade Bot\node_modules@ethersproject\logger\lib\index.js:247:20) at Logger.throwArgumentError (C:\Users\lidor\Desktop\Trade Bot\node_modules@ethersproject\logger\lib\index.js:250:21) at C:\Users\lidor\Desktop\Trade Bot\node_modules@ethersproject\contracts\lib\index.js:94:32 at step (C:\Users\lidor\Desktop\Trade Bot\node_modules@ethersproject\contracts\lib\index.js:48:23) at Object.next (C:\Users\lidor\Desktop\Trade Bot\node_modules@ethersproject\contracts\lib\index.js:29:53) at fulfilled (C:\Users\lidor\Desktop\Trade Bot\node_modules@ethersproject\contracts\lib\index.js:20:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { reason: 'invalid address or ENS name', code: 'INVALID_ARGUMENT', argument: 'name', value: Token { chainId: 1, decimals: 18, symbol: 'WETH', name: 'Wrapped Ether', isNative: false, isToken: true, address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' } } Error: Could not parse fraction at Function.tryParseFraction (C:\Users\lidor\Desktop\Trade Bot\node_modules@uniswap\sdk-core\dist\sdk-core.cjs.development.js:81:11)
at Percent.lessThan (C:\Users\lidor\Desktop\Trade Bot\node_modules@uniswap\sdk-core\dist\sdk-core.cjs.development.js:112:32) at Trade.minimumAmountOut (C:\Users\lidor\Desktop\Trade Bot\node_modules@uniswap\v3-sdk\dist\v3-sdk.cjs.development.js:3027:25) at C:\Users\lidor\Desktop\Trade Bot\node_modules@uniswap\v3-sdk\dist\v3-sdk.cjs.development.js:3977:28 at Array.reduce () at Function.swapCallParameters (C:\Users\lidor\Desktop\Trade Bot\node_modules@uniswap\v3-sdk\dist\v3-sdk.cjs.development.js:3976:33)
at main (C:\Users\lidor\Desktop\Trade Bot\index.js:53:41) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) PS C:\Users\lidor\Desktop\Trade Bot> on this code const { ethers } = require('ethers'); const { Token, CurrencyAmount, Percent, TradeType } = require('@uniswap/sdk-core'); const { Pool, Route, Trade, SwapRouter } = require('@uniswap/v3-sdk'); const IUniswapV3PoolABI = require('@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json').abi; const Quoter = require('@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json').abi; const IERC20 = require('@uniswap/v2-periphery/build/IERC20.json'); const JSBI = require('jsbi');const SWAP_ROUTER_ADDRESS = '0xE592427A0AEce92De3Edee1F18E0157C05861564';
const WALLET_ADDRESS = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'; const WALLET_SECRET = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'; const INFURA_TEST_URL = 'https://mainnet.infura.io/v3/2d5bc62bb8d748cebfc64763e719cb4f'; const POOL_FACTORY_CONTRACT_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984'; const QUOTER_CONTRACT_ADDRESS = '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6';
- Assistant
This error is due to the fact that you're trying to create an ethers.Contract object using an object as the "address" parameter instead of a valid Ethereum address. When you're calling
getTokenTransferApproval(token0, SWAP_ROUTER_ADDRESS), you pass the entiretoken0object instead of the token's address. To fix this issue, you need to pass the address of the token as the first argument. Change this line:await getTokenTransferApproval(token0, SWAP_ROUTER_ADDRESS);to
await getTokenTransferApproval(token0.address, SWAP_ROUTER_ADDRESS);As for the second error "Error: Could not parse fraction": This error is potentially due to a problematic output amount, which would cause issues when the SDK attempts to process the trade. Try adding a console.log statement before the creation of the unchecked trade to see the output amount value:
console.log("Quoted Amount Out:", quotedAmountOut.toString());Additionally, ensure that the input and output tokens are correct. If they are not correctly configured, it could cause issues with the trade calculation. If the issue persists, consider posting more information about the output amount and any other relevant details.
- User
- Assistant
The first error is because estimating the gas limit for the transaction is returning an error, saying that the gas required exceeds the allowance. To solve this issue, you can use a higher gas limit when estimating the gas. Replace the following line:
const tx = { data: methodParameters.calldata, to: methodParameters.address, value: methodParameters.value, from: WALLET_ADDRESS, maxFeePerGas: await provider.getGasPrice(), maxPriorityFeePerGas: await provider.getGasPrice(), };with:
const tx = { data: methodParameters.calldata, to: methodParameters.address, value: methodParameters.value, from: WALLET_ADDRESS, maxFeePerGas: await provider.getGasPrice(), maxPriorityFeePerGas: await provider.getGasPrice(), gasLimit: ethers.BigNumber.from(1000000) // Add an arbitrary higher gas limit here };The second error "Error: Could not parse fraction" might be because of an invalid slippage tolerance value. To check if the slippage tolerance value and the trade details are correct, add the following console.log statements before constructing :