leverageRatio : Precision TEN_THOUSAND
Forces the accountSubscriber to fetch account updates from rpc
calculates Buying Power = FC * MAX_LEVERAGE
: Precision QUOTE_PRECISION
calculates Free Collateral = (TC - TPV) * MAX_LEVERAGE
: Precision QUOTE_PRECISION
calculates current user leverage across all positions
: Precision TEN_THOUSAND
calculates margin ratio: total collateral / |total position value|
: Precision TEN_THOUSAND
calculates max allowable leverage exceeding hitting requirement category
: Precision TEN_THOUSAND
Get the maximum trade size for a given market, taking into account the user's current leverage, positions, collateral, etc.
To Calculate Max Quote Available:
Case 1: SameSide => Remaining quote to get to maxLeverage
Case 2: NOT SameSide && currentLeverage <= maxLeverage => Current opposite position x2 + remaining to get to maxLeverage
Case 3: NOT SameSide && currentLeverage > maxLeverage && otherPositions - currentPosition > maxLeverage => strictly reduce current position size
Case 4: NOT SameSide && currentLeverage > maxLeverage && otherPositions - currentPosition < maxLeverage => current position + remaining to get to maxLeverage
leverage : Precision TEN_THOUSAND
tradeSizeAllowed : Precision QUOTE_PRECISION
calculates average exit price for closing 100% of position
: Precision MARK_PRICE_PRECISION
calculates TotalCollateral: collateral + unrealized pnl
: Precision QUOTE_PRECISION
calculates sum of position value across all positions
: Precision QUOTE_PRECISION
Gets the user's current position for a given market. If the user has no position returns undefined
userPosition
Calculate the liquidation price of a position, with optional parameter to calculate the liquidation price after a trade
// change in position size to calculate liquidation price for : Precision 10^13
Precision : MARK_PRICE_PRECISION
Calculate the liquidation price of a position, with optional parameter to calculate the liquidation price after a trade
// change in position size to calculate liquidation price for : Precision 10^13
Precision : MARK_PRICE_PRECISION
Checks if any user position cumulative funding differs from respective market cumulative funding
Subscribe to ClearingHouseUser state accounts
SusbcriptionSuccess result
Generated using TypeDoc
Returns the leverage ratio for the account after adding (or subtracting) the given quote size to the given position