---
title: minGrossForNet
description: Smallest gross USDC such that net after a fee rate is at least the target.
---

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

Inverse of `net = gross − ceil(gross × rate / 1e8)`. Used by exact-output buys to size the wallet's USDC cap so the curve still receives `costRaw` after the 1.25% buy fee.

Rounds **up** so the net cannot fall short.

## Import

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

## Usage

```ts
import { parseUsdc } from "@repo/contract-client";
import { asMicroBps } from "@repo/contract-client/types";
import { minGrossForNet } from "@repo/contract-client/math";

const gross = minGrossForNet(parseUsdc("10"), asMicroBps(1_250_000n));
```

## Return Value

`UsdcRaw` — fee-inclusive gross. `0n` in, `0n` out.

## Parameters

### net

- **Type:** `UsdcRaw`

Desired amount after the fee (curve cost, or user proceeds).

```ts
minGrossForNet(curveCost, asMicroBps(1_250_000n));
```

### rate

- **Type:** `MicroBps`

Same units as [splitFee](/developers/math/split-fee). Must be `< 100_000_000`.

```ts
minGrossForNet(parseUsdc("10"), asMicroBps(1_250_000n));
```

## Error

`ProtocolRevertError` `ZeroAmount` if the rate is 100% (fee would consume all).
