Format dollar amount: 3 significant digits with k/m suffix on mobile, full on desktop
(v: number)
| 29 | |
| 30 | /** Format dollar amount: 3 significant digits with k/m suffix on mobile, full on desktop */ |
| 31 | function fmtBal(v: number): string { |
| 32 | if (window.innerWidth > 768) return `$${v.toFixed(2)}`; |
| 33 | const abs = Math.abs(v); |
| 34 | if (abs >= 1e6) return `$${+(v / 1e6).toPrecision(3)}m`; |
| 35 | if (abs >= 1e3) return `$${+(v / 1e3).toPrecision(3)}k`; |
| 36 | return `$${Math.round(v)}`; |
| 37 | } |
| 38 | |
| 39 | interface WalletButtonProps { |
| 40 | onRefresh?: () => void; |