Injective | TS & dApps Docs
DocumentationInjective TS
  • Overview
  • Getting Started
    • Technical Concepts
    • Application Concepts
      • Calculations
        • Min Price Tick Size
        • Min Quantity Tick Size
      • Networks
      • CosmJs Support
    • Assets
      • Creating Tokens
      • Denom Client (deprecated)
      • Injective Lists
    • Running examples
  • Wallets
    • Getting Started
    • Accounts
    • Wallet Connections
    • Wallet Strategy
    • Offchain (Arbitrary) Data
  • Querying
    • Getting Started
    • Chain
      • Auction
      • Auth
      • Bank
      • Distribution
      • Exchange
      • Governance
      • IBC
      • Mint
      • Insurance Funds
      • Oracle
      • Peggy
      • Permissions
      • Staking
      • Tendermint
      • Wasm
      • WasmX
      • Token Factory
    • Indexer
      • Account
      • Auction
      • Derivatives
      • Explorer
      • Insurance Funds
      • Markets
      • Leaderboard
      • Mito
      • Oracle
      • Portfolio
      • Spot
      • Web3Gw Transactions
      • Streaming
        • Account
        • Auction
        • Derivatives
        • Oracle
        • Portfolio
        • Spot
        • Explorer
    • Ethereum (GraphQL)
  • Transactions
    • Getting Started
    • Cosmos
      • Ledger through Keplr Wallet
    • Ethereum
      • Ethereum Ledger
    • MsgBroadcaster
    • Private Key
    • Web3 Gateway
  • Core Modules (& examples)
    • Getting Started
    • Auction
    • AuthZ
    • Bank
    • Distribution
    • Exchange
    • Feegrant
    • Governance
    • IBC
    • Insurance
    • Peggy
    • Permissions
    • Staking
    • Tokenfactory
    • Wasm
  • Smart Contracts
    • Cosmwasm
      • Injective Name Service
      • Neptune Service
      • CW20 to Bank & Market Order in One Transaction
  • Bridges
    • Getting Started
    • Ethereum
    • IBC
    • Wormhole
  • Building Dapps
    • Getting Started
    • Configuring Nuxt
    • Configuring React
    • dApps Examples
      • Smart Contract
      • DEX
      • Bridge
      • Simple HTML example with Webpack
Powered by GitBook
On this page
  1. Querying
  2. Indexer

Mito

PreviousLeaderboardNextOracle

Last updated 1 year ago

Example code snippets to query the indexer for the Mito vault module related data.

Mito Documentation has been moved here visit.

[Outdated] Using gRPC

Fetch a vault based off it's contract address, such as the vault's tvl or profits

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcNinjaApi = new IndexerGrpcNinjaApi(endpoints.ninjaApi)

const contractAddress = '0x...' /* optional param */
const slug = 'derivative-vault' /* optional param */

const vault = await indexerGrpcNinjaApi.fetchVault({
  contractAddress,
  slug,
})

console.log(vault)

Fetch vaults and associated details

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcNinjaApi = new IndexerGrpcNinjaApi(endpoints.ninjaApi)

const vault = await indexerGrpcNinjaApi.fetchVaults()

console.log(vault)

Fetch the lp token price chart for a vault based on the vault address

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcNinjaApi = new IndexerGrpcNinjaApi(endpoints.ninjaApi)

const vaultAddress = 'inj...'
const from = 50 /* optional pagination params */
const to = 150 /* optional pagination params */

const lpTokenPriceChart = await indexerGrpcNinjaApi.fetchLpTokenPriceChart({
  vaultAddress,
  from,
  to,
})

console.log(lpTokenPriceChart)

Fetch the tvl token chart for a vault based on the vault address

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcNinjaApi = new IndexerGrpcNinjaApi(endpoints.ninjaApi)

const vaultAddress = 'inj...'
const from = 50 /* optional pagination params */
const to = 150 /* optional pagination params */

const tvlChart = await indexerGrpcNinjaApi.fetchTVLChartRequest({
  vaultAddress,
  from,
  to,
})

console.log(tvlChart)

Fetch the vaults associated with a holder of its lp tokens

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcNinjaApi = new IndexerGrpcNinjaApi(endpoints.ninjaApi)

const holderAddress = 'inj...'

const vaults = await indexerGrpcNinjaApi.fetchVaultsByHolderAddress({
  holderAddress,
})

console.log(vaults)

Fetch the lp token holders from the vault address

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcNinjaApi = new IndexerGrpcNinjaApi(endpoints.ninjaApi)

const vaultAddress = 'inj...'

const holders = await indexerGrpcNinjaApi.fetchLPHolders({
  vaultAddress,
})

console.log(holders)

Fetch the lp holder's portfolio

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcNinjaApi = new IndexerGrpcNinjaApi(endpoints.ninjaApi)

const holderAddress = 'inj...'

const portfolio = await indexerGrpcNinjaApi.fetchHolderPortfolio(holderAddress)

console.log(portfolio)

Fetch the leaderboard to see Pnl rankings

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcNinjaApi = new IndexerGrpcNinjaApi(endpoints.ninjaApi)

const leaderboard = await indexerGrpcNinjaApi.fetchLeaderboard()

console.log(leaderboard)
Mito's Docs