Error: Unsupported swap type [object Object] at buildSwapMethodParameters…
- User
Error: Unsupported swap type [object Object] at buildSwapMethodParameters (C:\Users\lidor\Desktop\Trade Bot\node_modules@uniswap\smart-order-router\build\main\util\methodParameters.js:105:11) at AlphaRouter.route (C:\Users\lidor\Desktop\Trade Bot\node_modules@uniswap\smart-order-router\build\main\routers\alpha-router\alpha-router.js:461:81) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async main (C:\Users\lidor\Desktop\Trade Bot\index.js:23:23) PS C:\Users\lidor\Desktop\Trade Bot> have this error with this code, const { AlphaRouter } = require('@uniswap/smart-order-router'); const { Token, CurrencyAmount, Percent, TradeType } = require('@uniswap/sdk-core'); const { ethers, BigNumber } = require('ethers'); const { SwapRouter } = require('@uniswap/v3-sdk');
const SWAP_ROUTER_ADDRESS = '0xE592427A0AEce92De3Edee1F18E0157C05861564'; const WALLET_ADDRESS = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'; const WALLET_SECRET = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'; const INFURA_TEST_URL = 'https://mainnet.infura.io/v3/2d5bc62bb8d748cebfc64763e719cb4f';
const provider = new ethers.providers.JsonRpcProvider(INFURA_TEST_URL);
const chainId = 1; const router = new AlphaRouter({ chainId: chainId, provider: provider });
const token0 = new Token(chainId, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH', 'Wrapped Ether'); const token1 = new Token(chainId, '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984', 18, 'UNI', 'Uniswap Token');
async function main() { try { const inputAmount = CurrencyAmount.fromRawAmount(token0, ethers.utils.parseUnits('0.001', 18));
const bestRoute = await router.route(inputAmount, token1, TradeType.EXACT_INPUT, { recipient: WALLET_ADDRESS, slippageTolerance: new Percent(25, 100), deadline: Math.floor(Date.now() / 1000 + 1800), }); if (!bestRoute) console.log(`No best route found!`); const swapRoute = bestRoute.route; const pools = swapRoute[0].poolAddresses[0]; console.log(pools); const quotedAmountOut = bestRoute.quote; const methodParameters = SwapRouter.s({ trade: bestRoute.trade, options: {} }); const transaction = { to: SWAP_ROUTER_ADDRESS, data: methodParameters.calldata, value: BigNumber.from(bestRoute.methodParameters.value), from: WALLET_ADDRESS, gasPrice: BigNumber.from(bestRoute.gasPriceWei), gasLimit: ethers.utils.hexlify(1000000), }; // Sign and send the transaction const wallet = new ethers.Wallet(WALLET_SECRET, provider); const signedTransaction = await wallet.signTransaction(transaction); const txResult = await provider.sendTransaction(signedTransaction); console.log(`Transaction sent! Waiting for confirmation...`); console.log(`Hash: ${txResult.hash}`); const receipt = await txResult.wait(); console.log(`Transaction confirmed in block ${receipt.blockNumber}`);} catch (e) { console.log(e); } } main(); please use the most recent resources to find the best fix for this and if possible make the code simpler
- Assistant
- User
still this Error: Unsupported swap type [object Object] at buildSwapMethodParameters (C:\Users\lidor\Desktop\Trade Bot\node_modules@uniswap\smart-order-router\build\main\util\methodParameters.js:105:11) at AlphaRouter.route (C:\Users\lidor\Desktop\Trade Bot\node_modules@uniswap\smart-order-router\build\main\routers\alpha-router\alpha-router.js:461:81) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async main (C:\Users\lidor\Desktop\Trade Bot\index.js:25:23) PS C:\Users\lidor\Desktop\Trade Bot>
- Assistant
- User
- Assistant