Skip to content

Commit

Permalink
lp earning: enable all chains (#2123)
Browse files Browse the repository at this point in the history
* enable all chains

* update env

* disable polygon on legacy

* revert env

---------

Co-authored-by: Nam Nguyen <nam.nguyen@kyber.network>
  • Loading branch information
viet-nv and namgold authored Jul 31, 2023
1 parent f5fa98c commit a4b70cb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
14 changes: 2 additions & 12 deletions src/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,6 @@ export const SUPPORTED_NETWORKS_FOR_MY_EARNINGS = [
ChainId.MAINNET,
ChainId.ARBITRUM,
ChainId.OPTIMISM,
// ChainId.MATIC,
// ChainId.BSCMAINNET,
// ChainId.AVAXMAINNET,
// ChainId.FANTOM,
// ChainId.CRONOS,
// ChainId.BTTC,
// ChainId.VELAS,
// ChainId.AURORA,
// ChainId.OASIS,
]
export const COMING_SOON_NETWORKS_FOR_MY_EARNINGS = [
ChainId.MATIC,
ChainId.BSCMAINNET,
ChainId.AVAXMAINNET,
Expand All @@ -219,8 +208,9 @@ export const COMING_SOON_NETWORKS_FOR_MY_EARNINGS = [
ChainId.VELAS,
ChainId.AURORA,
ChainId.OASIS,
ChainId.ZKSYNC,
]
export const COMING_SOON_NETWORKS_FOR_MY_EARNINGS: ChainId[] = []
export const COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY: ChainId[] = [ChainId.MATIC]

// by pass invalid price impact/unable to calculate price impact/price impact too large
export const CHAINS_BYPASS_PRICE_IMPACT = [ChainId.LINEA_TESTNET]
6 changes: 5 additions & 1 deletion src/pages/MyEarnings/ElasticPools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import styled from 'styled-components'
import InfoHelper from 'components/InfoHelper'
import LoaderWithKyberLogo from 'components/LocalLoader'
import { EMPTY_ARRAY } from 'constants/index'
import { COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY } from 'constants/networks'
import { VERSION } from 'constants/v2'
import { useActiveWeb3React } from 'hooks'
import useDebounce from 'hooks/useDebounce'
Expand Down Expand Up @@ -81,7 +82,10 @@ const ElasticPools = () => {
const searchText = useDebounce(originalSearchText, 300).toLowerCase().trim()

const elasticEarningQueryResponse = useGetElasticEarningQuery({ account, chainIds: selectedChainIds })
const elasticLegacyEarningQueryResponse = useGetElasticLegacyEarningQuery({ account, chainIds: selectedChainIds })
const elasticLegacyEarningQueryResponse = useGetElasticLegacyEarningQuery({
account,
chainIds: selectedChainIds.filter(item => !COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY.includes(item)),
})

const earningResponse = useMemo(() => {
let data = elasticEarningQueryResponse.data
Expand Down
23 changes: 18 additions & 5 deletions src/pages/MyEarnings/MultipleChainSelect/PopoverBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import Checkbox from 'components/CheckBox'
import { MouseoverTooltip } from 'components/Tooltip'
import {
COMING_SOON_NETWORKS_FOR_MY_EARNINGS,
COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY,
NETWORKS_INFO,
SUPPORTED_NETWORKS_FOR_MY_EARNINGS,
} from 'constants/networks'
import { VERSION } from 'constants/v2'
import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
import useTheme from 'hooks/useTheme'
import { AppState } from 'state'
import { useAppSelector } from 'state/hooks'
import { selectChains } from 'state/myEarnings/actions'

import { StyledLogo } from '.'
Expand Down Expand Up @@ -103,9 +106,17 @@ const PopoverBody: React.FC<Props> = ({ onClose }) => {
const selectedChains = useSelector((state: AppState) => state.myEarnings.selectedChains)
const dispatch = useDispatch()

const [localSelectedChains, setLocalSelectedChains] = useState(selectedChains)
const isLegacy = useAppSelector(state => state.myEarnings.activeTab === VERSION.ELASTIC_LEGACY)

const isAllSelected = localSelectedChains.length === SUPPORTED_NETWORKS_FOR_MY_EARNINGS.length
const comingSoonList = isLegacy ? COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY : COMING_SOON_NETWORKS_FOR_MY_EARNINGS

const [localSelectedChains, setLocalSelectedChains] = useState(() =>
selectedChains.filter(item => !comingSoonList.includes(item)),
)

const networkList = SUPPORTED_NETWORKS_FOR_MY_EARNINGS.filter(item => !comingSoonList.includes(item))

const isAllSelected = localSelectedChains.length === networkList.length
const handleChangeChains = (chains: ChainId[]) => {
dispatch(selectChains(chains))
}
Expand All @@ -124,7 +135,8 @@ const PopoverBody: React.FC<Props> = ({ onClose }) => {
selectAllRef.current.indeterminate = indeterminate
}, [localSelectedChains])

const allNetworks = [...SUPPORTED_NETWORKS_FOR_MY_EARNINGS, ...COMING_SOON_NETWORKS_FOR_MY_EARNINGS]
const allNetworks = [...networkList, ...comingSoonList]

return (
<Flex
sx={{
Expand Down Expand Up @@ -155,7 +167,7 @@ const PopoverBody: React.FC<Props> = ({ onClose }) => {
setLocalSelectedChains([])
} else {
mixpanelHandler(MIXPANEL_TYPE.EARNING_DASHBOARD_CLICK_ALL_CHAINS_BUTTON)
setLocalSelectedChains(SUPPORTED_NETWORKS_FOR_MY_EARNINGS)
setLocalSelectedChains(networkList)
}
}}
/>
Expand All @@ -180,7 +192,8 @@ const PopoverBody: React.FC<Props> = ({ onClose }) => {
<ChainListWrapper>
{allNetworks.map((network, i) => {
const config = NETWORKS_INFO[network]
const isComingSoon = COMING_SOON_NETWORKS_FOR_MY_EARNINGS.includes(network)

const isComingSoon = comingSoonList.includes(network)
const isSelected = isComingSoon ? false : localSelectedChains.includes(network)

const handleClick = () => {
Expand Down
6 changes: 5 additions & 1 deletion src/pages/MyEarnings/MyEarningStats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Flex, Text } from 'rebass'
import { useGetElasticEarningQuery, useGetElasticLegacyEarningQuery } from 'services/earning'
import styled from 'styled-components'

import { COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY } from 'constants/networks'
import { useActiveWeb3React } from 'hooks'
import useTheme from 'hooks/useTheme'
import ChainSelect from 'pages/MyEarnings/ChainSelect'
Expand Down Expand Up @@ -79,7 +80,10 @@ const MyEarningStats = () => {
const tokensByChainId = useAppSelector(state => state.lists.mapWhitelistTokens)

const elasticEarningQueryResponse = useGetElasticEarningQuery({ account, chainIds: selectedChainIds })
const elasticLegacyEarningQueryResponse = useGetElasticLegacyEarningQuery({ account, chainIds: selectedChainIds })
const elasticLegacyEarningQueryResponse = useGetElasticLegacyEarningQuery({
account,
chainIds: selectedChainIds.filter(item => !COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY.includes(item)),
})
// const classicEarningQueryResponse = useGetClassicEarningQuery({ account, chainIds: selectedChainIds })

const isLoading = elasticEarningQueryResponse.isFetching || elasticLegacyEarningQueryResponse.isFetching
Expand Down

0 comments on commit a4b70cb

Please sign in to comment.