---
title: quoteExpandExactAvmOut
description: Quote a buy of an exact AVM amount, pledged as collateral, plus a borrow.
---

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

Same loop as [quoteExpandExactReserveIn](/developers/math/quote-expand-exact-reserve-in), but the buy leg is exact-output: mint `collateralAdded` AVM, then borrow `grossDebtIncrease`.

`reserveFromUserRaw` on the result is the implied gross USDC of that buy.

## Import

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

## Usage

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

const quote = quoteExpandExactAvmOut(snapshot, position, {
  collateralAdded: parseAvm("1000"),
  grossDebtIncrease: parseUsdc("5"),
});

quote.reserveFromUserRaw;
quote.collateralAdded;
quote.borrowFees;
quote.position;
```

## Return Value

`ExpandQuote` with `kind: 'expandExactAvmOut'`. Fields match the exact-input expand helper.

## Parameters

### snapshot

- **Type:** `MarketSnapshot`

### position

- **Type:** `PersonalPosition`

### params.collateralAdded

- **Type:** `AvmAtoms`

Exact AVM to mint and pledge.

### params.grossDebtIncrease

- **Type:** `UsdcRaw`

Gross borrow against the new collateral.

```ts
quoteExpandExactAvmOut(snapshot, position, {
  collateralAdded: parseAvm("1000"),
  grossDebtIncrease: parseUsdc("5"),
});
```

## Error

Nested buy / borrow errors (`BelowMinimum`, `CanaryCapExceeded`, `BorrowCapacityExceeded`, `InsufficientBacking`).
