In Compound III, baseBorrowMin constrains a base withdrawal that leaves the account owing the base asset. Supplying base can reduce debt to a remainder below that minimum, clear it completely, or create a positive supply balance with the excess. The minimum applies to the borrowing path’s resulting balance; it is not a minimum repayment amount.
This explanation follows Compound III’s Comet implementation, specifically CometWithExtendedAssetList and CometCore at revision f766f51, checked on 28 October 2026. A deployed market’s proxy, implementation and configuration still need verification. Compound V2 cToken accounting is outside this walkthrough.
Read the balance before the transaction label
A Comet market has one base asset. Its account stores a signed principal: a negative value represents borrowing, and a positive value represents supplied base. The present balance applies the matching borrow or supply index. The official borrowing documentation describes this shared balance and the supply methods that change it.
Consequently, a button labeled “Supply” can produce three outcomes for a borrower. It can reduce debt, reach zero, or cross into positive supply. The amount entering the protocol does not automatically become an interest-earning balance alongside an unchanged loan.
The asset matters. Supplying an approved collateral token increases that collateral holding. Repaying the base loan requires supplying the market’s base token. More collateral may improve borrowing capacity while leaving the base debt intact. The supply-cap versus borrow-headroom comparison separates those collateral limits from changes to the loan.
| Operation | Account effect | Relevant minimum test |
|---|---|---|
| Supply base while owing base | Reduces debt; excess becomes supply | No baseBorrowMin check on this supply path |
| Supply a collateral asset | Adds that collateral | Separate collateral rules |
| Withdraw base while remaining positive | Reduces supplied base | No negative balance to test |
| Withdraw base into a negative balance | Creates or increases borrowing | Computed debt must reach baseBorrowMin |
The pinned base-supply path adds received base to the signed present balance without applying a baseBorrowMin guard.
The minimum concerns the resulting loan
Read baseBorrowMin from the selected Comet market and interpret it using the base token’s decimals. A raw value of 1,000,000,000 represents 1,000 tokens for a six-decimal base asset. That example is hypothetical; the parameter is market-specific.
In the pinned base-withdrawal implementation, Comet subtracts the requested amount from the accrued signed present balance. If that result is negative, its magnitude must be at least baseBorrowMin. Collateral adequacy is a separate check.
The documentation’s summary that subsequent borrows can be any size describes an ordinary loan already above the threshold. A 1 U addition to a 1,250 U loan can satisfy a 1,000 U minimum. After repayment has reduced debt to 750 U, another 1 U withdrawal leaves only 751 U owed and fails the minimum test.
“Initial borrowing only” is therefore an incomplete rule for an account that has partially repaid. Test the proposed resulting negative balance each time.
Follow a repayment through zero
The following original example is an illustrative state replay, not an observed account. U is a hypothetical six-decimal base token. Assume sufficient collateral, transferable protocol cash, payer funds and allowance; supplies transfer their full stated amount without token fees. Operations use already-accrued indices held fixed at one timestamp, so the example isolates balance transitions rather than forecasting interest.
Set the borrow index to 1.25 and the supply index to 1.10. Their raw values are 1,250,000,000,000,000 and 1,100,000,000,000,000 because Comet’s base index scale is 10^15. Set baseBorrowMin to 1,000 U.
The pinned conversion helpers multiply principal magnitude by its index and divide by that scale. Both present-value magnitudes round down. Converting a negative present balance back to principal rounds the magnitude up; converting positive supply back rounds down.
Start with zero principal and withdraw 1,250 U against the assumed collateral. The resulting debt exceeds the illustrative minimum. The stored principal is −1,000,000,000: its magnitude multiplied by 1.25 gives 1,250,000,000 raw U, or 1,250 U.
Now supply 500 U. The signed present balance becomes −1,250 + 500 = −750 U. Its new stored principal is −600,000,000. Debt remains outstanding below the 1,000 U threshold because repayment uses the supply path.
Finally, supply another 805 U. Adding it to −750 U produces +55 U. The debt is cleared, and positive principal becomes 50,000,000 raw units: 55,000,000 raw U units divided by the supply index of 1.10.
| Confirmed illustrative state | Debt, U | Supplied base, U | Stored principal, raw |
|---|---|---|---|
| Before borrowing | 0 | 0 | 0 |
| After withdrawing 1,250 U | 1,250 | 0 | −1,000,000,000 |
| After supplying 500 U | 750 | 0 | −600,000,000 |
| After supplying another 805 U | 0 | 55 | +50,000,000 |
All divisions in this main sequence are exact. The total supplied back is 1,305 U: 1,250 U settles the loan and 55 U remains supplied. That 55 U is added capital, not interest earned during the example.
The last operation adds 50,000,000 units to aggregate supply principal and removes 600,000,000 units of borrow principal attributable to this account. Record the 805 U incoming transfer separately from these two principal changes.
Test a small withdrawal after repayment
The next requests are independent branches from the stated opening balances. They are not additional steps in the preceding timeline. “Passes” refers only to the minimum test; all other assumptions still apply.
| Starting signed balance | Base withdrawal | Computed balance afterward | Minimum test |
|---|---|---|---|
| 0 U | 1 U | −1 U | Fails |
| −1,250 U | 1 U | −1,251 U | Passes |
| −750 U | 1 U | −751 U | Fails |
| −750 U | 250 U | −1,000 U | Passes at equality |
| +55 U | 100 U | −45 U | Fails |
A failed call leaves the prior state unchanged. In the 751 U row, the account still owes 750 U afterward; the rejected proposal does not create an extra 1 U of debt.
There is also an exact boundary worth preserving in an integration. Starting at −750 U, withdrawing 249.999999 U produces a computed balance of −999.999999 U. It fails. Although converting that proposed debt to rounded principal would reconstruct 1,000 U at the chosen index, the checked code compares the minimum with the computed present balance. Rounding a display to “1,000” cannot make this request pass.
This is why the transaction amount, the threshold comparison and the saved principal belong in separate fields.
Use current debt when the goal is closure
A wallet’s older debt display can become stale as borrow interest accrues. The official interest-rate reference describes separate supply and borrow curves. While principal is negative, the borrow side determines accrued debt; after crossing positive, the supply side determines future base interest.
For ordinary base supplies, Comet recognizes the maximum unsigned integer, MaxUint256, as a request to repay the destination’s accrued base debt. The official supply tests cover that behavior, including a destination with no debt, for which the resolved amount is zero. This sentinel does not request the payer’s entire wallet balance or an extra positive supply position.
The payer still needs sufficient underlying and token approval. If using supplyTo, verify which address receives the repayment credit; if using a manager route, verify its permissions. A user interface can impose additional rules, so inspect the actual call rather than inferring the contract argument from “Max.”
The Aave supply-index versus debt-index walkthrough offers another example of matching a balance to its own multiplier. Comet uses its own scale, signed principal and rounding rules; copy the method of checking inputs, not Aave’s formulas.
Reconcile the result in raw units
The main example chooses exact divisions, but arbitrary amounts can round. In a separate illustrative fixture, supplying three raw U units, or 0.000003 U, from zero at supply index 1.10 creates two raw principal units. Reconstructing the visible claim gives two raw U units. A successful small supply call therefore need not increase the visible claim by exactly the amount sent.
Save raw integers before formatting. Use the official balance-helper reference alongside the implementation’s current-balance getters. An effective repayment record includes:
| Evidence | Validation |
|---|---|
| Chain, Comet proxy and base token | The payment reaches the intended market and asset |
| Block, timestamp and implementation | All calculations describe the same state |
| Principal and current debt | The starting liability includes accrued interest |
| baseBorrowMin and decimals | The parameter uses the intended token units |
| Caller, payer, destination and amount | The right account is funded and credited |
| Confirmed supply and balances | Actual token flow agrees with debt and supply changes |
After confirmation, read both borrowBalanceOf and balanceOf, and inspect principal. For the final main-example state, the expected pair is zero debt and 55 U supplied, with positive principal of 50,000,000. A successful transaction receipt alone does not prove that this was its effect.
If a repayment fails, check the supply pause, funding, allowance, asset and route before attributing the failure to baseBorrowMin. A positive balance also does not establish immediate withdrawal liquidity. The withdrawal-liquidity walkthrough illustrates why cash availability deserves its own check; Compound’s target reserves versus liquidity explains the Comet-specific distinction.
For a partial repayment, retain the remaining current debt even when it is below the borrow minimum. For closure, verify zero debt. For an intentional surplus, record the resulting positive claim separately from the amount that settled the loan.
