ClearingHouse
Last updated
Last updated
Entry point for users to vault and perpetual markets
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Add a staking contract
Staking contract is not implemented yet
Add one perpetual market to the list of markets
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
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 fail
Decrease withdrawal approval for a receiving address on the vault
Remove on perpetual market of the list of markets
Deposit tokens into the vault
Deposit tokens into the vault on behalf of another user
Single open position function, groups depositing collateral and extending position
Get user debt across all perpetual markets
Get free collateral of a user given a chosen margin ratio
Return the number of active markets
Get user profit/loss across all perpetual markets
Returns the admin role that controls role
. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.
Get the margin required to serve user debt at a chosen margin ratio
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.
Returns true
if account
has been granted role
.
Allowlisted Perpetual indices
Increase withdrawal approval for a receiving address on the vault
Insurance contract
Insurance ratio
Once the insurance reserve exceed this ratio of the tvl, governance can withdraw exceeding insurance fee
Submit the address of a LP whose position is worth liquidating for a reward
Submit the address of an Trader whose position is worth liquidating for a reward
Discount on the collateral price for the liquidator
liquidation reward paid to liquidators
Paid on dollar value of an trader position. important: liquidationReward < minMargin or liquidations will result in protocol losses
Portion of the liquidation reward that the insurance gets
Number of Allowlisted Perpetuals
minimum maintenance margin
minimum margin when opening a position
minimum positive open notional when opening a position
Discount ratio to be applied on non-UA collaterals before seizing said collaterals for some UA
Must be lower than liquidationDiscount to ensure liquidations don't generate bad debt
Open a position in the opposite direction of the currently opened positionFor example, a trader with a LONG position can switch to a SHORT position with just one call to this function
Pause the contract
Can only be called by Emergency Admin
Returns true if the contract is paused, and false otherwise.
Allowlisted Perpetual contracts
Provide liquidity to the pool, without depositing new capital in the vault
Remove liquidity from the pool and account profit/loss in UA
Revokes role
from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked role
, emits a {RoleRevoked} event. Requirements: - the caller must be account
. May emit a {RoleRevoked} event.
Revokes role
from account
. If account
had been granted role
, emits a {RoleRevoked} event. Requirements: - the caller must have role
's admin role. May emit a {RoleRevoked} event.
Buy the non-UA collaterals of a user at a discounted UA price to settle the debt of said user
Sell dust of a given market
Can only be called by Emergency Admin
Staking contract
See {IERC165-supportsInterface}.
UA debt amount at which non-UA collaterals can be seized to pay back UA debts
Unpause the contract
Can only be called by Emergency Admin
Vault contract
Withdraw tokens from the vault
Withdraw all tokens from the vault
Should only be called by the trader
Withdraw tokens from the vault on behalf of a user
Emitted when a position is opened/extended
Emitted when parameters are changed
Emitted when dust is sold by governance
Emitted when an user position is liquidated
Emitted when (additional) liquidity is provided
Emitted when liquidity is removed
Emitted when new perpetual market is added
Emitted when perpetual market is removed
Emitted when an user non-UA collaterals are seized
Emitted when a user attempts to provide liquidity with amount larger than his free collateral or collateral balance
Emitted when a user attempts to change his position with no amount
Emitted when the position is not reduced entirely using closePositionWithdrawCollateral
Emitted when attempting to deposit to the zero address
Emitted when the liquidationDiscount is too high
Emitted when the proposed share of the liquidation reward for the insurance is too high
Emitted when the proposed minimum open notional is too high
Emitted when there is not enough margin to extend to the proposed position amount
Emitted when a user attempts to extend their position with amount equal to 0
Emitted when the difference between liquidationDiscount and nonUACollSeizureDiscount isn't large enough
Emitted when the proposed UA debt limit is lower than the minimum acceptable value
Emitted when the proposed insurance ratio is too low or too high
Emitted when the proposed liquidation reward is too low or too high
Emitted when the proposed minMargin is too low or too high
Emitted when the proposed minMarginAtCreation is too low or too high
Emitted when the attempted liquidation does not close the full position
Emitted when the liquidatee does not have an open position
Emitted when the margin of the liquidatee's position is still valid
Emitted when a collateral liquidation for a user with no UA debt is tried
Emitted when attempting to remove a perpetual market which does not exist
Emitted when governance tries to sell dust with a negative balance
Emitted when passing the address of a perpetual market which has already been added
Emitted when a user attempts to provide liquidity with amount equal to 0
Emitted when a user attempts to reduce their position with amount equal to 0
Emitted when a user attempts to withdraw more liquidity than they have
Emitted when a liquidator tries seizing collateral of user with sufficient collaterals level
Emitted when a user tries to open a position with an incorrect open notional amount
Emitted when there is not enough margin to withdraw the requested amount
Emitted when the zero address is provided
Emitted when the input is MIN_SD59x18.
Emitted when one of the inputs is MIN_SD59x18.
Emitted when the intermediary absolute result overflows SD59x18.
Emitted when the result overflows uint256.
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
_0
bytes32
undefined
_0
bytes32
undefined
_0
bytes32
undefined
staking
contract IStakingContract
Staking Contract
perp
contract IPerpetual
Market to add to the list of supported market
liquidatee
address
undefined
_0
bool
undefined
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
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
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
perp
contract IPerpetual
Market to add to the list of supported market
amount
uint256
Amount to be used as collateral. Might not be 18 decimals
token
contract IERC20Metadata
Token to be used for the collateral
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
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
account
address
User address (trader and/or liquidity provider)
userDebt
int256
undefined
account
address
User address (trader and/or liquidity provider)
ratio
int256
Margin ratio (minMargin or minMarginAtCreation)
freeCollateral
int256
undefined
_0
uint256
undefined
account
address
User address (trader and/or liquidity provider)
unrealizedPositionPnl
int256
undefined
role
bytes32
undefined
_0
bytes32
undefined
account
address
User address (trader and/or liquidity provider)
ratio
int256
Margin ratio (minMargin or minMarginAtCreation)
requiredMargin
int256
undefined
role
bytes32
undefined
account
address
undefined
role
bytes32
undefined
account
address
undefined
_0
bool
undefined
_0
uint256
undefined
_0
uint256
undefined
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
_0
contract IInsurance
undefined
_0
uint256
undefined
account
address
undefined
_0
bool
undefined
account
address
undefined
_0
bool
undefined
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
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
_0
uint256
undefined
_0
uint256
undefined
_0
uint256
undefined
_0
uint256
undefined
_0
int256
undefined
_0
int256
undefined
_0
uint256
undefined
_0
uint256
undefined
idx
uint256
Index of the perpetual market
closeProposedAmount
uint256
Amount in vQuote (if SHORT) or vBase (if LONG) to sell to close the position. 18 decimals
closeMinAmount
uint256
Minimum amount that the user is willing to accept when closing the position. 18 decimals
openProposedAmount
uint256
Amount in vQuote (if LONG) or vBase (if SHORT) to sell to open the reversed position. 18 decimals
openMinAmount
uint256
Minimum amount that the user is willing to accept when opening the reversed position. 18 decimals
direction
enum LibPerpetual.Side
Whether the trader wants to go in the LONG or SHORT direction overall
_0
bool
undefined
_0
uint256
undefined
_0
contract IPerpetual
undefined
idx
uint256
Index of the perpetual market
amounts
uint256[2]
Amount of virtual tokens ([vQuote, vBase]) provided. 18 decimals
minLpAmount
uint256
Minimum amount of Lp tokens minted. 18 decimals
idx
uint256
Index of the perpetual market
liquidityAmountToRemove
uint256
Amount of liquidity (in LP tokens) to be removed from the pool. 18 decimals
minVTokenAmounts
uint256[2]
Minimum amount of virtual tokens [vQuote, vBase] to withdraw from the curve pool. 18 decimals
proposedAmount
uint256
Amount at which to sell the active LP position (in vBase if LONG, in vQuote if SHORT). 18 decimals
minAmount
uint256
Minimum amount that the user is willing to accept when closing his active position generated after removing liquidity, in vQuote if LONG, in vBase if SHORT. 18 decimals
role
bytes32
undefined
account
address
undefined
role
bytes32
undefined
account
address
undefined
liquidatee
address
Address of the account to liquidate
params
IClearingHouse.ClearingHouseParams
undefined
idx
uint256
Index of the perpetual market to sell dust from
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
direction
enum LibPerpetual.Side
undefined
_0
contract IStakingContract
undefined
interfaceId
bytes4
undefined
_0
bool
undefined
_0
int256
undefined
_0
contract IVault
undefined
amount
uint256
Amount of collateral to withdraw. Might not be 18 decimals (decimals of token
)
token
contract IERC20Metadata
Token of the collateral
token
contract IERC20Metadata
Token of the collateral
user
address
Account to withdraw collateral from
amount
uint256
Amount of collateral to withdraw. Might not be 18 decimals (decimals of token
)
token
contract IERC20Metadata
Token of the collateral
idx indexed
uint256
undefined
user indexed
address
undefined
direction
enum LibPerpetual.Side
undefined
addedOpenNotional
int256
undefined
addedPositionSize
int256
undefined
profit
int256
undefined
tradingFeesPayed
int256
undefined
insuranceFeesPayed
int256
undefined
isPositionIncreased
bool
undefined
isPositionClosed
bool
undefined
newMinMargin
int256
undefined
newMinMarginAtCreation
int256
undefined
newMinPositiveOpenNotional
uint256
undefined
newLiquidationReward
uint256
undefined
newInsuranceRatio
uint256
undefined
newLiquidationRewardInsuranceShare
uint256
undefined
newLiquidationDiscount
uint256
undefined
nonUACollSeizureDiscount
uint256
undefined
uaDebtSeizureThreshold
int256
undefined
idx indexed
uint256
undefined
profit
int256
undefined
tradingFeesPayed
int256
undefined
idx indexed
uint256
undefined
liquidatee indexed
address
undefined
liquidator indexed
address
undefined
notional
uint256
undefined
profit
int256
undefined
tradingFeesPayed
int256
undefined
isTrader
bool
undefined
idx indexed
uint256
undefined
liquidityProvider indexed
address
undefined
quoteAmount
uint256
undefined
baseAmount
uint256
undefined
tradingFeesEarned
int256
undefined
idx indexed
uint256
undefined
liquidityProvider indexed
address
undefined
reductionRatio
uint256
undefined
profit
int256
undefined
tradingFeesPayed
int256
undefined
isPositionClosed
bool
undefined
perpetual indexed
contract IPerpetual
undefined
listedIdx
uint256
undefined
numPerpetuals
uint256
undefined
perpetual indexed
contract IPerpetual
undefined
delistedIdx
uint256
undefined
numPerpetuals
uint256
undefined
account
address
undefined
role indexed
bytes32
undefined
previousAdminRole indexed
bytes32
undefined
newAdminRole indexed
bytes32
undefined
role indexed
bytes32
undefined
account indexed
address
undefined
sender indexed
address
undefined
role indexed
bytes32
undefined
account indexed
address
undefined
sender indexed
address
undefined
liquidatee indexed
address
undefined
liquidator indexed
address
undefined
newStakingContract
contract IStakingContract
undefined
account
address
undefined
rAbs
uint256
undefined
prod1
uint256
undefined