From 22558c8ad86336d246b3472d3f7bb54dfc6655f2 Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Wed, 11 Sep 2024 11:15:14 -0400 Subject: [PATCH] fix(router-sdk): Export TPool (#85) --- sdks/router-sdk/src/entities/mixedRoute/route.ts | 6 +----- sdks/router-sdk/src/entities/mixedRoute/trade.ts | 3 +-- sdks/router-sdk/src/utils/TPool.ts | 5 +++++ sdks/router-sdk/src/utils/encodeMixedRouteToPath.ts | 3 +-- sdks/router-sdk/src/utils/getOutputAmount.ts | 5 +---- sdks/router-sdk/src/utils/index.ts | 4 +--- sdks/router-sdk/src/utils/isValidTokenPath.ts | 5 +---- 7 files changed, 11 insertions(+), 20 deletions(-) create mode 100644 sdks/router-sdk/src/utils/TPool.ts diff --git a/sdks/router-sdk/src/entities/mixedRoute/route.ts b/sdks/router-sdk/src/entities/mixedRoute/route.ts index a8dcfa2cc..b61096b0a 100644 --- a/sdks/router-sdk/src/entities/mixedRoute/route.ts +++ b/sdks/router-sdk/src/entities/mixedRoute/route.ts @@ -1,12 +1,8 @@ import invariant from 'tiny-invariant' - import { Currency, Price, Token } from '@uniswap/sdk-core' -import { Pair } from '@uniswap/v2-sdk' -import { Pool as V3Pool } from '@uniswap/v3-sdk' import { Pool as V4Pool } from '@uniswap/v4-sdk' import { isValidTokenPath } from '../../utils/isValidTokenPath' - -type TPool = Pair | V3Pool | V4Pool +import { TPool } from '../../utils/TPool' /** * Represents a list of pools or pairs through which a swap can occur diff --git a/sdks/router-sdk/src/entities/mixedRoute/trade.ts b/sdks/router-sdk/src/entities/mixedRoute/trade.ts index 84b54887c..5405805ad 100644 --- a/sdks/router-sdk/src/entities/mixedRoute/trade.ts +++ b/sdks/router-sdk/src/entities/mixedRoute/trade.ts @@ -6,8 +6,7 @@ import invariant from 'tiny-invariant' import { ONE, ZERO } from '../../constants' import { MixedRouteSDK } from './route' import { getOutputAmount } from '../../utils/getOutputAmount' - -type TPool = Pair | V3Pool | V4Pool +import { TPool } from '../../utils/TPool' /** * Trades comparator, an extension of the input output comparator that also considers other dimensions of the trade in ranking them diff --git a/sdks/router-sdk/src/utils/TPool.ts b/sdks/router-sdk/src/utils/TPool.ts new file mode 100644 index 000000000..f3d9598ff --- /dev/null +++ b/sdks/router-sdk/src/utils/TPool.ts @@ -0,0 +1,5 @@ +import { Pool as V4Pool } from '@uniswap/v4-sdk' +import { Pair } from '@uniswap/v2-sdk' +import { Pool as V3Pool } from '@uniswap/v3-sdk' + +export type TPool = Pair | V3Pool | V4Pool diff --git a/sdks/router-sdk/src/utils/encodeMixedRouteToPath.ts b/sdks/router-sdk/src/utils/encodeMixedRouteToPath.ts index 4161095fa..845403427 100644 --- a/sdks/router-sdk/src/utils/encodeMixedRouteToPath.ts +++ b/sdks/router-sdk/src/utils/encodeMixedRouteToPath.ts @@ -2,11 +2,10 @@ import { pack } from '@ethersproject/solidity' import { Currency } from '@uniswap/sdk-core' import { Pool as V3Pool } from '@uniswap/v3-sdk' import { Pool as V4Pool } from '@uniswap/v4-sdk' -import { Pair } from '@uniswap/v2-sdk' import { MixedRouteSDK } from '../entities/mixedRoute/route' import { V2_FEE_PATH_PLACEHOLDER } from '../constants' +import { TPool } from './TPool' -type TPool = Pair | V3Pool | V4Pool /** * Converts a route to a hex encoded path * @notice only supports exactIn route encodings diff --git a/sdks/router-sdk/src/utils/getOutputAmount.ts b/sdks/router-sdk/src/utils/getOutputAmount.ts index c9abf7b68..ed67e57dd 100644 --- a/sdks/router-sdk/src/utils/getOutputAmount.ts +++ b/sdks/router-sdk/src/utils/getOutputAmount.ts @@ -1,9 +1,6 @@ import { Currency, CurrencyAmount } from '@uniswap/sdk-core' import { Pool as V4Pool } from '@uniswap/v4-sdk' -import { Pair } from '@uniswap/v2-sdk' -import { Pool as V3Pool } from '@uniswap/v3-sdk' - -type TPool = Pair | V3Pool | V4Pool +import { TPool } from './TPool' export async function getOutputAmount( pool: TPool, diff --git a/sdks/router-sdk/src/utils/index.ts b/sdks/router-sdk/src/utils/index.ts index 599c628d7..75b6a7c0b 100644 --- a/sdks/router-sdk/src/utils/index.ts +++ b/sdks/router-sdk/src/utils/index.ts @@ -1,10 +1,8 @@ import { Currency, Token } from '@uniswap/sdk-core' import { Pair } from '@uniswap/v2-sdk' import { Pool as V3Pool } from '@uniswap/v3-sdk' -import { Pool as V4Pool } from '@uniswap/v4-sdk' import { MixedRouteSDK } from '../entities/mixedRoute/route' - -type TPool = Pair | V3Pool | V4Pool +import { TPool } from './TPool' /** * Utility function to return each consecutive section of Pools or Pairs in a MixedRoute diff --git a/sdks/router-sdk/src/utils/isValidTokenPath.ts b/sdks/router-sdk/src/utils/isValidTokenPath.ts index af71b9764..d71a78b90 100644 --- a/sdks/router-sdk/src/utils/isValidTokenPath.ts +++ b/sdks/router-sdk/src/utils/isValidTokenPath.ts @@ -1,9 +1,6 @@ import { Currency, Token } from '@uniswap/sdk-core' import { Pool as V4Pool } from '@uniswap/v4-sdk' -import { Pair } from '@uniswap/v2-sdk' -import { Pool as V3Pool } from '@uniswap/v3-sdk' - -type TPool = Pair | V3Pool | V4Pool +import { TPool } from './TPool' export function isValidTokenPath(prevPool: TPool, currentPool: TPool, inputToken: Currency): boolean { if (currentPool.involvesToken(inputToken as Token)) return true