Interface for GNSTradingInteractions facet (inherits types and also contains functions, events, and custom errors)
initializeTrading
Copy function initializeTrading ( uint16 _marketOrdersTimeoutBlocks , address [] _usersByPassTriggerLink ) external
Initializes the trading facet
Parameters
updateMarketOrdersTimeoutBlocks
Copy function updateMarketOrdersTimeoutBlocks ( uint16 _valueBlocks ) external
Updates marketOrdersTimeoutBlocks
Parameters
updateByPassTriggerLink
Copy function updateByPassTriggerLink ( address [] _users , bool [] _shouldByPass ) external
Updates the users that can bypass the link cost of triggerOrder
Parameters
setTradingDelegate
Copy function setTradingDelegate ( address _delegate ) external
_Sets delegate as the new delegate of caller (can call delegatedAction)
Parameters
removeTradingDelegate
Copy function removeTradingDelegate () external
Removes the delegate of caller (can't call delegatedAction)
delegatedTradingAction
Copy function delegatedTradingAction ( address _trader , bytes _callData ) external returns ( bytes )
_Caller executes a trading action on behalf of trader using delegatecall
Parameters
openTrade
Copy function openTrade (struct ITradingStorage . Trade _trade , uint16 _maxSlippageP , address _referrer ) external
Opens a new trade/limit order/stop order
Parameters
openTradeNative
Copy function openTradeNative (struct ITradingStorage . Trade _trade , uint16 _maxSlippageP , address _referrer ) external payable
Wraps native token and opens a new trade/limit order/stop order
Parameters
updateMaxClosingSlippageP
Copy function updateMaxClosingSlippageP ( uint32 _index , uint16 _maxSlippageP ) external
Updates existing trade's max closing slippage % for caller
Parameters
closeTradeMarket
Copy function closeTradeMarket ( uint32 _index , uint64 _expectedPrice ) external
Closes an open trade (market order) for caller
Parameters
updateOpenOrder
Copy function updateOpenOrder ( uint32 _index , uint64 _triggerPrice , uint64 _tp , uint64 _sl , uint16 _maxSlippageP ) external
Updates an existing limit/stop order for caller
Parameters
cancelOpenOrder
Copy function cancelOpenOrder ( uint32 _index ) external
Cancels an open limit/stop order for caller
Parameters
updateTp
Copy function updateTp ( uint32 _index , uint64 _newTp ) external
Updates the tp of an open trade for caller
Parameters
updateSl
Copy function updateSl ( uint32 _index , uint64 _newSl ) external
Updates the sl of an open trade for caller
Parameters
triggerOrder
Copy function triggerOrder ( uint256 _packed ) external
Initiates a new trigger order (for tp/sl/liq/limit/stop orders)
Parameters
cancelOrderAfterTimeout
Copy function cancelOrderAfterTimeout ( uint32 _orderIndex ) external
Safety function in case oracles don't answer in time, allows caller to cancel a pending order and if relevant claim back any stuck collateral Only allowed for MARKET_OPEN, MARKET_CLOSE, UPDATE_LEVERAGE, MARKET_PARTIAL_OPEN, and MARKET_PARTIAL_CLOSE orders
Parameters
updateLeverage
Copy function updateLeverage ( uint32 _index , uint24 _newLeverage ) external
Update trade leverage
Parameters
increasePositionSize
Copy function increasePositionSize(uint32 _index, uint120 _collateralDelta, uint24 _leverageDelta, uint64 _expectedPrice, uint16 _maxSlippageP) external
Increase trade position size
Parameters
decreasePositionSize
Copy function decreasePositionSize(uint32 _index, uint120 _collateralDelta, uint24 _leverageDelta, uint64 _expectedPrice) external
Decrease trade position size
Parameters
getWrappedNativeToken
Copy function getWrappedNativeToken () external view returns ( address )
Returns the wrapped native token or address(0) if the current chain, or the wrapped token, is not supported.
isWrappedNativeToken
Copy function isWrappedNativeToken ( address _token ) external view returns ( bool )
Returns true if the token is the wrapped native token for the current chain, where supported.
Parameters
getTradingDelegate
Copy function getTradingDelegate ( address _trader ) external view returns ( address )
Returns the address a trader delegates his trading actions to
Parameters
getMarketOrdersTimeoutBlocks
Copy function getMarketOrdersTimeoutBlocks () external view returns ( uint16 )
Returns the current marketOrdersTimeoutBlocks value
getByPassTriggerLink
Copy function getByPassTriggerLink ( address _user ) external view returns ( bool )
Returns whether a user bypasses trigger link costs
Parameters
MarketOrdersTimeoutBlocksUpdated
Copy event MarketOrdersTimeoutBlocksUpdated ( uint256 newValueBlocks)
Emitted when marketOrdersTimeoutBlocks is updated
Parameters
ByPassTriggerLinkUpdated
Copy event ByPassTriggerLinkUpdated ( address user, bool bypass)
Emitted when a user is allowed/disallowed to bypass the link cost of triggerOrder
Parameters
MarketOrderInitiated
Copy event MarketOrderInitiated (struct ITradingStorage.Id orderId, address trader, uint16 pairIndex, bool open)
Emitted when a market order is initiated
Parameters
OpenOrderPlaced
Copy event OpenOrderPlaced ( address trader, uint16 pairIndex, uint32 index)
Emitted when a new limit/stop order is placed
Parameters
OpenLimitUpdated
Copy event OpenLimitUpdated(address trader, uint16 pairIndex, uint32 index, uint64 newPrice, uint64 newTp, uint64 newSl, uint64 maxSlippageP)
Parameters
OpenLimitCanceled
Copy event OpenLimitCanceled ( address trader, uint16 pairIndex, uint32 index)
Emitted when a limit/stop order is canceled (collateral sent back to trader)
Parameters
TriggerOrderInitiated
Copy event TriggerOrderInitiated (struct ITradingStorage.Id orderId, address trader, uint16 pairIndex, bool byPassesLinkCost)
Emitted when a trigger order is initiated (tp/sl/liq/limit/stop orders)
Parameters
ChainlinkCallbackTimeout
Copy event ChainlinkCallbackTimeout (struct ITradingStorage.Id pendingOrderId, uint256 pairIndex)
Emitted when a pending market order is canceled due to timeout
Parameters
CouldNotCloseTrade
Copy event CouldNotCloseTrade ( address trader, uint16 pairIndex, uint32 index)
Emitted when a pending market order is canceled due to timeout and new closeTradeMarket() call failed
Parameters
NativeTokenWrapped
Copy event NativeTokenWrapped ( address trader, uint256 nativeTokenAmount)
Emitted when a native token is wrapped
Parameters
NotWrappedNativeToken
Copy error NotWrappedNativeToken ()
DelegateNotApproved
Copy error DelegateNotApproved ()
PriceZero
AboveExposureLimits
Copy error AboveExposureLimits ()
CollateralNotActive
Copy error CollateralNotActive ()
PriceImpactTooHigh
Copy error PriceImpactTooHigh ()
NoTrade
NoOrder
AlreadyBeingMarketClosed
Copy error AlreadyBeingMarketClosed ()
ConflictingPendingOrder
Copy error ConflictingPendingOrder ( enum ITradingStorage .PendingOrderType)
WrongLeverage
Copy error WrongLeverage ()
WrongTp
WrongSl
WaitTimeout
PendingTrigger
Copy error PendingTrigger ()
NoSl
NoTp
NotYourOrder
DelegatedActionNotAllowed
Copy error DelegatedActionNotAllowed()
InsufficientCollateral
Copy error InsufficientCollateral()