quoteSurrender
Quote burning collateral to cancel a chosen amount of debt.
Burns collateralForDebtUp(amount, floor) AVM and reduces debt by amount. Irreversible on-chain. Spot does not move; priceImpact is null.
This is how a holder exits a position without repaying USDC: they give up the locked tokens and the matching debt disappears. Remaining free collateral stays in the position.
Import
import { quoteSurrender } from "@repo/contract-client/math";
Usage
import { parseUsdc } from "@repo/contract-client";
import { quoteSurrender } from "@repo/contract-client/math";
const quote = quoteSurrender(snapshot, position, parseUsdc("10"));
quote.debtToCancelRaw;
quote.collateralBurned;
quote.position.collateralAvm;
quote.position.debtRaw;
quote.priceImpact; // null
collateralBurned is lockedCollateral for that debt slice (ceil), which is the same helper as collateralForDebtUp.
Return Value
SurrenderQuote
| Field | Meaning |
|---|---|
kind | 'surrender' |
debtToCancelRaw | USDC of debt cancelled |
collateralBurned | AVM burned |
position | After the burn |
priceImpact | null |
Parameters
snapshot
- Type:
MarketSnapshot
Provides floor price.
quoteSurrender(snapshot, position, parseUsdc("10"));
position
- Type:
PersonalPosition
Must hold enough collateral and at least amount debt.
amount
- Type:
UsdcRaw
Debt to cancel. Must be ≤ position.debtRaw.
quoteSurrender(snapshot, position, asUsdcRaw(position.debtRaw));
Error
| Error | When |
|---|---|
ProtocolRevertError InsufficientFreeCollateral | Burn exceeds collateral |
ProtocolRevertError ZeroAmount | amount > position.debtRaw or too small |
Tips
- Max size is
getMaxActions(...).maxSurrenderDebtRaw. Pause zeros it.