Compound v3

Compound v3 repayment, withdrawals, and remaining rewards

Updated on

Compound v3 changes future reward participation when repayment or withdrawal changes an account's base-asset balance, while preserving previously accrued rewards. Full repayment ends borrowing; withdrawing the entire supplied balance ends supply participation. Partial changes leave a smaller position, whose future rewards depend on the applicable market configuration. Crossing zero changes the position's side: excess repayment becomes supply, and excess withdrawal can become borrowing. Claiming accumulated rewards remains a separate operation.

Reducing debt or withdrawing supplied funds

Repayment reduces an existing base-asset debt, while withdrawing supplied base assets returns funds from a positive balance. The relevant choice follows the position that the account already holds. A borrower must supply the market's base asset to repay. A supplier can withdraw part or all of the supplied balance, subject to the contract's ability to complete the transfer.

Keeping a partial position preserves exposure to its interest model and any eligible future rewards. Closing it removes that ongoing base-asset participation. Neither choice requires keeping debt open merely to preserve rewards already accrued. The amount remaining after execution matters more than the transaction label, particularly when the requested amount crosses the boundary between supplying and borrowing.


Principal, interest, and the zero-balance boundary

Comet, the Compound v3 market contract, records an account's base position as signed principal. Positive principal represents supply, negative principal represents borrowing, and zero represents neither. Interest indices convert that principal into the balance applicable at the transaction's execution time. Consequently, the amount originally borrowed may differ from the amount required to close the debt.

The balance functions answer different questions. balanceOf returns supplied base assets, including interest, and returns zero for a borrowing account. borrowBalanceOf returns outstanding base debt, including interest. Reading only the supply balance cannot establish that an account has exited: a borrower also has a zero supply balance. Reward tracking uses separate accounting from either interest-bearing balance.

Does repaying a loan erase accrued rewards?

Repaying a loan does not erase the account's previously accrued reward tracking. During a base-balance update, Comet accounts for the elapsed reward-index change using the old principal. It then records the new principal and the tracking index appropriate to the resulting side.

A base-balance update adds newly accrued tracking to the account's existing accrued total. Full repayment therefore ends the old borrowing participation without resetting its accumulated record. A reward display can increase at repayment because the transaction brings stored accounting up to date. That increase reflects preceding eligible participation, rather than a separate reward for closing the loan.

Partial repayment and excess base-asset supply

The repayment amount determines whether debt remains, reaches zero, or turns into a positive supply balance. These outcomes carry different future interest and reward conditions.

Amounts around the outstanding debt

Below the debt balance

A partial repayment leaves borrowing principal. Interest continues on the remaining debt, and that principal continues to participate in borrower reward tracking when the borrowing side qualifies. The operation changes the account's participation weight. It does not establish a fixed reduction in future token rewards, because market participation and reward settings also affect accrual.

Above the debt balance

Supplying more base assets than the outstanding debt first repays the loan and then creates supply principal. That excess follows supplier interest and reward conditions. Borrower eligibility does not carry over automatically. An account can therefore clear its debt successfully while retaining funds in the protocol.

Closing the debt without intentional excess

For base-asset supply, the contract supports MaxUint256 as an instruction to repay the destination account's full accrued borrowing balance. The payer still needs sufficient tokens and allowance. An integration must deliberately use that supported behavior; the wording of a repayment button alone does not establish which amount its transaction submits.


When does a base-asset withdrawal become borrowing?

A base-asset withdrawal becomes borrowing when its amount exceeds the account's available supplied balance and leaves a negative base balance. Comet uses the same withdrawal operation for both outcomes. The new debt must meet the market's borrowing minimum and collateral requirements, or the transaction reverts.

This boundary matters when the objective is to leave the market. A withdrawal that creates debt also creates borrowing interest and collateral exposure. Any borrower rewards then depend on borrower eligibility. Withdrawing within the positive balance instead leaves smaller supply participation or closes it. The contract's full-balance withdrawal instruction applies to supplied base assets.

Collateral withdrawals leave the debt in place

Removing collateral does not repay the base-asset loan. The account retains its borrowing balance, while the withdrawal reduces the collateral available to support it. Comet rejects a collateral withdrawal that fails the borrowing collateralization check. Collateral alone does not generate base-asset participation rewards, so removing it does not directly reduce reward-bearing principal. The practical consequence is reduced borrowing headroom while debt remains. Passing a withdrawal check also does not fix future collateral prices or prevent interest from increasing the outstanding debt.


Reward eligibility after the balance changes

Future reward tracking depends on the resulting side, its configured reward speed, and the market-wide principal total for that side. A smaller position remains relevant only while those conditions permit accrual.

