website logo
⌘K
Rage Trade
Delta Neutral GMX
ETH Perp
T&C + Privacy
Additional Resources
Docs powered by archbee 
117min

IClearingHouse

IClearingHouseActions

createAccount

Solidity
|


creates a new account and adds it to the accounts map

Name

Type

Description

newAccountId

uint256

- serial number of the new account created

updateMargin

Solidity
|


deposits 'amount' of token associated with 'poolId'

Name

Type

Description

accountId

uint256

account id

collateralId

uint32

truncated address of token to deposit

amount

int256

amount of token to deposit

createAccountAndAddMargin

Solidity
|


creates a new account and deposits 'amount' of token associated with 'poolId'

Name

Type

Description

collateralId

uint32

truncated address of collateral token to deposit

amount

uint256

amount of token to deposit

Name

Type

Description

newAccountId

uint256

- serial number of the new account created

updateProfit

Solidity
|


withdraws 'amount' of settlement token from the profit made

Name

Type

Description

accountId

uint256

account id

amount

int256

amount of token to withdraw

settleProfit

Solidity
|


settles the profit/loss made with the settlement token collateral deposits

Name

Type

Description

accountId

uint256

account id

swapToken

Solidity
|


swaps token associated with 'poolId' by 'amount' (Long if amount>0 else Short)

Name

Type

Description

accountId

uint256

account id

poolId

uint32

truncated address of token to withdraw

swapParams

struct IClearingHouseStructures.SwapParams

swap parameters

updateRangeOrder

Solidity
|


updates range order of token associated with 'poolId' by 'liquidityDelta' (Adds if amount>0 else Removes) also can be used to update limitOrderType

Name

Type

Description

accountId

uint256

account id

poolId

uint32

truncated address of token to withdraw

liquidityChangeParams

struct IClearingHouseStructures.LiquidityChangeParams

liquidity change parameters

removeLimitOrder

Solidity
|


keeper call to remove a limit order

checks the position of current price relative to limit order and checks limitOrderType

Name

Type

Description

accountId

uint256

account id

poolId

uint32

truncated address of token to withdraw

tickLower

int24

liquidity change parameters

tickUpper

int24

liquidity change parameters

liquidateLiquidityPositions

Solidity
|


keeper call for liquidation of range position

removes all the active range positions and gives liquidator a percent of notional amount closed + fixedFee

Name

Type

Description

accountId

uint256

account id

liquidateTokenPosition

Solidity
|


keeper call for liquidation of token position

transfers the fraction of token position at a discount to current price to liquidators account and gives liquidator some fixedFee

Name

Type

Description

targetAccountId

uint256

account id

poolId

uint32

truncated address of token to withdraw

Name

Type

Description

keeperFee

int256

- amount of fees transferred to keeper

IClearingHouseCustomErrors

AccessDenied

Solidity
|


error to denote invalid account access

Name

Type

Description

senderAddress

address

address of msg sender

CollateralDoesNotExist

Solidity
|


error to denote usage of uninitialized token

Name

Type

Description

collateralId

uint32

address of token

CollateralNotAllowedForUse

Solidity
|


error to denote usage of unsupported collateral token

Name

Type

Description

collateralId

uint32

address of token

PoolDoesNotExist

Solidity
|


error to denote usage of uninitialized pool

Name

Type

Description

poolId

uint32

unitialized truncated address supplied

PoolNotAllowedForTrade

Solidity
|


error to denote usage of unsupported pool

Name

Type

Description

poolId

uint32

address of token

LowNotionalValue

Solidity
|


error to denote low notional value of txn

Name

Type

Description

notionalValue

uint256

notional value of txn

IncorrectCollateralAddress

Solidity
|


error to denote incorrect address is supplied while updating collateral settings

Name

Type

Description

incorrectAddress

contract IERC20

incorrect address of collateral token

correctAddress

contract IERC20

correct address of collateral token

InvalidCollateralAddress

Solidity
|


error to denote invalid address supplied as a collateral token

Name

Type

Description

invalidAddress

address

invalid address of collateral token

InvalidTokenLiquidationParameters

Solidity
|


error to denote invalid token liquidation (fraction to liquidate> 1)

InvalidMulticallOperationType

