17.05.2026 funny

This commit is contained in:
2026-05-17 14:45:28 +03:00
parent 2d1c1654f9
commit 01d72f4885
6 changed files with 23 additions and 15 deletions

View File

@@ -0,0 +1,6 @@
export function truncateDecimals(value: string | number, maxDecimals = 8): string {
const s = typeof value === 'number' ? value.toString() : value
const dot = s.indexOf('.')
if (dot === -1) return s
return s.slice(0, dot + 1 + maxDecimals)
}

View File

@@ -1,4 +1,5 @@
import type { Token } from '../model/useSwapForm'
import { truncateDecimals } from '@shared/lib/utils/truncateDecimals'
import { TokenSelect } from './TokenSelect'
import styles from './SwapCard.module.css'
@@ -105,7 +106,7 @@ export function SwapCard({
<rect x="2" y="6" width="20" height="14" rx="3" />
<path d="M6 6V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v2" />
</svg>
{token.balance.toFixed(mode === 'from' ? 3 : 2)}
{truncateDecimals(token.balance, 8)}
{mode === 'from' && onSetPercent && (
<button className={styles.max} onClick={() => onSetPercent(100)}>МАКС</button>
)}

View File

@@ -1,6 +1,7 @@
import { useWalletBalance } from '@features/wallet'
import type { Chain } from '@features/wallet'
import { getCoinIcon } from '@shared/assets/coins'
import { truncateDecimals } from '@shared/lib/utils/truncateDecimals'
import { TOKENS, type Token } from './tokens'
const NATIVE_TICKER: Record<Chain, string> = {
@@ -53,7 +54,7 @@ export function useChainTokenRows(chain: Chain) {
color: nativeStatic?.color ?? DEFAULT_TOKEN_COLOR,
price: formatPrice(data.native.usdPrice),
change: 0,
bal: data.native.formatted,
bal: truncateDecimals(data.native.formatted),
usd: formatUsd(data.native.usdValue),
fav: false,
}
@@ -67,7 +68,7 @@ export function useChainTokenRows(chain: Chain) {
color: staticToken?.color ?? DEFAULT_TOKEN_COLOR,
price: formatPrice(amount.usdPrice),
change: 0,
bal: amount.formatted,
bal: truncateDecimals(amount.formatted),
usd: formatUsd(amount.usdValue),
fav: false,
}