Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/assets/translations/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -3040,6 +3040,7 @@
"foxBurnAmount": "FOX Burn Amount (This Epoch)",
"pendingDistribution": "Pending Distribution",
"selectRuneAddress": "Select a RUNE address",
"unstakeDisabledMigrationTooltip": "Un-staking is disabled until October 1, when the cooldown period is removed.",
"lpSunsetWarningTitle": "Program Ended",
"lpSunsetWarningDescription": "The Arbitrum WETH/FOX Rewards program has been sunset. Please un-stake and claim your balance at your earliest convenience."
},
Expand Down
46 changes: 37 additions & 9 deletions src/pages/Fox/components/RFOXSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Stack,
Tag,
Text as CText,
Tooltip,
usePrevious,
} from '@chakra-ui/react'
import {
Expand Down Expand Up @@ -45,6 +46,7 @@ import { Stats } from '@/pages/RFOX/components/Overview/Stats'
import { StakeModal } from '@/pages/RFOX/components/StakeModal'
import { UnstakeModal } from '@/pages/RFOX/components/UnstakeModal'
import { selectStakingBalance } from '@/pages/RFOX/helpers'
import { useCooldownPeriodQuery } from '@/pages/RFOX/hooks/useCooldownPeriodQuery'
import { useCurrentApyQuery } from '@/pages/RFOX/hooks/useCurrentApyQuery'
import { useCurrentEpochMetadataQuery } from '@/pages/RFOX/hooks/useCurrentEpochMetadataQuery'
import { useCurrentEpochRewardsQuery } from '@/pages/RFOX/hooks/useCurrentEpochRewardsQuery'
Expand All @@ -63,6 +65,8 @@ import {
} from '@/state/slices/selectors'
import { useAppDispatch, useAppSelector } from '@/state/store'

const tooltipWrapperSx = { '& > span': { display: 'block', width: '100%' } }

const tbArrowUp = <TbArrowUp />
const tbArrowDown = <TbArrowDown />

Expand Down Expand Up @@ -332,6 +336,18 @@ export const RFOXSection = () => {
setIsClaimModalOpen(false)
}, [])

const cooldownPeriodQuery = useCooldownPeriodQuery(stakingAssetId)
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// The cooldown is fixed per request when un-staking, so anyone un-staking before it is zeroed on
// the migration date is held to the full period regardless. Lifts itself once the cooldown is
// zeroed on chain, so this needs no follow up deploy on the day.
const isUnstakeDisabled = useMemo(
() =>
stakingAssetId === foxOnArbitrumOneAssetId &&
Boolean(cooldownPeriodQuery.data?.cooldownPeriodSeconds),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
[cooldownPeriodQuery.data?.cooldownPeriodSeconds, stakingAssetId],
)

const actionsButtons = useMemo(() => {
return (
<Flex flexWrap='wrap' gap={2}>
Expand All @@ -346,15 +362,26 @@ export const RFOXSection = () => {
{translate('defi.stake')}
</Button>
)}
<Button
data-testid='rfox-unstake-button'
onClick={handleUnstakeClick}
colorScheme='gray'
flex='1 1 auto'
leftIcon={tbArrowDown}
>
{translate('defi.unstake')}
</Button>
{/* Tooltip wraps its child in a span to catch hover on a disabled button, so the flex
sizing lives on the wrapper to keep this button growing with its siblings */}
<Box flex='1 1 auto' sx={tooltipWrapperSx}>
<Tooltip
label={translate('RFOX.unstakeDisabledMigrationTooltip')}
isDisabled={!isUnstakeDisabled}
shouldWrapChildren
>
<Button
data-testid='rfox-unstake-button'
onClick={handleUnstakeClick}
colorScheme='gray'
width='full'
leftIcon={tbArrowDown}
isDisabled={isUnstakeDisabled}
>
{translate('defi.unstake')}
</Button>
</Tooltip>
</Box>
<Button
data-testid='rfox-claim-button'
onClick={handleClaimClick}
Expand All @@ -373,6 +400,7 @@ export const RFOXSection = () => {
translate,
stakingAssetId,
hasClaimableRequests,
isUnstakeDisabled,
])

if (!(stakingAsset && usdcAsset)) return null
Expand Down
Loading