Skip to content

Commit

Permalink
feat: 🎸 refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chef-ryan committed Jan 14, 2025
1 parent 489304d commit d7d0f0b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { useCallback, useMemo } from 'react'
import { Address } from 'viem'
import { VestingData } from 'views/Ifos/hooks/vesting/fetchUserWalletIfoData'

import { isVestingEnd } from 'views/Ifos/hooks/vesting/useFetchVestingData'
import { SwitchNetworkTips } from '../../IfoFoldableCard/IfoPoolCard/SwitchNetworkTips'

interface Props {
Expand All @@ -35,7 +34,6 @@ const ClaimButton: React.FC<React.PropsWithChildren<Props>> = ({
const { address, token, chainId } = data.ifo
const contract = useIfoV3Contract(address)
const { fetchWithCatchTxError, loading: isPending } = useCatchTxError()
const isEnd = isVestingEnd(data)

const isReady = useMemo(() => {
const checkClaimableAmount = isVestingInitialized ? claimableAmount === '0' : false
Expand Down Expand Up @@ -89,7 +87,7 @@ const ClaimButton: React.FC<React.PropsWithChildren<Props>> = ({
width="100%"
onClick={handleClaim}
isLoading={isPending}
disabled={isReady && !enabled && !isEnd}
disabled={isReady && !enabled}
endIcon={isPending ? <AutoRenewIcon spin color="currentColor" /> : null}
>
{t('Claim', { symbol: token.symbol })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useGetPublicIfoV3Data from 'views/Ifos/hooks/v3/useGetPublicIfoData'
import { VestingData } from 'views/Ifos/hooks/vesting/fetchUserWalletIfoData'

import { useQuery } from '@tanstack/react-query'
import { getVestingInfo } from 'views/Ifos/hooks/usePoolVestingData'
import { getVestingInfo } from 'views/Ifos/hooks/getVestingInfo'
import { isBasicSale } from '../../../hooks/v7/helpers'
import Claim from './Claim'

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/views/Ifos/components/IfoVesting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useAccount } from 'wagmi'
import Trans from 'components/Trans'

import { PoolIds } from '@pancakeswap/ifos'
import { getHasClaimable } from 'views/Ifos/hooks/usePoolVestingData'
import { getHasClaimable } from 'views/Ifos/hooks/getVestingInfo'
import useFetchVestingData from '../../hooks/vesting/useFetchVestingData'
import { VestingStatus } from './types'
import VestingEnded from './VestingEnded'
Expand Down
7 changes: 0 additions & 7 deletions apps/web/src/views/Ifos/hooks/vesting/useFetchVestingData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ const isPoolEligible = (poolId: PoolIds, userVestingData: UserVestingData) => {
return vestingEndTime.gte(currentTimeStamp)
}

export const isVestingEnd = (vestingData: VestingData) => {
const pool = vestingData.userVestingData[PoolIds.poolBasic] || vestingData.userVestingData[PoolIds.poolUnlimited]
const currentTimeStamp = Date.now()
const vestingEndTime = (vestingData.userVestingData.vestingStartTime + pool.vestingInformationDuration) * 1000
return vestingEndTime < currentTimeStamp
}

const isEligibleVestingData = (ifo: VestingData) => {
const { userVestingData } = ifo
return POOLS.some((poolId) => isPoolEligible(poolId, userVestingData))
Expand Down

0 comments on commit d7d0f0b

Please sign in to comment.