Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@
},
"staking_page": {
"stake_ticker": "Stake {{ticker}}",
"total_staked_ticker_in_the_network": "Total Staked {{ticker}} in the network",
"total_ticker_in_the_network": "Total {{ticker}} in the network",
"total_staked_ticker_in_the_network": "Total Staked {{ticker}}",
"total_ticker_in_the_network": "{{ticker}} - Total vote-escrow",
"time": {
"one_week": "1 Week",
"one_month": "1 Month",
Expand Down
11 changes: 11 additions & 0 deletions src/common/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ const formatPercentage = (
return `${format(percentage)}%`;
};

const formatLargeNumber = (amount: number): string => {
const { format } = new Intl.NumberFormat(undefined, {
notation: 'compact',
maximumFractionDigits: 2,
minimumFractionDigits: 2
});

return format(amount);
};

function displayMonetaryAmount(amount: MonetaryAmount<CurrencyExt> | undefined, defaultValue = '0.00'): string {
if (amount === undefined) return defaultValue;

Expand Down Expand Up @@ -194,6 +204,7 @@ export {
displayMonetaryAmountInUSDFormat,
formatDateTime,
formatDateTimePrecise,
formatLargeNumber,
formatNumber,
formatPercentage,
formatUSD,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useTranslation } from 'react-i18next';

import { formatLargeNumber } from '@/common/utils/utils';
import {
TransactionDetails,
TransactionDetailsDd,
Expand Down Expand Up @@ -28,15 +29,15 @@ const StakingNetworkDetails = ({ data, ...props }: StakingNetworkDetailsProps):
{t('staking_page.total_staked_ticker_in_the_network', { ticker: GOVERNANCE_TOKEN.ticker })}
</TransactionDetailsDt>
<TransactionDetailsDd>
{data.totalStakedBalance.toHuman()} {GOVERNANCE_TOKEN.ticker}
{formatLargeNumber(data.totalStakedBalance.toBig().toNumber())} {GOVERNANCE_TOKEN.ticker}
</TransactionDetailsDd>
</TransactionDetailsGroup>
<TransactionDetailsGroup>
<TransactionDetailsDt>
{t('staking_page.total_ticker_in_the_network', { ticker: GOVERNANCE_TOKEN.ticker })}
{t('staking_page.total_ticker_in_the_network', { ticker: VOTE_GOVERNANCE_TOKEN.ticker })}
</TransactionDetailsDt>
<TransactionDetailsDd>
{data.totalVotingSupply.toHuman()} {VOTE_GOVERNANCE_TOKEN.ticker}
{formatLargeNumber(data.totalVotingSupply.toBig().toNumber())} {VOTE_GOVERNANCE_TOKEN.ticker}
</TransactionDetailsDd>
</TransactionDetailsGroup>
</TransactionDetails>
Expand Down