diff --git a/cli/base-command.ts b/cli/base-command.ts index 837d1d75e..65b8d753b 100644 --- a/cli/base-command.ts +++ b/cli/base-command.ts @@ -9,7 +9,7 @@ import { MethodParameters } from '@uniswap/v3-sdk'; import bunyan, { default as Logger } from 'bunyan'; import bunyanDebugStream from 'bunyan-debug-stream'; import _ from 'lodash'; -import NodeCache from 'node-cache'; +import NodeCache from '@cacheable/node-cache'; import { AlphaRouter, @@ -403,7 +403,7 @@ export abstract class BaseCommand extends Command { Math.min(estimatedGasUsedUSD.currency.decimals, 6) )}` ); - if(estimatedGasUsedGasToken) { + if (estimatedGasUsedGasToken) { this.logger.info( `Gas Used gas token: ${estimatedGasUsedGasToken.toFixed( Math.min(estimatedGasUsedGasToken.currency.decimals, 6) diff --git a/package-lock.json b/package-lock.json index f5f431072..e6374ba72 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "4.6.1", "license": "GPL", "dependencies": { + "@cacheable/node-cache": "^1.4.0", "@eth-optimism/sdk": "^3.2.2", "@types/brotli": "^1.3.4", "@uniswap/default-token-list": "^11.13.0", @@ -33,7 +34,6 @@ "graphql-request": "^3.4.0", "lodash": "^4.17.21", "mnemonist": "^0.38.3", - "node-cache": "^5.1.2", "stats-lite": "^2.2.0" }, "devDependencies": { @@ -703,6 +703,17 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, + "node_modules/@cacheable/node-cache": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@cacheable/node-cache/-/node-cache-1.4.0.tgz", + "integrity": "sha512-qo5GRCkyDSxws/dW6D1aMwHi+plU+Yzqk1pby54D6yGuMjcWe2MI6CoiYksGoRuNxaSBGb/zMpna25UtT/8fjw==", + "license": "MIT", + "dependencies": { + "cacheable": "^1.7.0", + "eventemitter3": "^5.0.1", + "keyv": "^5.0.3" + } + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -2003,6 +2014,15 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@keyv/serialize": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@keyv/serialize/-/serialize-1.0.1.tgz", + "integrity": "sha512-kKXeynfORDGPUEEl2PvTExM2zs+IldC6ZD8jPcfvI351MDNtfMlw9V9s4XZXuJNDK2qR5gbEKxRyoYx3quHUVQ==", + "license": "MIT", + "dependencies": { + "buffer": "^6.0.3" + } + }, "node_modules/@metamask/eth-sig-util": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@metamask/eth-sig-util/-/eth-sig-util-4.0.1.tgz", @@ -4395,6 +4415,16 @@ "node": ">= 0.8" } }, + "node_modules/cacheable": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/cacheable/-/cacheable-1.8.0.tgz", + "integrity": "sha512-ewQhhLQ7aUO95MALxgQ/04M8Eh97uCfinTK1pfktsCq+mULf4gNFAg1jSkLi5SDIw/2Md6K6Np3yWjWtYEzvqw==", + "license": "MIT", + "dependencies": { + "hookified": "^1.1.0", + "keyv": "^5.0.3" + } + }, "node_modules/caching-transform": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", @@ -4621,14 +4651,6 @@ "wrap-ansi": "^7.0.0" } }, - "node_modules/clone": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -5832,6 +5854,12 @@ "node": ">=6" } }, + "node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "license": "MIT" + }, "node_modules/evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", @@ -6736,6 +6764,15 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "node_modules/hookified": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-1.2.0.tgz", + "integrity": "sha512-32q0JrtZRAdCGeEa8IcBz4iABsrP4UiDrbFj/WADL1VyNHRvHdGs8MrYvaIZWMzbff1xdS3Tw8kBt6YvcSL7jQ==", + "license": "MIT", + "engines": { + "node": ">=20" + } + }, "node_modules/hosted-git-info": { "version": "2.8.9", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", @@ -8277,6 +8314,15 @@ "node": ">=10.0.0" } }, + "node_modules/keyv": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.1.0.tgz", + "integrity": "sha512-FUr1fbKVsj9IZkPkY9reJ80Lp2B3ldtFXH+xK0wvZYzOpwgHV1er3xP4JUhu2cgkV2X3BJQw+hzAbIGqa+hNIA==", + "license": "MIT", + "dependencies": { + "@keyv/serialize": "*" + } + }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -9065,17 +9111,6 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" }, - "node_modules/node-cache": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz", - "integrity": "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==", - "dependencies": { - "clone": "2.x" - }, - "engines": { - "node": ">= 8.0.0" - } - }, "node_modules/node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -12818,6 +12853,16 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, + "@cacheable/node-cache": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@cacheable/node-cache/-/node-cache-1.4.0.tgz", + "integrity": "sha512-qo5GRCkyDSxws/dW6D1aMwHi+plU+Yzqk1pby54D6yGuMjcWe2MI6CoiYksGoRuNxaSBGb/zMpna25UtT/8fjw==", + "requires": { + "cacheable": "^1.7.0", + "eventemitter3": "^5.0.1", + "keyv": "^5.0.3" + } + }, "@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -13693,6 +13738,14 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "@keyv/serialize": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@keyv/serialize/-/serialize-1.0.1.tgz", + "integrity": "sha512-kKXeynfORDGPUEEl2PvTExM2zs+IldC6ZD8jPcfvI351MDNtfMlw9V9s4XZXuJNDK2qR5gbEKxRyoYx3quHUVQ==", + "requires": { + "buffer": "^6.0.3" + } + }, "@metamask/eth-sig-util": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@metamask/eth-sig-util/-/eth-sig-util-4.0.1.tgz", @@ -15552,6 +15605,15 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" }, + "cacheable": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/cacheable/-/cacheable-1.8.0.tgz", + "integrity": "sha512-ewQhhLQ7aUO95MALxgQ/04M8Eh97uCfinTK1pfktsCq+mULf4gNFAg1jSkLi5SDIw/2Md6K6Np3yWjWtYEzvqw==", + "requires": { + "hookified": "^1.1.0", + "keyv": "^5.0.3" + } + }, "caching-transform": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", @@ -15711,11 +15773,6 @@ "wrap-ansi": "^7.0.0" } }, - "clone": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==" - }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -16678,6 +16735,11 @@ "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" }, + "eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" + }, "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", @@ -17334,6 +17396,11 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "hookified": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-1.2.0.tgz", + "integrity": "sha512-32q0JrtZRAdCGeEa8IcBz4iABsrP4UiDrbFj/WADL1VyNHRvHdGs8MrYvaIZWMzbff1xdS3Tw8kBt6YvcSL7jQ==" + }, "hosted-git-info": { "version": "2.8.9", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", @@ -18476,6 +18543,14 @@ "readable-stream": "^3.6.0" } }, + "keyv": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.1.0.tgz", + "integrity": "sha512-FUr1fbKVsj9IZkPkY9reJ80Lp2B3ldtFXH+xK0wvZYzOpwgHV1er3xP4JUhu2cgkV2X3BJQw+hzAbIGqa+hNIA==", + "requires": { + "@keyv/serialize": "*" + } + }, "kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -19085,14 +19160,6 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" }, - "node-cache": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz", - "integrity": "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==", - "requires": { - "clone": "2.x" - } - }, "node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", diff --git a/package.json b/package.json index 3c55bc06d..6d9129154 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "node": ">=10" }, "dependencies": { + "@cacheable/node-cache": "^1.4.0", "@eth-optimism/sdk": "^3.2.2", "@types/brotli": "^1.3.4", "@uniswap/default-token-list": "^11.13.0", @@ -57,7 +58,6 @@ "graphql-request": "^3.4.0", "lodash": "^4.17.21", "mnemonist": "^0.38.3", - "node-cache": "^5.1.2", "stats-lite": "^2.2.0" }, "devDependencies": { @@ -125,4 +125,4 @@ "oclif": { "commands": "./cli/commands" } -} +} \ No newline at end of file diff --git a/src/providers/cache-node.ts b/src/providers/cache-node.ts index aa4b3f327..c037aed82 100644 --- a/src/providers/cache-node.ts +++ b/src/providers/cache-node.ts @@ -1,9 +1,9 @@ -import NodeCache from 'node-cache'; +import NodeCache from '@cacheable/node-cache'; import { ICache } from './cache'; export class NodeJSCache implements ICache { - constructor(private nodeCache: NodeCache) {} + constructor(private nodeCache: NodeCache) { } async get(key: string): Promise { return this.nodeCache.get(key); diff --git a/src/routers/alpha-router/alpha-router.ts b/src/routers/alpha-router/alpha-router.ts index 358218498..ad0498f67 100644 --- a/src/routers/alpha-router/alpha-router.ts +++ b/src/routers/alpha-router/alpha-router.ts @@ -15,7 +15,7 @@ import { Pool, Position, SqrtPriceMath, TickMath } from '@uniswap/v3-sdk'; import retry from 'async-retry'; import JSBI from 'jsbi'; import _ from 'lodash'; -import NodeCache from 'node-cache'; +import NodeCache from '@cacheable/node-cache'; import { CachedRoutes, @@ -502,9 +502,8 @@ export type AlphaRouterConfig = { export class AlphaRouter implements - IRouter, - ISwapToRatio -{ + IRouter, + ISwapToRatio { protected chainId: ChainId; protected provider: BaseProvider; protected multicall2Provider: UniswapMulticallProvider; @@ -1318,8 +1317,8 @@ export class AlphaRouter // const gasTokenAccessor = await this.tokenProvider.getTokens([routingConfig.gasToken!]); const gasToken = routingConfig.gasToken ? ( - await this.tokenProvider.getTokens([routingConfig.gasToken]) - ).getTokenByAddress(routingConfig.gasToken) + await this.tokenProvider.getTokens([routingConfig.gasToken]) + ).getTokenByAddress(routingConfig.gasToken) : undefined; const providerConfig: GasModelProviderConfig = { @@ -2481,31 +2480,31 @@ export class AlphaRouter const nativeCurrency = WRAPPED_NATIVE_CURRENCY[this.chainId]; const nativeAndQuoteTokenV3PoolPromise = !quoteToken.equals(nativeCurrency) ? getHighestLiquidityV3NativePool( - quoteToken, - this.v3PoolProvider, - providerConfig - ) + quoteToken, + this.v3PoolProvider, + providerConfig + ) : Promise.resolve(null); const nativeAndAmountTokenV3PoolPromise = !amountToken.equals( nativeCurrency ) ? getHighestLiquidityV3NativePool( - amountToken, - this.v3PoolProvider, - providerConfig - ) + amountToken, + this.v3PoolProvider, + providerConfig + ) : Promise.resolve(null); // If a specific gas token is specified in the provider config // fetch the highest liq V3 pool with it and the native currency const nativeAndSpecifiedGasTokenV3PoolPromise = providerConfig?.gasToken && - !providerConfig?.gasToken.equals(nativeCurrency) + !providerConfig?.gasToken.equals(nativeCurrency) ? getHighestLiquidityV3NativePool( - providerConfig?.gasToken, - this.v3PoolProvider, - providerConfig - ) + providerConfig?.gasToken, + this.v3PoolProvider, + providerConfig + ) : Promise.resolve(null); const [ @@ -2529,15 +2528,15 @@ export class AlphaRouter const v2GasModelPromise = this.v2Supported?.includes(this.chainId) ? this.v2GasModelFactory - .buildGasModel({ - chainId: this.chainId, - gasPriceWei, - poolProvider: this.v2PoolProvider, - token: quoteToken, - l2GasDataProvider: this.l2GasDataProvider, - providerConfig: providerConfig, - }) - .catch((_) => undefined) // If v2 model throws uncaught exception, we return undefined v2 gas model, so there's a chance v3 route can go through + .buildGasModel({ + chainId: this.chainId, + gasPriceWei, + poolProvider: this.v2PoolProvider, + token: quoteToken, + l2GasDataProvider: this.l2GasDataProvider, + providerConfig: providerConfig, + }) + .catch((_) => undefined) // If v2 model throws uncaught exception, we return undefined v2 gas model, so there's a chance v3 route can go through : Promise.resolve(undefined); const v3GasModelPromise = this.v3GasModelFactory.buildGasModel({ diff --git a/test/integ/routers/alpha-router/alpha-router.integration.test.ts b/test/integ/routers/alpha-router/alpha-router.integration.test.ts index ace156e94..043ead0fd 100644 --- a/test/integ/routers/alpha-router/alpha-router.integration.test.ts +++ b/test/integ/routers/alpha-router/alpha-router.integration.test.ts @@ -35,7 +35,7 @@ import { parseEther } from 'ethers/lib/utils'; import 'jest-environment-hardhat'; import _ from 'lodash'; -import NodeCache from 'node-cache'; +import NodeCache from '@cacheable/node-cache'; import { AlphaRouter, AlphaRouterConfig, @@ -2745,7 +2745,7 @@ describe('alpha router integration', () => { GREENLIST_TOKEN_PAIRS.forEach(([tokenIn, tokenOut]) => { it(`${tokenIn.symbol} -> ${tokenOut.symbol} with portion`, async () => { const originalAmount = (tokenIn.symbol === 'WBTC' && tradeType === TradeType.EXACT_INPUT) || - (tokenOut.symbol === 'WBTC' && tradeType === TradeType.EXACT_OUTPUT) + (tokenOut.symbol === 'WBTC' && tradeType === TradeType.EXACT_OUTPUT) ? '1' : '100'; const amount = @@ -3512,7 +3512,7 @@ describe('quote for other networks', () => { const erc1 = TEST_ERC20_1[chain](); const erc2 = TEST_ERC20_2[chain](); - describe(`${ID_TO_NETWORK_NAME(chain)} ${tradeType} 2xx`, function() { + describe(`${ID_TO_NETWORK_NAME(chain)} ${tradeType} 2xx`, function () { const wrappedNative = WNATIVE_ON(chain); let alphaRouter: AlphaRouter; @@ -3642,7 +3642,7 @@ describe('quote for other networks', () => { }); } - describe(`Swap`, function() { + describe(`Swap`, function () { it(`${wrappedNative.symbol} -> erc20`, async () => { if (erc1.equals(V4_SEPOLIA_TEST_A)) { return; @@ -3652,7 +3652,7 @@ describe('quote for other networks', () => { const tokenOut = erc1; const amount = ChainId.ASTROCHAIN_SEPOLIA ? tradeType == TradeType.EXACT_INPUT ? - parseAmount('0.001', tokenIn): + parseAmount('0.001', tokenIn) : parseAmount('0.001', tokenOut) : tradeType == TradeType.EXACT_INPUT ? parseAmount('10', tokenIn) @@ -3719,7 +3719,7 @@ describe('quote for other networks', () => { const exactOutAmount = '1'; const amount = ChainId.ASTROCHAIN_SEPOLIA ? tradeType == TradeType.EXACT_INPUT ? - parseAmount('0.001', tokenIn): + parseAmount('0.001', tokenIn) : parseAmount('0.001', tokenOut) : tradeType == TradeType.EXACT_INPUT ? parseAmount('1', tokenIn) @@ -3769,8 +3769,8 @@ describe('quote for other networks', () => { ? parseAmount('1', tokenIn) : parseAmount('1', tokenOut) : tradeType == TradeType.EXACT_INPUT ? - parseAmount('0.00000000000001', tokenIn): - parseAmount('0.000001', tokenOut)); + parseAmount('0.00000000000001', tokenIn) : + parseAmount('0.000001', tokenOut)); const swap = await alphaRouter.route( amount, @@ -3797,7 +3797,7 @@ describe('quote for other networks', () => { const tokenOut = nativeOnChain(chain); const amount = tradeType == TradeType.EXACT_INPUT ? - parseAmount('0.000001', tokenIn): + parseAmount('0.000001', tokenIn) : parseAmount('0.00000000000001', tokenOut); const swap = await alphaRouter.route( @@ -3829,7 +3829,7 @@ describe('quote for other networks', () => { const exactOutAmount = '1'; const amount = ChainId.ASTROCHAIN_SEPOLIA ? tradeType == TradeType.EXACT_INPUT ? - parseAmount('0.001', tokenIn): + parseAmount('0.001', tokenIn) : parseAmount('0.001', tokenOut) : tradeType == TradeType.EXACT_INPUT ? parseAmount('1', tokenIn) @@ -3875,7 +3875,7 @@ describe('quote for other networks', () => { const exactOutAmount = chain === ChainId.BLAST ? '0.002' : '1'; const amount = ChainId.ASTROCHAIN_SEPOLIA ? tradeType == TradeType.EXACT_INPUT ? - parseAmount('0.001', tokenIn): + parseAmount('0.001', tokenIn) : parseAmount('0.001', tokenOut) : tradeType == TradeType.EXACT_INPUT ? parseAmount('1', tokenIn) @@ -3922,7 +3922,7 @@ describe('quote for other networks', () => { }); if (isTenderlyEnvironmentSet()) { - describe(`Simulate + Swap ${tradeType.toString()}`, function() { + describe(`Simulate + Swap ${tradeType.toString()}`, function () { // Tenderly does not support Celo if ([ ChainId.CELO, @@ -3981,13 +3981,13 @@ describe('quote for other networks', () => { // Universal Router is not deployed on Gorli. const swapOptions: SwapOptions = - { - type: SwapType.UNIVERSAL_ROUTER, - version: UniversalRouterVersion.V1_2, - recipient: WHALES(tokenIn), - slippageTolerance: SLIPPAGE, - deadlineOrPreviousBlockhash: parseDeadline(360), - }; + { + type: SwapType.UNIVERSAL_ROUTER, + version: UniversalRouterVersion.V1_2, + recipient: WHALES(tokenIn), + slippageTolerance: SLIPPAGE, + deadlineOrPreviousBlockhash: parseDeadline(360), + }; const swap = await alphaRouter.route( amount, @@ -4091,13 +4091,13 @@ describe('quote for other networks', () => { // Universal Router is not deployed on Gorli. const swapOptions: SwapOptions = - { - type: SwapType.UNIVERSAL_ROUTER, - version: UniversalRouterVersion.V1_2, - recipient: WHALES(tokenIn), - slippageTolerance: SLIPPAGE, - deadlineOrPreviousBlockhash: parseDeadline(360), - }; + { + type: SwapType.UNIVERSAL_ROUTER, + version: UniversalRouterVersion.V1_2, + recipient: WHALES(tokenIn), + slippageTolerance: SLIPPAGE, + deadlineOrPreviousBlockhash: parseDeadline(360), + }; const swap = await alphaRouter.route( amount, @@ -4188,13 +4188,13 @@ describe('quote for other networks', () => { // Universal Router is not deployed on Gorli. const swapOptions: SwapOptions = - { - type: SwapType.UNIVERSAL_ROUTER, - version: UniversalRouterVersion.V2_0, - recipient: WHALES(tokenIn), - slippageTolerance: SLIPPAGE, - deadlineOrPreviousBlockhash: parseDeadline(360), - }; + { + type: SwapType.UNIVERSAL_ROUTER, + version: UniversalRouterVersion.V2_0, + recipient: WHALES(tokenIn), + slippageTolerance: SLIPPAGE, + deadlineOrPreviousBlockhash: parseDeadline(360), + }; const swap = await alphaRouter.route( amount, @@ -4293,13 +4293,13 @@ describe('quote for other networks', () => { // Universal Router is not deployed on Gorli. const swapOptions: SwapOptions = - { - type: SwapType.UNIVERSAL_ROUTER, - version: UniversalRouterVersion.V1_2, - recipient: WHALES(tokenIn), - slippageTolerance: SLIPPAGE, - deadlineOrPreviousBlockhash: parseDeadline(360), - }; + { + type: SwapType.UNIVERSAL_ROUTER, + version: UniversalRouterVersion.V1_2, + recipient: WHALES(tokenIn), + slippageTolerance: SLIPPAGE, + deadlineOrPreviousBlockhash: parseDeadline(360), + }; const swap = await alphaRouter.route( amount, diff --git a/test/unit/providers/cache-node.test.ts b/test/unit/providers/cache-node.test.ts index 236543403..7d4d992ad 100644 --- a/test/unit/providers/cache-node.test.ts +++ b/test/unit/providers/cache-node.test.ts @@ -1,4 +1,4 @@ -import NodeCache from 'node-cache'; +import NodeCache from '@cacheable/node-cache'; import { NodeJSCache } from '../../../src'; describe('NodeJSCache', () => { diff --git a/test/unit/providers/token-properties-provider.test.ts b/test/unit/providers/token-properties-provider.test.ts index 14d1411ff..789606d5b 100644 --- a/test/unit/providers/token-properties-provider.test.ts +++ b/test/unit/providers/token-properties-provider.test.ts @@ -1,5 +1,5 @@ import { ChainId, Token, WETH9 } from '@uniswap/sdk-core'; -import NodeCache from 'node-cache'; +import NodeCache from '@cacheable/node-cache'; import sinon from 'sinon'; import { ITokenFeeFetcher, @@ -68,7 +68,7 @@ describe('TokenPropertiesProvider', () => { expect(Math.floor((underlyingCache.getTtl(CACHE_KEY(ChainId.MAINNET, token.address.toLowerCase())) ?? 0) / 1000)).toEqual(currentEpochTimeInSeconds + POSITIVE_CACHE_ENTRY_TTL); }) - it('succeeds to get token fee cache hit and second token fee fetcher call is skipped', async function() { + it('succeeds to get token fee cache hit and second token fee fetcher call is skipped', async function () { const underlyingCache: NodeCache = new NodeCache({ stdTTL: 3600, useClones: false }) const tokenPropertiesResultCache: NodeJSCache = new NodeJSCache(underlyingCache); const tokenPropertiesProvider = new TokenPropertiesProvider( @@ -98,7 +98,7 @@ describe('TokenPropertiesProvider', () => { expect(Math.floor((underlyingCache.getTtl(CACHE_KEY(ChainId.MAINNET, token.address.toLowerCase())) ?? 0) / 1000)).toEqual(currentEpochTimeInSeconds + POSITIVE_CACHE_ENTRY_TTL); }); - it('succeeds to get token allowlist with no on-chain calls nor caching', async function() { + it('succeeds to get token allowlist with no on-chain calls nor caching', async function () { const underlyingCache: NodeCache = new NodeCache({ stdTTL: 3600, useClones: false }) const tokenPropertiesResultCache: NodeJSCache = new NodeJSCache(underlyingCache); const tokenPropertiesProvider = new TokenPropertiesProvider( @@ -117,7 +117,7 @@ describe('TokenPropertiesProvider', () => { expect(await tokenPropertiesResultCache.get(CACHE_KEY(ChainId.MAINNET, allowListToken.address.toLowerCase()))).toBeUndefined(); }); - it('succeeds to get token properties in a single batch', async function() { + it('succeeds to get token properties in a single batch', async function () { const underlyingCache: NodeCache = new NodeCache({ stdTTL: 3600, useClones: false }) const tokenPropertiesResultCache: NodeJSCache = new NodeJSCache(underlyingCache); const tokenPropertiesProvider = new TokenPropertiesProvider( @@ -164,7 +164,7 @@ describe('TokenPropertiesProvider', () => { } }); - it('all token fee fetch failed', async function() { + it('all token fee fetch failed', async function () { const underlyingCache: NodeCache = new NodeCache({ stdTTL: 3600, useClones: false }) const tokenPropertiesResultCache: NodeJSCache = new NodeJSCache(underlyingCache); const tokenPropertiesProvider = new TokenPropertiesProvider( @@ -200,7 +200,7 @@ describe('TokenPropertiesProvider', () => { } }); - it('real ETH and BITBOY token fee fetch, only BITBOY fetched', async function() { + it('real ETH and BITBOY token fee fetch, only BITBOY fetched', async function () { const chain = ChainId.MAINNET; const chainProvider = ID_TO_PROVIDER(chain); const provider = new JsonRpcProvider(chainProvider, chain);