UpdateLeverageLifecycles
This is an external library for leverage update lifecycles Used by GNSTrading and GNSTradingCallbacks facets
requestUpdateLeverage
Initiate update leverage order, done in 2 steps because need to cancel if liquidation price reached
Parameters
executeUpdateLeverage
Execute update leverage callback
Parameters
_getMultiCollatDiamond
Returns current address as multi-collateral diamond interface to call other facets functions.
_getNewCollateralAmount
Returns new trade collateral amount based on new leverage (collateral precision)
Parameters
_existingCollateralAmount
uint256
existing trade collateral amount (collateral precision)
_existingLeverage
uint256
existing trade leverage (1e3)
_newLeverage
uint256
new trade leverage (1e3)
_validateRequest
Fetches trade, does validation for update leverage request, and returns useful data
Parameters
_initiateRequest
Stores pending update leverage order and makes price aggregator request
Parameters
_newLeverage
uint24
new leverage (1e3)
_collateralDelta
uint256
trade collateral delta (collateral precision)
_prepareCallbackValues
Calculates values for callback
Parameters
_isIncrease
bool
true if increase leverage, false if decrease leverage
_validateCallback
Validates callback, and returns corresponding cancel reason
Parameters
_handleCallback
Handles trade update, removes gov fee OI, and transfers collateral delta (for both successful and failed requests)
Parameters
_cancelReason
enum ITradingCallbacks.CancelReason
cancel reason
_isIncrease
bool
true if increase leverage, false if decrease leverage
Last updated