Credit Operations

Interact with CreditFacade and CreditManager from Solidity.

For SDK credit account operations, see Credit Accounts.

ICreditFacadeV3

The CreditFacade is the primary entry point for all user operations.

Core Functions

import {ICreditFacadeV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditFacadeV3.sol";
import {MultiCall} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditFacadeV3.sol";

ICreditFacadeV3 facade = ICreditFacadeV3(facadeAddress);
Function
Purpose

openCreditAccount

Create new credit account

closeCreditAccount

Close and return funds

multicall

Execute operations on existing account

botMulticall

Bot-initiated operations

liquidateCreditAccount

Liquidate unhealthy account

Opening a Credit Account

function openCreditAccount(
    address onBehalfOf,
    MultiCall[] calldata calls,
    uint256 referralCode
) external payable returns (address creditAccount);

Example:

Closing a Credit Account

The close multicall typically includes operations to:

  1. Swap all tokens back to underlying

  2. Repay remaining debt

  3. Withdraw remaining funds to owner

Executing Operations on Existing Account

ICreditManagerV3

The CreditManager handles internal logic. Use it for reading state, not for user operations.

Reading Account State

The most important function for determining solvency:

Example:

Reading Configuration

Collateral Tokens

Adapter Discovery

Complete Example

Next Steps

For architectural background, see Credit Suite Architecture.

Last updated