Commit e9ef3193 authored by Jesse's avatar Jesse Committed by GitHub

refactor: remaining changes from the large celo merge (#4088)

* refactor: useUSDCValue -> useStablecoinValue

* refactor: use the isCelo() helper

* refactor: remove unneeded white space
parent 6a1506ad
......@@ -6,7 +6,7 @@ import { Text } from 'rebass'
import { InterfaceTrade } from 'state/routing/types'
import styled, { ThemeContext } from 'styled-components/macro'
import { useUSDCValue } from '../../hooks/useStablecoinPrice'
import { useStablecoinValue } from '../../hooks/useStablecoinPrice'
import { ThemedText } from '../../theme'
import { isAddress, shortenAddress } from '../../utils'
import { computeFiatValuePriceImpact } from '../../utils/computeFiatValuePriceImpact'
......@@ -55,8 +55,8 @@ export default function SwapModalHeader({
const [showInverted, setShowInverted] = useState<boolean>(false)
const fiatValueInput = useUSDCValue(trade.inputAmount)
const fiatValueOutput = useUSDCValue(trade.outputAmount)
const fiatValueInput = useStablecoinValue(trade.inputAmount)
const fiatValueOutput = useStablecoinValue(trade.outputAmount)
return (
<AutoColumn gap={'4px'} style={{ marginTop: '1rem' }}>
......
......@@ -9,7 +9,7 @@ import { useMemo } from 'react'
import { InterfaceTrade } from 'state/routing/types'
import useGasPrice from './useGasPrice'
import useStablecoinPrice, { useUSDCValue } from './useStablecoinPrice'
import useStablecoinPrice, { useStablecoinValue } from './useStablecoinPrice'
const V3_SWAP_DEFAULT_SLIPPAGE = new Percent(50, 10_000) // .50%
const ONE_TENTHS_PERCENT = new Percent(10, 10_000) // .10%
......@@ -37,7 +37,7 @@ export default function useAutoSlippageTolerance(
): Percent {
const { chainId } = useWeb3React()
const onL2 = chainId && L2_CHAIN_IDS.includes(chainId)
const outputDollarValue = useUSDCValue(trade?.outputAmount)
const outputDollarValue = useStablecoinValue(trade?.outputAmount)
const nativeGasPrice = useGasPrice()
const gasEstimate = guesstimateGas(trade)
......
......@@ -7,6 +7,7 @@ import { useSingleContractWithCallData } from 'lib/hooks/multicall'
import { useMemo } from 'react'
import { InterfaceTrade, TradeState } from 'state/routing/types'
import { isCelo } from '../constants/tokens'
import { useAllV3Routes } from './useAllV3Routes'
import { useQuoter } from './useContract'
......@@ -36,10 +37,7 @@ export function useClientSideV3Trade<TTradeType extends TradeType>(
const { chainId } = useWeb3React()
// Chains deployed using the deploy-v3 script only deploy QuoterV2.
const useQuoterV2 = useMemo(
() => Boolean(chainId && [SupportedChainId.CELO, SupportedChainId.CELO_ALFAJORES].includes(chainId)),
[chainId]
)
const useQuoterV2 = useMemo(() => Boolean(chainId && isCelo(chainId)), [chainId])
const quoter = useQuoter(useQuoterV2)
const callData = useMemo(
() =>
......
......@@ -62,7 +62,7 @@ export default function useStablecoinPrice(currency?: Currency): Price<Currency,
return lastPrice.current
}
export function useUSDCValue(currencyAmount: CurrencyAmount<Currency> | undefined | null) {
export function useStablecoinValue(currencyAmount: CurrencyAmount<Currency> | undefined | null) {
const price = useStablecoinPrice(currencyAmount?.currency)
return useMemo(() => {
......
......@@ -8,7 +8,6 @@ import { useMemo } from 'react'
import { getTxOptimizedSwapRouter, SwapRouterVersion } from 'utils/getTxOptimizedSwapRouter'
import { ApprovalState, useApproval, useApprovalStateForSpender } from '../useApproval'
export { ApprovalState } from '../useApproval'
/** Returns approval state for all known swap routers */
......
......@@ -43,7 +43,7 @@ import { useArgentWalletContract } from '../../hooks/useArgentWalletContract'
import { useV3NFTPositionManagerContract } from '../../hooks/useContract'
import { useDerivedPositionInfo } from '../../hooks/useDerivedPositionInfo'
import { useIsSwapUnsupported } from '../../hooks/useIsSwapUnsupported'
import { useUSDCValue } from '../../hooks/useStablecoinPrice'
import { useStablecoinValue } from '../../hooks/useStablecoinPrice'
import useTransactionDeadline from '../../hooks/useTransactionDeadline'
import { useV3PositionFromTokenId } from '../../hooks/useV3Positions'
import { useToggleWalletModal } from '../../state/application/hooks'
......@@ -183,8 +183,8 @@ export default function AddLiquidity({
}
const usdcValues = {
[Field.CURRENCY_A]: useUSDCValue(parsedAmounts[Field.CURRENCY_A]),
[Field.CURRENCY_B]: useUSDCValue(parsedAmounts[Field.CURRENCY_B]),
[Field.CURRENCY_A]: useStablecoinValue(parsedAmounts[Field.CURRENCY_A]),
[Field.CURRENCY_B]: useStablecoinValue(parsedAmounts[Field.CURRENCY_B]),
}
// get the max amounts user can add
......
......@@ -42,7 +42,7 @@ import useENSAddress from '../../hooks/useENSAddress'
import { useERC20PermitFromTrade, UseERC20PermitState } from '../../hooks/useERC20Permit'
import useIsArgentWallet from '../../hooks/useIsArgentWallet'
import { useIsSwapUnsupported } from '../../hooks/useIsSwapUnsupported'
import { useUSDCValue } from '../../hooks/useStablecoinPrice'
import { useStablecoinValue } from '../../hooks/useStablecoinPrice'
import useWrapCallback, { WrapErrorText, WrapType } from '../../hooks/useWrapCallback'
import { useToggleWalletModal } from '../../state/application/hooks'
import { Field } from '../../state/swap/actions'
......@@ -153,8 +153,8 @@ export default function Swap({ history }: RouteComponentProps) {
// show price estimates based on wrap trade
const inputValue = showWrap ? parsedAmount : trade?.inputAmount
const outputValue = showWrap ? parsedAmount : trade?.outputAmount
const fiatValueInput = useUSDCValue(inputValue)
const fiatValueOutput = useUSDCValue(outputValue)
const fiatValueInput = useStablecoinValue(inputValue)
const fiatValueOutput = useStablecoinValue(outputValue)
const priceImpact = useMemo(
() => (routeIsSyncing ? undefined : computeFiatValuePriceImpact(fiatValueInput, fiatValueOutput)),
[fiatValueInput, fiatValueOutput, routeIsSyncing]
......
......@@ -7,6 +7,7 @@ import { useCallback, useEffect } from 'react'
import { useAppDispatch } from 'state/hooks'
import { useAllLists } from 'state/lists/hooks'
import { isCelo } from '../../constants/tokens'
import { useFetchListCallback } from '../../hooks/useFetchListCallback'
import useIsWindowVisible from '../../hooks/useIsWindowVisible'
import { acceptListUpdate, enableList } from './actions'
......@@ -36,7 +37,7 @@ export default function Updater(): null {
if (chainId && [SupportedChainId.ARBITRUM_ONE, SupportedChainId.ARBITRUM_RINKEBY].includes(chainId)) {
dispatch(enableList(ARBITRUM_LIST))
}
if (chainId && [SupportedChainId.CELO, SupportedChainId.CELO_ALFAJORES].includes(chainId)) {
if (chainId && isCelo(chainId)) {
dispatch(enableList(CELO_LIST))
}
}, [chainId, dispatch])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment