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. Chain

Insurance Funds

Example code snippets to query data related to the insurance fund on chain.

Using gRPC

Fetch default redemption notice period duration

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const chainGrpcInsuranceFundApi = new ChainGrpcInsuranceFundApi(endpoints.grpc)

const moduleParams = await chainGrpcInsuranceFundApi.fetchModuleParams()

console.log(moduleParams)

Fetch insurance funds and associated metadata

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const chainGrpcInsuranceFundApi = new ChainGrpcInsuranceFundApi(endpoints.grpc)

const insuranceFunds = await chainGrpcInsuranceFundApi.fetchInsuranceFunds()

console.log(insuranceFunds)

Fetch insurance fund and associated metadata based on the market ID

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const chainGrpcInsuranceFundApi = new ChainGrpcInsuranceFundApi(endpoints.grpc)

const marketId = '0x...'
const insuranceFund = await chainGrpcInsuranceFundApi.fetchInsuranceFund(
  marketId,
)

console.log(insuranceFund)

Fetch estimated redemptions for a given injective address for a market

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const chainGrpcInsuranceFundApi = new ChainGrpcInsuranceFundApi(endpoints.grpc)

const marketId = '0x...'
const injectiveAddress = 'inj...'

const estimatedRedemptions =
  await chainGrpcInsuranceFundApi.fetchEstimatedRedemptions({
    marketId,
    address: injectiveAddress,
  })

console.log(estimatedRedemptions)

Fetch pending redemptions for a given injective address for a market

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

const endpoints = getNetworkEndpoints(Network.Testnet)
const chainGrpcInsuranceFundApi = new ChainGrpcInsuranceFundApi(endpoints.grpc)

const marketId = '0x...'
const injectiveAddress = 'inj...'

const pendingRedemptions =
  await chainGrpcInsuranceFundApi.fetchPendingRedemptions({
    marketId,
    address: injectiveAddress,
  })

console.log(pendingRedemptions)
PreviousMintNextOracle

Last updated 1 year ago