Skip to content

Commit

Permalink
fix: CR-487 wrong tvl due to linea testnet (#2078)
Browse files Browse the repository at this point in the history
* fix: CR-487 wrong tvl due to linea testnet

* fix: display vesting time issue
  • Loading branch information
viet-nv authored Jul 18, 2023
1 parent 8d66f96 commit b04263d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
7 changes: 5 additions & 2 deletions src/components/Vesting/RewardLockerSchedules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber'
import { Token } from '@kyberswap/ks-sdk-core'

import { ZERO_ADDRESS } from 'constants/index'
import { EVMNetworkInfo } from 'constants/networks/type'
import { NativeCurrencies } from 'constants/tokens'
import { useActiveWeb3React } from 'hooks'
import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel'
Expand All @@ -28,7 +29,7 @@ const RewardLockerSchedules = ({
const dispatch = useAppDispatch()
const currentBlockNumber = useBlockNumber()
const currentTimestamp = Math.round(Date.now() / 1000)
const { account, chainId } = useActiveWeb3React()
const { account, chainId, networkInfo } = useActiveWeb3React()
const { vestMultipleTokensAtIndices } = useVesting(rewardLockerAddress)
const { mixpanelHandler } = useMixpanel()
if (!schedules) {
Expand Down Expand Up @@ -173,6 +174,8 @@ const RewardLockerSchedules = ({
return acc
}, currentBlockNumber)

const blockDiff = (maxEndBlock || 0) - (currentBlockNumber || 0)

const endTimestampFromBlock = useTimestampFromBlock(maxEndBlock)

const endTime = schedules.reduce((acc, cur) => {
Expand All @@ -183,7 +186,7 @@ const RewardLockerSchedules = ({
}

return acc
}, endTimestampFromBlock || 0)
}, endTimestampFromBlock || currentTimestamp + blockDiff * ((networkInfo as EVMNetworkInfo).averageBlockTimeInSeconds || 0))

return <VestingCard info={info} endTime={endTime} remainTime={endTime - currentTimestamp} onClaimAll={onClaimAll} />
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Vesting/VestingCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { formatDollarAmount } from 'utils/numbers'
const formatRemainTime = (numberOfSeconds: number) => {
if (numberOfSeconds < 0) return t`Full unlocked`
const days = numberOfSeconds / 60 / 60 / 24
if (days > 1) return days + ' Days left'
if (days > 1) return days.toFixed(2) + ' Days left'

const hours = numberOfSeconds / 60 / 60
if (hours < 24 && hours > 1) return hours.toFixed(0) + ' Hours left'
Expand Down
18 changes: 11 additions & 7 deletions src/state/about/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export function useGlobalData() {
}
const getResultByChainIds = async (chainIds: readonly ChainId[]) => {
// todo namgold: add aggregator API for solana
const elasticChains = chainIds.filter(isEVM).filter(id => !ELASTIC_NOT_SUPPORTED[id])
const elasticChains = chainIds
.filter(id => isEVM(id))
.filter(id => !ELASTIC_NOT_SUPPORTED[id] && id !== ChainId.LINEA_TESTNET)

const elasticPromises = elasticChains.map(chain =>
allKyberswapConfig[chain].elasticClient.query({
Expand All @@ -70,12 +72,14 @@ export function useGlobalData() {
return total + parseFloat(item?.data?.factories?.[0]?.totalValueLockedUSD || '0')
}, 0)

const allChainPromises = chainIds.filter(isEVM).map(chain =>
allKyberswapConfig[chain].classicClient.query({
query: GLOBAL_DATA(),
fetchPolicy: 'cache-first',
}),
)
const allChainPromises = chainIds
.filter(id => isEVM(id) && id !== ChainId.LINEA_TESTNET)
.map(chain =>
allKyberswapConfig[chain].classicClient.query({
query: GLOBAL_DATA(),
fetchPolicy: 'cache-first',
}),
)

const queryResult = (await Promise.all(allChainPromises.map(promises => promises.catch(e => e)))).filter(
res => !(res instanceof Error),
Expand Down

0 comments on commit b04263d

Please sign in to comment.