Skip to content

Commit

Permalink
add zkevm
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv committed Aug 15, 2023
1 parent 1326942 commit 3f3e1d4
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/components/GlobalStats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
Expand Down
17 changes: 10 additions & 7 deletions src/components/SwitchNetworkButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = () => {
Expand All @@ -48,14 +55,10 @@ const SwitchNetworkButton = () => {
return (
<ButtonWrapper onClick={toggleNetworkModal}>
<NetworkWrapper>
<img
src={networksInfo[1] ? Kyber : networksInfo[0].icon}
alt='Network Icon'
style={{ maxWidth: '24px', maxHeight: '24px' }}
/>
<img src={networksInfo[1] ? Kyber : networksInfo[0].icon} alt='Network Icon' width='24px' />
<NetworkLabel>{networksInfo[1] ? 'All Chains' : networksInfo[0].name}</NetworkLabel>
</NetworkWrapper>
<img src={SwitchNetworkIcon} alt='Switch Network Icon' style={{ width: '20px', maxHeight: '20px', marginLeft: '8px' }} />
<img src={SwitchNetworkIcon} alt='Switch Network Icon' width='20px' marginLeft='6px' />
</ButtonWrapper>
)
}
Expand Down
12 changes: 6 additions & 6 deletions src/components/TxnList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -356,10 +356,10 @@ function TxnList({ transactions, symbol0Override, symbol1Override, color }) {
{!below780 && (
<>
<DataText area='amountOther'>
{formattedNum(item.token1Amount) + ' '} <FormattedName text={item.token1Symbol} maxCharacters={5} margin={true} />
{formattedNum(item.token0Amount) + ' '} <FormattedName text={item.token0Symbol} maxCharacters={5} margin={true} />
</DataText>
<DataText area='amountToken'>
{formattedNum(item.token0Amount) + ' '} <FormattedName text={item.token0Symbol} maxCharacters={5} margin={true} />
{formattedNum(item.token1Amount) + ' '} <FormattedName text={item.token1Symbol} maxCharacters={5} margin={true} />
</DataText>
</>
)}
Expand Down Expand Up @@ -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 ? '↑' : '↓') : ''}
</ClickableText>
</Flex>
)}
Expand All @@ -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 ? '↑' : '↓') : ''}
</ClickableText>
</Flex>
)}
Expand Down
25 changes: 25 additions & 0 deletions src/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export enum ChainId {
OPTIMISM = 10,
ZKSYNC = 324,
LINEA = 59144,
ZKEVM = 1101,
}

export type NETWORK_INFO = {
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions src/contexts/GlobalData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3f3e1d4

Please sign in to comment.