Building on top of the Descent Protocol
πŸ›  Descent SDK - Descent's Typescript's Library

Installation

Install the package with npm in your terminal:

npm install @descent-protocol/sdk

Once it's installed, import the module into your project as shown below.

import Descent from '@descent-protocol/sdk';
// or
const Descent = require('@descent-protocol/sdk');

UMD

This library is also usable as a UMD module, which you can build with npm run build:frontend.

<script src="./descent.js" />
 
<script>
// once the script loads, window.Descent is available
</script>

Quick examples

Look up information about a vault

This code uses getVaultInfo to look up a vault that was created in the Descent protocol UI. Since this code is only reading data, not creating any transactions, it is not necessary to provide a private key or connect a wallet.

// you provide these values
const infuraKey = 'your-infura-api-key';
const ownerAddress = '0xf00...';
 
const descent = await Descent.create('https', {
  url: `https://mainnet.infura.io/v3/${infuraKey}`
  collateral: 'USDC'
});
 
const vaultInfo = descent.getVaultInfo(ownerAddress);
console.log(
      vault.depositedCollateral, // amount of collateral tokens deposited
      vault.collateralLocked,  // amount of collateral locked in the system
      vault.borrowedAmount, // amount of currency(xNGN) debt
      vault.accruedFees, // amount of fees accrued by the vault
      vault.currentCollateralRatio, // collateralValue  to debt ratio
      vault.healthFactor, // vaults health factor to determine liquidatable status
      vault.availableCollateral, // amount of collateral in the system available
      vault.availablexNGN, // amount of xNGN in the system ready to be minted
);

In the next section, learn more about how to configure the Descent instance with Descent.create