---
title: quoteBuyExactReserveIn
description: Quote AVM minted for an exact USDC input from a market snapshot.
---

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

Given a pinned `MarketSnapshot` and a gross USDC amount, returns tokens out, the curve leg after the 1.25% buy fee, the fee split, next spot, and Uniswap-style price impact. No RPC.

This is the slider function for "I will spend this USDC." To submit that ticket, prefer [prepareBuyForReserveBudget](/developers/prepare-buy-for-reserve-budget), which keeps the cap by encoding the cheaper exact-output selector.

## Import

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

## Usage

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

const quote = quoteBuyExactReserveIn(snapshot, parseUsdc("1"));

quote.avmOut;
quote.curveReserveInRaw;
quote.fees.totalRaw;
quote.fees.protocolRaw;
quote.fees.creatorRaw;
quote.fees.floorRaw;
quote.priceImpact.totalPriceImpactWad;
quote.nextSpotPriceWad;
```

Gross USDC is split: 1.25% fee, remainder is curve input. Settlement below `100` raw (`0.0001` USDC) reverts with `BelowMinimum`.

## Return Value

`BuyExactInQuote`

| Field               | Type                  | Meaning                                                                           |
| ------------------- | --------------------- | --------------------------------------------------------------------------------- |
| `kind`              | `'buyExactReserveIn'` | Discriminator                                                                     |
| `grossReserveInRaw` | `UsdcRaw`             | What you passed in                                                                |
| `curveReserveInRaw` | `UsdcRaw`             | Gross minus buy fee                                                               |
| `avmOut`            | `AvmAtoms`            | Tokens minted                                                                     |
| `fees`              | `FeeBreakdown`        | Protocol / creator / floor split                                                  |
| `priceImpact`       | `TradePriceImpact`    | Uniswap-style impact; see [tradePriceImpact](/developers/math/trade-price-impact) |
| `nextSpotPriceWad`  | `Wad`                 | Spot after the mint                                                               |
| `nextFloorPriceWad` | `Wad`                 | Unchanged on a buy                                                                |
| `provenance`        | `QuoteProvenance`     | Block pin, revision, warnings                                                     |

## Parameters

### snapshot

- **Type:** `MarketSnapshot`

Frozen market state from [getQuoteState](/developers/get-quote-state) or [getTradeContext](/developers/get-trade-context). `snapshot.math` must be a supported revision.

```ts
quoteBuyExactReserveIn(snapshot, parseUsdc("1"));
```

### amount

- **Type:** `UsdcRaw`

Gross USDC in, 6 decimals. Brand with `parseUsdc('1')` or `asUsdcRaw(1_000_000n)`. Must be ≥ `MIN_SETTLEMENT_RAW` (`100`).

```ts
quoteBuyExactReserveIn(snapshot, asUsdcRaw(1_000_000n));
```

## Error

| Error                                | When                             |
| ------------------------------------ | -------------------------------- |
| `UnsupportedCurveRevisionError`      | `snapshot.math` is not supported |
| `ProtocolRevertError` `BelowMinimum` | `amount < 100`                   |
| `ProtocolRevertError` `ZeroAmount`   | Fee consumes the whole input     |

## Tips

- `priceImpact.totalPriceImpactWad` is **not** the ABI `priceImpactWad` field. The ABI value is the absolute spot delta, exported here as `priceImpact.spotPriceDeltaWad`.
- Same math is available as `sv3.quote.buyExactReserveIn({ market, amount })` if you pass a market address and want the SDK to load the snapshot.
