Interface for GNSTradingStorage facet (inherits types and also contains functions, events, and custom errors)
initializeTradingStorage
Copy function initializeTradingStorage(address _gns, address _gnsStaking, address[] _collaterals, address[] _gTokens) external
Initializes the trading storage facet
Parameters
updateTradingActivated
Copy function updateTradingActivated (enum ITradingStorage . TradingActivated _activated ) external
Updates the trading activated state
Parameters
addCollateral
Copy function addCollateral ( address _collateral , address _gToken ) external
Adds a new supported collateral
Parameters
toggleCollateralActiveState
Copy function toggleCollateralActiveState ( uint8 _collateralIndex ) external
Toggles the active state of a supported collateral
Parameters
updateGToken
Copy function updateGToken ( address _collateral , address _gToken ) external
Updates the contracts of a supported collateral trading stack
Parameters
storeTrade
Copy function storeTrade(struct ITradingStorage.Trade _trade, struct ITradingStorage.TradeInfo _tradeInfo) external returns (struct ITradingStorage.Trade)
Stores a new trade (trade/limit/stop)
Parameters
updateTradeMaxClosingSlippageP
Copy function updateTradeMaxClosingSlippageP (struct ITradingStorage . Id _tradeId , uint16 _maxSlippageP ) external
Updates an existing trade max closing slippage %
Parameters
updateTradeCollateralAmount
Copy function updateTradeCollateralAmount (struct ITradingStorage . Id _tradeId , uint120 _collateralAmount ) external
Updates an open trade collateral
Parameters
updateTradePosition
Copy function updateTradePosition(struct ITradingStorage.Id _tradeId, uint120 _collateralAmount, uint24 _leverage, uint64 _openPrice, bool _isPartialIncrease, bool _isPnlPositive) external
Updates an open trade collateral
Parameters
updateOpenOrderDetails
Copy function updateOpenOrderDetails(struct ITradingStorage.Id _tradeId, uint64 _openPrice, uint64 _tp, uint64 _sl, uint16 _maxSlippageP) external
Updates an open order details (limit/stop)
Parameters
updateTradeTp
Copy function updateTradeTp (struct ITradingStorage . Id _tradeId , uint64 _newTp ) external
Updates the take profit of an open trade
Parameters
updateTradeSl
Copy function updateTradeSl (struct ITradingStorage . Id _tradeId , uint64 _newSl ) external
Updates the stop loss of an open trade
Parameters
closeTrade
Copy function closeTrade (struct ITradingStorage . Id _tradeId , bool _isPnlPositive ) external
Marks an open trade/limit/stop as closed
Parameters
storePendingOrder
Copy function storePendingOrder(struct ITradingStorage.PendingOrder _pendingOrder) external returns (struct ITradingStorage.PendingOrder)
Stores a new pending order
Parameters
closePendingOrder
Copy function closePendingOrder (struct ITradingStorage . Id _orderId ) external
Closes a pending order
Parameters
getCollateral
Copy function getCollateral ( uint8 _index ) external view returns (struct ITradingStorage . Collateral )
Returns collateral data by index
Parameters
isCollateralActive
Copy function isCollateralActive ( uint8 _index ) external view returns ( bool )
Returns whether can open new trades with a collateral
Parameters
isCollateralListed
Copy function isCollateralListed ( uint8 _index ) external view returns ( bool )
Returns whether a collateral has been listed
Parameters
getCollateralsCount
Copy function getCollateralsCount () external view returns ( uint8 )
Returns the number of supported collaterals
getCollaterals
Copy function getCollaterals () external view returns (struct ITradingStorage . Collateral [])
Returns the supported collaterals
getCollateralIndex
Copy function getCollateralIndex ( address _collateral ) external view returns ( uint8 )
Returns the index of a supported collateral
Parameters
getTradingActivated
Copy function getTradingActivated () external view returns (enum ITradingStorage . TradingActivated )
Returns the trading activated state
getTraderStored
Copy function getTraderStored ( address _trader ) external view returns ( bool )
Returns whether a trader is stored in the traders array
Parameters
getTradersCount
Copy function getTradersCount () external view returns ( uint256 )
Returns the length of the traders array
getTraders
Copy function getTraders ( uint32 _offset , uint32 _limit ) external view returns ( address [])
Returns all traders that have open trades using a pagination system
Parameters
getTrade
Copy function getTrade ( address _trader , uint32 _index ) external view returns (struct ITradingStorage . Trade )
Returns open trade/limit/stop order
Parameters
getTrades
Copy function getTrades ( address _trader ) external view returns (struct ITradingStorage . Trade [])
Returns all open trades/limit/stop orders for a trader
Parameters
getAllTradesForTraders
Copy function getAllTradesForTraders(address[] _traders, uint256 _offset, uint256 _limit) external view returns (struct ITradingStorage.Trade[])
Returns all trade/limit/stop orders using a pagination system
Parameters
getAllTrades
Copy function getAllTrades ( uint256 _offset , uint256 _limit ) external view returns (struct ITradingStorage . Trade [])
Returns all trade/limit/stop orders using a pagination system. Calls getAllTradesForTraders
internally with all traders.
Parameters
getTradeInfo
Copy function getTradeInfo ( address _trader , uint32 _index ) external view returns (struct ITradingStorage . TradeInfo )
Returns trade info of an open trade/limit/stop order
Parameters
getTradeInfos
Copy function getTradeInfos ( address _trader ) external view returns (struct ITradingStorage . TradeInfo [])
Returns all trade infos of open trade/limit/stop orders for a trader
Parameters
getAllTradeInfosForTraders
Copy function getAllTradeInfosForTraders(address[] _traders, uint256 _offset, uint256 _limit) external view returns (struct ITradingStorage.TradeInfo[])
Returns all trade infos of open trade/limit/stop orders using a pagination system
Parameters
getAllTradeInfos
Copy function getAllTradeInfos ( uint256 _offset , uint256 _limit ) external view returns (struct ITradingStorage . TradeInfo [])
Returns all trade infos of open trade/limit/stop orders using a pagination system. Calls getAllTradeInfosForTraders
internally with all traders.
Parameters
getPendingOrder
Copy function getPendingOrder(struct ITradingStorage.Id _orderId) external view returns (struct ITradingStorage.PendingOrder)
Returns a pending ordeer
Parameters
getPendingOrders
Copy function getPendingOrders ( address _user ) external view returns (struct ITradingStorage . PendingOrder [])
Returns all pending orders for a trader
Parameters
getAllPendingOrdersForTraders
Copy function getAllPendingOrdersForTraders(address[] _traders, uint256 _offset, uint256 _limit) external view returns (struct ITradingStorage.PendingOrder[])
Returns all pending orders using a pagination system
Parameters
getAllPendingOrders
Copy function getAllPendingOrders(uint256 _offset, uint256 _limit) external view returns (struct ITradingStorage.PendingOrder[])
Returns all pending orders using a pagination system Calls getAllPendingOrdersForTraders
internally with all traders.
Parameters
getTradePendingOrderBlock
Copy function getTradePendingOrderBlock(struct ITradingStorage.Id _tradeId, enum ITradingStorage.PendingOrderType _orderType) external view returns (uint256)
Returns the block number of the pending order for a trade (0 = doesn't exist)
Parameters
getCounters
Copy function getCounters(address _trader, enum ITradingStorage.CounterType _type) external view returns (struct ITradingStorage.Counter)
Returns the counters of a trader (currentIndex / open count for trades/tradeInfos and pendingOrders mappings)
Parameters
getCountersForTraders
Copy function getCountersForTraders(address[] _traders, enum ITradingStorage.CounterType _type) external view returns (struct ITradingStorage.Counter[])
Returns the counters for a list of traders
Parameters
getGToken
Copy function getGToken ( uint8 _collateralIndex ) external view returns ( address )
Returns the address of the gToken for a collateral stack
Parameters
getTradeLiquidationParams
Copy function getTradeLiquidationParams(address _trader, uint32 _index) external view returns (struct IPairsStorage.GroupLiquidationParams)
Returns the liquidation params for a trade
Parameters
getTradesLiquidationParams
Copy function getTradesLiquidationParams(address _trader) external view returns (struct IPairsStorage.GroupLiquidationParams[])
Returns all trade liquidation params of open trade/limit/stop orders for a trader
Parameters
getAllTradesLiquidationParamsForTraders
Copy function getAllTradesLiquidationParamsForTraders(address[] _traders, uint256 _offset, uint256 _limit) external view returns (struct IPairsStorage.GroupLiquidationParams[])
Returns all trade liquidation params of open trade/limit/stop orders using a pagination system
Parameters
getAllTradesLiquidationParams
Copy function getAllTradesLiquidationParams(uint256 _offset, uint256 _limit) external view returns (struct IPairsStorage.GroupLiquidationParams[])
Returns all trade liquidation params of open trade/limit/stop orders using a pagination system Calls getAllTradesLiquidationParamsForTraders
internally with all traders.
Parameters
getCurrentContractsVersion
Copy function getCurrentContractsVersion () external pure returns (enum ITradingStorage . ContractsVersion )
Returns the current contracts version
TradingActivatedUpdated
Copy event TradingActivatedUpdated (enum ITradingStorage.TradingActivated activated)
Emitted when the trading activated state is updated
Parameters
CollateralAdded
Copy event CollateralAdded ( address collateral, uint8 index, address gToken)
Emitted when a new supported collateral is added
Parameters
CollateralUpdated
Copy event CollateralUpdated ( uint8 index, bool isActive)
Emitted when an existing supported collateral active state is updated
Parameters
CollateralDisabled
Copy event CollateralDisabled(uint8 index)
Emitted when an existing supported collateral is disabled (can still close trades but not open new ones)
Parameters
GTokenUpdated
Copy event GTokenUpdated(address collateral, uint8 index, address gToken)
Emitted when the contracts of a supported collateral trading stack are updated
Parameters
TradeStored
Copy event TradeStored(address user, uint32 index, struct ITradingStorage.Trade trade, struct ITradingStorage.TradeInfo tradeInfo, struct IPairsStorage.GroupLiquidationParams liquidationParams)
Emitted when a new trade is stored
Parameters
TradeMaxClosingSlippagePUpdated
Copy event TradeMaxClosingSlippagePUpdated(address user, uint32 index, uint16 maxClosingSlippageP)
Emitted when the max closing slippage % of an open trade is updated
Parameters
TradeCollateralUpdated
Copy event TradeCollateralUpdated(address user, uint32 index, uint120 collateralAmount)
Emitted when an open trade collateral is updated
Parameters
TradePositionUpdated
Copy event TradePositionUpdated(address user, uint32 index, uint120 collateralAmount, uint24 leverage, uint64 openPrice, uint64 newTp, uint64 newSl, bool isPartialIncrease, bool isPnlPositive)
Emitted when an open trade collateral is updated
Parameters
OpenOrderDetailsUpdated
Copy event OpenOrderDetailsUpdated(address user, uint32 index, uint64 openPrice, uint64 tp, uint64 sl, uint16 maxSlippageP)
Emitted when an existing trade/limit order/stop order is updated
Parameters
TradeTpUpdated
Copy event TradeTpUpdated(address user, uint32 index, uint64 newTp)
Emitted when the take profit of an open trade is updated
Parameters
TradeSlUpdated
Copy event TradeSlUpdated(address user, uint32 index, uint64 newSl)
Emitted when the stop loss of an open trade is updated
Parameters
TradeClosed
Copy event TradeClosed(address user, uint32 index, bool isPnlPositive)
Emitted when an open trade is closed
Parameters
PendingOrderStored
Copy event PendingOrderStored(struct ITradingStorage.PendingOrder pendingOrder)
Emitted when a new pending order is stored
Parameters
PendingOrderClosed
Copy event PendingOrderClosed(struct ITradingStorage.Id orderId)
Emitted when a pending order is closed
Parameters
MissingCollaterals
Copy error MissingCollaterals()
CollateralAlreadyActive
Copy error CollateralAlreadyActive()
CollateralAlreadyDisabled
Copy error CollateralAlreadyDisabled()
TradePositionSizeZero
Copy error TradePositionSizeZero()
TradeOpenPriceZero
Copy error TradeOpenPriceZero()
TradePairNotListed
Copy error TradePairNotListed()
TradeTpInvalid
Copy error TradeTpInvalid()
TradeSlInvalid
Copy error TradeSlInvalid()
MaxSlippageZero
Copy error MaxSlippageZero()
TradeInfoCollateralPriceUsdZero
Copy error TradeInfoCollateralPriceUsdZero()