Gains Network
  • 📚Home
  • Gains Network
    • 🔎Overview
    • 🍏GNS Token
    • 📔Contract Addresses
      • Apechain Mainnet
      • Arbitrum Mainnet
      • Base Mainnet
      • Polygon Mainnet
  • gTrade (Leveraged Trading)
    • 🔎Overview
    • 🎛️Setting up to trade
      • 🟣Polygon Network Setup
      • 🔵Arbitrum Network Setup
    • 🏦Opening / Closing trades
    • 💲Trade Collaterals
      • Spotlight: WETH
    • 📖Asset classes
      • 🪙Cryptocurrencies
      • 💵Forex
      • 🛢️Commodities
    • 🎫Fees & Spread
    • 📰Pair List
    • 🧒How to use Practice Mode
    • ⚡One-Click Trading (1CT)
    • 🌌gTrade Solana
    • 📺Video tutorials
  • Loyalty Programs
    • Prime Trader
    • gTrade Credits
  • Community
    • gTrade Guardians
    • Governance forum
  • Reward Pools
    • 💚GNS Staking
    • 👛gToken Vaults
      • 👷Staker Functions
      • ❔Staker FAQ
      • ⏳Upgrades, updates, and timelocks
    • 🔼Active Pools & Incentives
  • Help
    • ❓FAQ
    • ⏳Chain congestion
  • Bridges
    • 🪐Arbitrum <-> Polygon Bridge
    • 🪐ERC20 Bridge (Polygon)
    • 🪐NFT Bridge (Polygon)
  • Developer
    • Integrators
      • Trading Contracts
      • Backend
      • Price Feed
      • Guides
        • v9 migration
        • Calculating borrowing fees
        • Calculating liquidation price
    • Technical Reference
      • Contracts
        • Changelogs
          • v9.2.1 Update
          • v9.1 Update
          • v9.1.1 Update
          • v9 Update
        • Core
          • Abstract
            • GNSAddressStore
            • GNSDiamondCut
            • GNSDiamondLoupe
            • GNSDiamondStorage
          • Facets
            • GNSBorrowingFees
            • GNSOtc
            • GNSPriceAggregator
            • GNSTradingInteractions
            • GNSTriggerRewards
            • GNSFeeTiers
            • GNSPairsStorage
            • GNSPriceImpact
            • GNSReferrals
            • GNSTradingCallbacks
            • GNSTradingStorage
          • GNSMultiCollatDiamond
          • GNSStaking
          • GToken
          • GTokenOpenPnlFeed
        • Interfaces
          • Libraries
            • IBorrowingFeesUtils
            • IOtcUtils
            • IPriceAggregatorUtils
            • ITriggerRewardsUtils
            • IFeeTiersUtils
            • IPairsStorageUtils
            • IPriceImpactUtils
            • IReferralsUtils
            • ITradingCallbacksUtils
            • ITradingCommonUtils
            • ITradingInteractionsUtils
            • ITradingStorageUtils
            • IUpdateLeverageUtils
            • IUpdatePositionSizeUtils
          • Types
            • IAddressStore
            • IBorrowingFees
            • IDiamondStorage
            • IOtc
            • IPriceAggregator
            • ITradingStorage
            • ITradingInteractions
            • ITriggerRewards
            • ITypes
            • IUpdateLeverage
            • IPairsStorage
            • IFeeTiers
            • IPriceImpact
            • IReferrals
            • ITradingCallbacks
            • IUpdatePositionSize
          • IChainlinkFeed
          • IArbSys
          • IChainlinkOracle
          • IERC20
          • IERC721
          • IERC721Design
          • IGeneralErrors
          • IGNSAddressStore
          • IGNSDiamond
          • IGNSDiamondCut
          • IGNSMultiCollatDiamond
          • IGNSDiamondLoupe
          • IGNSStaking
          • IGToken
          • IGTokenLockedDepositNft
          • IGTokenOpenPnlFeed
          • IGTokenLockedDepositNftDesign
          • ILiquidityPool
          • IRateProvider
          • IOwnable
        • Libraries
          • updateLeverage
            • UpdateLeverageLifecycles
          • updatePositionSize
            • IncreasePositionSizeUtils
            • DecreasePositionSizeUtils
            • UpdatePositionSizeLifecycles
          • AddressStoreUtils
          • ChainlinkClientUtils
          • ChainUtils
          • ConstantsUtils
          • CollateralUtils
          • DiamondUtils
          • LiquidityPoolUtils
          • OtcUtils
          • PackingUtils
          • StorageUtils
          • TriggerRewardsUtils
          • ArrayGetters
          • BorrowingFeesUtils
          • FeeTiersUtils
          • PriceAggregatorUtils
          • PriceImpactUtils
          • ReferralsUtils
          • TradingCallbacksUtils
          • PairsStorageUtils
          • TradingCommonUtils
          • TradingStorageUtils
          • TradingInteractionsUtils
        • Misc
          • EpochBasedTokenClaim
          • GNSCompensationHandler
          • GTokenRateProvider
          • GTokenLockedDepositNftDesign
          • ManagerTimelock
          • OwnerTimelock
          • VotingDelegator
        • Tokens
          • GainsNetworkToken
          • GTokenLockedDepositNft
      • Backend
        • Backend Types
      • SDK
        • Client Types
  • Archived
    • 🖼️gFARM2 NFTs
