Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Refactor claim timestamp hooks #2127

Merged
merged 3 commits into from
Jan 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions src/custom/state/claim/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,28 +259,42 @@ function useDeploymentTimestamp(): number | null {
return timestamp
}

/**
* Returns the timestamp of when the investment window closes
*/
export function useInvestmentDeadline(): number | null {
const deploymentTimestamp = useDeploymentTimestamp()

return deploymentTimestamp && deploymentTimestamp + TWO_WEEKS
}

/**
* Returns whether vCOW contract is still open for investments
* Null when not applicable
*
* That is, there has been less than 2 weeks since it was deployed
*/
export function useInvestmentStillAvailable(): boolean {
const investmentDeadline = useInvestmentDeadline()

return Boolean(investmentDeadline && investmentDeadline > Date.now())
}

/**
* Returns the timestamp of when the airdrop window closes
*/
export function useAirdropDeadline(): number | null {
const deploymentTimestamp = useDeploymentTimestamp()

return Boolean(deploymentTimestamp && deploymentTimestamp + TWO_WEEKS > Date.now())
return deploymentTimestamp && deploymentTimestamp + SIX_WEEKS
}

/**
* Returns whether vCOW contract is still open for airdrops
* Null when not applicable
*
* That is, there has been less than 6 weeks since it was deployed
*/
export function useAirdropStillAvailable(): boolean {
const deploymentTimestamp = useDeploymentTimestamp()
const airdropDeadline = useAirdropDeadline()

return Boolean(deploymentTimestamp && deploymentTimestamp + SIX_WEEKS > Date.now())
return Boolean(airdropDeadline && airdropDeadline > Date.now())
}

/**
Expand Down