Exchange

Example code snippets to query the exchange module on the chain.

Using gRPC

Fetch parameters such as the default spot and derivatives fees/trading rewards

import { ChainGrpcExchangeApi } from '@injectivelabs/sdk-ts'
import { getNetworkEndpoints, Network } from '@injectivelabs/networks'

const endpoints = getNetworkEndpoints(Network.Testnet)
const chainGrpcExchangeApi = new ChainGrpcExchangeApi(endpoints.grpc)

const moduleParams = await chainGrpcExchangeApi.fetchModuleParams()

console.log(moduleParams)

Fetch the fee discount schedules

import { ChainGrpcExchangeApi } from '@injectivelabs/sdk-ts'
import { getNetworkEndpoints, Network } from '@injectivelabs/networks'

const endpoints = getNetworkEndpoints(Network.Testnet)
const chainGrpcExchangeApi = new ChainGrpcExchangeApi(endpoints.grpc)

const feeDiscountSchedule =
  await chainGrpcExchangeApi.fetchFeeDiscountSchedule()

console.log(feeDiscountSchedule)

Fetch the fee discounts associated with an injective address

Fetch the details regarding the trading reward campaign, such as the total reward points

Fetch the trading rewards points for an injective address

Fetch the pending trading rewards points for injective addresses

Fetch the current positions, such as subaccountId, marketId, and position

Fetch the subaccount trade nonce

Last updated