From 682215a574d9b3164bc7ce0587f84de080edf8ed Mon Sep 17 00:00:00 2001 From: Tina <59578595+tinaszheng@users.noreply.github.com> Date: Thu, 9 Nov 2023 13:08:54 -0500 Subject: [PATCH] feat: use useUSDPrice hook for calculating token usd value for auto slippage (#7555) --- src/hooks/useAutoSlippageTolerance.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hooks/useAutoSlippageTolerance.ts b/src/hooks/useAutoSlippageTolerance.ts index 9b08b4b859..70d3649ff0 100644 --- a/src/hooks/useAutoSlippageTolerance.ts +++ b/src/hooks/useAutoSlippageTolerance.ts @@ -11,7 +11,7 @@ import { useMemo } from 'react' import { ClassicTrade } from 'state/routing/types' import useGasPrice from './useGasPrice' -import { useStablecoinAmountFromFiatValue, useStablecoinValue } from './useStablecoinPrice' +import { useStablecoinAmountFromFiatValue } from './useStablecoinPrice' import { useUSDPrice } from './useUSDPrice' const DEFAULT_AUTO_SLIPPAGE = new Percent(5, 1000) // 0.5% @@ -77,7 +77,8 @@ const MAX_AUTO_SLIPPAGE_TOLERANCE = new Percent(5, 100) // 5% export default function useClassicAutoSlippageTolerance(trade?: ClassicTrade): Percent { const { chainId } = useWeb3React() const onL2 = chainId && L2_CHAIN_IDS.includes(chainId) - const outputDollarValue = useStablecoinValue(trade?.outputAmount) + const outputUSD = useUSDPrice(trade?.outputAmount) + const outputDollarValue = useStablecoinAmountFromFiatValue(outputUSD.data) const nativeGasPrice = useGasPrice() const gasEstimate = guesstimateGas(trade)