quoteSellExactReserveOut
Quote the AVM that must be burned to take home an exact net USDC amount.
Exact-output curve sell. Sizes avmIn so that net USDC (after the 1.25% sell fee) equals amount. This is the expensive selector: the user burns whatever AVM it takes.
The quote attaches warning exact-out-sell-expensive. Prefer quoteSellExactAvmIn unless the UI is a "I want $X out" ticket.
Import
import { quoteSellExactReserveOut } from "@repo/contract-client/math";
Usage
import { parseUsdc } from "@repo/contract-client";
import { quoteSellExactReserveOut } from "@repo/contract-client/math";
const quote = quoteSellExactReserveOut(snapshot, parseUsdc("10"));
quote.netReserveOutRaw; // the $10 you asked for
quote.avmIn; // tokens burned
quote.grossReserveOutRaw;
quote.residualRaw;
quote.provenance.warnings; // includes exact-out-sell-expensive
Return Value
SellExactOutQuote
| Field | Meaning |
|---|---|
kind | 'sellExactReserveOut' |
netReserveOutRaw | Target proceeds |
grossReserveOutRaw | Curve payout before fee |
avmIn | Tokens that must be burned |
residualRaw | Rounding dust kept in the market |
priceImpact / nextEngine / provenance | Same family as other sells |
Parameters
snapshot
- Type:
MarketSnapshot
quoteSellExactReserveOut(snapshot, parseUsdc("10"));
amount
- Type:
UsdcRaw
Net USDC the wallet should receive. Must be ≥ 100 raw.
quoteSellExactReserveOut(snapshot, asUsdcRaw(10_000_000n));
Error
| Error | When |
|---|---|
ProtocolRevertError BelowMinimum | Target too small |
ProtocolRevertError ZeroAmount | Curve cannot pay that much |
Tips
prepareSellForNetTargetis the prepare helper that uses this intent without forcing the expensive selector when an exact-in sell is cheaper.