From 3f3e1d43e0cc2258805acae46105c0ad25917714 Mon Sep 17 00:00:00 2001 From: viet-nv Date: Wed, 9 Aug 2023 16:05:58 +0700 Subject: [PATCH] add zkevm --- src/components/GlobalStats/index.js | 2 +- src/components/SwitchNetworkButton/index.js | 17 ++++++++------ src/components/TxnList/index.js | 12 +++++----- src/constants/networks.ts | 25 +++++++++++++++++++++ src/contexts/GlobalData.js | 12 +++++----- 5 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/components/GlobalStats/index.js b/src/components/GlobalStats/index.js index 7db377d21..415b61207 100644 --- a/src/components/GlobalStats/index.js +++ b/src/components/GlobalStats/index.js @@ -29,7 +29,7 @@ export default function GlobalStats() { const { oneDayTxns, oneDayFeeUSD, oneDayFeeChange, txnChange } = globalDatas[1] ? aggregateGlobalData(globalDatas) : globalDatas[0] || {} - const oneDayFees = oneDayFeeUSD ? formattedNum(oneDayFeeUSD, true) : '' + const oneDayFees = oneDayFeeUSD ? formattedNum(oneDayFeeUSD, true) : '0' const theme = useTheme() const aggregatorVolume = useAggregatorVolume() const above800 = useMedia('(min-width: 800px)') diff --git a/src/components/SwitchNetworkButton/index.js b/src/components/SwitchNetworkButton/index.js index 901bb1c47..d0fd97b0f 100644 --- a/src/components/SwitchNetworkButton/index.js +++ b/src/components/SwitchNetworkButton/index.js @@ -14,6 +14,7 @@ const ButtonWrapper = styled(ButtonOutlined)` justify-content: space-between; align-items: center; padding: 8px 10px; + overflow: hidden; border-radius: 8px; background: ${({ theme }) => theme.buttonBlack}; border: none; @@ -28,15 +29,21 @@ const ButtonWrapper = styled(ButtonOutlined)` ` const NetworkWrapper = styled.div` + flex: 1; display: flex; align-items: center; ` const NetworkLabel = styled.div` + flex: 1; font-size: 16px; font-weight: 500; color: ${({ theme }) => theme.primary}; - margin-left: 10px; + margin-left: 6px; + max-width: 100px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; ` const SwitchNetworkButton = () => { @@ -48,14 +55,10 @@ const SwitchNetworkButton = () => { return ( - Network Icon + Network Icon {networksInfo[1] ? 'All Chains' : networksInfo[0].name} - Switch Network Icon + Switch Network Icon ) } diff --git a/src/components/TxnList/index.js b/src/components/TxnList/index.js index 97f9304c9..ba67d3227 100644 --- a/src/components/TxnList/index.js +++ b/src/components/TxnList/index.js @@ -299,8 +299,8 @@ function TxnList({ transactions, symbol0Override, symbol1Override, color }) { valueToCompareA = parseFloat(a[sortedColumn]) valueToCompareB = parseFloat(b[sortedColumn]) } - if (valueToCompareA > valueToCompareB) return (sortDirection ? -1 : 1) * -1 - if (valueToCompareA < valueToCompareB) return (sortDirection ? -1 : 1) * 1 + if (valueToCompareA > valueToCompareB) return (sortDirection ? -1 : 1) * 1 + if (valueToCompareA < valueToCompareB) return (sortDirection ? -1 : 1) * -1 if (a.timestamp < b.timestamp) return -1 if (a.timestamp > b.timestamp) return 1 @@ -356,10 +356,10 @@ function TxnList({ transactions, symbol0Override, symbol1Override, color }) { {!below780 && ( <> - {formattedNum(item.token1Amount) + ' '} + {formattedNum(item.token0Amount) + ' '} - {formattedNum(item.token0Amount) + ' '} + {formattedNum(item.token1Amount) + ' '} )} @@ -458,7 +458,7 @@ function TxnList({ transactions, symbol0Override, symbol1Override, color }) { }} > {symbol0Override ? symbol0Override + ' Amount' : 'Token Amount'}{' '} - {sortedColumn === SORT_FIELD.AMOUNT0 ? (sortDirection ? '↑' : '↓') : ''} + {sortedColumn === SORT_FIELD.AMOUNT0 ? (!sortDirection ? '↑' : '↓') : ''} )} @@ -474,7 +474,7 @@ function TxnList({ transactions, symbol0Override, symbol1Override, color }) { }} > {symbol1Override ? symbol1Override + ' Amount' : 'Token Amount'}{' '} - {sortedColumn === SORT_FIELD.AMOUNT1 ? (sortDirection ? '↑' : '↓') : ''} + {sortedColumn === SORT_FIELD.AMOUNT1 ? (!sortDirection ? '↑' : '↓') : ''} )} diff --git a/src/constants/networks.ts b/src/constants/networks.ts index 828bb07de..1bf17fffa 100644 --- a/src/constants/networks.ts +++ b/src/constants/networks.ts @@ -38,6 +38,7 @@ export enum ChainId { OPTIMISM = 10, ZKSYNC = 324, LINEA = 59144, + ZKEVM = 1101, } export type NETWORK_INFO = { @@ -379,6 +380,30 @@ export const NETWORKS_INFO: { [key in ChainId]: NETWORK_INFO } = { tokensListUrl: 'https://raw.githubusercontent.com/KyberNetwork/ks-assets/main/tokenLists/linea.tokenlist.json', isEnableBlockService: false, }, + [ChainId.ZKEVM]: { + chainId: ChainId.ZKEVM, + icon: 'https://wallet.polygon.technology/assets/img/zkEVM.svg', + name: 'Polygon zkEvm', + urlKey: 'polygon-zkevm', + priceRoute: 'polygon-zkevm', + blockServiceRoute: 'polygon-zkevm', + dmmSwapUrl: 'https://kyberswap.com/', + subgraphName: 'kybernetwork/kyberswap-exchange-polygon-zkevm', + subgraphUrls: [ + 'https://polygon-zkevm-graph.kyberengineering.io/subgraphs/name/kybernetwork/kyberswap-exchange-polygon-zkevm', + ], + subgraphBlockUrl: '', + etherscanUrl: 'https://zkevm.polygonscan.com', + kncAddress: '', + wethAddress: '0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9', + defaultStartTime: 1691391568, + nativeTokenSymbol: 'ETH', + nativeTokenWrappedName: 'ETH (Wrapped)', + nativeTokenLogo: EthereumLogo, + etherscanLinkText: 'Polygon zkEvm Explorer', + tokensListUrl: '', + isEnableBlockService: true, + }, } export const NETWORKS_INFO_LIST: NETWORK_INFO[] = Object.values(NETWORKS_INFO) diff --git a/src/contexts/GlobalData.js b/src/contexts/GlobalData.js index 45b4306bf..e60d371cb 100644 --- a/src/contexts/GlobalData.js +++ b/src/contexts/GlobalData.js @@ -261,11 +261,13 @@ async function getGlobalData(client, networksInfo) { }) data.oneWeekData = { ...mergeFactoriesData(oneWeekResult.data.dmmFactories) } //preventing fetchPolicy: 'cache-first' returning same object causing circular object - let twoWeekResult = await client.query({ - query: GLOBAL_DATA(twoWeekBlock?.number), - fetchPolicy: 'cache-first', - }) - data.twoWeekData = { ...mergeFactoriesData(twoWeekResult.data.dmmFactories) } //preventing fetchPolicy: 'cache-first' returning same object causing circular object + try { + let twoWeekResult = await client.query({ + query: GLOBAL_DATA(twoWeekBlock?.number), + fetchPolicy: 'cache-first', + }) + data.twoWeekData = { ...mergeFactoriesData(twoWeekResult.data.dmmFactories) } //preventing fetchPolicy: 'cache-first' returning same object causing circular object + } catch (e) {} calculateValuesOnGlobalData(data) } catch (e) {