Mito
  • Introduction
    • ๐Ÿ‘‹Welcome
    • ๐ŸŒProtocol Overview
    • ๐Ÿ—๏ธValue Propositions
  • Products
    • ๐Ÿš€Launchpad
      • ๐Ÿ”‘Key Features
      • โ“How Does It Work?
      • ๐ŸŽŸ๏ธLaunchpad Eligibility
      • ๐Ÿ“ˆLaunchpad Subscription Model
      • โŒ›Launchpad Subscription Conclusion
        • ๐Ÿ‘จโ€๐Ÿ’ปNon-Whitelisted Users
    • ๐ŸŽ๏ธAutomated Vaults
      • โš–๏ธCPMM Automated Vaults
      • โšกRewards
    • ๐Ÿช„Permissionless Vaults
  • HOW TO
    • ๐Ÿš€Launchpad Creation Guide
    • ๐Ÿช„Vault Creation Guide
  • Integration
    • ๐ŸคนLaunchpad
    • ๐Ÿ๏ธAutomated Vaults
    • ๐ŸฅฉRewards
    • ๐Ÿช„Permissionless Vaults
    • ๐Ÿฆ“Holders/Stakers
Powered by GitBook
On this page
  • Query
  • Transactions
  1. Integration

Rewards

PreviousAutomated VaultsNextPermissionless Vaults

Last updated 1 year ago

This document aims to allow external developers to integrate with Mito's LP Staking Rewards from within their dApps. We will only show the message examples, how will you integrate them within your dApp is your own choice. Documentation on broadcasting the transactions containing these messages can be found .

Query

Fetch Staking Rewards

import { IndexerGrpcMitoApi } from '@injectivelabs/sdk-ts'

const MITO_API_ENDPOINT = 'https://k8s.mainnet.mito.grpc-web.injective.network' /** for mainnet */
const mitoApi = new IndexerGrpcMitoApi(MITO_API_ENDPOINT)

const address = 'inj1..'
const STAKING_CONTRACT_ADDRESS = `inj1gtze7qm07nky47n7mwgj4zatf2s77xqvh3k2n8` /** staking contract address for mainnet */

const { rewards } = await mitoApi.fetchStakingRewardsByAccount({
    stakingContractAddress: STAKING_CONTRACT_ADDRESS,
    accountAddress: address
})

console.log(rewards)

Fetch Staking Pools

import { IndexerGrpcMitoApi } from '@injectivelabs/sdk-ts'

const MITO_API_ENDPOINT = 'https://k8s.mainnet.mito.grpc-web.injective.network' /** for mainnet */
const mitoApi = new IndexerGrpcMitoApi(MITO_API_ENDPOINT)

const address = 'inj1..'
const STAKING_CONTRACT_ADDRESS = `inj1gtze7qm07nky47n7mwgj4zatf2s77xqvh3k2n8` /** staking contract address for mainnet */

const { pools } = await mitoApi.fetchStakingPools({
    stakingContractAddress: STAKING_CONTRACT_ADDRESS
})

console.log(pools)

Transactions

Stake LP

import { 
  MsgExecuteContractCompat,
  spotQuantityToChainQuantityToFixed 
} from '@injectivelabs/sdk-ts'

const sender = `inj1...`
const amount = 0.01 /** staking 0.01 QUNT/INJ LP */
const vaultLpDenom = 'factory...' /** Can be fetched from the vault's information */
const vaultTokenDecimals = 18
const STAKING_CONTRACT_ADDRESS = `inj1gtze7qm07nky47n7mwgj4zatf2s77xqvh3k2n8` /** staking contract address for mainnet */

const message = MsgExecuteContractCompat.fromJSON({
  sender,
  funds: [
    {
      denom: vaultLpDenom,
      amount: spotQuantityToChainQuantityToFixed({
        value: amount,
        baseDecimals: vaultTokenDecimals
      })
    }
  ],
  contractAddress: STAKING_CONTRACT_ADDRESS,
  exec: {
    action: 'stake',
    msg: {}
  }
})

/** (Prepare) Broadcast the transaction */

Unstake LP

import { 
  MsgExecuteContractCompat,
  spotQuantityToChainQuantityToFixed 
} from '@injectivelabs/sdk-ts'

const sender = `inj1...`
const amount = 0.01 /** unstaking 0.01 QUNT/INJ LP */
const vaultLpDenom = 'factory...' /** Can be fetched from the vault's information */
const vaultTokenDecimals = 18
const STAKING_CONTRACT_ADDRESS = `inj1gtze7qm07nky47n7mwgj4zatf2s77xqvh3k2n8` /** staking contract address for mainnet */

const message = MsgExecuteContractCompat.fromJSON({
  sender,
  contractAddress: STAKING_CONTRACT_ADDRESS,
  exec: {
    action: 'unstake',
    msg: {
      coin: {
        denom: vault.lpDenom,
        amount: spotQuantityToChainQuantityToFixed({
          value: amount,
          baseDecimals: vaultTokenDecimals
        })
      }
    }
  }
})

/** (Prepare) Broadcast the transaction */

Claim Stake

import { 
  MsgExecuteContractCompat 
} from '@injectivelabs/sdk-ts'

const sender = `inj1...`
const vaultLpDenom = 'factory...' /** Can be fetched from the vault's information */
const STAKING_CONTRACT_ADDRESS = `inj1gtze7qm07nky47n7mwgj4zatf2s77xqvh3k2n8` /** staking contract address for mainnet */

const message = MsgExecuteContractCompat.fromJSON({
  sender,
  contractAddress: STAKING_CONTRACT_ADDRESS,
  exec: {
    action: 'claim_stake',
    msg: {
      lp_token: vaultLpDenom
    }
  }
})

/** (Prepare) Broadcast the transaction */

Claim Rewards

import { 
  MsgExecuteContractCompat 
} from '@injectivelabs/sdk-ts'

const sender = `inj1...`
const vaultLpDenom = 'factory...' /** Can be fetched from the vault's information */
const STAKING_CONTRACT_ADDRESS = `inj1gtze7qm07nky47n7mwgj4zatf2s77xqvh3k2n8` /** staking contract address for mainnet */

const message = MsgExecuteContractCompat.fromJSON({
  sender,
  contractAddress: STAKING_CONTRACT_ADDRESS,
  exec: {
    action: 'claim_rewards',
    msg: {
      lp_token: vaultLpDenom
    }
  }
})

Note: The users need to 24 hours after they unstaked their LP.

๐Ÿฅฉ
here
Claim Stake