Solidity
|


this is errored when the enum (uint8) value is out of bounds

Name

Type

Description

multicallOperationType

enum IClearingHouseEnums.MulticallOperationType

is the value that is out of bounds

SlippageBeyondTolerance

Solidity
|


error to denote slippage of txn beyond set threshold

KeeperFeeNotPositive

Solidity
|


error to denote that keeper fee is negative or zero

IClearingHouseEnums

LimitOrderType

Solidity
|


MulticallOperationType

Solidity
|


IClearingHouseEvents

AccountCreated

Solidity
|


denotes new account creation

Name

Type

Description

ownerAddress

address

wallet address of account owner

accountId

uint256

serial number of the account

CollateralSettingsUpdated

Solidity
|


new collateral supported as margin

Name

Type

Description

cToken

contract IERC20



cTokenInfo

struct IClearingHouseStructures.CollateralSettings

collateral token info

PoolSettingsUpdated

Solidity
|


maintainance margin ratio of a pool changed

Name

Type

Description

poolId

uint32

id of the rage trade pool

settings

struct IClearingHouseStructures.PoolSettings

new settings

ProtocolSettingsUpdated

Solidity
|


protocol settings changed

Name

Type

Description

liquidationParams

struct IClearingHouseStructures.LiquidationParams

liquidation params

removeLimitOrderFee

uint256

fee for remove limit order

minimumOrderNotional

uint256

minimum order notional

minRequiredMargin

uint256

minimum required margin

PausedUpdated

Solidity
|




IClearingHouseOwnerActions

updateCollateralSettings

Solidity
|


updates the collataral settings

Name

Type

Description

cToken

contract IERC20

collateral token

collateralSettings

struct IClearingHouseStructures.CollateralSettings

settings

updatePoolSettings

Solidity
|


updates the rage trade pool settings

Name

Type

Description

poolId

uint32

rage trade pool id

newSettings

struct IClearingHouseStructures.PoolSettings

updated rage trade pool settings

updateProtocolSettings

Solidity
|


updates the protocol settings

Name

Type

Description

liquidationParams

struct IClearingHouseStructures.LiquidationParams

liquidation params

removeLimitOrderFee

uint256

fee for remove limit order

minimumOrderNotional

uint256

minimum order notional

minRequiredMargin

uint256

minimum required margin

withdrawProtocolFee

Solidity
|


withdraws protocol fees collected in the supplied wrappers to team multisig

Name

Type

Description

wrapperAddresses

address[]

list of wrapper addresses to collect fees from

IClearingHouseStructures

BalanceAdjustments

Solidity
|


Collateral

Solidity
|


CollateralSettings

Solidity
|


CollateralDepositView

Solidity
|


LiquidityChangeParams

Solidity
|


LiquidityPositionView

Solidity
|


LiquidationParams

Solidity
|


MulticallOperation

Solidity
|


Pool

Solidity
|


PoolSettings

Solidity
|


SwapParams

Solidity
|


VTokenPositionView

Solidity
|


IClearingHouseSystemActions

initialize

Solidity
|


initializes clearing house contract

Name

Type

Description

rageTradeFactoryAddress

address

rage trade factory address

defaultCollateralToken

contract IERC20

address of default collateral token

defaultCollateralTokenOracle

contract IOracle

address of default collateral token oracle

insuranceFund

contract IInsuranceFund

address of insurance fund

vQuote

contract IVQuote

address of vQuote

registerPool

Solidity
|




IClearingHouseView

getAccountInfo

Solidity
|


Gets details about account id

Name

Type

Description

accountId

uint256

the account id

Name

Type

Description

owner

address

address of the account creator

vQuoteBalance

int256

the vQuote balance of the account

collateralDeposits

struct IClearingHouseStructures.CollateralDepositView[]

the collateral deposits of the account

tokenPositions

struct IClearingHouseStructures.VTokenPositionView[]

the token positions of the account along with liquidity positions

getAccountMarketValueAndRequiredMargin

Solidity
|


Gets the market value and required margin of an account

This method can be used to check if an account is under water or not. If accountMarketValue < requiredMargin then liquidation can take place.

Name

Type

Description

accountId

uint256

the account id

