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 🙏

© 2024 – Pkg Stats / Ryan Hefner

kiloex-ts-sdk

v1.1.6

Published

KiloEx contract interaction SDK

Downloads

374

Readme

KiloEx TS SDK

Introduction

The Kilo SDK provides a set of TypeScript interfaces and functions for interacting with the Kilo protocol. allowing users to manage their positions, orders, and trade history on supported chains.

Installation

To install the SDK, you can use npm:

npm install kiloex-ts-sdk

Getting started

Initialization

import { create, ChainId } from 'kiloex-ts-sdk';
const kiloClient = create(ChainId.BSC, {
    env?: 'WEB' | 'NODE',  // WEB
    brokerId?: number
});

env In the code snippet, env is used for environment detection. node refers to the Node.js environment, while web refers to usage within a web browser.

Functions

Supported Chains

Get a list of supported chains:

import { supportedChains } from 'kiloex-ts-sdk';
const chains = supportedChains();

Supported Products by Chain

Get all supported products for a specific chain:

const products = await kiloClient.supportedProductsByChain(chainId);

Get Products Info

Retrieve information about specific products:

const productIds = [1, 2, 3]; // Example product IDs
const productsInfo = await kiloClient.getProductsInfo(productIds);

Get Product Prices

Retrieve prices of specific products:

const productPrices = await kiloClient.getProductPrices(productIds);

Set Approve

Set approval for a spender:

const spender = '0x456def...'; // Example spender address
const isApproved = await kiloClient.setApprove(walletAddress, spender);

Increase Position

Increase a position:

const walletAddress = '0x123abc...'; // Example wallet address
const type = 'Market'; // Example trade type
const position = {
  // Example position data
};
const transactionReceipt = await kiloClient.increasePosition(walletAddress, type, position);

Close Position

Close a position:

const positionToClose = {
  // Example position data
};
const transactionReceipt = await kiloClient.closePosition(walletAddress, positionToClose);

Update Position Margin

Update the margin of a position:

const positionToUpdate = {
  // Example position data
};
const transactionReceipt = await kiloClient.updatePositionMargin(walletAddress, positionToUpdate);

Cancel Order

Cancel a buy/sell limit order:

const orderIndex = 123; // Example order index
const transactionReceipt = await kiloClient.cancelOrder(walletAddress, 'Increase', orderIndex);

Update Order

Update a limit order:

const orderToUpdate = {
  // Example order data
};
const transactionReceipt = await kiloClient.updateOrder(walletAddress, orderToUpdate);

Get All Positions

Retrieve all positions associated with a wallet address:

const positions = await kiloClient.getAllPositions(walletAddress);

Get All Orders

Retrieve all orders associated with a wallet address:

const orders = await kiloClient.getAllOrders(walletAddress);

Get Trades History

Retrieve trade history associated with a wallet address:

const tradeHistory = await kiloClient.getTradesHistory(walletAddress);

Cancel Position

The order price is not within the executable price range; the margin needs to be withdrawn

const orderIndex = 123; // Example order index
const transactionReceipt = await kiloClient.cancelPosition(walletAddress, 'Increase', orderIndex);

Quote and Candlestick

We using pyth network as our Oracle, So you can get price and candlestick history from the pyth network, we use this too

https://benchmarks.pyth.network/docs#/TradingView/tradingview_streaming_route_v1_shims_tradingview_streaming_get