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
function updateGToken(address _collateral, address _gToken) external
Check ITradingStorageUtils interface for documentation
storeTrade
function storeTrade(struct ITradingStorage.Trade _trade, struct ITradingStorage.TradeInfo _tradeInfo) external returns (struct ITradingStorage.Trade)
Check ITradingStorageUtils interface for documentation
updateTradeMaxClosingSlippageP
function updateTradeMaxClosingSlippageP(struct ITradingStorage.Id _tradeId, uint16 _maxClosingSlippageP) external
updateTradeCollateralAmount
function updateTradeCollateralAmount(struct ITradingStorage.Id _tradeId, uint120 _collateralAmount) external
Check ITradingStorageUtils interface for documentation
updateTradePosition
function updateTradePosition(struct ITradingStorage.Id _tradeId, uint120 _collateralAmount, uint24 _leverage, uint64 _openPrice, bool _isPartialIncrease, bool _isPnlPositive) external
Check ITradingStorageUtils interface for documentation
updateOpenOrderDetails
function updateOpenOrderDetails(struct ITradingStorage.Id _tradeId, uint64 _openPrice, uint64 _tp, uint64 _sl, uint16 _maxSlippageP) external
Check ITradingStorageUtils interface for documentation
updateTradeTp
function updateTradeTp(struct ITradingStorage.Id _tradeId, uint64 _newTp) external
Check ITradingStorageUtils interface for documentation
updateTradeSl
function updateTradeSl(struct ITradingStorage.Id _tradeId, uint64 _newSl) external
Check ITradingStorageUtils interface for documentation
closeTrade
function closeTrade(struct ITradingStorage.Id _tradeId, bool _isPnlPositive) external
Check ITradingStorageUtils interface for documentation
storePendingOrder
function storePendingOrder(struct ITradingStorage.PendingOrder _pendingOrder) external returns (struct ITradingStorage.PendingOrder)
Check ITradingStorageUtils interface for documentation
closePendingOrder
function closePendingOrder(struct ITradingStorage.Id _orderId) external
Check ITradingStorageUtils interface for documentation
getCollateral
function getCollateral(uint8 _index) external view returns (struct ITradingStorage.Collateral)
Check ITradingStorageUtils interface for documentation
isCollateralActive
function isCollateralActive(uint8 _index) public view returns (bool)
Check ITradingStorageUtils interface for documentation
isCollateralListed
function isCollateralListed(uint8 _index) external view returns (bool)
Check ITradingStorageUtils interface for documentation
getCollateralsCount
function getCollateralsCount() external view returns (uint8)
Check ITradingStorageUtils interface for documentation
getCollaterals
function getCollaterals() external view returns (struct ITradingStorage.Collateral[])
Check ITradingStorageUtils interface for documentation
getCollateralIndex
function getCollateralIndex(address _collateral) external view returns (uint8)
Check ITradingStorageUtils interface for documentation
getTradingActivated
function getTradingActivated() external view returns (enum ITradingStorage.TradingActivated)
Check ITradingStorageUtils interface for documentation
getTraderStored
function getTraderStored(address _trader) external view returns (bool)
Check ITradingStorageUtils interface for documentation
getTrade
function getTrade(address _trader, uint32 _index) external view returns (struct ITradingStorage.Trade)
Check ITradingStorageUtils interface for documentation
getTradeInfo
function getTradeInfo(address _trader, uint32 _index) external view returns (struct ITradingStorage.TradeInfo)
Check ITradingStorageUtils interface for documentation
getPendingOrder
function getPendingOrder(struct ITradingStorage.Id _orderId) external view returns (struct ITradingStorage.PendingOrder)
Check ITradingStorageUtils interface for documentation
getTradePendingOrderBlock
function getTradePendingOrderBlock(struct ITradingStorage.Id _tradeId, enum ITradingStorage.PendingOrderType _orderType) external view returns (uint256)
Check ITradingStorageUtils interface for documentation
getCounters
function getCounters(address _trader, enum ITradingStorage.CounterType _type) external view returns (struct ITradingStorage.Counter)
Check ITradingStorageUtils interface for documentation
getGToken
function getGToken(uint8 _collateralIndex) external view returns (address)
Check ITradingStorageUtils interface for documentation
getTradeLiquidationParams
function getTradeLiquidationParams(address _trader, uint32 _index) external view returns (struct IPairsStorage.GroupLiquidationParams)
Check ITradingStorageUtils interface for documentation
getCurrentContractsVersion
function getCurrentContractsVersion() external pure returns (enum ITradingStorage.ContractsVersion)
Check ITradingStorageUtils interface for documentation
getTradersCount
function getTradersCount() external view returns (uint256)
Check ITradingStorageUtils 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 ITradingStorage.TradingStorage 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.
_limitTpDistance
function _limitTpDistance(uint64 _openPrice, uint24 _leverage, uint64 _tp, bool _long) public pure returns (uint64)
_Limits take profit price distance for long/short based on '_openPrice', '_tp, '_leverage' and sets an automatic TP if 'tp' is zero.
Parameters
_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
function _limitSlDistance(uint64 _openPrice, uint24 _leverage, uint64 _sl, bool _long, uint256 _liqPnlThresholdP) public pure returns (uint64)
_Limits stop loss price distance for long/short based on '_openPrice', '_sl, 'leverage'.
Parameters
_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
function _limitTradeSlDistance(struct ITradingStorage.Trade _trade, uint64 _newSl) public view returns (uint64)
Limits trade stop loss price distance
Parameters
_newSl
uint64
_validateTrade
function _validateTrade(struct ITradingStorage.Trade _trade) internal view
Validation for trade struct (used by storeTrade and storePendingOrder for market open orders)
Parameters
Last updated
Was this helpful?