isInitialMargin

bool

true is initial margin, false is maintainance margin

Name

Type

Description

accountMarketValue

int256

the market value of the account, due to collateral and positions

requiredMargin

int256

margin needed due to positions

getAccountNetProfit

Solidity
|


Gets the net profit of an account

Name

Type

Description

accountId

uint256

the account id

Name

Type

Description

accountNetProfit

int256

the net profit of the account

getAccountNetTokenPosition

Solidity
|


Gets the net position of an account

Name

Type

Description

accountId

uint256

the account id

poolId

uint32

the id of the pool (vETH, ... etc)

Name

Type

Description

netPosition

int256

the net position of the account

getCollateralInfo

Solidity
|


Gets the info about a supported collateral in the protocol

Name

Type

Description

collateralId

uint32

the id of the collateral

Name

Type

Description

[0]

struct IClearingHouseStructures.Collateral

collateral the Collateral struct

getPoolInfo

Solidity
|


Gets the info about a supported pool in the protocol

Name

Type

Description

poolId

uint32

the id of the pool

Name

Type

Description

[0]

struct IClearingHouseStructures.Pool

pool the Pool struct

getProtocolInfo

Solidity
|


Gets the protocol info, global protocol settings

Name

Type

Description

settlementToken

contract IERC20

the token in which profit is settled

vQuote

contract IVQuote

the vQuote token contract

liquidationParams

struct IClearingHouseStructures.LiquidationParams

the liquidation parameters

minRequiredMargin

uint256

minimum required margin an account has to keep with non-zero netPosition

removeLimitOrderFee

uint256

the fee charged for using removeLimitOrder service

minimumOrderNotional

uint256

the minimum order notional

getRealTwapPriceX128

Solidity
|


Gets the real twap price from the respective oracle of the given poolId

Name

Type

Description

poolId

uint32

the id of the pool

Name

Type

Description

realPriceX128

uint256

the real price of the pool

getVirtualTwapPriceX128

Solidity
|


Gets the virtual twap price from the respective oracle of the given poolId

Name

Type

Description

poolId

uint32

the id of the pool

Name

Type

Description

virtualPriceX128

uint256

the virtual price of the pool

isPoolIdAvailable

Solidity
|


Checks if a poolId is unused

Name

Type

Description

poolId

uint32

the id of the pool

Name

Type

Description

[0]

bool

true if the poolId is unused, false otherwise



Updated 03 Mar 2023
Did this page help you?
Yes
No
UP NEXT
IVPoolWrapper
Docs powered by archbee 
TABLE OF CONTENTS
IClearingHouseActions
createAccount
updateMargin
createAccountAndAddMargin
updateProfit
settleProfit
swapToken
updateRangeOrder
removeLimitOrder
liquidateLiquidityPositions
liquidateTokenPosition
IClearingHouseCustomErrors
AccessDenied
CollateralDoesNotExist
CollateralNotAllowedForUse
PoolDoesNotExist
PoolNotAllowedForTrade
LowNotionalValue
IncorrectCollateralAddress
InvalidCollateralAddress
InvalidTokenLiquidationParameters
InvalidMulticallOperationType
SlippageBeyondTolerance
KeeperFeeNotPositive
IClearingHouseEnums
LimitOrderType
MulticallOperationType
IClearingHouseEvents
AccountCreated
CollateralSettingsUpdated
PoolSettingsUpdated
ProtocolSettingsUpdated
PausedUpdated
IClearingHouseOwnerActions
updateCollateralSettings
updatePoolSettings
updateProtocolSettings
withdrawProtocolFee
IClearingHouseStructures
BalanceAdjustments
Collateral
CollateralSettings
CollateralDepositView
LiquidityChangeParams
LiquidityPositionView
LiquidationParams
MulticallOperation
Pool
PoolSettings
SwapParams
VTokenPositionView
IClearingHouseSystemActions
initialize
registerPool
IClearingHouseView
getAccountInfo
getAccountMarketValueAndRequiredMargin
getAccountNetProfit
getAccountNetTokenPosition
getCollateralInfo
getPoolInfo
getProtocolInfo
getRealTwapPriceX128
getVirtualTwapPriceX128
isPoolIdAvailable