first day of vibe coding
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
export function formatPrice(n: number): string {
|
||||
return '$' + n.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
}
|
||||
|
||||
export function formatPct(n: number): string {
|
||||
const sign = n >= 0 ? '+' : ''
|
||||
return `${sign}${n.toFixed(2)}%`
|
||||
}
|
||||
|
||||
export function formatHold(seconds: number): string {
|
||||
if (seconds < 60) return `${seconds}s`
|
||||
const h = Math.floor(seconds / 3600)
|
||||
const m = Math.floor((seconds % 3600) / 60)
|
||||
if (h === 0) return `${m}m`
|
||||
if (m === 0) return `${h}h`
|
||||
return `${h}h ${m}m`
|
||||
}
|
||||
|
||||
export function shortenAddress(addr: string): string {
|
||||
if (addr.length < 10) return addr
|
||||
return `${addr.slice(0, 6)}...${addr.slice(-4)}`
|
||||
}
|
||||
|
||||
export function sentimentColor(s: string): string {
|
||||
switch (s) {
|
||||
case 'bullish':
|
||||
return '#4ade80'
|
||||
case 'bearish':
|
||||
return '#ef4444'
|
||||
default:
|
||||
return '#555555'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user