Core Components
The protocol consists of four primary components that work together to provide credit infrastructure:1. Pool (PoolV3)
The lending pool implements ERC-4626 standard for vault functionality and serves as the liquidity source for credit accounts. Key Responsibilities:- Accept deposits from liquidity providers and mint LP tokens (shares)
- Lend funds to credit managers for borrowing
- Manage base interest rates and quota revenue
- Track total debt across all connected credit managers
2. Credit Manager (CreditManagerV3)
The credit manager implements core logic for credit account management, debt accounting, and collateral validation. Key Responsibilities:- Open and close credit accounts
- Manage debt operations (increase/decrease)
- Execute collateral checks and liquidations
- Track enabled tokens and quotas per account
- Maintain adapter registry for whitelisted protocol interactions
The credit manager uses bitmask operations extensively for gas-efficient token tracking. Each token is assigned a unique bit position, allowing up to 256 tokens to be represented in a single
uint256.3. Credit Facade (CreditFacadeV3)
The credit facade is the user-facing interface that provides safe access to credit manager functionality through multicall operations. Key Responsibilities:- Execute multicall transactions with permission checks
- Enforce debt limits and collateral requirements
- Handle account opening, closing, and liquidation flows
- Manage bot permissions for automated operations
4. Pool Quota Keeper (PoolQuotaKeeperV3)
The quota keeper manages token-specific quotas and interest rates for non-underlying collateral assets. Key Responsibilities:- Track quotas for each account and token combination
- Calculate quota interest using additive (non-compounding) index
- Enforce per-token quota limits
- Manage quota increase fees
Quota interest uses an additive index rather than compounding, making calculations simpler and gas costs more predictable.
Architectural Patterns
Separation of Concerns
Gearbox V3 strictly separates different concerns across contracts:- Credit Manager: Core state and logic (internal only)
- Credit Facade: User interface and safety checks
- Credit Configurator: Admin functions and parameter updates
Multicall Pattern
All user operations are executed through multicalls, enabling atomic sequences of operations:- Atomic execution (all operations succeed or all fail)
- Gas efficiency through batching
- Flexible composition of operations
- Single collateral check at the end
Active Credit Account Pattern
Adapters interact with credit accounts through an “active credit account” mechanism:- Facade sets the active credit account before adapter calls
- Adapter retrieves the active account from the credit manager
- Adapter executes operations on behalf of the account
- Facade clears the active account after execution
Interest and Debt Accounting
Dual Interest System
Gearbox V3 uses two separate interest systems: Base Interest (compounding):- Applied to the principal debt
- Uses cumulative index that grows exponentially
- Calculated as:
accruedInterest = debt * (indexNow / indexLastUpdate - 1)
- Applied to quota amounts for non-underlying collateral
- Uses additive cumulative index
- Calculated as:
quotaInterest = quota * (indexNow - indexLastUpdate) / RAY
Debt Repayment Priority
When decreasing debt, components are repaid in this order:- Quota fees
- Quota interest (+ protocol fee)
- Base interest (+ protocol fee)
- Debt principal
Collateral and Token Management
Enabled Tokens Bitmask
Each credit account tracks which tokens are enabled as collateral using a bitmask:Liquidation Thresholds
Each collateral token has a liquidation threshold (LT) that determines its contribution to the account’s debt coverage:ltInitial to ltFinal during the specified period.
Version Information
All core contracts implement version 3.10:Next Steps
Credit Accounts
Learn about credit account lifecycle and operations
Pools
Understand lending pool mechanics and interest rates
Collateral & Debt
Explore collateral checks and debt management
Quotas
Deep dive into the quota system