UNPKG

shield-bridge-sdk

Version:
31 lines 1.32 kB
import type { AmountInput } from '../types.js'; /** * Convert a human-readable amount to base units (mutez / smallest token unit). * * Accepts number, string, or BigNumber as input. * * @param amount - Human-readable amount (e.g. 1.5 for 1.5 XTZ) * @param decimals - Number of decimals for the token (6 for XTZ/mutez) * @returns The amount in base units as a string (safe for the RPC) */ export declare function toBaseUnits(amount: AmountInput, decimals: number): string; /** * Convert a base-unit amount to human-readable form. * * Returns a string to prevent JavaScript floating-point precision loss * for large values (numbers only have ~15-17 significant digits). * * @param amount - Amount in base units (e.g. 1_500_000 mutez) * @param decimals - Number of decimals for the token (6 for XTZ) * @returns The human-readable amount as a string (lossless precision) */ export declare function fromBaseUnits(amount: AmountInput, decimals: number): string; /** * Validate that an amount is positive, finite, and not NaN. * * @param amount - The amount to validate * @param context - Description of the amount for error messages * @throws {Error} If amount is invalid */ export declare function validateAmount(amount: AmountInput, context?: string): void; //# sourceMappingURL=amount.d.ts.map