Skip to content

Commit

Permalink
Merge branch 'mana-calculator' of https://github.com/iotaledger/iota-…
Browse files Browse the repository at this point in the history
…wiki into mana-calculator
  • Loading branch information
oliviasaa committed Oct 20, 2023
2 parents 5817c2d + eaa86c2 commit 05b8eef
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
41 changes: 20 additions & 21 deletions src/components/ManaCalculator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
ValidatorParameters,
} from './types';
import { Details } from '@docusaurus/theme-common/Details';
import { EPOCH } from './utils';
import { EPOCH, fromMicro, toMicro } from './utils';

function ValidatorCard({
validator,
Expand Down Expand Up @@ -56,17 +56,17 @@ function ValidatorCard({
<div className='col col--8'>Stake:</div>
<input
className='col col--4 align-right'
value={validator.lockedStake}
onChange={(e) => handleStakeChange(Number(e.target.value), id)}
value={fromMicro(validator.lockedStake)}
onChange={(e) => handleStakeChange(toMicro(Number(e.target.value)), id)}
></input>
</div>
<div className='row'>
<div className='col col--8'>Delegated:</div>
<input
className='col col--4 align-right'
value={validator.delegatedStake}
value={fromMicro(validator.delegatedStake)}
onChange={(e) =>
handleDelegatedStakeChange(Number(e.target.value), id)
handleDelegatedStakeChange(toMicro(Number(e.target.value)), id)
}
></input>
</div>
Expand Down Expand Up @@ -101,27 +101,27 @@ export default function ManaCalculator() {
finalEpoch: 100,
validators: [
{
lockedStake: 100,
delegatedStake: 0,
lockedStake: toMicro(100),
delegatedStake: toMicro(0),
performanceFactor: 1.0,
fixedCost: 0.0,
},
{
lockedStake: 100,
delegatedStake: 0,
lockedStake: toMicro(100),
delegatedStake: toMicro(0),
performanceFactor: 1.0,
fixedCost: 0.0,
},
{
lockedStake: 100,
delegatedStake: 0,
lockedStake: toMicro(100),
delegatedStake: toMicro(0),
performanceFactor: 1.0,
fixedCost: 0.0,
},
],
userType: UserType.DELEGATOR,
congestion: CongestionType.LOW,
stake: 100,
stake: toMicro(100),
delegator: {
validator: 0,
},
Expand Down Expand Up @@ -579,8 +579,8 @@ function DelegatorForm({
<div className='col col--6'>Amount you delegate:</div>
<input
className='align-right col col--6'
value={stake}
onChange={(e) => handleOwnStakeChange(Number(e.target.value))}
value={fromMicro(stake)}
onChange={(e) => handleOwnStakeChange(toMicro(Number(e.target.value)))}
></input>
</div>
</div>
Expand Down Expand Up @@ -618,11 +618,10 @@ function ValidatorForm({
<div className='table'>
<div className='row '>
<div className='col col--6'>Stake:</div>

<input
className='col col--6 align-right'
value={stake}
onChange={(e) => handleOwnStakeChange(Number(e.target.value))}
value={fromMicro(stake)}
onChange={(e) => handleOwnStakeChange(toMicro(Number(e.target.value)))}
></input>
</div>
<Details summary='Advanced Settings - Validator'>
Expand Down Expand Up @@ -701,12 +700,12 @@ function OutputForm({
return (
<div className='table'>
<div className='row '>
<div className='col col--6'> Mana generation per epoch</div>
<div className='col col--6 align-right'>{manaGeneratedPerEpoch}</div>
<div className='col col--6'>Mana generation (holding IOTA)</div>
<div className='col col--6 align-right'>{fromMicro(passiveRewards)}</div>
</div>
<div className='row '>
<div className='col col--6'>Additional rewards per epoch</div>
<div className='col col--6 align-right'>{passiveRewards}</div>
<div className='col col--6'>Mana rewards (delegation/validation)</div>
<div className='col col--6 align-right'>{fromMicro(manaGeneratedPerEpoch)}</div>
</div>

<div className='row '>
Expand Down
10 changes: 10 additions & 0 deletions src/components/ManaCalculator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,13 @@ export function targetReward(n: number): number {
}
return reward;
}

//returns The number of Mana/IOTA from micros
export function fromMicro(n: number): number {
return n / 1_000_000;
}

//returns The number of micro(Mana/IOTA).
export function toMicro(n: number): number {
return n * 1_000_000;
}

0 comments on commit 05b8eef

Please sign in to comment.