Documentation

Comprehensive guides and reference documentation for developing with Nidus-FI

Introduction

The Nidus-FI documentation portal provides exhaustive technical resources for developers seeking to interact with our protocol infrastructure. This compendium encompasses API specifications, smart contract interfaces, and integration methodologies, organized according to implementation complexity and use case categorization.

Our protocol leverages advanced mathematical models and AI-driven strategies to optimize liquidity and trading efficiency on the Solana blockchain. The documentation is structured to provide both high-level conceptual understanding and low-level technical details for implementation.

Quick Start Guide

This guide will help you get started with integrating Nidus-FI into your application. Follow these simple steps to begin using our protocol.

Installation

Install the Nidus-FI SDK using npm or yarn:

npm install @Nidus-FI/sdk

Basic Usage

Here's a simple example to initialize the client and execute a trade:

import { NubisClient } from '@Nidus-FI/sdk';

// Initialize client
const client = new NubisClient({
  rpcUrl: 'https://api.mainnet.solana.com',
  walletProvider: wallet
});

// Execute a trade
const trade = await client.executeSwap({
  fromToken: 'SOL',
  toToken: 'USDC',
  amount: new BN(1000000000), // 1 SOL
  slippageTolerance: 0.005, // 0.5%
  useOptimalRouting: true
});

console.log('Trade executed:', trade.signature);

Key Concepts

Understanding these fundamental concepts will help you work effectively with the Nidus-FI protocol.

Adaptive Liquidity Concentration

Our protocol dynamically adjusts liquidity position ranges based on market conditions and volatility metrics. This ensures capital efficiency by concentrating liquidity where it's most needed.

Multi-Pool Routing

Trades are executed across multiple liquidity pools to minimize price impact. The routing algorithm evaluates all possible paths and splits orders optimally to achieve the best execution price.

AI Strategy Management

Neural networks analyze market data to predict optimal liquidity positioning. The system continuously learns from market behavior to improve capital efficiency and reduce impermanent loss.

Protocol Governance

NUBIS token holders can participate in protocol governance through voting on parameter adjustments and feature prioritization. Voting power is weighted by both token quantity and staking duration.

Installation

Nidus-FI provides client libraries for multiple programming languages to facilitate integration with our protocol.

JavaScript/TypeScript

npm install @Nidus-FI/sdk

Python

pip install Nidus-FI

Rust

cargo add Nidus-FI

Go

go get github.com/Nidus-FI/sdk-go

Authentication

Nidus-FI API uses a secure authentication system to ensure that only authorized users can access the API endpoints. There are two authentication methods available:

API Key Authentication

For server-to-server integrations, we provide API keys that should be included in the request header. API keys can be generated in the developer dashboard.

// Example API request with API key
const response = await fetch('https://api.Nidus-FI.com/v1/pools', {
  headers: {
    'X-API-Key': 'your-api-key-here'
  }
});

JWT Authentication

For user-facing applications, we support JWT (JSON Web Token) authentication. This method is suitable for authenticating end-users and managing session states.

// Example JWT authentication
const response = await fetch('https://api.Nidus-FI.com/v1/user/positions', {
  headers: {
    'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
  }
});

Wallet Authentication

For decentralized applications, we also support Solana wallet-based authentication through message signing. This allows users to authenticate using their existing Solana wallets.

// Example wallet authentication
// 1. Request challenge
const challenge = await fetch('https://api.Nidus-FI.com/v1/auth/challenge?wallet=user_wallet_address');
const { message } = await challenge.json();

// 2. Sign message with wallet
const signature = await wallet.signMessage(new TextEncoder().encode(message));

// 3. Verify signature and get auth token
const auth = await fetch('https://api.Nidus-FI.com/v1/auth/verify', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ wallet: wallet.publicKey.toString(), signature })
});
const { token } = await auth.json();

Endpoints

The Nidus-FI API provides a comprehensive set of endpoints for interacting with the protocol. Below are the key endpoint categories and their functionalities.

