Skip to content
Open
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions src/components/Warnings/CooldownWarning.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Stake } from '@aave/contract-helpers';
import { Trans } from '@lingui/macro';
import { Typography } from '@mui/material';
import { useRootStore } from 'src/store/root';
Expand All @@ -7,10 +8,22 @@ import { Link } from '../primitives/Link';
import { Warning } from '../primitives/Warning';
import { SecondsToString } from '../SecondsToString';

const SEVEN_DAYS = 7 * 24 * 60 * 60;
const TWENTY_DAYS = 20 * 24 * 60 * 60;

export const CooldownWarning = ({ cooldownSeconds }: { cooldownSeconds?: number }) => {
const cooldownTime = cooldownSeconds || TWENTY_DAYS;
export const CooldownWarning = ({
cooldownSeconds,
stakeAssetName,
}: {
cooldownSeconds?: number;
stakeAssetName?: Stake;
}) => {
const fallbackCooldown = stakeAssetName
? stakeAssetName === Stake.aave
? SEVEN_DAYS
: TWENTY_DAYS
: TWENTY_DAYS;
const cooldownTime = cooldownSeconds || fallbackCooldown;

const trackEvent = useRootStore((store) => store.trackEvent);
return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/transactions/Stake/StakeModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const StakeModalContent = ({ stakeAssetName, icon }: StakeProps) => {
const { data: stakeGeneralResult } = useGeneralStakeUiData(currentMarketData, stakeAssetName);

const stakeData = stakeGeneralResult?.[0];
const stakeCooldownSeconds = stakeData?.stakeCooldownSeconds || 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were just showing default right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were displaying a hardcoded value equal to 20 days. I updated to show the cooldown value coming from the SC, and giving a hardcoded fallback equal to 7 days

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I’m thinking that the proposal only changed the cooldown period for AAVE, so I need to adjust the fallback to make sure it doesn’t affect other scenarios.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we read from the contract directly?

const stakeUserData = stakeUserResult?.[0];

// states
Expand Down Expand Up @@ -112,7 +113,7 @@ export const StakeModalContent = ({ stakeAssetName, icon }: StakeProps) => {
/>
)}

{nameFormatted !== 'GHO' && <CooldownWarning />}
{nameFormatted !== 'GHO' && <CooldownWarning cooldownSeconds={stakeCooldownSeconds} />}

<AssetInput
value={amount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const StakeCooldownModalContent = ({ stakeAssetName, icon }: StakeCooldow

// Cooldown logic
const stakeCooldownSeconds = stakeData?.stakeCooldownSeconds || 0;

const stakeUnstakeWindow = stakeData?.stakeUnstakeWindow || 0;

const cooldownPercent = valueToBigNumber(stakeCooldownSeconds)
Expand Down
Loading