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

# Credit Lines: Drawdowns, Repayments, and Interest Accrual

> How Synclear credit lines work — revolving vs. term facilities, drawing funds, repaying debt, and tracking interest accrual per block.

A credit line on Synclear is a smart-contract-bound facility that lets a verified business borrow up to a defined limit against posted collateral. Once a credit line is established and collateral is deposited, the borrower can draw funds at any time without re-applying — subject to maintaining the required collateral ratio. Interest accrues continuously on the outstanding balance, and repayments can be made in full or in part at any time.

## Facility Types

Synclear offers two credit line structures depending on the business's capital planning needs.

<Tabs>
  <Tab title="Revolving Credit Line">
    A revolving facility works like a draw-and-repay cycle with no fixed end date. The borrower can draw up to the credit limit, repay some or all of the principal, and draw again — as long as collateral requirements are met. This is suited to businesses with variable, recurring capital needs such as inventory purchases, payroll, or operational float.

    * **No fixed maturity** — the line remains open while collateral is maintained
    * **Repay and redraw** — repaid principal restores available credit immediately
    * **Interest on outstanding balance only** — idle credit capacity incurs no cost
  </Tab>

  <Tab title="Term Credit Facility">
    A term facility is a single-draw loan with a defined repayment schedule or bullet maturity. The full principal is drawn at origination and must be repaid by a specified block height or timestamp. Term facilities are suited to businesses executing a known, time-bounded capital deployment — such as funding a liquidity mining position or a pre-funded grant cycle.

    * **Fixed draw at origination** — full principal disbursed upfront
    * **Defined maturity** — repayment due by agreed block/timestamp
    * **Structured repayment** — periodic payments or bullet repayment at maturity
  </Tab>
</Tabs>

## Opening a Credit Line

<Steps>
  <Step title="Complete Business Onboarding">
    Ensure your on-chain business account has completed the Synclear verification flow. Credit line issuance requires a verified business entity. Navigate to **Settings → Business Profile** to check your verification status.
  </Step>

  <Step title="Select Facility Type and Parameters">
    In the **Borrow** module, select **New Credit Line**. Choose between a revolving or term facility. Specify your requested credit limit and preferred collateral asset. The interface will display the required collateral amount based on current LTV parameters.
  </Step>

  <Step title="Deposit Collateral">
    Approve and transfer collateral to Synclear's escrow contract. Collateral is held by a non-custodial vault contract; the protocol cannot unilaterally move it except to enforce liquidation. You will receive a collateral receipt token representing your deposited position.
  </Step>

  <Step title="Credit Line Activation">
    Once the collateral deposit is confirmed on-chain (typically 1–2 block confirmations), the credit line is activated. Your available credit limit, current utilization, and health factor will appear in the Borrow dashboard.
  </Step>

  <Step title="Draw Funds">
    Issue a drawdown transaction specifying the amount and recipient address. Funds are transferred directly from the protocol liquidity pool to the recipient in a single atomic transaction. You can draw up to the available limit at any time while your health factor remains above 1.0.
  </Step>
</Steps>

## Drawing From a Credit Line

Each drawdown is an on-chain transaction calling the `BorrowRouter` contract. The `draw` function transfers the requested amount from the lending pool to the specified recipient address and records the liability against the credit line.

### Parameters

<ParamField path="creditLineId" type="bytes32" required>
  The unique identifier of the credit line, returned at activation. Used to reference the specific facility and its associated collateral escrow.
</ParamField>

<ParamField path="amount" type="uint256" required>
  The amount to draw, denominated in the credit line's base asset (e.g., USDC). Must not exceed `availableCredit` at the time of the transaction. Expressed in the token's native decimals.
</ParamField>

<ParamField path="recipientAddress" type="address" required>
  The Ethereum address to receive the drawn funds. Can be any externally owned account or contract address. Does not need to be the same address that opened the credit line.
</ParamField>

```js theme={null}
// Example: draw from credit line using ethers.js
// RPC_URL, PRIVATE_KEY, BORROW_ROUTER_ADDRESS, and BORROW_ROUTER_ABI must be
// set from your environment. Contract addresses are published at:
// https://docs.synclear.fi/get-started/contract-addresses
const { ethers } = require("ethers");

const provider = new ethers.JsonRpcProvider(RPC_URL);
const signer = new ethers.Wallet(PRIVATE_KEY, provider);
const borrowRouter = new ethers.Contract(BORROW_ROUTER_ADDRESS, BORROW_ROUTER_ABI, signer);

// Draw 10,000 USDC from an existing credit line
const creditLineId = "0xabc123..."; // bytes32 identifier returned at credit line activation
const amount = ethers.parseUnits("10000", 6); // USDC uses 6 decimals
const recipientAddress = "0x0000000000000000000000000000000000000001"; // replace with your operating wallet address

const tx = await borrowRouter.draw(creditLineId, amount, recipientAddress);
const receipt = await tx.wait();

console.log("Draw confirmed in block:", receipt.blockNumber);
```

## Interest Accrual

Interest accrues on outstanding balances per block, not daily. The protocol calculates accrued interest using the following formula:

```
accruedInterest = principal × ratePerBlock × blocksDelta
```

Where `ratePerBlock` is derived from the current utilization-based interest rate model. The effective annualized rate is displayed in the Borrow dashboard and updates in real time as pool utilization changes.

<Note>
  Interest is added to the outstanding balance continuously. When you repay, the protocol applies the payment first to accrued interest, then to principal. Always check `outstandingBalance` on-chain rather than relying on a cached UI value before submitting a repayment transaction.
</Note>

## Repaying a Credit Line

Repayments can be partial or full. To repay, approve the credit line contract to spend the repayment amount from your wallet, then call the `repay` function:

```js theme={null}
// Example: repay credit line (full repayment)
// Assumes provider, signer, borrowRouter, and creditLineId are initialized
// as shown in the drawdown example above.
// USDC_ADDRESS and ERC20_ABI must be set from your environment.
const outstandingBalance = await borrowRouter.outstandingBalance(creditLineId);

// Approve the borrow router to pull repayment funds
const usdc = new ethers.Contract(USDC_ADDRESS, ERC20_ABI, signer);
await usdc.approve(BORROW_ROUTER_ADDRESS, outstandingBalance);

// Execute repayment — pass ethers.MaxUint256 to repay in full
const repayTx = await borrowRouter.repay(
  creditLineId,
  ethers.MaxUint256 // repay full outstanding balance (principal + accrued interest)
);
await repayTx.wait();
```

Pass `ethers.MaxUint256` as the amount to trigger a full repayment that settles both principal and all accrued interest. Pass a specific amount for partial repayment — the remainder continues to accrue.

## Credit Line Utilization

Utilization is tracked as the ratio of drawn balance to total credit limit:

```
utilization = outstandingBalance / creditLimit
```

High utilization reduces your available draw capacity and may affect your health factor if collateral value fluctuates. Monitor utilization and health factor together — both are visible in the Borrow dashboard and queryable on-chain via `borrowRouter.creditLineStatus(creditLineId)`.
