@somnia-chain/markets-sdk / index / fromHuman
Function: fromHuman()
fromHuman(
human,decimals?):bigint
Defined in: packages/sdk/src/units.ts:46
Human amount (number or decimal string) → raw bigint at decimals, for the
write API (placeOrder price/quantity, mintSet amount, …). Accepts a string
to avoid float rounding (fromHuman("0.1")), or a number for convenience.
Gotchas
A number carrying more fraction digits than decimals is ROUNDED to scale
(half-away-from-zero, via toFixed): fromHuman(0.1234567, 6) is
123457n. That is a deliberate, long-standing choice — the alternative
(throwing) would reject ordinary computed values like a mid price. Pass a
string when you need the exact value preserved or rejected instead.
Parameters
human
string | number
decimals?
number = Store.DECIMALS
Returns
bigint