Skip to main content
The Credit Manager is the core contract that manages credit accounts, handles collateral checks, debt management, and liquidations.

View Functions

pool

function pool() external view returns (address)
Returns the address of the pool connected to this credit manager.
pool
address
The pool contract address

underlying

function underlying() external view returns (address)
Returns the address of the underlying token.
underlying
address
The underlying token address

creditFacade

function creditFacade() external view returns (address)
Returns the address of the credit facade.
creditFacade
address
The credit facade contract address

creditConfigurator

function creditConfigurator() external view returns (address)
Returns the address of the credit configurator.
creditConfigurator
address
The credit configurator contract address

accountFactory

function accountFactory() external view returns (address)
Returns the address of the account factory.
accountFactory
address
The account factory contract address

priceOracle

function priceOracle() external view returns (address)
Returns the address of the price oracle.
priceOracle
address
The price oracle contract address

poolQuotaKeeper

function poolQuotaKeeper() external view returns (address)
Returns the address of the pool quota keeper.
poolQuotaKeeper
address
The pool quota keeper contract address

name

function name() external view returns (string memory)
Returns the name of the credit manager.
name
string
The credit manager name

Account Management

openCreditAccount

function openCreditAccount(address onBehalfOf) external returns (address)
Opens a new credit account.
onBehalfOf
address
required
The address to open the credit account for
creditAccount
address
The address of the newly created credit account

closeCreditAccount

function closeCreditAccount(address creditAccount) external
Closes a credit account.
creditAccount
address
required
The credit account to close

liquidateCreditAccount

function liquidateCreditAccount(
    address creditAccount,
    CollateralDebtData calldata collateralDebtData,
    address to,
    bool isExpired
) external returns (uint256 remainingFunds, uint256 loss)
Liquidates a credit account.
creditAccount
address
required
The credit account to liquidate
collateralDebtData
CollateralDebtData
required
Collateral and debt data for the account
to
address
required
Address to send remaining funds to
isExpired
bool
required
Whether the account is being liquidated due to expiration
remainingFunds
uint256
Amount of funds remaining after liquidation
loss
uint256
Amount of loss incurred during liquidation

manageDebt

function manageDebt(
    address creditAccount,
    uint256 amount,
    uint256 enabledTokensMask,
    ManageDebtAction action
) external returns (uint256 newDebt, uint256, uint256)
Manages debt for a credit account (increase or decrease).
creditAccount
address
required
The credit account to manage debt for
amount
uint256
required
The amount to increase or decrease debt by
enabledTokensMask
uint256
required
Bitmask of enabled tokens
action
ManageDebtAction
required
The action to perform (INCREASE_DEBT or DECREASE_DEBT)
newDebt
uint256
The new debt amount after the operation

addCollateral

function addCollateral(
    address payer,
    address creditAccount,
    address token,
    uint256 amount
) external returns (uint256)
Adds collateral to a credit account.
payer
address
required
The address paying for the collateral
creditAccount
address
required
The credit account to add collateral to
token
address
required
The token to add as collateral
amount
uint256
required
The amount to add
tokensToEnable
uint256
Bitmask of tokens to enable

withdrawCollateral

function withdrawCollateral(
    address creditAccount,
    address token,
    uint256 amount,
    address to
) external returns (uint256)
Withdraws collateral from a credit account.
creditAccount
address
required
The credit account to withdraw from
token
address
required
The token to withdraw
amount
uint256
required
The amount to withdraw
to
address
required
The recipient address
tokensToDisable
uint256
Bitmask of tokens to disable

externalCall

function externalCall(
    address creditAccount,
    address target,
    bytes calldata callData
) external returns (bytes memory result)
Executes an external call from a credit account.
creditAccount
address
required
The credit account making the call
target
address
required
The target contract address
callData
bytes
required
The call data to send
result
bytes
The result of the external call

approveToken

function approveToken(
    address creditAccount,
    address token,
    address spender,
    uint256 amount
) external
Approves a token for spending from a credit account.
creditAccount
address
required
The credit account
token
address
required
The token to approve
spender
address
required
The address to approve for spending
amount
uint256
required
The amount to approve

Adapters

adapterToContract

function adapterToContract(address adapter) external view returns (address targetContract)
Returns the target contract for an adapter.
adapter
address
required
The adapter address
targetContract
address
The target contract address

contractToAdapter

function contractToAdapter(address targetContract) external view returns (address adapter)
Returns the adapter for a target contract.
targetContract
address
required
The target contract address
adapter
address
The adapter address

execute

function execute(bytes calldata data) external returns (bytes memory result)
Executes an adapter call.
data
bytes
required
The call data
result
bytes
The result of the execution

approveCreditAccount

