@@ -4,6 +4,7 @@ import { useMemo } from 'react'
44
55import { BASES_TO_CHECK_TRADES_AGAINST } from '../constants'
66import { PairState , usePairs } from '../data/Reserves'
7+ import { maxHopsFor } from '../utils/maxHopsFor'
78import { wrappedCurrency } from '../utils/wrappedCurrency'
89
910import { useActiveWeb3React } from './index'
@@ -58,8 +59,9 @@ export function useTradeExactIn(currencyAmountIn?: CurrencyAmount, currencyOut?:
5859
5960 return useMemo ( ( ) => {
6061 if ( currencyAmountIn && currencyOut && allowedPairs . length > 0 ) {
62+ const maxHops = maxHopsFor ( currencyAmountIn . currency , currencyOut )
6163 return (
62- Trade . bestTradeExactIn ( allowedPairs , currencyAmountIn , currencyOut , { maxHops : 3 , maxNumResults : 1 } ) [ 0 ] ?? null
64+ Trade . bestTradeExactIn ( allowedPairs , currencyAmountIn , currencyOut , { maxHops, maxNumResults : 1 } ) [ 0 ] ?? null
6365 )
6466 }
6567 return null
@@ -74,9 +76,9 @@ export function useTradeExactOut(currencyIn?: Currency, currencyAmountOut?: Curr
7476
7577 return useMemo ( ( ) => {
7678 if ( currencyIn && currencyAmountOut && allowedPairs . length > 0 ) {
79+ const maxHops = maxHopsFor ( currencyIn , currencyAmountOut . currency )
7780 return (
78- Trade . bestTradeExactOut ( allowedPairs , currencyIn , currencyAmountOut , { maxHops : 3 , maxNumResults : 1 } ) [ 0 ] ??
79- null
81+ Trade . bestTradeExactOut ( allowedPairs , currencyIn , currencyAmountOut , { maxHops, maxNumResults : 1 } ) [ 0 ] ?? null
8082 )
8183 }
8284 return null
0 commit comments