Compound III target reserves govern when protocol-held collateral can be bought. Signed base reserves equal base-token cash plus accrued borrows minus accrued supply claims. Cash is the base token the market actually holds. A reserve balance below target permits the collateral-sale gate to pass; it does not establish how much a lender can withdraw.
This walkthrough follows Compound III's CometWithExtendedAssetList implementation at revision f766f51, inspected on 28 October 2026. It explains reference code rather than reporting a live market's balances or governance settings. A deployed proxy's implementation and configuration must be checked separately.
Keep three different numbers in the ledger
“Reserves” can sound like a vault containing a protected pile of tokens. Comet's base reserves are an accounting result. Keep that result separate from the physical token balance and the configured target.
| Quantity | Meaning | Relevant read |
|---|---|---|
| Base cash | Base tokens held by this Comet market | Base token's balance of the Comet address |
| Signed base reserves | Cash plus borrower obligations, less supplier claims | getReserves() |
| Target reserves | Threshold used to stop collateral sales | targetReserves() |
Let C mean cash, B mean accrued aggregate borrowing and S mean accrued aggregate supply. All three must use the same base-token unit. The reserve getter implements R = C + B − S and returns a signed integer.
B is money borrowers owe the market. It cannot be transferred to a withdrawing lender until base tokens are available. S is what the market owes suppliers. Adding C and B before subtracting S therefore answers a different question from counting cash.
Comet also keeps base accounting separate from collateral accounting. Its storage definitions contain a signed principal for each account and separate supply and borrow principal aggregates. In the conversion code, positive principal represents supply and negative principal represents borrowing. Present values apply the matching index, scaled by 10^15. Raw principal totals cannot simply replace S and B.
This is Compound III accounting. A Compound V2 cToken exchange-rate worksheet uses another model.
Cash can change while signed reserves stay fixed
Consider an entirely hypothetical market with six-decimal base token U. At one checkpoint it holds 130 U of cash, owes suppliers 1,000 U and is owed 900 U by borrowers. Target reserves are an invented 50 U.
Signed reserves are 130 + 900 − 1,000 = 30 U. Cash is 130 U; neither 30 U nor 50 U replaces that token balance.
For exact arithmetic, both indices equal their initial 10^15 scale, no time passes, and every amount is exactly representable in token units. Assume ordinary transfers without fees and successful account checks. Each row below starts from that same opening state; the rows are alternative transactions, not a sequence.
| Alternative state | Cash U | Supply U | Borrow U | Reserves U |
|---|---|---|---|---|
| Opening | 130 | 1,000 | 900 | 30 |
| Supplier withdraws 100 U | 30 | 900 | 900 | 30 |
| Borrower draws 100 U | 30 | 1,000 | 1,000 | 30 |
| Borrower repays 100 U | 230 | 1,000 | 800 | 30 |
| Supplier adds 100 U | 230 | 1,100 | 900 | 30 |
A withdrawal reduces cash and the supplier liability together. A new borrow reduces cash while increasing the borrower obligation. A repayment raises cash while reducing that obligation. An ordinary supply raises cash and the supplier liability. The paired changes cancel in the reserve identity under these assumptions.
This exposes a misleading operational claim: “repayment increased reserves by 100.” It increased cash by 100 U here. Signed reserves remained 30 U. Repayment may improve immediate withdrawal liquidity without replenishing the base reserve surplus.
The repayment row assumes an existing debt large enough to take the whole payment. An overpayment can cross the account into positive supply. The minimum-borrow and repayment walkthrough explains that account transition and its limits. Preserve the actual executed changes when applying this ledger to a real transaction.
A lender's claim still needs cash
Suppose one supplier owns a 200 U claim in the opening state and requests 150 U. The claim covers the request, but the market holds only 130 U. The request cannot be funded by those holdings. Positive reserves of 30 U do not fill the 20 U cash gap.
A 100 U withdrawal fits both the assumed claim and available cash. It leaves cash of 30 U and reserves of 30 U, even though reserves were below the 50 U target before the withdrawal. Comet's base withdrawal path contains no target-reserve floor. Subtracting the target from cash would incorrectly invent an 80 U withdrawal ceiling.
The general separation between a claim and an executable exit also appears in the Aave withdrawal-liquidity example. Its account rules belong to Aave. For this Comet example, the supplier stays positive; a base withdrawal that crosses into debt instead needs the borrowing checks.
Target reserves test the start of a collateral purchase
Compound's official liquidation documentation source describes a target for base reserves: collateral purchases stop once reserves reach or exceed it. The target uses base-token units, not a dollar amount or the market's total collateral value.
The pinned collateral-purchase path checks reserves before taking the buyer's base payment. At the 50 U target, the boundary is:
| Signed reserves before the call | Reserve gate |
|---|---|
| −60 U | Passes |
| 30 U | Passes |
| 50 U | Rejects with NotForSale |
| 77.5 U | Rejects with NotForSale |
Negative reserves pass this particular condition. They must remain signed during decoding and comparison; treating −60 as an unsigned quantity destroys the meaning of the check. Passing the reserve condition alone does not prove that a purchase will succeed.
The target is also not a cap on the size of the next payment. Return to opening reserves of 30 U, just 20 U below target. A buyer proposes spending 47.5 U on protocol-held collateral. Assume an unpaused purchase path, sufficient allowance, enough inventory and an acceptable minimum output.
For a checked illustrative quote, give collateral token Z 18 decimals and an oracle price of $100. Assume U's oracle price is $1, the collateral's liquidation factor is 90%, and the storefront factor is 50%. These are invented settings. The documented discount calculation gives 50% × (1 − 90%) = 5%. The discounted price is therefore 95 U per Z, so 47.5 U buys exactly 0.5 Z.
The payment increases cash from 130 U to 177.5 U. It credits no new supplier claim and repays no borrower's account, so S remains 1,000 U and B remains 900 U. Resulting reserves are 177.5 + 900 − 1,000 = 77.5 U.
The call began below target and ended 27.5 U above it. The implementation does not trim that payment to the 20 U gap or repeat the target test after payment. A subsequent purchase would fail the reserve condition at that unchanged state. The historical ChainSecurity Comet assessment, section 5.7 also discusses purchases exceeding the target; the behavior here was checked against the pinned source independently of that older audit.
For inventory, use getCollateralReserves(asset). A raw collateral-token balance can include tokens still owed to users. An attractive quote and an open reserve gate do not establish that the quoted amount is for sale.
Negative reserves can coexist with positive cash
A separate branch from the opening state demonstrates why the sign matters. Assume an eligible borrower owes 90 U and absorption removes that debt with no residual supply credit. One consistent illustrative position has 1 Z worth $100, an 85% liquidation collateral factor and the 90% liquidation factor above: 85 U of liquidation support is below the 90 U debt, while the absorption credit equals 90 U.
The pinned absorption path changes the base ledger without transferring base tokens out. Cash stays 130 U; B falls from 900 U to 810 U; S remains 1,000 U. Signed reserves become 130 + 810 − 1,000 = −60 U.
The protocol now owns the seized collateral separately. Its value is absent from this base reserve formula. Negative base reserves therefore require investigation of both the base shortfall and the collateral inventory; the number alone is not a complete valuation of the protocol's assets. The absorb-versus-buy-collateral walkthrough follows those liquidation stages in detail.
If a different supplier now deposits 100 U, cash becomes 230 U and supply claims become 1,100 U. Reserves are still 230 + 810 − 1,100 = −60 U. More cash improves the immediate payment capacity while adding an equal claim.
Alternatively, sell half the seized Z for the assumed 47.5 U. Cash becomes 177.5 U, supply stays 1,000 U and borrowing stays 810 U. Reserves rise to −12.5 U. The same cash inflow has a different reserve effect because a collateral buyer receives collateral rather than a new base supply claim.
Reconcile the amount needed for the action
Start with one chain, Comet proxy, base-token address, implementation revision and observation block. Keep amounts as raw integers until after comparison. Save the target from that implementation rather than copying a setting from another market.
For the reserve calculation, read base cash, totalSupply(), totalBorrow() and getReserves() at the same block. The pinned aggregate and reserve views project interest to that block's timestamp. If reconstructing from stored principal, apply the matching projected indices and exact integer rounding. The Aave index comparison illustrates why each balance needs its own multiplier; use Comet's actual conversion rules here.
Then branch by the requested action:
- For a supplier exit, compare the proposed amount with that account's accrued claim and the market's transferable base cash. Check withdrawal pause state and authorization. If the result crosses into borrowing, evaluate that resulting debt and collateral too.
- For a collateral purchase, test signed reserves against target, then check buy pause state, the selected collateral's protocol inventory, the quote, minimum output, payment allowance and recipient.
Simulate the exact call with the intended caller and parameters. A later state can differ before inclusion, so retain the confirmed outcome and reconcile resulting balances as well. A withdrawal and a collateral purchase consume different assets and satisfy different conditions; one successful check cannot authorize the other.
In the opening fixture, a useful record reads: cash 130 U, signed reserves 30 U, target 50 U. A 150 U supplier exit lacks cash. A 47.5 U collateral purchase passes the reserve gate and, under the stated inventory and execution assumptions, leaves reserves at 77.5 U. Keeping those outcomes beside their inputs makes the next change explainable.