Powered by GitBook
On this page
  • constructor
  • initializeCallbacks
  • Parameters
  • initializeTreasuryAddress
  • Parameters
  • updateVaultClosingFeeP
  • Parameters
  • updateTreasuryAddress
  • Parameters
  • claimPendingGovFees
  • openTradeMarketCallback
  • Parameters
  • closeTradeMarketCallback
  • Parameters
  • executeTriggerOpenOrderCallback
  • Parameters
  • executeTriggerCloseOrderCallback
  • Parameters
  • getVaultClosingFeeP
  • getPendingGovFeesCollateral
  • updateLeverageCallback
  • Parameters
  • increasePositionSizeMarketCallback
  • Parameters
  • decreasePositionSizeMarketCallback
  • Parameters
  • validateTriggerOpenOrderCallback
  • Parameters
  • validateTriggerCloseOrderCallback
  • Parameters

Was this helpful?

  1. Developer
  2. Technical Reference
  3. Contracts
  4. Core
  5. Facets

GNSTradingCallbacks

Facet #8: Callbacks (to execute actions after receiving median price from price aggregator)

constructor

constructor() public

initializeCallbacks

function initializeCallbacks(uint8 _vaultClosingFeeP) external

Parameters

Name
Type
Description

_vaultClosingFeeP

uint8

the % of closing fee going to vault

initializeTreasuryAddress

function initializeTreasuryAddress(address _treasury) external

Initialize the treasury address

Parameters

Name
Type
Description

_treasury

address

the treasury address

updateVaultClosingFeeP

function updateVaultClosingFeeP(uint8 _valueP) external

Update the % of closing fee going to vault

Parameters

Name
Type
Description

_valueP

uint8

the % of closing fee going to vault

updateTreasuryAddress

function updateTreasuryAddress(address _treasury) external

Updates the treasury address

Parameters

Name
Type
Description

_treasury

address

the new treasury address

claimPendingGovFees

function claimPendingGovFees() external

Claim the pending gov fees for all collaterals

openTradeMarketCallback

function openTradeMarketCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual

Executes a pending open trade market order

Parameters

Name
Type
Description

_a

the price aggregator answer (order id, price, etc.)

closeTradeMarketCallback

function closeTradeMarketCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual

Executes a pending close trade market order

Parameters

Name
Type
Description

_a

the price aggregator answer (order id, price, etc.)

executeTriggerOpenOrderCallback

function executeTriggerOpenOrderCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual

Executes a pending open trigger order (for limit/stop orders)

Parameters

Name
Type
Description

_a

the price aggregator answer (order id, price, etc.)

executeTriggerCloseOrderCallback

function executeTriggerCloseOrderCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual

Executes a pending close trigger order (for tp/sl/liq orders)

Parameters

Name
Type
Description

_a

the price aggregator answer (order id, price, etc.)

getVaultClosingFeeP

function getVaultClosingFeeP() external view returns (uint8)

Returns the current vaultClosingFeeP value (%)

getPendingGovFeesCollateral

function getPendingGovFeesCollateral(uint8 _collateralIndex) external view returns (uint256)

Returns the current pending gov fees for a collateral index (collateral precision)

updateLeverageCallback

function updateLeverageCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual

Executes a pending update leverage order

Parameters

Name
Type
Description

_a

the price aggregator answer (order id, price, etc.)

increasePositionSizeMarketCallback

function increasePositionSizeMarketCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual

Executes a pending increase position size market order

Parameters

Name
Type
Description

_a

the price aggregator answer (order id, price, etc.)

decreasePositionSizeMarketCallback

function decreasePositionSizeMarketCallback(struct ITradingCallbacks.AggregatorAnswer _a) external virtual

Executes a pending decrease position size market order

Parameters

Name
Type
Description

_a

the price aggregator answer (order id, price, etc.)

validateTriggerOpenOrderCallback

function validateTriggerOpenOrderCallback(struct ITradingStorage.Id _tradeId, enum ITradingStorage.PendingOrderType _orderType, uint64 _open, uint64 _high, uint64 _low) external view returns (struct ITradingStorage.Trade t, enum ITradingCallbacks.CancelReason cancelReason, struct ITradingCallbacks.Values v)

Makes open trigger (STOP/LIMIT) checks like slippage, price impact, missed targets and returns cancellation reason if any

Parameters

Name
Type
Description

_tradeId

the id of the trade

_orderType

enum ITradingStorage.PendingOrderType

the pending order type

_open

uint64

the open value from an aggregator answer

_high

uint64

the high value from an aggregator answer

_low

uint64

the low value from an aggregator answer

validateTriggerCloseOrderCallback

function validateTriggerCloseOrderCallback(struct ITradingStorage.Id _tradeId, enum ITradingStorage.PendingOrderType _orderType, uint64 _open, uint64 _high, uint64 _low) external view returns (struct ITradingStorage.Trade t, enum ITradingCallbacks.CancelReason cancelReason, struct ITradingCallbacks.Values v)

Makes close trigger (SL/TP/LIQ) checks like slippage and price impact and returns cancellation reason if any

Parameters

Name
Type
Description

_tradeId

the id of the trade

_orderType

enum ITradingStorage.PendingOrderType

the pending order type

_open

uint64

the open value from an aggregator answer

_high

uint64

the high value from an aggregator answer

_low

uint64

the low value from an aggregator answer

PreviousGNSReferralsNextGNSTradingStorage

Last updated 7 months ago

Was this helpful?

ITradingCallbacks.AggregatorAnswer
ITradingCallbacks.AggregatorAnswer
ITradingCallbacks.AggregatorAnswer
ITradingCallbacks.AggregatorAnswer
ITradingCallbacks.AggregatorAnswer
ITradingCallbacks.AggregatorAnswer
ITradingCallbacks.AggregatorAnswer
ITradingStorage.Id
ITradingStorage.Id