---
title: getMaxActions
description: Largest borrow, withdraw, repay, shrink, and surrender with the limiting reason.
---

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

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](/developers/get-account-context) and calls this.

## Import

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

## Usage

```ts
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`

| Field                    | Meaning                                  |
| ------------------------ | ---------------------------------------- |
| `maxBorrowGrossRaw`      | Gross USDC that can still be drawn       |
| `maxWithdrawFreeAvm`     | AVM not locking debt                     |
| `maxRepayRaw`            | `min(debt, walletReserve)` unless paused |
| `maxShrinkCollateralAvm` | Collateral that can be sold              |
| `maxSurrenderDebtRaw`    | Debt that can be cancelled               |
| `limiting.*`             | Why that max is what it is               |

## Parameters

### snapshot

- **Type:** `MarketSnapshot`

Floor, pause flags, liquid reserve.

```ts
getMaxActions(snapshot, position, walletUsdc);
```

### position

- **Type:** `PersonalPosition`

### walletReserve (optional)

- **Type:** `bigint`
- **Default:** `0n`

Wallet USDC, used only for repay sizing.

```ts
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.
