diff --git a/apps/wallet/src/components/TotalPnL.tsx b/apps/wallet/src/components/TotalPnL.tsx index 1e0d02a23..179485835 100644 --- a/apps/wallet/src/components/TotalPnL.tsx +++ b/apps/wallet/src/components/TotalPnL.tsx @@ -6,37 +6,51 @@ interface Props { value: number; percentage: number; isDarkTheme: boolean; + numDigit: number; } -const TotalPnL: FC = ({ value, percentage, isDarkTheme = false }) => { +const TotalPnL: FC = ({ + value, + percentage, + isDarkTheme = false, + numDigit = 2, +}) => { + if (numDigit <= 0) { + numDigit = 2; + } + const baseDigit = 10 ** numDigit; + value = Math.round(value * baseDigit) / baseDigit; + percentage = Math.round(percentage * baseDigit) / baseDigit; const isLost = value < 0; const isProfit = value > 0; - return ( - - - {isLost ? `≈ -$${-value}` : isProfit ? `≈ +$${value}` : null} - - - - {isLost ? `${percentage}%` : isProfit ? `+${percentage}%` : null} + if (percentage !== 0) { + return ( + + + {isLost ? `≈ -$${-value}` : isProfit ? `≈ +$${value}` : null} + + + {isLost ? `${percentage}%` : isProfit ? `+${percentage}%` : null} + + - - ); + ); + } }; export default TotalPnL; diff --git a/apps/wallet/src/features/Home/TokenValue.tsx b/apps/wallet/src/features/Home/TokenValue.tsx index 4a9b629f3..3338f5ead 100644 --- a/apps/wallet/src/features/Home/TokenValue.tsx +++ b/apps/wallet/src/features/Home/TokenValue.tsx @@ -35,9 +35,10 @@ const TokenValue: FC = ({ value }) => { diff --git a/apps/wallet/src/features/Widget/BuiltInNetwork/WalletCard/Balance.tsx b/apps/wallet/src/features/Widget/BuiltInNetwork/WalletCard/Balance.tsx index 3cb45ba46..5a15e55f6 100644 --- a/apps/wallet/src/features/Widget/BuiltInNetwork/WalletCard/Balance.tsx +++ b/apps/wallet/src/features/Widget/BuiltInNetwork/WalletCard/Balance.tsx @@ -36,9 +36,10 @@ export const WalletBalance: FC = ({