---
title: parseUsdc
description: Parse a decimal string into 6-decimal USDC (UsdcRaw) for quotes and prepare calls.
---

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

SV3 amounts are branded bigint values. USDC is 6 decimals (`UsdcRaw`). AVM is 18 decimals (`AvmAtoms`). Prices are 18-decimal WAD (`Wad`). Never pass a JavaScript number into math.

`parseUsdc('1')` equals 1 USDC in raw units (`asUsdcRaw(1000000n)`).

## Import

```ts
import { parseUsdc, parseAvm, parsePrice } from "@repo/contract-client";
import { asUsdcRaw, asAvmAtoms, asWad } from "@repo/contract-client/types";
```

`sv3.units.parseUsdc` is the same function.

## Usage

```ts
import { parseUsdc, parseAvm } from "@repo/contract-client";
import { quoteBuyExactReserveIn } from "@repo/contract-client/math";

const quote = quoteBuyExactReserveIn(snapshot, parseUsdc("1.5"));
const sell = quoteSellExactAvmIn(snapshot, parseAvm("100"));
```

Already in atoms:

```ts
import { asUsdcRaw, asAvmAtoms, asWad } from "@repo/contract-client/types";

asUsdcRaw(1_500_000n); // 1.5 USDC
asAvmAtoms(10n ** 18n); // 1 AVM
asWad(10n ** 18n); // 1.0 as WAD
```

Format for UI:

```ts
import { formatTokenAmount, formatPrice } from "@repo/contract-client";

formatTokenAmount(1_500_000n, 6); // '1.5'
formatPrice(snapshot.spotPriceWad); // spot as a decimal string
```

## Return Value

`parseUsdc` → `UsdcRaw`  
`parseAvm` → `AvmAtoms`  
`parsePrice` → `Wad`  
`asUsdcRaw` / `asAvmAtoms` / `asWad` → the same branded bigint you passed in

## Parameters

### value (`parseUsdc` / `parseAvm` / `parsePrice`)

- **Type:** `string`

Decimal string. Too many fractional digits throws `InvalidAmountError`. Negative values throw.

```ts
parseUsdc("10");
parseUsdc("0.000001"); // 1 raw unit
parseAvm("1.5");
parsePrice("0.0004555");
```

### n (`asUsdcRaw` / `asAvmAtoms` / `asWad`)

- **Type:** `bigint`

Already-scaled integer. These helpers only brand the value.

```ts
asUsdcRaw(1_000_000n);
```

## Error

`InvalidAmountError` if the string is not a decimal, has too many fractional digits, or is negative.

## Tips

- `1e6` in JavaScript is a `number`. Use `1_000_000n` or `parseUsdc('1')`.
- Slippage helpers `applyMinSlippage` / `applyMaxSlippage` also live on `sv3.units`.
- 6dp ↔ 18dp conversion without branding is [rawToWad](/developers/math/raw-to-wad) / [wadToRaw](/developers/math/wad-to-raw).
