SV3 logo

getMaxActions

Largest borrow, withdraw, repay, shrink, and surrender with the limiting reason.

Read-only sizing for a position ticket. Does not send. A market or global pause zeros every max.

Use this to clamp sliders before calling quoteBorrow / shrink / surrender. The client helper sv3.position.getMaxActions(market, owner) loads getAccountContext and calls this.

Import

import { getMaxActions } from "@repo/contract-client/math";

Usage

const max = getMaxActions(snapshot, position, walletUsdc);

max.maxBorrowGrossRaw;
max.maxWithdrawFreeAvm;
max.maxRepayRaw;
max.maxShrinkCollateralAvm;
max.maxSurrenderDebtRaw;

max.limiting.borrow;
// 'capacity' | 'reserve' | 'paused' | 'min-settlement' | …

Return Value

MaxActions

FieldMeaning
maxBorrowGrossRawGross USDC that can still be drawn
maxWithdrawFreeAvmAVM not locking debt
maxRepayRawmin(debt, walletReserve) unless paused
maxShrinkCollateralAvmCollateral that can be sold
maxSurrenderDebtRawDebt that can be cancelled
limiting.*Why that max is what it is

Parameters

snapshot

  • Type: MarketSnapshot

Floor, pause flags, liquid reserve.

getMaxActions(snapshot, position, walletUsdc);

position

  • Type: PersonalPosition

walletReserve (optional)

  • Type: bigint
  • Default: 0n

Wallet USDC, used only for repay sizing.

getMaxActions(snapshot, position, context.reserveBalance);

Error

UnsupportedCurveRevisionError if snapshot.math is unknown.

Tips

  • limiting.borrow === 'min-settlement' means capacity is below 100 raw — show "cannot borrow" rather than a tiny slider.
  • On-chain debt and backing caps also appear as limiting reasons (market-debt-cap, protocol-debt-cap) when the snapshot carries them.