> ## 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: Pay down a loan

> Repay USDC debt, close a loan in full, and withdraw cirBTC collateral from a Borrow loan

Pay down a Borrow loan with a partial repayment, a full close, or a collateral
withdrawal. Each operation addresses the loan by `loanId`.

## Prerequisites

Before you begin, ensure that you've:

* [Installed the App Kit SDK](/app-kit/tutorials/installation) and an adapter
* Opened a loan with debt or collateral to withdraw

## Repay part of a loan

Call `repay` with the loan's `loanId` and the USDC amount. The SDK rejects the
request before signing if `repayAmount` exceeds outstanding debt. Use
`closeLoan` for a full payoff.

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

## Close a loan in full

Call `closeLoan` to repay all outstanding debt and withdraw all collateral in a
single atomic batch. The SDK uses share-based payoff math and may pull more USDC
than needed, up to your `slippageBps` bound, refunding any surplus.

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

if (result.status === "confirmed") {
  console.log("Repaid:", result.amountRepaid.amount);
  console.log("Collateral withdrawn:", result.collateralWithdrawn.amount);
}
```

To preview a full close before signing, see
[Preview Borrow operations](/app-kit/howtos/borrow/preview-a-loan-operation#preview-a-full-close).

## Withdraw collateral

Call `withdrawCollateralRepayIfNeeded` to release cirBTC from a loan. The SDK
sizes any repayment needed to keep the loan healthy after the withdrawal and
pays it from the wallet's USDC balance in the same atomic batch. If the
repayment covers the entire debt, the withdrawal closes the loan.

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

To preview a collateral withdrawal before signing, see
[Preview Borrow operations](/app-kit/howtos/borrow/preview-a-loan-operation#preview-withdrawing-collateral).
