Skip to main content
Gearbox Protocol uses several enums to represent different modes and actions throughout the system.

ManageDebtAction

Debt management action type.
enum ManageDebtAction {
    INCREASE_DEBT,
    DECREASE_DEBT
}

Values

INCREASE_DEBT
ManageDebtAction
Borrows additional funds from the pool, updates account’s debt and cumulative interest index
DECREASE_DEBT
ManageDebtAction
Repays debt components in order: quota interest and fees → base interest and fees → debt principal. Updates all corresponding state variables (base interest index, quota interest and fees, debt). When repaying all debt, ensures that account has no enabled quotas.

CollateralCalcTask

Collateral and debt calculation mode.
enum CollateralCalcTask {
    GENERIC_PARAMS,
    DEBT_ONLY,
    FULL_COLLATERAL_CHECK_LAZY,
    DEBT_COLLATERAL,
    DEBT_COLLATERAL_SAFE_PRICES
}

Values

GENERIC_PARAMS
CollateralCalcTask
Returns generic data like account debt and cumulative indexes
DEBT_ONLY
CollateralCalcTask
Same as GENERIC_PARAMS but includes more detailed debt info, like accrued base/quota interest and fees
FULL_COLLATERAL_CHECK_LAZY
CollateralCalcTask
Checks whether account is sufficiently collateralized in a lazy fashion, i.e., it stops iterating over collateral tokens once TWV reaches the desired target. Since it may return underestimated TWV, it’s only available for internal use.
DEBT_COLLATERAL
CollateralCalcTask
Same as DEBT_ONLY but also returns total value and total LT-weighted value of account’s tokens. This mode is used during account liquidation.
DEBT_COLLATERAL_SAFE_PRICES
CollateralCalcTask
Same as DEBT_COLLATERAL but uses safe prices (minimum of main and reserve price feeds) from price oracle

AllowanceAction

Token allowance action for configuration.
enum AllowanceAction {
    FORBID,
    ALLOW
}

Values

FORBID
AllowanceAction
Forbids a token, preventing it from being added to accounts or having quotas increased
ALLOW
AllowanceAction
Allows a previously forbidden token

Usage Examples

Managing Debt

// Increase debt
creditManager.manageDebt(
    creditAccount,
    1000e6,
    enabledTokensMask,
    ManageDebtAction.INCREASE_DEBT
);

// Decrease debt
creditManager.manageDebt(
    creditAccount,
    500e6,
    enabledTokensMask,
    ManageDebtAction.DECREASE_DEBT
);

Calculating Collateral

// Get full debt and collateral data for liquidation
CollateralDebtData memory cdd = creditManager.calcDebtAndCollateral(
    creditAccount,
    CollateralCalcTask.DEBT_COLLATERAL
);

// Use safe prices for withdrawals
CollateralDebtData memory cddSafe = creditManager.calcDebtAndCollateral(
    creditAccount,
    CollateralCalcTask.DEBT_COLLATERAL_SAFE_PRICES
);

Token Allowance

// Forbid a risky token
creditFacade.setTokenAllowance(riskyToken, AllowanceAction.FORBID);

// Re-allow it later
creditFacade.setTokenAllowance(riskyToken, AllowanceAction.ALLOW);

Build docs developers (and LLMs) love