Liquidity Pools Endpoints

GET

/pools

Returns a list of all available liquidity pools with basic information.

Response Example:
{
  "pools": [
    {
      "id": "sol-usdc",
      "token0": "SOL",
      "token1": "USDC",
      "fee": 0.003,
      "tvl": 1250000,
      "volume24h": 542000,
      "apy": 12.5
    },
    // More pools...
  ]
}
GET

/pools/{pool_id}

Returns detailed information about a specific liquidity pool.

Response Example:
{
  "id": "sol-usdc",
  "token0": {
    "symbol": "SOL",
    "address": "So11111111111111111111111111111111111111112",
    "decimals": 9
  },
  "token1": {
    "symbol": "USDC",
    "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "decimals": 6
  },
  "fee": 0.003,
  "tvl": 1250000,
  "volume24h": 542000,
  "apy": 12.5,
  "price": 100.25,
  "liquidityDistribution": [
    { "price": 90.5, "liquidity": 250000 },
    { "price": 95.25, "liquidity": 350000 },
    { "price": 100.25, "liquidity": 450000 },
    { "price": 105.75, "liquidity": 200000 }
  ]
}

Trading Endpoints

GET

/quote

Get a quote for a potential swap without executing it.

Request Parameters:
{
  "fromToken": "SOL",
  "toToken": "USDC",
  "amount": "1000000000", // 1 SOL in lamports
  "slippageTolerance": 0.005 // 0.5%
}
Response Example:
{
  "fromToken": "SOL",
  "toToken": "USDC",
  "fromAmount": "1000000000",
  "toAmount": "100250000", // 100.25 USDC
  "price": 100.25,
  "priceImpact": 0.0015, // 0.15%
  "minimumReceived": "99748750", // With 0.5% slippage
  "fee": {
    "amount": "3000000", // 0.003 SOL
    "usdValue": 0.30075
  },
  "route": [
    {
      "poolId": "sol-usdc",
      "percentage": 100
    }
  ]
}
POST

/swap

Execute a token swap with optimal routing.

Request Parameters:
{
  "fromToken": "SOL",
  "toToken": "USDC",
  "amount": "1000000000", // 1 SOL in lamports
  "slippageTolerance": 0.005, // 0.5%
  "useOptimalRouting": true,
  "deadline": 1650000000 // Unix timestamp
}
Response Example:
{
  "transactionId": "4QKcZmxUKpvnqj9F7F5KQtx4qhXDUSjLbNdE6UYxvARJrAUxWD4G3S1y5gLYHYBQvpQ5kJmXUPBFUuvhtTPzeDCN",
  "fromToken": "SOL",
  "toToken": "USDC",
  "fromAmount": "1000000000",
  "toAmount": "100275000", // 100.275 USDC
  "price": 100.275,
  "executionTime": 250, // ms
  "route": [
    {
      "poolId": "sol-usdc",
      "percentage": 70
    },
    {
      "poolId": "sol-usdt-usdc",
      "percentage": 30
    }
  ]
}

Error Handling

The Nidus-FI API uses standard HTTP status codes to indicate the success or failure of API requests. In addition, error responses include detailed error messages to help you troubleshoot issues.

HTTP Status Codes

Status CodeDescription
200 - OKThe request was successful
400 - Bad RequestThe request could not be understood or was missing required parameters
401 - UnauthorizedAuthentication failed or user does not have permissions
404 - Not FoundThe requested resource could not be found
429 - Too Many RequestsRate limit exceeded
500 - Internal Server ErrorAn error occurred on the server

Error Response Format

Error responses follow a consistent format to make error handling in your applications easier.

{
  "error": {
    "code": "invalid_parameter",
    "message": "The provided token address is invalid",
    "details": {
      "parameter": "fromToken",
      "value": "NOT_A_VALID_TOKEN",
      "reason": "Token not found"
    }
  }
}

Common Error Codes

