Catalog npm
Back to packageRELEASE DETAILS

1.0.5

npm

100x-sdk

Solana 100x.fun SDK

anchorblockchainsdksolana
Published20 Sept 2026
Direct dependencies22
Transitive dependenciesNot calculated

README

Current package documentation

100x SDK

A JavaScript/TypeScript SDK for interacting with the 100x protocol on the Solana blockchain. Supports both Node.js and browser environments, providing modular functionality for trading, token management, order management, and more.

npm version License

Features

  • =� Spot Trading: Direct buy and sell operations for tokens
  • =� Margin Trading: Leverage trading with long/short positions
  • = Dual Data Sources: Fast API and reliable on-chain data access
  • =� Token Creation: Create and launch new tokens on the protocol
  • <� Trade Simulation: Pre-calculate slippage and costs before execution
  • =� Comprehensive Tooling: Order management, AMM calculations, and utilities
  • < Cross-Platform: Works in Node.js and modern browsers
  • =� Modular Design: Clean, intuitive API with separate functional modules

Installation

npm install 100x-sdk @solana/web3.js @coral-xyz/anchor

or with Yarn:

yarn add 100x-sdk @solana/web3.js @coral-xyz/anchor

Quick Start

const { Fun100xSdk, getDefaultOptions, FUN100X_PROGRAM_ID } = require('100x-sdk');
const { Connection } = require('@solana/web3.js');
const anchor = require('@coral-xyz/anchor');

// 1. Get network configuration
const options = getDefaultOptions('MAINNET'); // or 'DEVNET', 'LOCALNET'

// 2. Create connection
const connection = new Connection(options.solanaEndpoint, 'confirmed');

// 3. Initialize SDK
const sdk = new Fun100xSdk(connection, FUN100X_PROGRAM_ID, options);

// 4. Example: Buy tokens
const result = await sdk.trading.buy({
  mintAccount: "TOKEN_ADDRESS",
  buyTokenAmount: new anchor.BN('1000000'), // 1 token (6 decimals)
  maxSolAmount: new anchor.BN('2000000000'), // 2 SOL (9 decimals)
  payer: wallet.publicKey
});

// 5. Sign and send transaction
result.transaction.feePayer = wallet.publicKey;
result.transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
result.transaction.sign(wallet);

const signature = await connection.sendRawTransaction(result.transaction.serialize());
await connection.confirmTransaction(signature);

console.log('Transaction successful!', signature);

SDK Architecture

The SDK is organized into functional modules, all accessible through the main Fun100xSdk class:

const sdk = new Fun100xSdk(connection, FUN100X_PROGRAM_ID, options);

// Trading operations
await sdk.trading.buy({...});
await sdk.trading.sell({...});
await sdk.trading.long({...});
await sdk.trading.short({...});

// Data access (unified interface)
const orders = await sdk.data.orders(mint, { type: 'down_orders' });
const price = await sdk.data.price(mint);

// Token creation
await sdk.token.create({...});

// Trade simulation
const simulation = await sdk.simulator.simulateTokenBuy(mint, amount);

// Utility tools
await sdk.tools.approveTrade({...});

Module Overview

ModulePurposeKey Methods
TradingModuleExecute tradesbuy, sell, long, short, closeLong, closeShort
FastModuleAPI data accessmints, mint_info, orders, price, user_orders
ChainModuleOn-chain datagetCurveAccount, orders, price, user_orders
TokenModuleToken creationcreate, createAndBuy
ParamModuleParameter managementcreateParams, getParams, getAdmin
SimulatorModuleTrade simulationsimulateTokenBuy, simulateTokenSell, simulateLongStopLoss
ToolsModuleUtility functionsapproveTrade, closeTradeCooldown, validateCooldown
CurveAMMAMM calculationsu128ToDecimal, buyFromPriceToPrice, sellFromPriceToPrice

Documentation

Quick Reference

Core Modules

Utilities

Language Options

  • <�<� English Documentation: ./doc/ (Current)
  • <�<� -��c: ./doc_cn/

Network Configuration

The SDK supports three network environments:

// Mainnet (Production)
const mainnetOptions = getDefaultOptions('MAINNET');

// Devnet (Testing)
const devnetOptions = getDefaultOptions('DEVNET');

// Localnet (Local Development)
const localnetOptions = getDefaultOptions('LOCALNET');

Data Source Options

Choose between fast API access or reliable on-chain reading:

// Fast API (default) - Quick responses, slight latency
const sdk = new Fun100xSdk(connection, FUN100X_PROGRAM_ID, {
  ...options,
  defaultDataSource: 'fast'
});

