Amount Conversion
parseRawAmount / parse_raw_amount
Convert a display amount to the raw (smallest) unit (e.g., BTC to satoshis).
toDisplayAmount / to_display_amount
Convert a raw (smallest-unit) amount back to a display amount.
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.
The TypeScript
getVersion() currently returns a hardcoded "0.1.0" rather than the installed package version. To read the real version, check package.json for the kaleido-sdk dependency.