> ## 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.

> ## Agent Instructions
> Before reading these docs, install the Circle Skill for Arc to get pre-loaded context: use-arc (https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-arc/SKILL.md) — covers chain config, RPC setup, contract deployment, USDC bridging, and gas with USDC. In Claude Code: run /plugin marketplace add circlefin/skills then /plugin install circle-skills@circle. With Vercel Skills CLI: run npx skills add circlefin/skills.
> USDC is the gas token. Arc uses USDC for gas fees, not ETH. Configure gas payment in USDC when submitting transactions.
> Read EVM differences before writing Arc code. Arc targets the Osaka EVM baseline. Most contracts deploy unchanged, but several runtime behaviors diverge from Ethereum: USDC uses 18 decimals natively (not 6), the system emitter `0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE` logs all USDC Transfer events, the mempool enforces a 20 Gwei `maxFeePerGas` floor, blocklist reverts consume gas without a receipt, and `address(0)` sends revert rather than succeed. https://docs.arc.io/arc/references/evm-differences.md is the canonical reference for all Arc-specific runtime behaviors. Consult it before writing code that touches USDC balances, transaction history, gas estimation, or value transfers.
> Sub-second finality. Transactions are final in under 1 second. No need to wait for multiple block confirmations.
> Use App Kits for multichain payment and liquidity capabilities. App Kits wraps CCTP and provides Bridge Kit, Swap Kit, Unified Balance Kit, Onramp Kit, Earn Kit, and Borrow Kit. Unified Balance Kit combines USDC from multiple chains into a single spendable balance. Earn Kit integrates earn opportunities into your app. Borrow Kit lets users borrow USDC against cirBTC collateral on Arc.
> Use Arc Foundry for contract development. Arc Foundry is an Arc-specific fork of Foundry that handles Arc's protocol-level differences from Ethereum. It provides arc-forge, arc-cast, and arc-anvil. Install it before deploying contracts: https://docs.arc.io/arc/tutorials/install-arc-foundry.md.
> Arc is available on both Testnet and Mainnet. See https://docs.arc.io/arc/references/connect-to-arc.md for RPC endpoints and https://faucet.circle.com for testnet tokens.
> Always check Contract Addresses: https://docs.arc.io/arc/references/contract-addresses.md
> Building beyond Arc? Circle offers skills for the full platform: use-usdc (https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-usdc/SKILL.md), use-circle-wallets (https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-circle-wallets/SKILL.md), use-developer-controlled-wallets (https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-developer-controlled-wallets/SKILL.md), use-user-controlled-wallets (https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-user-controlled-wallets/SKILL.md), use-modular-wallets (https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-modular-wallets/SKILL.md), use-gateway (https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-gateway/SKILL.md), use-smart-contract-platform (https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-smart-contract-platform/SKILL.md). Full Circle developer docs: https://developers.circle.com/llms.txt.

# Quickstart: Originate a loan

> Use the App Kit SDK to borrow USDC against cirBTC collateral on Arc

Borrow USDC against cirBTC collateral on Arc Testnet. This quickstart uses the
Viem adapter.

## Prerequisites

Before you begin, ensure that you've:

