diff --git a/src/components/ManaCalculator/components/DelegatorSettings.tsx b/src/components/ManaCalculator/components/DelegatorSettings.tsx
new file mode 100644
index 00000000000..ead0fa71e41
--- /dev/null
+++ b/src/components/ManaCalculator/components/DelegatorSettings.tsx
@@ -0,0 +1,30 @@
+import React from 'react';
+import { Details } from '@docusaurus/theme-common/Details';
+import { useManaState } from '../hooks';
+import { fromMicro, toMicro, roundMax } from '../utils';
+
+export function DelegatorSettings() {
+ const {
+ state,
+ handleOwnPFChange,
+ handleOwnFCChange,
+ handleOwnStakeChange,
+ handleAttractedNewDelegatedStakeChange,
+ } = useManaState();
+ return (
+
+ Delegated amount ({state.network})
+
+ handleOwnStakeChange(toMicro(Number(e.target.value)))
+ }
+ >
+
+
+ );
+}
diff --git a/src/components/ManaCalculator/components/OtherParametersSection.tsx b/src/components/ManaCalculator/components/OtherParametersSection.tsx
index 5d60e49610d..5aa3c621125 100644
--- a/src/components/ManaCalculator/components/OtherParametersSection.tsx
+++ b/src/components/ManaCalculator/components/OtherParametersSection.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import { useManaState } from '../hooks/useManaState';
import Select from 'react-select';
+import { UserType } from '../enums';
import { CongestionType } from '../enums';
import { AdvancedSettingsValidator } from './AdvancedSettingsValidator';
@@ -45,7 +46,14 @@ export function OtherParametersSection() {
value={state.finalEpoch}
onChange={(e) => handleFinalEpochChange(Number(e.target.value))}
>
-
+ {state.userType === UserType.HOLDER ? (
+ <>
+ >
+ ) : (
+ <>
+ < AdvancedSettingsValidator />
+ >
+ )}
);
}
diff --git a/src/components/ManaCalculator/components/OutputForm.tsx b/src/components/ManaCalculator/components/OutputForm.tsx
index 4a7a88340d0..c54c306fc15 100644
--- a/src/components/ManaCalculator/components/OutputForm.tsx
+++ b/src/components/ManaCalculator/components/OutputForm.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import { useManaState, useResults } from '../hooks';
import { fromMicro, roundMax } from '../utils';
+import { UserType } from '../enums';
import humanizeDuration from 'humanize-duration';
export function OutputForm() {
@@ -8,7 +9,8 @@ export function OutputForm() {
const results = useResults(state);
const passiveRewards = roundMax(fromMicro(results.passiveRewards), 6);
const manaGenerated = roundMax(fromMicro(results.generatedRewards), 6);
- const totalBPS = roundMax(results.totalBPS, 2);
+ const blockAllowance = roundMax(results.blockAllowance, 2);
+ const totalBPS = roundMax(results.totalBPS, 20);
const humanizer = humanizeDuration.humanizer({
units: ['y', 'mo', 'w', 'd', 'h', 'm', 's', 'ms'],
maxDecimalPoints: 3,
@@ -18,27 +20,70 @@ export function OutputForm() {
return (
+ { state.userType === UserType.VALIDATOR ? (
+ <>
- Mana generation (by holding):{' '}
- {passiveRewards}
+ Generation (by just holding) in the input period:{' '}
+ {passiveRewards} Mana
- Mana rewards: {manaGenerated}
+ Mana rewards from staking in the input period: {manaGenerated} Mana
- Total BPS granted: {totalBPS}
+ Total Block Allowance granted after the input period: {roundMax(blockAllowance,3)} standard blocks
+
+
+ Time it takes to accumulate enough mana for a standard block...
+
+
+ ...as a holder (owning {fromMicro(state.heldTokens)} tokens and not staking any of them):{' '}
+ {passiveMsToTransaction}
+
+
+ ...as a validator (owning {fromMicro(state.heldTokens)} tokens and staking {fromMicro(state.stakedOrDelegatedTokens)} of them):{' '}
+ {msToTransaction}
+
+ >
+ ) :
+ state.userType === UserType.DELEGATOR ? (
+ <>
+
+ Generation (by just holding) in the input period:{' '}
+ {passiveRewards} Mana
+
+
+ Mana rewards from delegating in the input period: {manaGenerated} Mana
+
+
+ Total Block Allowance granted after the input period: {roundMax(blockAllowance,3)} standard blocks
+
+
+ Time it takes to accumulate enough mana for a standard block...
- Time it takes to accumulate enough mana for a standard transaction...
+ ...as a holder (owning {fromMicro(state.heldTokens)} tokens and not delegating any of them):{' '}
+ {passiveMsToTransaction}
- ...as a delegator/validator:{' '}
+ ...as a delegator (owning {fromMicro(state.heldTokens)} tokens and delegating {fromMicro(state.stakedOrDelegatedTokens)} of them):{' '}
{msToTransaction}
+ >
+ ): (
+ <>
+
+ Generation in the input period:{' '}
+ {passiveRewards} Mana
+
+
+ Total Block Allowance granted after the input period: {roundMax(blockAllowance,3)} standard blocks
+
- ...as a holder:{' '}
+ Time it takes to accumulate enough mana for a standard block:{' '}
{passiveMsToTransaction}
+ >
+ )}
);
}
diff --git a/src/components/ManaCalculator/components/RoleSection.tsx b/src/components/ManaCalculator/components/RoleSection.tsx
index 48c4bc26f21..85cadffa2a8 100644
--- a/src/components/ManaCalculator/components/RoleSection.tsx
+++ b/src/components/ManaCalculator/components/RoleSection.tsx
@@ -4,6 +4,7 @@ import Select from 'react-select';
import { UserType } from '../enums';
import { fromMicro, toMicro } from '../utils';
import { ValidatorSettings } from './ValidatorSettings';
+import { DelegatorSettings } from './DelegatorSettings';
export function RoleSection() {
const {
@@ -31,30 +32,24 @@ export function RoleSection() {
options={[
{ value: UserType.DELEGATOR, label: `Delegator` },
{ value: UserType.VALIDATOR, label: `Validator` },
+ { value: UserType.HOLDER, label: `Holder` },
]}
/>
- Held amount ({state.network})
+ Owned amount ({state.network})
handleOwnHoldChange(toMicro(Number(e.target.value)))}
>
- {state.userType === UserType.VALIDATOR ? (
+ {
+ state.userType === UserType.VALIDATOR ? (
<>
- Stake ({state.network})
-
- handleOwnStakeChange(toMicro(Number(e.target.value)))
- }
- >
-
-
+
>
- ) : (
+ ) :
+ state.userType === UserType.DELEGATOR ? (
<>
Delegating to
>
- )}
+ ): (
+ <>
+ >
+ )}
);
}
diff --git a/src/components/ManaCalculator/components/ValidatorSettings.tsx b/src/components/ManaCalculator/components/ValidatorSettings.tsx
index d7cc8384f2b..7d4a9bf1a5f 100644
--- a/src/components/ManaCalculator/components/ValidatorSettings.tsx
+++ b/src/components/ManaCalculator/components/ValidatorSettings.tsx
@@ -1,14 +1,14 @@
import React from 'react';
import { Details } from '@docusaurus/theme-common/Details';
import { useManaState } from '../hooks';
+import { fromMicro, toMicro, roundMax } from '../utils';
export function ValidatorSettings() {
const {
- state: {
- validator: { performanceFactor, fixedCost, attractedNewDelegatedStake },
- },
+ state,
handleOwnPFChange,
handleOwnFCChange,
+ handleOwnStakeChange,
handleAttractedNewDelegatedStakeChange,
} = useManaState();
return (
@@ -16,12 +16,21 @@ export function ValidatorSettings() {
summary='Validator Settings'
className='mana_calculator__card mana_calculator_inner__card'
>
+ Staked amount ({state.network})
+
+ handleOwnStakeChange(toMicro(Number(e.target.value)))
+ }
+ >
+
Performance factor
handleOwnPFChange(Number(e.target.value))}
>
@@ -30,15 +39,15 @@ export function ValidatorSettings() {
className='mana_calculator__compact input--vertical-spaced'
type='number'
step='0.01'
- value={fixedCost}
+ value={state.validator.fixedCost}
onChange={(e) => handleOwnFCChange(Number(e.target.value))}
>
- Attracted new delegated stake
+ Attracted new delegated stake ({state.network})
handleAttractedNewDelegatedStakeChange(Number(e.target.value))
}
diff --git a/src/components/ManaCalculator/components/index.ts b/src/components/ManaCalculator/components/index.ts
index dfac57d8bbb..92fa8d84681 100644
--- a/src/components/ManaCalculator/components/index.ts
+++ b/src/components/ManaCalculator/components/index.ts
@@ -3,6 +3,7 @@ export * from './ManaCalculator';
export * from './OtherParametersSection';
export * from './ValidatorCard';
export * from './ValidatorSettings';
+export * from './DelegatorSettings';
export * from './RoleSection';
export * from './OutputForm';
export * from './NetworkSection';
diff --git a/src/components/ManaCalculator/constants.ts b/src/components/ManaCalculator/constants.ts
index 64131d888f3..2ccf3c798e7 100644
--- a/src/components/ManaCalculator/constants.ts
+++ b/src/components/ManaCalculator/constants.ts
@@ -3,7 +3,7 @@ import { CongestionType } from './enums/parameters.enum';
// GENERIC
export const INITIAL_EPOCH = 1;
-export const FINAL_EPOCH = 1000;
+export const FINAL_EPOCH = 10;
export const SLOT_DURATION = 10;
export const SLOTS_IN_EPOCH = 8192;
export const EPOCH_DURATION = SLOTS_IN_EPOCH * SLOT_DURATION;
diff --git a/src/components/ManaCalculator/enums/parameters.enum.ts b/src/components/ManaCalculator/enums/parameters.enum.ts
index faff9332bdb..5f5a8e8f4a5 100644
--- a/src/components/ManaCalculator/enums/parameters.enum.ts
+++ b/src/components/ManaCalculator/enums/parameters.enum.ts
@@ -1,6 +1,7 @@
export enum UserType {
DELEGATOR,
VALIDATOR,
+ HOLDER,
}
export enum NetworkType {
diff --git a/src/components/ManaCalculator/hooks/useManaState.ts b/src/components/ManaCalculator/hooks/useManaState.ts
index 495e75bf19f..75cd3d844d0 100644
--- a/src/components/ManaCalculator/hooks/useManaState.ts
+++ b/src/components/ManaCalculator/hooks/useManaState.ts
@@ -234,8 +234,8 @@ export function getDefaultParameters(
shareOfYourStakeLocked: 1.0,
attractedNewDelegatedStake:
(finalNetworkParams.stakedTokens *
- validators.reduce((a, b) => a + b.lockedStake, 0)) /
- validators.reduce((a, b) => a + b.delegatedStake, 0),
+ validators.reduce((a, b) => a + b.delegatedStake, 0)) /
+ validators.reduce((a, b) => a + b.lockedStake, 0),
attractedDelegatedStakeFromOtherPools: 0,
},
network,
diff --git a/src/components/ManaCalculator/hooks/useResults.ts b/src/components/ManaCalculator/hooks/useResults.ts
index 5e53f02ff77..2268bda04f5 100644
--- a/src/components/ManaCalculator/hooks/useResults.ts
+++ b/src/components/ManaCalculator/hooks/useResults.ts
@@ -40,21 +40,51 @@ export function useResults(state: ManaState) {
state.generationPerSlot,
);
- const yourBlocksPerEpoch = passiveRewards / state.congestionAmount;
- const yourAdditionalBlocksPerEpoch =
+ const passiveRewardsInTheFirstEpoch = calculatePassiveRewards(
+ state.heldTokens,
+ state.initialEpoch,
+ state.initialEpoch + 1,
+ state.generationPerSlot,
+ );
+
+
+ const generatedRewardsInTheFirstEpoch = calculateManaRewards(
+ state.stakedOrDelegatedTokens,
+ state.delegator.validator,
+ validatorParameters,
+ state.validators,
+ state.initialEpoch,
+ state.initialEpoch + 1,
+ state.userType,
+ state.network,
+ state.generationPerSlot,
+ );
+
+ const yourPassiveBlocksInPeriod = passiveRewards / state.congestionAmount;
+ const yourAdditionalBlocksInPeriod =
generatedRewards / state.congestionAmount;
- const yourTPS = yourBlocksPerEpoch / EPOCH_DURATION;
- const yourAdditionalTPS = yourAdditionalBlocksPerEpoch / EPOCH_DURATION;
- const totalBPS = yourTPS + yourAdditionalTPS;
+ const yourPassiveBlocksInTheFirstEpoch = passiveRewardsInTheFirstEpoch / state.congestionAmount;
+ const yourAdditionalBlocksInTheFirstEpoch =
+ generatedRewardsInTheFirstEpoch / state.congestionAmount;
+
+ const yourTotalBlocksInPeriod = yourPassiveBlocksInPeriod + yourAdditionalBlocksInPeriod
+
+ const yourTotalBlocksInTheFirstEpoch = yourPassiveBlocksInTheFirstEpoch + yourAdditionalBlocksInTheFirstEpoch
+
+ const blockAllowance = yourTotalBlocksInPeriod;
+
+ const yourBPSasHolder = yourPassiveBlocksInTheFirstEpoch / EPOCH_DURATION;
+ const totalBPS = yourTotalBlocksInTheFirstEpoch / EPOCH_DURATION;
const msToTransaction = (1 / totalBPS) * 1_000;
- const passiveMsToTransaction = (1 / yourTPS) * 1_000;
+ const passiveMsToTransaction = (1 / yourBPSasHolder) * 1_000;
return {
generatedRewards,
passiveRewards,
totalBPS,
+ blockAllowance,
msToTransaction,
passiveMsToTransaction,
};
diff --git a/src/components/ManaCalculator/utils.ts b/src/components/ManaCalculator/utils.ts
index 9a6ca572255..5d1f2f870f8 100644
--- a/src/components/ManaCalculator/utils.ts
+++ b/src/components/ManaCalculator/utils.ts
@@ -7,6 +7,7 @@ import {
SHIMMER_GENERATION_PER_SLOT,
SHIMMER_SUPPLY,
SHIMMER_THROUGHPUT,
+ SLOT_DURATION,
SLOTS_IN_EPOCH,
} from './constants';
import { CongestionType, NetworkType, UserType } from './enums';
@@ -51,7 +52,7 @@ export function getNetworkCongestion(
const generation = getNetworkGenerationPerSlot(network);
const throughput = getNetworkThroughput(network);
- return (supply * generation) / (10 * throughput);
+ return (supply * generation) / (SLOT_DURATION * throughput);
} else {
if (network == NetworkType.IOTA) {
return IOTA_CONGESTION[congestionType];