sol-trade-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +390 -0
  2. package/dist/chunk-MMQAMIKR.mjs +3735 -0
  3. package/dist/chunk-NEZDFAYA.mjs +7744 -0
  4. package/dist/clients-VITWK7B6.mjs +1370 -0
  5. package/dist/index-1BK_FXsW.d.mts +2327 -0
  6. package/dist/index-1BK_FXsW.d.ts +2327 -0
  7. package/dist/index.d.mts +2659 -0
  8. package/dist/index.d.ts +2659 -0
  9. package/dist/index.js +13265 -0
  10. package/dist/index.mjs +562 -0
  11. package/dist/perf/index.d.mts +2 -0
  12. package/dist/perf/index.d.ts +2 -0
  13. package/dist/perf/index.js +3742 -0
  14. package/dist/perf/index.mjs +214 -0
  15. package/package.json +101 -0
  16. package/src/__tests__/complete_sdk.test.ts +354 -0
  17. package/src/__tests__/hotpath.test.ts +486 -0
  18. package/src/__tests__/nonce.test.ts +45 -0
  19. package/src/__tests__/sdk.test.ts +425 -0
  20. package/src/address-lookup/index.ts +197 -0
  21. package/src/cache/cache.ts +308 -0
  22. package/src/calc/index.ts +1058 -0
  23. package/src/calc/pumpfun.ts +124 -0
  24. package/src/common/bonding_curve.ts +272 -0
  25. package/src/common/compute-budget.ts +148 -0
  26. package/src/common/confirm-any-signature.ts +184 -0
  27. package/src/common/fast-timing.ts +481 -0
  28. package/src/common/fast_fn.ts +150 -0
  29. package/src/common/gas-fee-strategy.ts +253 -0
  30. package/src/common/map-pool.ts +23 -0
  31. package/src/common/nonce.ts +40 -0
  32. package/src/common/sdk-log.ts +460 -0
  33. package/src/common/seed.ts +381 -0
  34. package/src/common/spl-token.ts +578 -0
  35. package/src/common/subscription-handle.ts +644 -0
  36. package/src/common/trading-utils.ts +239 -0
  37. package/src/common/wsol-manager.ts +325 -0
  38. package/src/compute/compute_budget_manager.ts +187 -0
  39. package/src/compute/index.ts +21 -0
  40. package/src/constants/index.ts +96 -0
  41. package/src/execution/execution.ts +532 -0
  42. package/src/execution/index.ts +42 -0
  43. package/src/hotpath/executor.ts +464 -0
  44. package/src/hotpath/index.ts +64 -0
  45. package/src/hotpath/state.ts +435 -0
  46. package/src/index.ts +2117 -0
  47. package/src/instruction/bonk_builder.ts +730 -0
  48. package/src/instruction/index.ts +24 -0
  49. package/src/instruction/meteora_damm_v2_builder.ts +509 -0
  50. package/src/instruction/pumpfun_builder.ts +1183 -0
  51. package/src/instruction/pumpswap.ts +1123 -0
  52. package/src/instruction/raydium_amm_v4_builder.ts +692 -0
  53. package/src/instruction/raydium_cpmm_builder.ts +795 -0
  54. package/src/middleware/traits.ts +407 -0
  55. package/src/params/index.ts +483 -0
  56. package/src/perf/compiler-optimization.ts +529 -0
  57. package/src/perf/hardware.ts +631 -0
  58. package/src/perf/index.ts +9 -0
  59. package/src/perf/kernel-bypass.ts +656 -0
  60. package/src/perf/protocol.ts +682 -0
  61. package/src/perf/realtime.ts +592 -0
  62. package/src/perf/simd.ts +668 -0
  63. package/src/perf/syscall-bypass.ts +331 -0
  64. package/src/perf/ultra-low-latency.ts +505 -0
  65. package/src/perf/zero-copy.ts +589 -0
  66. package/src/pool/pool.ts +294 -0
  67. package/src/rpc/client.ts +345 -0
  68. package/src/sdk-errors.ts +13 -0
  69. package/src/security/index.ts +26 -0
  70. package/src/security/secure-key.ts +303 -0
  71. package/src/security/validators.ts +281 -0
  72. package/src/seed/pda.ts +262 -0
  73. package/src/serialization/index.ts +28 -0
  74. package/src/serialization/serialization.ts +288 -0
  75. package/src/swqos/clients.ts +1754 -0
  76. package/src/swqos/index.ts +50 -0
  77. package/src/swqos/providers.ts +1707 -0
  78. package/src/trading/core/async-executor.ts +702 -0
  79. package/src/trading/core/confirmation-monitor.ts +711 -0
  80. package/src/trading/core/index.ts +82 -0
  81. package/src/trading/core/retry-handler.ts +683 -0
  82. package/src/trading/core/transaction-pool.ts +780 -0
  83. package/src/trading/executor.ts +385 -0
  84. package/src/trading/factory.ts +282 -0
  85. package/src/trading/index.ts +30 -0
  86. package/src/types.ts +8 -0
  87. package/src/utils/index.ts +155 -0
