Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDW-759] Over-saturation warning #2733

Merged
merged 22 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
665fba2
[DDW-759] Added translations, new component for warning
danielmain Oct 17, 2021
d26fa71
[DDW-759] Fixed flow Issues
danielmain Oct 18, 2021
02f0816
[DDW-759] Converted in functional component. Refactoring
danielmain Oct 19, 2021
9140a7c
[DDW-759] Simplify code, created function to calculate the oversatura…
Nov 4, 2021
5380b09
[DDW-759] Merge branch 'develop' into feature/ddw-759-oversaturation-…
mchappell Nov 4, 2021
3fd7b2a
[DDW-759] Updated oversaturation calculation and component
mchappell Nov 5, 2021
6165126
[DDW-759] Updated storybook components
mchappell Nov 5, 2021
7a487c1
[DDW-759] Removed logging
mchappell Nov 5, 2021
71f41b3
[DDW-759] Amended oversaturation component css class for centering text
mchappell Nov 5, 2021
f9e1f5d
[DDW-759] Updated CHANGELOG
mchappell Nov 5, 2021
b17377e
[DDW-759] Fixed flow types
mchappell Nov 5, 2021
478c415
[DDW-759] Adjusted line-height of over-saturation warning
mchappell Nov 5, 2021
7b32c2a
[DDW-759] Updated over-saturation check to ignore already delegating …
mchappell Nov 5, 2021
ceab0a0
[DDW-759] Removed unused import
mchappell Nov 5, 2021
92362f2
[DDW-759] Updated css properties for over-saturation component
mchappell Nov 5, 2021
7553d8d
[DDW-759] Handle pre-selected pool with fee calculation
mchappell Nov 5, 2021
0baae60
[DDW-759] Prevent modal overlay scroll
mchappell Nov 8, 2021
a3b9c72
[DDW-759] Prevent any modal body overflow
mchappell Nov 8, 2021
0f0562e
[DDW-759] Adjusted CSS of over-saturation messages to match updated d…
mchappell Nov 8, 2021
5b67bbc
[DDW-759] Use updated circulating supply figure, fast exit over-satur…
mchappell Nov 8, 2021
5447b1d
[DDW-759] Updated condition for checking over-saturation
mchappell Nov 9, 2021
1e4b6ec
[DDW-759] Formatted over-saturation warning with 2 decimal places
mchappell Nov 9, 2021
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Features

- Added Over-saturation warning in delegation wizard ([PR 2733](https://github.com/input-output-hk/daedalus/pull/2733))
- Added Catalyst footer links ([PR 2721](https://github.com/input-output-hk/daedalus/pull/2721))
- Fixed the Delegation popover timeout ([PR 2722](https://github.com/input-output-hk/daedalus/pull/2722))
- Removed "Alonzo tada" icon and "Alonzo countdown" screen ([PR 2708](https://github.com/input-output-hk/daedalus/pull/2708))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import DelegationStepsChooseStakePoolDialog from './DelegationStepsChooseStakePo
import LocalizableError from '../../../i18n/LocalizableError';
import StakePool from '../../../domains/StakePool';
import Wallet from '../../../domains/Wallet';

import type { DelegationCalculateFeeResponse } from '../../../api/staking/types';
import type { HwDeviceStatus } from '../../../domains/Wallet';

Expand All @@ -26,6 +25,7 @@ type Props = {
onSelectWallet: Function,
onSelectPool: Function,
isWalletAcceptable: Function,
maxDelegationFunds: number,
stepsList: Array<string>,
wallets: Array<Wallet>,
minDelegationFunds: number,
Expand All @@ -45,6 +45,25 @@ type Props = {
isTrezor: boolean,
};

const getOversaturationPercentage = (
selectedWallet: ?Wallet,
selectedPool: ?StakePool,
maxDelegationFunds: number
): number => {
if (
!selectedPool ||
!selectedWallet ||
(selectedWallet.lastDelegatedStakePoolId ||
selectedWallet.delegatedStakePoolId) === selectedPool.id
)
return 0;

const percentageIncrease = Number(
(100 / maxDelegationFunds) * selectedWallet.availableAmount
);
return selectedPool.saturation + percentageIncrease - 100;
};

@observer
export default class DelegationSetupWizardDialog extends Component<Props> {
componentDidUpdate(prevProps: Props) {
Expand Down Expand Up @@ -88,9 +107,15 @@ export default class DelegationSetupWizardDialog extends Component<Props> {
getStakePoolById,
hwDeviceStatus,
isTrezor,
maxDelegationFunds,
} = this.props;

const selectedWalletId = get(selectedWallet, 'id', null);
const oversaturationPercentage = getOversaturationPercentage(
selectedWallet,
selectedPool,
maxDelegationFunds
);

if (isDisabled) {
return (
Expand Down Expand Up @@ -132,6 +157,8 @@ export default class DelegationSetupWizardDialog extends Component<Props> {
onClose={onClose}
onBack={onBack}
onSelectPool={onSelectPool}
onContinue={onContinue}
oversaturationPercentage={oversaturationPercentage}
/>
);
break;
Expand All @@ -150,6 +177,7 @@ export default class DelegationSetupWizardDialog extends Component<Props> {
hwDeviceStatus={hwDeviceStatus}
onExternalLinkClick={onOpenExternalLink}
isTrezor={isTrezor}
oversaturationPercentage={oversaturationPercentage}
/>
);
break;
Expand Down
Loading