The Lending Stack
Every product built on Gearbox — leveraged farming, margin trading, RWA settlement, structured credit — starts from the same primitive: the Credit Account.
Credit Account: The Primitive
A Credit Account is an isolated smart contract wallet that holds both a user's collateral and borrowed funds in one place. Unlike traditional lending protocols where collateral sits in a shared vault, each Gearbox position is a separate contract with its own state.
This isolation is what makes everything else possible:
- Programmable leverage — the Credit Account can interact with any whitelisted DeFi protocol (Uniswap, Curve, Lido, Aave) as if it were a regular wallet. Borrowed funds never leave the account — they're deployed inside it.
- Check-on-exit — the protocol doesn't restrict what you do within a transaction. It only checks that the account is solvent at the end. This enables complex multi-step strategies (borrow → swap → farm → rebalance) in a single atomic transaction.
- Composability — external protocols see the Credit Account as a standard EOA-like contract. No special integrations needed from their side.
Leverage with Delayed Deposits
The Credit Account primitive uniquely solves a problem that traditional lending protocols cannot: leverage on assets with non-atomic settlement.
The Looping Problem
Many assets — tokenized securities (ACRED), staked positions, RWA deposits — have settlement delays. A deposit of USDC into ACRED might take 2 days to mint.
On traditional platforms (Morpho, Aave), building a 10x leveraged position with such a token requires looping: deposit collateral → wait 2 days → use the minted token as collateral → borrow more → deposit again → wait 2 more days → repeat. Getting to 10x leverage takes weeks.
Phantom Tokens: Instant Leverage
Gearbox solves this with phantom tokens — on-chain representations of pending positions that act as collateral during the settlement period.
How it works:
- User opens a Credit Account, deposits $100 collateral, borrows $900
- The Credit Account sends $1,000 to the issuer's deposit contract
- While the deposit is pending (2 days), the Credit Account receives a phantom token — a futures-like representation of the position
- The phantom token is accepted as collateral by the Credit Manager (configured by the curator), keeping the account solvent
- When the deposit matures, the phantom token is replaced by the real asset
The user gets 10x leverage on day zero, not after weeks of looping. The curator configures the phantom token's liquidation threshold to reflect settlement risk.
This is why the Credit Account is the right primitive for RWAs and delayed deposits — it holds the entire position (collateral + debt + pending assets) in one isolated contract, making the settlement state visible and manageable at the protocol level.
The Lending Stack
Capital flows through three layers: from liquidity source, through a Credit Manager, into Credit Accounts that interact with DeFi.
Layer 1: Liquidity Source
Where the capital comes from. Two models, same Credit Account primitive underneath:
- Gearbox Markets (pooled) — many lenders deposit into a shared Pool. Dynamic rates based on utilization. Quotas limit per-token exposure.
- Intent-Based (P2P) — one lender matches one borrower directly. Fixed or reference-based rates (LIBOR + 2%). Custom terms per deal.
Layer 2: Credit Manager
The policy keeper. Each Credit Manager defines the rules: which collateral tokens are accepted, which DeFi protocols can be used, what leverage is allowed. The Credit Manager borrows from the liquidity source and allocates to Credit Accounts.
Layer 3: Credit Accounts → DeFi
The execution layer. Each Credit Account is an isolated contract holding collateral + borrowed funds. Through Adapters, it interacts with external DeFi protocols — swap on Uniswap, stake on Lido, deposit on Curve. Multicalls batch all operations into a single atomic transaction with a solvency check at the end.
Zoom Into the Credit Account
The Credit Account is the foundation of the entire stack. Everything — markets, P2P lending, leveraged farming, RWA settlement — is built by composing operations on top of this single primitive. Here's what makes it work.
Multi-Collateral Solvency
A Credit Account can hold many tokens simultaneously — WETH, USDC, stETH, CRV LP tokens, phantom tokens. The Credit Manager iterates over all of them to compute the account's value:
For each token in the account:
- Get the price from a dual oracle —
min(main feed, reserve feed)— protection against manipulation - Apply the Liquidation Threshold — e.g., WETH at 90% means $100 of ETH counts as $90
- Cap the contribution by the token's Quota — concentration limit per token
- Sum into the Total Weighted Value (TWV)
Then:
Health Factor = TWV / Total Debt
where Total Debt = principal + accrued interest + quota fees
If HF >= 1 → account is solvent. If HF < 1 → account is liquidatable.
Check-on-Exit: The Execution Model
The Credit Account doesn't check solvency on every operation — only at the end of a multicall. This is the check-on-exit model:
Example: building a leveraged stETH position
addCollateral— deposit $100 USDCincreaseDebt— borrow $900 USDC from Poolswap(via Uniswap adapter) — swap $1,000 USDC → WETHstake(via Lido adapter) — stake WETH → stETHdeposit(via Curve adapter) — deposit stETH into Curve pool- Final check: HF >= 1? → Yes: TX succeeds. No: entire TX reverts.
Between steps 2 and 5, the account is temporarily insolvent — it has $900 debt but collateral is mid-transformation. This is fine because all operations are atomic: if the final check fails, everything reverts as if nothing happened. No bad debt can ever be created.
The Building Block
This is why every product on Gearbox reduces to the same primitive:
| Product | What Happens Inside the Credit Account |
|---|---|
| Leveraged Farming | Borrow → swap → deposit into yield vault |
| Margin Trading | Borrow → swap to long/short asset |
| RWA Settlement | Borrow → deposit with issuer → hold phantom token |
| Structured Credit | P2P terms → borrow → deploy into strategy |
The Credit Manager defines which operations and tokens are allowed. The Credit Account executes them. The solvency check enforces safety. Everything else — pools, quotas, insurance, oracles — exists to support this core loop.
Deep Dive
- Credit Accounts — The Credit Suite architecture (Manager, Facade, Configurator), account lifecycle, and configuration parameters
- Multicall System — All available operations, the diff pattern, safety controls, and bot permissions
- Health Factor & Risk — TWV formula, Liquidation Thresholds, Quotas, Dual Oracle, Loss Policy, and liquidation mechanics
What's Next
- Gearbox Markets — The pooled lending product built on top of this stack
- Start building — Install the SDK and make your first call