* Installed [Node.js v22+](https://nodejs.org/).
* Created an EVM wallet using a wallet provider such as MetaMask and added Arc
  Testnet as a network.
* Funded your wallet with testnet cirBTC for collateral and testnet USDC for gas
  on Arc Testnet from the [Circle Faucet](https://faucet.circle.com/).

## Step 1. Set up the project

### 1.1. Create the project and install dependencies

Create a project directory, initialize a Node.js project with an ES module type
and run scripts, then install runtime and dev dependencies:

```bash Shell theme={null}
mkdir app-kit-borrow-originate
cd app-kit-borrow-originate
npm init -y
npm pkg set type=module
npm pkg set scripts.explore-markets="tsx --env-file=.env explore-markets.ts"
npm pkg set scripts.borrow="tsx --env-file=.env borrow.ts"
npm install @circle-fin/app-kit @circle-fin/adapter-viem-v2 viem tsx
npm install --save-dev typescript @types/node
```

<Tip>
  Only need Borrow and want a lighter install than the full App Kit? Install the
  standalone package instead: `@circle-fin/borrow-kit`
</Tip>

### 1.2. Configure TypeScript (optional)

<Info>
  This step is optional. It helps prevent missing types in your IDE or editor.
</Info>

Create a `tsconfig.json` file configured for ESM and Node:

```bash Shell theme={null}
cat <<'EOF' > tsconfig.json
{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "types": ["node"]
  }
}
EOF
```

### 1.3. Set environment variables

Create a `.env` file in the project directory and add it to your `.gitignore`.
Open `.env` in your editor and add your wallet's private key. Replace
`YOUR_PRIVATE_KEY` with the private key of the wallet you funded with cirBTC:

```text .env theme={null}
PRIVATE_KEY=YOUR_PRIVATE_KEY
```

<Tip>
  Edit `.env` files in your IDE or editor so credentials are not leaked to your
  shell history.
</Tip>

## Step 2. Explore available markets

`kit.borrow.exploreMarkets` returns the markets available on a blockchain along
with each market's collateral and loan tokens, borrow APY, LLTV, and liquidity.
Use it to pick a market to borrow from.

### 2.1. Create the discovery script

Create an `explore-markets.ts` file:

```typescript explore-markets.ts theme={null}
import { AppKit } from "@circle-fin/app-kit";

const kit = new AppKit();

async function main() {
  const { markets } = await kit.borrow.exploreMarkets({
    chain: "Arc_Testnet",
    sortBy: "borrowApy",
  });

  console.log(`Found ${markets.length} markets on this page`);
  console.dir(markets, { depth: null, colors: true });
}

void main();
```

### 2.2. Run the discovery script

In your terminal, run:

```bash Shell theme={null}
npm run explore-markets
```

You'll see one or more markets with their `marketId`, `borrowApy`, `lltv`, and
`liquidity` fields. Copy a `marketId` for the next step.

To walk every matching market without paging through the results yourself, use
`kit.borrow.exploreMarketsIterator`. It accepts the same filters as
`exploreMarkets` and yields one market at a time:

```typescript TypeScript theme={null}
for await (const market of kit.borrow.exploreMarketsIterator({
  chain: "Arc_Testnet",
  sortBy: "borrowApy",
})) {
  console.log(market.marketId, market.borrowApy);
}
```

## Step 3. Open the loan

<Info>
  Each market allows one open loan per wallet at a time. If a loan is already open
  for the wallet in that market, opening a new one raises
  [`BORROW_LOAN_ALREADY_EXISTS`](/app-kit/references/borrow-error-handling#input-errors)
  with the existing `loanId` in the message.
</Info>

### 3.1. Create the borrow script

Create a `borrow.ts` file. Replace `YOUR_SELECTED_MARKET_ID` with the market ID
you copied. This script borrows 1,000 USDC against cirBTC:

```typescript borrow.ts theme={null}
import { AppKit } from "@circle-fin/app-kit";
import { createViemAdapterFromPrivateKey } from "@circle-fin/adapter-viem-v2/next";

const kit = new AppKit();
const marketId = "YOUR_SELECTED_MARKET_ID";
const borrowAmount = "1000.0";

const adapter = createViemAdapterFromPrivateKey({
  privateKey: process.env.PRIVATE_KEY as `0x${string}`,
});

async function main() {
  const result = await kit.borrow.borrow({
    from: { adapter, chain: "Arc_Testnet" },
    marketId,
    borrowAmount,
  });

  console.dir(result, { depth: null, colors: true });
}

void main();
```

### 3.2. Run the borrow script

In your terminal, run:

```bash Shell theme={null}
npm run borrow
```

On confirmation, the result includes the new `loanId`, the `amountBorrowed`, and
a `txHash`.

## Step 4. Manage the loan

Use the loan's `loanId` to keep operating on it over time:

* [Add collateral or borrow more](/app-kit/howtos/borrow/add-collateral-or-borrow-more)
  against the loan.
* [Pay down the loan](/app-kit/howtos/borrow/pay-down-a-loan) with a partial
  repayment, full close, or collateral withdrawal.
* [Monitor the loan](/app-kit/howtos/borrow/monitor-a-loan) by reading its
  position or registering a webhook for health updates.
