Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Liqwid-Labs/defi-sdk

Repository files navigation

DeFi SDK

A library providing methods for querying high-level information about market participants (such as supplied balance and debt) and general market state in DeFi protocols. Currently, only Liqwid is supported.

Table of Contents

Installation

npm install "@liqwid-labs/defi-sdk"

Docs

Up-to-date API documentation can be generated using npm run generate-docs.

Usage

import { BlockFrostAPI } from "@blockfrost/blockfrost-js";
import { Address, BlockFrostAdapter, mkLiqwidLayer, SDK } from "@liqwid-labs/defi-sdk";

const blockfrostApi = new BlockFrostAPI({
  projectId: "<your api key here>"
})

const queryAdapter = new BlockFrostAdapter(blockfrostApi);
const sdk = new SDK(queryAdapter, mkLiqwidLayer);

const printUserDebtInAllMarkets = async (address: Address): Promise<void> => {
  const userDebt = await sdk.protocol.currentDebt(address);
  console.log(userDebt);
}

printUserDebtInAllMarkets(
  "addr1q8anl7qusc8aklly4sw80czujnt69f5tqu8xa4kryyujsldxj95970vfr9pzmygfauqtx8x6aanhda3azwz2m2js3dqq93jg0q"
);

/*
Output:
    [
      { asset: 'lovelace', quantity: 14032583507n },
      {
        asset: {
          policyId: '8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61',
          hexTokenName: '446a65644d6963726f555344'
        },
        quantity: 3713403928n
      }
    ]
*/