package/README.md ADDED
@@ -0,0 +1,390 @@
1
+ <div align="center">
2
+ <h1>πŸš€ Sol Trade SDK for Node.js</h1>
3
+ <h3><em>A comprehensive TypeScript SDK for seamless Solana DEX trading</em></h3>
4
+ </div>
5
+
6
+ <p align="center">
7
+ <strong>A high-performance TypeScript SDK for low-latency Solana DEX trading bots. Built for speed and efficiency, it enables seamless, high-throughput interaction with PumpFun, Pump AMM (PumpSwap), Bonk, Meteora DAMM v2, Raydium AMM v4, and Raydium CPMM for latency-critical trading strategies.</strong>
8
+ </p>
9
+
10
+ <p align="center">
11
+ <a href="https://www.npmjs.com/package/sol-trade-sdk">
12
+ <img src="https://img.shields.io/npm/v/sol-trade-sdk.svg" alt="npm">
13
+ </a>
14
+ <a href="https://www.npmjs.com/package/sol-trade-sdk">
15
+ <img src="https://img.shields.io/node/v/sol-trade-sdk.svg" alt="Node Version">
16
+ </a>
17
+ <a href="LICENSE">
18
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
19
+ </a>
20
+ </p>
21
+
22
+ <p align="center">
23
+ <img src="https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript">
24
+ <img src="https://img.shields.io/badge/Solana-9945FF?style=for-the-badge&logo=solana&logoColor=white" alt="Solana">
25
+ <img src="https://img.shields.io/badge/DEX-4B8BBE?style=for-the-badge&logo=bitcoin&logoColor=white" alt="DEX Trading">
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/README_CN.md">δΈ­ζ–‡</a> |
30
+ <a href="https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/README.md">English</a> |
31
+ <a href="https://fnzero.dev/">Website</a> |
32
+ <a href="https://t.me/fnzero_group">Telegram</a> |
33
+ <a href="https://discord.gg/vuazbGkqQE">Discord</a>
34
+ </p>
35
+
36
+ > β˜• **Support This Project**
37
+ >
38
+ > This SDK is completely free and open source. However, maintaining and continuously updating it requires significant AI computing resources and token consumption. If this SDK helps with your development, consider making a monthly SOL donation β€” any amount is appreciated and helps keep this project alive!
39
+ >
40
+ > **Donation Wallet:** `6oW7AXz1yRb57pYSxysuXnMs2aR1ha5rzGzReZ1MjPV8`
41
+
42
+ ## πŸ“‹ Table of Contents
43
+
44
+ - [✨ Features](#-features)
45
+ - [πŸ“¦ Installation](#-installation)
46
+ - [πŸ› οΈ Usage Examples](#️-usage-examples)
47
+ - [πŸ“‹ Example Usage](#-example-usage)
48
+ - [⚑ Trading Parameters](#-trading-parameters)
49
+ - [πŸ“Š Usage Examples Summary Table](#-usage-examples-summary-table)
50
+ - [βš™οΈ SWQoS Service Configuration](#️-swqos-service-configuration)
51
+ - [πŸ”§ Middleware System](#-middleware-system)
52
+ - [πŸ” Address Lookup Tables](#-address-lookup-tables)
53
+ - [πŸ” Nonce Cache](#-nonce-cache)
54
+ - [πŸ’° Cashback Support (PumpFun / PumpSwap)](#-cashback-support-pumpfun--pumpswap)
55
+ - [πŸ›‘οΈ MEV Protection Services](#️-mev-protection-services)
56
+ - [πŸ“ Project Structure](#-project-structure)
57
+ - [πŸ“„ License](#-license)
58
+ - [πŸ’¬ Contact](#-contact)
59
+ - [⚠️ Important Notes](#️-important-notes)
60
+
61
+ ---
62
+
63
+ ## πŸ“¦ SDK Versions
64
+
65
+ This SDK is available in multiple languages:
66
+
67
+ | Language | Repository | Description |
68
+ |----------|------------|-------------|
69
+ | **Rust** | [sol-trade-sdk](https://github.com/0xfnzero/sol-trade-sdk) | Ultra-low latency with zero-copy optimization |
70
+ | **Node.js** | [sol-trade-sdk-nodejs](https://github.com/0xfnzero/sol-trade-sdk-nodejs) | TypeScript/JavaScript for Node.js |
71
+ | **Python** | [sol-trade-sdk-python](https://github.com/0xfnzero/sol-trade-sdk-python) | Async/await native support |
72
+ | **Go** | [sol-trade-sdk-golang](https://github.com/0xfnzero/sol-trade-sdk-golang) | Concurrent-safe with goroutine support |
73
+
74
+ ## ✨ Features
75
+
76
+ 1. **PumpFun Trading**: Support for `buy` and `sell` operations
77
+ 2. **PumpSwap Trading**: Support for PumpSwap pool trading operations
78
+ 3. **Bonk Trading**: Support for Bonk trading operations
79
+ 4. **Raydium CPMM Trading**: Support for Raydium CPMM (Concentrated Pool Market Maker) trading operations
80
+ 5. **Raydium AMM V4 Trading**: Support for Raydium AMM V4 (Automated Market Maker) trading operations
81
+ 6. **Meteora DAMM V2 Trading**: Support for Meteora DAMM V2 (Dynamic AMM) trading operations
82
+ 7. **Multiple MEV Protection**: Support for Jito, Nextblock, ZeroSlot, Temporal, Bloxroute, FlashBlock, BlockRazor, Node1, Astralane and other services
83
+ 8. **Concurrent Trading**: Send transactions using multiple MEV services simultaneously; the fastest succeeds while others fail
84
+ 9. **Unified Trading Interface**: Use unified trading protocol types for trading operations
85
+ 10. **Middleware System**: Support for custom instruction middleware to modify, add, or remove instructions before transaction execution
86
+ 11. **Shared Infrastructure**: Share expensive RPC and SWQoS clients across multiple wallets for reduced resource usage
87
+
88
+ ## πŸ“¦ Installation
89
+
90
+ ### Direct Clone (Recommended)
91
+
92
+ Clone this project to your project directory:
93
+
94
+ ```bash
95
+ cd your_project_root_directory
96
+ git clone https://github.com/0xfnzero/sol-trade-sdk-nodejs
97
+ ```
98
+
99
+ Install dependencies and build:
100
+
101
+ ```bash
102
+ cd sol-trade-sdk-nodejs
103
+ npm install
104
+ npm run build
105
+ ```
106
+
107
+ Add to your `package.json`:
108
+
109
+ ```json
110
+ {
111
+ "dependencies": {
112
+ "sol-trade-sdk": "./sol-trade-sdk-nodejs"
113
+ }
114
+ }
115
+ ```
116
+
117
+ ### Use NPM
118
+
119
+ ```bash
120
+ npm install sol-trade-sdk
121
+ # or
122
+ yarn add sol-trade-sdk
123
+ # or
124
+ pnpm add sol-trade-sdk
125
+ ```
126
+
127
+ ## πŸ› οΈ Usage Examples
128
+
129
+ ### πŸ“‹ Example Usage
130
+
131
+ #### 1. Create TradingClient Instance
132
+
133
+ You can refer to [Example: Create TradingClient Instance](examples/trading_client.ts).
134
+
135
+ **Method 1: Simple (single wallet)**
136
+ ```typescript
137
+ import { TradingClient, TradeConfig, SwqosConfig, SwqosRegion } from 'sol-trade-sdk';
138
+
139
+ // Wallet
140
+ const payer = Keypair.fromSecretKey(/* your keypair */);
141
+
142
+ // RPC URL
143
+ const rpcUrl = "https://mainnet.helius-rpc.com/?api-key=xxxxxx";
144
+
145
+ // Multiple SWQoS services can be configured
146
+ const swqosConfigs: SwqosConfig[] = [
147
+ { type: 'Default', rpcUrl },
148
+ { type: 'Jito', uuid: "your_uuid", region: SwqosRegion.Frankfurt },
149
+ { type: 'Bloxroute', apiToken: "your_api_token", region: SwqosRegion.Frankfurt },
150
+ { type: 'Astralane', apiKey: "your_api_key", region: SwqosRegion.Frankfurt },
151
+ ];
152
+
153
+ // Create TradeConfig instance
154
+ const tradeConfig = new TradeConfig(rpcUrl, swqosConfigs);
155
+
156
+ // Create TradingClient
157
+ const client = new TradingClient(payer, tradeConfig);
158
+ ```
159
+
160
+ **Method 2: Shared infrastructure (multiple wallets)**
161
+
162
+ For multi-wallet scenarios, create the infrastructure once and share it across wallets.
163
+ See [Example: Shared Infrastructure](examples/shared_infrastructure.ts).
164
+
165
+ ```typescript
166
+ import { TradingInfrastructure, InfrastructureConfig } from 'sol-trade-sdk';
167
+
168
+ // Create infrastructure once (expensive)
169
+ const infraConfig = new InfrastructureConfig(rpcUrl, swqosConfigs);
170
+ const infrastructure = new TradingInfrastructure(infraConfig);
171
+
172
+ // Create multiple clients sharing the same infrastructure (fast)
173
+ const client1 = TradingClient.fromInfrastructure(payer1, infrastructure);
174
+ const client2 = TradingClient.fromInfrastructure(payer2, infrastructure);
175
+ ```
176
+
177
+ #### 2. Configure Gas Fee Strategy
178
+
179
+ ```typescript
180
+ import { GasFeeStrategy } from 'sol-trade-sdk';
181
+
182
+ // Create GasFeeStrategy instance
183
+ const gasFeeStrategy = new GasFeeStrategy();
184
+ // Set global strategy
185
+ gasFeeStrategy.setGlobalFeeStrategy(150000, 150000, 500000, 500000, 0.001, 0.001);
186
+ ```
187
+
188
+ #### 3. Build Trading Parameters
189
+
190
+ ```typescript
191
+ import { TradeBuyParams, DexType, TradeTokenType, DexParamEnum } from 'sol-trade-sdk';
192
+
193
+ const buyParams: TradeBuyParams = {
194
+ dexType: DexType.PumpSwap,
195
+ inputTokenType: TradeTokenType.WSOL,
196
+ mint: mintPubkey,
197
+ inputTokenAmount: buySolAmount,
198
+ slippageBasisPoints: 500,
199
+ recentBlockhash: recentBlockhash,
200
+ // Use DexParamEnum for type-safe protocol parameters
201
+ extensionParams: { type: 'PumpSwap', params: pumpSwapParams },
202
+ addressLookupTableAccount: null,
203
+ waitTransactionConfirmed: true,
204
+ createInputTokenAta: true,
205
+ closeInputTokenAta: true,
206
+ createMintAta: true,
207
+ durableNonce: null,
208
+ fixedOutputTokenAmount: null,
209
+ gasFeeStrategy: gasFeeStrategy,
210
+ simulate: false,
211
+ };
212
+ ```
213
+
214
+ #### 4. Execute Trading
215
+
216
+ ```typescript
217
+ const result = await client.buy(buyParams);
218
+ console.log(`Transaction signature: ${result.signature}`);
219
+ ```
220
+
221
+ ### ⚑ Trading Parameters
222
+
223
+ For comprehensive information about all trading parameters including `TradeBuyParams` and `TradeSellParams`, see the Trading Parameters documentation.
224
+
225
+ #### About ShredStream
226
+
227
+ When using shred to subscribe to events, due to the nature of shreds, you cannot get complete information about transaction events.
228
+ Please ensure that the parameters your trading logic depends on are available in shreds when using them.
229
+
230
+ ### πŸ“Š Usage Examples Summary Table
231
+
232
+ | Description | Run Command | Source Code |
233
+ |-------------|-------------|-------------|
234
+ | Create and configure TradingClient instance | `npx ts-node examples/trading_client.ts` | [examples/trading_client.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/trading_client.ts) |
235
+ | Share infrastructure across multiple wallets | `npx ts-node examples/shared_infrastructure.ts` | [examples/shared_infrastructure.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/shared_infrastructure.ts) |
236
+ | PumpFun token sniping trading | `npx ts-node examples/pumpfun_sniper_trading.ts` | [examples/pumpfun_sniper_trading.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/pumpfun_sniper_trading.ts) |
237
+ | PumpFun token copy trading | `npx ts-node examples/pumpfun_copy_trading.ts` | [examples/pumpfun_copy_trading.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/pumpfun_copy_trading.ts) |
238
+ | PumpSwap trading operations | `npx ts-node examples/pumpswap_trading.ts` | [examples/pumpswap_trading.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/pumpswap_trading.ts) |
239
+ | PumpSwap direct trading (via RPC) | `npx ts-node examples/pumpswap_direct_trading.ts` | [examples/pumpswap_direct_trading.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/pumpswap_direct_trading.ts) |
240
+ | Raydium CPMM trading operations | `npx ts-node examples/raydium_cpmm_trading.ts` | [examples/raydium_cpmm_trading.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/raydium_cpmm_trading.ts) |
241
+ | Raydium AMM V4 trading operations | `npx ts-node examples/raydium_amm_v4_trading.ts` | [examples/raydium_amm_v4_trading.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/raydium_amm_v4_trading.ts) |
242
+ | Meteora DAMM V2 trading operations | `npx ts-node examples/meteora_damm_v2_trading.ts` | [examples/meteora_damm_v2_trading.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/meteora_damm_v2_trading.ts) |
243
+ | Bonk token sniping trading | `npx ts-node examples/bonk_sniper_trading.ts` | [examples/bonk_sniper_trading.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/bonk_sniper_trading.ts) |
244
+ | Bonk token copy trading | `npx ts-node examples/bonk_copy_trading.ts` | [examples/bonk_copy_trading.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/bonk_copy_trading.ts) |
245
+ | Custom instruction middleware example | `npx ts-node examples/middleware_system.ts` | [examples/middleware_system.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/middleware_system.ts) |
246
+ | Address lookup table example | `npx ts-node examples/address_lookup.ts` | [examples/address_lookup.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/address_lookup.ts) |
247
+ | Nonce cache (durable nonce) example | `npx ts-node examples/nonce_cache.ts` | [examples/nonce_cache.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/nonce_cache.ts) |
248
+ | Wrap/unwrap SOL to/from WSOL example | `npx ts-node examples/wsol_wrapper.ts` | [examples/wsol_wrapper.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/wsol_wrapper.ts) |
249
+ | Seed trading example | `npx ts-node examples/seed_trading.ts` | [examples/seed_trading.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/seed_trading.ts) |
250
+ | Gas fee strategy example | `npx ts-node examples/gas_fee_strategy.ts` | [examples/gas_fee_strategy.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/gas_fee_strategy.ts) |
251
+ | Hot path trading (zero-RPC) | `npx ts-node examples/hot_path_trading.ts` | [examples/hot_path_trading.ts](https://github.com/0xfnzero/sol-trade-sdk-nodejs/blob/main/examples/hot_path_trading.ts) |
252
+
253
+ ### βš™οΈ SWQoS Service Configuration
254
+
255
+ When configuring SWQoS services, note the different parameter requirements for each service:
256
+
257
+ - **Jito**: The first parameter is UUID (if no UUID, pass an empty string `""`)
258
+ - **Other MEV services**: The first parameter is the API Token
259
+
260
+ #### Custom URL Support
261
+
262
+ Each SWQoS service supports an optional custom URL parameter:
263
+
264
+ ```typescript
265
+ // Using custom URL
266
+ const jitoConfig: SwqosConfig = {
267
+ type: 'Jito',
268
+ uuid: "your_uuid",
269
+ region: SwqosRegion.Frankfurt,
270
+ customUrl: "https://custom-jito-endpoint.com"
271
+ };
272
+
273
+ // Using default regional endpoint
274
+ const bloxrouteConfig: SwqosConfig = {
275
+ type: 'Bloxroute',
276
+ apiToken: "your_api_token",
277
+ region: SwqosRegion.NewYork
278
+ };
279
+ ```
280
+
281
+ **URL Priority Logic**:
282
+ - If a custom URL is provided, it will be used instead of the regional endpoint
283
+ - If no custom URL is provided, the system will use the default endpoint for the specified region
284
+ - This allows for maximum flexibility while maintaining backward compatibility
285
+
286
+ When using multiple MEV services, you need to use `Durable Nonce`. You need to use the `fetchNonceInfo` function to get the latest `nonce` value, and use it as the `durableNonce` when trading.
287
+
288
+ ---
289
+
290
+ ### πŸ”§ Middleware System
291
+
292
+ The SDK provides a powerful middleware system that allows you to modify, add, or remove instructions before transaction execution. Middleware executes in the order they are added:
293
+
294
+ ```typescript
295
+ import { MiddlewareManager, ValidationMiddleware, TimerMiddleware } from 'sol-trade-sdk';
296
+
297
+ const manager = new MiddlewareManager()
298
+ .addMiddleware(new FirstMiddleware()) // Executes first
299
+ .addMiddleware(new SecondMiddleware()) // Executes second
300
+ .addMiddleware(new ThirdMiddleware()); // Executes last
301
+ ```
302
+
303
+ ### πŸ” Address Lookup Tables
304
+
305
+ Address Lookup Tables (ALT) allow you to optimize transaction size and reduce fees by storing frequently used addresses in a compact table format.
306
+
307
+ ```typescript
308
+ import { fetchAddressLookupTableAccount, AddressLookupTableCache } from 'sol-trade-sdk';
309
+
310
+ // Fetch ALT from chain
311
+ const alt = await fetchAddressLookupTableAccount(rpc, altAddress);
312
+ console.log(`ALT contains ${alt.addresses.length} addresses`);
313
+
314
+ // Use cache for performance
315
+ const cache = new AddressLookupTableCache(rpc);
316
+ await cache.prefetch([altAddress1, altAddress2, altAddress3]);
317
+ const cached = cache.get(altAddress1);
318
+ ```
319
+
320
+ ### πŸ” Durable Nonce
321
+
322
+ Use Durable Nonce to implement transaction replay protection and optimize transaction processing.
323
+
324
+ ```typescript
325
+ import { fetchNonceInfo, NonceCache } from 'sol-trade-sdk';
326
+
327
+ // Fetch nonce info
328
+ const nonceInfo = await fetchNonceInfo(rpc, nonceAccount);
329
+ ```
330
+
331
+ ## πŸ’° Cashback Support (PumpFun / PumpSwap)
332
+
333
+ PumpFun and PumpSwap support **cashback** for eligible tokens: part of the trading fee can be returned to the user. The SDK **must know** whether the token has cashback enabled so that buy/sell instructions include the correct accounts.
334
+
335
+ - **When params come from RPC**: If you use `PumpFunParams.fromMintByRpc` or `PumpSwapParams.fromPoolAddressByRpc`, the SDK reads `isCashbackCoin` from chainβ€”no extra step.
336
+ - **When params come from event/parser**: If you build params from trade events (e.g. [sol-parser-sdk](https://github.com/0xfnzero/sol-parser-sdk)), you **must** pass the cashback flag into the SDK:
337
+ - **PumpFun**: Set `isCashbackCoin` when building params from parsed events.
338
+ - **PumpSwap**: Set `isCashbackCoin` field when constructing params manually.
339
+
340
+ ## πŸ›‘οΈ MEV Protection Services
341
+
342
+ You can apply for a key through the official website: [Community Website](https://fnzero.dev/swqos)
343
+
344
+ - **Jito**: High-performance block space
345
+ - **ZeroSlot**: Zero-latency transactions
346
+ - **Temporal**: Time-sensitive transactions
347
+ - **Bloxroute**: Blockchain network acceleration
348
+ - **FlashBlock**: High-speed transaction execution with API key authentication
349
+ - **BlockRazor**: High-speed transaction execution with API key authentication
350
+ - **Node1**: High-speed transaction execution with API key authentication
351
+ - **Astralane**: Blockchain network acceleration
352
+
353
+ ## πŸ“ Project Structure
354
+
355
+ ```
356
+ src/
357
+ β”œβ”€β”€ common/ # Common functionality and tools
358
+ β”œβ”€β”€ constants/ # Constant definitions
359
+ β”œβ”€β”€ instruction/ # Instruction building
360
+ β”‚ └── utils/ # Instruction utilities
361
+ β”œβ”€β”€ swqos/ # MEV service clients
362
+ β”œβ”€β”€ trading/ # Unified trading engine
363
+ β”‚ β”œβ”€β”€ common/ # Common trading tools
364
+ β”‚ β”œβ”€β”€ core/ # Core trading engine
365
+ β”‚ β”œβ”€β”€ middleware/ # Middleware system
366
+ β”‚ └── factory.ts # Trading factory
367
+ β”œβ”€β”€ utils/ # Utility functions
368
+ β”‚ β”œβ”€β”€ calc/ # Amount calculation utilities
369
+ β”‚ └── price/ # Price calculation utilities
370
+ └── index.ts # Main library file
371
+ ```
372
+
373
+ ## πŸ“„ License
374
+
375
+ MIT License
376
+
377
+ ## πŸ’¬ Contact
378
+
379
+ - Official Website: https://fnzero.dev/
380
+ - Project Repository: https://github.com/0xfnzero/sol-trade-sdk-nodejs
381
+ - Telegram Group: https://t.me/fnzero_group
382
+ - Discord: https://discord.gg/vuazbGkqQE
383
+
384
+ ## ⚠️ Important Notes
385
+
386
+ 1. Test thoroughly before using on mainnet
387
+ 2. Properly configure private keys and API tokens
388
+ 3. Pay attention to slippage settings to avoid transaction failures
389
+ 4. Monitor balances and transaction fees
390
+ 5. Comply with relevant laws and regulations