// On-chain direct reading - More reliable, slower
const sdk = new Fun100xSdk(connection, FUN100X_PROGRAM_ID, {
  ...options,
  defaultDataSource: 'chain'
});

// Or switch temporarily per call
const orders = await sdk.data.orders(mint, {
  type: 'down_orders',
  dataSource: 'chain' // Override default
});

Key Concepts

Precision Handling

  • SOL: 9 decimal places (lamports) - 1 SOL = 1,000,000,000 lamports
  • Tokens: 6 decimal places - 1 Token = 1,000,000 units
  • Price: u128 format with 28-digit precision
// SOL amounts
const oneSol = new anchor.BN('1000000000'); // 1 SOL

// Token amounts
const oneToken = new anchor.BN('1000000'); // 1 Token

// Price conversion
const { CurveAMM } = require('100x-sdk');
const decimalPrice = CurveAMM.u128ToDecimal(priceU128);
const priceU128 = CurveAMM.decimalToU128(decimalPrice);

Transaction Signing

The SDK returns unsigned transactions for security and wallet compatibility:

// SDK builds the transaction
const result = await sdk.trading.buy({...});

// You control the signing
result.transaction.feePayer = wallet.publicKey;
result.transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;

// Sign with your wallet
const signature = await wallet.sendTransaction(result.transaction, connection);

Example Use Cases

Spot Trading

// Buy tokens
const buyResult = await sdk.trading.buy({
  mintAccount: mint,
  buyTokenAmount: new anchor.BN('1000000'),
  maxSolAmount: new anchor.BN('2000000000'),
  payer: wallet.publicKey
});

// Sell tokens
const sellResult = await sdk.trading.sell({
  mintAccount: mint,
  sellTokenAmount: new anchor.BN('1000000'),
  minSolOutput: new anchor.BN('1800000000'),
  payer: wallet.publicKey
});

Margin Trading

// Open long position
const longResult = await sdk.trading.long({
  mintAccount: mint,
  buyTokenAmount: new anchor.BN('10000000'),
  maxSolAmount: new anchor.BN('20000000000'),
  marginSol: new anchor.BN('5000000000'),
  closePrice: new anchor.BN('...'),
  closeInsertIndices: [...],
  payer: wallet.publicKey
});

// Close long position
const closeResult = await sdk.trading.closeLong({
  mintAccount: mint,
  sellTokenAmount: new anchor.BN('10000000'),
  minSolOutput: new anchor.BN('18000000000'),
  closeOrderId: orderId,
  closeOrderIndices: [...],
  payer: wallet.publicKey,
  userSolAccount: orderOwner
});

Data Queries

// Get token list
const tokens = await sdk.fast.mints({ limit: 10 });

// Get token price
const price = await sdk.data.price(mint);

// Get orders
const orders = await sdk.data.orders(mint, { type: 'down_orders' });

// Get user orders
const userOrders = await sdk.data.user_orders(userAddress, mint);

Trade Simulation

// Simulate buy before execution
const simulation = await sdk.simulator.simulateTokenBuy(mint, buyTokenAmount);

console.log('Completion:', simulation.completion + '%');
console.log('Slippage:', simulation.slippage + '%');
console.log('Suggested SOL:', simulation.suggestedSolAmount);

// Use simulation results in actual trade
const result = await sdk.trading.buy({
  mintAccount: mint,
  buyTokenAmount: new anchor.BN(buyTokenAmount),
  maxSolAmount: new anchor.BN(simulation.suggestedSolAmount),
  payer: wallet.publicKey
});

Development

Build

npm run build          # Build all distribution formats (CJS, ESM, UMD)
npm run build:dev      # Watch mode for development

Testing

# Run individual test files
node tests/example-trading-buy.js
node tests/test-closeShort.js

# Standard test commands (coming soon)
npm test

Linting

npm run lint

Important Notes

  1. Data Source Selection

    • fast (API) - Fast responses, may have slight delays during peak times
    • chain (Direct) - More reliable, slower, no third-party dependencies
  2. Transaction Signing

    • SDK returns unsigned transactions
    • Signing must be done externally for security
    • Compatible with hardware wallets and browser extensions
  3. Error Handling

    • All async methods can throw exceptions
    • Always implement proper error handling
    • Use try-catch blocks around SDK calls
  4. Precision

    • Always use anchor.BN for amounts
    • Remember decimal places: SOL (9), Token (6)
    • Use CurveAMM utilities for price conversions

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.


Version: 2.0.0 Last Updated: 2024-12-09

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 22

