From cd8587a925f3841f71fb8a14f1d06b87f2975645 Mon Sep 17 00:00:00 2001 From: Eric Zhong Date: Tue, 5 Jul 2022 14:31:36 -0400 Subject: [PATCH 1/2] Fix linter issues & actions workflow (#107) * fix eslintrc.json * Add lint action to PR into main, and add eslint key * Add ts overrides * try moving parser opt into ovverrides * unbundle lint from prettier, run npm run fix:lint in workflow * fix eslint manual errors * disable no-useless-catch * fix eslint disable next line * add types/ and test/ ignorePatterns * add some disables * add @typescript-eslint/ prefix * fix * fix * npm run fix:lint * disable all errors * Fix code style issues with Prettier * test * re add PR * autofix: false * run local package.json prettier f ix instead * remove comments Co-authored-by: Lint Action --- .eslintrc.json | 9 +++------ .github/workflows/lint.yml | 14 +++++++------- cli/commands/quote.ts | 2 +- jest.config.js | 2 +- src/providers/cache-node.ts | 1 + src/providers/caching-gas-provider.ts | 1 + src/providers/caching-token-list-provider.ts | 2 ++ src/providers/caching-token-provider.ts | 2 ++ src/providers/eip-1559-gas-price-provider.ts | 2 ++ .../eth-gas-station-info-gas-price-provider.ts | 2 ++ src/providers/index.ts | 2 ++ src/providers/legacy-gas-price-provider.ts | 2 ++ src/providers/multicall-provider.ts | 1 + src/providers/multicall-uniswap-provider.ts | 2 ++ src/providers/on-chain-gas-price-provider.ts | 1 + src/providers/static-gas-price-provider.ts | 2 ++ src/providers/swap-router-provider.ts | 2 ++ src/providers/token-provider.ts | 2 ++ src/providers/token-validator-provider.ts | 2 ++ src/providers/uri-subgraph-provider.ts | 4 ++++ src/providers/v2/caching-subgraph-provider.ts | 1 + src/providers/v2/pool-provider.ts | 1 + src/providers/v2/quote-provider.ts | 3 +++ src/providers/v2/static-subgraph-provider.ts | 2 ++ .../v2/subgraph-provider-with-fallback.ts | 2 ++ src/providers/v2/subgraph-provider.ts | 3 +++ src/providers/v2/uri-subgraph-provider.ts | 1 + src/providers/v3/caching-pool-provider.ts | 2 ++ src/providers/v3/caching-subgraph-provider.ts | 1 + src/providers/v3/gas-data-provider.ts | 1 + src/providers/v3/pool-provider.ts | 1 + src/providers/v3/quote-provider.ts | 1 + src/providers/v3/static-subgraph-provider.ts | 2 ++ .../v3/subgraph-provider-with-fallback.ts | 2 ++ src/providers/v3/subgraph-provider.ts | 3 +++ src/providers/v3/uri-subgraph-provider.ts | 1 + src/routers/alpha-router/alpha-router.ts | 5 ++++- src/routers/alpha-router/config.ts | 1 + .../entities/route-with-valid-quote.ts | 1 + .../alpha-router/functions/best-swap-route.ts | 3 +++ .../functions/calculate-ratio-amount-in.ts | 1 + .../alpha-router/functions/compute-all-routes.ts | 1 + .../alpha-router/functions/get-candidate-pools.ts | 1 + src/routers/alpha-router/gas-models/gas-model.ts | 1 + .../gas-models/v2/v2-heuristic-gas-model.ts | 1 + .../alpha-router/gas-models/v3/gas-costs.ts | 1 + .../gas-models/v3/v3-heuristic-gas-model.ts | 2 ++ src/routers/legacy-router/bases.ts | 1 + src/routers/legacy-router/legacy-router.ts | 2 ++ src/routers/router.ts | 2 ++ src/util/addresses.ts | 1 + src/util/chains.ts | 1 + src/util/index.ts | 1 + src/util/log.ts | 2 ++ src/util/methodParameters.ts | 1 + src/util/routes.ts | 4 +++- 56 files changed, 100 insertions(+), 17 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 1e23acb55..1671d4222 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,7 +3,7 @@ "parser": "@typescript-eslint/parser", "parserOptions": { "project": "./tsconfig.json" }, "env": { "es6": true }, - "ignorePatterns": ["node_modules", "build", "coverage"], + "ignorePatterns": ["node_modules", "build", "coverage", "types", "test"], "plugins": ["import", "eslint-comments"], "extends": [ "eslint:recommended", @@ -15,6 +15,7 @@ ], "globals": { "BigInt": true, "console": true, "WebAssembly": true }, "rules": { + "eslint-comments/no-unlimited-disable": "off", "@typescript-eslint/explicit-module-boundary-types": "off", "eslint-comments/disable-enable-pair": [ "error", @@ -36,11 +37,7 @@ { "name": "ethers", "message": "Please import from '@ethersproject/module' directly to support tree-shaking." - } - ] - }, - { - "paths": [ + }, { "name": "mnemonist", "message": "Please import from 'mnemonist/module' directly to support tree-shaking." diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 408bd031a..4674e7461 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,6 +5,8 @@ on: branches: - main pull_request: + branches: + - main jobs: run-linters: @@ -24,10 +26,8 @@ jobs: - name: Install dependencies run: npm ci - - name: Run linters - uses: wearerequired/lint-action@v1 - with: - github_token: ${{ secrets.github_token }} - prettier: true - auto_fix: true - prettier_extensions: 'css,html,js,json,jsx,md,sass,scss,ts,tsx,vue,yaml,yml,sol' + - name: Run linter + run: npm run fix:lint + + - name: Run Prettier + run: npm run fix:prettier diff --git a/cli/commands/quote.ts b/cli/commands/quote.ts index 62507092b..ed838e4d4 100644 --- a/cli/commands/quote.ts +++ b/cli/commands/quote.ts @@ -11,7 +11,7 @@ import { parseAmount, SwapRoute, } from '../../src'; -import { TO_PROTOCOL } from '../../src/util/protocols'; +import { TO_PROTOCOL } from '../../src/util'; import { BaseCommand } from '../base-command'; dotenv.config(); diff --git a/jest.config.js b/jest.config.js index b775a4983..ab6472612 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,7 +4,7 @@ module.exports = { testEnvironment: 'node', moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node', 'd.ts'], /** - * @note use this if we have multiple integration test files + * @dev use this if we have multiple integration test files */ // testEnvironment: "jest-environment-hardhat" }; diff --git a/src/providers/cache-node.ts b/src/providers/cache-node.ts index 3d8092010..3aed9bf97 100644 --- a/src/providers/cache-node.ts +++ b/src/providers/cache-node.ts @@ -1,4 +1,5 @@ import NodeCache from 'node-cache'; + import { ICache } from './cache'; export class NodeJSCache implements ICache { diff --git a/src/providers/caching-gas-provider.ts b/src/providers/caching-gas-provider.ts index 2254efc79..808f4c1fa 100644 --- a/src/providers/caching-gas-provider.ts +++ b/src/providers/caching-gas-provider.ts @@ -1,5 +1,6 @@ import { ChainId } from '../util/chains'; import { log } from '../util/log'; + import { ICache } from './cache'; import { GasPrice, IGasPriceProvider } from './gas-price-provider'; diff --git a/src/providers/caching-token-list-provider.ts b/src/providers/caching-token-list-provider.ts index a2ac5e5dc..84526d957 100644 --- a/src/providers/caching-token-list-provider.ts +++ b/src/providers/caching-token-list-provider.ts @@ -2,9 +2,11 @@ import { Token } from '@uniswap/sdk-core'; import { TokenInfo, TokenList } from '@uniswap/token-lists'; import axios from 'axios'; import _ from 'lodash'; + import { ChainId } from '../util/chains'; import { log } from '../util/log'; import { metric, MetricLoggerUnit } from '../util/metric'; + import { ICache } from './cache'; import { ITokenProvider, TokenAccessor } from './token-provider'; diff --git a/src/providers/caching-token-provider.ts b/src/providers/caching-token-provider.ts index 01410bead..3b1f22bda 100644 --- a/src/providers/caching-token-provider.ts +++ b/src/providers/caching-token-provider.ts @@ -1,6 +1,8 @@ import { Token } from '@uniswap/sdk-core'; import _ from 'lodash'; + import { ChainId, log, WRAPPED_NATIVE_CURRENCY } from '../util'; + import { ICache } from './cache'; import { CELO, diff --git a/src/providers/eip-1559-gas-price-provider.ts b/src/providers/eip-1559-gas-price-provider.ts index ade78d651..0eae86066 100644 --- a/src/providers/eip-1559-gas-price-provider.ts +++ b/src/providers/eip-1559-gas-price-provider.ts @@ -1,7 +1,9 @@ import { BigNumber } from '@ethersproject/bignumber'; import { JsonRpcProvider } from '@ethersproject/providers'; import _ from 'lodash'; + import { log } from '../util/log'; + import { GasPrice, IGasPriceProvider } from './gas-price-provider'; export type RawFeeHistoryResponse = { diff --git a/src/providers/eth-gas-station-info-gas-price-provider.ts b/src/providers/eth-gas-station-info-gas-price-provider.ts index 882c72705..7eec18af5 100644 --- a/src/providers/eth-gas-station-info-gas-price-provider.ts +++ b/src/providers/eth-gas-station-info-gas-price-provider.ts @@ -1,7 +1,9 @@ import { BigNumber } from '@ethersproject/bignumber'; import retry from 'async-retry'; import axios from 'axios'; + import { log } from '../util/log'; + import { GasPrice, IGasPriceProvider } from './gas-price-provider'; // Gas prices from ethgasstation are in x10 Gwei. Must divide by 10 to use. diff --git a/src/providers/index.ts b/src/providers/index.ts index 50e935260..8de83d6fb 100644 --- a/src/providers/index.ts +++ b/src/providers/index.ts @@ -10,6 +10,7 @@ export * from './legacy-gas-price-provider'; export * from './multicall-provider'; export * from './multicall-uniswap-provider'; export * from './on-chain-gas-price-provider'; +export * from './static-gas-price-provider'; export * from './swap-router-provider'; export * from './token-provider'; export * from './uri-subgraph-provider'; @@ -19,6 +20,7 @@ export * from './v2/quote-provider'; export * from './v2/static-subgraph-provider'; export * from './v2/subgraph-provider'; export * from './v2/subgraph-provider-with-fallback'; +export * from './v2/uri-subgraph-provider'; export * from './v3/caching-pool-provider'; export * from './v3/caching-subgraph-provider'; export * from './v3/pool-provider'; diff --git a/src/providers/legacy-gas-price-provider.ts b/src/providers/legacy-gas-price-provider.ts index 36b60e8ec..fbb7799e0 100644 --- a/src/providers/legacy-gas-price-provider.ts +++ b/src/providers/legacy-gas-price-provider.ts @@ -1,5 +1,7 @@ import { JsonRpcProvider } from '@ethersproject/providers'; + import { log } from '../util'; + import { GasPrice, IGasPriceProvider } from './gas-price-provider'; export class LegacyGasPriceProvider extends IGasPriceProvider { diff --git a/src/providers/multicall-provider.ts b/src/providers/multicall-provider.ts index 558af83cc..d10ff566e 100644 --- a/src/providers/multicall-provider.ts +++ b/src/providers/multicall-provider.ts @@ -1,5 +1,6 @@ import { Interface } from '@ethersproject/abi'; import { BigNumber } from '@ethersproject/bignumber'; + import { ProviderConfig } from './provider'; export type CallSameFunctionOnMultipleContractsParams< diff --git a/src/providers/multicall-uniswap-provider.ts b/src/providers/multicall-uniswap-provider.ts index 87cdd7a43..f27cc72fd 100644 --- a/src/providers/multicall-uniswap-provider.ts +++ b/src/providers/multicall-uniswap-provider.ts @@ -2,11 +2,13 @@ import { BigNumber } from '@ethersproject/bignumber'; import { BaseProvider } from '@ethersproject/providers'; import _ from 'lodash'; import stats from 'stats-lite'; + import { UniswapInterfaceMulticall__factory } from '../types/v3/factories/UniswapInterfaceMulticall__factory'; import { UniswapInterfaceMulticall } from '../types/v3/UniswapInterfaceMulticall'; import { ChainId } from '../util'; import { UNISWAP_MULTICALL_ADDRESSES } from '../util/addresses'; import { log } from '../util/log'; + import { CallMultipleFunctionsOnSameContractParams, CallSameFunctionOnContractWithMultipleParams, diff --git a/src/providers/on-chain-gas-price-provider.ts b/src/providers/on-chain-gas-price-provider.ts index e53c44f28..5c831c4b2 100644 --- a/src/providers/on-chain-gas-price-provider.ts +++ b/src/providers/on-chain-gas-price-provider.ts @@ -1,4 +1,5 @@ import { ChainId } from '../util/chains'; + import { EIP1559GasPriceProvider } from './eip-1559-gas-price-provider'; import { GasPrice, IGasPriceProvider } from './gas-price-provider'; import { LegacyGasPriceProvider } from './legacy-gas-price-provider'; diff --git a/src/providers/static-gas-price-provider.ts b/src/providers/static-gas-price-provider.ts index 820e3430f..fb79ce666 100644 --- a/src/providers/static-gas-price-provider.ts +++ b/src/providers/static-gas-price-provider.ts @@ -1,4 +1,6 @@ +// eslint-disable-next-line no-restricted-imports import { BigNumber } from 'ethers'; + import { GasPrice, IGasPriceProvider } from './gas-price-provider'; export class StaticGasPriceProvider implements IGasPriceProvider { diff --git a/src/providers/swap-router-provider.ts b/src/providers/swap-router-provider.ts index f9a545561..4ff3c4530 100644 --- a/src/providers/swap-router-provider.ts +++ b/src/providers/swap-router-provider.ts @@ -1,7 +1,9 @@ import { ApprovalTypes } from '@uniswap/router-sdk'; import { Currency, CurrencyAmount } from '@uniswap/sdk-core'; + import { SwapRouter02__factory } from '../types/other/factories/SwapRouter02__factory'; import { log } from '../util'; + import { IMulticallProvider } from './multicall-provider'; type TokenApprovalTypes = { diff --git a/src/providers/token-provider.ts b/src/providers/token-provider.ts index 47579ce30..c9b6a699b 100644 --- a/src/providers/token-provider.ts +++ b/src/providers/token-provider.ts @@ -1,7 +1,9 @@ import { Token } from '@uniswap/sdk-core'; import _ from 'lodash'; + import { IERC20Metadata__factory } from '../types/v3/factories/IERC20Metadata__factory'; import { ChainId, log, WRAPPED_NATIVE_CURRENCY } from '../util'; + import { IMulticallProvider } from './multicall-provider'; import { ProviderConfig } from './provider'; diff --git a/src/providers/token-validator-provider.ts b/src/providers/token-validator-provider.ts index ccbc44a61..65e1491d7 100644 --- a/src/providers/token-validator-provider.ts +++ b/src/providers/token-validator-provider.ts @@ -1,7 +1,9 @@ import { Token } from '@uniswap/sdk-core'; import _ from 'lodash'; + import { ITokenValidator__factory } from '../types/other/factories/ITokenValidator__factory'; import { ChainId, log, WRAPPED_NATIVE_CURRENCY } from '../util'; + import { ICache } from './cache'; import { IMulticallProvider } from './multicall-provider'; import { ProviderConfig } from './provider'; diff --git a/src/providers/uri-subgraph-provider.ts b/src/providers/uri-subgraph-provider.ts index beef0ca91..65e72fc9e 100644 --- a/src/providers/uri-subgraph-provider.ts +++ b/src/providers/uri-subgraph-provider.ts @@ -1,8 +1,10 @@ import retry from 'async-retry'; import Timeout from 'await-timeout'; import axios from 'axios'; + import { ChainId } from '../util/chains'; import { log } from '../util/log'; + import { V2SubgraphPool } from './v2/subgraph-provider'; import { V3SubgraphPool } from './v3/subgraph-provider'; @@ -44,6 +46,7 @@ export class URISubgraphProvider< let response; + /* eslint-disable no-useless-catch */ try { response = await Promise.race([axios.get(this.uri), timerPromise]); } catch (err) { @@ -51,6 +54,7 @@ export class URISubgraphProvider< } finally { timeout.clear(); } + /* eslint-enable no-useless-catch */ const { data: poolsBuffer, status } = response; diff --git a/src/providers/v2/caching-subgraph-provider.ts b/src/providers/v2/caching-subgraph-provider.ts index eb87c724e..ff38148a0 100644 --- a/src/providers/v2/caching-subgraph-provider.ts +++ b/src/providers/v2/caching-subgraph-provider.ts @@ -1,4 +1,5 @@ import { ChainId } from '../../util/chains'; + import { ICache } from './../cache'; import { IV2SubgraphProvider, V2SubgraphPool } from './subgraph-provider'; diff --git a/src/providers/v2/pool-provider.ts b/src/providers/v2/pool-provider.ts index 8f9aa1483..a5ebd5986 100644 --- a/src/providers/v2/pool-provider.ts +++ b/src/providers/v2/pool-provider.ts @@ -3,6 +3,7 @@ import { Token } from '@uniswap/sdk-core'; import { Pair } from '@uniswap/v2-sdk'; import retry, { Options as RetryOptions } from 'async-retry'; import _ from 'lodash'; + import { IUniswapV2Pair__factory } from '../../types/v2/factories/IUniswapV2Pair__factory'; import { ChainId, CurrencyAmount } from '../../util'; import { log } from '../../util/log'; diff --git a/src/providers/v2/quote-provider.ts b/src/providers/v2/quote-provider.ts index 5bd9c59dc..bf2f2bdc4 100644 --- a/src/providers/v2/quote-provider.ts +++ b/src/providers/v2/quote-provider.ts @@ -4,6 +4,7 @@ import { InsufficientInputAmountError, InsufficientReservesError, } from '@uniswap/v2-sdk'; + import { V2Route } from '../../routers/router'; import { CurrencyAmount } from '../../util/amounts'; import { log } from '../../util/log'; @@ -37,7 +38,9 @@ export interface IV2QuoteProvider { * @class V2QuoteProvider */ export class V2QuoteProvider implements IV2QuoteProvider { + /* eslint-disable @typescript-eslint/no-empty-function */ constructor() {} + /* eslint-enable @typescript-eslint/no-empty-function */ public async getQuotesManyExactIn( amountIns: CurrencyAmount[], diff --git a/src/providers/v2/static-subgraph-provider.ts b/src/providers/v2/static-subgraph-provider.ts index 4414d5221..b2982b0d9 100644 --- a/src/providers/v2/static-subgraph-provider.ts +++ b/src/providers/v2/static-subgraph-provider.ts @@ -1,6 +1,7 @@ import { Token } from '@uniswap/sdk-core'; import { Pair } from '@uniswap/v2-sdk'; import _ from 'lodash'; + import { ChainId, WRAPPED_NATIVE_CURRENCY } from '../../util/chains'; import { log } from '../../util/log'; import { @@ -11,6 +12,7 @@ import { USDT_MAINNET, WBTC_MAINNET, } from '../token-provider'; + import { IV2SubgraphProvider, V2SubgraphPool } from './subgraph-provider'; type ChainTokenList = { diff --git a/src/providers/v2/subgraph-provider-with-fallback.ts b/src/providers/v2/subgraph-provider-with-fallback.ts index 70fb1fe3e..41c7e4c91 100644 --- a/src/providers/v2/subgraph-provider-with-fallback.ts +++ b/src/providers/v2/subgraph-provider-with-fallback.ts @@ -1,6 +1,8 @@ import { Token } from '@uniswap/sdk-core'; + import { log } from '../../util'; import { ProviderConfig } from '../provider'; + import { IV2SubgraphProvider, V2SubgraphPool } from './subgraph-provider'; /** diff --git a/src/providers/v2/subgraph-provider.ts b/src/providers/v2/subgraph-provider.ts index 8de61d20e..ea5236cc9 100644 --- a/src/providers/v2/subgraph-provider.ts +++ b/src/providers/v2/subgraph-provider.ts @@ -3,6 +3,7 @@ import retry from 'async-retry'; import Timeout from 'await-timeout'; import { gql, GraphQLClient } from 'graphql-request'; import _ from 'lodash'; + import { ChainId } from '../../util/chains'; import { log } from '../../util/log'; import { ProviderConfig } from '../provider'; @@ -151,6 +152,7 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { return pairs; }; + /* eslint-disable no-useless-catch */ try { const getPoolsPromise = getPools(); const timerPromise = timeout.set(this.timeout).then(() => { @@ -165,6 +167,7 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { } finally { timeout.clear(); } + /* eslint-enable no-useless-catch */ }, { retries: this.retries, diff --git a/src/providers/v2/uri-subgraph-provider.ts b/src/providers/v2/uri-subgraph-provider.ts index c7bab16d8..9d298d57f 100644 --- a/src/providers/v2/uri-subgraph-provider.ts +++ b/src/providers/v2/uri-subgraph-provider.ts @@ -1,4 +1,5 @@ import { URISubgraphProvider } from '../uri-subgraph-provider'; + import { IV2SubgraphProvider, V2SubgraphPool } from './subgraph-provider'; export class V2URISubgraphProvider diff --git a/src/providers/v3/caching-pool-provider.ts b/src/providers/v3/caching-pool-provider.ts index 62222eeb7..576f5f7e5 100644 --- a/src/providers/v3/caching-pool-provider.ts +++ b/src/providers/v3/caching-pool-provider.ts @@ -1,7 +1,9 @@ import { Token } from '@uniswap/sdk-core'; import { FeeAmount, Pool } from '@uniswap/v3-sdk'; + import { ChainId } from '../../util/chains'; import { log } from '../../util/log'; + import { ICache } from './../cache'; import { ProviderConfig } from './../provider'; import { IV3PoolProvider, V3PoolAccessor } from './pool-provider'; diff --git a/src/providers/v3/caching-subgraph-provider.ts b/src/providers/v3/caching-subgraph-provider.ts index e95e2b0a7..c2dd3a88d 100644 --- a/src/providers/v3/caching-subgraph-provider.ts +++ b/src/providers/v3/caching-subgraph-provider.ts @@ -1,4 +1,5 @@ import { ChainId } from '../../util/chains'; + import { ICache } from './../cache'; import { IV3SubgraphProvider, V3SubgraphPool } from './subgraph-provider'; diff --git a/src/providers/v3/gas-data-provider.ts b/src/providers/v3/gas-data-provider.ts index 22e8fa015..ff6deb137 100644 --- a/src/providers/v3/gas-data-provider.ts +++ b/src/providers/v3/gas-data-provider.ts @@ -1,5 +1,6 @@ import { BigNumber } from '@ethersproject/bignumber'; import { BaseProvider } from '@ethersproject/providers'; + import { GasDataArbitrum__factory } from '../../types/other/factories/GasDataArbitrum__factory'; import { GasPriceOracle__factory } from '../../types/other/factories/GasPriceOracle__factory'; import { diff --git a/src/providers/v3/pool-provider.ts b/src/providers/v3/pool-provider.ts index 0b8628cb6..e37c97c2e 100644 --- a/src/providers/v3/pool-provider.ts +++ b/src/providers/v3/pool-provider.ts @@ -3,6 +3,7 @@ import { Token } from '@uniswap/sdk-core'; import { computePoolAddress, FeeAmount, Pool } from '@uniswap/v3-sdk'; import retry, { Options as RetryOptions } from 'async-retry'; import _ from 'lodash'; + import { IUniswapV3PoolState__factory } from '../../types/v3/factories/IUniswapV3PoolState__factory'; import { ChainId } from '../../util'; import { V3_CORE_FACTORY_ADDRESSES } from '../../util/addresses'; diff --git a/src/providers/v3/quote-provider.ts b/src/providers/v3/quote-provider.ts index 90688b1d6..0b4a94ebd 100644 --- a/src/providers/v3/quote-provider.ts +++ b/src/providers/v3/quote-provider.ts @@ -4,6 +4,7 @@ import { encodeRouteToPath } from '@uniswap/v3-sdk'; import retry, { Options as RetryOptions } from 'async-retry'; import _ from 'lodash'; import stats from 'stats-lite'; + import { V3Route } from '../../routers/router'; import { IQuoterV2__factory } from '../../types/v3/factories/IQuoterV2__factory'; import { ChainId, metric, MetricLoggerUnit } from '../../util'; diff --git a/src/providers/v3/static-subgraph-provider.ts b/src/providers/v3/static-subgraph-provider.ts index 9f9f48cba..6499c5fdf 100644 --- a/src/providers/v3/static-subgraph-provider.ts +++ b/src/providers/v3/static-subgraph-provider.ts @@ -2,6 +2,7 @@ import { Token } from '@uniswap/sdk-core'; import { FeeAmount, Pool } from '@uniswap/v3-sdk'; import JSBI from 'jsbi'; import _ from 'lodash'; + import { unparseFeeAmount } from '../../util/amounts'; import { ChainId, WRAPPED_NATIVE_CURRENCY } from '../../util/chains'; import { log } from '../../util/log'; @@ -60,6 +61,7 @@ import { WMATIC_POLYGON_MUMBAI, WXDAI_GNOSIS, } from '../token-provider'; + import { IV3PoolProvider } from './pool-provider'; import { IV3SubgraphProvider, V3SubgraphPool } from './subgraph-provider'; diff --git a/src/providers/v3/subgraph-provider-with-fallback.ts b/src/providers/v3/subgraph-provider-with-fallback.ts index 258b9105c..f044cc8bf 100644 --- a/src/providers/v3/subgraph-provider-with-fallback.ts +++ b/src/providers/v3/subgraph-provider-with-fallback.ts @@ -1,6 +1,8 @@ import { Token } from '@uniswap/sdk-core'; + import { log } from '../../util'; import { ProviderConfig } from '../provider'; + import { IV3SubgraphProvider, V3SubgraphPool } from './subgraph-provider'; /** diff --git a/src/providers/v3/subgraph-provider.ts b/src/providers/v3/subgraph-provider.ts index 6a5a7ba09..7c3179827 100644 --- a/src/providers/v3/subgraph-provider.ts +++ b/src/providers/v3/subgraph-provider.ts @@ -3,6 +3,7 @@ import retry from 'async-retry'; import Timeout from 'await-timeout'; import { gql, GraphQLClient } from 'graphql-request'; import _ from 'lodash'; + import { ChainId } from '../../util/chains'; import { log } from '../../util/log'; import { ProviderConfig } from '../provider'; @@ -163,6 +164,7 @@ export class V3SubgraphProvider implements IV3SubgraphProvider { return pools; }; + /* eslint-disable no-useless-catch */ try { const getPoolsPromise = getPools(); const timerPromise = timeout.set(this.timeout).then(() => { @@ -177,6 +179,7 @@ export class V3SubgraphProvider implements IV3SubgraphProvider { } finally { timeout.clear(); } + /* eslint-enable no-useless-catch */ }, { retries: this.retries, diff --git a/src/providers/v3/uri-subgraph-provider.ts b/src/providers/v3/uri-subgraph-provider.ts index 8802e0f61..da5193d54 100644 --- a/src/providers/v3/uri-subgraph-provider.ts +++ b/src/providers/v3/uri-subgraph-provider.ts @@ -1,4 +1,5 @@ import { URISubgraphProvider } from '../uri-subgraph-provider'; + import { IV3SubgraphProvider, V3SubgraphPool } from './subgraph-provider'; export class V3URISubgraphProvider diff --git a/src/routers/alpha-router/alpha-router.ts b/src/routers/alpha-router/alpha-router.ts index a5b02afb0..4a2022ad4 100644 --- a/src/routers/alpha-router/alpha-router.ts +++ b/src/routers/alpha-router/alpha-router.ts @@ -16,7 +16,7 @@ import retry from 'async-retry'; import JSBI from 'jsbi'; import _ from 'lodash'; import NodeCache from 'node-cache'; -import { V3HeuristicGasModelFactory } from '.'; + import { CachingGasStationProvider, CachingTokenProviderWithFallback, @@ -100,6 +100,7 @@ import { SwapToRatioResponse, SwapToRatioStatus, } from '../router'; + import { DEFAULT_ROUTING_CONFIG_BY_CHAIN, ETH_GAS_STATION_API_URL, @@ -128,6 +129,8 @@ import { } from './gas-models/gas-model'; import { V2HeuristicGasModelFactory } from './gas-models/v2/v2-heuristic-gas-model'; +import { V3HeuristicGasModelFactory } from '.'; + export type AlphaRouterParams = { /** * The chain id for this instance of the Alpha Router. diff --git a/src/routers/alpha-router/config.ts b/src/routers/alpha-router/config.ts index aef24c3ec..7ffd4ebbb 100644 --- a/src/routers/alpha-router/config.ts +++ b/src/routers/alpha-router/config.ts @@ -1,4 +1,5 @@ import { ChainId } from '../../util/chains'; + import { AlphaRouterConfig } from './alpha-router'; export const DEFAULT_ROUTING_CONFIG_BY_CHAIN = ( diff --git a/src/routers/alpha-router/entities/route-with-valid-quote.ts b/src/routers/alpha-router/entities/route-with-valid-quote.ts index f525e414b..bfb88e491 100644 --- a/src/routers/alpha-router/entities/route-with-valid-quote.ts +++ b/src/routers/alpha-router/entities/route-with-valid-quote.ts @@ -2,6 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber'; import { Protocol } from '@uniswap/router-sdk'; import { Token, TradeType } from '@uniswap/sdk-core'; import _ from 'lodash'; + import { IV2PoolProvider } from '../../../providers/v2/pool-provider'; import { IV3PoolProvider } from '../../../providers/v3/pool-provider'; import { CurrencyAmount } from '../../../util/amounts'; diff --git a/src/routers/alpha-router/functions/best-swap-route.ts b/src/routers/alpha-router/functions/best-swap-route.ts index c4ea24fd6..83e623012 100644 --- a/src/routers/alpha-router/functions/best-swap-route.ts +++ b/src/routers/alpha-router/functions/best-swap-route.ts @@ -5,6 +5,7 @@ import JSBI from 'jsbi'; import _ from 'lodash'; import FixedReverseHeap from 'mnemonist/fixed-reverse-heap'; import Queue from 'mnemonist/queue'; + import { ChainId, HAS_L1_FEE } from '../../../util'; import { CurrencyAmount } from '../../../util/amounts'; import { log } from '../../../util/log'; @@ -12,6 +13,7 @@ import { metric, MetricLoggerUnit } from '../../../util/metric'; import { routeAmountsToString, routeToString } from '../../../util/routes'; import { AlphaRouterConfig } from '../alpha-router'; import { IGasModel, L1ToL2GasCosts, usdGasTokensByChain } from '../gas-models'; + import { RouteWithValidQuote, V3RouteWithValidQuote, @@ -422,6 +424,7 @@ export async function getBestSwapRouteBy( gasUsedL1: BigNumber.from(0), gasCostL1USD: CurrencyAmount.fromRawAmount(usdToken, 0), gasCostL1QuoteToken: CurrencyAmount.fromRawAmount( + // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain bestSwap[0]?.quoteToken!, 0 ), diff --git a/src/routers/alpha-router/functions/calculate-ratio-amount-in.ts b/src/routers/alpha-router/functions/calculate-ratio-amount-in.ts index 99804821d..19c99bbb8 100644 --- a/src/routers/alpha-router/functions/calculate-ratio-amount-in.ts +++ b/src/routers/alpha-router/functions/calculate-ratio-amount-in.ts @@ -1,4 +1,5 @@ import { Fraction } from '@uniswap/sdk-core'; + import { CurrencyAmount } from '../../../util/amounts'; export function calculateRatioAmountIn( diff --git a/src/routers/alpha-router/functions/compute-all-routes.ts b/src/routers/alpha-router/functions/compute-all-routes.ts index d408954c6..fb0abee62 100644 --- a/src/routers/alpha-router/functions/compute-all-routes.ts +++ b/src/routers/alpha-router/functions/compute-all-routes.ts @@ -1,6 +1,7 @@ import { Token } from '@uniswap/sdk-core'; import { Pair } from '@uniswap/v2-sdk'; import { Pool } from '@uniswap/v3-sdk'; + import { log } from '../../../util/log'; import { routeToString } from '../../../util/routes'; import { V2Route, V3Route } from '../../router'; diff --git a/src/routers/alpha-router/functions/get-candidate-pools.ts b/src/routers/alpha-router/functions/get-candidate-pools.ts index 48fd47012..397be1bce 100644 --- a/src/routers/alpha-router/functions/get-candidate-pools.ts +++ b/src/routers/alpha-router/functions/get-candidate-pools.ts @@ -2,6 +2,7 @@ import { Protocol } from '@uniswap/router-sdk'; import { Token, TradeType } from '@uniswap/sdk-core'; import { FeeAmount } from '@uniswap/v3-sdk'; import _ from 'lodash'; + import { ITokenListProvider, IV2SubgraphProvider, diff --git a/src/routers/alpha-router/gas-models/gas-model.ts b/src/routers/alpha-router/gas-models/gas-model.ts index 7c7172cb5..47cbf03fc 100644 --- a/src/routers/alpha-router/gas-models/gas-model.ts +++ b/src/routers/alpha-router/gas-models/gas-model.ts @@ -1,5 +1,6 @@ import { BigNumber } from '@ethersproject/bignumber'; import { Token } from '@uniswap/sdk-core'; + import { CUSD_CELO, CUSD_CELO_ALFAJORES, diff --git a/src/routers/alpha-router/gas-models/v2/v2-heuristic-gas-model.ts b/src/routers/alpha-router/gas-models/v2/v2-heuristic-gas-model.ts index dbd452beb..f27cb42d8 100644 --- a/src/routers/alpha-router/gas-models/v2/v2-heuristic-gas-model.ts +++ b/src/routers/alpha-router/gas-models/v2/v2-heuristic-gas-model.ts @@ -2,6 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber'; import { Token } from '@uniswap/sdk-core'; import { Pair } from '@uniswap/v2-sdk'; import _ from 'lodash'; + import { IV2PoolProvider } from '../../../../providers/v2/pool-provider'; import { ChainId, log, WRAPPED_NATIVE_CURRENCY } from '../../../../util'; import { CurrencyAmount } from '../../../../util/amounts'; diff --git a/src/routers/alpha-router/gas-models/v3/gas-costs.ts b/src/routers/alpha-router/gas-models/v3/gas-costs.ts index ab7eaa343..8fb816a71 100644 --- a/src/routers/alpha-router/gas-models/v3/gas-costs.ts +++ b/src/routers/alpha-router/gas-models/v3/gas-costs.ts @@ -1,4 +1,5 @@ import { BigNumber } from '@ethersproject/bignumber'; + import { ChainId } from '../../../..'; //l2 execution fee on optimism is roughly the same as mainnet diff --git a/src/routers/alpha-router/gas-models/v3/v3-heuristic-gas-model.ts b/src/routers/alpha-router/gas-models/v3/v3-heuristic-gas-model.ts index dbf5ffcb4..081e9f686 100644 --- a/src/routers/alpha-router/gas-models/v3/v3-heuristic-gas-model.ts +++ b/src/routers/alpha-router/gas-models/v3/v3-heuristic-gas-model.ts @@ -2,6 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber'; import { Percent, Token, TradeType } from '@uniswap/sdk-core'; import { FeeAmount, Pool } from '@uniswap/v3-sdk'; import _ from 'lodash'; + import { SwapOptions, WRAPPED_NATIVE_CURRENCY } from '../../../..'; import { ArbitrumGasData, @@ -22,6 +23,7 @@ import { IV3GasModelFactory, usdGasTokensByChain, } from '../gas-model'; + import { BASE_SWAP_COST, COST_PER_HOP, COST_PER_INIT_TICK } from './gas-costs'; // Cost for crossing an uninitialized tick. diff --git a/src/routers/legacy-router/bases.ts b/src/routers/legacy-router/bases.ts index a5586f354..68031a8c4 100644 --- a/src/routers/legacy-router/bases.ts +++ b/src/routers/legacy-router/bases.ts @@ -1,4 +1,5 @@ import { Token } from '@uniswap/sdk-core'; + import { DAI_MAINNET, ITokenProvider, diff --git a/src/routers/legacy-router/legacy-router.ts b/src/routers/legacy-router/legacy-router.ts index 337b0fbb3..fabe175aa 100644 --- a/src/routers/legacy-router/legacy-router.ts +++ b/src/routers/legacy-router/legacy-router.ts @@ -4,6 +4,7 @@ import { SwapRouter, Trade } from '@uniswap/router-sdk'; import { Currency, Token, TradeType } from '@uniswap/sdk-core'; import { FeeAmount, MethodParameters, Pool, Route } from '@uniswap/v3-sdk'; import _ from 'lodash'; + import { IMulticallProvider } from '../../providers/multicall-provider'; import { DAI_MAINNET, @@ -21,6 +22,7 @@ import { log } from '../../util/log'; import { routeToString } from '../../util/routes'; import { V3RouteWithValidQuote } from '../alpha-router'; import { IRouter, SwapOptions, SwapRoute, V3Route } from '../router'; + import { ADDITIONAL_BASES, BASES_TO_CHECK_TRADES_AGAINST, diff --git a/src/routers/router.ts b/src/routers/router.ts index 3c214adae..eec8c72fb 100644 --- a/src/routers/router.ts +++ b/src/routers/router.ts @@ -14,7 +14,9 @@ import { Position, Route as V3RouteRaw, } from '@uniswap/v3-sdk'; + import { CurrencyAmount } from '../util/amounts'; + import { RouteWithValidQuote } from './alpha-router'; export class V3Route extends V3RouteRaw {} diff --git a/src/util/addresses.ts b/src/util/addresses.ts index f4828bc89..1b7814e0b 100644 --- a/src/util/addresses.ts +++ b/src/util/addresses.ts @@ -1,5 +1,6 @@ import { Token } from '@uniswap/sdk-core'; import { FACTORY_ADDRESS } from '@uniswap/v3-sdk'; + import { ChainId, NETWORKS_WITH_SAME_UNISWAP_ADDRESSES } from './chains'; const CELO_V3_CORE_FACTORY_ADDRESSES = diff --git a/src/util/chains.ts b/src/util/chains.ts index 69e222788..814b0e125 100644 --- a/src/util/chains.ts +++ b/src/util/chains.ts @@ -1,4 +1,5 @@ import { Currency, Ether, NativeCurrency, Token } from '@uniswap/sdk-core'; + import { WGLMR_MOONBEAM, WXDAI_GNOSIS } from '../providers'; export enum ChainId { MAINNET = 1, diff --git a/src/util/index.ts b/src/util/index.ts index 2d30db128..b6abf44da 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -3,4 +3,5 @@ export * from './amounts'; export * from './chains'; export * from './log'; export * from './metric'; +export * from './protocols'; export * from './routes'; diff --git a/src/util/log.ts b/src/util/log.ts index 865306a15..45ce5404f 100644 --- a/src/util/log.ts +++ b/src/util/log.ts @@ -1,3 +1,5 @@ +/* eslint-disable */ + import Logger from 'bunyan'; class NullLogger implements Logger { diff --git a/src/util/methodParameters.ts b/src/util/methodParameters.ts index 658e9ea32..f886a4807 100644 --- a/src/util/methodParameters.ts +++ b/src/util/methodParameters.ts @@ -3,6 +3,7 @@ import { Currency, TradeType } from '@uniswap/sdk-core'; import { Route as V2RouteRaw } from '@uniswap/v2-sdk'; import { MethodParameters, Route as V3RouteRaw } from '@uniswap/v3-sdk'; import _ from 'lodash'; + import { CurrencyAmount, RouteWithValidQuote, diff --git a/src/util/routes.ts b/src/util/routes.ts index 932f4886c..5c7b905fe 100644 --- a/src/util/routes.ts +++ b/src/util/routes.ts @@ -2,10 +2,12 @@ import { Percent } from '@uniswap/sdk-core'; import { Pair } from '@uniswap/v2-sdk'; import { Pool } from '@uniswap/v3-sdk'; import _ from 'lodash'; -import { CurrencyAmount } from '.'; + import { RouteWithValidQuote } from '../routers/alpha-router'; import { V2Route, V3Route } from '../routers/router'; +import { CurrencyAmount } from '.'; + export const routeToString = (route: V3Route | V2Route): string => { const isV3Route = (route: V3Route | V2Route): route is V3Route => (route as V3Route).pools != undefined; From 7306173f2ec3ec8a21a14eca48240a6d73fbddbf Mon Sep 17 00:00:00 2001 From: Will Pote Date: Tue, 5 Jul 2022 14:52:34 -0400 Subject: [PATCH 2/2] chore(release): 2.5.32 --- CHANGELOG.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29d6a3cb2..f37a2bbc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [2.5.32](https://github.com/Uniswap/smart-order-router/compare/v2.5.31...v2.5.32) (2022-07-05) + ### [2.5.31](https://github.com/Uniswap/smart-order-router/compare/v2.5.30...v2.5.31) (2022-07-01) ### [2.5.30](https://github.com/Uniswap/smart-order-router/compare/v2.5.29...v2.5.30) (2022-05-14) diff --git a/package-lock.json b/package-lock.json index e61f9e214..6e13d5576 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "2.5.31", + "version": "2.5.32", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "2.5.31", + "version": "2.5.32", "license": "GPL", "dependencies": { "@nomiclabs/hardhat-ethers": "^2.0.6", diff --git a/package.json b/package.json index 447ce968d..270c0bc9e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "2.5.31", + "version": "2.5.32", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts",