# Installation Setup

### Supported Markets

This API provides information for the following trading markets:

<table data-header-hidden><thead><tr><th width="350"></th><th width="179"></th><th></th></tr></thead><tbody><tr><td><strong>Asset</strong></td><td><strong>Market ID</strong></td><td><strong>Description</strong></td></tr><tr><td>APT/USDC</td><td>396</td><td>Aptos-based trading market.</td></tr><tr><td>BTC/USDC</td><td>397</td><td>Bitcoin-based trading market.</td></tr><tr><td>ETH/USDC</td><td>398</td><td>Ethereum-based trading market.</td></tr></tbody></table>

#### Prerequisites

Before using the API, ensure you have the following:

1. **Node.js**: Install version 16 or higher. [Download here](https://nodejs.org/).
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`:

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

   ```bash
   npm install @aptos-labs/ts-sdk
   ```

#### Example Setup in TypeScript

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

```typescript
// 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:

```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:

```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);
});

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kanalabs.io/spot-and-perp-apis/trading-apis/kana-perps-api/installation-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
