Skip to main content
This is an external library for position size updates lifecycles Used by GNSTrading and GNSTradingCallbacks facets

requestIncreasePositionSize

Initiate increase position size order, done in 2 steps because position size changes

Parameters

NameTypeDescription
_inputIUpdatePositionSize.IncreasePositionSizeInputrequest increase position size input struct

requestDecreasePositionSize

Initiate decrease position size order, done in 2 steps because position size changes

Parameters

NameTypeDescription
_inputIUpdatePositionSize.DecreasePositionSizeInputrequest decrease position size input struct

executeIncreasePositionSizeMarket

Execute increase position size market callback

Parameters

NameTypeDescription
_orderITradingStorage.PendingOrdercorresponding pending order
_answerITradingCallbacks.AggregatorAnswerprice aggregator answer

executeDecreasePositionSizeMarket

Execute decrease position size market callback

Parameters

NameTypeDescription
_orderITradingStorage.PendingOrdercorresponding pending order
_answerITradingCallbacks.AggregatorAnswerprice aggregator answer

_getMultiCollatDiamond

Returns current address as multi-collateral diamond interface to call other facets functions.

_baseValidateRequest

Basic validation for increase/decrease position size request

Parameters

NameTypeDescription
_traderaddresstrader address
_indexuint32trade index

_initiateRequest

Creates pending order, makes price aggregator request, and returns corresponding pending order id

Parameters

NameTypeDescription
_tradeITradingStorage.Tradetrade to update
_isIncreaseboolwhether is increase or decrease position size order
_collateralAmountuint120partial trade collateral amount (collateral precision)
_leverageuint24partial trade leverage (1e3)
_positionSizeCollateralDeltauint256position size delta in collateral tokens (collateral precision)
_expectedPriceuint64reference price for max slippage check (1e10), only useful for increase position size
_maxSlippagePuint16max slippage % (1e3), only useful for increase position size

_validateBaseFulfillment

Basic validation for callbacks, returns corresponding cancel reason

Parameters

NameTypeDescription
_tradeITradingStorage.Tradetrade struct
_answerITradingCallbacks.AggregatorAnswerprice aggegator answer