ClearingHouse
Entry point for users to vault and perpetual markets
function DEFAULT_ADMIN_ROLE() external view returns (bytes32)
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function EMERGENCY_ADMIN() external view returns (bytes32)
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function GOVERNANCE() external view returns (bytes32)
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function addStakingContract(contract IStakingContract staking) external nonpayable
Add a staking contract
Staking contract is not implemented yet
Name | Type | Description |
---|---|---|
staking | contract IStakingContract | Staking Contract |
function allowListPerpetual(contract IPerpetual perp) external nonpayable
Add one perpetual market to the list of markets
Name | Type | Description |
---|---|---|
perp | contract IPerpetual | Market to add to the list of supported market |
function canSeizeCollateral(address liquidatee) external view returns (bool)
Name | Type | Description |
---|---|---|
liquidatee | address | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function changePosition(uint256 idx, uint256 amount, uint256 minAmount, enum LibPerpetual.Side direction) external nonpayable
Open or increase or reduce a position, either LONG or SHORT
No number for the leverage is given but the amount in the vault must be bigger than minMarginAtCreation
Name | Type | Description |
---|---|---|
idx | uint256 | Index of the perpetual market |
amount | uint256 | Amount in vQuote (if LONG) or vBase (if SHORT) to sell. 18 decimals |
minAmount | uint256 | Minimum amount that the user is willing to accept. 18 decimals |
direction | enum LibPerpetual.Side | Whether the trader wants to go in the LONG or SHORT direction overall |
function closePositionWithdrawCollateral(uint256 idx, uint256 proposedAmount, uint256 minAmount, contract IERC20Metadata token) external nonpayable
Single close position function, groups closing position and withdrawing collateralImportant:
proposedAmount
must be large enough to close the entire position else the function call will failName | Type | Description |
---|---|---|
idx | uint256 | Index of the perpetual market |
proposedAmount | uint256 | Amount of tokens to be sold, in vBase if LONG, in vQuote if SHORT. 18 decimals |
minAmount | uint256 | Minimum amount that the user is willing to accept, in vQuote if LONG, in vBase if SHORT. 18 decimals |
token | contract IERC20Metadata | Token used for the collateral |
function decreaseAllowance(address receiver, uint256 subtractedAmount, contract IERC20Metadata token) external nonpayable
Decrease withdrawal approval for a receiving address on the vault
Name | Type | Description |
---|---|---|
receiver | address | Address allowed to transfer amount of token of msg.sender from the vault |
subtractedAmount | uint256 | Amount to subtract from the current approved value. 18 decimals |
token | contract IERC20Metadata | Token to be withdrawn by the to address |
function delistPerpetual(contract IPerpetual perp) external nonpayable
Remove on perpetual market of the list of markets
Name | Type | Description |
---|---|---|
perp | contract IPerpetual | Market to add to the list of supported market |
function deposit(uint256 amount, contract IERC20Metadata token) external nonpayable
Deposit tokens into the vault
Name | Type | Description |
---|---|---|
amount | uint256 | Amount to be used as collateral. Might not be 18 decimals |
token | contract IERC20Metadata | Token to be used for the collateral |
function depositFor(address user, uint256 amount, contract IERC20Metadata token) external nonpayable
Deposit tokens into the vault on behalf of another user
Name | Type | Description |
---|---|---|
user | address | Address of user whose balance should be adjusted |
amount | uint256 | Amount to be used as collateral. Might not be 18 decimals |
token | contract IERC20Metadata | Token to be used for the collateral |
function extendPositionWithCollateral(uint256 idx, address user, uint256 collateralAmount, contract IERC20Metadata token, uint256 positionAmount, enum LibPerpetual.Side direction, uint256 minAmount) external nonpayable
Single open position function, groups depositing collateral and extending position
Name | Type | Description |
---|---|---|
idx | uint256 | Index of the perpetual market |
user | address | Address of user whose balance should be adjusted |
collateralAmount | uint256 | Amount to be used as the collateral of the position. Might not be 18 decimals |
token | contract IERC20Metadata | Token to be used for the collateral of the position |
positionAmount | uint256 | Amount to be sold, in vQuote (if LONG) or vBase (if SHORT). Must be 18 decimals |
direction | enum LibPerpetual.Side | Whether the position is LONG or SHORT |
minAmount | uint256 | Minimum amount that the user is willing to accept. 18 decimals |
function getDebtAcrossMarkets(address account) external view returns (int256 userDebt)
Get user debt across all perpetual markets
Name | Type | Description |
---|---|---|
account | address | User address (trader and/or liquidity provider) |
Name | Type | Description |
---|---|---|
userDebt | int256 | undefined |
function getFreeCollateralByRatio(address account, int256 ratio) external view returns (int256 freeCollateral)
Get free collateral of a user given a chosen margin ratio
Name | Type | Description |
---|---|---|
account | address | User address (trader and/or liquidity provider) |
ratio | int256 | Margin ratio (minMargin or minMarginAtCreation) |
Name | Type | Description |
---|---|---|
freeCollateral | int256 | undefined |
function getNumMarkets() external view returns (uint256)
Return the number of active markets
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function getPnLAcrossMarkets(address account) external view returns (int256 unrealizedPositionPnl)
Get user profit/loss across all perpetual markets
Name | Type | Description |
---|---|---|
account | address | User address (trader and/or liquidity provider) |
Name | Type | Description |
---|---|---|
unrealizedPositionPnl | int256 | undefined |
function getRoleAdmin(bytes32 role) external view returns (bytes32)
Returns the admin role that controls
role
. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function getTotalMarginRequirement(address account, int256 ratio) external view returns (int256 requiredMargin)
Get the margin required to serve user debt at a chosen margin ratio
Name | Type | Description |
---|---|---|
account | address | User address (trader and/or liquidity provider) |
ratio | int256 | Margin ratio (minMargin or minMarginAtCreation) |
Name | Type | Description |
---|---|---|
requiredMargin | int256 | undefined |
function grantRole(bytes32 role, address account) external nonpayable
Grants
role
to account
. If account
had not been already granted role
, emits a {RoleGranted} event. Requirements: - the caller must have role
's admin role. May emit a {RoleGranted} event.Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
function hasRole(bytes32 role, address account) external view returns (bool)
Returns
true
if account
has been granted role
.Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function id(uint256) external view returns (uint256)
Allowlisted Perpetual indices
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function increaseAllowance(address receiver, uint256 addedAmount, contract IERC20Metadata token) external nonpayable
Increase withdrawal approval for a receiving address on the vault
Name | Type | Description |
---|---|---|
receiver | address | Address allowed to transfer amount of token of msg.sender from the vault |
addedAmount | uint256 | Amount to add to the current approved value. 18 decimals |
token | contract IERC20Metadata | Token to be withdrawn by the to address |
function insurance() external view returns (contract IInsurance)
Insurance contract
Name | Type | Description |
---|---|---|
_0 | contract IInsurance | undefined |
function insuranceRatio() external view returns (uint256)
Insurance ratio
Once the insurance reserve exceed this ratio of the tvl, governance can withdraw exceeding insurance fee
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function isEmergencyAdmin(address account) external view returns (bool)
Name | Type | Description |
---|---|---|
account | address | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function isGovernor(address account) external view returns (bool)
Name | Type | Description |
---|---|---|
account | address | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function liquidateLp(uint256 idx, address liquidatee, uint256[2] minVTokenAmounts, uint256 proposedAmount, uint256 minAmount) external nonpayable
Submit the address of a LP whose position is worth liquidating for a reward
Name | Type | Description |
---|---|---|
idx | uint256 | Index of the perpetual market |
liquidatee | address | Address of the account to liquidate |
minVTokenAmounts | uint256[2] | undefined |
proposedAmount | uint256 | Amount of tokens to be sold, in vBase if LONG, in vQuote if SHORT. 18 decimals |
minAmount | uint256 | Minimum amount that the user is willing to accept. 18 decimals |
function liquidateTrader(uint256 idx, address liquidatee, uint256 proposedAmount, uint256 minAmount) external nonpayable
Submit the address of an Trader whose position is worth liquidating for a reward
Name | Type | Description |
---|---|---|
idx | uint256 | Index of the perpetual market |
liquidatee | address | Address of the account to liquidate |
proposedAmount | uint256 | Amount of tokens to be sold, in vBase if LONG, in vQuote if SHORT. 18 decimals |
minAmount | uint256 | Minimum amount that the user is willing to accept. 18 decimals |
function liquidationDiscount() external view returns (uint256)
Discount on the collateral price for the liquidator
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function liquidationReward() external view returns (uint256)
liquidation reward paid to liquidators
Paid on dollar value of an trader position. important: liquidationReward < minMargin or liquidations will result in protocol losses
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function liquidationRewardInsuranceShare() external view returns (uint256)
Portion of the liquidation reward that the insurance gets
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function marketIds() external view returns (uint256)
Number of Allowlisted Perpetuals
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function minMargin() external view returns (int256)
minimum maintenance margin
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function minMarginAtCreation() external view returns (int256)
minimum margin when opening a position
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function minPositiveOpenNotional() external view returns (uint256)
minimum positive open notional when opening a position
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |