@@ -27,7 +27,7 @@ import { useHomePageExtraStats } from "queries/useHomePageExtraStats";
2727import { calculateSubtextRender } from "utils/calculateSubtextRender" ;
2828import { formatETH , formatPNK , formatUnitsWei , formatUSD } from "utils/format" ;
2929import { isUndefined } from "utils/index" ;
30- import { commify } from "utils/commify " ;
30+ import { beautifyStatNumber } from "utils/beautifyStatNumber " ;
3131
3232import StatDisplay , { IStatDisplay } from "components/StatDisplay" ;
3333import { StyledSkeleton } from "components/StyledSkeleton" ;
@@ -109,23 +109,6 @@ const StyledDropdownSelect = styled(DropdownSelect)`
109109 }
110110` ;
111111
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-
129112interface IStat {
130113 title : string ;
131114 coinId ?: number ;
@@ -255,7 +238,7 @@ const Stats = () => {
255238 const ethPriceUSD = pricesData ? pricesData [ CoinIds . ETH ] ?. price : undefined ;
256239 if ( ! ethPriceUSD || ! treeExpectedRewardPerPnk ) return "N/A" ;
257240 const pnkNeeded = treeExpectedRewardPerPnk * ethPriceUSD ;
258- return beautifyStatNumber ( pnkNeeded ) ;
241+ return beautifyStatNumber ( pnkNeeded , true ) ;
259242 } ,
260243 color : "purple" ,
261244 icon : PNKUSDIcon ,
@@ -270,7 +253,7 @@ const Stats = () => {
270253 const treeExpectedRewardPerPnk = data ?. treeExpectedRewardPerPnk ;
271254 if ( ! treeExpectedRewardPerPnk ) return "N/A" ;
272255 const pnkNeeded = treeExpectedRewardPerPnk ;
273- return beautifyStatNumber ( pnkNeeded ) ;
256+ return beautifyStatNumber ( pnkNeeded , true ) ;
274257 } ,
275258 color : "blue" ,
276259 icon : PNKETHIcon ,
@@ -283,7 +266,7 @@ const Stats = () => {
283266 ) ,
284267 getText : ( data ) => {
285268 const treeVotesPerPnk = data ?. treeVotesPerPnk ;
286- return beautifyStatNumber ( treeVotesPerPnk ) ;
269+ return beautifyStatNumber ( treeVotesPerPnk , true ) ;
287270 } ,
288271 color : "orange" ,
289272 icon : VotesPerPNKIcon ,
@@ -299,7 +282,7 @@ const Stats = () => {
299282 ) ,
300283 getText : ( data ) => {
301284 const treeDisputesPerPnk = data ?. treeDisputesPerPnk ;
302- return beautifyStatNumber ( treeDisputesPerPnk ) ;
285+ return beautifyStatNumber ( treeDisputesPerPnk , true ) ;
303286 } ,
304287 color : "orange" ,
305288 icon : BalanceWithPNKIcon ,
0 commit comments