Account

Example code snippets to query the indexer for subaccount related data.

Using gRPC

Fetch user's portfolio details

This includes available balance, unrealized Pnl, and portfolio value. Note: deprecated -> use Portfolio instead

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcAccountApi = new IndexerGrpcAccountApi(endpoints.indexer)

const injectiveAddress = 'inj...'

const portfolio = await indexerGrpcAccountApi.fetchPortfolio(injectiveAddress)

console.log(portfolio)

Fetch user's trading rewards per epoch

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcAccountApi = new IndexerGrpcAccountApi(endpoints.indexer)

const injectiveAddress = 'inj...'
const epoch = -1 // current epoch

const tradingRewards = await indexerGrpcAccountApi.fetchRewards({
  address: injectiveAddress,
  epoch,
})

console.log(tradingRewards)

Fetch subaccounts associated with an injective address

Fetch balance of a subaccount for a specific denom

Fetch of balances for a subaccount

Fetch subacount history

Fetch a summary of a subaccount's orders

Fetch states of spot or (and) derivatives orders

Last updated