---
title: quoteBuyExactAvmOut
description: Quote the USDC that must be paid to mint an exact AVM amount.
---

> **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 exact-input buy. Sizes gross USDC (including the 1.25% buy fee) so the curve mints exactly `amount` AVM.

Use this when the user typed a token amount. On-chain that is `buyWithExactAvmTokensOut`. [prepareBuyForReserveBudget](/developers/prepare-buy-for-reserve-budget) also uses this selector, but sizes AVM from a USDC budget.

## Import

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

## Usage

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

const quote = quoteBuyExactAvmOut(snapshot, parseAvm("1000"));

quote.avmOut; // equals the amount you asked for
quote.grossReserveInRaw; // USDC the wallet must have, including fee
quote.curveReserveInRaw; // USDC that actually hits the curve
quote.priceImpact.totalPriceImpactWad;
```

## Return Value

`BuyExactOutQuote`

| Field                                                      | Meaning                       |
| ---------------------------------------------------------- | ----------------------------- |
| `kind`                                                     | `'buyExactAvmOut'`            |
| `avmOut`                                                   | Exact tokens minted           |
| `grossReserveInRaw`                                        | Gross USDC in (fee-inclusive) |
| `curveReserveInRaw`                                        | Gross minus buy fee           |
| `fees` / `priceImpact` / `nextSpotPriceWad` / `provenance` | Same shape as exact-input     |

Gross is computed with [minGrossForNet](/developers/math/min-gross-for-net) so the fee-exclusive curve cost is covered.

## Parameters

### snapshot

- **Type:** `MarketSnapshot`

```ts
quoteBuyExactAvmOut(snapshot, parseAvm("1000"));
```

### amount

- **Type:** `AvmAtoms`

Exact AVM to mint, 18 decimals. Must imply gross USDC ≥ `100` raw.

```ts
quoteBuyExactAvmOut(snapshot, asAvmAtoms(10n ** 18n));
```

## Error

| Error                                     | When                         |
| ----------------------------------------- | ---------------------------- |
| `UnsupportedCurveRevisionError`           | Unsupported `snapshot.math`  |
| `ProtocolRevertError` `BelowMinimum`      | Implied gross USDC `< 100`   |
| `ProtocolRevertError` `CanaryCapExceeded` | Supply cap would be breached |

## Tips

- Exact-output is how you keep a USDC cap: quote exact-in to learn `avmOut`, then submit exact-out with `maxIn = budget`.
