TradingCallbacksUtils

GNSTradingCallbacks facet internal library

tradingActivated

modifier tradingActivated()

Modifier to only allow trading action when trading is activated (= revert if not activated)

tradingActivatedOrCloseOnly

modifier tradingActivatedOrCloseOnly()

Modifier to only allow trading action when trading is activated or close only (= revert if paused)

initializeCallbacks

function initializeCallbacks(uint8 _vaultClosingFeeP) internal

Check ITradingCallbacksUtils interface for documentation

updateVaultClosingFeeP

function updateVaultClosingFeeP(uint8 _valueP) internal

Check ITradingCallbacksUtils interface for documentation

updateTreasuryAddress

Check ITradingCallbacksUtils interface for documentation

claimPendingGovFees

Check ITradingCallbacksUtils interface for documentation

openTradeMarketCallback

Check ITradingCallbacksUtils interface for documentation

closeTradeMarketCallback

Check ITradingCallbacksUtils interface for documentation

executeTriggerOpenOrderCallback

Check ITradingCallbacksUtils interface for documentation

executeTriggerCloseOrderCallback

Check ITradingCallbacksUtils interface for documentation

updateLeverageCallback

Check ITradingCallbacksUtils interface for documentation

increasePositionSizeMarketCallback

Check ITradingCallbacksUtils interface for documentation

decreasePositionSizeMarketCallback

Check ITradingCallbacksUtils interface for documentation

getVaultClosingFeeP

Check ITradingCallbacksUtils interface for documentation

getPendingGovFeesCollateral

Check ITradingCallbacksUtils interface for documentation

validateTriggerOpenOrderCallback

Check ITradingCallbacksUtils interface for documentation

validateTriggerCloseOrderCallback

Check ITradingCallbacksUtils interface for documentation

_getSlot

Returns storage slot to use when fetching storage relevant to library

_getStorage

Returns storage pointer for storage struct in diamond contract, at defined slot

_getMultiCollatDiamond

Returns current address as multi-collateral diamond interface to call other facets functions.

_registerTrade

Registers a trade in storage, and handles all fees and rewards

Parameters

Name
Type
Description

_trade

Trade to register

_pendingOrder

Corresponding pending order

Return Values

Name
Type
Description

[0]

Final registered trade

_unregisterTrade

Unregisters a trade from storage, and handles all fees and rewards

Parameters

Name
Type
Description

_trade

Trade to unregister

_profitP

int256

Profit percentage (1e10)

_orderType

enum ITradingStorage.PendingOrderType

pending order type

_oraclePrice

uint256

oracle price without closing spread/impact (1e10)

_liqPrice

uint256

trade liquidation price (1e10)

Return Values

Name
Type
Description

tradeValueCollateral

uint256

Amount of collateral sent to trader, collateral + pnl (collateral precision)

_openTradePrep

Makes pre-trade checks: price impact, if trade should be cancelled based on parameters like: PnL, leverage, slippage, etc.

Parameters

Name
Type
Description

_trade

trade input

_executionPrice

uint256

execution price (1e10 precision)

_oraclePrice

uint256

oracle price (1e10 precision)

_spreadP

uint256

spread % (1e10 precision)

_maxSlippageP

uint256

max slippage % (1e3 precision)

_getPendingOrder

Returns pending order from storage

Parameters

Name
Type
Description

_orderId

Order ID

Return Values

Name
Type
Description

_getCollateralPriceUsd

Returns collateral price in USD

Parameters

Name
Type
Description

_collateralIndex

uint8

Collateral index

Return Values

Name
Type
Description

[0]

uint256

Collateral price in USD

_getTrade

Returns trade from storage

Parameters

Name
Type
Description

_trader

address

Trader address

_index

uint32

Trade index

Return Values

Name
Type
Description

_getTradeInfo

Returns trade info from storage

Parameters

Name
Type
Description

_trader

address

Trader address

_index

uint32

Trade index

Return Values

Name
Type
Description

Last updated

Was this helpful?