Error CodeDescription
invalid_parameterOne of the request parameters is invalid
missing_parameterA required parameter is missing
authentication_failedAuthentication credentials are invalid
insufficient_fundsThe wallet does not have enough funds
insufficient_liquidityNot enough liquidity to complete the trade
price_impact_too_highThe trade would result in excessive price impact

REST API Overview

Our API reference implements OpenAPI 3.0 specification standards, facilitating programmatic discovery of available endpoints and expected response schemas. Each endpoint documentation includes comprehensive parameter descriptions, authentication requirements, rate limitation parameters, and example response objects.

Base URL

https://api.Nidus-FI.com/v1

API Key

All API requests require an API key to be included in the header. You can obtain an API key by registering on our developer portal.

// Example API request header
{
  "X-API-Key": "your-api-key-here"
}

Available Endpoints

GET

/pools

Returns a list of all available liquidity pools

POST

/swap

Execute a token swap with optimal routing

GET

/pools/{pool_id}/stats

Returns statistics for a specific liquidity pool

PUT

/positions/{position_id}

Update an existing liquidity position

Core Module Interface

The Core Module is the fundamental component of the Nidus-FI protocol, responsible for liquidity management, price discovery, and trade execution. Understanding this interface is essential for developers seeking to integrate with the protocol at a deeper level.

Program Interface

The Core Module is implemented as a Solana program with the following primary interfaces:

// Core Module Interface
// Program ID: NUB1Sfi45cQsz4NCjNQQkBJxCUGQnfZAkVCrSZ8Vcq4

// Primary Interfaces
pub trait CoreModule {
    // Pool Management
    fn create_pool(context: Context<CreatePool>, params: CreatePoolParams) -> Result<()>;
    fn add_liquidity(context: Context<AddLiquidity>, params: AddLiquidityParams) -> Result<()>;
    fn remove_liquidity(context: Context<RemoveLiquidity>, params: RemoveLiquidityParams) -> Result<()>;
    
    // Trading
    fn swap(context: Context<Swap>, params: SwapParams) -> Result<()>;
    fn create_limit_order(context: Context<CreateOrder>, params: OrderParams) -> Result<()>;
    fn cancel_order(context: Context<CancelOrder>, order_id: u64) -> Result<()>;
    
    // Analytics and Data
    fn get_pool_data(pool_id: Pubkey) -> Result<PoolData>;
    fn get_position_info(position_id: Pubkey) -> Result<PositionInfo>;
    fn get_fee_tier_info(fee_tier_id: Pubkey) -> Result<FeeTierInfo>;
}

// Key Structs and Types
pub struct CreatePoolParams {
    pub token_a_mint: Pubkey,
    pub token_b_mint: Pubkey,
    pub fee_tier: u16, // Basis points (e.g., 30 = 0.3%)
    pub initial_price_sqrt: u128,
    pub price_range: PriceRange,
}

pub struct AddLiquidityParams {
    pub pool_id: Pubkey,
    pub amount_a_desired: u64,
    pub amount_b_desired: u64,
    pub amount_a_min: u64,
    pub amount_b_min: u64,
    pub price_range: PriceRange,
    pub deadline: i64,
}

pub struct SwapParams {
    pub pool_id: Pubkey,
    pub amount_in: u64,
    pub minimum_amount_out: u64,
    pub swap_direction: SwapDirection, // TokenA -> TokenB or TokenB -> TokenA
    pub deadline: i64,
}

// Price Range for Concentrated Liquidity
pub struct PriceRange {
    pub lower_tick: i32,
    pub upper_tick: i32,
}

// Swap Direction Enum
pub enum SwapDirection {
    AtoB,
    BtoA,
}

Key Concepts

Concentrated Liquidity

Unlike traditional AMMs, the Nidus-FI Core Module implements concentrated liquidity positions where liquidity providers can specify price ranges for their capital. This significantly increases capital efficiency by focusing liquidity where it's most needed.

Tick System

