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.
Creating a Mapper
Methods
findByTicker
Find an asset by its ticker symbol.
findById
Find an asset by its asset ID.
getAllAssets
Get all assets.
canTrade / canTradeByTicker
Check if two assets can be traded.
getTradingPartners
Get all assets that can be traded with a given asset.
getActivePairs
Get all active trading pairs.
findPairByTickers
Find a specific pair by base and quote tickers.
SDK Info
getVersion / get_version
Get the SDK version string.
getSdkName / get_sdk_name
Get the SDK package name.
Next Steps
Examples
See amount conversion used in real swap examples
Types
Asset and TradingPair types that PrecisionHandler works with
Client Reference
Full method reference including convenience toRaw / toDisplay methods
Troubleshooting
Precision and conversion edge cases