Amount Conversion
toSmallestUnits / to_smallest_units
Convert a display amount to the smallest unit (e.g., BTC to satoshis).
toDisplayUnits / to_display_units
Convert from smallest units back to display units.
toRawAmount / to_raw_amount
Equivalent to toSmallestUnits. Convert display to raw.
toDisplayAmount / to_display_amount
Equivalent to toDisplayUnits. Convert raw to display.
PrecisionHandler
ThePrecisionHandler manages amount conversions for multiple assets, using their metadata to look up precision automatically.
Creating a PrecisionHandler
Methods
toRawAmount / to_raw_amount
Convert display amount to raw, using the asset’s precision.
toDisplayAmount / to_display_amount
Convert raw amount to display.
getAssetPrecision / get_asset_precision
Get the precision for a specific asset.
formatDisplayAmount / format_display_amount
Format a display amount with the correct number of decimal places.
validateOrderSize / validate_order_size
Validate an order amount against min/max limits.
getOrderSizeLimits / get_order_size_limits
Get the min/max order size for an asset.
AssetPairMapper (TypeScript)
TheAssetPairMapper helps look up assets and trading pairs from the listPairs response. This utility is available in the TypeScript SDK.