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