DecreasePositionSizeUtils

This is an internal utils library for position size decreases Used by UpdatePositionSizeLifecycles internal library

validateRequest

function validateRequest(struct ITradingStorage.Trade _trade, struct IUpdatePositionSize.DecreasePositionSizeInput _input) internal view returns (uint256 positionSizeCollateralDelta)

_Validates decrease position size request

Possible inputs: collateral delta > 0 and leverage delta = 0 (decrease collateral by collateral delta) collateral delta = 0 and leverage delta > 0 (decrease leverage by leverage delta)

@param _trade trade of request @param input input values

prepareCallbackValues

function prepareCallbackValues(struct ITradingStorage.Trade _existingTrade, struct ITradingStorage.Trade _partialTrade, struct ITradingCallbacks.AggregatorAnswer _answer) internal view returns (struct IUpdatePositionSize.DecreasePositionSizeValues values)

Calculates values for callback

Parameters

Name
Type
Description

_existingTrade

existing trade data

_partialTrade

partial trade data

_answer

price aggregator answer

validateCallback

function validateCallback(struct ITradingStorage.Trade _existingTrade, struct ITradingStorage.PendingOrder _pendingOrder, struct IUpdatePositionSize.DecreasePositionSizeValues _values, struct ITradingCallbacks.AggregatorAnswer _answer) internal view returns (enum ITradingCallbacks.CancelReason)

Validates callback, and returns corresponding cancel reason

Parameters

Name
Type
Description

_existingTrade

_pendingOrder

_values

pre-calculated useful values

_answer

updateTradeSuccess

function updateTradeSuccess(struct ITradingStorage.Trade _existingTrade, struct IUpdatePositionSize.DecreasePositionSizeValues _values) internal

Updates trade (for successful request)

Parameters

Name
Type
Description

_existingTrade

existing trade data

_values

pre-calculated useful values

handleCanceled

function handleCanceled(struct ITradingStorage.Trade _existingTrade, enum ITradingCallbacks.CancelReason _cancelReason) internal

Handles callback canceled case (for failed request)

Parameters

Name
Type
Description

_existingTrade

trade to update

_cancelReason

enum ITradingCallbacks.CancelReason

cancel reason

_getMultiCollatDiamond

function _getMultiCollatDiamond() internal view returns (contract IGNSMultiCollatDiamond)

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

Last updated