-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(govern) fix: changes for next week start, veOlas -> veOLAS
- Loading branch information
Atatakai
authored and
Atatakai
committed
Jul 30, 2024
1 parent
a829485
commit e6c8e57
Showing
10 changed files
with
113 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
export const getStartOfNextWeekTimestamp = () => { | ||
const date = new Date(); | ||
const dayOfWeek = date.getDay(); | ||
const daysUntilNextWeek = dayOfWeek === 1 ? 7 : (8 - dayOfWeek) % 7; | ||
// Returns the closest Thursday in the future | ||
// which is the start of the next week by Unix time | ||
export const getUnixNextWeekStartTimestamp = () => { | ||
const now = new Date(); | ||
const dayOfWeek = now.getDay(); | ||
const daysUntilNextThursday = (4 - dayOfWeek + 7) % 7; | ||
|
||
const nextWeekStartDate = new Date(date); | ||
nextWeekStartDate.setDate(date.getDate() + daysUntilNextWeek); | ||
nextWeekStartDate.setHours(0, 0, 0, 0); | ||
const nextThursday = new Date(now); | ||
nextThursday.setDate(now.getDate() + daysUntilNextThursday); | ||
nextThursday.setHours(0, 0, 0, 0); | ||
|
||
return nextWeekStartDate.getTime() / 1000; | ||
return nextThursday.getTime() / 1000; | ||
}; | ||
|
||
export const getThisWeekMondayTimestamp = () => { | ||
// Returns the closest Thursday in the past | ||
// which is the start of the current week by Unix time | ||
export const getUnixWeekStartTimestamp = () => { | ||
const now = new Date(); | ||
const dayOfWeek = now.getDay(); | ||
const daysToMonday = (dayOfWeek + 6) % 7; | ||
const monday = new Date(now); | ||
const daysSinceThursday = ((dayOfWeek + 2) % 7) + 1; | ||
const thursday = new Date(now); | ||
|
||
monday.setDate(now.getDate() - daysToMonday); | ||
monday.setHours(0, 0, 0, 0); | ||
thursday.setDate(now.getDate() - daysSinceThursday); | ||
thursday.setHours(0, 0, 0, 0); | ||
|
||
return monday.getTime() / 1000; | ||
return thursday.getTime() / 1000; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Space, Tooltip, Typography } from 'antd'; | ||
import { ReactNode } from 'react'; | ||
import { mainnet } from 'viem/chains'; | ||
|
||
import { COLOR } from 'libs/ui-theme/src'; | ||
import { UNICODE_SYMBOLS } from 'libs/util-constants/src'; | ||
import { VOTE_WEIGHTING } from 'libs/util-contracts/src/lib/abiAndAddresses'; | ||
|
||
const { Text } = Typography; | ||
|
||
const TOOLTIP_STYLE = { maxWidth: '350px' }; | ||
|
||
export const NextWeekTooltip = ({ children }: { children: ReactNode }) => { | ||
return ( | ||
<Tooltip | ||
color={COLOR.WHITE} | ||
overlayStyle={TOOLTIP_STYLE} | ||
title={ | ||
<Space direction="vertical"> | ||
<Text>Updated voting weights will take effect at the start of next week Unix time.</Text> | ||
<a | ||
href={`https://etherscan.io/address/${ | ||
VOTE_WEIGHTING.addresses[mainnet.id] | ||
}#readContract#F29`} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
{`View timestamp when the last votes apply ${UNICODE_SYMBOLS.EXTERNAL_LINK}`} | ||
</a> | ||
</Space> | ||
} | ||
> | ||
{children} | ||
</Tooltip> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters