npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

test-kohin-sdk

v1.0.13

Published

The Kohin JS is a comprehensive developer toolkit designed to integrate Kohin's decentralized insurance system seamlessly into your applications. It enables efficient interaction with Kohin smart contracts and backend APIs, facilitating management and ana

Readme

Kohin JS

The Kohin JS is a comprehensive developer toolkit designed to integrate Kohin's decentralized insurance system seamlessly into your applications. It enables efficient interaction with Kohin smart contracts and backend APIs, facilitating management and analytics for user bets, coverage, and liquidity pools.

Installation

npm install kohin-js

Requirements

  • Access Key and Secret Key
  • Affiliate Address
  • Polygon Network RPC URL (Optional)

Network Support

  • Test: Polygon Amoy (Chain ID: 80002)
  • Pre-Production: Polygon (Chain ID: 137)
  • Production: Polygon Mainnet

Quick Start

import { Kohin } from "kohin-js";

// Initialize Kohin with your access credentials, RPC URL, and affiliate address
const kohin = new Kohin({
  accessKey: "your-access-key", // Replace with your unique access key
  secretKey: "your-secret-key", // Replace with your secret authentication key
  envMode: "test", // Options: 'test', 'preProd', 'prod' (set according to environment)
  affiliateAddress: "your-affiliate-address", // Replace with your affiliate address
  rpcUrl: "https://your-rpc-url.com", // (Optional) Replace with your blockchain RPC URL
});

Core Features

Betting Operations

// Get Active Bets
const activeBets = await kohin.getActiveBetData({
  bettorAddress: "0x...",
  pageCount: 1,
});

// Get Bet Details
const details = await kohin.getBetDetails({
  betId: "0x...",
});

// Get Odds History
const history = await kohin.getOddsHistory({
  conditionId: "0x...",
});

Insurance Operations

// Calculate Premium
const premium = await kohin.calculatePremium({
  betId: 123,
  betType: "Combo", // For an "Express" bet, pass betType as "Combo" and for an "Ordinar" bet, pass betType as "Single."
  odds: 2.5,
  betAmount: 100,
  numLegs: 2,
});

// Buy Cover
import { useWalletClient } from "wagmi";
const walletClient = useWalletClient();
const approveRes = await kohin.approveAmount({
  amount: 1000, // The amount to be approved for processing (e.g., 1000 USDT)
  walletClient: walletClient?.data, // The wallet client instance used to authorize the approval request
});
const cover = await kohin.buyCover({
  betId: 219, // The ID of the bet to insure
  betType: "Combo", // For an "Express" bet, pass betType as "Combo" and for an "Ordinar" bet, pass betType as "Single."
  coverPremium: 53982374n, // The premium amount for the insurance cover (bigint format)
  slippagePercent: 5, // Slippage percentage (between 1 and 100)
  betAmount: 1000, // The total amount placed on the bet
  walletClient: walletClient?.data, // The wallet client instance used to process the payment for the insurance cover
});

Liquidity Management

// Add Liquidity
const walletClient = useWalletClient();
const approveRes = await kohin.approveAmount({
  amount: 56.68, // The amount to be approved for processing (e.g., 56.68 USDT)
  walletClient: walletClient?.data, // The wallet client instance used to authorize the approval request
});
const deposit = await kohin.addLiquidity({
  amount: 1000, // The amount to be added to liquidity (e.g., 1000 USDT)
  walletClient: walletClient?.data, // The wallet client instance used to facilitate the liquidity addition
});

// Remove Liquidity
const walletClient = useWalletClient();
const withdrawal = await kohin.removeLiquidity({
  depositId: 1099511627894, // The unique identifier of the deposit from which liquidity will be removed
  percent: 16, // The percentage of liquidity to remove (value between 0 and 100)
  walletClient: walletClient?.data, // The wallet client instance used to process the liquidity removal request
});

Response Types

All methods return a consistent response format:

interface ResponseData<T> {
  success: boolean;
  data?: T;
  error?: string;
}

Error Handling

try {
  const result = await kohin.someOperation(params);
  if (result.success) {
    // Handle success
  } else {
    // Handle error
  }
} catch (error) {
  // Handle unexpected errors
}

Dependencies

  • viem: Web3 interactions
  • axios: API requests
  • typescript: Type definitions

Security Best Practices

  • Store credentials securely
  • Validate all transaction parameters
  • Maintain sufficient gas for transactions

License

MIT