import { PaymentCurrencyId } from './formatCurrencyValue'; /** What a project is denominated in. */ export type ProjectCurrency = 'EUR' | 'USD' | 'BTC'; /** A project's own token (AQF, BMN2) with its own number of decimals. */ export type TokenUnit = { symbol: string; decimals: number; }; /** Every amount says which of the three kinds it is. */ export type AmountUnit = { project: ProjectCurrency; } | { payment: PaymentCurrencyId; } | { token: TokenUnit; }; export type UnitInfo = { kind: 'project' | 'payment' | 'token'; /** USD, BTC, USDC, AQF */ code: string; /** $, €, ₿ — only project currencies have one. */ symbol?: string; decimals: number; /** Tokens are never shortened to K/M/Bn. */ compactable: boolean; /** False for an unknown project currency or payment id; those get 2 decimals. */ matched: boolean; }; export type CodeCase = 'upper' | 'original'; /** 'round' (default) is half away from zero. Investing or paying: floor what is received, ceil what is paid. */ export type Rounding = 'round' | 'floor' | 'ceil'; export type FormatNumberOptions = { /** Default 2. */ decimals?: number; /** Round to 2 decimals, then K/M/Bn: 1,865.76 → 1.87K, 999,996 → 1.00M. */ compact?: boolean; rounding?: Rounding; /** Show '+' on positive values. */ signed?: boolean; /** Shown for null, undefined, '' and anything that isn't a number. Default '-'. */ fallback?: string; /** Thousands separators. Default true. */ grouping?: boolean; }; export type FormatAmountOptions = Omit & { /** Overrides the unit's decimals, for prices and fees that need more precision. */ decimals?: number; /** Project currencies only: 'symbol' (default) $12,500.56, 'code' USD 12,500.56. Others always show their code. */ display?: 'symbol' | 'code'; /** 'upper' (default) aqf → AQF, keeping XAUt; 'original' keeps the code as given. */ codeCase?: CodeCase; }; export type AmountParts = { /** Same as formatAmount. */ text: string; /** The number only, with its sign: -12,500.56 */ value: string; code: string; symbol?: string; }; export declare const isProjectCurrency: (value: unknown) => value is ProjectCurrency; export declare const isPaymentCurrency: (value: unknown) => value is PaymentCurrencyId; /** `project.tokenCurrency` → unit. Empty falls back to USD. */ export declare const projectUnit: (tokenCurrency: string | null | undefined) => AmountUnit; /** `investment.currencyType` / `sale.currencies[i]` → unit. */ export declare const paymentUnit: (currencyType: string | null | undefined) => AmountUnit; /** Missing decimals fall back to 2. */ export declare const tokenUnit: (symbol: string | null | undefined, decimals: number | null | undefined) => AmountUnit; /** The one place that decides token decimals: `tokenRoundingDecimals`, else `tokenDecimals`. */ export declare const projectTokenUnit: (project: { tokenSymbol?: string | null; tokenDecimals?: number | null; tokenRoundingDecimals?: number | null; }) => AmountUnit; /** Code, symbol and decimals of a unit, for components that lay out the number and the code themselves. */ export declare const getUnitInfo: (unit: AmountUnit, codeCase?: CodeCase) => UnitInfo; /** Numbers and numeric strings, commas ignored: '12,500.5' → 12500.5. Anything else → null. */ export declare const parseAmount: (value: unknown) => number | null; /** Rounds without float noise: 1.005 → 1.01, and 0.3 / 0.1 floored is 3, not 2. */ export declare const roundTo: (value: number, decimals: number, rounding?: Rounding) => number; /** formatAmount, with the number and the code also returned separately. */ export declare const formatAmountParts: (value: unknown, unit: AmountUnit, options?: FormatAmountOptions) => AmountParts; /** * The formatter for money and token amounts. * * formatAmount(12500.555, { project: 'USD' }) // $12,500.56 * formatAmount(12500.555, { project: 'USD' }, { display: 'code' }) // USD 12,500.56 * formatAmount(1865.76, { project: 'EUR' }, { compact: true }) // €1.87K * formatAmount(0.123456785, { payment: 'btc-fb' }) // BTC 0.12345679 * formatAmount(1250, tokenUnit('aqf', 4)) // AQF 1,250.0000 */ export declare const formatAmount: (value: unknown, unit: AmountUnit, options?: FormatAmountOptions) => string; /** A number without a unit: 12,500.56 · 1.87K · +4.20 */ export declare const formatNumber: (value: unknown, options?: FormatNumberOptions) => string; /** 12.3456 → 12.35% */ export declare const formatPercent: (value: unknown, options?: FormatNumberOptions) => string; /** * '12500.56' — no grouping, no code. For input values, API payloads, QR/payment URIs and components that group * the number themselves (PaymentDisplay). Show and send the same result so the two never differ. */ export declare const toFixedAmount: (value: unknown, unit: AmountUnit | number, rounding?: Rounding) => string | null; /** * Keeps digits and one decimal point, cuts (never rounds) the fraction to `maxDecimals`, and keeps a trailing '.' * so typing can continue. A single comma not followed by exactly 3 digits is a decimal comma: '12,5' → '12.5'. * '1,000.50' → '1000.50' · '.5' → '0.5' · '007' → '7' */ export declare const sanitizeAmountInput: (input: string | null | undefined, maxDecimals: number) => string; /** Groups a sanitized input while typing, keeping the fraction as typed: '12345.' → '12,345.' */ export declare const formatAmountInput: (raw: string | null | undefined) => string;