Skip to content

Commit 8b2d51f

Browse files
mchappelldanielmainDaniel Main
authored
[DDW-759] Over-saturation warning (#2733)
* [DDW-759] Added translations, new component for warning * [DDW-759] Fixed flow Issues * [DDW-759] Converted in functional component. Refactoring * [DDW-759] Simplify code, created function to calculate the oversaturation * [DDW-759] Updated oversaturation calculation and component * [DDW-759] Updated storybook components * [DDW-759] Removed logging * [DDW-759] Amended oversaturation component css class for centering text * [DDW-759] Updated CHANGELOG * [DDW-759] Fixed flow types * [DDW-759] Adjusted line-height of over-saturation warning * [DDW-759] Updated over-saturation check to ignore already delegating pool * [DDW-759] Removed unused import * [DDW-759] Updated css properties for over-saturation component * [DDW-759] Handle pre-selected pool with fee calculation * [DDW-759] Prevent modal overlay scroll * [DDW-759] Prevent any modal body overflow * [DDW-759] Adjusted CSS of over-saturation messages to match updated designs * [DDW-759] Use updated circulating supply figure, fast exit over-saturation calculations * [DDW-759] Updated condition for checking over-saturation * [DDW-759] Formatted over-saturation warning with 2 decimal places Co-authored-by: Daniel Main <[email protected]> Co-authored-by: Daniel Main <[email protected]>
1 parent 714306b commit 8b2d51f

18 files changed

+777
-564
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Features
66

7+
- Added Over-saturation warning in delegation wizard ([PR 2733](https://github.com/input-output-hk/daedalus/pull/2733))
78
- Added Catalyst footer links ([PR 2721](https://github.com/input-output-hk/daedalus/pull/2721))
89
- Fixed the Delegation popover timeout ([PR 2722](https://github.com/input-output-hk/daedalus/pull/2722))
910
- Removed "Alonzo tada" icon and "Alonzo countdown" screen ([PR 2708](https://github.com/input-output-hk/daedalus/pull/2708))

source/renderer/app/components/staking/delegation-setup-wizard/DelegationSetupWizardDialog.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import DelegationStepsChooseStakePoolDialog from './DelegationStepsChooseStakePo
1111
import LocalizableError from '../../../i18n/LocalizableError';
1212
import StakePool from '../../../domains/StakePool';
1313
import Wallet from '../../../domains/Wallet';
14-
1514
import type { DelegationCalculateFeeResponse } from '../../../api/staking/types';
1615
import type { HwDeviceStatus } from '../../../domains/Wallet';
1716

@@ -26,6 +25,7 @@ type Props = {
2625
onSelectWallet: Function,
2726
onSelectPool: Function,
2827
isWalletAcceptable: Function,
28+
maxDelegationFunds: number,
2929
stepsList: Array<string>,
3030
wallets: Array<Wallet>,
3131
minDelegationFunds: number,
@@ -45,6 +45,25 @@ type Props = {
4545
isTrezor: boolean,
4646
};
4747

48+
const getOversaturationPercentage = (
49+
selectedWallet: ?Wallet,
50+
selectedPool: ?StakePool,
51+
maxDelegationFunds: number
52+
): number => {
53+
if (
54+
!selectedPool ||
55+
!selectedWallet ||
56+
(selectedWallet.lastDelegatedStakePoolId ||
57+
selectedWallet.delegatedStakePoolId) === selectedPool.id
58+
)
59+
return 0;
60+
61+
const percentageIncrease = Number(
62+
(100 / maxDelegationFunds) * selectedWallet.availableAmount
63+
);
64+
return selectedPool.saturation + percentageIncrease - 100;
65+
};
66+
4867
@observer
4968
export default class DelegationSetupWizardDialog extends Component<Props> {
5069
componentDidUpdate(prevProps: Props) {
@@ -88,9 +107,15 @@ export default class DelegationSetupWizardDialog extends Component<Props> {
88107
getStakePoolById,
89108
hwDeviceStatus,
90109
isTrezor,
110+
maxDelegationFunds,
91111
} = this.props;
92112

93113
const selectedWalletId = get(selectedWallet, 'id', null);
114+
const oversaturationPercentage = getOversaturationPercentage(
115+
selectedWallet,
116+
selectedPool,
117+
maxDelegationFunds
118+
);
94119

95120
if (isDisabled) {
96121
return (
@@ -132,6 +157,8 @@ export default class DelegationSetupWizardDialog extends Component<Props> {
132157
onClose={onClose}
133158
onBack={onBack}
134159
onSelectPool={onSelectPool}
160+
onContinue={onContinue}
161+
oversaturationPercentage={oversaturationPercentage}
135162
/>
136163
);
137164
break;
@@ -150,6 +177,7 @@ export default class DelegationSetupWizardDialog extends Component<Props> {
150177
hwDeviceStatus={hwDeviceStatus}
151178
onExternalLinkClick={onOpenExternalLink}
152179
isTrezor={isTrezor}
180+
oversaturationPercentage={oversaturationPercentage}
153181
/>
154182
);
155183
break;

0 commit comments

Comments
 (0)