DocumentationOpen App

Credit Facade

The CreditFacadeV3 is the primary user-facing interface for Credit Account operations. It implements atomic multicall batching, enforces debt limits, manages bot permissions, and ensures all operations complete with a healthy account state.

Core Data Structures

MultiCall

Solidity
struct MultiCall { address target; // Facade itself or whitelisted adapter bytes callData; // Function selector + encoded arguments }

DebtLimits

Solidity
struct DebtLimits { uint128 minDebt; // Minimum principal (except 0) uint128 maxDebt; // Maximum principal }

Bot Permissions

Bot permissions are stored as a uint192 bitmask:

PermissionValueOperation
ADD_COLLATERAL_PERMISSION1 << 0Add funds to account
INCREASE_DEBT_PERMISSION1 << 1Borrow more from pool
DECREASE_DEBT_PERMISSION1 << 2Repay debt
WITHDRAW_COLLATERAL_PERMISSION1 << 5Withdraw assets
UPDATE_QUOTA_PERMISSION1 << 6Change token quotas
EXTERNAL_CALLS_PERMISSION1 << 16Execute adapter calls

Write Methods

openCreditAccount

Creates a new Credit Account with initial operations executed atomically.

Solidity
function openCreditAccount( MultiCall[] calldata calls, address onBehalfOf ) external returns (address creditAccount);
ParameterTypeDescription
callsMultiCall[]Initial operations (add collateral, increase debt, etc.)
onBehalfOfaddressOwner of the new Credit Account

Returns: Address of the created Credit Account.

Access: Anyone. A full collateral check is performed after all calls execute.


closeCreditAccount

Closes a Credit Account, repaying all debt and returning remaining assets.

Solidity
function closeCreditAccount( address creditAccount, MultiCall[] calldata calls ) external;
ParameterTypeDescription
creditAccountaddressAccount to close
callsMultiCall[]Operations to execute before closing (e.g., swap to underlying)

Access: Account owner only (creditAccountOwnerOnly).


multicall

Executes a batch of operations on an existing Credit Account.

Solidity
function multicall( address creditAccount, MultiCall[] calldata calls ) external;
ParameterTypeDescription
creditAccountaddressTarget account
callsMultiCall[]Operations to execute

Access: Account owner only. Full collateral check after execution.


botMulticall

Executes a batch of operations initiated by an authorized bot.

Solidity
function botMulticall( address creditAccount, MultiCall[] calldata calls ) external;
ParameterTypeDescription
creditAccountaddressTarget account
callsMultiCall[]Operations to execute

Access: Authorized bot only. Each operation is checked against the bot's permission bitmask.


liquidateCreditAccount

Liquidates an unhealthy Credit Account (HF < 1.0).

Solidity
function liquidateCreditAccount( address creditAccount, address to, MultiCall[] calldata calls ) external;
ParameterTypeDescription
creditAccountaddressAccount to liquidate
toaddressRecipient of remaining funds
callsMultiCall[]Operations to execute during liquidation

Access: Anyone (account must be liquidatable).


setBotPermissions

Grants or revokes bot permissions for a Credit Account.

Solidity
function setBotPermissions( address creditAccount, address bot, uint192 permissions ) external;
ParameterTypeDescription
creditAccountaddressTarget account
botaddressBot address to authorize
permissionsuint192Permission bitmask (0 to revoke)

Access: Account owner only.


Multicall-Only Methods

These methods can only be called as part of a MultiCall array (encoded in callData with the Facade as target).

addCollateral

Solidity
function addCollateral(address token, uint256 amount) external;

Transfers tokens from the caller to the Credit Account.

increaseDebt

Solidity
function increaseDebt(uint256 amount) external;

Borrows additional funds from the pool. Subject to debt limits and per-block caps.

decreaseDebt

Solidity
function decreaseDebt(uint256 amount) external;

Repays debt to the pool.

withdrawCollateral

Solidity
function withdrawCollateral(address token, uint256 amount, address to) external;

Withdraws collateral from the Credit Account to the specified address.

updateQuota

Solidity
function updateQuota(address token, int96 quotaChange, uint96 minQuota) external;

Adjusts the quota for a specific token on the Credit Account.

storeExpectedBalances / compareBalances

Solidity
function storeExpectedBalances(BalanceWithMask[] calldata balances) external; function compareBalances() external;

Slippage protection pair: store expected balances before swaps, then verify after.


View Methods

debtLimits

Returns the min/max debt bounds for this Credit Facade.

Solidity
function debtLimits() external view returns (uint128 minDebt, uint128 maxDebt);

maxDebtPerBlockMultiplier

Returns the per-block borrowing multiplier. Value of 0 means borrowing is disabled.

Solidity
function maxDebtPerBlockMultiplier() external view returns (uint8);

creditManager

Returns the associated Credit Manager address.

Solidity
function creditManager() external view returns (address);

canLiquidate

Checks whether a Credit Account is liquidatable.

Solidity
function canLiquidate(address creditAccount) external view returns (bool);

botPermissions

Returns the permission bitmask for a bot on a specific Credit Account.

Solidity
function botPermissions(address creditAccount, address bot) external view returns (uint192);

expirable / expirationDate

Returns whether this Facade has an expiration date and what it is.

Solidity
function expirable() external view returns (bool); function expirationDate() external view returns (uint40);

Events

StartMultiCall

Solidity
event StartMultiCall(address indexed creditAccount, address indexed caller);

Emitted at the start of a multicall execution.

FinishMultiCall

Solidity
event FinishMultiCall();

Emitted when a multicall completes successfully.

OpenCreditAccount

Solidity
event OpenCreditAccount( address indexed creditAccount, address indexed onBehalfOf, address indexed caller );

Emitted when a Credit Account is opened through the Facade.

CloseCreditAccount

Solidity
event CloseCreditAccount(address indexed creditAccount, address indexed caller);

Emitted when a Credit Account is closed.

LiquidateCreditAccount

Solidity
event LiquidateCreditAccount( address indexed creditAccount, address indexed liquidator, address indexed to, uint256 remainingFunds );

Emitted when a Credit Account is liquidated.

SetBotPermissions

Solidity
event SetBotPermissions( address indexed creditAccount, address indexed bot, uint192 permissions );

Emitted when bot permissions are updated.