> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arc.io/llms.txt
> Use this file to discover all available pages before exploring further.

# How-to: Preview Borrow operations

> Inspect the expected outcome and health impact of a Borrow operation before submitting a transaction

Preview a Borrow operation with its paired quote method, or size a borrow with
`getRequiredCollateral` or `getMaxBorrow`. For the full list of quote methods
and their return shapes, see
[Borrow quote methods](/app-kit/references/borrow-quote-methods).

## Prerequisites

Before you begin, ensure that you've:

* [Installed the App Kit SDK](/app-kit/tutorials/installation)
* [Configured an adapter](/app-kit/tutorials/adapter-setups)

These are required so any example below runs with a valid `kit` and `adapter`.

## Preview a borrow

`getBorrowQuote` handles both opening a new loan and borrowing more against an
existing one. To preview opening a new loan, pass the `walletAddress`, `chain`,
and `marketId`:

```typescript TypeScript theme={null}
const quote = await kit.borrow.getBorrowQuote({
  chain: "Arc_Testnet",
  walletAddress: "0x...",
  marketId:
    "0x1111111111111111111111111111111111111111111111111111111111111111",
  borrowAmount: "1000.0",
});
```

To preview borrowing more against an existing loan, pass its `loanId`. The
service resolves the owner, blockchain, and market from the loan:

```typescript TypeScript theme={null}
const quote = await kit.borrow.getBorrowQuote({
  loanId: "11111111-1111-4111-8111-111111111111",
  borrowAmount: "500.0",
});
```

Either call returns the `collateralAmount` the borrow would pull, the
`loanAssetAmount` it would deliver, the market's `borrowApy`, `fees`, `gasFees`,
and the position's `resultingHealthFactor`, `resultingLtv`, `resultingBand`, and
`liquidationPrice`.

## Preview add collateral

Quote the effect of adding cirBTC to an existing loan:

```typescript TypeScript theme={null}
const quote = await kit.borrow.getAddCollateralQuote({
  chain: "Arc_Testnet",
  loanId: "11111111-1111-4111-8111-111111111111",
  collateralAmount: "0.05",
});
```

The quote returns `fees`, `gasFees`, and the position's resulting health fields
after the collateral addition.

## Preview a repayment

Quote a partial repayment. The SDK rejects repayments that exceed the loan's
outstanding debt at quote time.

```typescript TypeScript theme={null}
const quote = await kit.borrow.getRepayQuote({
  chain: "Arc_Testnet",
  loanId: "11111111-1111-4111-8111-111111111111",
  repayAmount: "100.0",
});
```

The quote returns the requested `repayAmount`, `fees`, `gasFees`, and resulting
health fields.

## Preview a full close

Quote a full payoff. Because `closeLoan` uses share-based payoff math and may
pull more USDC than needed (up to your `slippageBps` bound), the quote's
`bundledRepayment` reflects the upper bound of what the transaction may pull.

```typescript TypeScript theme={null}
const quote = await kit.borrow.getCloseLoanQuote({
  chain: "Arc_Testnet",
  loanId: "11111111-1111-4111-8111-111111111111",
});
```

The quote returns `bundledRepayment` (the upper bound of USDC the close may
pull), `collateralAmount` (the cirBTC returned), `fees`, `gasFees`, and
resulting health fields.

## Preview withdrawing collateral

Quote the effect of withdrawing collateral, including the USDC required for the
internal repay leg:

```typescript TypeScript theme={null}
const quote = await kit.borrow.getWithdrawCollateralRepayIfNeededQuote({
  chain: "Arc_Testnet",
  loanId: "11111111-1111-4111-8111-111111111111",
  collateralAmount: "0.01",
});
```

The quote returns `collateralAmount` (the cirBTC released), `bundledRepayment`
(the upper bound of USDC needed for the internal repay leg), `fees`, `gasFees`,
and resulting health fields.

Between preview and execution, the exact repayment amount can shift slightly as
interest accrues on the loan. `slippageBps` (default `300`, or 3%) caps how much
larger the actual repayment can be than the previewed amount. Pass a smaller
`slippageBps` to tighten the ceiling, or omit it for the default.

## Size a borrow

Use `getRequiredCollateral` when the user knows how much USDC they want and what
health factor they want to land on:

```typescript TypeScript theme={null}
const sizing = await kit.borrow.getRequiredCollateral({
  chain: "Arc_Testnet",
  marketId:
    "0x1111111111111111111111111111111111111111111111111111111111111111",
  borrowAmount: "1000.0",
  targetHealthFactor: 1.5,
});
```

Use `getMaxBorrow` when the user has a fixed collateral amount and wants to see
the largest borrow it supports:

```typescript TypeScript theme={null}
const ceiling = await kit.borrow.getMaxBorrow({
  chain: "Arc_Testnet",
  marketId:
    "0x1111111111111111111111111111111111111111111111111111111111111111",
  collateralAmount: "0.05",
});
```

Both return the sizing value along with `resultingHealthFactor` and
`liquidationPrice`. They do not return `fees`, `gasFees`, `resultingLtv`, or
`resultingBand`.
