GNSTradingInteractions
Facet #7: Trading (user interactions)
constructor
initializeTrading
Initializes the trading facet
Parameters
_marketOrdersTimeoutBlocks
uint16
The number of blocks after which a market order is considered timed out
_usersByPassTriggerLink
address[]
updateMarketOrdersTimeoutBlocks
Updates marketOrdersTimeoutBlocks
Parameters
_valueBlocks
uint16
blocks after which a market order times out
updateByPassTriggerLink
Updates the users that can bypass the link cost of triggerOrder
Parameters
_users
address[]
array of addresses that can bypass the link cost of triggerOrder
_shouldByPass
bool[]
whether each user should bypass the link cost
setTradingDelegate
_Sets delegate as the new delegate of caller (can call delegatedAction)
Parameters
_delegate
address
the new delegate address
removeTradingDelegate
Removes the delegate of caller (can't call delegatedAction)
delegatedTradingAction
_Caller executes a trading action on behalf of trader using delegatecall
Parameters
_trader
address
the trader address to execute the trading action for
_callData
bytes
the data to be executed (open trade/close trade, etc.)
openTrade
Opens a new trade/limit order/stop order
Parameters
_maxSlippageP
uint16
the maximum allowed slippage % when open the trade (1e3 precision)
_referrer
address
the address of the referrer (can only be set once for a trader)
openTradeNative
Wraps native token and opens a new trade/limit order/stop order
Parameters
_maxSlippageP
uint16
the maximum allowed slippage % when open the trade (1e3 precision)
_referrer
address
the address of the referrer (can only be set once for a trader)
updateMaxClosingSlippageP
Updates existing trade's max closing slippage % for caller
Parameters
_index
uint32
index of trade
_maxSlippageP
uint16
new max closing slippage % (1e3 precision)
closeTradeMarket
Closes an open trade (market order) for caller
Parameters
_index
uint32
the index of the trade of caller
_expectedPrice
uint64
expected closing price, used to check max slippage (1e10 precision)
updateOpenOrder
Updates an existing limit/stop order for caller
Parameters
_index
uint32
index of limit/stop order of caller
_triggerPrice
uint64
new trigger price of limit/stop order (1e10 precision)
_tp
uint64
new tp of limit/stop order (1e10 precision)
_sl
uint64
new sl of limit/stop order (1e10 precision)
_maxSlippageP
uint16
new max slippage % of limit/stop order (1e3 precision)
cancelOpenOrder
Cancels an open limit/stop order for caller
Parameters
_index
uint32
index of limit/stop order of caller
updateTp
Updates the tp of an open trade for caller
Parameters
_index
uint32
index of open trade of caller
_newTp
uint64
new tp of open trade (1e10 precision)
updateSl
Updates the sl of an open trade for caller
Parameters
_index
uint32
index of open trade of caller
_newSl
uint64
new sl of open trade (1e10 precision)
updateLeverage
Update trade leverage
Parameters
_index
uint32
index of trade
_newLeverage
uint24
new leverage (1e3)
increasePositionSize
Increase trade position size
Parameters
_index
uint32
index of trade
_collateralDelta
uint120
collateral to add (collateral precision)
_leverageDelta
uint24
partial trade leverage (1e3)
_expectedPrice
uint64
expected price of execution (1e10 precision)
_maxSlippageP
uint16
max slippage % (1e3)
decreasePositionSize
Decrease trade position size
Parameters
_index
uint32
index of trade
_collateralDelta
uint120
collateral to remove (collateral precision)
_leverageDelta
uint24
leverage to reduce by (1e3)
_expectedPrice
uint64
expected closing price, used to check max slippage (1e10 precision)
triggerOrder
Initiates a new trigger order (for tp/sl/liq/limit/stop orders)
Parameters
_packed
uint256
the packed data of the trigger order (orderType, trader, index)
cancelOrderAfterTimeout
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
_orderIndex
uint32
the id of the pending order to cancel
getWrappedNativeToken
Returns the wrapped native token or address(0) if the current chain, or the wrapped token, is not supported.
isWrappedNativeToken
Returns true if the token is the wrapped native token for the current chain, where supported.
Parameters
_token
address
token address
getTradingDelegate
Returns the address a trader delegates his trading actions to
Parameters
_trader
address
address of the trader
getMarketOrdersTimeoutBlocks
Returns the current marketOrdersTimeoutBlocks value
getByPassTriggerLink
Returns whether a user bypasses trigger link costs
Parameters
_user
address
address of the user
Last updated