---
title: prepareBuyForReserveBudget
description: Prepare a buy that spends at most a USDC budget by submitting the cheaper exact-output selector.
---

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

Keeps the user's USDC cap. Quotes an exact-input buy locally, then encodes `buyWithExactAvmTokensOut` so the wallet spends **at most** `amount` and receives the quoted AVM.

This is the helper you want for a "I will spend $10" ticket. The SDK has no hidden slippage default — `slippageBps` is required.

Does not send. Pass the result to [getRequirements](/developers/get-requirements), then [executePrepared](/developers/execute-prepared).

## Import

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

## Usage

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

const prepared = await sv3.trade.prepareBuyForReserveBudget({
  market,
  amount: parseUsdc("10"),
  slippageBps: 100n, // 1%
});

prepared.to;
prepared.data;
prepared.functionName; // 'buyWithExactAvmTokensOut'
prepared.constraints.maxIn;
prepared.quoteContext;
```

`prepareBuyExactReserveIn` instead encodes `buyWithExactReserveTokensIn` (exact USDC in, min AVM out). See [prepareBuyExactReserveIn](/developers/prepare-buy-exact-reserve-in).

## Return Value

`Promise<PreparedAction>`

Frozen calldata: `to`, `data`, `value` (`0n`), `functionName`, `args`, `deadline`, `constraints` (`maxIn`, `marketStateNonce`, `marketStateHash`), and the `quoteContext` used to build it.

## Parameters

### market

- **Type:** `Address`

FloorMarket proxy.

```ts
await sv3.trade.prepareBuyForReserveBudget({
  market,
  amount: parseUsdc("10"),
  slippageBps: 100n,
});
```

### amount

- **Type:** `bigint` (`UsdcRaw`)

Gross USDC budget, 6 decimals. Must be ≥ `100` (`MIN_SETTLEMENT_RAW`).

```ts
await sv3.trade.prepareBuyForReserveBudget({
  market,
  amount: parseUsdc("10"),
  slippageBps: 100n,
});
```

### slippageBps

- **Type:** `bigint`
- **Required** — no default

Basis points of tolerance applied when encoding limits. `100n` is 1%.

```ts
await sv3.trade.prepareBuyForReserveBudget({
  market,
  amount: parseUsdc("10"),
  slippageBps: 50n,
});
```

## Error

| Error                                | When                                   |
| ------------------------------------ | -------------------------------------- |
| `WalletClientRequiredError`          | No wallet / account on the client      |
| `ProtocolRevertError` `BelowMinimum` | Budget too small to mint               |
| `InvalidDeadlineError`               | Client deadline config is out of range |

## Other prepare helpers

| Method                       | User intent                | On-chain selector                   |
| ---------------------------- | -------------------------- | ----------------------------------- |
| `prepareBuyForReserveBudget` | Spend at most this USDC    | `buyWithExactAvmTokensOut`          |
| `prepareBuyExactReserveIn`   | Spend exactly this USDC    | `buyWithExactReserveTokensIn`       |
| `prepareBuyExactAvmOut`      | Mint exactly this AVM      | `buyWithExactAvmTokensOut`          |
| `prepareSellExactAvmIn`      | Sell exactly this AVM      | `sellWithExactAvmTokensIn`          |
| `prepareSellForNetTarget`    | Receive at least this USDC | cheaper sell path                   |
| `prepareSellExactReserveOut` | Receive exactly this USDC  | `sellWithExactReserveTokensOut`     |
| `prepareRedeemAtFloor`       | Redeem at floor            | `redeemAtFloorWithExactAvmTokensIn` |

All take `{ market, amount, slippageBps }` and return `PreparedAction`. None of them send.

## Tips

- Re-quote if the snapshot is stale. `executePrepared` throws `StaleStateError` when `stateNonce` moved, unless you pass `acceptStale: true`.
- Exact-output sells are the expensive selector. Prefer `prepareSellExactAvmIn` unless the user typed a USDC target.
