AccountBalance
Functions
initialize
setVault
modifyTakerBalance
Modify trader account balance
Only used by ClearingHouse
contract
Parameters:
Return Values:
modifyOwedRealizedPnl
Modify trader owedRealizedPnl
Only used by ClearingHouse
contract
Parameters:
settleQuoteToOwedRealizedPnl
Modify trader owedRealizedPnl
Only used by ClearingHouse
contract
Parameters:
settleOwedRealizedPnl
Settle owedRealizedPnl
Only used by Vault.withdraw()
Parameters:
Return Values:
settleBalanceAndDeregister
Settle account balance and deregister base token
Only used by ClearingHouse
contract
Parameters:
registerBaseToken
Every time a trader's position value is checked, the base token list of this trader will be traversed; thus, this list should be kept as short as possible
Only used by ClearingHouse
contract
Parameters:
deregisterBaseToken
Deregister baseToken from trader accountInfo
Only used by ClearingHouse
contract, this function is expensive, due to for loop
Parameters:
updateTwPremiumGrowthGlobal
Update trader Twap premium info
Only used by ClearingHouse
contract
Parameters:
settlePositionInClosedMarket
Settle trader's PnL in closed market
we don't do swap to get position notional here. we define the position notional in a closed market is closed price * position size
Parameters:
Return Values:
getClearingHouseConfig
Get ClearingHouseConfig
address
Return Values:
getOrderBook
Get OrderBook
address
Return Values:
getVault
Get Vault
address
Return Values:
getBaseTokens
Get trader registered baseTokens
Parameters:
Return Values:
getAccountInfo
Get trader account info
Parameters:
Return Values:
getTakerOpenNotional
getTotalOpenNotional
getTotalDebtValue
Get total debt value of trader
Total debt value will relate to Vault.getFreeCollateral()
Parameters:
Return Values:
getPnlAndPendingFee
Get owedRealizedPnl, unrealizedPnl and pending fee
Parameters:
Return Values:
hasOrder
Check trader has open order in open/closed market.
Parameters:
Return Values:
getLiquidatablePositionSize
Get liquidatable position size of trader's baseToken market
Parameters:
Return Values:
getMarkPrice
Get mark price of baseToken market
Mark price is the median of three prices as below.
If the parameters to calculate mark price are not set, returns index twap instead for backward compatible If the market is paused, returns index twap instead, that will be the index twap while pausing market
Parameters:
Return Values:
getBase
Get trader base amount
base amount = takerPositionSize - orderBaseDebt
Parameters:
Return Values:
getQuote
Get trader quote amount
quote amount = takerOpenNotional - orderQuoteDebt
Parameters:
Return Values:
getTakerPositionSize
Get taker position size of trader's baseToken market
This will only has taker position, can get maker impermanent position through getTotalPositionSize
Parameters:
Return Values:
getTotalPositionSize
Get total position size of trader's baseToken market
total position size = taker position size + maker impermanent position size
Parameters:
Return Values:
getTotalPositionValue
Get total position value of trader's baseToken market
A negative returned value is only be used when calculating pnl, we use mark price to calc position value
Parameters:
Return Values:
getTotalAbsPositionValue
Get all market position abs value of trader
Parameters:
Return Values:
getMarginRequirementForLiquidation
Get margin requirement to check whether trader will be able to liquidate
This is different from Vault._getTotalMarginRequirement()
, which is for freeCollateral calculation
Parameters:
Return Values:
Last updated