1
1
import React from "react" ;
2
2
import styled from "styled-components" ;
3
- import { formatUnits , formatEther } from "viem" ;
4
3
import { useParams } from "react-router-dom" ;
5
4
import { useCourtDetails , CourtDetailsQuery } from "queries/useCourtDetails" ;
6
- import { KLEROS_CONTRACT_ADDRESS , WETH_CONTRACT_ADDRESS } from "src/consts/index" ;
5
+ import { useCoinPrice } from "hooks/useCoinPrice" ;
6
+ import { KLEROS_CONTRACT_ADDRESS , WETH_CONTRACT_ADDRESS } from "consts/index" ;
7
+ import { formatETH , formatPNK , formatUnitsWei , formatUSD , isUndefined } from "utils/index" ;
7
8
import StatDisplay , { IStatDisplay } from "components/StatDisplay" ;
8
9
import BalanceIcon from "svgs/icons/law-balance.svg" ;
9
10
import MinStake from "svgs/icons/min-stake.svg" ;
10
- import { commify } from "utils/commify" ;
11
11
import VoteStake from "svgs/icons/vote-stake.svg" ;
12
12
import PNKIcon from "svgs/icons/pnk.svg" ;
13
13
import PNKRedistributedIcon from "svgs/icons/redistributed-pnk.svg" ;
14
14
import EthereumIcon from "svgs/icons/ethereum.svg" ;
15
- import { useCoinPrice } from "hooks/useCoinPrice" ;
16
- import { isUndefined } from "utils/index" ;
17
15
18
16
const StyledCard = styled . div `
19
17
width: auto;
@@ -36,18 +34,16 @@ const stats: IStat[] = [
36
34
{
37
35
title : "Min Stake" ,
38
36
coinId : 0 ,
39
- getText : ( data ) => commify ( formatUnits ( data ?. minStake , 18 ) ) ,
40
- getSubtext : ( data , coinPrice ) =>
41
- ( parseInt ( formatUnits ( data ?. minStake , 18 ) ) * ( coinPrice ?? 0 ) ) . toFixed ( 2 ) . toString ( ) + "$" ,
37
+ getText : ( data ) => formatPNK ( data ?. minStake ) ,
38
+ getSubtext : ( data , coinPrice ) => formatUSD ( Number ( formatUnitsWei ( data ?. minStake ) ) * ( coinPrice ?? 0 ) ) ,
42
39
color : "purple" ,
43
40
icon : MinStake ,
44
41
} ,
45
42
{
46
43
title : "Vote Stake" ,
47
44
coinId : 0 ,
48
- getText : ( data ) => commify ( formatUnits ( data ?. minStake , 18 ) ) ,
49
- getSubtext : ( data , coinPrice ) =>
50
- ( parseInt ( formatUnits ( data ?. minStake , 18 ) ) * ( coinPrice ?? 0 ) ) . toFixed ( 2 ) . toString ( ) + "$" ,
45
+ getText : ( data ) => formatPNK ( data ?. minStake ) ,
46
+ getSubtext : ( data , coinPrice ) => formatUSD ( Number ( formatUnitsWei ( data ?. minStake ) ) * ( coinPrice ?? 0 ) ) ,
51
47
color : "purple" ,
52
48
icon : VoteStake ,
53
49
} ,
@@ -61,9 +57,8 @@ const stats: IStat[] = [
61
57
{
62
58
title : "PNK Staked" ,
63
59
coinId : 0 ,
64
- getText : ( data ) => commify ( Number ( formatUnits ( data ?. stake , 18 ) ) . toFixed ( 0 ) ) ,
65
- getSubtext : ( data , coinPrice ) =>
66
- ( parseInt ( formatUnits ( data ?. stake , 18 ) ) * ( coinPrice ?? 0 ) ) . toFixed ( 2 ) . toString ( ) + "$" ,
60
+ getText : ( data ) => formatPNK ( data ?. stake ) ,
61
+ getSubtext : ( data , coinPrice ) => formatUSD ( Number ( formatUnitsWei ( data ?. stake ) ) * ( coinPrice ?? 0 ) ) ,
67
62
color : "purple" ,
68
63
icon : PNKIcon ,
69
64
} ,
@@ -84,18 +79,16 @@ const stats: IStat[] = [
84
79
{
85
80
title : "ETH paid to Jurors" ,
86
81
coinId : 1 ,
87
- getText : ( data ) => commify ( Number ( formatEther ( BigInt ( data ?. paidETH ) ) ) . toFixed ( 4 ) ) ,
88
- getSubtext : ( data , coinPrice ) =>
89
- ( Number ( formatUnits ( data ?. paidETH , 18 ) ) * ( coinPrice ?? 0 ) ) . toFixed ( 2 ) . toString ( ) + "$" ,
82
+ getText : ( data ) => formatETH ( data ?. paidETH ) ,
83
+ getSubtext : ( data , coinPrice ) => formatUSD ( Number ( formatUnitsWei ( data ?. paidETH ) ) * ( coinPrice ?? 0 ) ) ,
90
84
color : "blue" ,
91
85
icon : EthereumIcon ,
92
86
} ,
93
87
{
94
88
title : "PNK redistributed" ,
95
89
coinId : 0 ,
96
- getText : ( data ) => commify ( Number ( formatUnits ( data ?. paidPNK , 18 ) ) . toFixed ( 0 ) ) ,
97
- getSubtext : ( data , coinPrice ) =>
98
- ( parseInt ( formatUnits ( data ?. paidPNK , 18 ) ) * ( coinPrice ?? 0 ) ) . toFixed ( 2 ) . toString ( ) + "$" ,
90
+ getText : ( data ) => formatPNK ( data ?. paidPNK , 18 ) ,
91
+ getSubtext : ( data , coinPrice ) => formatUSD ( Number ( formatUnitsWei ( data ?. paidPNK ) ) * ( coinPrice ?? 0 ) ) ,
99
92
color : "purple" ,
100
93
icon : PNKRedistributedIcon ,
101
94
} ,
0 commit comments