# Credit Accounts (The Primitive)

The Credit Account is the fundamental primitive of the Gearbox Protocol. It functions as a user-owned, isolated smart contract wallet that holds both collateral and borrowed funds, enabling leveraged execution across DeFi protocols.

### Core Concept: Isolated Smart Contract Wallet

Unlike traditional lending protocols where user collateral is siloed in a global vault, Gearbox deploys a unique smart contract for each borrower.&#x20;

<figure><img src="https://2617978714-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FviVygst6ymEvrLTl74w1%2Fuploads%2FD4RgaXdcKKBdmF1dYLJv%2Flegacy-lending.png?alt=media&#x26;token=30c6e44a-fc53-4c80-b4c4-1a2a395077af" alt=""><figcaption></figcaption></figure>

The Credit Account serves as a container for the user's entire position.

* **Segregated State:** Assets within the Credit Account are legally and technically distinct from the protocol's liquidity pools.
* **User Ownership:** The user retains control over the account's operations, subject only to the solvency checks enforced by the Credit Manager.
* **Portability:** Because the Credit Account is a standard smart contract, it can interact with external protocols as a distinct entity, preserving the identity of the position.

### Atomic Solvency Check

The Credit Account operates on a "Check-on-Exit" architecture. The protocol does not restrict specific actions within a transaction bundle, provided the account remains solvent at the conclusion of the execution trace.

Upon the completion of any interaction (e.g., a swap or deposit), the protocol calculates the account's **Health Factor**.

* **If Health Factor > 1:** The transaction is finalized and recorded on-chain.
* **If Health Factor < 1:** The entire transaction reverts, ensuring no bad debt can be created atomically.

This mechanism allows users to perform complex, multi-step operations in a single transaction without requiring the protocol to understand the intermediate states, as long as the final state satisfies the risk parameters.

<figure><img src="https://2617978714-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FviVygst6ymEvrLTl74w1%2Fuploads%2Fy2nFsmBdF5BOaDCMhSnp%2Fca-lending.png?alt=media&#x26;token=52ce722e-1a44-4bb4-a72c-edcade9eb5d4" alt=""><figcaption></figcaption></figure>

### Composability via Adapters

The Credit Account interacts with the external DeFi ecosystem through **Adapters**. These are lightweight contract interfaces that translate generic user intents into protocol-specific function calls.

From the perspective of an external protocol, the Credit Account appears as a standard user wallet. This enables:

1. **Native Execution:** Users interact directly with external contracts rather than through a protocol-specific abstraction layer.
2. **Programmable Credit:** Developers can compose credit logic into arbitrary workflows, treating the Credit Account as a programmable leverage module.

***

### Learn More

* **Risk Enforcement:** the logic for calculating the Health Factor and enforcing solvency is managed by the Credit Manager and Credit Facade.
  * &#x20;[credit-suite](https://docs.gearbox.finance/about-gearbox/core-architecture/credit-suite "mention")
* **External Interactions:** The mechanism for connecting Credit Accounts to external DeFi protocols is defined by the Adapter system.
  * [adapters-integrations](https://docs.gearbox.finance/about-gearbox/core-architecture/adapters-integrations "mention")
* **Liquidity Source:** The capital borrowed by the Credit Account is sourced from the passive Liquidity Pool.
  * [pool](https://docs.gearbox.finance/about-gearbox/core-architecture/pool "mention")
