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 🙏

© 2026 – Pkg Stats / Ryan Hefner

kulap-sdk

v0.1.5

Published

Javascript SDK for Kulap DEX

Downloads

18

Readme

KULAP SDK

This SDK provides access to KULAP DEX from a custom application where the best rate will be given to you and your user on each trade using ERC-20 tokens.

Initialization

Install the SDK using npm or yarn

yarn add kulap-sdk

You will need to the provider object to the constructor which will allows the SDK to automatically handle query and retrieve requests from blockchains the user is connected to. Also the access token doesn't required at the moment.

Node.js

const { Kulap } = require("kulap-sdk")
const Web3 = require('web3')

const web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/v3/YOUR_PROJECT_ID"))

const kulapSDK = new Kulap('access_key',web3.currentProvider) // getting access key from the kulap.io console

ES6 / Typescript with injected Web3 (Metamask)

import { Kulap } from "kulap-sdk"

const kulapSDK = new Kulap('access_key', window.ethereum) // getting access key from the kulap.io console

Quick Start

Example: Swap 100 DAI to LINK

const srcToken = "DAI"
const destToken = "LINK"
const amountIn = "100" // 100 DAI

const response = await kulapSDK.getRate(baseToken, pairToken, amountIn) // Get best rate from off-chain API

const isApproved = await kulapSDK.validate(response) // Check allowance of DAI token to Kulap DEX smart contract is made

if (!isApproved) {
  await kulapSDK.approve(response) // Giving a permission to Kulap DEX smart contract, the rights to transfer DAI
}

await kulapSDK.trade(response) // Execute trade

Demo Dapp

We've build the demo dapp that allows you to quickly look up quickly look up how first sample application is made.

https://pensive-thompson-5185d1.netlify.app

Source code :

https://github.com/pisuthd/kulap-demo-dapp

Usage

To retrieve the list all available tokens

const symbols = kulapSDK.listSymbols()

To get network ID

const networkId = await kulapSDK.getNetworkId()

To get the rate of a token pair

This will help construct the order details from the pair and given amount that later you use it for validate, approve and execute a trade.

const srcToken = "ETH"
const destToken = "DAI"
const amountIn = "1" // 1 ETH

const order = await kulapSDK.getRate(baseToken, pairToken, amountIn)
Response

| Value | Description | |------------|--------------------------------------------| | rate | Best rate given from off-chain API | | routes | Trading proxy containing the best rate |
| fromAmount | Source ERC20 token amount in Wei | | fromSymbol | Source token symbol | | toAmount | Destination ERC20 token amount in Wei | | toSymbol | Destination token symbol | | gasOptions | GAS price options (SLOW, STD, FAST) |

To get the allowance of an ERC20

const isValidated = await kulapSDK.validate(response) // given response when get the rate 

or

const fromSymbol = "DAI"
const fromAmount = "100" // 100 DAI
const isValidated = await kulapSDK.validate({ fromSymbol, fromAmount })

To approve an ERC20

await kulapSDK.approve(order) // given response when get the rate 

or

await kulapSDK.approve(order, { gasOptions : "FAST" }) // "FAST", "STD", "SLOW" (default : "FAST")

or

const fromSymbol = "LINK"
await kulapSDK.approve({ fromSymbol }, { gasOptions : "SLOW" })

Execute trade

We would recommend to set the slippage rate to prevent surge, for example the default value is 0, if the price is change more than the given price from order details, the transaction will failed.

await kulapSDK.trade(order)

or

await kulapSDK.trade(order , { gasOptions : "FAST", slippage : 3  }) // slippage must be provided in percentage

If you registered as partner and want the commision to be paid out on transactions, kindly provide your partner id as following:

await kulapSDK.trade(order, { partnerId : YOUR_ID })

Running tests

To run the tests, follow these steps.

First clone the repository to your local machine and then install dependencies

yarn install

You will need to run forked mainnet of Ganache by

yarn run-ganache

Open another terminal and run tests

yarn test

This will execute the simulated trade of ETH to DAI and DAI to LINK on the local ganache server instead of running it on mainnet.