ITradingStorage

Contains the types for the GNSTradingStorage facet

TradingStorage

struct TradingStorage {
  enum ITradingStorage.TradingActivated tradingActivated;
  uint8 lastCollateralIndex;
  uint240 __placeholder;
  mapping(uint8 => struct ITradingStorage.Collateral) collaterals;
  mapping(uint8 => address) gTokens;
  mapping(address => uint8) collateralIndex;
  mapping(address => mapping(uint32 => struct ITradingStorage.Trade)) trades;
  mapping(address => mapping(uint32 => struct ITradingStorage.TradeInfo)) tradeInfos;
  mapping(address => mapping(uint32 => mapping(enum ITradingStorage.PendingOrderType => uint256))) tradePendingOrderBlock;
  mapping(address => mapping(uint32 => struct ITradingStorage.PendingOrder)) pendingOrders;
  mapping(address => mapping(enum ITradingStorage.CounterType => struct ITradingStorage.Counter)) userCounters;
  address[] traders;
  mapping(address => bool) traderStored;
  uint256[39] __gap;
}

PendingOrderType

enum PendingOrderType {
  MARKET_OPEN,
  MARKET_CLOSE,
  LIMIT_OPEN,
  STOP_OPEN,
  TP_CLOSE,
  SL_CLOSE,
  LIQ_CLOSE
}

CounterType

enum CounterType {
  TRADE,
  PENDING_ORDER
}

TradeType

enum TradeType {
  TRADE,
  LIMIT,
  STOP
}

TradingActivated

enum TradingActivated {
  ACTIVATED,
  CLOSE_ONLY,
  PAUSED
}

Collateral

struct Collateral {
  address collateral;
  bool isActive;
  uint88 __placeholder;
  uint128 precision;
  uint128 precisionDelta;
}

Id

struct Id {
  address user;
  uint32 index;
}

Trade

struct Trade {
  address user;
  uint32 index;
  uint16 pairIndex;
  uint24 leverage;
  bool long;
  bool isOpen;
  uint8 collateralIndex;
  enum ITradingStorage.TradeType tradeType;
  uint120 collateralAmount;
  uint64 openPrice;
  uint64 tp;
  uint64 sl;
  uint192 __placeholder;
}

TradeInfo

struct TradeInfo {
  uint32 createdBlock;
  uint32 tpLastUpdatedBlock;
  uint32 slLastUpdatedBlock;
  uint16 maxSlippageP;
  uint48 lastOiUpdateTs;
  uint48 collateralPriceUsd;
  uint48 __placeholder;
}

PendingOrder

struct PendingOrder {
  struct ITradingStorage.Trade trade;
  address user;
  uint32 index;
  bool isOpen;
  enum ITradingStorage.PendingOrderType orderType;
  uint32 createdBlock;
  uint16 maxSlippageP;
}

Counter

struct Counter {
  uint32 currentIndex;
  uint32 openCount;
  uint192 __placeholder;
}