The protocol uses a tick-based system to represent price ranges. Ticks are discrete price points that form the boundaries of liquidity positions. The spacing between ticks depends on the fee tier and affects the granularity of price range selection.

Fee Tiers

Different pools can have different fee tiers (e.g., 0.01%, 0.05%, 0.3%, 1%). Lower fee tiers are suitable for stable pairs, while higher fee tiers are better for volatile tokens. Fee tiers are expressed in basis points in the API.

Basic Integration Guide

This guide walks through the process of integrating Nidus-FI into your application, from initial setup to executing transactions.

Setup and Configuration

First, install the Nidus-FI SDK for your platform:

// npm
npm install @Nidus-FI/sdk

// yarn
yarn add @Nidus-FI/sdk

Initialize the client with your configuration:

import { NubisClient } from '@Nidus-FI/sdk';

// Initialize with default mainnet configuration
const client = new NubisClient({
  rpcUrl: 'https://api.mainnet.solana.com',  // Optional, defaults to mainnet
  walletProvider: wallet,                     // Your wallet instance
  apiKey: 'your-api-key',                     // Optional, for higher rate limits
  network: 'mainnet'                          // Optional: 'mainnet', 'testnet', or 'devnet'
});

Token Swaps

Execute a token swap with automatic route optimization:

// 1. Get a quote first (optional but recommended)
const quote = await client.getQuote({
  fromToken: 'SOL',
  toToken: 'USDC',
  amount: '1000000000', // 1 SOL (in lamports)
  slippageTolerance: 0.005 // 0.5%
});

console.log(`Expected to receive: ${quote.toAmount} USDC`);
console.log(`Price impact: ${quote.priceImpact * 100}%`);

// 2. Execute the swap
const swap = await client.executeSwap({
  fromToken: 'SOL',
  toToken: 'USDC',
  amount: '1000000000',
  slippageTolerance: 0.005,
  useOptimalRouting: true // Use AI-powered routing for best execution
});

console.log(`Swap executed with transaction ID: ${swap.transactionId}`);
console.log(`Received: ${swap.toAmount} USDC`);

Providing Liquidity

Add liquidity to a pool with concentrated position:

// 1. Find available pools
const pools = await client.getPools({
  tokenA: 'SOL',
  tokenB: 'USDC'
});

// 2. Add liquidity to a pool
const addLiquidity = await client.addLiquidity({
  poolId: pools[0].id,
  amountA: '10000000000', // 10 SOL
  amountB: '1000000000',  // 1000 USDC
  priceRange: {
    min: 95.0,  // Min price: 95 USDC per SOL
    max: 105.0  // Max price: 105 USDC per SOL
  },
  useRecommendedRange: false // Set to true to use AI-recommended price range
});

console.log(`Added liquidity with position ID: ${addLiquidity.positionId}`);

JavaScript SDK Documentation

Our JavaScript SDK provides a complete set of tools for interacting with the Nidus-FI protocol from web applications, Node.js services, or command-line tools.

Installation

npm install @Nidus-FI/sdk @solana/web3.js

Key Classes and Methods

NubisClient

The main entry point for interacting with the protocol.

Constructor
new NubisClient(config: {
  rpcUrl?: string,
  walletProvider: WalletProvider,
  apiKey?: string,
  network?: 'mainnet' | 'testnet' | 'devnet'
})
Core Methods
  • .getPools(options?: PoolQueryOptions): Promise<Pool[]>

    Returns a list of available liquidity pools.

  • .getQuote(params: QuoteParams): Promise<QuoteResult>

    Gets a quote for a potential swap without executing it.

  • .executeSwap(params: SwapParams): Promise<SwapResult>

    Executes a token swap with optimal routing.

Need Additional Help?

Developer Forum

Join our community forum to ask questions and share knowledge with other developers.

Visit Forum →

Technical Support

Contact our technical support team for assistance with integration issues.

Contact Support →

API Playground

Experiment with our API in an interactive environment to test requests and responses.

Try API Playground →