Reward eligibility after the balance changes: Future reward tracking depends on the resulting side, its configured reward speed, and the market-wide principal total for that side.; A smaller position remains relevant only while those conditions permit accrual.

Open full-size image

Comet applies the reward threshold separately to total supply principal and total borrowing principal. The parameter baseMinForRewards is therefore not a personal deposit minimum. A repayment or withdrawal can also change whether the affected market side clears that threshold. Governance can change reward speeds and configuration, so a previous reward estimate does not establish the return after a balance change.

A repayment choice through transaction confirmation

Consider a borrowing account choosing between partial repayment and closing its debt. Assume its borrowing participation currently qualifies for rewards. Both options require base assets that the payer controls and sufficient token allowance. A missing allowance prevents execution even when the wallet holds enough tokens.

Choose partial repayment to retain some debt or full repayment to close it. In this example, the borrower chooses full repayment and leaves collateral withdrawal and reward claiming as separate decisions.

A repayment choice through transaction confirmation
Stage Repayment action or observation Funds and transaction status
Establish the starting position Read outstanding debt, accrued rewards, token balance, and allowance for the selected account. The wallet controls repayment tokens; Comet holds deposited collateral.
Choose the remaining debt Compare partial repayment with full repayment, then select closure. No repayment has occurred; the amount remains changeable.
Resolve missing authorization Provide sufficient base-token allowance if the existing allowance is inadequate. Approval permits spending but does not itself repay debt.
Submit the repayment Execute the supported base-asset supply operation for full accrued debt. The payer authorizes movement of repayment tokens into Comet.
Confirm execution Check that the transaction succeeded and the account has no remaining borrow balance. Borrowing again after repayment requires a new transaction.
Reconcile remaining balances Inspect any supplied excess, retained collateral, and unpaid rewards. Collateral and reward tokens require their respective withdrawal or claim operations.

If the transaction fails, the expected debt closure has not occurred. An earlier approval may still remain active. If execution succeeds but debt remains, the observed result invalidates the assumption of full repayment; reconcile the account, submitted amount, and accrued balance before sending another transaction.


Can rewards be claimed after closing the position?

Previously accrued rewards can remain claimable after the base-asset position closes, provided the relevant rewards contract supports the market and can complete payment. Closing the position does not itself transfer reward tokens into the wallet.

The rewards contract converts accrued tracking into reward-token units and subtracts rewards already claimed. Its getRewardOwed operation returns the token and outstanding amount. Claiming with accrual enabled refreshes accounting before payment. These distinctions explain why a retained accrued total, a smaller unpaid amount, and an empty supplied balance can coexist without contradiction. Payment also requires sufficient reward tokens in the paying contract and a successful token transfer.


Unfinished exits and the next transaction

Repayment, collateral withdrawal, and reward claiming have separate completion conditions. A successful repayment does not prove that collateral reached the wallet. Likewise, a successful withdrawal does not prove that reward tokens arrived. Supply and withdrawal pauses can independently block their respective operations; repayment uses the supply path and inherits its pause condition.

Before signing and submitting the repayment, you can change its amount or abandon it. Until repayment executes, debt remains outstanding and interest and eligible rewards can continue to accrue. A completed transaction has no equivalent undo operation. Reopening borrowing requires another permitted loan, and restoring withdrawn supply requires another deposit. After closure, the next decision concerns whatever remains: deposited collateral, unintended base-asset supply, or unpaid rewards. Each calls for its own operation, rather than repeating the repayment.

Questions and answers

Can I repay by sending base tokens directly to the Comet address?

A direct token transfer does not credit repayment to your borrowing account. Repayment requires the protocol's supply operation, which updates the account balance. Sending tokens to the contract through an ordinary wallet transfer bypasses that accounting and can leave the debt unchanged.

Does a reward claim automatically reduce my remaining debt?

A reward claim transfers reward tokens to its recipient without automatically repaying the loan. Debt reduction requires a separate base-asset supply operation. The reward token and the market's base asset need not be the same token, so a reward balance is not automatically available for repayment.

What happens if I claim after repayment with accrual disabled?

The claim uses the reward tracking already stored for the account. A successful base-asset repayment updates that tracking, but disabling accrual skips any later update during the claim. This matters when partial repayment leaves a position that continues to accrue rewards.

Do I need to approve reward-token spending before claiming after withdrawal?

A direct reward claim does not require approval to spend reward tokens from your wallet. The rewards contract sends tokens that it holds to the recipient. This differs from repayment, where Comet needs sufficient allowance to take base assets from the payer.

Is a successful claim transaction proof that rewards were paid?

A successful claim transaction can transfer nothing when no additional reward amount is owed. The contract transfers tokens only when converted accrued rewards exceed the amount already claimed. A reward-transfer event and the recipient's token balance establish payment more precisely than transaction success alone.