Skip to content

Commit

Permalink
feat: adjust decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
icfor committed Apr 16, 2024
1 parent 8f72780 commit fd88962
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ export const unbondingDays = isTestnet ? 3 : 21;
// Arbitrary value to avoid using a bigger fee than the actual reward
export const minClaimableXion = 0.00001;

export const minDisplayedXion = 0.000001;
export const minDisplayedXionDecs = 6;
export const minDisplayedXion = 10 ** -minDisplayedXionDecs;
10 changes: 4 additions & 6 deletions src/features/staking/lib/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Coin } from "@cosmjs/stargate";
import BigNumber from "bignumber.js";

import { xionToUSD } from "@/constants";
import { minDisplayedXion, minDisplayedXionDecs, xionToUSD } from "@/constants";

import { getEmptyXionCoin, normaliseCoin } from "./core/coins";

Expand All @@ -13,10 +13,8 @@ export const formatCoin = (coin: Coin, compact?: boolean) => {
return `${amount.toFormat()} ${resolved.denom}`;
}

const minDisplayed = 0.0001;

if (amount.lt(minDisplayed)) {
return `<${minDisplayed} ${resolved.denom}`;
if (amount.lt(minDisplayedXion)) {
return `<${minDisplayedXion} ${resolved.denom}`;
}

if (compact) {
Expand All @@ -27,7 +25,7 @@ export const formatCoin = (coin: Coin, compact?: boolean) => {
return `${formatter.format(amount.toNumber())} ${resolved.denom}`;
}

return `${amount.toFormat(4)} ${resolved.denom}`;
return `${amount.toFormat(minDisplayedXionDecs)} ${resolved.denom}`;
};

export const formatVotingPowerPerc = (perc: null | number) => {
Expand Down

0 comments on commit fd88962

Please sign in to comment.