Skip to content

Research notes

Compound III Collateral Cap vs Borrow Headroom

A full Comet collateral cap can block a deposit while leaving account borrowing room. Follow an exact-cap deposit and a separate collateral withdrawal check.

Filled ivory ceramic tray with a lime slab outside its stop beside a separate cantilever with open clearance.
Illustration for research notes; examples in this article are educational.

In Compound III, a collateral supply cap limits how much of one asset all accounts can deposit into a particular Comet market. Borrow headroom measures an individual account's collateral support after debt. A full cap can block a new collateral deposit while leaving borrowing or withdrawal headroom; check the cap and the proposed account state separately.

This walkthrough follows Compound's CometWithExtendedAssetList reference implementation at revision f766f51, inspected on 28 October 2026. Confirm the implementation and effective parameters of the particular deployed market before applying the method. Compound V2's cToken rules are outside this example.

Give each limit an owner and a unit

A Comet market has one borrowable base asset and supported collateral assets. The collateral cap belongs to one asset in that market. It does not combine deposits across every Compound chain, and it is not a personal allowance.

The storage definitions make the distinction concrete: totalsCollateral records aggregate supplied collateral by asset, while userCollateral records an account's balance by asset. An account's base principal is stored separately.

QuantityWhose limit?Useful unit
Remaining collateral capAll depositors of that asset in one marketCollateral tokens
Borrow headroomOne accountCommon oracle value, then base tokens
Collateral withdrawal headroomOne account after a proposed withdrawalSelected collateral tokens
Available base cashThe market funding a base transferBase tokens

These numbers cannot be compared until their units and purpose agree. A market can accept more collateral even when an account has little borrowing room. An account can also retain borrowing room when the market accepts no more of that collateral.

Our Aave withdrawal walkthrough separates available cash from account support. Comet requires its own implementation check: as the withdrawal example below shows, the borrowing factor governs removal of collateral.

Start with a hypothetical cap and account

Every token, price, balance and parameter in this example is invented. C is an ordinary collateral token with 18 decimals; U is the base token with six decimals. Transfers have no token fee. Prices and indices stay fixed throughout the constructed sequence, all needed transfers are funded, and permissions and pause checks pass.

Opening inputIllustrative value
Effective C supply cap1,000 C
Market C, including this account998 C
This account's supplied C10 C
C oracle price$1,000
U oracle price$1
C borrow collateral factor75%
C liquidate collateral factor85%

The dollar sign denotes the common oracle valuation unit. Assuming U's oracle price is $1 does not establish a stable market price or a redemption guarantee.

The account has negative base principal of 5,000 U in magnitude and a stored borrow index of 1.20. Its resulting base debt is 6,000 U: 5,000 multiplied by 1.20. The raw calculation uses six decimals for U principal and a separate index scale of 10^15.

This conversion follows the negative-principal branch in CometCore. Principal is not the same quantity as the base debt used in a collateral calculation. Likewise, the Aave index comparison explains why an indexed position must be reconstructed with its own implementation's multiplier.

Opening borrowing support is 10 C multiplied by $1,000 and 75%, giving $7,500. Subtracting $6,000 of debt leaves $1,500 of account headroom. Separately, the market has space for 2 C beneath its cap.

A rejected deposit does not partially fill the cap

Suppose this account submits a supply of 3 C. The proposed aggregate becomes 1,001 C, above the 1,000 C cap. The official supply tests explicitly check that over-cap collateral supply reverts with SupplyCapExceeded.

The account's existing headroom cannot authorize that extra C. Nor does the contract automatically accept the 2 C that would fit. The reverted call leaves the account at 10 C and the market at 998 C. Gas paid for a failed transaction is separate from this collateral ledger.

Now submit a separate 2 C deposit, with the same observed state. Aggregate supplied C reaches exactly 1,000 C; the account reaches 12 C. The collateral supply implementation rejects a resulting total greater than the cap, so equality passes that comparison.

State after the stated actionMarket CAccount CCap space, CAccount headroom, U
Opening snapshot9981021,500
Supply 3 C reverts9981021,500
Separate supply of 2 C succeeds1,0001203,000

The last column uses U's assumed $1 oracle price. After the accepted deposit, account support is $9,000 and debt remains $6,000.

A zero in the cap space column therefore coexists with 3,000 U of borrowing headroom. Additional base borrowing would not add C to the aggregate collateral total. Its execution would still need available base tokens and the other borrowing checks. The minimum-borrow comparison explains the separate baseBorrowMin constraint.

