TradingStorageUtils

GNSTradingStorage facet external library

initializeTradingStorage

function initializeTradingStorage(address _gns, address _gnsStaking, address[] _collaterals, address[] _gTokens) external

Check ITradingStorageUtils interface for documentation

updateTradingActivated

function updateTradingActivated(enum ITradingStorage.TradingActivated _activated) public

Check ITradingStorageUtils interface for documentation

addCollateral

function addCollateral(address _collateral, address _gToken) public

Check ITradingStorageUtils interface for documentation

toggleCollateralActiveState

function toggleCollateralActiveState(uint8 _collateralIndex) external

Check ITradingStorageUtils interface for documentation

updateGToken

Check ITradingStorageUtils interface for documentation

storeTrade

Check ITradingStorageUtils interface for documentation

updateTradeMaxClosingSlippageP

updateTradeCollateralAmount

Check ITradingStorageUtils interface for documentation

updateTradePosition

Check ITradingStorageUtils interface for documentation

updateOpenOrderDetails

Check ITradingStorageUtils interface for documentation

updateTradeTp

Check ITradingStorageUtils interface for documentation

updateTradeSl

Check ITradingStorageUtils interface for documentation

closeTrade

Check ITradingStorageUtils interface for documentation

storePendingOrder

Check ITradingStorageUtils interface for documentation

closePendingOrder

Check ITradingStorageUtils interface for documentation

getCollateral

Check ITradingStorageUtils interface for documentation

isCollateralActive

Check ITradingStorageUtils interface for documentation

isCollateralListed

Check ITradingStorageUtils interface for documentation

getCollateralsCount

Check ITradingStorageUtils interface for documentation

getCollaterals

Check ITradingStorageUtils interface for documentation

getCollateralIndex

Check ITradingStorageUtils interface for documentation

getTradingActivated

Check ITradingStorageUtils interface for documentation

getTraderStored

Check ITradingStorageUtils interface for documentation

getTrade

Check ITradingStorageUtils interface for documentation

getTradeInfo

Check ITradingStorageUtils interface for documentation

getPendingOrder

Check ITradingStorageUtils interface for documentation

getTradePendingOrderBlock

Check ITradingStorageUtils interface for documentation

getCounters

Check ITradingStorageUtils interface for documentation

getGToken

Check ITradingStorageUtils interface for documentation

getTradeLiquidationParams

Check ITradingStorageUtils interface for documentation

getCurrentContractsVersion

Check ITradingStorageUtils interface for documentation

getTradersCount

Check ITradingStorageUtils interface for documentation

_getSlot

Returns storage slot to use when fetching storage relevant to library

_getStorage

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

_getMultiCollatDiamond

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

_limitTpDistance

_Limits take profit price distance for long/short based on '_openPrice', '_tp, '_leverage' and sets an automatic TP if 'tp' is zero.

Parameters

Name
Type
Description

_openPrice

uint64

trade open price (1e10 precision)

_leverage

uint24

trade leverage (1e3 precision)

_tp

uint64

trade take profit price (1e10 precision)

_long

bool

trade direction

_limitSlDistance

_Limits stop loss price distance for long/short based on '_openPrice', '_sl, 'leverage'.

Parameters

Name
Type
Description

_openPrice

uint64

trade open price (1e10 precision)

_leverage

uint24

trade leverage (1e3 precision)

_sl

uint64

trade stop loss price (1e10 precision)

_long

bool

trade direction

_liqPnlThresholdP

uint256

liquidation pnl threshold percentage (1e10)

_limitTradeSlDistance

Limits trade stop loss price distance

Parameters

Name
Type
Description

_trade

trade struct

_newSl

uint64

_validateTrade

Validation for trade struct (used by storeTrade and storePendingOrder for market open orders)

Parameters

Name
Type
Description

_trade

trade struct to validate

Last updated

Was this helpful?