$0.00
; + } + + if (value >= 0.01 || firstNonZeroIndex < 2) { + return${value.toFixed(5)}
; + } + + const leadingZerosCount = firstNonZeroIndex; + const significantDigits = decimals.slice( + firstNonZeroIndex, + firstNonZeroIndex + 4 + ); + + return ( ++ $0.0{leadingZerosCount} + {significantDigits} +
+ ); +} diff --git a/src/apps/gas-tank/components/Price/TokenPriceChange.tsx b/src/apps/gas-tank/components/Price/TokenPriceChange.tsx new file mode 100644 index 00000000..a9b05b4e --- /dev/null +++ b/src/apps/gas-tank/components/Price/TokenPriceChange.tsx @@ -0,0 +1,56 @@ +export interface TokenPriceChangeProps { + value: number; +} + +export default function TokenPriceChange( + props: TokenPriceChangeProps +): JSX.Element { + const { value } = props; + const green = ( + + ); + + const red = ( + + ); + + return ( +{value < 0 ? (value * -1).toFixed(2) : value.toFixed(2)}%
+Loading your portfolio...
+⚠️ Failed to load portfolio
++ Unable to fetch your wallet data. Please try again later. +
+🔍 No portfolio data
++ Connect your wallet to see your holdings +
++ {searchText && searchText.trim() + ? '🔍 No matching tokens found' + : '💰 Portfolio is empty'} +
++ {searchText && searchText.trim() + ? `No tokens match '${searchText}' in your portfolio` + : // eslint-disable-next-line quotes + "You don't have any tokens in your portfolio yet"} +
++ {token.symbol} +
++ $ + {token.price + ? formatExponentialSmallNumber( + limitDigitsNumber(token.price) + ) + : '0.00'} +
++ ${Math.floor(balanceUSD * 100) / 100} +
++ {Math.floor((token.balance || 0) * 100000) / 100000} +
+= 0 ? 'text-[#4ADE80]' : 'text-[#F87171]' + }`}> + ${(Math.abs(balanceUSD * (token.price_change_24h || 0) / 100)).toFixed(2)} +
+= 0 ? 'text-[#4ADE80]' : 'text-[#F87171]' + }`}> + {(token.price_change_24h || 0).toFixed(2)}% +
++ 💰My Holdings +
+| handleSort('symbol')} + > + Token/Price {getSortIcon('symbol')} + | +handleSort('balance')} + > + Balance {getSortIcon('balance')} + | +handleSort('pnl')} + > + Unrealized PnL/% {getSortIcon('pnl')} + | +
|---|
+ Token/Price +
++ Balance +
++ Search by token or paste address... +
+