Cap occupancy also says little about the interest cost of borrowing U. That depends on the market's configured borrow rate curve and utilization, covered in the Comet utilization and kink walkthrough.

Test an existing collateral withdrawal separately

Start each proposed withdrawal below from the accepted-deposit snapshot: 12 C in the account, 1,000 C across the market and 6,000 U owed.

Each C removed takes away $750 of borrowing support: $1,000 multiplied by 75%. The account has $3,000 of headroom, so its mathematical withdrawal boundary is 4 C.

Equivalently, $6,000 of debt requires 8 C at those prices and that factor. With 12 C initially supplied, 4 C can leave while preserving equality. This reaches the protocol's mathematical boundary without an operating buffer.

Proposed withdrawalC remainingBorrowing supportHeadroom afterwardAccount test
3 C9$6,750$750Passes
4 C8$6,000$0Equality passes
4.1 C7.9$5,925−$75Fails

The rows model proposed outcomes, including the rejected request. They are not three completed transactions.

In the pinned withdrawal path, collateral balances are reduced before isBorrowCollateralized is checked; failure reverts the changes. The withdrawal tests separately confirm rejection when removed collateral would leave borrowing uncovered.

A failed 4.1 C withdrawal thus leaves 12 C in the account and 1,000 C in the market. A successful 4 C withdrawal instead leaves 8 C and 996 C respectively. That successful withdrawal opens 4 C of market cap space even though this account now has zero borrowing headroom.

A withdrawal rejection need not mean liquidation

The 85% liquidate collateral factor answers a different question. After the hypothetical 4.1 C removal, 7.9 C would provide $6,715 under that factor, exceeding the $6,000 debt. Yet the borrowing factor calculation fails.

Comet's two collateralization checks use the respective factors. Being outside liquidation eligibility does not grant permission to remove more collateral.

Using 85% for this withdrawal would overstate removable C. Using the market's remaining supply cap as a withdrawal ceiling would also answer the wrong question.

Change the constraint that actually binds

Consider two independent alternatives from the full-cap snapshot with 12 C and 6,000 U debt.

If the effective cap increases to 1,010 C, deposit capacity increases to 10 C. The account still has $9,000 of support and $6,000 debt, leaving $3,000 of headroom.

If the account instead repays 1,500 U from an external wallet, debt becomes 4,500 U. Account headroom rises to $4,500, but aggregate supplied C remains 1,000 C. Repayment supplies the base token; it does not remove C from the collateral ledger.

Under the unchanged price and factor, that repayment would increase the mathematical C withdrawal boundary to 6 C. Raising the C cap alone would leave the original 4 C boundary unchanged.

A later deposit must still use the aggregate observed when it executes. Cap space freed by a withdrawal is shared market capacity; it is not reserved for the person who withdrew.

Reproduce the check before submitting a call

Keep a record that can explain both the accepted and rejected amounts:

  1. Identify the chain, Comet proxy, implementation, base token and collateral address. Record one block number and timestamp for the snapshot.
  2. Read the effective asset information, including supplyCap, token scale, price feed and both collateral factors. The AssetList implementation packs caps in whole-token units and factors at limited precision, then returns rescaled values. Prefer those effective values to an unprocessed configuration input.
  3. Record aggregate totalSupplyAsset, the account's collateral balances, signed base principal, base indices and oracle prices. For several collateral assets, add their contributions using each asset's own price and borrowing factor. Reconstruct the proposed account with integer arithmetic before formatting decimals.
  4. For a deposit, test the aggregate after the amount actually received. For a withdrawal, test the remaining account support and confirm the selected asset and amount can transfer.
  5. Simulate the exact call with its caller, asset, amount and recipient. Save the outcome, then reconcile confirmed balances and events after execution.

Timing matters even at one observation block. In this reference, collateral withdrawal does not accrue the base index first, and its account check uses the present value from the stored index. The borrowBalanceOf getter projects an updated index, while a base withdrawal accrues before its checks. Those paths are visible in the pinned implementation. A projected debt display can therefore differ from the collateral withdrawal check. Our fixture assumes the stored index is current and unchanged.

For the full-cap fixture, retain four separate results: zero C of deposit capacity, 3,000 U of borrowing headroom, a 4 C collateral-withdrawal boundary, and the separately verified ability to fund the proposed transfer. Recompute them when debt, prices, configuration or aggregate deposits change.

Keep the context with the example.

Each worked example is illustrative, with its sources and assumptions in the article. Read our editorial standards for authorship, verification and corrections.