Commit 2eb5ff3c authored by Tina's avatar Tina Committed by GitHub

fix: USD price for WETH + don't call gql for testnets (#6133)

fix weth + dont call gql for testnets
parent a8864614
...@@ -73,8 +73,16 @@ export function chainIdToBackendName(chainId: number | undefined) { ...@@ -73,8 +73,16 @@ export function chainIdToBackendName(chainId: number | undefined) {
: CHAIN_ID_TO_BACKEND_NAME[SupportedChainId.MAINNET] : CHAIN_ID_TO_BACKEND_NAME[SupportedChainId.MAINNET]
} }
const GQL_CHAINS: number[] = [
SupportedChainId.MAINNET,
SupportedChainId.OPTIMISM,
SupportedChainId.POLYGON,
SupportedChainId.ARBITRUM_ONE,
SupportedChainId.CELO,
]
export function isGqlSupportedChain(chainId: number | undefined): chainId is SupportedChainId { export function isGqlSupportedChain(chainId: number | undefined): chainId is SupportedChainId {
return Boolean(chainId && CHAIN_ID_TO_BACKEND_NAME[chainId]) return !!chainId && GQL_CHAINS.includes(chainId)
} }
const URL_CHAIN_PARAM_TO_BACKEND: { [key: string]: Chain } = { const URL_CHAIN_PARAM_TO_BACKEND: { [key: string]: Chain } = {
......
...@@ -27,7 +27,8 @@ function useETHValue(currencyAmount?: CurrencyAmount<Currency>): CurrencyAmount< ...@@ -27,7 +27,8 @@ function useETHValue(currencyAmount?: CurrencyAmount<Currency>): CurrencyAmount<
RouterPreference.PRICE RouterPreference.PRICE
) )
if (chainId && currencyAmount && currencyAmount.currency.equals(nativeOnChain(chainId))) { // Get ETH value of ETH or WETH
if (chainId && currencyAmount && currencyAmount.currency.wrapped.equals(nativeOnChain(chainId).wrapped)) {
return new Price(currencyAmount.currency, currencyAmount.currency, '1', '1').quote(currencyAmount) return new Price(currencyAmount.currency, currencyAmount.currency, '1', '1').quote(currencyAmount)
} }
......
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