Debt Management

Borrow from or repay to the pool.

For Solidity implementation, see Debt Management.

Why

You manage debt when:

  • Increasing leverage - Borrow more to amplify exposure

  • Taking profit - Repay debt while keeping collateral positions

  • Reducing risk - Lower debt to improve health factor

  • Closing account - Repay all debt before withdrawal

Debt operations affect your health factor: borrowing decreases it, repaying increases it.

What

Increase Debt

increaseDebt borrows the underlying asset from the pool to your Credit Account:

  1. Pool transfers underlying to Credit Account

  2. Debt parameters (principal + interest) are recalculated

  3. Health factor decreases

Decrease Debt

decreaseDebt repays debt from Credit Account's underlying balance:

  1. Underlying is transferred from Credit Account to pool

  2. Debt parameters are recalculated

  3. Health factor increases

Repayment order (when not paying full debt):

  1. Quota-related fees (quota increase fees)

  2. Accrued quota interest

  3. Interest + interest fee (split pro-rata if partial)

  4. Principal

This means partial payments may not reduce your principal at all.

How

Borrow More

Repay Debt

Repay All Debt

Pass type(uint256).max equivalent to repay everything:

Common Pattern: Add Collateral + Borrow

Gotchas

One Debt Update Per Block

You cannot increase AND decrease debt in the same block. This constraint prevents manipulation:

Zero All Quotas Before Full Repayment

Non-zero quotas with zero debt is an invalid state. Zero your quotas BEFORE the final debt repayment:

Debt Must Stay in Range

After any debt change, the principal must be either:

  • Zero (fully repaid), OR

  • Within [minDebt, maxDebt] range

You cannot have debt between 0 and minDebt.

Forbidden Tokens Block Borrowing

If your account has forbidden tokens enabled as collateral, you cannot increase debt. Disable them first.

Interest Accrues Continuously

When repaying "the full amount", the debt may have grown since you read it. Add a buffer:

Cannot Decrease on Open / Increase on Close

  • decreaseDebt is prohibited when opening an account

  • increaseDebt is prohibited when closing an account

This prevents gaming the system by borrowing during liquidation or repaying during account creation.

See Also

Last updated