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

refactor: Remove deprecated info components #11182

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
53 changes: 1 addition & 52 deletions apps/web/src/state/info/constant.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { GraphQLClient } from 'graphql-request'
import { infoStableSwapClients, v2Clients } from 'utils/graphql'
import { infoStableSwapClients } from 'utils/graphql'

import { ChainId, isTestnetChainId } from '@pancakeswap/chains'
import { STABLE_SUPPORTED_CHAIN_IDS } from '@pancakeswap/stable-swap-sdk'
import { BSC_TOKEN_WHITELIST, ETH_TOKEN_BLACKLIST, ETH_TOKEN_WHITELIST, TOKEN_BLACKLIST } from 'config/constants/info'
import mapValues from 'lodash/mapValues'
import { arbitrum, base, bsc, linea, mainnet, opBNB, polygonZkEvm, zkSync } from 'wagmi/chains'

export type MultiChainName = 'BSC' | 'ETH' | 'POLYGON_ZKEVM' | 'ZKSYNC' | 'ARB' | 'LINEA' | 'BASE' | 'OPBNB'
Expand All @@ -27,17 +25,6 @@ export const multiChainShortName: Record<number, string> = {
[ChainId.POLYGON_ZKEVM]: 'zkEVM',
}

export const multiChainQueryMainToken: Record<MultiChainName, string> = {
BSC: 'BNB',
ETH: 'ETH',
POLYGON_ZKEVM: 'ETH',
ZKSYNC: 'ETH',
ARB: 'ETH',
LINEA: 'ETH',
BASE: 'ETH',
OPBNB: 'ETH',
}

export const multiChainId: Record<MultiChainName, ChainId> = {
BSC: ChainId.BSC,
ETH: ChainId.ETHEREUM,
Expand Down Expand Up @@ -76,10 +63,6 @@ export const infoChainNameToExplorerChainName = {
OPBNB: 'opbnb',
} as const

export const STABLESWAP_SUBGRAPHS_START_BLOCK = {
ARB: 169319653,
}

export const multiChainScan: Record<MultiChainName, string> = {
BSC: bsc.blockExplorers.default.name,
ETH: mainnet.blockExplorers.default.name,
Expand All @@ -99,40 +82,6 @@ export const multiChainScanName: Partial<Record<ChainId, string>> = {
[ChainId.LINEA_TESTNET]: 'LineaScan',
}

export const multiChainTokenBlackList: Record<MultiChainName, string[]> = mapValues(
{
BSC: TOKEN_BLACKLIST,
ETH: ETH_TOKEN_BLACKLIST,
POLYGON_ZKEVM: ['0x'],
ZKSYNC: ['0x'],
ARB: ['0x'],
LINEA: ['0x'],
BASE: ['0x'],
OPBNB: ['0x'],
},
(val) => val.map((address) => address.toLowerCase()),
)

export const multiChainTokenWhiteList: Record<MultiChainName, string[]> = mapValues(
{
BSC: BSC_TOKEN_WHITELIST,
ETH: ETH_TOKEN_WHITELIST,
POLYGON_ZKEVM: [],
ZKSYNC: [],
ARB: [],
LINEA: [],
BASE: [],
OPBNB: [],
},
(val) => val.map((address) => address.toLowerCase()),
)

export const getMultiChainQueryEndPointWithStableSwap = (chainName: MultiChainNameExtend): GraphQLClient => {
const isStableSwap = checkIsStableSwap()
if (isStableSwap) return multiChainQueryStableClient[chainName]
return v2Clients[multiChainId[chainName]]
}

export const subgraphTokenName = {
[ChainId.BSC]: {
'0x738d96Caf7096659DB4C1aFbf1E1BDFD281f388C': 'Ankr Staked MATIC',
Expand Down
35 changes: 3 additions & 32 deletions apps/web/src/state/info/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import dayjs from 'dayjs'
import duration from 'dayjs/plugin/duration'
import { useRouter } from 'next/router'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { useCallback, useMemo } from 'react'

import { STABLE_SUPPORTED_CHAIN_IDS } from '@pancakeswap/stable-swap-sdk'
import { keepPreviousData, useQuery } from '@tanstack/react-query'
import BigNumber from 'bignumber.js'
import { fetchAllTokenDataByAddresses } from 'state/info/queries/tokens/tokenData'
import { Block, Transaction, TransactionType, TvlChartEntry, VolumeChartEntry } from 'state/info/types'
import { Transaction, TransactionType, TvlChartEntry, VolumeChartEntry } from 'state/info/types'
import { getAprsForStableFarm } from 'utils/getAprsForStableFarm'
import { getLpFeesAndApr } from 'utils/getLpFeesAndApr'
import { getPercentChange } from 'utils/infoDataHelpers'
import { explorerApiClient } from './api/client'
import { useExplorerChainNameByQuery } from './api/hooks'
import { operations } from './api/schema'
import { checkIsStableSwap, multiChainId, MultiChainName, MultiChainNameExtend } from './constant'
import { checkIsStableSwap, multiChainId, MultiChainName } from './constant'
import { PoolData, PriceChartEntry, ProtocolData, TokenData } from './types'

dayjs.extend(duration)
Expand Down Expand Up @@ -631,17 +630,6 @@ export const useAllTokenDataQuery = (): {
return data ?? {}
}

const graphPerPage = 50

const fetcher = (addresses: string[], chainName: MultiChainName, blocks: Block[]) => {
const times = Math.ceil(addresses.length / graphPerPage)
const addressGroup: Array<string[]> = []
for (let i = 0; i < times; i++) {
addressGroup.push(addresses.slice(i * graphPerPage, (i + 1) * graphPerPage))
}
return Promise.all(addressGroup.map((d) => fetchAllTokenDataByAddresses(chainName, blocks, d)))
}

export const useTokenDataQuery = (address: string | undefined): TokenData | undefined => {
const chainName = useExplorerChainNameByQuery()
const chainId = useChainIdByQuery()
Expand Down Expand Up @@ -986,23 +974,6 @@ export const useTokenTransactionsQuery = (address: string): Transaction[] | unde
return data ?? undefined
}

export const useGetChainName = () => {
const { pathname, query } = useRouter()

const getChain = useCallback(() => {
if (pathname.includes('eth') || query.chain === 'eth') return 'ETH'
return 'BSC'
}, [pathname, query])
const [name, setName] = useState<MultiChainName | null>(() => getChain())
const result = useMemo(() => name, [name])

useEffect(() => {
setName(getChain())
}, [getChain])

return result
}

export const useChainNameByQuery = (): MultiChainName => {
const { query } = useRouter()
const chainName = useMemo(() => {
Expand Down
215 changes: 0 additions & 215 deletions apps/web/src/state/info/queries/tokens/tokenData.ts

This file was deleted.

Loading
Loading