SV3 logo

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

FieldMeaning
kind'surrender'
debtToCancelRawUSDC of debt cancelled
collateralBurnedAVM burned
positionAfter the burn
priceImpactnull

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

ErrorWhen
ProtocolRevertError InsufficientFreeCollateralBurn exceeds collateral
ProtocolRevertError ZeroAmountamount > position.debtRaw or too small

Tips

  • Max size is getMaxActions(...).maxSurrenderDebtRaw. Pause zeros it.