๐Ÿฆ“Holders/Stakers

This document aims to allow external developers to fetch denom holders and Mito LP holders/stakers at a particular height.

Query

Fetch Bank Denom Holders

This can be the particular denom OR the LP token that's minted when users hold LP on Mito. For example, for Ethena the denom is peggy0x4c9EDD5852cd905f086C759E8383e09bff1E68B3 and the LP for the Mito vault is factory/inj1vcqkkvqs7prqu70dpddfj7kqeqfdz5gg662qs3/lpinj1r86atmuulmhzw63pqx5tp989nmupvn4fd94m7u.

You can also fetch at a particular height. Remember that the public nodes do not store long historical data (up to 2 days).

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

const BLOCK_HEIGHT = 74264699
const endpoints = getNetworkEndpoints(Network.MainnetSentry)
const chainGrpcBankApi = new ChainGrpcBankApi(endpoints.grpc)

const denom = 'peggy0x...'

// In case you want to set a particular height
chainGrpcBankApi.setMetadata({
    "x-cosmos-block-height": BLOCK_HEIGHT,
});

const owners = await chainGrpcBankApi.fetchDenomOwners(denom, {
    limit: 10000,
})

console.log(owners)

Fetch LP Stakers

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

const STAKING_CONTRACT_ADDRESS = 'inj1gtze7qm07nky47n7mwgj4zatf2s77xqvh3k2n8'
const BLOCK_HEIGHT = 74264699
const LP_DENOM = 'factory/...'
const endpoints = getNetworkEndpoints(Network.MainnetSentry)
const chainGrpcWasmApi = new ChainGrpcWasmmApi(endpoints.grpc)

const denom = 'peggy0x...'

// In case you want to set a particular height
chainGrpcWasmApi.setMetadata({
    "x-cosmos-block-height": BLOCK_HEIGHT,
});

const staker = 'inj1...'

// Has to be queried for each staker individually
const response = (await api.fetchSmartContractState(
  STAKING_CONTRACT_ADDRESS,
  toBase64({
    user_stakes: {
      address: staker,
      denom: LP_DENOM,
    },
  })
)) as unknown as { data: string };
const result = fromBase64(response.data);

// Amount is stored within the `power` property of the result object
console.log({ staker, amount: result.power })

Last updated