Perp v2
Perp v2
  • About Perpetual Protocol
    • Social Links
    • Governance
    • v2 Era Ecosystem
    • PERP Token
  • Terms of Service
  • General
    • Wallets
    • Transfering Assets
    • Deposit & Withdrawal
    • Perpetual + Uniswap
    • FAQs
    • Guides
    • Legacy Reward Programs
    • Security
  • Hot Tub
  • Trading on Perp v2
    • How It Works
    • UI Overview
    • Perpetual Futures Basics
    • Trading Quick-start
    • Opening and Closing Positions
    • Account Value & More
    • Funding Payments
    • Order Types
    • Trading Fees and Gas Fees
    • Managing Risk
    • Multi-collateral
    • More docs
  • Providing Liquidity
    • Basics
    • Introduction to Maker UI
    • Add / Remove Liquidity
    • Estimated Fees and Rewards APR
    • More on LPing
    • Tools for LPs
  • Perp v2 Specs
  • Developer Docs
    • Developer FAQs
    • Source Code
    • Protocol Attributes
    • Contract guide
      • AccountBalance
      • BaseToken
      • ClearingHouse
      • CollateralManager
      • DelegateApproval
      • Exchange
      • InsuranceFund
      • MarketRegistry
      • OrderBook
      • QuoteToken
      • Vault
      • VirtualToken
    • Interface Contracts
      • IAccountBalance
      • IBaseToken
      • IClearingHouse
      • IClearingHouseConfig
      • IClearingHouseConfigEvent
      • ICollateralManager
      • IDelegateApproval
      • IERC20Metadata
      • IExchange
      • IIndexPrice
      • IInsuranceFund
      • IMarketRegistry
      • IOrderBook
      • IVault
      • IVirtualToken
    • Integration guide
    • Dev tools
Powered by GitBook
On this page

Was this helpful?

  1. Developer Docs
  2. Contract guide

CollateralManager

Last updated 1 year ago

Was this helpful?

Functions

initialize

  function initialize(
  ) external

addCollateral

  function addCollateral(
  ) external

setPriceFeed

  function setPriceFeed(
  ) external

setCollateralRatio

  function setCollateralRatio(
  ) external

setDiscountRatio

  function setDiscountRatio(
  ) external

setDepositCap

  function setDepositCap(
  ) external
  function setMaxCollateralTokensPerAccount(
  ) external
  function setMmRatioBuffer(
  ) external
  function setDebtNonSettlementTokenValueRatio(
  ) external
  function setLiquidationRatio(
  ) external
  function setCLInsuranceFundFeeRatio(
  ) external
  function setDebtThreshold(
  ) external
  function setWhitelistedDebtThreshold(
  ) external
  function setCollateralValueDust(
  ) external

Same decimals as the settlement token

  function getClearingHouseConfig(
  ) external returns (address)

Get the address of clearing house config

Name
Type
Description

clearingHouseConfig

address

address of clearing house config

  function getVault(
  ) external returns (address)

Get the address of vault

Name
Type
Description

vault

address

address of vault

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

Get collateral config by token address

Name
Type
Description

token

address

address of token

Name
Type
Description

collateral

struct Collateral.Config

config

  function getPriceFeedDecimals(
    address token
  ) external returns (uint8)

Get price feed decimals of the collateral token

Name
Type
Description

token

address

address of token

Name
Type
Description

decimals

uint8

of the price feed

  function getPrice(
    address token
  ) external returns (uint256)

Get the price of the collateral token

Name
Type
Description

token

address

address of token

Name
Type
Description

price

uint256

of the certain period

  function getMaxCollateralTokensPerAccount(
  ) external returns (uint8)
  function getMmRatioBuffer(
  ) external returns (uint24)

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

6 decimals, same decimals as _mmRatio

  function getDebtNonSettlementTokenValueRatio(
  ) external returns (uint24)

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

6 decimals

  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

Name
Type
Description

liquidation

uint24

ratio

  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

Name
Type
Description

insurance

uint24

fund fee ratio

  function getDebtThreshold(
  ) external returns (uint256)

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

6 decimals

  function getDebtThresholdByTrader(
  ) external returns (uint256)

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

6 decimals

  function getTotalWhitelistedDebtThreshold(
  ) external returns (uint256)

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

6 decimals

  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

Name
Type
Description

Dust

uint256

collateral value

  function isCollateral(
    address token
  ) public returns (bool)

Check if the given token is one of collateral tokens

Name
Type
Description

token

address

address of token

Name
Type
Description

true

bool

if the token is one of collateral tokens

  function requireValidCollateralMmRatio(
    uint24 mmRatioBuffer
  ) public returns (uint24)

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

Name
Type
Description

mmRatioBuffer

uint24

safe margin ratio buffer; 6 decimals, same decimals as _mmRatio

Name
Type
Description

collateralMmRatio

uint24

the collateral maintenance margin ratio

setMaxCollateralTokensPerAccount

setMmRatioBuffer

setDebtNonSettlementTokenValueRatio

setLiquidationRatio

setCLInsuranceFundFeeRatio

setDebtThreshold

setWhitelistedDebtThreshold

setCollateralValueDust

getClearingHouseConfig

Return Values:

getVault

Return Values:

getCollateralConfig

Parameters:

Return Values:

getPriceFeedDecimals

Parameters:

Return Values:

getPrice

Parameters:

Return Values:

getMaxCollateralTokensPerAccount

getMmRatioBuffer

getDebtNonSettlementTokenValueRatio

getLiquidationRatio

Return Values:

getCLInsuranceFundFeeRatio

Return Values:

getDebtThreshold

getDebtThresholdByTrader

getTotalWhitelistedDebtThreshold

getCollateralValueDust

Return Values:

isCollateral

Parameters:

Return Values:

requireValidCollateralMmRatio

Parameters:

Return Values:

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​