/** * Decimal money arithmetic. * * Wallet balances arrive as decimal strings ("47.76", and the account grammar also * permits exponent forms such as "0E-16"). Every balance-drop sum in this plugin is * therefore accumulated in **scaled integers**, because adding floats would drift: * `47.76 - 47.70` is `0.06000000000000227`, and a day of such deltas would visibly * corrupt the spend totals the correction factor is learnt from. * * Only the price table and the token counts are floating point, because they are * estimates by nature. * * @module dsh-balance/money */ /** Micro-units per currency unit: enough for any decimal the platform reports. */ export declare const MONEY_SCALE = 1000000; /** * Parse a decimal amount into scaled integer units. * * @param value - the decimal string, as reported by the platform. * @returns the amount in {@link MONEY_SCALE} units, or null when it is not a finite * decimal within the supported magnitude. */ export declare function parseMoneyUnits(value: unknown): number | null; /** * Convert scaled integer units back to a currency amount. * @param units - scaled units. * @returns the amount as a float, for display and estimator math. */ export declare function moneyUnitsToAmount(units: number): number; /** * Convert a currency amount to scaled integer units. * @param amount - the amount. * @returns the nearest scaled unit. */ export declare function amountToMoneyUnits(amount: number): number; /** * Render a currency amount with a fixed number of decimals. * @param amount - the amount. * @param digits - decimal places; defaults to 2, matching the platform. * @returns the formatted decimal string. */ export declare function formatMoney(amount: number, digits?: number): string;