@somnia-chain/markets-sdk


@somnia-chain/markets-sdk / index / ceilRawAmount

Function: ceilRawAmount()

ceilRawAmount(raw, decimals, quantum): bigint

Defined in: packages/sdk/src/units.ts:417

Ceil a raw on-chain amount UP to a whole multiple of quantum (a human decimal string — the market's lot size for base amounts, or a display precision like "0.01" for quote). The mirror of floorRawBalance, for sizing a minimum: a minimum rounded DOWN falls below what the pool requires and the order is rejected as under the minimum — the exact mirror of the max-order revert the floors prevent. An amount below one quantum rises to one whole quantum rather than collapsing to 0 the way the floor does.

Returns a bigint, unlike the floors, which return number. A minimum is checked against the lot boundary exactly, and no double can hold one: the nearest double to 0.1 at 18 decimals sits tens of wei off, which puts it below the minimum itself. Convert at the edge if you need a number — Number(formatUnits(result, decimals)).

Parameters

raw

bigint

decimals

number

quantum

string

Returns

bigint