Skip to content

bitquid-labs/Bitcoin-Bangkok-hacker-house

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BQJS - JavaScript SDK for Insurance Cover

BQJS is a Javascript library designed to simplify interactions with BQ insurance cover services. This library offers user-friendly functions for querying insurance cover details and executing cover purchases on third-party platforms, allowing seamless management of insurance covers without direct interaction with the BQ Insurance platform.

Key Features

  • Retrieve Cover Information: Fetch details about available cover for a specific client.
  • Purchase Insurance Cover: Easily manage cover purchases, including setting cover value and period.

Installation

To incorporate the BQJS SDK into your project, use npm (Node Package Manager):

npm install bqjs

You can refer to our examples for sample usage.

Getting Started

Import the SDK

To begin using BQJS in your application, import the necessary modules:

import { ClientConfig } from "bqjs";

This import statement brings in the ClientConfig class, which is the primary interface for interacting with the BQJS SDK.

Creating a client instance

To allow users to purchase cover for transactions and events directly from your platform, you have to first instantiate the client with the protocol name and cover ID. This step is crucial for for identifying and specifying your protocol cover from the BQ insurance protocol which the users would be interacting with.

The cover ID and name corresponds to a specific insurance protocol and can be obtained from the Network / Cover IDs table

NB : If you're unable to find cover for your protocol, please contact our team for assistance.

const protocolName = "Lorenzo Smart Contract";
const coverId = 21000001;

const client = new ClientConfig(protocolName, coverId);

Retrieving Cover Information

Before initiating a cover purchase, it's essential to retrieve the latest cover details, including the maximum available coverage, risk, and cost. This can be achieved by calling the coverInfo method.

const coverInfo = await client.coverInfo();

This returns an object containing detailed information about the selected cover like the riskType, capacity, cost, and maximum available coverage.

return {
  id: Number(coverInfo[0]),
  name: coverInfo[1],
  risk: Number(coverInfo[2]),
  chains: coverInfo[3],
  capacity: Number(coverInfo[4]),
  cost: Number(coverInfo[5]),
  capacityAmount: Number(coverInfo[6]),
  coverValues: Number(coverInfo[7]),
  maxAmount: Number(coverInfo[8]),
  poolId: Number(coverInfo[9]),
  cid: coverInfo[10],
};

Purchase Insurance Cover

To purchase insurance cover, use the userPurchaseCover() method. This method requires the following inputs:

coverValue: The amount of coverage desired (in wei). coverPeriod: The duration of the coverage (in days).

The fee for the cover purchase: coverFee is calculated dynamically based of this two inputs.

const coverValue = 1000000000000000; // Example cover value in wei (0.001 ETH)
const coverPeriod = 120; // Coverage period in days

let hash = await client.userPurchaseCover(coverValue, coverPeriod);

Once executed, it returns the transaction hash for the purchase:

0xd3ccd983403fa4dca40e16f3cd6fbe0ead0f359a22246dfe66db535a47fc8e36

Network/ Cover IDs

BQJS supports a wide range of networks and protocols. Use the following table to identify the correct Cover ID for your protocol:

NB : If you're unable to find cover for your protocol, please contact our team for assistance.

Network Testnet Chain ID Mainnet Chain ID
Babylon 1 1
Infstone 2 2
Merlin 686868 4200
Core DAO 1115 1116
PWR 21000001 (Bitcoin+) -
Lorenzo 83291 8329
Lombard 3 3
Pump BTC 4 4
Octopus Bridge 5 5
Avalon Finance 6 6
Omni BTC 7 7
Zest Protocol 8 8
Liquidium 9 9
Ordeez Protocol 10 10
Eastblue Protocol 11 11
Yona Network 12 12
Satoshi Protocol 13 13
Palladium 14 14
Bima BTC 15 15
BitStable 16 16
Rye Harvest 17 17

Contract Addresses

ROOSTOCK Token Address: 0x1E89336D439aD1D7A1E9558280FC0E602b1D5f35

BQ BTC Address: 0x44De012018dA5FA8E37A2E2E0bEC51bfAA24dd6B

Pool Address: 0xCf2eE259295F9056BC7ACd6875D97153CA7E3210

Gov Address: 0xf1966A1d1a6098c80341f38DCE1a54F8D67e8c87

Cover Address: 0x37918B0E3cD5A543D111077A2Ac3D95Eef54B438

BOB Token Address: 0xC454fabCF7356Afd2C7767fCf438E69126Be4DBf

BQ BTC Address: 0x3d90F178B1Abd4B85301b2B2d99faB778F399071

Pool Address: 0xf97F6A71f2256917225Ab61e85963A888f9Ee037

Gov Address: 0x1E89336D439aD1D7A1E9558280FC0E602b1D5f35

Cover Address: 0x44De012018dA5FA8E37A2E2E0bEC51bfAA24dd6B

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published