Native requirements
22 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
bs58
Environment
{
  "local_name": "bs58",
  "alias": false,
  "peer_metadata": null
}
^4.0.1runtime
axios
Environment
{
  "local_name": "axios",
  "alias": false,
  "peer_metadata": null
}
^1.11.0runtime
buffer
Environment
{
  "local_name": "buffer",
  "alias": false,
  "peer_metadata": null
}
^6.0.3runtime
decimal.js
Environment
{
  "local_name": "decimal.js",
  "alias": false,
  "peer_metadata": null
}
^10.6.0runtime
node-fetch
Environment
{
  "local_name": "node-fetch",
  "alias": false,
  "peer_metadata": null
}
^3.3.2runtime
json-bigint
Environment
{
  "local_name": "json-bigint",
  "alias": false,
  "peer_metadata": null
}
^1.0.0runtime
@solana/web3.js
Environment
{
  "local_name": "@solana/web3.js",
  "alias": false,
  "peer_metadata": null
}
^1.78.0runtime
isomorphic-fetch
Environment
{
  "local_name": "isomorphic-fetch",
  "alias": false,
  "peer_metadata": null
}
^3.0.0runtime
@coral-xyz/anchor
Environment
{
  "local_name": "@coral-xyz/anchor",
  "alias": false,
  "peer_metadata": null
}
^0.31.1runtime
@solana/spl-token
Environment
{
  "local_name": "@solana/spl-token",
  "alias": false,
  "peer_metadata": null
}
^0.4.13runtime
@pythnetwork/client
Environment
{
  "local_name": "@pythnetwork/client",
  "alias": false,
  "peer_metadata": null
}
^2.22.1runtime
glob
Environment
{
  "local_name": "glob",
  "alias": false,
  "peer_metadata": null
}
^10.3.10development
mocha
Environment
{
  "local_name": "mocha",
  "alias": false,
  "peer_metadata": null
}
^10.2.0development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^9.0.0development
rimraf
Environment
{
  "local_name": "rimraf",
  "alias": false,
  "peer_metadata": null
}
^5.0.5development
rollup
Environment
{
  "local_name": "rollup",
  "alias": false,
  "peer_metadata": null
}
^2.79.1development
@rollup/plugin-json
Environment
{
  "local_name": "@rollup/plugin-json",
  "alias": false,
  "peer_metadata": null
}
^6.1.0development
@rollup/plugin-terser
Environment
{
  "local_name": "@rollup/plugin-terser",
  "alias": false,
  "peer_metadata": null
}
^0.4.4development
@rollup/plugin-replace
Environment
{
  "local_name": "@rollup/plugin-replace",
  "alias": false,
  "peer_metadata": null
}
^5.0.5development
@rollup/plugin-commonjs
Environment
{
  "local_name": "@rollup/plugin-commonjs",
  "alias": false,
  "peer_metadata": null
}
^24.1.0development
@rollup/plugin-node-resolve
Environment
{
  "local_name": "@rollup/plugin-node-resolve",
  "alias": false,
  "peer_metadata": null
}
^15.2.3development
rollup-plugin-polyfill-node
Environment
{
  "local_name": "rollup-plugin-polyfill-node",
  "alias": false,
  "peer_metadata": null
}
^0.13.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "b7e8f6cb1d97224e5d3e75cb95320bb6bca5f66d",
  "tarball": "https://registry.npmjs.org/100x-sdk/-/100x-sdk-1.0.5.tgz",
  "fileCount": 31,
  "integrity": "sha512-kOWn5jjB0JiI8EQFqmcO7jyGSG1FbFqjlSw+A6B2ba8EEHVpsbxpqfyMjGGxIsf0oicUDs90mpb25n8lItunbg==",
  "signatures": [
    {
      "sig": "MEUCIGptGRwZMM7zUq0+LQ27HCw6l94O040m/MkMk5+1U062AiEAgmt3F0Ir+wzzMwhQcGmTikZ7Yh3WTtrgvpxXMOqh3SA=",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    },
    {
      "sig": "MEYCIQC4KlqHumzO2/C0OCtNcGds9/bXammGOUsM9/bC2kRisQIhAK6WUEHYybLQIDKzFsuzAb9C2yyQu27pIR0Y+cO0isB5",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 8671303
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 17:59 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:b3eb2d91c9fb114fa981ea50c38e634bb2f5ecf8f71b4a48fca01dd7f015ea6e

Other collected versions

1.0.729 Sept1.0.627 Sept1.0.420 Sept1.0.330 Jun1.0.230 Jun1.0.121 JunView all collected versions →