Kana Labs
  • Getting Started
    • Welcome to Kana Labs
  • CROSS CHAIN SWAPS
    • AMM DEX Aggregator
  • INTEGRATE KANA WIDGET
    • Kana Widget
      • Install Widget
      • Configure Widget
      • Configure Aptos Keyless
  • Web3 Aggregator SDK
    • Web3 Aggregator SDK
      • Installation
      • SameChain
      • Cross Chain Swap
      • Aggregator API's
  • SPOT TRADING PLATFORM
    • Kana Trade
      • API Docs
  • PERPETUAL FUTURES
    • Kana Perps
      • Getting Started
        • Mint Tokens on Testnet
      • Breaking Down Kana Perps
        • Assets Supported
        • Order Types
        • Orderbook
        • Funding Rate
        • Leverage
        • Margin and Liquidation
        • Hedge Mode
          • Hedging a Short-Term 2-3% Price Decline
          • Dual Positioning for Flexible Profit-Taking
        • Trading Fees
      • API Docs
        • Installation Setup
        • Kana Perps Typescript REST API
        • Kana Perps Python Websocket API
        • Kana Perps Python REST API
        • Steps to place an order
        • Perps Contract Error Codes
        • Websocket Connection
        • Supported Markets
  • SPOT & PERP APIs
    • Trading APIs
      • Kana Trade API
      • Kana Perps API
        • Installation Setup
        • Example setup functions
        • Kana Perps Typescript REST API
        • Kana Perps Websocket API
        • Kana Perps Python Websocket API
        • Kana Perps Python REST API
        • Steps to place an order
  • PAYMASTER SERVICE
    • Kana Paymaster For Aptos and Supra
      • How it works?
      • How to Register?
      • Deposit Allowance
      • Manage Users
      • Paymaster SDK Tutorial (Typescript)
      • Paymaster API
      • Module & Function Whitelist
      • Subscription - Coming soon
      • FAQS
  • PERPETUAL OPTIONS
    • OPerps
  • Tokenomics & Governance
    • Kana Labs Tokenomics
  • REWARDS & REFERRAL PROGRAM
    • Rewards Program
      • Reward Program Season 1
      • Reward Program Season 2
      • How to Keep Track of Your Points?
      • Where to find the Missions Dashboard?
  • Referral Program
    • How to Generate Referral Link? (For the Referrer)
    • How to map your wallet to the invite IDs? (For the invited users)
Powered by GitBook
On this page
  • Testnet Supported Markets
  • Mainnet Supported Markets
  • Size Conversion Details:
  • Price Conversion Details:
  1. PERPETUAL FUTURES
  2. Kana Perps
  3. API Docs

Installation Setup

Overview of supported trading markets and installation prerequisites for using the API.

PreviousAPI DocsNextKana Perps Typescript REST API

Last updated 26 days ago

Testnet Supported Markets

Asset

Market ID

Description

APT-USD

1338

Aptos-based trading market.

BTC-USD

1339

Bitcoin-based trading market.

ETH-USD

1340

Ethereum-based trading market.

Mainnet Supported Markets

Asset

Market ID

Description

APT-USD

14

Aptos-based trading market.

BTC-USD

15

Bitcoin-based trading market.

ETH-USD

16

Ethereum-based trading market.

Prerequisites

Before using the API, ensure you have the following:

  1. Node.js: Install version 16 or higher. .

  2. npm: Verify npm is installed to manage packages.

Install Required Packages

Run these commands to install the required dependencies:

  1. Install dotenv and axios:

    npm install dotenv axios
  2. Install the Aptos SDK for TypeScript:

    npm install @aptos-labs/ts-sdk

Example Setup in TypeScript

Create a file, e.g., setup.ts, and use the following code:

// Import required packages
import dotenv from 'dotenv';
import axios from 'axios';
import { AptosConfig, Aptos, Network, Account, Ed25519PrivateKey, PrivateKeyVariants } from "@aptos-labs/ts-sdk";

// Load environment variables from .env file
dotenv.config();

// Setup the client
const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);
const formattedPrivateKey = PrivateKey.formatPrivateKey(
    process.env.APTOS_PRIVATEKEY || '',
    'ed25519' as PrivateKeyVariants
);
const account = Account.fromPrivateKey({
    privateKey: new Ed25519PrivateKey(formattedPrivateKey),
});

Size Conversion Details:

APT Market

  • base_decimals: 8

  • lot_size_multiplier: 100000

BTC Market

  • base_decimals: 8

  • lot_size_multiplier: 1000

ETH Market

  • base_decimals: 8

  • lot_size_multiplier: 10000

Size Conversion Example in TypeScript:

import BigNumber from "bignumber.js";

async function main(): Promise<void> {

    // Size conversion
    const size = new BigNumber("your_size_value"); // Eg: 5.67
    const baseDecimals = "your_base_decimals_value"; // Eg: 8
    const lotSizeMultiplier = new BigNumber("your_lot_size_multiplier_value"); // Eg: 100000

    // 10^baseDecimals
    const sizeScalingFactor = new BigNumber(10).pow(baseDecimals);

    // Convert size and remove decimals
    const convertedSize = size.multipliedBy(sizeScalingFactor).dividedBy(lotSizeMultiplier).integerValue(BigNumber.ROUND_FLOOR);

    console.log("Converted Size: ", convertedSize.toString());
}

main().catch(error => {
    console.error('An error occurred:', error);
});

Price Conversion Details:

APT Market

  • price_precision: 3

BTC Market

  • price_precision: 0

ETH Market

  • price_precision: 1

Price Conversion Example in TypeScript:

import BigNumber from "bignumber.js";

async function main(): Promise<void> {

    // Price conversion
    const price = new BigNumber("your_price_value"); // Eg: 8.356
    const pricePrecision = "your_price_precision_value"; // Eg: 3

    // 10^pricePrecision
    const priceMultiplier = new BigNumber(10).pow(pricePrecision);

    // Convert price and remove decimals
    const convertedPrice = price.multipliedBy(priceMultiplier).integerValue(BigNumber.ROUND_FLOOR);

    console.log("Converted Price: ", convertedPrice.toString());
}

main().catch(error => {
    console.error('An error occurred:', error);
});
Download here