@hubbleprotocol/hubble-idl
TypeScript icon, indicating that this package has built-in type declarations

5.0.12 • Public • Published

Hubble IDL

Hubble IDL (Interface Description Language) is a package that contains the IDLs of Hubble on-chain programs used on Solana (Hubble borrowing, Kamino and Scope programs supported). The IDL can be used to generate a client to speak to Hubble on-chain programs. The IDL is generated by Anchor.

Install

npm

npm install @hubbleprotocol/hubble-idl

Usage

Import borrowing IDL JSON to your project:

// For ESM
import { BORROWING_IDL, SCOPE_IDL, KAMINO_IDL } from "@hubbleprotocol/hubble-idl";

// For CommonJS
const config = require("@hubbleprotocol/hubble-config"); //config.BORROWING_IDL

Example: get borrowing market state

Dependencies required:

  • @project-serum/anchor,
  • @solana/web3.js,
  • @hubbleprotocol/hubble-config.

Use borrowing IDL with Anchor to get the borrowing market state (using readonly wallet):

import { Connection, Keypair, PublicKey, clusterApiUrl } from '@solana/web3.js';
import { Idl, Program, Provider } from '@project-serum/anchor';
import { BORROWING_IDL } from '@hubbleprotocol/hubble-idl';
import { getConfigByEnv } from '@hubbleprotocol/hubble-config';

const mainnetConfig = getConfigByEnv('mainnet-beta');
const connection = new Connection(clusterApiUrl('mainnet-beta'));
const provider = new Provider(
  connection,
  {
    publicKey: Keypair.generate().publicKey,
    signAllTransactions: async (txs) => txs,
    signTransaction: async (txs) => txs,
  },
  { commitment: 'confirmed' }
);
const program = new Program(BORROWING_IDL, mainnetConfig.borrowing.programId, provider);

// get borrowing market state with Anchor
const state = await program.account.borrowingMarketState.fetch(mainnetConfig.borrowing.accounts.borrowingMarketState);

Package Sidebar

Install

npm i @hubbleprotocol/hubble-idl

Weekly Downloads

710

Version

5.0.12

License

Apache-2.0

Unpacked Size

812 kB

Total Files

15

Last publish

Collaborators

  • siltros971
  • valqrtis
  • mihalex
  • andreihrs
  • peroxy
  • elliotkennedy
  • hubbleadmin