@@ -27,7 +27,7 @@ import { useHomePageExtraStats } from "queries/useHomePageExtraStats";
27
27
import { calculateSubtextRender } from "utils/calculateSubtextRender" ;
28
28
import { formatETH , formatPNK , formatUnitsWei , formatUSD } from "utils/format" ;
29
29
import { isUndefined } from "utils/index" ;
30
- import { commify } from "utils/commify " ;
30
+ import { beautifyStatNumber } from "utils/beautifyStatNumber " ;
31
31
32
32
import StatDisplay , { IStatDisplay } from "components/StatDisplay" ;
33
33
import { StyledSkeleton } from "components/StyledSkeleton" ;
@@ -109,23 +109,6 @@ const StyledDropdownSelect = styled(DropdownSelect)`
109
109
}
110
110
` ;
111
111
112
- function beautifyStatNumber ( value : number ) : string {
113
- const absValue = Math . abs ( value ) ;
114
-
115
- if ( absValue >= 1e9 ) {
116
- return `${ commify ( ( value / 1e9 ) . toFixed ( 2 ) ) } B` ;
117
- } else if ( absValue >= 1e6 ) {
118
- return `${ commify ( ( value / 1e6 ) . toFixed ( 2 ) ) } M` ;
119
- } else if ( absValue >= 1e3 ) {
120
- return `${ commify ( ( value / 1e3 ) . toFixed ( 0 ) ) } K` ;
121
- } else if ( absValue < 1 && absValue !== 0 ) {
122
- const inverseValue = 1 / absValue ;
123
- return commify ( inverseValue . toFixed ( 0 ) ) ;
124
- }
125
-
126
- return commify ( value . toFixed ( 0 ) ) ;
127
- }
128
-
129
112
interface IStat {
130
113
title : string ;
131
114
coinId ?: number ;
@@ -255,7 +238,7 @@ const Stats = () => {
255
238
const ethPriceUSD = pricesData ? pricesData [ CoinIds . ETH ] ?. price : undefined ;
256
239
if ( ! ethPriceUSD || ! treeExpectedRewardPerPnk ) return "N/A" ;
257
240
const pnkNeeded = treeExpectedRewardPerPnk * ethPriceUSD ;
258
- return beautifyStatNumber ( pnkNeeded ) ;
241
+ return beautifyStatNumber ( pnkNeeded , true ) ;
259
242
} ,
260
243
color : "purple" ,
261
244
icon : PNKUSDIcon ,
@@ -270,7 +253,7 @@ const Stats = () => {
270
253
const treeExpectedRewardPerPnk = data ?. treeExpectedRewardPerPnk ;
271
254
if ( ! treeExpectedRewardPerPnk ) return "N/A" ;
272
255
const pnkNeeded = treeExpectedRewardPerPnk ;
273
- return beautifyStatNumber ( pnkNeeded ) ;
256
+ return beautifyStatNumber ( pnkNeeded , true ) ;
274
257
} ,
275
258
color : "blue" ,
276
259
icon : PNKETHIcon ,
@@ -283,7 +266,7 @@ const Stats = () => {
283
266
) ,
284
267
getText : ( data ) => {
285
268
const treeVotesPerPnk = data ?. treeVotesPerPnk ;
286
- return beautifyStatNumber ( treeVotesPerPnk ) ;
269
+ return beautifyStatNumber ( treeVotesPerPnk , true ) ;
287
270
} ,
288
271
color : "orange" ,
289
272
icon : VotesPerPNKIcon ,
@@ -299,7 +282,7 @@ const Stats = () => {
299
282
) ,
300
283
getText : ( data ) => {
301
284
const treeDisputesPerPnk = data ?. treeDisputesPerPnk ;
302
- return beautifyStatNumber ( treeDisputesPerPnk ) ;
285
+ return beautifyStatNumber ( treeDisputesPerPnk , true ) ;
303
286
} ,
304
287
color : "orange" ,
305
288
icon : BalanceWithPNKIcon ,
0 commit comments