Skip to content

Commit

Permalink
fix rounding of numbers like $550k to $1m
Browse files Browse the repository at this point in the history
  • Loading branch information
benwolski committed Jan 8, 2025
1 parent 6ff6c40 commit 0455ad7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/ambient-utils/dataLayer/functions/getFormattedNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function getFormattedNumber({
? formatAbbrev(value, false, 1)
: value < 1000000
? formatAbbrev(value, false, 0)
: formatAbbrev(value, false, 2);
: formatAbbrev(value, false, 1);
prefix = '$';
} else if (isUSD) {
// only display two decimal points for USD values
Expand Down Expand Up @@ -179,7 +179,9 @@ const formatSubscript = (value: number, precision = 3) => {
const formatAbbrev = (value: number, isTvl?: boolean, mantissa = 2) => {
return numbro(value).format({
average: true,
...(isTvl && { roundingFunction: (num: number) => Math.floor(num) }),
...(isTvl
? { roundingFunction: (num: number) => Math.floor(num) }
: { roundingFunction: (num: number) => num }),
mantissa: mantissa,
abbreviations: {
thousand: 'k',
Expand Down
6 changes: 3 additions & 3 deletions src/components/Futa/TickerComponent/tickerDisplayElements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import {
MARKET_CAP_MULTIPLIER_BIG_INT,
maxMarketCapWeiValues,
} from '../../../pages/platformFuta/mockAuctionData';
import useOnClickOutside from '../../../utils/hooks/useOnClickOutside';
import { CurrencySelector } from '../../Form/CurrencySelector';
import ProgressBar from '../ProgressBar/ProgressBar';
import TooltipLabel from '../TooltipLabel/TooltipLabel';
import useOnClickOutside from '../../../utils/hooks/useOnClickOutside';

// Props interface
export interface PropsIF {
Expand Down Expand Up @@ -481,7 +481,7 @@ export const tickerDisplayElements = (props: PropsIF) => {
? fdvUsdValue
? getFormattedNumber({
value: fdvUsdValue,
isUSD: true,
isTickerDisplay: true,
})
: '$0.00'
: '...';
Expand Down Expand Up @@ -551,7 +551,7 @@ export const tickerDisplayElements = (props: PropsIF) => {
? fdvUsdValue
? getFormattedNumber({
value: fdvUsdValue,
isUSD: true,
isTickerDisplay: true,
})
: '$0.00'
: undefined;
Expand Down

0 comments on commit 0455ad7

Please sign in to comment.