---
title: wadToRaw
description: Convert 18-decimal WAD to 6-decimal USDC raw units.
---

> **For AI agents:** the complete documentation index is at [llms.txt](/llms.txt). Append `.md` to any page URL for its markdown version.

Divides by `10^12`. Pass `ceil: true` when the result is a liability the market must still cover.

## Import

```ts
import { wadToRaw } from "@repo/contract-client/math";
```

## Usage

```ts
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.

```ts
wadToRaw(10n ** 18n); // 1_000_000n
```

### ceil (optional)

- **Type:** `boolean`
- **Default:** `false`

```ts
wadToRaw(amountWad, true);
```

## Error

`InvalidAmountError` if `wad < 0`.
