IncreasePositionSizeUtils

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

validateRequest

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

_Validates increase position request.

Possible inputs: collateral delta > 0 and leverage delta > 0 (increase position size by collateral delta * leverage delta) collateral delta = 0 and leverage delta > 0 (increase trade leverage by leverage delta)_

Parameters

Name
Type
Description

prepareCallbackValues

function prepareCallbackValues(struct ITradingStorage.Trade _existingTrade, struct ITradingStorage.Trade _partialTrade, struct ITradingCallbacks.AggregatorAnswer _answer) internal view returns (struct IUpdatePositionSize.IncreasePositionSizeValues 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 IUpdatePositionSize.IncreasePositionSizeValues _values, struct ITradingCallbacks.AggregatorAnswer _answer, uint256 _expectedPrice, uint256 _maxSlippageP) internal view returns (enum ITradingCallbacks.CancelReason cancelReason)

Validates callback, and returns corresponding cancel reason

Parameters

Name
Type
Description

_existingTrade

existing trade data

_values

pre-calculated useful values

_expectedPrice

uint256

user expected price before callback (1e10)

_maxSlippageP

uint256

maximum slippage percentage from expected price (1e3)

updateTradeSuccess

function updateTradeSuccess(struct ITradingStorage.Trade _existingTrade, struct IUpdatePositionSize.IncreasePositionSizeValues _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, struct ITradingStorage.Trade _partialTrade, enum ITradingCallbacks.CancelReason _cancelReason) internal

Handles callback canceled case (for failed request)

Parameters

Name
Type
Description

_existingTrade

existing trade data

_partialTrade

partial trade data

_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