function approveCreditAccount(address token, uint256 amount) external
Approves a token from the active credit account.
token
address
required
The token to approve
amount
uint256
required
The amount to approve

setActiveCreditAccount

function setActiveCreditAccount(address creditAccount) external
Sets the active credit account for the current adapter call.
creditAccount
address
required
The credit account to set as active

getActiveCreditAccountOrRevert

function getActiveCreditAccountOrRevert() external view returns (address creditAccount)
Returns the active credit account, reverts if none is set.
creditAccount
address
The active credit account address

Collateral Checks

fullCollateralCheck

function fullCollateralCheck(
    address creditAccount,
    uint256 enabledTokensMask,
    uint256[] calldata collateralHints,
    uint16 minHealthFactor,
    bool useSafePrices
) external returns (uint256)
Performs a full collateral check on a credit account.
creditAccount
address
required
The credit account to check
enabledTokensMask
uint256
required
Bitmask of enabled tokens
collateralHints
uint256[]
required
Optional array of token masks to check first
minHealthFactor
uint16
required
Minimum health factor in basis points
useSafePrices
bool
required
Whether to use safe prices from the oracle
enabledTokensMask
uint256
Updated enabled tokens mask

isLiquidatable

function isLiquidatable(
    address creditAccount,
    uint16 minHealthFactor
) external view returns (bool)
Checks if a credit account is liquidatable.
creditAccount
address
required
The credit account to check
minHealthFactor
uint16
required
Minimum health factor in basis points
liquidatable
bool
Whether the account is liquidatable

calcDebtAndCollateral

function calcDebtAndCollateral(
    address creditAccount,
    CollateralCalcTask task
) external view returns (CollateralDebtData memory cdd)
Calculates debt and collateral data for a credit account.
creditAccount
address
required
The credit account to calculate for
task
CollateralCalcTask
required
The calculation task to perform
cdd
CollateralDebtData
The calculated collateral and debt data

Quotas

quotedTokensMask

function quotedTokensMask() external view returns (uint256)
Returns the bitmask of quoted tokens.
quotedTokensMask
uint256
Bitmask of tokens with quotas enabled

updateQuota

function updateQuota(
    address creditAccount,
    address token,
    int96 quotaChange,
    uint96 minQuota,
    uint96 maxQuota
) external returns (uint256 tokensToEnable, uint256 tokensToDisable)
Updates the quota for a token on a credit account.
creditAccount
address
required
The credit account to update quota for
token
address
required
The token to update quota for
quotaChange
int96
required
The change in quota (can be negative)
minQuota
uint96
required
Minimum quota required
maxQuota
uint96
required
Maximum quota allowed
tokensToEnable
uint256
Bitmask of tokens to enable
tokensToDisable
uint256
Bitmask of tokens to disable

Credit Manager Parameters

maxEnabledTokens

function maxEnabledTokens() external view returns (uint8)
Returns the maximum number of enabled tokens allowed per account.
maxEnabledTokens
uint8
Maximum number of enabled tokens

fees

function fees() external view returns (
    uint16 feeInterest,
    uint16 feeLiquidation,
    uint16 liquidationDiscount,
    uint16 feeLiquidationExpired,
    uint16 liquidationDiscountExpired
)
Returns the fee parameters.
feeInterest
uint16
Interest fee in basis points
feeLiquidation
uint16
Liquidation fee in basis points
liquidationDiscount
uint16
Liquidation discount in basis points
feeLiquidationExpired
uint16
Expired liquidation fee in basis points
liquidationDiscountExpired
uint16
Expired liquidation discount in basis points

collateralTokensCount

function collateralTokensCount() external view returns (uint8)
Returns the number of collateral tokens.
count
uint8
Number of collateral tokens

getTokenMaskOrRevert

function getTokenMaskOrRevert(address token) external view returns (uint256 tokenMask)
Returns the token mask for a token, reverts if token is not recognized.
token
address
required
The token address
tokenMask
uint256
The token’s bitmask

getTokenByMask

function getTokenByMask(uint256 tokenMask) external view returns (address token)
Returns the token address for a token mask.
tokenMask
uint256
required
The token mask
token
address
The token address

liquidationThresholds

function liquidationThresholds(address token) external view returns (uint16 lt)
Returns the liquidation threshold for a token.
token
address
required
The token address
lt
uint16
Liquidation threshold in basis points

ltParams

function ltParams(address token) external view returns (
    uint16 ltInitial,
    uint16 ltFinal,
    uint40 timestampRampStart,
    uint24 rampDuration
)
Returns liquidation threshold ramping parameters for a token.
token
address
required
The token address
ltInitial
uint16
Initial liquidation threshold
ltFinal
uint16
Final liquidation threshold
timestampRampStart
uint40
Timestamp when ramping starts
rampDuration
uint24
Duration of the ramp in seconds

