Observed since 20 Oct, 17:59 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
100x-sdk
Solana 100x.fun 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 install 100x-sdk @solana/web3.js @coral-xyz/anchor
or with Yarn:
yarn add 100x-sdk @solana/web3.js @coral-xyz/anchor
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);
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 | Purpose | Key Methods |
|---|---|---|
| TradingModule | Execute trades | buy, sell, long, short, closeLong, closeShort |
| FastModule | API data access | mints, mint_info, orders, price, user_orders |
| ChainModule | On-chain data | getCurveAccount, orders, price, user_orders |
| TokenModule | Token creation | create, createAndBuy |
| ParamModule | Parameter management | createParams, getParams, getAdmin |
| SimulatorModule | Trade simulation | simulateTokenBuy, simulateTokenSell, simulateLongStopLoss |
| ToolsModule | Utility functions | approveTrade, closeTradeCooldown, validateCooldown |
| CurveAMM | AMM calculations | u128ToDecimal, buyFromPriceToPrice, sellFromPriceToPrice |
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');
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
});
1 SOL = 1,000,000,000 lamports1 Token = 1,000,000 units// 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);
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);
// 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
});
// 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
});
// 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);
// 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
});
npm run build # Build all distribution formats (CJS, ESM, UMD)
npm run build:dev # Watch mode for development
# Run individual test files
node tests/example-trading-buy.js
node tests/test-closeShort.js
# Standard test commands (coming soon)
npm test
npm run lint
Data Source Selection
fast (API) - Fast responses, may have slight delays during peak timeschain (Direct) - More reliable, slower, no third-party dependenciesTransaction Signing
Error Handling
Precision
anchor.BN for amountsContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Version: 2.0.0 Last Updated: 2024-12-09
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
bs58Environment{
"local_name": "bs58",
"alias": false,
"peer_metadata": null
} | ^4.0.1 | runtime |
axiosEnvironment{
"local_name": "axios",
"alias": false,
"peer_metadata": null
} | ^1.11.0 | runtime |
bufferEnvironment{
"local_name": "buffer",
"alias": false,
"peer_metadata": null
} | ^6.0.3 | runtime |
decimal.jsEnvironment{
"local_name": "decimal.js",
"alias": false,
"peer_metadata": null
} | ^10.6.0 | runtime |
node-fetchEnvironment{
"local_name": "node-fetch",
"alias": false,
"peer_metadata": null
} | ^3.3.2 | runtime |
json-bigintEnvironment{
"local_name": "json-bigint",
"alias": false,
"peer_metadata": null
} | ^1.0.0 | runtime |
@solana/web3.jsEnvironment{
"local_name": "@solana/web3.js",
"alias": false,
"peer_metadata": null
} | ^1.78.0 | runtime |
isomorphic-fetchEnvironment{
"local_name": "isomorphic-fetch",
"alias": false,
"peer_metadata": null
} | ^3.0.0 | runtime |
@coral-xyz/anchorEnvironment{
"local_name": "@coral-xyz/anchor",
"alias": false,
"peer_metadata": null
} | ^0.31.1 | runtime |
@solana/spl-tokenEnvironment{
"local_name": "@solana/spl-token",
"alias": false,
"peer_metadata": null
} | ^0.4.13 | runtime |
@pythnetwork/clientEnvironment{
"local_name": "@pythnetwork/client",
"alias": false,
"peer_metadata": null
} | ^2.22.1 | runtime |
globEnvironment{
"local_name": "glob",
"alias": false,
"peer_metadata": null
} | ^10.3.10 | development |
mochaEnvironment{
"local_name": "mocha",
"alias": false,
"peer_metadata": null
} | ^10.2.0 | development |
eslintEnvironment{
"local_name": "eslint",
"alias": false,
"peer_metadata": null
} | ^9.0.0 | development |
rimrafEnvironment{
"local_name": "rimraf",
"alias": false,
"peer_metadata": null
} | ^5.0.5 | development |
rollupEnvironment{
"local_name": "rollup",
"alias": false,
"peer_metadata": null
} | ^2.79.1 | development |
@rollup/plugin-jsonEnvironment{
"local_name": "@rollup/plugin-json",
"alias": false,
"peer_metadata": null
} | ^6.1.0 | development |
@rollup/plugin-terserEnvironment{
"local_name": "@rollup/plugin-terser",
"alias": false,
"peer_metadata": null
} | ^0.4.4 | development |
@rollup/plugin-replaceEnvironment{
"local_name": "@rollup/plugin-replace",
"alias": false,
"peer_metadata": null
} | ^5.0.5 | development |
@rollup/plugin-commonjsEnvironment{
"local_name": "@rollup/plugin-commonjs",
"alias": false,
"peer_metadata": null
} | ^24.1.0 | development |
@rollup/plugin-node-resolveEnvironment{
"local_name": "@rollup/plugin-node-resolve",
"alias": false,
"peer_metadata": null
} | ^15.2.3 | development |
rollup-plugin-polyfill-nodeEnvironment{
"local_name": "rollup-plugin-polyfill-node",
"alias": false,
"peer_metadata": null
} | ^0.13.0 | development |
Source distribution
{
"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
}Observed since 20 Oct, 17:59 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:b3eb2d91c9fb114fa981ea50c38e634bb2f5ecf8f71b4a48fca01dd7f015ea6e