feat: use useUSDPrice hook for calculating token usd value for auto slippage (#7555)

This commit is contained in:
Tina 2023-11-09 13:08:54 -05:00 committed by GitHub
parent 395b390df6
commit 682215a574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)