Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt with new asset api #2255

Merged
merged 18 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/Header/groups/EarnNavGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const EarnNavGroup = () => {
to={`${APP_PATHS.POOLS}/${networkInfo.route}`}
style={{ width: '100%' }}
>
<Flex sx={{ gap: '4px' }} alignItems="center">
<Flex sx={{ gap: '12px' }} alignItems="center">
<Icon id="liquid" size={16} />
<Trans>Pools</Trans>
</Flex>
Expand All @@ -61,14 +61,14 @@ const EarnNavGroup = () => {
data-testid="farms-nav-link"
to={`${APP_PATHS.FARMS}/${networkInfo.route}`}
>
<Flex sx={{ gap: '4px' }} alignItems="center">
<Flex sx={{ gap: '12px' }} alignItems="center">
<MoneyBag size={16} />
<Trans>Farms</Trans>
</Flex>
</StyledNavLink>

<StyledNavLink id="my-earnings-link" to={APP_PATHS.MY_EARNINGS}>
<Flex sx={{ gap: '4px' }} alignItems="center">
<Flex sx={{ gap: '12px' }} alignItems="center">
<Icon id="pig" size={16} />
<Trans>My Earnings</Trans>
<NewLabel>
Expand All @@ -82,7 +82,7 @@ const EarnNavGroup = () => {
data-testid="my-pools-nav-link"
to={`${APP_PATHS.MY_POOLS}/${networkInfo.route}`}
>
<Flex sx={{ gap: '4px' }} alignItems="center">
<Flex sx={{ gap: '12px' }} alignItems="center">
<Icon id="liquid-outline" size={16} />
<Trans>My Pools</Trans>
</Flex>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Header/groups/KyberDaoGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ const KyberDAONavGroup = () => {
}
dropdownContent={
<Column>
<StyledNavLink id="kyberdao-stake-knc" to={APP_PATHS.KYBERDAO_STAKE} style={{ gap: '4px' }}>
<StyledNavLink id="kyberdao-stake-knc" to={APP_PATHS.KYBERDAO_STAKE} style={{ gap: '12px' }}>
<StakeIcon />
<Trans>Stake KNC</Trans>
</StyledNavLink>
<StyledNavLink id="kyberdao-vote" to={APP_PATHS.KYBERDAO_VOTE} style={{ gap: '4px' }}>
<StyledNavLink id="kyberdao-vote" to={APP_PATHS.KYBERDAO_VOTE} style={{ gap: '12px' }}>
<VoteIcon />
<Trans>Vote</Trans>
</StyledNavLink>
<StyledNavLink
id="knc-utility"
to={APP_PATHS.KYBERDAO_KNC_UTILITY}
style={{ gap: '4px' }}
style={{ gap: '12px' }}
onClick={() => {
mixpanelHandler(MIXPANEL_TYPE.GAS_REFUND_SOURCE_CLICK, { source: 'KyberDAO_tab' })
}}
Expand All @@ -61,7 +61,7 @@ const KyberDAONavGroup = () => {
id="kyberdao-feature-request"
href="https://kyberswap.canny.io/feature-request"
target="_blank"
style={{ gap: '4px' }}
style={{ gap: '12px' }}
onClick={() => {
mixpanelHandler(MIXPANEL_TYPE.KYBER_DAO_FEATURE_REQUEST_CLICK)
}}
Expand Down
24 changes: 16 additions & 8 deletions src/components/KyberAITokenBanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import useTheme from 'hooks/useTheme'
import KyberScoreMeter from 'pages/TrueSightV2/components/KyberScoreMeter'
import { NETWORK_TO_CHAINID } from 'pages/TrueSightV2/constants'
import { SUPPORTED_NETWORK_KYBERAI } from 'pages/TrueSightV2/constants/index'
import { useTokenDetailQuery } from 'pages/TrueSightV2/hooks/useKyberAIData'
import { useTokenOverviewQuery } from 'pages/TrueSightV2/hooks/useKyberAIData'
import { calculateValueToColor } from 'pages/TrueSightV2/utils'
import { useIsWhiteListKyberAI } from 'state/user/hooks'
import { useIsWhiteListKyberAI, useShowKyberAIBanner } from 'state/user/hooks'
import { MEDIA_WIDTHS } from 'theme'

const KyberAITokenBanner = ({
Expand All @@ -36,6 +36,8 @@ const KyberAITokenBanner = ({
}) => {
const { chainId, account } = useActiveWeb3React()
const { isWhiteList } = useIsWhiteListKyberAI()
const isShowKyberAIBanner = useShowKyberAIBanner()

const navigate = useNavigate()
const { mixpanelHandler } = useMixpanel()
const chain = Object.keys(NETWORK_TO_CHAINID).find(i => NETWORK_TO_CHAINID[i] === chainId)
Expand All @@ -47,19 +49,25 @@ const KyberAITokenBanner = ({

const { isStableCoin } = useStableCoins(chainId)

const { data: tokenInputOverview } = useTokenDetailQuery(
const { data: tokenInputOverview } = useTokenOverviewQuery(
{ address: token0?.address, chain },
{ skip: !token0?.address || !account || !isWhiteList || !chain, refetchOnMountOrArgChange: true },
{
skip: !token0?.address || !account || !isWhiteList || !chain || !isShowKyberAIBanner,
refetchOnMountOrArgChange: true,
},
)

const { data: tokenOutputOverview } = useTokenDetailQuery(
const { data: tokenOutputOverview } = useTokenOverviewQuery(
{ address: token1?.address, chain },
{ skip: !token1?.address || !account || !isWhiteList || !chain, refetchOnMountOrArgChange: true },
{
skip: !token1?.address || !account || !isWhiteList || !chain || !isShowKyberAIBanner,
refetchOnMountOrArgChange: true,
},
)

const { data: tokenNativeOverview } = useTokenDetailQuery(
const { data: tokenNativeOverview } = useTokenOverviewQuery(
{ address: NativeCurrencies[chainId].wrapped.address, chain },
{ skip: !account || !isWhiteList || !chain, refetchOnMountOrArgChange: true },
{ skip: !account || !isWhiteList || !chain || !isShowKyberAIBanner, refetchOnMountOrArgChange: true },
)

const token: { kyberScore?: number; label?: string; address?: string; logo?: string; symbol?: string } | undefined =
Expand Down
2 changes: 1 addition & 1 deletion src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ export default function App() {
}
/>
<Route
path={`${APP_PATHS.KYBERAI_EXPLORE}/:chain/:address`}
path={`${APP_PATHS.KYBERAI_EXPLORE}/:assetId`}
element={
<ProtectedRouteKyberAI redirectUrl={APP_PATHS.KYBERAI_ABOUT}>
<KyberAIExplore />
Expand Down
6 changes: 3 additions & 3 deletions src/pages/ProAmmPools/KyberAIModalInPool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import useTheme from 'hooks/useTheme'
import KyberScoreMeter from 'pages/TrueSightV2/components/KyberScoreMeter'
import SimpleTooltip from 'pages/TrueSightV2/components/SimpleTooltip'
import { SUPPORTED_NETWORK_KYBERAI } from 'pages/TrueSightV2/constants/index'
import { useTokenDetailQuery } from 'pages/TrueSightV2/hooks/useKyberAIData'
import { useTokenOverviewQuery } from 'pages/TrueSightV2/hooks/useKyberAIData'
import { calculateValueToColor, formatTokenPrice, navigateToSwapPage } from 'pages/TrueSightV2/utils'
import { useIsWhiteListKyberAI } from 'state/user/hooks'

Expand Down Expand Up @@ -99,11 +99,11 @@ const KyberAIModalInPool = ({ currency0, currency1 }: { currency0?: Currency; cu
const [tab, setTab] = useState<TokenTabType>(TokenTabType.First)
const [openTruesightModal, setOpenTruesightModal] = useState(false)

const { data: token0Overview } = useTokenDetailQuery(
const { data: token0Overview } = useTokenOverviewQuery(
{ address: currency0?.wrapped?.address, chain: SUPPORTED_NETWORK_KYBERAI[chainId] },
{ skip: !currency0?.wrapped?.address && !isWhiteList, refetchOnMountOrArgChange: true },
)
const { data: token1Overview } = useTokenDetailQuery(
const { data: token1Overview } = useTokenOverviewQuery(
{ address: currency1?.wrapped?.address, chain: SUPPORTED_NETWORK_KYBERAI[chainId] },
{ skip: !currency1?.wrapped?.address && !isWhiteList, refetchOnMountOrArgChange: true },
)
Expand Down
13 changes: 8 additions & 5 deletions src/pages/TrueSightV2/components/CexRekt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ const Card = styled.div`
export default function CexRekt() {
const above768 = useMedia(`(min-width:${MEDIA_WIDTHS.upToSmall}px)`)
const { address, chain } = useParams()
const { data } = useCexesLiquidationQuery({
tokenAddress: address,
chartSize: '1m',
chain,
})
const { data } = useCexesLiquidationQuery(
{
tokenAddress: address,
chartSize: '1m',
chain,
},
{ skip: !chain || !address },
)

return (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/TrueSightV2/components/DisplaySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ApplicationModal } from 'state/application/actions'
import { useToggleModal } from 'state/application/hooks'
import { useTokenAnalysisSettings, useUpdateTokenAnalysisSettings } from 'state/user/hooks'

import useKyberAITokenOverview from '../hooks/useKyberAITokenOverview'
import useKyberAIAssetOverview from '../hooks/useKyberAIAssetOverview'
import { HeaderButton } from '../pages/SingleToken'
import { DiscoverTokenTab } from '../types'

Expand Down Expand Up @@ -112,7 +112,7 @@ export default function DisplaySettings({ currentTab }: { currentTab: DiscoverTo
const storedTokenAnalysisSettings = useTokenAnalysisSettings()
const updateTokenAnalysisSettings = useUpdateTokenAnalysisSettings()
const toggleTutorial = useToggleModal(ApplicationModal.KYBERAI_TUTORIAL)
const { data: token } = useKyberAITokenOverview()
const { data: token } = useKyberAIAssetOverview()
const { chain } = useParams()
const ref = useRef<HTMLDivElement>(null)
useOnClickOutside(ref, () => {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/TrueSightV2/components/KyberAIShareModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { downloadImage } from 'utils/index'
import { getProxyTokenLogo } from 'utils/tokenInfo'

import { NETWORK_IMAGE_URL } from '../constants'
import useKyberAITokenOverview from '../hooks/useKyberAITokenOverview'
import useKyberAIAssetOverview from '../hooks/useKyberAIAssetOverview'
import KyberSwapShareLogo from './KyberSwapShareLogo'
import LoadingTextAnimation from './LoadingTextAnimation'
import { InfoWrapper, LegendWrapper } from './chart'
Expand Down Expand Up @@ -208,7 +208,7 @@ export default function KyberAIShareModal({
}) {
const theme = useTheme()
const { chain } = useParams()
const { data: tokenOverview } = useKyberAITokenOverview()
const { data: tokenOverview } = useKyberAIAssetOverview()

const ref = useRef<HTMLDivElement>(null)
const refMobile = useRef<HTMLDivElement>(null)
Expand Down
3 changes: 2 additions & 1 deletion src/pages/TrueSightV2/components/KyberAIWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ export default function Widget() {
page: 1,
pageSize: 5,
},
{ refetchOnMountOrArgChange: true, skip: !isWhiteList },
{ refetchOnMountOrArgChange: true, skip: !isWhiteList || !showWidget },
)

if (!account) return <></>

return (
Expand Down
5 changes: 2 additions & 3 deletions src/pages/TrueSightV2/components/MultipleChainDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ const MultipleChainDropdown = React.forwardRef(
(
props: {
show: boolean
menuLeft?: number
tokens?: Array<{ address: string; logo: string; chain: string }>
onChainClick: (chain: string, address: string) => void
},
ref,
) => {
const { show, menuLeft, tokens, onChainClick } = props
const { show, tokens, onChainClick } = props
const theme = useTheme()
if (isMobile) {
return (
Expand Down Expand Up @@ -167,7 +166,7 @@ const MultipleChainDropdown = React.forwardRef(
className={show ? 'show' : ''}
gap="8px"
color={theme.text}
style={{ left: menuLeft !== undefined ? `${menuLeft}px` : undefined }}
style={{ right: 0 }}
ref={ref}
onClick={e => e.stopPropagation()}
>
Expand Down
Loading
Loading