Skip to main content

ICollateralManager

Functions

getVault

  function getVault(
) external returns (address)

Get the address of vault

Return Values:

NameTypeDescription
vaultaddressaddress of vault

getClearingHouseConfig

  function getClearingHouseConfig(
) external returns (address)

Get the address of clearing house config

Return Values:

NameTypeDescription
clearingHouseConfigaddressaddress of clearing house config

getCollateralConfig

  function getCollateralConfig(
address token
) external returns (struct Collateral.Config)

Get collateral config by token address

Parameters:

NameTypeDescription
tokenaddressaddress of token

Return Values:

NameTypeDescription
collateralstruct Collateral.Configconfig

getPriceFeedDecimals

  function getPriceFeedDecimals(
address token
) external returns (uint8)

Get price feed decimals of the collateral token

Parameters:

NameTypeDescription
tokenaddressaddress of token

Return Values:

NameTypeDescription
decimalsuint8of the price feed

getPrice

  function getPrice(
address token
) external returns (uint256)

Get the price of the collateral token

Parameters:

NameTypeDescription
tokenaddressaddress of token

Return Values:

NameTypeDescription
priceuint256of the certain period

getMaxCollateralTokensPerAccount

  function getMaxCollateralTokensPerAccount(
) external returns (uint8)

Get the max number of collateral tokens per account

Return Values:

NameTypeDescription
maxuint8number of collateral tokens per account

getMmRatioBuffer

  function getMmRatioBuffer(
) external returns (uint24)

Get the minimum margin ratio - mmRatio before the account's collateral is liquidatable

6 decimals, same decimals as _mmRatio

getDebtNonSettlementTokenValueRatio

  function getDebtNonSettlementTokenValueRatio(
) external returns (uint24)

Get the maximum debt / nonSettlementTokenValue before the account's collaterals are liquidated

6 decimals

getLiquidationRatio

  function getLiquidationRatio(
) external returns (uint24)

Get the maximum ratio of debt can be repaid in one transaction

6 decimals. For example, liquidationRatio = 50% means the liquidator can repay as much as half of the trader’s debt in one liquidation

Return Values:

NameTypeDescription
liquidationuint24ratio

getCLInsuranceFundFeeRatio

  function getCLInsuranceFundFeeRatio(
) external returns (uint24)

Get the insurance fund fee ratio when liquidating a trader's collateral

6 decimals. For example, clInsuranceFundFeeRatio = 5% means the liquidator will pay 5% of transferred settlement token to insurance fund

Return Values:

NameTypeDescription
insuranceuint24fund fee ratio

getDebtThreshold

  function getDebtThreshold(
) external returns (uint256)

Get the default maximum debt (denominated in settlement token) allowed before an account’s collateral is liquidatable.

6 decimals

getDebtThresholdByTrader

  function getDebtThresholdByTrader(
) external returns (uint256)

Get the maximum whitelisted debt (denominated in settlement token) allowed before an account’s collateral is liquidatable.

6 decimals

getTotalWhitelistedDebtThreshold

  function getTotalWhitelistedDebtThreshold(
) external returns (uint256)

Get the total whitelisted debt (denominated in settlement token) allowed

6 decimals

getCollateralValueDust

  function getCollateralValueDust(
) external returns (uint256)

Get the threshold of the minium repaid. If a trader’s collateral value (denominated in settlement token) falls below the threshold, the liquidator can convert it with 100% liquidationRatio so there is no dust left

6 decimals

Return Values:

NameTypeDescription
Dustuint256collateral value

isCollateral

  function isCollateral(
address token
) external returns (bool)

Check if the given token is one of collateral tokens

Parameters:

NameTypeDescription
tokenaddressaddress of token

Return Values:

NameTypeDescription
trueboolif the token is one of collateral tokens

requireValidCollateralMmRatio

  function requireValidCollateralMmRatio(
uint24 mmRatioBuffer
) external returns (uint24)

Require and get the the valid collateral maintenance margin ratio by mmRatioBuffer

Parameters:

NameTypeDescription
mmRatioBufferuint24safe margin ratio buffer; 6 decimals, same decimals as _mmRatio

Return Values:

NameTypeDescription
collateralMmRatiouint24the collateral maintenance margin ratio

Events

CollateralAdded

  event CollateralAdded(
address token,
address priceFeed,
uint24 collateralRatio,
uint24 discountRatio,
uint256 depositCap
)

Emitted when owner add collateral

Parameters:

