wadToRaw
Convert 18-decimal WAD to 6-decimal USDC raw units.
Divides by 10^12. Pass ceil: true when the result is a liability the market must still cover.
Import
import { wadToRaw } from "@repo/contract-client/math";
Usage
import { wadToRaw } from "@repo/contract-client/math";
const down = wadToRaw(snapshot.spotPriceWad);
const up = wadToRaw(areaWad, true);
Return Value
bigint (USDC raw, 6 decimals).
Parameters
wad
- Type:
bigint
Non-negative 18-decimal value.
wadToRaw(10n ** 18n); // 1_000_000n
ceil (optional)
- Type:
boolean - Default:
false
wadToRaw(amountWad, true);
Error
InvalidAmountError if wad < 0.