Skip to content

Commit 6a911a1

Browse files
feat: [LW-7837, LW-8921] add warning banner for retiring, retired and saturated stake pools (#678)
--------- Signed-off-by: John Oshalusi <john.oshalusi@iohk.io> Co-authored-by: Szymon Masłowski <szymon.maslowski@iohk.io>
1 parent 22242ed commit 6a911a1

21 files changed

+169
-102
lines changed
Lines changed: 3 additions & 0 deletions
Loading

packages/staking/src/features/i18n/translations/en.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ export const en: Translations = {
116116
'overview.banners.portfolioDrifted.message':
117117
'Make sure to rebalance your staking ratios if you want to match your preferences',
118118
'overview.banners.portfolioDrifted.title': 'Your current delegation portfolio has shifted',
119+
'overview.banners.saturatedOrRetiredPool.message': 'Please make sure to choose other pool(s) to avoid losing rewards',
120+
'overview.banners.saturatedOrRetiredPool.title': 'One or several of your pools are too saturated / retired',
119121
'overview.delegationCard.label.balance': 'ADA Balance',
120122
'overview.delegationCard.label.pools': 'Pool(s)',
121123
'overview.delegationCard.label.status': 'Status',
@@ -142,6 +144,7 @@ export const en: Translations = {
142144
'overview.stakingInfoCard.lastReward': 'Last reward',
143145
'overview.stakingInfoCard.margin': 'Margin',
144146
'overview.stakingInfoCard.poolRetired': 'Pool retired',
147+
'overview.stakingInfoCard.poolRetiring': 'Pool retiring',
145148
'overview.stakingInfoCard.poolSaturated': 'Pool over-saturated',
146149
'overview.stakingInfoCard.ros': 'ROS',
147150
'overview.stakingInfoCard.tooltipFiatLabel': 'USD Value',

packages/staking/src/features/i18n/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ type KeysStructure = {
200200
title: '';
201201
message: '';
202202
};
203+
saturatedOrRetiredPool: {
204+
title: '';
205+
message: '';
206+
};
203207
};
204208
stakingInfoCard: {
205209
fee: '';
@@ -209,6 +213,7 @@ type KeysStructure = {
209213
totalRewards: '';
210214
totalStaked: '';
211215
poolRetired: '';
216+
poolRetiring: '';
212217
poolSaturated: '';
213218
tooltipFiatLabel: '';
214219
};

packages/staking/src/features/overview/Overview.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { GetStartedSteps } from './GetStartedSteps';
1010
import { hasMinimumFundsToDelegate, hasPendingDelegationTransaction, mapPortfolioToDisplayData } from './helpers';
1111
import { StakeFundsBanner } from './StakeFundsBanner';
1212
import { StakingInfoCard } from './StakingInfoCard';
13-
import { StakingNotificationBanner, getCurrentStakingNotification } from './StakingNotificationBanner';
13+
import { StakingNotificationBanners, getCurrentStakingNotifications } from './StakingNotificationBanners';
1414

1515
export const Overview = () => {
1616
const { t } = useTranslation();
@@ -29,7 +29,7 @@ export const Overview = () => {
2929
currentPortfolio: store.currentPortfolio,
3030
portfolioMutators: store.mutators,
3131
}));
32-
const stakingNotification = getCurrentStakingNotification({ currentPortfolio, walletActivities });
32+
const stakingNotifications = getCurrentStakingNotifications({ currentPortfolio, walletActivities });
3333

3434
const totalCoinBalance = balancesBalance?.total?.coinBalance;
3535

@@ -76,8 +76,9 @@ export const Overview = () => {
7676
if (currentPortfolio.length === 0) {
7777
return (
7878
<>
79-
{stakingNotification ? (
80-
<StakingNotificationBanner notification={stakingNotification} />
79+
{/* defensive check - no other notification than pendingFirstDelegation should be possible here at the moment of writing this comment */}
80+
{stakingNotifications.includes('pendingFirstDelegation') ? (
81+
<StakingNotificationBanners notifications={stakingNotifications} />
8182
) : (
8283
<Flex flexDirection="column" gap="$32">
8384
<StakeFundsBanner balance={totalCoinBalance} />
@@ -104,10 +105,10 @@ export const Overview = () => {
104105
status={currentPortfolio.length === 1 ? 'simple-delegation' : 'multi-delegation'}
105106
/>
106107
</Box>
107-
{stakingNotification && (
108-
<Box mb="$40">
109-
<StakingNotificationBanner notification={stakingNotification} />
110-
</Box>
108+
{stakingNotifications.length > 0 && (
109+
<Flex mb="$40" flexDirection="column">
110+
<StakingNotificationBanners notifications={stakingNotifications} />
111+
</Flex>
111112
)}
112113
<Flex justifyContent="space-between" mb="$16">
113114
<Text.SubHeading>{t('overview.yourPoolsSection.heading')}</Text.SubHeading>

packages/staking/src/features/overview/OverviewPopup.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { FundWalletBanner } from './FundWalletBanner';
1111
import { hasMinimumFundsToDelegate, mapPortfolioToDisplayData } from './helpers';
1212
import { StakeFundsBanner } from './StakeFundsBanner';
1313
import { StakingInfoCard } from './StakingInfoCard';
14-
import { StakingNotificationBanner, getCurrentStakingNotification } from './StakingNotificationBanner';
14+
import { StakingNotificationBanners, getCurrentStakingNotifications } from './StakingNotificationBanners';
1515

1616
export const OverviewPopup = () => {
1717
const { t } = useTranslation();
@@ -30,7 +30,7 @@ export const OverviewPopup = () => {
3030
currentPortfolio: store.currentPortfolio,
3131
portfolioMutators: store.mutators,
3232
}));
33-
const stakingNotification = getCurrentStakingNotification({ currentPortfolio, walletActivities });
33+
const stakingNotifications = getCurrentStakingNotifications({ currentPortfolio, walletActivities });
3434

3535
const totalCoinBalance = balancesBalance?.total?.coinBalance || '0';
3636

@@ -85,10 +85,10 @@ export const OverviewPopup = () => {
8585

8686
return (
8787
<>
88-
{stakingNotification === 'portfolioDrifted' && (
89-
<Box mb="$32">
90-
<StakingNotificationBanner notification="portfolioDrifted" />
91-
</Box>
88+
{stakingNotifications.length > 0 && (
89+
<Flex mb="$32" flexDirection="column">
90+
<StakingNotificationBanners notifications={stakingNotifications} />
91+
</Flex>
9292
)}
9393
<Box mb="$32">
9494
<DelegationCard

packages/staking/src/features/overview/StakingInfoCard/StakingInfoCard.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { getRandomIcon } from '@lace/common';
44
import { Flex } from '@lace/ui';
55
import BigNumber from 'bignumber.js';
66
import cn from 'classnames';
7-
import React from 'react';
7+
import React, { ReactNode } from 'react';
88
import { useTranslation } from 'react-i18next';
9+
import MoonIcon from '../../../assets/icons/moon.component.svg';
10+
import WarningIcon from '../../../assets/icons/warning.component.svg';
911
import { TranslationKey } from '../../i18n';
10-
import MoonIcon from './moon.component.svg';
1112
import { StakePoolInfo } from './StakePoolInfo';
1213
import styles from './StakingInfoCard.module.scss';
1314
import { Stats } from './Stats';
1415
import { Tooltip } from './StatsTooltip';
15-
import WarningIon from './warning.component.svg';
1616

1717
const DEFAULT_DECIMALS = 2;
1818

@@ -34,7 +34,7 @@ const formatNumericValue = (
3434
</>
3535
);
3636

37-
type PoolStatus = 'retired' | 'saturated';
37+
export type PoolStatus = 'retired' | 'saturated' | 'retiring';
3838

3939
export type StakingInfoCardProps = {
4040
className?: string;
@@ -56,13 +56,15 @@ export type StakingInfoCardProps = {
5656
status?: PoolStatus;
5757
};
5858

59-
const iconsByPoolStatus: Record<PoolStatus, React.FC<React.SVGProps<SVGSVGElement>>> = {
60-
retired: MoonIcon,
61-
saturated: WarningIon,
59+
const iconsByPoolStatus: Record<PoolStatus, ReactNode> = {
60+
retired: <Icon style={{ color: '#FF8E3C', fontSize: '24px' }} component={MoonIcon} />,
61+
retiring: <Icon style={{ color: '#FDC300', fontSize: '24px' }} component={MoonIcon} />,
62+
saturated: <Icon style={{ color: '#FF5470', fontSize: '24px' }} component={WarningIcon} />,
6263
};
6364

6465
const labelTranslationKeysByPoolStatus: Record<PoolStatus, TranslationKey> = {
6566
retired: 'overview.stakingInfoCard.poolRetired',
67+
retiring: 'overview.stakingInfoCard.poolRetiring',
6668
saturated: 'overview.stakingInfoCard.poolSaturated',
6769
};
6870

@@ -102,10 +104,8 @@ export const StakingInfoCard = ({
102104
id={id}
103105
onClick={onStakePoolSelect}
104106
/>
105-
{(status === 'retired' || status === 'saturated') && (
106-
<Tooltip content={t(labelTranslationKeysByPoolStatus[status])}>
107-
<Icon style={{ color: '#FF5470', fontSize: '24px' }} component={iconsByPoolStatus[status]} />
108-
</Tooltip>
107+
{(status === 'retired' || status === 'saturated' || status === 'retiring') && (
108+
<Tooltip content={t(labelTranslationKeysByPoolStatus[status])}>{iconsByPoolStatus[status]}</Tooltip>
109109
)}
110110
</Flex>
111111
</div>

packages/staking/src/features/overview/StakingNotificationBanner/StakingNotificationBanner.tsx

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/staking/src/features/overview/StakingNotificationBanner/getCurrentStakingNotification.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)