Skip to content

Commit

Permalink
fix(router-sdk): Export TPool (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilz authored Sep 11, 2024
1 parent 27231c8 commit 22558c8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 20 deletions.
6 changes: 1 addition & 5 deletions sdks/router-sdk/src/entities/mixedRoute/route.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions sdks/router-sdk/src/entities/mixedRoute/trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions sdks/router-sdk/src/utils/TPool.ts
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions sdks/router-sdk/src/utils/encodeMixedRouteToPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions sdks/router-sdk/src/utils/getOutputAmount.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 1 addition & 3 deletions sdks/router-sdk/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions sdks/router-sdk/src/utils/isValidTokenPath.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 22558c8

Please sign in to comment.