Open lokesh-systango opened 2 months ago
The SDK returns the error
Cannot return best route
for using TradeType as EXACT_OUTPUT
`
import { Fetcher, Route, Token, TokenAmount, Trade, TradeType } from "quickswap-sdk"; const provider = new ethers.providers.JsonRpcProvider(httpsUrl, chainId); // Create contract instances for input and output tokens const contractIn = new ethers.Contract(token, erc20Abi, provider); const contractOut = new ethers.Contract(StableCoinAddress, erc20Abi, provider); // Helper function to get token details const getToken = async function (contract: ethers.Contract): Promise<Token[]> { const [dec, symbol, name] = await Promise.all([contract.decimals(), contract.symbol(), contract.name()]); return [new Token(chainId, contract.address, dec, symbol, name)]; }; // Retrieve token details for input and output tokens const [tokenIn] = await getToken(contractIn); const [tokenOut] = await getToken(contractOut); // Fetch pair data and create route const pair = await Fetcher.fetchPairData(tokenOut, tokenIn, provider); const route = new Route([pair], tokenOut); // Map route addresses and create trade instance const routePathAddresses = route.path.map((token) => token.address); const amountIn = new TokenAmount(tokenOut, ethers.utils.parseUnits(amount, tokenOut.decimals).toString()); const trade = new Trade(route, amountIn, TradeType.EXACT_OUTPUT);
This code runs fine for the case of EXACT_INPUT but gives this error for EXACT_OUTPUT.
The SDK returns the error
for using TradeType as EXACT_OUTPUT
Steps to reproduce -
`
`
This code runs fine for the case of EXACT_INPUT but gives this error for EXACT_OUTPUT.