Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
chef-ryan committed Jan 9, 2025
1 parent 23db1ad commit 45ab95c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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 @@ -34,6 +35,7 @@ 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 @@ -87,7 +89,7 @@ const ClaimButton: React.FC<React.PropsWithChildren<Props>> = ({
width="100%"
onClick={handleClaim}
isLoading={isPending}
disabled={isReady && !enabled}
disabled={isReady && !enabled && !isEnd}
endIcon={isPending ? <AutoRenewIcon spin color="currentColor" /> : null}
>
{t('Claim %symbol%', { symbol: token.symbol })}
Expand Down
11 changes: 8 additions & 3 deletions apps/web/src/views/Ifos/hooks/vesting/useFetchVestingData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@ 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))
}

const useFetchVestingData = () => {
let { address: account } = useAccount()
// For demo purposes, overriding the account here
account = '0xa9c60777fD1A95602D6c080A72Ff02324373F609'
const { address: account } = useAccount()

const { chainId } = useActiveChainId()
const configs = useIfoConfigsAcrossChains()
Expand Down

0 comments on commit 45ab95c

Please sign in to comment.