NameTypeDescription
tokenaddressaddress of token
priceFeedaddressaddress of price feed
collateralRatiouint24collateral ratio
discountRatiouint24discount ratio for the collateral liquidation
depositCapuint256max amount of collateral that can be deposited

ClearingHouseConfigChanged

  event ClearingHouseConfigChanged(
address clearingHouseConfig
)

Emitted when owner update the address of clearing house config

Parameters:

NameTypeDescription
clearingHouseConfigaddressaddress of clearing house config

VaultChanged

  event VaultChanged(
address vault
)

Emitted when owner update the address of vault

Parameters:

NameTypeDescription
vaultaddressaddress of vault

PriceFeedChanged

  event PriceFeedChanged(
address token,
address priceFeed
)

Emitted when owner update the price feed address of a collateral token

Parameters:

NameTypeDescription
tokenaddressaddress of token
priceFeedaddressaddress of price feed

CollateralRatioChanged

  event CollateralRatioChanged(
address token,
uint24 collateralRatio
)

Emitted when owner update the collateral ratio of a collateral token

Parameters:

NameTypeDescription
tokenaddressaddress of token
collateralRatiouint24collateral ratio

DiscountRatioChanged

  event DiscountRatioChanged(
address token,
uint24 discountRatio
)

Emitted when owner change the discount ratio

Parameters:

NameTypeDescription
tokenaddressaddress of token
discountRatiouint24discount ratio for the collateral liquidation

DepositCapChanged

  event DepositCapChanged(
address token,
uint256 depositCap
)

Emitted when owner update the deposit cap of a collateral token

Parameters:

NameTypeDescription
tokenaddressaddress of token
depositCapuint256max amount of the collateral that can be deposited

MaxCollateralTokensPerAccountChanged

  event MaxCollateralTokensPerAccountChanged(
uint8 maxCollateralTokensPerAccount
)

Emitted when owner init or update the max collateral tokens that per account can have, this is can prevent high gas cost.

Parameters:

NameTypeDescription
maxCollateralTokensPerAccountuint8max amount of collateral tokens that per account can have

MmRatioBufferChanged

  event MmRatioBufferChanged(
uint24 mmRatioBuffer
)

Emitted when owner init or update the maintenance margin ratio buffer, the value provides a safe range between the mmRatio & the collateralMMRatio.

Parameters:

NameTypeDescription
mmRatioBufferuint24safe buffer number (bps)

DebtNonSettlementTokenValueRatioChanged

  event DebtNonSettlementTokenValueRatioChanged(
uint24 debtNonSettlementTokenValueRatio
)

Emitted when owner init or update the debt non-settlement token value ratio, maximum debt / nonSettlementTokenValue before the account's is liquidatable

Parameters:

NameTypeDescription
debtNonSettlementTokenValueRatiouint24debt non-settlement token value ratio, ≤ 1

LiquidationRatioChanged

  event LiquidationRatioChanged(
uint24 liquidationRatio
)

Emitted when owner init or update the liquidation ratio, the value presents the max repaid ratio of the collateral liquidation.

Parameters:

NameTypeDescription
liquidationRatiouint24liquidation ratio, ≤ 1

CLInsuranceFundFeeRatioChanged

  event CLInsuranceFundFeeRatioChanged(
uint24 clInsuranceFundFeeRatio
)

Emitted when owner init or update the clearing house insurance fund fee ratio, charge fee for clearing house insurance fund.

Parameters:

NameTypeDescription
clInsuranceFundFeeRatiouint24clearing house insurance fund fee ratio, ≤ 1

DebtThresholdChanged

  event DebtThresholdChanged(
uint256 debtThreshold
)

Emitted when owner init or update the debt threshold, maximum debt allowed before an account’s collateral is liquidatable.

Parameters:

NameTypeDescription
debtThresholduint256debt threshold

WhitelistedDebtThresholdChanged

  event WhitelistedDebtThresholdChanged(
address whitelistedDebtThreshold
)

Emitted when owner init or update the whitelisted debt threshold, maximum debt allowed before an account’s collateral is liquidatable.

Parameters:

NameTypeDescription
whitelistedDebtThresholdaddresswhitelisted debt threshold

CollateralValueDustChanged

  event CollateralValueDustChanged(
uint256 collateralValueDust
)

Emitted when owner init or update the collateral value dust, if a trader’s debt value falls below this dust threshold, the liquidator will ignore the liquidationRatio.

Parameters:

NameTypeDescription
collateralValueDustuint256collateral value dust