collateralTokenByMask

function collateralTokenByMask(uint256 tokenMask) external view returns (
    address token,
    uint16 liquidationThreshold
)
Returns the collateral token and liquidation threshold for a token mask.
tokenMask
uint256
required
The token mask
token
address
The token address
liquidationThreshold
uint16
Liquidation threshold in basis points

Account Info

creditAccountInfo

function creditAccountInfo(address creditAccount) external view returns (
    uint256 debt,
    uint256 cumulativeIndexLastUpdate,
    uint128 cumulativeQuotaInterest,
    uint128 quotaFees,
    uint256 enabledTokensMask,
    uint16 flags,
    uint64 lastDebtUpdate,
    address borrower
)
Returns comprehensive information about a credit account.
creditAccount
address
required
The credit account address
debt
uint256
Current debt amount
cumulativeIndexLastUpdate
uint256
Cumulative index at last update
cumulativeQuotaInterest
uint128
Cumulative quota interest
quotaFees
uint128
Quota fees
enabledTokensMask
uint256
Bitmask of enabled tokens
flags
uint16
Account flags
lastDebtUpdate
uint64
Timestamp of last debt update
borrower
address
Address of the account borrower

getBorrowerOrRevert

function getBorrowerOrRevert(address creditAccount) external view returns (address borrower)
Returns the borrower address for a credit account, reverts if account doesn’t exist.
creditAccount
address
required
The credit account address
borrower
address
The borrower address

flagsOf

function flagsOf(address creditAccount) external view returns (uint16)
Returns the flags for a credit account.
creditAccount
address
required
The credit account address
flags
uint16
Account flags

setFlagFor

function setFlagFor(
    address creditAccount,
    uint16 flag,
    bool value
) external
Sets a flag for a credit account.
creditAccount
address
required
The credit account address
flag
uint16
required
The flag to set
value
bool
required
Whether to enable or disable the flag

enabledTokensMaskOf

function enabledTokensMaskOf(address creditAccount) external view returns (uint256)
Returns the enabled tokens mask for a credit account.
creditAccount
address
required
The credit account address
enabledTokensMask
uint256
Bitmask of enabled tokens

creditAccounts

function creditAccounts() external view returns (address[] memory)
Returns all credit accounts.
accounts
address[]
Array of all credit account addresses
function creditAccounts(
    uint256 offset,
    uint256 limit
) external view returns (address[] memory)
Returns a paginated list of credit accounts.
offset
uint256
required
The starting index
limit
uint256
required
The maximum number of accounts to return
accounts
address[]
Array of credit account addresses

creditAccountsLen

function creditAccountsLen() external view returns (uint256)
Returns the total number of credit accounts.
length
uint256
Total number of credit accounts

Configuration

addToken

function addToken(address token) external
Adds a new collateral token.
token
address
required
The token to add

setCollateralTokenData

function setCollateralTokenData(
    address token,
    uint16 ltInitial,
    uint16 ltFinal,
    uint40 timestampRampStart,
    uint24 rampDuration
) external
Sets collateral token data including liquidation threshold ramping.
token
address
required
The token address
ltInitial
uint16
required
Initial liquidation threshold
ltFinal
uint16
required
Final liquidation threshold
timestampRampStart
uint40
required
Timestamp when ramping starts
rampDuration
uint24
required
Duration of the ramp in seconds

setFees

function setFees(
    uint16 feeInterest,
    uint16 feeLiquidation,
    uint16 liquidationDiscount,
    uint16 feeLiquidationExpired,
    uint16 liquidationDiscountExpired
) external
Sets fee parameters.
feeInterest
uint16
required
Interest fee in basis points
feeLiquidation
uint16
required
Liquidation fee in basis points
liquidationDiscount
uint16
required
Liquidation discount in basis points
feeLiquidationExpired
uint16
required
Expired liquidation fee in basis points
liquidationDiscountExpired
uint16
required
Expired liquidation discount in basis points

setContractAllowance

function setContractAllowance(
    address adapter,
    address targetContract
) external
Sets contract allowance for an adapter.
adapter
address
required
The adapter address
targetContract
address
required
The target contract address

setCreditFacade

function setCreditFacade(address creditFacade) external
Sets the credit facade address.
creditFacade
address
required
The new credit facade address

setPriceOracle

function setPriceOracle(address priceOracle) external
Sets the price oracle address.
priceOracle
address
required
The new price oracle address

setCreditConfigurator

function setCreditConfigurator(address creditConfigurator) external
Sets the credit configurator address.
creditConfigurator
address
required
The new credit configurator address

Build docs developers (and LLMs) love