From 8d0f11df973896055d2259d58b287109ac0578b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Ho=C3=A0i=20Danh?= <33005392+nguyenhoaidanh@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:34:14 +0700 Subject: [PATCH] add hardcode mKnc on optimism (#2327) --- .../InboxItemKyberAIWatchList.tsx | 18 +++++++++++---- .../NotificationCenter/KyberAIWatchlist.tsx | 11 +++++---- .../SwapButtonWithPriceImpact.tsx | 2 +- src/components/swapv2/LimitOrder/Tutorial.tsx | 10 ++++---- src/utils/tokenInfo.ts | 23 ++++++++++--------- 5 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/components/Announcement/PrivateAnnoucement/InboxItemKyberAIWatchList.tsx b/src/components/Announcement/PrivateAnnoucement/InboxItemKyberAIWatchList.tsx index 19f2a3f02a..f7696b09be 100644 --- a/src/components/Announcement/PrivateAnnoucement/InboxItemKyberAIWatchList.tsx +++ b/src/components/Announcement/PrivateAnnoucement/InboxItemKyberAIWatchList.tsx @@ -1,3 +1,4 @@ +import { useCallback } from 'react' import { useNavigate } from 'react-router-dom' import { Text } from 'rebass' import styled from 'styled-components' @@ -10,6 +11,7 @@ import Column from 'components/Column' import { TokenLogoWithShadow } from 'components/Logo' import { APP_PATHS } from 'constants/index' import useTheme from 'hooks/useTheme' +import { KyberAIListType } from 'pages/TrueSightV2/types' import { calculateValueToColor, getTypeByKyberScore } from 'pages/TrueSightV2/utils' import { formatDisplayNumber } from 'utils/numbers' @@ -55,7 +57,15 @@ export const TokenInfo = ({ ) } -function InboxItemBridge({ +export const useNavigateToMyWatchList = () => { + const navigate = useNavigate() + return useCallback( + () => navigate(`${APP_PATHS.KYBERAI_RANKINGS}?listType=${KyberAIListType.MYWATCHLIST}`), + [navigate], + ) +} + +function InboxItemKyberAIWatchlist({ announcement, onRead, style, @@ -66,9 +76,9 @@ function InboxItemBridge({ const { assets = [] } = templateBody || {} const [token1, token2, token3] = assets - const navigate = useNavigate() + const navigateToWatchList = useNavigateToMyWatchList() const onClick = () => { - navigate(APP_PATHS.KYBERAI_RANKINGS) + navigateToWatchList() onRead(announcement, 'kyberAI_watchlist') } @@ -94,4 +104,4 @@ function InboxItemBridge({ ) } -export default InboxItemBridge +export default InboxItemKyberAIWatchlist diff --git a/src/components/Announcement/PrivateAnnoucement/NotificationCenter/KyberAIWatchlist.tsx b/src/components/Announcement/PrivateAnnoucement/NotificationCenter/KyberAIWatchlist.tsx index 2bf1223fd5..a956a8f899 100644 --- a/src/components/Announcement/PrivateAnnoucement/NotificationCenter/KyberAIWatchlist.tsx +++ b/src/components/Announcement/PrivateAnnoucement/NotificationCenter/KyberAIWatchlist.tsx @@ -1,15 +1,16 @@ import { Trans } from '@lingui/macro' import { Fragment, useState } from 'react' -import { useNavigate } from 'react-router-dom' import { Flex } from 'rebass' import styled from 'styled-components' import { ReactComponent as DropdownSVG } from 'assets/svg/down.svg' import InboxIcon from 'components/Announcement/PrivateAnnoucement/Icon' -import { TokenInfo } from 'components/Announcement/PrivateAnnoucement/InboxItemKyberAIWatchList' +import { + TokenInfo, + useNavigateToMyWatchList, +} from 'components/Announcement/PrivateAnnoucement/InboxItemKyberAIWatchList' import { PrivateAnnouncementPropCenter } from 'components/Announcement/PrivateAnnoucement/NotificationCenter' import { AnnouncementTemplateKyberAIWatchlist } from 'components/Announcement/type' -import { APP_PATHS } from 'constants/index' import useTheme from 'hooks/useTheme' import { formatTime } from 'utils/time' @@ -29,7 +30,7 @@ export default function AnnouncementItem({ const { sentAt, templateType, templateBody } = announcement const { assets = [] } = templateBody || {} const theme = useTheme() - const navigate = useNavigate() + const navigateToWatchList = useNavigateToMyWatchList() const [expand, setExpand] = useState(false) const slice = 3 const minimalAssets = assets.slice(0, slice) @@ -37,7 +38,7 @@ export default function AnnouncementItem({ return ( setExpand(!expand)}> - navigate(APP_PATHS.KYBERAI_RANKINGS)}> + <Title onClick={navigateToWatchList}> <InboxIcon type={templateType} /> {title} diff --git a/src/components/SwapForm/SwapActionButton/SwapButtonWithPriceImpact.tsx b/src/components/SwapForm/SwapActionButton/SwapButtonWithPriceImpact.tsx index 97bbe6cb30..53e018ce50 100644 --- a/src/components/SwapForm/SwapActionButton/SwapButtonWithPriceImpact.tsx +++ b/src/components/SwapForm/SwapActionButton/SwapButtonWithPriceImpact.tsx @@ -82,7 +82,7 @@ export const SwapButtonWithPriceImpact = ({ onClick={onClick} disabled={shouldDisable} $minimal={minimal} - style={shouldDisable ? undefined : { background: theme.red }} + style={shouldDisable ? undefined : { background: theme.red, color: theme.text }} > Swap Anyway diff --git a/src/components/swapv2/LimitOrder/Tutorial.tsx b/src/components/swapv2/LimitOrder/Tutorial.tsx index c2a317c320..a877ca842c 100644 --- a/src/components/swapv2/LimitOrder/Tutorial.tsx +++ b/src/components/swapv2/LimitOrder/Tutorial.tsx @@ -68,11 +68,11 @@ export default function Tutorial({ onClose }: { onClose: () => void }) { - Place orders on thousands on tokens for{' '} + Place orders on thousands of tokens for{' '} - FREE + Free - . + ! } /> @@ -82,9 +82,9 @@ export default function Tutorial({ onClose }: { onClose: () => void }) { Cancel and edit orders for{' '} - FREE + Free - . + ! } /> diff --git a/src/utils/tokenInfo.ts b/src/utils/tokenInfo.ts index 53328f997e..4dc019b585 100644 --- a/src/utils/tokenInfo.ts +++ b/src/utils/tokenInfo.ts @@ -46,22 +46,23 @@ export const isTokenNative = ( export const getTokenAddress = (currency: Currency) => currency.isNative ? (isEVM(currency.chainId) ? ETHER_ADDRESS : ETHER_ADDRESS_SOLANA) : currency?.wrapped.address ?? '' +const MAP_TOKEN_SYMBOL: Partial<{ [key in ChainId]: { [address: string]: string } }> = { + [ChainId.ARBITRUM]: { + '0x316772cFEc9A3E976FDE42C3Ba21F5A13aAaFf12': 'mKNC', + '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8': 'USDC.e', + '0x9cfb13e6c11054ac9fcb92ba89644f30775436e4': 'axl.wstETH', + }, + [ChainId.OPTIMISM]: { '0x4518231a8fdf6ac553b9bbd51bbb86825b583263': 'mKNC' }, + [ChainId.AVAXMAINNET]: { '0x39fC9e94Caeacb435842FADeDeCB783589F50f5f': 'mKNC' }, +} export const getTokenSymbolWithHardcode = ( chainId: ChainId | undefined, address: string | undefined, defaultSymbol: string | undefined, ) => { - const formatAddress = address?.toLowerCase() - if ( - (chainId === ChainId.OPTIMISM && formatAddress === '0x4518231a8fdf6ac553b9bbd51bbb86825b583263'.toLowerCase()) || - (chainId === ChainId.ARBITRUM && formatAddress === '0x316772cFEc9A3E976FDE42C3Ba21F5A13aAaFf12'.toLowerCase()) - ) { - return 'mKNC' - } - if (chainId === ChainId.ARBITRUM && formatAddress === '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8') return 'USDC.e' - if (chainId === ChainId.ARBITRUM && formatAddress === '0x9cfb13e6c11054ac9fcb92ba89644f30775436e4') - return 'axl.wstETH' - return defaultSymbol ?? '' + const chainInfo = chainId ? MAP_TOKEN_SYMBOL[chainId] || {} : {} + const symbolHardCode = chainInfo[address?.toLowerCase() ?? ''] || chainInfo[address ?? ''] + return symbolHardCode || defaultSymbol || '' } export const getProxyTokenLogo = (logoUrl: string | undefined) =>