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'constBLOCK_HEIGHT=74264699constendpoints=getNetworkEndpoints(Network.MainnetSentry)constchainGrpcBankApi=newChainGrpcBankApi(endpoints.grpc)constdenom='peggy0x...'// In case you want to set a particular heightchainGrpcBankApi.setMetadata({"x-cosmos-block-height":BLOCK_HEIGHT,});constowners=awaitchainGrpcBankApi.fetchDenomOwners(denom, { limit:10000,})console.log(owners)
Fetch LP Stakers
import { ChainGrpcWasmApi } from'@injectivelabs/sdk-ts'import { getNetworkEndpoints, Network } from'@injectivelabs/networks'constSTAKING_CONTRACT_ADDRESS='inj1gtze7qm07nky47n7mwgj4zatf2s77xqvh3k2n8'constBLOCK_HEIGHT=74264699constLP_DENOM='factory/...'constendpoints=getNetworkEndpoints(Network.MainnetSentry)constchainGrpcWasmApi=newChainGrpcWasmmApi(endpoints.grpc)constdenom='peggy0x...'// In case you want to set a particular heightchainGrpcWasmApi.setMetadata({"x-cosmos-block-height":BLOCK_HEIGHT,});conststaker='inj1...'// Has to be queried for each staker individuallyconstresponse= (awaitapi.fetchSmartContractState(STAKING_CONTRACT_ADDRESS,toBase64({ user_stakes: { address: staker, denom:LP_DENOM, }, }))) asunknownas { data:string };constresult=fromBase64(response.data);// Amount is stored within the `power` property of the result objectconsole.log({ staker, amount:result.power })