Formatting
Import
import { formatPrice, formatSize } from "@nktkas/hyperliquid/utils";formatPrice
import { formatPrice } from "@nktkas/hyperliquid/utils";
// Perpetual (default)
formatPrice("1234.5", 0); // "1234.5" ✓
formatPrice("1234.56", 0); // "1234.5" (truncated to 5 sig figs)
formatPrice("0.001234", 0); // "0.001234" ✓
formatPrice("0.0012345", 0); // "0.001234" (truncated to 5 sig figs)
// Spot market
formatPrice("0.0001234", 0, "spot"); // "0.0001234" ✓
formatPrice("0.00012345", 2, "spot"); // "0.000123" (max 6 decimals for szDecimals=2)
// Integer prices always allowed
formatPrice("123456", 0); // "123456" ✓Parameters
price (required)
szDecimals (required)
type (optional)
Throws
formatSize
Parameters
size (required)
szDecimals (required)
Throws
Example: Placing an Order
Last updated