Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

NippyLabs/nerox-open-sdk

Repository files navigation

NeroX SDK

Project Overview

A comprehensive multi-chain SDK for decentralized exchange operations on the Solana, Aptos, BSC, SUI, and Base networks. The NeroX SDK provides a unified interface for token swapping, wallet management, and DeFi activities across various blockchain ecosystems. This SDK is designed to simplify the development of decentralized applications by offering a robust and easy-to-use set of tools.

Features

  • Multi-chain Support: Interact with Solana, Aptos, BSC, SUI, and Base networks.
  • DEX Integration: Supports multiple decentralized exchanges including PancakeSwap, Raydium, Cetus, and more.
  • Buy/Sell Orders: Create and manage buy/sell orders with slippage protection.
  • Wallet Management: Handle multiple wallets and distribute transactions efficiently.
  • Token Operations: Fetch token metadata, balances, and account information.
  • Gas Fee Management: Configure gas fees for different chains and operations.
  • TypeScript Support: Full TypeScript support with comprehensive type definitions.

Supported Chains

  • Solana (SOL)
  • Aptos (APT)
  • Binance Smart Chain (BSC)
  • Sui (SUI)
  • Base (BASE)

Supported DEXs

Solana

  • PumpFun Bonding Curve
  • Raydium
  • PumpSwap
  • Meteora
  • Jupiter

BSC

  • FourMeme Bonding Curve
  • PancakeSwap V2
  • PancakeSwap V3

Sui

  • MovePump
  • Cetus

Aptos

  • Panora

Base

  • Uniswap V3
  • Uniswap V2

Installation

npm install @nippylabs/nerox-core
# or
yarn add @nippylabs/nerox-core

Quick Start

import { ChainProvider, ChainId } from '@nippylabs/nerox-core';
// Initialize the chain provider with configuration
const chainProvider = new ChainProvider({
 [ChainId.SOL]: {
 rpcConfig: {
 rpcUrl: 'https://api.mainnet-beta.solana.com',
 // Add other RPC configurations
 },
 gasFeeConfig: {
 buy: 0.000005,
 sell: 0.000005,
 },
 programConfig: {
 // Add program-specific configurations
 },
 },
 // Add configurations for other chains
});
// Switch to the desired chain
chainProvider.switchChain(ChainId.SOL);

Usage Examples

Create Buy Order

import { createBuyOrder } from '@nippylabs/nerox-core';
const buyOrder = await createBuyOrder({
 buyAmount: BigInt('1000000000'), // Raw amount
 tokenAddress: 'TokenAddressHere',
 wallets: ['wallet1', 'wallet2'],
 fee: 5000, // Fee in the smallest unit
 slippage: '5', // 5% slippage
 chain: chainProvider.getActiveChain(),
 routes: [
 {
 route: 'pumpfun',
 poolAddress: 'poolAddress',
 poolFee: 10000,
 tokenIn: 'SOL',
 tokenOut: 'TokenAddress',
 },
 ],
});

Create Sell Order

import { createSellOrder } from '@nippylabs/nerox-core';
const sellOrder = await createSellOrder({
 sellAmount: BigInt('1000000'), // Raw amount
 tokenAddress: 'TokenAddressHere',
 tokenDecimals: 9,
 wallets: [
 { address: 'wallet1', tokenAmount: '500000' },
 { address: 'wallet2', tokenAmount: '500000' },
 ],
 fee: 5000,
 slippage: '5',
 chain: chainProvider.getActiveChain(),
 routes: [
 {
 route: 'raydium',
 poolAddress: 'poolAddress',
 poolFee: 2500,
 tokenIn: 'TokenAddress',
 tokenOut: 'SOL',
 },
 ],
});

Get Token Metadata

const tokenMetadata = await chainProvider.getActiveChain().getTokenMetadata('tokenAddress');
console.log(tokenMetadata);
// Result:
// {
// tokenAddress: '...',
// name: 'Token Name',
// symbol: 'SYMBOL',
// decimals: 9,
// iconUrl: '...',
// chainId: 'solana',
// isWatched: false
// }

Get Account Balances

const balances = await chainProvider.getActiveChain().getBalances(['wallet1', 'wallet2']);
console.log(balances); // Array of balance strings

Get Account Owned Tokens

const tokens = await chainProvider.getActiveChain().getAccountOwnedTokens(['wallet1']);
console.log(tokens); // Array of token accounts for each wallet

Configuration

Chain Configuration

Each chain requires specific configuration:

const chainConfig = {
 rpcConfig: {
 rpcUrl: 'RPC_URL',
 // Additional RPC configuration
 },
 gasFeeConfig: {
 buy: 0.000005, // Gas fee for buy operations
 sell: 0.000005, // Gas fee for sell operations
 },
 programConfig: {
 packageId: 'packageId', // For non-EVM chains
 depositDiscriminator: 'discriminator', // For non-EVM chains
 },
};

API Reference

ChainProvider

The main class for managing multiple chains and operations.

Methods

  • switchChain(chainId: ChainId): Switch to a different blockchain
  • getChainId(): ChainId: Get the current active chain ID
  • getActiveChain(): AbstractChain: Get the current active chain instance
  • createBuyOrder(params): Create a buy order on the active chain
  • createSellOrder(params): Create a sell order on the active chain
  • getChain(chainId: ChainId): Get a specific chain instance
  • getNativeToken(chainId: ChainId): Get the native token information for a chain
  • getNativeTokens(): Get all native tokens across all chains

Swap Operations

createBuyOrder

Creates a buy order for a specific token.

Parameters:

  • buyAmount: bigint - The raw amount to buy
  • tokenAddress: string - The address of the token to buy
  • wallets: string[] - An array of wallet addresses
  • fee: NumberLike - The transaction fee
  • slippage: string - The slippage tolerance percentage
  • chain: AbstractChain - The chain instance
  • routes: TRoute[] - An array of available routes

createSellOrder

Creates a sell order for a specific token.

Parameters:

  • sellAmount: NumberLike - The raw amount to sell
  • tokenAddress: string - The address of the token to sell
  • tokenDecimals: number - The number of decimals for the token
  • wallets: { address: string; tokenAmount: NumberLike }[] - An array of wallets with token amounts
  • fee: NumberLike - The transaction fee
  • slippage: string - The slippage tolerance percentage
  • chain: AbstractChain - The chain instance
  • routes: TRoute[] - An array of available routes

Development

Build

yarn build

Test

yarn test

Linting

yarn eslint

Folder Structure

The project is organized as a monorepo, with individual packages located in the packages directory.

  • packages/nerox-core: The main package containing the core logic of the SDK.
    • lib/: Contains the original TypeScript source code.
      • web3/chains/: Contains the implementation classes for each supported blockchain (Solana, BSC, Aptos, SUI, Base).
      • web3/swap/: Logic for handling token buy and sell transactions.
      • web3/contracts/: Smart contract definitions and ABIs.
    • dist/: Contains the compiled JavaScript code, ready for use.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /