Skip to content

Commit

Permalink
add hardcode mKnc on optimism (#2327)
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh authored Oct 25, 2023
1 parent 3d921e9 commit 8d0f11d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useCallback } from 'react'
import { useNavigate } from 'react-router-dom'
import { Text } from 'rebass'
import styled from 'styled-components'
Expand All @@ -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'

Expand Down Expand Up @@ -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,
Expand All @@ -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')
}

Expand All @@ -94,4 +104,4 @@ function InboxItemBridge({
</InboxItemWrapper>
)
}
export default InboxItemBridge
export default InboxItemKyberAIWatchlist
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -29,15 +30,15 @@ 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)

return (
<Wrapper onClick={() => setExpand(!expand)}>
<Flex justifyContent="space-between" width="100%">
<Title onClick={() => navigate(APP_PATHS.KYBERAI_RANKINGS)}>
<Title onClick={navigateToWatchList}>
<InboxIcon type={templateType} />
{title}
</Title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
>
<Trans>Swap Anyway</Trans>
</CustomPrimaryButton>
Expand Down
10 changes: 5 additions & 5 deletions src/components/swapv2/LimitOrder/Tutorial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ export default function Tutorial({ onClose }: { onClose: () => void }) {
<ContentItem
text={
<Trans>
Place orders on thousands on tokens for{' '}
Place orders on thousands of tokens for{' '}
<Text as="span" fontWeight={'500'} color={theme.primary}>
<Trans>FREE</Trans>
<Trans>Free</Trans>
</Text>
.
!
</Trans>
}
/>
Expand All @@ -82,9 +82,9 @@ export default function Tutorial({ onClose }: { onClose: () => void }) {
<Trans>
Cancel and edit orders for{' '}
<Text as="span" fontWeight={'500'} color={theme.primary}>
<Trans>FREE</Trans>
<Trans>Free</Trans>
</Text>
.
!
</Trans>
}
/>
Expand Down
23 changes: 12 additions & 11 deletions src/utils/tokenInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down

0 comments on commit 8d0f11d

Please sign in to comment.