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
  • Addresses
  • Interactions
  • Place a Trade
  • Place a Limit Order
  • Update Active Trade
  • Update Pending Limit Order
  • Cancel Pending Limit Order
  • Close a Trade
  • Update Leverage
  • Update Position Size
  • Events

Was this helpful?

  1. Developer
  2. Integrators

Trading Contracts

Details how to interact with trading contracts

PreviousIntegratorsNextBackend

Last updated 10 months ago

Was this helpful?

To interact with trading contracts, you should call the respective methods on the GNSMultiCollatDiamond contract. Each method within the facets can be accessed through this central contract, ensuring a streamlined approach to contract interactions. You can find network-specific GNSMultiCollatDiamond address in

Addresses

For latest addresses, refer to:

If you are using testnet, the for GNSMultiCollatDiamond is: 0xd659a15812064C79E189fd950A189b15c75d3186

Interactions

Below is a list of available actions, consisting of market & limit orders, as well as updates. Where possible, NatSpec documentation is linked to. For full reference, see Technical Reference.

  • Place a trade*

  • Place a limit order

  • Update a trade

  • Update a limit order

  • Cancel a limit order

  • Close a trade*

  • Update leverage (decrease/increase)

  • Increase position size

  • Decrease position size

*Requires order fulfillment. Integrators make requests, and oracles fulfill them.

Place a Trade

Place a trade using the following functions. Use tradeType = 0.

If an order hasn't been fulfilled in 60 seconds, collateral can be claimed back using the timeout function:

Place a Limit Order

Same as market order, but provided tradeType of 1 or 2.

Limit: To be used when you want to go long at a lower price than present, or to go short if the price reaches a higher price than present. Executes at exact price set if price reaches threshold + spread.

Stop: To be used when you want to go long if the price reaches a higher price than present, or to go short if the price reaches a lower price than present. You might want to use this to long a breakout, or short a breakdown. The execution price is the current market price + spread.

Update Active Trade

Support updating take profit (TP) and stop loss (SL).

Update Pending Limit Order

If a limit order hasn't been fulfilled yet, it can be updated

Cancel Pending Limit Order

If a limit order hasn't been fulfilled yet, it can be canceled

Close a Trade

Market close a trade

If the trade hasn't been closed in 60 seconds, a timeout may be initiated, allowing for another close attempt:

Update Leverage

Update leverage for a trade

Update Position Size

Decrease position size (by decreasing collateral amount or leverage)

Increase position size (by increasing collateral amount or leverage or both)

Events

Events are emitted to allow off-chain services to stay updated. You can subscribe to these directly, or review the Backendpage for instructions on receiving from a WebSocket stream. It is recommended to use the backend.

Core Events

For opening or closing a trade: MarketOrderInitiated -> MarketExecuted

For placing a limit order: OpenOrderPlaced

For updating a trade: TradeSlUpdated or TradeTpUpdated

For fulfilling a limit order (SL, TP, Open limit): LimitExecuted

For updating leverage: LeverageUpdateInitiated-> LeverageUpdateExecuted

For updating position size (increase): PositionSizeUpdateInitiated-> PositionSizeIncreaseExecuted

For updating position size (decrease): PositionSizeUpdateInitiated-> PositionSizeDeccreaseExecuted

All Lifecycle Events

Active Contracts page
Arbitrum Sepolia address
Active Contracts: