import { FallbackProvider, StaticJsonRpcProvider } from '@ethersproject/providers'; import { SmartRouter, smartRoutes } from '@sovryn/sdk'; it('test', async () => { // const sellToken = Addresses.NATIVE_TOKEN // RBTC const sellToken = '0x9ac7fe28967b30e3a4e6e03286d715b42b453d10' // MOC const buyToken = '0xe700691da7b9851f2f35f8b8182c69c53ccad9db' // DOC const sellAmount = '100000000000000000' const chainId = 30 // Get Rootstock provider const rpcs = ["https://public-node.rsk.co", "https://mycrypto.rsk.co"] const provider = new FallbackProvider(rpcs.map((url) => new StaticJsonRpcProvider(url, chainId))); // Create smart router // Note: we removed some of the routes because they required permit to work const smartRouter = new SmartRouter(provider, [smartRoutes.ammSwapRoute, smartRoutes.myntBassetRoute, smartRoutes.myntFixedRateRoute]); // Map buy and sell token since on Rootstock native token = address(0) const mappedSellToken = mapNativeToken(sellToken); const mappedBuyToken = mapNativeToken(buyToken); // Find best quote try { await smartRouter.getBestQuote(mappedSellToken, mappedBuyToken, sellAmount); } catch (e) { console.error(e) } }) function mapNativeToken(address: Address) { return isSameAddress(address, Addresses.NATIVE_TOKEN) ? Addresses.ZERO_ADDRESS : address; }