Skip to content

Commit

Permalink
[DDW-323] Updates maximum delegation amount calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaglumac committed Dec 3, 2020
1 parent 9420f00 commit fa37d16
Show file tree
Hide file tree
Showing 20 changed files with 103 additions and 65 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,11 @@ Changelog
- Fixed empty disk space calculation for some Linux distributions ([PR 2258](https://github.com/input-output-hk/daedalus/pull/2258))
- Fixed the overlap of the "X" button in the stake pools search box ([PR 2251](https://github.com/input-output-hk/daedalus/pull/2251))

### Chores

- Improved maximum delegation stake amount calculation ([PR 2262](https://github.com/input-output-hk/daedalus/pull/2262))
- Updated `cardano-wallet` to version `2020-11-26` ([PR 2262](https://github.com/input-output-hk/daedalus/pull/2262))

## 2.5.0

### Features
Expand Down
8 changes: 4 additions & 4 deletions nix/sources.json
Expand Up @@ -29,12 +29,12 @@
"homepage": null,
"owner": "input-output-hk",
"repo": "cardano-wallet",
"rev": "7767f33b7fde5cadf35e7974c531a49cd2680aa5",
"sha256": "1y4sfykqkdijv2rx4758nc1b2f262cn89qfsv48xrv4irwi7x5mr",
"rev": "5276dfdb433778643c4c82772c06f4d9fc3b28a7",
"sha256": "1262mangwrc2ykr9qwbcj57h2z2ib2sn0haipm2md4246f7b97v7",
"type": "tarball",
"url": "https://github.com/input-output-hk/cardano-wallet/archive/7767f33b7fde5cadf35e7974c531a49cd2680aa5.tar.gz",
"url": "https://github.com/input-output-hk/cardano-wallet/archive/5276dfdb433778643c4c82772c06f4d9fc3b28a7.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"version": "v2020-04-28"
"version": "v2020-11-26"
},
"gitignore": {
"branch": "master",
Expand Down
2 changes: 1 addition & 1 deletion source/renderer/app/components/sidebar/Sidebar.js
Expand Up @@ -7,7 +7,7 @@ import styles from './Sidebar.scss';
import SidebarCategory from './SidebarCategory';
import SidebarCategoryNetworkInfo from './SidebarCategoryNetworkInfo';
import SidebarWalletsMenu from './wallets/SidebarWalletsMenu';
import { CATEGORIES_BY_NAME } from '../../config/sidebarConfig.js';
import { CATEGORIES_BY_NAME } from '../../config/sidebarConfig';
import { ROUTES } from '../../routes-config';
import type {
SidebarHardwareWalletType,
Expand Down
Expand Up @@ -8,7 +8,7 @@ import BorderedBox from '../../widgets/BorderedBox';
import LoadingSpinner from '../../widgets/LoadingSpinner';
import StakingEpochsCurrentEpochData from './StakingEpochsCurrentEpochData';
import StakingEpochsPreviousEpochData from './StakingEpochsPreviousEpochData';
import { SELECTED_EPOCH_OPTIONS, humanizeDurationToShort } from './helpers.js';
import { SELECTED_EPOCH_OPTIONS, humanizeDurationToShort } from './helpers';
import type { EpochData } from '../../../api/staking/types';
import styles from './StakingEpochs.scss';

Expand Down
Expand Up @@ -10,7 +10,7 @@ import {
noDataExisting,
hasDataExisting,
sortData,
} from './helpers.js';
} from './helpers';
import type { EpochData } from '../../../api/staking/types';
import styles from './StakingEpochs.scss';

Expand Down
Expand Up @@ -10,7 +10,7 @@ import {
noDataExisting,
hasDataExisting,
sortData,
} from './helpers.js';
} from './helpers';
import type { EpochData } from '../../../api/staking/types';
import styles from './StakingEpochs.scss';
import globalMessages from '../../../i18n/global-messages';
Expand Down
Expand Up @@ -58,6 +58,7 @@ type Props = {
isRanking: boolean,
stakePoolsDelegatingList: Array<StakePool>,
getStakePoolById: Function,
maxDelegationFunds: number,
};

type State = {
Expand Down Expand Up @@ -132,6 +133,7 @@ export default class StakePools extends Component<Props, State> {
isRanking,
stakePoolsDelegatingList,
getStakePoolById,
maxDelegationFunds,
} = this.props;
const {
search,
Expand Down Expand Up @@ -196,6 +198,8 @@ export default class StakePools extends Component<Props, State> {
isRanking={isRanking}
numberOfStakePools={stakePoolsList.length}
getStakePoolById={getStakePoolById}
maxDelegationFunds={maxDelegationFunds}
maxDelegationFundsLog={Math.log(maxDelegationFunds)}
/>
<StakePoolsSearch
search={search}
Expand Down
Expand Up @@ -21,11 +21,9 @@ import {
RANKING_SLIDER_RATIO,
MIN_DELEGATION_FUNDS_LOG,
MIN_DELEGATION_FUNDS,
MAX_DELEGATION_FUNDS_LOG,
MAX_DELEGATION_FUNDS,
INITIAL_DELEGATION_FUNDS_LOG,
INITIAL_DELEGATION_FUNDS,
OUT_OF_RANGE_MAX_DELEGATION_FUNDS,
CIRCULATING_SUPPLY,
ALL_WALLETS_SELECTION_ID,
IS_RANKING_DATA_AVAILABLE,
} from '../../../config/stakingConfig';
Expand Down Expand Up @@ -127,6 +125,8 @@ type Props = {
isRanking: boolean,
numberOfStakePools: number,
getStakePoolById: Function,
maxDelegationFunds: number,
maxDelegationFundsLog: number,
};

type State = {
Expand Down Expand Up @@ -179,6 +179,7 @@ export default class StakePoolsRanking extends Component<Props, State> {
updateDelegatingStake,
rankStakePools,
selectedDelegationWalletId,
maxDelegationFunds,
} = this.props;
const selectedWallet = wallets.find(
(wallet) => wallet.id === selectedWalletId
Expand All @@ -197,7 +198,7 @@ export default class StakePoolsRanking extends Component<Props, State> {
if (selectedWalletId === ALL_WALLETS_SELECTION_ID) {
amountValue = Math.min(
getAllAmounts(wallets).toNumber(),
MAX_DELEGATION_FUNDS
maxDelegationFunds
);
} else if (selectedWallet) {
amountValue = selectedWallet.amount.toNumber();
Expand All @@ -219,18 +220,21 @@ export default class StakePoolsRanking extends Component<Props, State> {
};

onSliderChange = (sliderValue: number) => {
const { updateDelegatingStake } = this.props;
const {
updateDelegatingStake,
maxDelegationFunds,
maxDelegationFundsLog,
} = this.props;
let amountValue = null;
if (
sliderValue ===
Math.round(MIN_DELEGATION_FUNDS_LOG * RANKING_SLIDER_RATIO)
) {
amountValue = MIN_DELEGATION_FUNDS;
} else if (
sliderValue ===
Math.round(MAX_DELEGATION_FUNDS_LOG * RANKING_SLIDER_RATIO)
sliderValue === Math.round(maxDelegationFundsLog * RANKING_SLIDER_RATIO)
) {
amountValue = MAX_DELEGATION_FUNDS;
amountValue = maxDelegationFunds;
} else {
amountValue = generateThousands(
Math.exp(sliderValue / RANKING_SLIDER_RATIO)
Expand Down Expand Up @@ -296,6 +300,8 @@ export default class StakePoolsRanking extends Component<Props, State> {
numberOfStakePools,
getStakePoolById,
rankStakePools,
maxDelegationFunds,
maxDelegationFundsLog,
} = this.props;
const { sliderValue, displayValue } = this.state;
const learnMoreButtonClasses = classnames(['flat', styles.actionLearnMore]);
Expand Down Expand Up @@ -381,10 +387,8 @@ export default class StakePoolsRanking extends Component<Props, State> {
MIN_DELEGATION_FUNDS_LOG * RANKING_SLIDER_RATIO
)}
minDisplayValue={MIN_DELEGATION_FUNDS}
max={Math.round(
MAX_DELEGATION_FUNDS_LOG * RANKING_SLIDER_RATIO
)}
maxDisplayValue={MAX_DELEGATION_FUNDS}
max={Math.round(maxDelegationFundsLog * RANKING_SLIDER_RATIO)}
maxDisplayValue={maxDelegationFunds}
value={sliderValue}
displayValue={displayValue}
showRawValue
Expand All @@ -401,7 +405,7 @@ export default class StakePoolsRanking extends Component<Props, State> {
<PopOver
content={intl.formatMessage(messages.rankingExtraTooltip)}
>
{shortNumber(OUT_OF_RANGE_MAX_DELEGATION_FUNDS)}
{shortNumber(CIRCULATING_SUPPLY)}
</PopOver>
</div>
<div className={styles.outOfSliderRangeEnd} />
Expand Down
Expand Up @@ -18,7 +18,7 @@ import {
RECOVERY_PHRASE_VERIFICATION_TIMES as times,
} from '../../../config/walletRecoveryPhraseVerificationConfig';
import { getStatusFromWalletData } from '../../../utils/walletRecoveryPhraseVerificationUtils';
import { LOCALES } from '../../../../../common/types/locales.types.js';
import { LOCALES } from '../../../../../common/types/locales.types';

export const messages = defineMessages({
title: {
Expand Down
Expand Up @@ -9,7 +9,7 @@ import { Link } from 'react-polymorph/lib/components/Link';
import { LinkSkin } from 'react-polymorph/lib/skins/simple/LinkSkin';
import CancelTransactionButton from './CancelTransactionButton';
import styles from './Transaction.scss';
import TransactionTypeIcon from './TransactionTypeIcon.js';
import TransactionTypeIcon from './TransactionTypeIcon';
import adaSymbol from '../../../assets/images/ada-symbol.inline.svg';
import arrow from '../../../assets/images/collapse-arrow.inline.svg';
import {
Expand Down
9 changes: 4 additions & 5 deletions source/renderer/app/config/stakingConfig.js
Expand Up @@ -2,13 +2,12 @@
import type { RedeemItnRewardsStep } from '../types/stakingTypes';

export const RANKING_SLIDER_RATIO = 60;
export const MIN_DELEGATION_FUNDS_LOG = Math.log(10);
export const MIN_DELEGATION_FUNDS = 10;
export const INITIAL_DELEGATION_FUNDS_LOG = Math.log(1000);
export const MIN_DELEGATION_FUNDS_LOG = Math.log(MIN_DELEGATION_FUNDS);
export const INITIAL_DELEGATION_FUNDS = 1000;
export const MAX_DELEGATION_FUNDS_LOG = Math.log(220000000);
export const MAX_DELEGATION_FUNDS = 220000000;
export const OUT_OF_RANGE_MAX_DELEGATION_FUNDS = 33000000000;
export const INITIAL_DELEGATION_FUNDS_LOG = Math.log(INITIAL_DELEGATION_FUNDS);
export const INITIAL_DESIRED_POOLS_NUMBER = 150;
export const CIRCULATING_SUPPLY = 31112484646;
export const ALL_WALLETS_SELECTION_ID = '0';

// Dimensions
Expand Down
Expand Up @@ -2,7 +2,7 @@
import React, { Component } from 'react';
import { observer, inject } from 'mobx-react';
import GeneralSettings from '../../../components/settings/categories/GeneralSettings';
import { rebuildApplicationMenu } from '../../../ipc/rebuild-application-menu.js';
import { rebuildApplicationMenu } from '../../../ipc/rebuild-application-menu';
import type { InjectedProps } from '../../../types/injectedPropsType';

@inject('stores', 'actions')
Expand Down
2 changes: 2 additions & 0 deletions source/renderer/app/containers/staking/StakePoolsListPage.js
Expand Up @@ -57,6 +57,7 @@ export default class StakePoolsListPage extends Component<Props> {
fetchingStakePoolsFailed,
recentStakePools,
getStakePoolById,
maxDelegationFunds,
} = staking;
const { all } = wallets;
const isLoading =
Expand All @@ -81,6 +82,7 @@ export default class StakePoolsListPage extends Component<Props> {
isLoading={isLoading}
isRanking={isRanking}
getStakePoolById={getStakePoolById}
maxDelegationFunds={maxDelegationFunds}
/>
{isRanking && <StakePoolsRankingLoader />}
{uiDialogs.isOpen(DelegationSetupWizardDialog) ? (
Expand Down

0 comments on commit fa37d16

Please sign in to comment.