TradingInteractionsUtils

GNSTradingInteractions facet internal library

tradingActivated

modifier tradingActivated()

Modifier to only allow trading action when trading is activated (= revert if not activated)

tradingActivatedOrCloseOnly

modifier tradingActivatedOrCloseOnly()

Modifier to only allow trading action when trading is activated or close only (= revert if paused)

notDelegatedAction

modifier notDelegatedAction()

Modifier to prevent calling function from delegated action

initializeTrading

function initializeTrading(uint16 _marketOrdersTimeoutBlocks, address[] _usersByPassTriggerLink) internal

Check ITradingInteractionsUtils interface for documentation

updateMarketOrdersTimeoutBlocks

function updateMarketOrdersTimeoutBlocks(uint16 _valueBlocks) internal

Check ITradingInteractionsUtils interface for documentation

function updateByPassTriggerLink(address[] _users, bool[] _shouldByPass) internal

Check ITradingInteractionsUtils interface for documentation

setTradingDelegate

function setTradingDelegate(address _delegate) internal

Check ITradingInteractionsUtils interface for documentation

removeTradingDelegate

function removeTradingDelegate() internal

Check ITradingInteractionsUtils interface for documentation

delegatedTradingAction

function delegatedTradingAction(address _trader, bytes _callData) internal returns (bytes)

Check ITradingInteractionsUtils interface for documentation

openTrade

function openTrade(struct ITradingStorage.Trade _trade, uint16 _maxSlippageP, address _referrer) internal

Check ITradingInteractionsUtils interface for documentation

openTradeNative

function openTradeNative(struct ITradingStorage.Trade _trade, uint16 _maxSlippageP, address _referrer) internal

Check ITradingInteractionsUtils interface for documentation

updateMaxClosingSlippageP

function updateMaxClosingSlippageP(uint32 _index, uint16 _maxClosingSlippageP) internal

Check ITradingInteractionsUtils interface for documentation

closeTradeMarket

function closeTradeMarket(uint32 _index, uint64 _expectedPrice) internal

Check ITradingInteractionsUtils interface for documentation

updateOpenOrder

function updateOpenOrder(uint32 _index, uint64 _openPrice, uint64 _tp, uint64 _sl, uint16 _maxSlippageP) internal

Check ITradingInteractionsUtils interface for documentation

cancelOpenOrder

function cancelOpenOrder(uint32 _index) internal

Check ITradingInteractionsUtils interface for documentation

updateTp

function updateTp(uint32 _index, uint64 _newTp) internal

Check ITradingInteractionsUtils interface for documentation

updateSl

function updateSl(uint32 _index, uint64 _newSl) internal

Check ITradingInteractionsUtils interface for documentation

updateLeverage

function updateLeverage(uint32 _index, uint24 _newLeverage) internal

Check ITradingInteractionsUtils interface for documentation

increasePositionSize

function increasePositionSize(uint32 _index, uint120 _collateralDelta, uint24 _leverageDelta, uint64 _expectedPrice, uint16 _maxSlippageP) internal

Check ITradingInteractionsUtils interface for documentation

decreasePositionSize

function decreasePositionSize(uint32 _index, uint120 _collateralDelta, uint24 _leverageDelta, uint64 _expectedPrice) internal

Check ITradingInteractionsUtils interface for documentation

triggerOrder

function triggerOrder(uint256 _packed) internal

Check ITradingInteractionsUtils interface for documentation

cancelOrderAfterTimeout

function cancelOrderAfterTimeout(uint32 _orderIndex) internal

Check ITradingInteractionsUtils interface for documentation

getWrappedNativeToken

function getWrappedNativeToken() internal view returns (address)

Check ITradingInteractionsUtils interface for documentation

isWrappedNativeToken

function isWrappedNativeToken(address _token) internal view returns (bool)

Check ITradingInteractionsUtils interface for documentation

getTradingDelegate

function getTradingDelegate(address _trader) internal view returns (address)

Check ITradingInteractionsUtils interface for documentation

getMarketOrdersTimeoutBlocks

function getMarketOrdersTimeoutBlocks() internal view returns (uint16)

Check ITradingInteractionsUtils interface for documentation

function getByPassTriggerLink(address _user) internal view returns (bool)

Check ITradingInteractionsUtils interface for documentation

_getSlot

function _getSlot() internal pure returns (uint256)

Returns storage slot to use when fetching storage relevant to library

_getStorage

function _getStorage() internal pure returns (struct ITradingInteractions.TradingInteractionsStorage s)

Returns storage pointer for storage struct in diamond contract, at defined slot

_getMultiCollatDiamond

function _getMultiCollatDiamond() internal view returns (contract IGNSMultiCollatDiamond)

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

_openTrade

function _openTrade(struct ITradingStorage.Trade _trade, uint16 _maxSlippageP, address _referrer, bool _isNative) internal

Internal function for openTrade and openTradeNative

Parameters

Name
Type
Description

_trade

trade data

_maxSlippageP

uint16

max slippage percentage (1e3 precision)

_referrer

address

referrer address

_isNative

bool

if true we skip the collateral transfer from user to contract

_checkNoPendingTrigger

function _checkNoPendingTrigger(struct ITradingStorage.Id _tradeId, enum ITradingStorage.PendingOrderType _orderType) internal view

Revert if there is an active pending order for the trade

Parameters

Name
Type
Description

_tradeId

trade id

_orderType

enum ITradingStorage.PendingOrderType

order type

_getPriceTriggerOrder

function _getPriceTriggerOrder(struct ITradingStorage.Trade _trade, struct ITradingStorage.Id _orderId, enum ITradingStorage.PendingOrderType _orderType, uint256 _positionSizeCollateral) internal

Initiate price aggregator request for trigger order

Parameters

Name
Type
Description

_trade

trade

_orderId

order id

_orderType

enum ITradingStorage.PendingOrderType

order type

_positionSizeCollateral

uint256

position size in collateral tokens (collateral precision)

_wrapNativeToken

function _wrapNativeToken(uint8 _collateralIndex) internal returns (uint120)

Receives native token and sends back wrapped token to user

Parameters

Name
Type
Description

_collateralIndex

uint8

index of the collateral

_msgSender

function _msgSender() internal view returns (address)

Returns the caller of the transaction (overriden by trader address if delegatedAction is called)

Last updated