diff --git a/apps/web/src/state/swap/hooks.ts b/apps/web/src/state/swap/hooks.ts index 08fa8dff1ce89..43bcb0bf13d51 100644 --- a/apps/web/src/state/swap/hooks.ts +++ b/apps/web/src/state/swap/hooks.ts @@ -56,8 +56,9 @@ export function useSingleTokenSwapInfo( outputCurrencyId: string | undefined, outputCurrency: Currency | undefined, ): { [key: string]: number } { - const token0Address = useMemo(() => getTokenAddress(inputCurrencyId), [inputCurrencyId]) - const token1Address = useMemo(() => getTokenAddress(outputCurrencyId), [outputCurrencyId]) + const { chainId } = useActiveChainId() + const token0Address = useMemo(() => getTokenAddress(chainId, inputCurrencyId), [chainId, inputCurrencyId]) + const token1Address = useMemo(() => getTokenAddress(chainId, outputCurrencyId), [chainId, outputCurrencyId]) const amount = useMemo(() => tryParseAmount('1', inputCurrency ?? undefined), [inputCurrency]) diff --git a/apps/web/src/views/Swap/components/Chart/utils.ts b/apps/web/src/views/Swap/components/Chart/utils.ts index 443913f5e7861..97c5bb535cf8b 100644 --- a/apps/web/src/views/Swap/components/Chart/utils.ts +++ b/apps/web/src/views/Swap/components/Chart/utils.ts @@ -1,4 +1,4 @@ -import { BNB_ADDRESS } from './constants' +import { NATIVE, WNATIVE } from '@pancakeswap/sdk' const MIN_VALUE_DISPLAYED = 0.001 @@ -23,17 +23,15 @@ export const getTimeWindowChange = (lineChartData) => { } } -/** - * - * @deprecated not multi chain compatible - */ -export const getTokenAddress = (tokenAddress: undefined | string) => { - if (!tokenAddress) { +export const getTokenAddress = (chainId: number, tokenAddress: undefined | string) => { + if (!tokenAddress || !chainId) { return '' } const lowerCaseAddress = tokenAddress.toLowerCase() - if (lowerCaseAddress === 'bnb') { - return BNB_ADDRESS + const nativeToken = NATIVE[chainId] + const nativeSymbol = nativeToken?.symbol?.toLowerCase() || '' + if (lowerCaseAddress === nativeSymbol) { + return WNATIVE[chainId].address } return lowerCaseAddress