frontend-monorepo-267 Reduce total staked to 2 decimal precision (#282)
* frontend-monorepo-267 Reduce total staked to 2 decimal precision * Tweak to formatNumber to allow fixed decimal specificity * Setting default value for the 'defaultPrecision' argument in the function signature of 'addDecimal'
This commit is contained in:
parent
ce5d7bc15b
commit
3354fbb0c2
@ -60,7 +60,7 @@ export const statsFields: { [key in keyof IStats]: IStatFields[] } = {
|
||||
{
|
||||
title: t('Total staked'),
|
||||
formatter: (total: string) => {
|
||||
return formatNumber(total, 18);
|
||||
return formatNumber(total, 18, 2);
|
||||
},
|
||||
description: t('Sum of VEGA associated with a Vega key'),
|
||||
},
|
||||
|
@ -2,11 +2,15 @@ import { BigNumber } from 'bignumber.js';
|
||||
import memoize from 'lodash/memoize';
|
||||
import { getUserLocale } from './utils';
|
||||
|
||||
export function addDecimal(value: string, decimals: number): string {
|
||||
export function addDecimal(
|
||||
value: string,
|
||||
decimals: number,
|
||||
decimalPrecision = decimals
|
||||
): string {
|
||||
if (!decimals) return value;
|
||||
return new BigNumber(value || 0)
|
||||
.dividedBy(Math.pow(10, decimals))
|
||||
.toFixed(decimals);
|
||||
.toFixed(decimalPrecision);
|
||||
}
|
||||
|
||||
export function removeDecimal(value: string, decimals: number): string {
|
||||
@ -16,9 +20,10 @@ export function removeDecimal(value: string, decimals: number): string {
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
|
||||
export const getNumberFormat = memoize(
|
||||
(minimumFractionDigits: number) =>
|
||||
(digits: number) =>
|
||||
new Intl.NumberFormat(getUserLocale(), {
|
||||
minimumFractionDigits,
|
||||
minimumFractionDigits: digits,
|
||||
maximumFractionDigits: digits,
|
||||
})
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user