> For the complete documentation index, see [llms.txt](https://docs.creditcoop.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.creditcoop.xyz/start-here/how-it-works.md).

# How It Works

The full lifecycle of a dollar through Credit Coop — from depositor to vault to credit line to borrower, and back again through the Spigot.

This page walks the complete lifecycle end-to-end. Every step names the actual onchain action, so you can follow along in the contracts.

## 1. Depositors fund the vault

Capital enters through a **Lending Vault**, an ERC-4626 vault with asynchronous (ERC-7540) deposits and redemptions:

1. A depositor calls `requestDeposit()` with the vault asset. If the vault is whitelist-gated, their address must be approved first.
2. The Vault Curator processes the request (`processDepositRequest()`), locking in the share price within slippage bounds.
3. The depositor claims their shares with `deposit()` — they now hold vault tokens whose value tracks the vault's `sharePrice()`.

Redemptions mirror this: `requestRedeem()` → Curator processing → `redeem()` to claim assets. The two-step design lets the vault manage liquidity responsibly — capital may be deployed in credit lines and needs to be recalled in an orderly way.

While capital waits to be deployed into credit, the **Liquid Strategy** can park it in an approved external yield source (any ERC-4626 vault with the same base asset), so idle funds still earn.

## 2. The vault extends credit

The **Credit Strategy** acts on behalf of depositors. With capital from the vault, it proposes and funds positions on a borrower's **Secured Line of Credit**:

1. Terms — amount, rate, deadline — are agreed by **mutual consent**: both the lender side and the borrower must sign the same proposal (`addCredit()`).
2. Once accepted, the position is minted as an ERC-721 **Credit Position Token** held by the Credit Strategy. Positions are transferable (where permitted), which enables secondary liquidity for lenders.
3. The borrower draws funds with `borrow()` — up to the committed amount, repay and redraw as needed. It's a revolver, not a term loan.

## 3. The Spigot secures repayment

Before (or as a condition of) funding, the borrower's revenue-generating contracts are transferred to the **Spigot**'s ownership:

* Each revenue contract is registered with `addSpigot()`, defining how tokens are claimed and how ownership transfers back.
* Incoming revenue is escrowed and split automatically: the **owner share** accumulates toward debt service; the **operator share** is claimable by the borrower (`claimOperatorTokens()`) to run their business.
* The borrower keeps operating their product through `operate()` — but only via functions explicitly whitelisted, so they can never redirect the cash flow or reclaim ownership while debt is outstanding.
* Revenue arriving in other tokens can be converted before repayment — via market trade (`tradeAndDistribute()`) or a bounded OTC swap — so debt is always serviced in the credit token.

The Spigot supports multiple **beneficiaries** with defined allocations, so one secured cash flow can service more than one obligation with a transparent, programmatic waterfall.

## 4. Repayment flows back to depositors

Escrowed owner tokens are used to pay down interest and principal (`claimAndRepay()` and related flows). Interest accrues continuously per the agreed rate. Repayments flow to the Credit Strategy, increasing vault assets — which is what drives the vault share price, and thus depositor yield. Vault-level management and performance fees are taken per the disclosed fee schedule.

## 5. The line closes — or doesn't

A line's status is a state machine: `ACTIVE` while healthy, `REPAID` when fully closed out, `LIQUIDATABLE` if covenants are breached (missed deadline, collateral shortfall), and `INSOLVENT` or `ABORTED` in failure scenarios.

* **Happy path:** the borrower repays in full (`depositAndClose()`), positions close, and the Spigot releases ownership of the revenue contracts back to the borrower automatically. The lien exists only as long as the debt does.
* **Distress path:** if the line becomes liquidatable, the protocol's recovery tools activate — escrowed collateral can be liquidated, Spigot flows stepped up to full escrow for debt service, and positions impaired transparently if recovery falls short.

```mermaid
sequenceDiagram
    participant D as Depositor
    participant V as Lending Vault
    participant CS as Credit Strategy
    participant L as Secured Line of Credit
    participant B as Borrower
    participant S as Spigot

    D->>V: requestDeposit(assets)
    V-->>D: vault shares (after processing)
    V->>CS: deploy capital
    CS->>L: addCredit (mutual consent)
    B->>L: borrow()
    L->>B: funds
    Note over B,S: Borrower's revenue contracts owned by Spigot
    S->>S: escrow & split incoming revenue
    S->>L: owner share → repay interest + principal
    S->>B: operator share → business operations
    L->>CS: repayments
    CS->>V: assets grow → sharePrice ↑
    D->>V: requestRedeem() → redeem assets + yield
```

## Go deeper

* Facility mechanics: [Secured Line of Credit](/core-concepts/secured-line-of-credit.md)
* Cash-flow security: [The Spigot](/core-concepts/the-spigot.md)
* Pooled lending: [Vaults](/core-concepts/vaults.md)
* Your role-specific guide: [Who It's For](/start-here/who-its-for.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.creditcoop.xyz/start-here/how-it-works.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
