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
@@ -0,0 +1,2327 @@
1
+ import { TransactionInstruction } from '@solana/web3.js';
2
+
3
+ /**
4
+ * Compiler-level optimizations for TypeScript/JavaScript code.
5
+ * Provides JIT compilation hints, optimization patterns, and
6
+ * performance-critical code paths.
7
+ */
8
+ /**
9
+ * Configuration for JIT-like optimizations
10
+ */
11
+ interface JITConfig {
12
+ enabled: boolean;
13
+ cacheSize: number;
14
+ optimizationLevel: 'O0' | 'O1' | 'O2' | 'O3';
15
+ inlineThreshold: number;
16
+ loopVectorize: boolean;
17
+ slpVectorize: boolean;
18
+ }
19
+ /**
20
+ * Default JIT configuration
21
+ */
22
+ declare function defaultJITConfig(): JITConfig;
23
+ /**
24
+ * Branch prediction optimization hints
25
+ */
26
+ declare class BranchOptimizer {
27
+ /**
28
+ * Hint that the condition is likely true
29
+ * Use this to guide branch prediction in hot paths
30
+ */
31
+ static likely(condition: boolean): boolean;
32
+ /**
33
+ * Hint that the condition is likely false
34
+ * Use this to guide branch prediction in error handling paths
35
+ */
36
+ static unlikely(condition: boolean): boolean;
37
+ }
38
+ /**
39
+ * Hint that the condition is likely true
40
+ */
41
+ declare function likely(condition: boolean): boolean;
42
+ /**
43
+ * Hint that the condition is likely false
44
+ */
45
+ declare function unlikely(condition: boolean): boolean;
46
+ /**
47
+ * Loop optimization utilities
48
+ */
49
+ declare class LoopOptimizer {
50
+ /**
51
+ * Hint that a loop should be unrolled
52
+ */
53
+ static unrollHint(factor: number): number;
54
+ /**
55
+ * Hint that a loop should be vectorized
56
+ */
57
+ static vectorizeHint(): void;
58
+ /**
59
+ * Hint that a loop should be parallelized
60
+ */
61
+ static parallelHint(): void;
62
+ }
63
+ /**
64
+ * Cache line size (typical for modern CPUs)
65
+ */
66
+ declare const CACHE_LINE_SIZE = 64;
67
+ /**
68
+ * Cache-aligned buffer
69
+ */
70
+ declare class AlignedBuffer {
71
+ private data;
72
+ private offset;
73
+ constructor(size: number, align?: number);
74
+ /**
75
+ * Get the aligned buffer
76
+ */
77
+ get buffer(): Buffer;
78
+ /**
79
+ * Get the underlying buffer
80
+ */
81
+ get underlying(): Buffer;
82
+ }
83
+ /**
84
+ * Prefetch hint - documents intent for prefetching
85
+ */
86
+ declare function prefetchHint(address: number): void;
87
+ /**
88
+ * Profile-guided optimization utilities
89
+ */
90
+ declare class ProfileGuidedOptimizer {
91
+ private profileData;
92
+ private callCounts;
93
+ /**
94
+ * Instrument a function for profiling
95
+ */
96
+ instrument<T extends (...args: any[]) => any>(name: string, fn: T): T;
97
+ /**
98
+ * Get the most frequently called functions
99
+ */
100
+ getHotFunctions(topN?: number): Array<{
101
+ name: string;
102
+ count: number;
103
+ }>;
104
+ /**
105
+ * Get functions with highest average execution time
106
+ */
107
+ getSlowFunctions(topN?: number): Array<{
108
+ name: string;
109
+ avgTime: number;
110
+ }>;
111
+ }
112
+ /**
113
+ * Optimized mathematical operations
114
+ */
115
+ declare class OptimizedMath {
116
+ /**
117
+ * Fast exponential approximation
118
+ */
119
+ static fastExp(x: number): number;
120
+ /**
121
+ * Fast logarithm
122
+ */
123
+ static fastLog(x: number): number;
124
+ /**
125
+ * Fast square root
126
+ */
127
+ static fastSqrt(x: number): number;
128
+ /**
129
+ * Fast inverse square root (Quake III algorithm)
130
+ */
131
+ static fastInvSqrt(x: number): number;
132
+ /**
133
+ * Fast power
134
+ */
135
+ static fastPow(base: number, exp: number): number;
136
+ /**
137
+ * Fast absolute value for integers
138
+ */
139
+ static fastAbs(x: number): number;
140
+ }
141
+ /**
142
+ * Fast inverse square root
143
+ */
144
+ declare function fastInvSqrt(x: number): number;
145
+ /**
146
+ * Cache for expensive function results
147
+ */
148
+ declare class FuncCache<T> {
149
+ private cache;
150
+ private hits;
151
+ private misses;
152
+ private maxSize;
153
+ constructor(maxSize?: number);
154
+ /**
155
+ * Get a cached value
156
+ */
157
+ get(key: string): T | undefined;
158
+ /**
159
+ * Set a cached value
160
+ */
161
+ set(key: string, value: T): void;
162
+ /**
163
+ * Get cache statistics
164
+ */
165
+ stats(): {
166
+ hits: number;
167
+ misses: number;
168
+ hitRate: number;
169
+ };
170
+ /**
171
+ * Clear the cache
172
+ */
173
+ clear(): void;
174
+ }
175
+ /**
176
+ * Simple spin lock for very short critical sections
177
+ * Note: In JavaScript, this is not truly blocking, but uses busy waiting
178
+ */
179
+ declare class SpinLock {
180
+ private locked;
181
+ /**
182
+ * Acquire the lock
183
+ */
184
+ lock(): Promise<void>;
185
+ /**
186
+ * Release the lock
187
+ */
188
+ unlock(): void;
189
+ /**
190
+ * Try to acquire the lock without blocking
191
+ */
192
+ tryLock(): boolean;
193
+ }
194
+ /**
195
+ * Mark a function as a hot path (frequently executed)
196
+ * This is a no-op but documents intent for optimization
197
+ */
198
+ declare function hotPath(): void;
199
+ /**
200
+ * Mark a function as a cold path (rarely executed)
201
+ * This is a no-op but documents intent for optimization
202
+ */
203
+ declare function coldPath(): void;
204
+ /**
205
+ * Optimized memory operations
206
+ */
207
+ declare class MemoryOps {
208
+ /**
209
+ * Copy memory with potential SIMD optimization
210
+ */
211
+ static memCopy(dst: Uint8Array, src: Uint8Array): number;
212
+ /**
213
+ * Set memory with potential SIMD optimization
214
+ */
215
+ static memSet(dst: Uint8Array, value: number): void;
216
+ /**
217
+ * Zero memory
218
+ */
219
+ static memZero(dst: Uint8Array): void;
220
+ }
221
+ /**
222
+ * CPU features
223
+ */
224
+ interface CPUFeatures {
225
+ hasSIMD: boolean;
226
+ hasAVX: boolean;
227
+ hasAVX2: boolean;
228
+ hasSSE: boolean;
229
+ hasSSE2: boolean;
230
+ hasSSE3: boolean;
231
+ hasSSE41: boolean;
232
+ hasSSE42: boolean;
233
+ hasFMA: boolean;
234
+ hasBMI: boolean;
235
+ hasBMI2: boolean;
236
+ hasPopcnt: boolean;
237
+ cacheLine: number;
238
+ numCPU: number;
239
+ }
240
+ /**
241
+ * Detect CPU features
242
+ * Note: In JavaScript, most CPU features are not directly accessible
243
+ */
244
+ declare function detectCPUFeatures(): CPUFeatures;
245
+ /**
246
+ * Get or create global profile optimizer
247
+ */
248
+ declare function getProfileOptimizer(): ProfileGuidedOptimizer;
249
+ /**
250
+ * Profile decorator using global profile optimizer
251
+ */
252
+ declare function profile(target: any, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
253
+
254
+ /**
255
+ * Hardware Optimization Module for Sol Trade SDK
256
+ * Provides CPU affinity, NUMA optimization, and cache optimizations.
257
+ */
258
+ /**
259
+ * CPU topology information
260
+ */
261
+ interface CPUTopology {
262
+ physicalCores: number;
263
+ logicalCores: number;
264
+ numaNodes: number;
265
+ cacheLevels: CacheInfo[];
266
+ }
267
+ /**
268
+ * Cache information
269
+ */
270
+ interface CacheInfo {
271
+ level: number;
272
+ size: number;
273
+ lineSize: number;
274
+ associativity: number;
275
+ }
276
+ /**
277
+ * CPU affinity configuration
278
+ */
279
+ interface AffinityConfig {
280
+ /** Enable CPU pinning */
281
+ enablePinning: boolean;
282
+ /** Preferred CPU cores */
283
+ preferredCores: number[];
284
+ /** Avoid hyperthreading pairs */
285
+ avoidSMT: boolean;
286
+ /** NUMA node preference */
287
+ numaNode: number;
288
+ }
289
+ /**
290
+ * Default affinity configuration
291
+ */
292
+ declare function defaultAffinityConfig(): AffinityConfig;
293
+ /**
294
+ * NUMA configuration
295
+ */
296
+ interface NUMAConfig {
297
+ /** Enable NUMA-aware allocation */
298
+ enableNUMA: boolean;
299
+ /** Preferred NUMA node */
300
+ preferredNode: number;
301
+ /** Interleave memory across nodes */
302
+ interleave: boolean;
303
+ }
304
+ /**
305
+ * Default NUMA configuration
306
+ */
307
+ declare function defaultNUMAConfig(): NUMAConfig;
308
+ /**
309
+ * CPU affinity manager for pinning threads to specific cores.
310
+ * Reduces context switches and improves cache locality.
311
+ */
312
+ declare class CPUAffinity {
313
+ private config;
314
+ private pinnedCores;
315
+ constructor(config?: AffinityConfig);
316
+ /**
317
+ * Get CPU topology information
318
+ */
319
+ getTopology(): CPUTopology;
320
+ /**
321
+ * Pin current execution context to a specific core
322
+ * Note: In Node.js, this is advisory only via worker threads
323
+ */
324
+ pinToCore(coreId: number): boolean;
325
+ /**
326
+ * Pin to multiple cores
327
+ */
328
+ pinToCores(coreIds: number[]): boolean;
329
+ /**
330
+ * Get recommended cores for pinning
331
+ */
332
+ getRecommendedCores(count?: number): number[];
333
+ /**
334
+ * Check if a core is available
335
+ */
336
+ isCoreAvailable(coreId: number): boolean;
337
+ /**
338
+ * Get current core (simulated)
339
+ */
340
+ getCurrentCore(): number;
341
+ /**
342
+ * Get pinned cores
343
+ */
344
+ getPinnedCores(): number[];
345
+ /**
346
+ * Unpin all cores
347
+ */
348
+ unpinAll(): void;
349
+ }
350
+ /**
351
+ * NUMA (Non-Uniform Memory Access) optimizer.
352
+ * Optimizes memory allocation for NUMA architectures.
353
+ */
354
+ declare class NUMAOptimizer {
355
+ private config;
356
+ private allocations;
357
+ constructor(config?: NUMAConfig);
358
+ /**
359
+ * Allocate memory with NUMA awareness
360
+ */
361
+ allocate(size: number, tag?: string): ArrayBuffer;
362
+ /**
363
+ * Allocate typed array with NUMA awareness
364
+ */
365
+ allocateTypedArray<T extends TypedArray>(constructor: TypedArrayConstructor<T>, length: number, tag?: string): T;
366
+ /**
367
+ * Get allocation information
368
+ */
369
+ getAllocation(tag: string): NUMAAllocation | undefined;
370
+ /**
371
+ * Get local memory node for current thread
372
+ */
373
+ getLocalNode(): number;
374
+ /**
375
+ * Get number of NUMA nodes
376
+ */
377
+ getNodeCount(): number;
378
+ /**
379
+ * Check if NUMA is available
380
+ */
381
+ isNUMAAvailable(): boolean;
382
+ /**
383
+ * Migrate allocation to preferred node
384
+ * Note: No-op in JavaScript
385
+ */
386
+ migrateToNode(tag: string, node: number): boolean;
387
+ /**
388
+ * Free allocation tracking
389
+ */
390
+ free(tag: string): void;
391
+ /**
392
+ * Get all allocations
393
+ */
394
+ getAllAllocations(): Map<string, NUMAAllocation>;
395
+ }
396
+ /**
397
+ * NUMA allocation tracking
398
+ */
399
+ interface NUMAAllocation {
400
+ buffer: ArrayBuffer;
401
+ size: number;
402
+ node: number;
403
+ timestamp: number;
404
+ }
405
+ /**
406
+ * Typed array types
407
+ */
408
+ type TypedArray = Uint8Array | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array;
409
+ interface TypedArrayConstructor<T> {
410
+ new (buffer: ArrayBuffer): T;
411
+ BYTES_PER_ELEMENT: number;
412
+ }
413
+ /**
414
+ * Cache optimization utilities.
415
+ * Provides cache-friendly data structure layouts and prefetching hints.
416
+ */
417
+ declare class CacheOptimizer {
418
+ private cacheLineSize;
419
+ private l1Size;
420
+ private l2Size;
421
+ private l3Size;
422
+ constructor();
423
+ /**
424
+ * Set cache parameters
425
+ */
426
+ setCacheParams(params: {
427
+ cacheLineSize?: number;
428
+ l1Size?: number;
429
+ l2Size?: number;
430
+ l3Size?: number;
431
+ }): void;
432
+ /**
433
+ * Align size to cache line boundary
434
+ */
435
+ alignToCacheLine(size: number): number;
436
+ /**
437
+ * Check if address is cache line aligned
438
+ */
439
+ isCacheLineAligned(address: number): boolean;
440
+ /**
441
+ * Calculate cache-friendly array stride
442
+ */
443
+ calculateStride(elementSize: number): number;
444
+ /**
445
+ * Create cache-friendly layout for array of objects
446
+ */
447
+ createSoALayout<T extends Record<string, number | bigint>>(count: number, schema: Record<keyof T, 'u8' | 'u16' | 'u32' | 'u64' | 'f32' | 'f64'>): StructureOfArrays<T>;
448
+ /**
449
+ * Get cache line size
450
+ */
451
+ getCacheLineSize(): number;
452
+ /**
453
+ * Get L1 cache size
454
+ */
455
+ getL1Size(): number;
456
+ /**
457
+ * Get L2 cache size
458
+ */
459
+ getL2Size(): number;
460
+ /**
461
+ * Get L3 cache size
462
+ */
463
+ getL3Size(): number;
464
+ }
465
+ /**
466
+ * Structure of Arrays layout
467
+ */
468
+ interface StructureOfArrays<T> {
469
+ arrays: Record<keyof T, TypedArray>;
470
+ offsets: Record<keyof T, number>;
471
+ count: number;
472
+ get(index: number): T;
473
+ set(index: number, value: T): void;
474
+ }
475
+ /**
476
+ * Hardware performance monitoring
477
+ */
478
+ declare class HardwareMonitor {
479
+ private startTime;
480
+ private measurements;
481
+ /**
482
+ * Start monitoring
483
+ */
484
+ start(): void;
485
+ /**
486
+ * Take a measurement
487
+ */
488
+ measure(label: string): void;
489
+ /**
490
+ * Get memory information
491
+ */
492
+ getMemoryInfo(): MemoryInfo;
493
+ /**
494
+ * Get all measurements
495
+ */
496
+ getMeasurements(): HardwareMeasurement[];
497
+ /**
498
+ * Reset measurements
499
+ */
500
+ reset(): void;
501
+ }
502
+ /**
503
+ * Memory information
504
+ */
505
+ interface MemoryInfo {
506
+ used: number;
507
+ total: number;
508
+ external: number;
509
+ rss: number;
510
+ }
511
+ /**
512
+ * Hardware measurement
513
+ */
514
+ interface HardwareMeasurement {
515
+ label: string;
516
+ timestamp: number;
517
+ memory: MemoryInfo;
518
+ }
519
+ /**
520
+ * Create a CPU affinity manager
521
+ */
522
+ declare function createCPUAffinity(config?: Partial<AffinityConfig>): CPUAffinity;
523
+ /**
524
+ * Create a NUMA optimizer
525
+ */
526
+ declare function createNUMAOptimizer(config?: Partial<NUMAConfig>): NUMAOptimizer;
527
+ /**
528
+ * Create a cache optimizer
529
+ */
530
+ declare function createCacheOptimizer(): CacheOptimizer;
531
+ /**
532
+ * Create a hardware monitor
533
+ */
534
+ declare function createHardwareMonitor(): HardwareMonitor;
535
+ /**
536
+ * Get system CPU information
537
+ */
538
+ declare function getSystemCPUInfo(): {
539
+ cores: number;
540
+ model: string;
541
+ };
542
+ /**
543
+ * Get system memory information
544
+ */
545
+ declare function getSystemMemoryInfo(): {
546
+ total: number;
547
+ free: number;
548
+ };
549
+
550
+ /**
551
+ * Kernel bypass optimizations for ultra-low latency I/O.
552
+ * Provides io_uring-like support for async I/O without kernel copies,
553
+ * along with fallback implementations for different platforms.
554
+ */
555
+ /**
556
+ * I/O operation types
557
+ */
558
+ declare enum IOOperation {
559
+ READ = "READ",
560
+ WRITE = "WRITE",
561
+ FSYNC = "FSYNC",
562
+ POLL = "POLL",
563
+ TIMEOUT = "TIMEOUT"
564
+ }
565
+ /**
566
+ * I/O request for kernel bypass operations
567
+ */
568
+ interface IORequest {
569
+ op: IOOperation;
570
+ fd: number;
571
+ buffer?: Buffer;
572
+ offset: number;
573
+ size: number;
574
+ callback?: (id: number, data: Buffer | null, bytesTransferred: number) => void;
575
+ userData?: unknown;
576
+ }
577
+ /**
578
+ * I/O result
579
+ */
580
+ interface IOResult {
581
+ requestId: number;
582
+ bytesTransferred: number;
583
+ buffer?: Buffer;
584
+ error?: Error;
585
+ userData?: unknown;
586
+ }
587
+ /**
588
+ * io_uring configuration
589
+ */
590
+ interface IOUringConfig {
591
+ queueDepth: number;
592
+ sqThreadIdle: number;
593
+ sqThreadCpu: number;
594
+ cqSize: number;
595
+ flags: number;
596
+ features: string[];
597
+ }
598
+ /**
599
+ * Default io_uring configuration
600
+ */
601
+ declare function defaultIOUringConfig(): IOUringConfig;
602
+ /**
603
+ * Manager for kernel bypass I/O operations.
604
+ * Uses optimized async I/O when available, falls back to standard async I/O.
605
+ */
606
+ declare class KernelBypassManager {
607
+ private config;
608
+ private uringAvailable;
609
+ private requestCounter;
610
+ private pendingRequests;
611
+ private running;
612
+ private processTimer;
613
+ constructor(config?: IOUringConfig);
614
+ /**
615
+ * Check if io_uring-like functionality is available
616
+ */
617
+ private checkUringAvailability;
618
+ /**
619
+ * Check if io_uring is available
620
+ */
621
+ isUringAvailable(): boolean;
622
+ /**
623
+ * Start the I/O processing loop
624
+ */
625
+ start(): void;
626
+ /**
627
+ * Stop the I/O processing loop
628
+ */
629
+ stop(): void;
630
+ /**
631
+ * Main processing loop
632
+ */
633
+ private processLoop;
634
+ /**
635
+ * Process pending I/O requests
636
+ */
637
+ private processPendingRequests;
638
+ /**
639
+ * Process a read request
640
+ */
641
+ private processRead;
642
+ /**
643
+ * Process a write request
644
+ */
645
+ private processWrite;
646
+ /**
647
+ * Submit an async read request
648
+ */
649
+ submitRead(fd: number, size: number, offset?: number, callback?: (id: number, data: Buffer | null, bytesTransferred: number) => void, userData?: unknown): number;
650
+ /**
651
+ * Submit an async write request
652
+ */
653
+ submitWrite(fd: number, buffer: Buffer, offset?: number, callback?: (id: number, data: Buffer | null, bytesTransferred: number) => void, userData?: unknown): number;
654
+ }
655
+ /**
656
+ * File with direct I/O support (bypassing page cache)
657
+ */
658
+ declare class DirectIOFile {
659
+ private path;
660
+ private fd;
661
+ private directIO;
662
+ constructor(path: string);
663
+ /**
664
+ * Open file with direct I/O if available
665
+ */
666
+ open(): Promise<boolean>;
667
+ /**
668
+ * Close the file
669
+ */
670
+ close(): Promise<void>;
671
+ /**
672
+ * Read from file
673
+ */
674
+ read(size: number, offset?: number): Promise<Buffer>;
675
+ /**
676
+ * Read using direct I/O with aligned buffer
677
+ */
678
+ private readDirect;
679
+ /**
680
+ * Write to file
681
+ */
682
+ write(data: Buffer, offset?: number): Promise<number>;
683
+ /**
684
+ * Sync file to disk
685
+ */
686
+ fsync(): Promise<void>;
687
+ }
688
+ /**
689
+ * Memory-mapped file for zero-copy access
690
+ */
691
+ declare class MemoryMappedFile {
692
+ private path;
693
+ private fd;
694
+ private buffer;
695
+ constructor(path: string);
696
+ /**
697
+ * Open and memory-map the file
698
+ */
699
+ open(size?: number): Promise<boolean>;
700
+ /**
701
+ * Close the memory-mapped file
702
+ */
703
+ close(): Promise<void>;
704
+ /**
705
+ * Read from memory-mapped file
706
+ */
707
+ read(offset: number, size: number): Buffer;
708
+ /**
709
+ * Write to memory-mapped file
710
+ */
711
+ write(offset: number, data: Buffer): void;
712
+ /**
713
+ * Flush changes to disk
714
+ */
715
+ flush(): Promise<void>;
716
+ }
717
+ /**
718
+ * Async socket with kernel bypass optimizations
719
+ */
720
+ declare class AsyncSocket {
721
+ private socket;
722
+ /**
723
+ * Set the underlying socket
724
+ */
725
+ setSocket(socket: any): void;
726
+ /**
727
+ * Enable kernel bypass optimizations for this socket
728
+ */
729
+ enableKernelBypass(): boolean;
730
+ /**
731
+ * Async receive with optimization
732
+ */
733
+ recv(size: number): Promise<Buffer>;
734
+ /**
735
+ * Async send with optimization
736
+ */
737
+ send(data: Buffer): Promise<void>;
738
+ }
739
+ /**
740
+ * Batch processor for I/O operations with kernel bypass
741
+ */
742
+ declare class IOBatchProcessor {
743
+ private maxBatchSize;
744
+ private readBatch;
745
+ private writeBatch;
746
+ private manager;
747
+ constructor(maxBatchSize?: number);
748
+ /**
749
+ * Add read to batch
750
+ */
751
+ addRead(fd: number, size: number, offset?: number, callback?: (id: number, data: Buffer | null, bytesTransferred: number) => void): void;
752
+ /**
753
+ * Add write to batch
754
+ */
755
+ addWrite(fd: number, data: Buffer, offset?: number, callback?: (id: number, data: Buffer | null, bytesTransferred: number) => void): void;
756
+ /**
757
+ * Flush all pending reads
758
+ */
759
+ flushReads(): number[];
760
+ /**
761
+ * Flush all pending writes
762
+ */
763
+ flushWrites(): number[];
764
+ /**
765
+ * Flush all pending operations
766
+ */
767
+ flushAll(): {
768
+ readIds: number[];
769
+ writeIds: number[];
770
+ };
771
+ }
772
+ /**
773
+ * Get or create global kernel bypass manager
774
+ */
775
+ declare function getKernelBypassManager(config?: IOUringConfig): KernelBypassManager;
776
+
777
+ /**
778
+ * Protocol Optimization Module for Sol Trade SDK
779
+ * Provides transaction optimization, compute budget management, and builder patterns.
780
+ */
781
+
782
+ /**
783
+ * Transaction configuration
784
+ */
785
+ interface TransactionConfig {
786
+ /** Compute unit limit */
787
+ computeUnitLimit: number;
788
+ /** Compute unit price (micro-lamports) */
789
+ computeUnitPrice: number;
790
+ /** Priority fee in lamports */
791
+ priorityFee: number;
792
+ /** Enable dynamic compute budget */
793
+ dynamicComputeBudget: boolean;
794
+ /** Enable instruction packing */
795
+ packInstructions: boolean;
796
+ /** Maximum transaction size */
797
+ maxTransactionSize: number;
798
+ /** Enable address lookup tables */
799
+ useAddressLookupTables: boolean;
800
+ }
801
+ /**
802
+ * Default transaction configuration
803
+ */
804
+ declare function defaultTransactionConfig(): TransactionConfig;
805
+ /**
806
+ * Compute budget statistics
807
+ */
808
+ interface ComputeBudgetStats {
809
+ totalComputeUsed: number;
810
+ totalComputeLimit: number;
811
+ averageComputePerInstruction: number;
812
+ estimatedFee: number;
813
+ efficiency: number;
814
+ }
815
+ /**
816
+ * Instruction group for batching
817
+ */
818
+ interface InstructionGroup {
819
+ instructions: TransactionInstruction[];
820
+ computeEstimate: number;
821
+ priority: number;
822
+ }
823
+ /**
824
+ * Transaction optimization result
825
+ */
826
+ interface OptimizationResult {
827
+ instructions: TransactionInstruction[];
828
+ computeLimit: number;
829
+ computePrice: number;
830
+ estimatedSize: number;
831
+ optimizations: string[];
832
+ }
833
+ /**
834
+ * High-performance transaction builder with optimization.
835
+ * Constructs optimized Solana transactions for trading.
836
+ */
837
+ declare class TransactionBuilder {
838
+ private instructions;
839
+ private config;
840
+ private computeEstimates;
841
+ private signers;
842
+ constructor(config?: TransactionConfig);
843
+ /**
844
+ * Initialize default compute estimates for common instructions
845
+ */
846
+ private initializeComputeEstimates;
847
+ /**
848
+ * Add an instruction to the transaction
849
+ */
850
+ addInstruction(instruction: TransactionInstruction, computeEstimate?: number, priority?: number): this;
851
+ /**
852
+ * Add multiple instructions
853
+ */
854
+ addInstructions(instructions: TransactionInstruction[]): this;
855
+ /**
856
+ * Add compute budget instructions
857
+ */
858
+ addComputeBudget(units: number, price: number): this;
859
+ /**
860
+ * Estimate total compute units
861
+ */
862
+ estimateCompute(): number;
863
+ /**
864
+ * Build optimized transaction instructions
865
+ */
866
+ build(): OptimizationResult;
867
+ /**
868
+ * Build and return only the instructions (without compute budget)
869
+ */
870
+ buildInstructions(): TransactionInstruction[];
871
+ /**
872
+ * Clear all instructions
873
+ */
874
+ clear(): this;
875
+ /**
876
+ * Get current instruction count
877
+ */
878
+ getInstructionCount(): number;
879
+ /**
880
+ * Get current signer count
881
+ */
882
+ getSignerCount(): number;
883
+ private packInstructions;
884
+ private calculateOptimalComputeLimit;
885
+ private calculateOptimalPrice;
886
+ private estimateTransactionSize;
887
+ private addComputeBudgetInstructions;
888
+ }
889
+ /**
890
+ * Optimizes compute budget allocation for transactions.
891
+ * Provides dynamic adjustment based on network conditions.
892
+ */
893
+ declare class ComputeBudgetOptimizer {
894
+ private baseConfig;
895
+ private networkStats;
896
+ private history;
897
+ private maxHistorySize;
898
+ constructor(config?: TransactionConfig);
899
+ /**
900
+ * Update network statistics
901
+ */
902
+ updateNetworkStats(stats: Partial<NetworkStats>): void;
903
+ /**
904
+ * Get optimized compute budget for current conditions
905
+ */
906
+ getOptimizedBudget(priority?: 'low' | 'normal' | 'high' | 'critical'): {
907
+ computeLimit: number;
908
+ computePrice: number;
909
+ priorityFee: number;
910
+ };
911
+ /**
912
+ * Record transaction result for learning
913
+ */
914
+ recordResult(computeUsed: number, computeLimit: number, success: boolean, confirmationTimeMs: number): void;
915
+ /**
916
+ * Get recommended compute limit based on history
917
+ */
918
+ getRecommendedComputeLimit(): number;
919
+ /**
920
+ * Get optimization statistics
921
+ */
922
+ getStats(): ComputeBudgetStats;
923
+ /**
924
+ * Reset history
925
+ */
926
+ reset(): void;
927
+ private calculateEstimatedFee;
928
+ }
929
+ /**
930
+ * Network statistics
931
+ */
932
+ interface NetworkStats {
933
+ averageComputePrice: number;
934
+ congestionLevel: number;
935
+ recentSuccessRate: number;
936
+ }
937
+ /**
938
+ * Batches multiple instructions into optimized groups.
939
+ */
940
+ declare class InstructionBatcher {
941
+ private groups;
942
+ private maxComputePerGroup;
943
+ /**
944
+ * Add an instruction group
945
+ */
946
+ addGroup(group: InstructionGroup): this;
947
+ /**
948
+ * Batch all groups into optimal transaction sets
949
+ */
950
+ batch(): InstructionGroup[][];
951
+ /**
952
+ * Set maximum compute per batch
953
+ */
954
+ setMaxComputePerGroup(compute: number): this;
955
+ /**
956
+ * Clear all groups
957
+ */
958
+ clear(): this;
959
+ }
960
+ /**
961
+ * High-level transaction optimizer.
962
+ * Applies multiple optimization strategies.
963
+ */
964
+ declare class TransactionOptimizer {
965
+ private config;
966
+ private budgetOptimizer;
967
+ constructor(config?: TransactionConfig);
968
+ /**
969
+ * Optimize a set of instructions
970
+ */
971
+ optimize(instructions: TransactionInstruction[], options?: {
972
+ priority?: 'low' | 'normal' | 'high' | 'critical';
973
+ useLookupTables?: boolean;
974
+ }): OptimizationResult;
975
+ /**
976
+ * Optimize for minimum latency
977
+ */
978
+ optimizeForLatency(instructions: TransactionInstruction[]): OptimizationResult;
979
+ /**
980
+ * Optimize for minimum cost
981
+ */
982
+ optimizeForCost(instructions: TransactionInstruction[]): OptimizationResult;
983
+ /**
984
+ * Get the compute budget optimizer
985
+ */
986
+ getBudgetOptimizer(): ComputeBudgetOptimizer;
987
+ /**
988
+ * Update configuration
989
+ */
990
+ updateConfig(config: Partial<TransactionConfig>): void;
991
+ }
992
+ /**
993
+ * Create a transaction builder
994
+ */
995
+ declare function createTransactionBuilder(config?: Partial<TransactionConfig>): TransactionBuilder;
996
+ /**
997
+ * Create a compute budget optimizer
998
+ */
999
+ declare function createComputeBudgetOptimizer(config?: Partial<TransactionConfig>): ComputeBudgetOptimizer;
1000
+ /**
1001
+ * Create an instruction batcher
1002
+ */
1003
+ declare function createInstructionBatcher(): InstructionBatcher;
1004
+ /**
1005
+ * Create a transaction optimizer
1006
+ */
1007
+ declare function createTransactionOptimizer(config?: Partial<TransactionConfig>): TransactionOptimizer;
1008
+ /**
1009
+ * Estimate compute units for common operations
1010
+ */
1011
+ declare function estimateCompute(operation: string): number;
1012
+ /**
1013
+ * Calculate optimal compute unit price
1014
+ */
1015
+ declare function calculateOptimalPrice(targetLatencyMs: number, currentCongestion: number): number;
1016
+
1017
+ /**
1018
+ * Realtime Tuning Module for Sol Trade SDK
1019
+ * Provides realtime configuration, thread priority, and performance tuning.
1020
+ */
1021
+ /**
1022
+ * Realtime configuration
1023
+ */
1024
+ interface RealtimeConfig {
1025
+ /** Enable realtime mode */
1026
+ enableRealtime: boolean;
1027
+ /** Target latency in microseconds */
1028
+ targetLatencyUs: number;
1029
+ /** CPU core for pinning */
1030
+ cpuCore: number;
1031
+ /** Thread priority level */
1032
+ priority: ThreadPriorityLevel;
1033
+ /** Enable busy waiting */
1034
+ busyWait: boolean;
1035
+ /** Scheduler policy */
1036
+ scheduler: SchedulerPolicy;
1037
+ /** Memory lock */
1038
+ lockMemory: boolean;
1039
+ }
1040
+ /**
1041
+ * Thread priority levels
1042
+ */
1043
+ declare enum ThreadPriorityLevel {
1044
+ Idle = 0,
1045
+ Lowest = 1,
1046
+ Low = 2,
1047
+ Normal = 3,
1048
+ High = 4,
1049
+ Highest = 5,
1050
+ Realtime = 6
1051
+ }
1052
+ /**
1053
+ * Scheduler policies
1054
+ */
1055
+ declare enum SchedulerPolicy {
1056
+ /** Normal scheduler */
1057
+ Normal = "normal",
1058
+ /** FIFO scheduler */
1059
+ FIFO = "fifo",
1060
+ /** Round-robin scheduler */
1061
+ RoundRobin = "rr",
1062
+ /** Batch scheduler */
1063
+ Batch = "batch",
1064
+ /** Idle scheduler */
1065
+ Idle = "idle"
1066
+ }
1067
+ /**
1068
+ * Default realtime configuration
1069
+ */
1070
+ declare function defaultRealtimeConfig(): RealtimeConfig;
1071
+ /**
1072
+ * Tuning statistics
1073
+ */
1074
+ interface TuningStats {
1075
+ adjustments: number;
1076
+ averageLatencyUs: number;
1077
+ minLatencyUs: number;
1078
+ maxLatencyUs: number;
1079
+ violations: number;
1080
+ lastAdjustmentTime: number;
1081
+ }
1082
+ /**
1083
+ * Thread priority manager for realtime performance.
1084
+ * Controls execution priority of trading threads.
1085
+ */
1086
+ declare class ThreadPriority {
1087
+ private currentPriority;
1088
+ private config;
1089
+ constructor(config?: RealtimeConfig);
1090
+ /**
1091
+ * Set thread priority
1092
+ */
1093
+ setPriority(priority: ThreadPriorityLevel): boolean;
1094
+ /**
1095
+ * Get current priority
1096
+ */
1097
+ getPriority(): ThreadPriorityLevel;
1098
+ /**
1099
+ * Increase priority by one level
1100
+ */
1101
+ increasePriority(): boolean;
1102
+ /**
1103
+ * Decrease priority by one level
1104
+ */
1105
+ decreasePriority(): boolean;
1106
+ /**
1107
+ * Set realtime priority
1108
+ */
1109
+ setRealtime(): boolean;
1110
+ /**
1111
+ * Set normal priority
1112
+ */
1113
+ setNormal(): boolean;
1114
+ /**
1115
+ * Check if running at realtime priority
1116
+ */
1117
+ isRealtime(): boolean;
1118
+ }
1119
+ /**
1120
+ * Realtime performance tuner for trading systems.
1121
+ * Automatically adjusts system parameters for optimal latency.
1122
+ */
1123
+ declare class RealtimeTuner {
1124
+ private config;
1125
+ private running;
1126
+ private tunerInterval;
1127
+ private latencies;
1128
+ private stats;
1129
+ private callbacks;
1130
+ private lastAdjustment;
1131
+ private adjustmentCooldownMs;
1132
+ constructor(config?: RealtimeConfig);
1133
+ /**
1134
+ * Start the realtime tuner
1135
+ */
1136
+ start(): void;
1137
+ /**
1138
+ * Stop the realtime tuner
1139
+ */
1140
+ stop(): void;
1141
+ /**
1142
+ * Record a latency measurement
1143
+ */
1144
+ recordLatency(latencyUs: number): void;
1145
+ /**
1146
+ * Get current tuning statistics
1147
+ */
1148
+ getStats(): TuningStats;
1149
+ /**
1150
+ * Register a callback for tuning events
1151
+ */
1152
+ onTune(callback: (stats: TuningStats) => void): void;
1153
+ /**
1154
+ * Reset statistics
1155
+ */
1156
+ resetStats(): void;
1157
+ private applyConfiguration;
1158
+ private tune;
1159
+ private adjustForLowerLatency;
1160
+ }
1161
+ /**
1162
+ * Busy wait for a precise amount of time.
1163
+ * More accurate than setTimeout for short durations.
1164
+ */
1165
+ declare function busyWait(microseconds: number): void;
1166
+ /**
1167
+ * Spin lock with timeout
1168
+ */
1169
+ declare function spinLock(condition: () => boolean, timeoutUs: number): boolean;
1170
+ /**
1171
+ * Latency monitoring for realtime systems
1172
+ */
1173
+ declare class LatencyMonitor {
1174
+ private measurements;
1175
+ private maxMeasurements;
1176
+ private histogram;
1177
+ private bucketSize;
1178
+ constructor(maxMeasurements?: number, bucketSize?: number);
1179
+ /**
1180
+ * Record a latency measurement
1181
+ */
1182
+ record(latencyUs: number): void;
1183
+ /**
1184
+ * Get percentile latency
1185
+ */
1186
+ getPercentile(percentile: number): number;
1187
+ /**
1188
+ * Get average latency
1189
+ */
1190
+ getAverage(): number;
1191
+ /**
1192
+ * Get minimum latency
1193
+ */
1194
+ getMin(): number;
1195
+ /**
1196
+ * Get maximum latency
1197
+ */
1198
+ getMax(): number;
1199
+ /**
1200
+ * Get histogram
1201
+ */
1202
+ getHistogram(): Map<number, number>;
1203
+ /**
1204
+ * Reset all measurements
1205
+ */
1206
+ reset(): void;
1207
+ /**
1208
+ * Get summary statistics
1209
+ */
1210
+ getSummary(): {
1211
+ count: number;
1212
+ min: number;
1213
+ max: number;
1214
+ avg: number;
1215
+ p50: number;
1216
+ p95: number;
1217
+ p99: number;
1218
+ p999: number;
1219
+ };
1220
+ }
1221
+ /**
1222
+ * Performance governor for trading systems
1223
+ */
1224
+ declare class PerformanceGovernor {
1225
+ private targetThroughput;
1226
+ private currentThroughput;
1227
+ private adjustments;
1228
+ /**
1229
+ * Set target throughput (operations per second)
1230
+ */
1231
+ setTargetThroughput(opsPerSecond: number): void;
1232
+ /**
1233
+ * Report actual throughput
1234
+ */
1235
+ reportThroughput(opsPerSecond: number): void;
1236
+ /**
1237
+ * Get recommended batch size
1238
+ */
1239
+ getRecommendedBatchSize(): number;
1240
+ /**
1241
+ * Get adjustment count
1242
+ */
1243
+ getAdjustments(): number;
1244
+ }
1245
+ /**
1246
+ * Create a realtime tuner
1247
+ */
1248
+ declare function createRealtimeTuner(config?: Partial<RealtimeConfig>): RealtimeTuner;
1249
+ /**
1250
+ * Create a thread priority manager
1251
+ */
1252
+ declare function createThreadPriority(config?: Partial<RealtimeConfig>): ThreadPriority;
1253
+ /**
1254
+ * Create a latency monitor
1255
+ */
1256
+ declare function createLatencyMonitor(maxMeasurements?: number, bucketSize?: number): LatencyMonitor;
1257
+ /**
1258
+ * Create a performance governor
1259
+ */
1260
+ declare function createPerformanceGovernor(): PerformanceGovernor;
1261
+ /**
1262
+ * Measure function execution time
1263
+ */
1264
+ declare function measureTime<T>(fn: () => T): {
1265
+ result: T;
1266
+ elapsedUs: number;
1267
+ };
1268
+ /**
1269
+ * Create a high-resolution timer
1270
+ */
1271
+ declare function createTimer(): {
1272
+ start: () => void;
1273
+ elapsed: () => number;
1274
+ reset: () => void;
1275
+ };
1276
+
1277
+ /**
1278
+ * SIMD (Single Instruction Multiple Data) Module for Sol Trade SDK
1279
+ * Provides SIMD operations, detection, and crypto optimizations.
1280
+ */
1281
+ /**
1282
+ * SIMD configuration
1283
+ */
1284
+ interface SIMDConfig {
1285
+ /** Enable SIMD operations */
1286
+ enableSIMD: boolean;
1287
+ /** Preferred SIMD width (128, 256, 512) */
1288
+ preferredWidth: number;
1289
+ /** Enable WebAssembly SIMD */
1290
+ enableWasmSIMD: boolean;
1291
+ /** Fallback to scalar on failure */
1292
+ fallbackToScalar: boolean;
1293
+ }
1294
+ /**
1295
+ * Default SIMD configuration
1296
+ */
1297
+ declare function defaultSIMDConfig(): SIMDConfig;
1298
+ /**
1299
+ * SIMD capabilities
1300
+ */
1301
+ interface SIMDCapabilities {
1302
+ /** SSE support */
1303
+ sse: boolean;
1304
+ /** SSE2 support */
1305
+ sse2: boolean;
1306
+ /** SSE3 support */
1307
+ sse3: boolean;
1308
+ /** SSSE3 support */
1309
+ ssse3: boolean;
1310
+ /** SSE4.1 support */
1311
+ sse41: boolean;
1312
+ /** SSE4.2 support */
1313
+ sse42: boolean;
1314
+ /** AVX support */
1315
+ avx: boolean;
1316
+ /** AVX2 support */
1317
+ avx2: boolean;
1318
+ /** AVX-512 support */
1319
+ avx512: boolean;
1320
+ /** NEON support (ARM) */
1321
+ neon: boolean;
1322
+ /** WebAssembly SIMD128 support */
1323
+ wasmSimd128: boolean;
1324
+ }
1325
+ /**
1326
+ * Vector types
1327
+ */
1328
+ type Float32Vector = Float32Array;
1329
+ type Float64Vector = Float64Array;
1330
+ type Int32Vector = Int32Array;
1331
+ type Int64Vector = BigInt64Array;
1332
+ /**
1333
+ * Detects SIMD capabilities of the runtime environment.
1334
+ */
1335
+ declare class SIMDDetector {
1336
+ private capabilities;
1337
+ /**
1338
+ * Detect SIMD capabilities
1339
+ */
1340
+ detect(): SIMDCapabilities;
1341
+ /**
1342
+ * Check if WebAssembly SIMD128 is available
1343
+ */
1344
+ private detectWasmSIMD128;
1345
+ /**
1346
+ * Detect NEON support (ARM)
1347
+ */
1348
+ private detectNEON;
1349
+ /**
1350
+ * Check if specific capability is available
1351
+ */
1352
+ hasCapability(capability: keyof SIMDCapabilities): boolean;
1353
+ /**
1354
+ * Get optimal vector width
1355
+ */
1356
+ getOptimalWidth(): number;
1357
+ /**
1358
+ * Check if any SIMD is available
1359
+ */
1360
+ hasAnySIMD(): boolean;
1361
+ }
1362
+ /**
1363
+ * Vectorized mathematical operations using SIMD where available.
1364
+ */
1365
+ declare class VectorizedMath {
1366
+ private config;
1367
+ private detector;
1368
+ constructor(config?: SIMDConfig);
1369
+ /**
1370
+ * Vector addition: result = a + b
1371
+ */
1372
+ add(a: Float32Array, b: Float32Array, result?: Float32Array): Float32Array;
1373
+ /**
1374
+ * Vector subtraction: result = a - b
1375
+ */
1376
+ subtract(a: Float32Array, b: Float32Array, result?: Float32Array): Float32Array;
1377
+ /**
1378
+ * Vector multiplication: result = a * b
1379
+ */
1380
+ multiply(a: Float32Array, b: Float32Array, result?: Float32Array): Float32Array;
1381
+ /**
1382
+ * Vector division: result = a / b
1383
+ */
1384
+ divide(a: Float32Array, b: Float32Array, result?: Float32Array): Float32Array;
1385
+ /**
1386
+ * Vector dot product
1387
+ */
1388
+ dot(a: Float32Array, b: Float32Array): number;
1389
+ /**
1390
+ * Vector sum
1391
+ */
1392
+ sum(a: Float32Array): number;
1393
+ /**
1394
+ * Vector minimum
1395
+ */
1396
+ min(a: Float32Array): number;
1397
+ /**
1398
+ * Vector maximum
1399
+ */
1400
+ max(a: Float32Array): number;
1401
+ /**
1402
+ * Element-wise absolute value
1403
+ */
1404
+ abs(a: Float32Array, result?: Float32Array): Float32Array;
1405
+ /**
1406
+ * Element-wise square root
1407
+ */
1408
+ sqrt(a: Float32Array, result?: Float32Array): Float32Array;
1409
+ }
1410
+ /**
1411
+ * SIMD-optimized cryptographic operations.
1412
+ * Provides accelerated hashing and verification.
1413
+ */
1414
+ declare class CryptoSIMD {
1415
+ private config;
1416
+ private detector;
1417
+ constructor(config?: SIMDConfig);
1418
+ /**
1419
+ * XOR two byte arrays (SIMD-accelerated)
1420
+ */
1421
+ xor(a: Uint8Array, b: Uint8Array, result?: Uint8Array): Uint8Array;
1422
+ /**
1423
+ * Compare two byte arrays for equality (SIMD-accelerated)
1424
+ */
1425
+ equals(a: Uint8Array, b: Uint8Array): boolean;
1426
+ /**
1427
+ * Fill array with value (SIMD-accelerated)
1428
+ */
1429
+ fill(buffer: Uint8Array, value: number): void;
1430
+ /**
1431
+ * Copy bytes (SIMD-accelerated)
1432
+ */
1433
+ copy(src: Uint8Array, dst: Uint8Array, srcOffset?: number, dstOffset?: number, length?: number): void;
1434
+ /**
1435
+ * Compute parity of byte array
1436
+ */
1437
+ parity(data: Uint8Array): number;
1438
+ /**
1439
+ * Rotate bytes left
1440
+ */
1441
+ rotateLeft(data: Uint8Array, bits: number, result?: Uint8Array): Uint8Array;
1442
+ }
1443
+ /**
1444
+ * 128-bit SIMD vector (4 floats)
1445
+ */
1446
+ declare class Float32x4 {
1447
+ private data;
1448
+ constructor(x?: number, y?: number, z?: number, w?: number);
1449
+ static fromArray(arr: Float32Array, offset?: number): Float32x4;
1450
+ add(other: Float32x4): Float32x4;
1451
+ subtract(other: Float32x4): Float32x4;
1452
+ multiply(other: Float32x4): Float32x4;
1453
+ toArray(): Float32Array;
1454
+ get x(): number;
1455
+ get y(): number;
1456
+ get z(): number;
1457
+ get w(): number;
1458
+ }
1459
+ /**
1460
+ * Create a SIMD detector
1461
+ */
1462
+ declare function createSIMDDetector(): SIMDDetector;
1463
+ /**
1464
+ * Create a vectorized math instance
1465
+ */
1466
+ declare function createVectorizedMath(config?: Partial<SIMDConfig>): VectorizedMath;
1467
+ /**
1468
+ * Create a crypto SIMD instance
1469
+ */
1470
+ declare function createCryptoSIMD(config?: Partial<SIMDConfig>): CryptoSIMD;
1471
+ /**
1472
+ * Check if SIMD is available
1473
+ */
1474
+ declare function isSIMDAvailable(): boolean;
1475
+ /**
1476
+ * Get optimal SIMD width
1477
+ */
1478
+ declare function getOptimalSIMDWidth(): number;
1479
+
1480
+ /**
1481
+ * Syscall Bypass Module for Sol Trade SDK
1482
+ * Provides high-performance time and system call optimizations.
1483
+ */
1484
+ /**
1485
+ * Configuration for syscall bypass optimizations
1486
+ */
1487
+ interface SyscallBypassConfig {
1488
+ /** Enable fast time provider using cached time */
1489
+ enableFastTime: boolean;
1490
+ /** Time cache interval in microseconds */
1491
+ timeCacheIntervalUs: number;
1492
+ /** Enable syscall batching */
1493
+ enableBatching: boolean;
1494
+ /** Maximum batch size for syscalls */
1495
+ maxBatchSize: number;
1496
+ /** Enable vDSO (virtual dynamic shared object) time */
1497
+ useVdsoTime: boolean;
1498
+ }
1499
+ /**
1500
+ * Default syscall bypass configuration
1501
+ */
1502
+ declare function defaultSyscallBypassConfig(): SyscallBypassConfig;
1503
+ /**
1504
+ * High-performance time provider with caching to reduce syscalls.
1505
+ * Uses a background update mechanism to cache current time.
1506
+ */
1507
+ declare class FastTimeProvider {
1508
+ private cachedTimeNs;
1509
+ private cachedTimeMs;
1510
+ private lastUpdateNs;
1511
+ private updateIntervalNs;
1512
+ private running;
1513
+ private updateTimer;
1514
+ private useHighRes;
1515
+ constructor(updateIntervalUs?: number, useHighRes?: boolean);
1516
+ /**
1517
+ * Start the background time update loop
1518
+ */
1519
+ start(): void;
1520
+ /**
1521
+ * Stop the background time update loop
1522
+ */
1523
+ stop(): void;
1524
+ /**
1525
+ * Get cached time in nanoseconds (fast, no syscall)
1526
+ */
1527
+ nowNs(): bigint;
1528
+ /**
1529
+ * Get cached time in microseconds (fast, no syscall)
1530
+ */
1531
+ nowUs(): bigint;
1532
+ /**
1533
+ * Get cached time in milliseconds (fast, no syscall)
1534
+ */
1535
+ nowMs(): number;
1536
+ /**
1537
+ * Get precise time (may involve syscall)
1538
+ */
1539
+ preciseNowNs(): bigint;
1540
+ /**
1541
+ * Get precise time in microseconds
1542
+ */
1543
+ preciseNowUs(): bigint;
1544
+ private updateTime;
1545
+ }
1546
+ /**
1547
+ * Manages syscall bypass optimizations for high-frequency trading.
1548
+ * Reduces system call overhead through caching and batching.
1549
+ */
1550
+ declare class SyscallBypassManager {
1551
+ private config;
1552
+ private timeProvider;
1553
+ private syscallQueue;
1554
+ private batchTimer;
1555
+ private stats;
1556
+ constructor(config?: SyscallBypassConfig);
1557
+ /**
1558
+ * Initialize the syscall bypass manager
1559
+ */
1560
+ initialize(): void;
1561
+ /**
1562
+ * Shutdown the syscall bypass manager
1563
+ */
1564
+ shutdown(): void;
1565
+ /**
1566
+ * Get fast cached time in nanoseconds
1567
+ */
1568
+ fastTimeNs(): bigint;
1569
+ /**
1570
+ * Get fast cached time in microseconds
1571
+ */
1572
+ fastTimeUs(): bigint;
1573
+ /**
1574
+ * Get fast cached time in milliseconds
1575
+ */
1576
+ fastTimeMs(): number;
1577
+ /**
1578
+ * Queue a syscall for batching
1579
+ */
1580
+ queueSyscall(syscall: () => void): void;
1581
+ /**
1582
+ * Execute a function with syscall bypass timing
1583
+ */
1584
+ measure<T>(fn: () => T): {
1585
+ result: T;
1586
+ elapsedNs: bigint;
1587
+ };
1588
+ /**
1589
+ * Get syscall bypass statistics
1590
+ */
1591
+ getStats(): SyscallStats;
1592
+ /**
1593
+ * Reset statistics
1594
+ */
1595
+ resetStats(): void;
1596
+ private startBatching;
1597
+ private flushBatch;
1598
+ }
1599
+ /**
1600
+ * Syscall bypass statistics
1601
+ */
1602
+ interface SyscallStats {
1603
+ totalCalls: number;
1604
+ bypassedCalls: number;
1605
+ batchedCalls: number;
1606
+ timeSavedNs: bigint;
1607
+ bypassRate?: number;
1608
+ }
1609
+ /**
1610
+ * Create a new syscall bypass manager with default configuration
1611
+ */
1612
+ declare function createSyscallBypassManager(config?: Partial<SyscallBypassConfig>): SyscallBypassManager;
1613
+ /**
1614
+ * Get the global fast time provider (creates if needed)
1615
+ */
1616
+ declare function getGlobalTimeProvider(): FastTimeProvider;
1617
+ /**
1618
+ * Fast time access using global provider
1619
+ */
1620
+ declare function fastNowNs(): bigint;
1621
+ declare function fastNowUs(): bigint;
1622
+ declare function fastNowMs(): number;
1623
+
1624
+ /**
1625
+ * Ultra-Low Latency (ULL) Module for Sol Trade SDK
1626
+ * Provides memory pools, lock-free queues, and latency optimization.
1627
+ */
1628
+ /**
1629
+ * Configuration for ultra-low latency optimizations
1630
+ */
1631
+ interface UltraLowLatencyConfig {
1632
+ /** Memory pool size per object type */
1633
+ memoryPoolSize: number;
1634
+ /** Lock-free queue capacity */
1635
+ queueCapacity: number;
1636
+ /** Enable busy spinning instead of yielding */
1637
+ enableBusySpin: boolean;
1638
+ /** Spin count before yielding */
1639
+ spinCount: number;
1640
+ /** Enable memory prefetching */
1641
+ enablePrefetch: boolean;
1642
+ /** NUMA-aware memory allocation */
1643
+ numaAware: boolean;
1644
+ }
1645
+ /**
1646
+ * Default ULL configuration
1647
+ */
1648
+ declare function defaultUltraLowLatencyConfig(): UltraLowLatencyConfig;
1649
+ /**
1650
+ * Latency statistics
1651
+ */
1652
+ interface LatencyStats {
1653
+ minLatencyUs: number;
1654
+ maxLatencyUs: number;
1655
+ avgLatencyUs: number;
1656
+ p50LatencyUs: number;
1657
+ p99LatencyUs: number;
1658
+ p999LatencyUs: number;
1659
+ totalOperations: number;
1660
+ }
1661
+ /**
1662
+ * High-performance memory pool for object reuse.
1663
+ * Reduces GC pressure and allocation latency.
1664
+ */
1665
+ declare class MemoryPool<T> {
1666
+ private pool;
1667
+ private factory;
1668
+ private resetFn;
1669
+ private maxSize;
1670
+ private leased;
1671
+ constructor(factory: () => T, resetFn: (obj: T) => void, maxSize?: number);
1672
+ /**
1673
+ * Acquire an object from the pool
1674
+ */
1675
+ acquire(): T;
1676
+ /**
1677
+ * Release an object back to the pool
1678
+ */
1679
+ release(obj: T): void;
1680
+ /**
1681
+ * Execute a function with a pooled object
1682
+ */
1683
+ with<R>(fn: (obj: T) => R): R;
1684
+ /**
1685
+ * Get pool statistics
1686
+ */
1687
+ getStats(): {
1688
+ available: number;
1689
+ inUse: number;
1690
+ total: number;
1691
+ };
1692
+ }
1693
+ /**
1694
+ * Lock-free circular buffer queue for single-producer single-consumer scenarios.
1695
+ * Uses atomic operations for synchronization.
1696
+ */
1697
+ declare class LockFreeQueue<T> {
1698
+ private buffer;
1699
+ private capacity;
1700
+ private mask;
1701
+ private head;
1702
+ private tail;
1703
+ private config;
1704
+ constructor(capacity?: number, config?: UltraLowLatencyConfig);
1705
+ /**
1706
+ * Enqueue an item (producer only)
1707
+ */
1708
+ enqueue(item: T): boolean;
1709
+ /**
1710
+ * Dequeue an item (consumer only)
1711
+ */
1712
+ dequeue(): T | undefined;
1713
+ /**
1714
+ * Try dequeue with spinning
1715
+ */
1716
+ dequeueSpin(timeoutUs?: number): T | undefined;
1717
+ /**
1718
+ * Get current size
1719
+ */
1720
+ size(): number;
1721
+ /**
1722
+ * Check if empty
1723
+ */
1724
+ isEmpty(): boolean;
1725
+ /**
1726
+ * Check if full
1727
+ */
1728
+ isFull(): boolean;
1729
+ /**
1730
+ * Clear the queue
1731
+ */
1732
+ clear(): void;
1733
+ }
1734
+ /**
1735
+ * Thread-safe queue supporting multiple producers and consumers.
1736
+ * Uses compare-and-swap for atomic operations.
1737
+ */
1738
+ declare class MPMCQueue<T> {
1739
+ private buffer;
1740
+ private capacity;
1741
+ private mask;
1742
+ private enqueuePos;
1743
+ private dequeuePos;
1744
+ constructor(capacity?: number);
1745
+ /**
1746
+ * Enqueue an item (thread-safe)
1747
+ */
1748
+ enqueue(item: T): boolean;
1749
+ /**
1750
+ * Dequeue an item (thread-safe)
1751
+ */
1752
+ dequeue(): T | undefined;
1753
+ private compareAndSwapEnqueuePos;
1754
+ private compareAndSwapDequeuePos;
1755
+ }
1756
+ /**
1757
+ * Latency optimizer for trading operations.
1758
+ * Provides latency measurement, optimization, and reporting.
1759
+ */
1760
+ declare class LatencyOptimizer {
1761
+ private latencies;
1762
+ private maxSamples;
1763
+ private config;
1764
+ private optimizationCallbacks;
1765
+ constructor(maxSamples?: number, config?: UltraLowLatencyConfig);
1766
+ /**
1767
+ * Record a latency measurement
1768
+ */
1769
+ recordLatency(latencyUs: number): void;
1770
+ /**
1771
+ * Measure and record function execution time
1772
+ */
1773
+ measure<T>(fn: () => T): {
1774
+ result: T;
1775
+ latencyUs: number;
1776
+ };
1777
+ /**
1778
+ * Get latency statistics
1779
+ */
1780
+ getStats(): LatencyStats;
1781
+ /**
1782
+ * Register an optimization callback
1783
+ */
1784
+ onOptimization(callback: () => void): void;
1785
+ /**
1786
+ * Trigger optimization
1787
+ */
1788
+ optimize(): void;
1789
+ /**
1790
+ * Reset statistics
1791
+ */
1792
+ reset(): void;
1793
+ }
1794
+ /**
1795
+ * Software prefetch hint (no-op in JS, but documents intent)
1796
+ */
1797
+ declare function prefetch<T>(obj: T): void;
1798
+ /**
1799
+ * Prefetch an array element
1800
+ */
1801
+ declare function prefetchArray<T>(arr: T[], index: number): void;
1802
+ /**
1803
+ * Create a memory pool with default configuration
1804
+ */
1805
+ declare function createMemoryPool<T>(factory: () => T, resetFn: (obj: T) => void, size?: number): MemoryPool<T>;
1806
+ /**
1807
+ * Create a lock-free queue
1808
+ */
1809
+ declare function createLockFreeQueue<T>(capacity?: number): LockFreeQueue<T>;
1810
+ /**
1811
+ * Create an MPMC queue
1812
+ */
1813
+ declare function createMPMCQueue<T>(capacity?: number): MPMCQueue<T>;
1814
+ /**
1815
+ * Busy spin for a number of iterations
1816
+ */
1817
+ declare function busySpin(iterations: number): void;
1818
+ /**
1819
+ * Yield to event loop
1820
+ */
1821
+ declare function yieldToEventLoop(): Promise<void>;
1822
+
1823
+ /**
1824
+ * Zero-Copy Module for Sol Trade SDK
1825
+ * Provides zero-copy buffer operations and serialization.
1826
+ */
1827
+ /**
1828
+ * Buffer view with zero-copy semantics
1829
+ */
1830
+ interface BufferView {
1831
+ buffer: ArrayBuffer;
1832
+ byteOffset: number;
1833
+ byteLength: number;
1834
+ }
1835
+ /**
1836
+ * Serializable interface for zero-copy operations
1837
+ */
1838
+ interface ZeroCopySerializable {
1839
+ serialize(): Uint8Array;
1840
+ deserialize(data: Uint8Array): void;
1841
+ serializedSize(): number;
1842
+ }
1843
+ /**
1844
+ * Buffer pool configuration
1845
+ */
1846
+ interface BufferPoolConfig {
1847
+ /** Buffer size in bytes */
1848
+ bufferSize: number;
1849
+ /** Number of buffers in pool */
1850
+ poolSize: number;
1851
+ /** Enable automatic expansion */
1852
+ autoExpand: boolean;
1853
+ /** Maximum pool size */
1854
+ maxPoolSize: number;
1855
+ }
1856
+ /**
1857
+ * Default buffer pool configuration
1858
+ */
1859
+ declare function defaultBufferPoolConfig(): BufferPoolConfig;
1860
+ /**
1861
+ * Zero-copy buffer with view semantics.
1862
+ * Allows multiple views into the same underlying buffer without copying.
1863
+ */
1864
+ declare class ZeroCopyBuffer {
1865
+ private buffer;
1866
+ private view;
1867
+ private uint8View;
1868
+ private offset;
1869
+ constructor(size?: number);
1870
+ /**
1871
+ * Create from existing buffer (zero-copy)
1872
+ */
1873
+ static from(buffer: ArrayBuffer): ZeroCopyBuffer;
1874
+ /**
1875
+ * Create a view into this buffer without copying
1876
+ */
1877
+ slice(start: number, end: number): Uint8Array;
1878
+ /**
1879
+ * Get current write offset
1880
+ */
1881
+ getOffset(): number;
1882
+ /**
1883
+ * Set write offset
1884
+ */
1885
+ setOffset(offset: number): void;
1886
+ /**
1887
+ * Get buffer capacity
1888
+ */
1889
+ capacity(): number;
1890
+ /**
1891
+ * Write Uint8 at current offset
1892
+ */
1893
+ writeUint8(value: number): void;
1894
+ /**
1895
+ * Write Uint16 at current offset (little-endian)
1896
+ */
1897
+ writeUint16(value: number): void;
1898
+ /**
1899
+ * Write Uint32 at current offset (little-endian)
1900
+ */
1901
+ writeUint32(value: number): void;
1902
+ /**
1903
+ * Write BigUint64 at current offset (little-endian)
1904
+ */
1905
+ writeUint64(value: bigint): void;
1906
+ /**
1907
+ * Write bytes at current offset
1908
+ */
1909
+ writeBytes(bytes: Uint8Array): void;
1910
+ /**
1911
+ * Read Uint8 at offset
1912
+ */
1913
+ readUint8(offset: number): number;
1914
+ /**
1915
+ * Read Uint16 at offset (little-endian)
1916
+ */
1917
+ readUint16(offset: number): number;
1918
+ /**
1919
+ * Read Uint32 at offset (little-endian)
1920
+ */
1921
+ readUint32(offset: number): number;
1922
+ /**
1923
+ * Read BigUint64 at offset (little-endian)
1924
+ */
1925
+ readUint64(offset: number): bigint;
1926
+ /**
1927
+ * Read bytes at offset
1928
+ */
1929
+ readBytes(offset: number, length: number): Uint8Array;
1930
+ /**
1931
+ * Get the underlying ArrayBuffer
1932
+ */
1933
+ getBuffer(): ArrayBuffer;
1934
+ /**
1935
+ * Get as Uint8Array (full buffer)
1936
+ */
1937
+ asUint8Array(): Uint8Array;
1938
+ /**
1939
+ * Get used portion as Uint8Array (zero-copy view)
1940
+ */
1941
+ asUsedUint8Array(): Uint8Array;
1942
+ /**
1943
+ * Reset offset to beginning
1944
+ */
1945
+ reset(): void;
1946
+ /**
1947
+ * Ensure capacity (creates new buffer if needed, copies data)
1948
+ */
1949
+ ensureCapacity(minCapacity: number): void;
1950
+ }
1951
+ /**
1952
+ * High-performance buffer pool for zero-copy operations.
1953
+ * Reduces allocation overhead by reusing buffers.
1954
+ */
1955
+ declare class BufferPool {
1956
+ private pool;
1957
+ private inUse;
1958
+ private config;
1959
+ constructor(config?: BufferPoolConfig);
1960
+ /**
1961
+ * Acquire a buffer from the pool
1962
+ */
1963
+ acquire(): ArrayBuffer;
1964
+ /**
1965
+ * Acquire a ZeroCopyBuffer wrapper
1966
+ */
1967
+ acquireZeroCopyBuffer(): ZeroCopyBuffer;
1968
+ /**
1969
+ * Release a buffer back to the pool
1970
+ */
1971
+ release(buffer: ArrayBuffer): void;
1972
+ /**
1973
+ * Execute a function with a pooled buffer
1974
+ */
1975
+ with<T>(fn: (buffer: ArrayBuffer) => T): T;
1976
+ /**
1977
+ * Get pool statistics
1978
+ */
1979
+ getStats(): {
1980
+ available: number;
1981
+ inUse: number;
1982
+ total: number;
1983
+ };
1984
+ /**
1985
+ * Clear all buffers
1986
+ */
1987
+ clear(): void;
1988
+ }
1989
+ /**
1990
+ * High-performance serializer with zero-copy semantics.
1991
+ * Minimizes memory copies during serialization/deserialization.
1992
+ */
1993
+ declare class ZeroCopySerializer {
1994
+ private buffer;
1995
+ private textEncoder;
1996
+ private textDecoder;
1997
+ constructor(initialSize?: number);
1998
+ /**
1999
+ * Serialize a string (length-prefixed)
2000
+ */
2001
+ writeString(value: string): void;
2002
+ /**
2003
+ * Serialize a PublicKey (32 bytes)
2004
+ */
2005
+ writePublicKey(bytes: Uint8Array): void;
2006
+ /**
2007
+ * Serialize a BigInt (8 bytes)
2008
+ */
2009
+ writeBigInt(value: bigint): void;
2010
+ /**
2011
+ * Serialize a number (4 bytes)
2012
+ */
2013
+ writeNumber(value: number): void;
2014
+ /**
2015
+ * Serialize a boolean (1 byte)
2016
+ */
2017
+ writeBoolean(value: boolean): void;
2018
+ /**
2019
+ * Serialize bytes with length prefix
2020
+ */
2021
+ writeByteArray(bytes: Uint8Array): void;
2022
+ /**
2023
+ * Deserialize a string
2024
+ */
2025
+ readString(offset: number): {
2026
+ value: string;
2027
+ nextOffset: number;
2028
+ };
2029
+ /**
2030
+ * Deserialize a PublicKey
2031
+ */
2032
+ readPublicKey(offset: number): {
2033
+ value: Uint8Array;
2034
+ nextOffset: number;
2035
+ };
2036
+ /**
2037
+ * Deserialize a BigInt
2038
+ */
2039
+ readBigInt(offset: number): {
2040
+ value: bigint;
2041
+ nextOffset: number;
2042
+ };
2043
+ /**
2044
+ * Deserialize a number
2045
+ */
2046
+ readNumber(offset: number): {
2047
+ value: number;
2048
+ nextOffset: number;
2049
+ };
2050
+ /**
2051
+ * Deserialize a boolean
2052
+ */
2053
+ readBoolean(offset: number): {
2054
+ value: boolean;
2055
+ nextOffset: number;
2056
+ };
2057
+ /**
2058
+ * Deserialize a byte array
2059
+ */
2060
+ readByteArray(offset: number): {
2061
+ value: Uint8Array;
2062
+ nextOffset: number;
2063
+ };
2064
+ /**
2065
+ * Get serialized data as Uint8Array (zero-copy view)
2066
+ */
2067
+ getData(): Uint8Array;
2068
+ /**
2069
+ * Reset for reuse
2070
+ */
2071
+ reset(): void;
2072
+ /**
2073
+ * Get current offset
2074
+ */
2075
+ getOffset(): number;
2076
+ }
2077
+ /**
2078
+ * Fixed-size view into a buffer for predictable memory layout.
2079
+ * Useful for structures with known sizes.
2080
+ */
2081
+ declare class FixedBufferView {
2082
+ private buffer;
2083
+ private view;
2084
+ private uint8View;
2085
+ private baseOffset;
2086
+ constructor(buffer: ArrayBuffer, offset: number, size: number);
2087
+ /**
2088
+ * Get Uint8 at relative offset
2089
+ */
2090
+ getUint8(offset: number): number;
2091
+ /**
2092
+ * Set Uint8 at relative offset
2093
+ */
2094
+ setUint8(offset: number, value: number): void;
2095
+ /**
2096
+ * Get Uint32 at relative offset
2097
+ */
2098
+ getUint32(offset: number): number;
2099
+ /**
2100
+ * Set Uint32 at relative offset
2101
+ */
2102
+ setUint32(offset: number, value: number): void;
2103
+ /**
2104
+ * Get BigUint64 at relative offset
2105
+ */
2106
+ getUint64(offset: number): bigint;
2107
+ /**
2108
+ * Set BigUint64 at relative offset
2109
+ */
2110
+ setUint64(offset: number, value: bigint): void;
2111
+ /**
2112
+ * Get bytes at relative offset
2113
+ */
2114
+ getBytes(offset: number, length: number): Uint8Array;
2115
+ /**
2116
+ * Set bytes at relative offset
2117
+ */
2118
+ setBytes(offset: number, bytes: Uint8Array): void;
2119
+ /**
2120
+ * Get the underlying ArrayBuffer
2121
+ */
2122
+ getBuffer(): ArrayBuffer;
2123
+ /**
2124
+ * Get the base offset
2125
+ */
2126
+ getBaseOffset(): number;
2127
+ }
2128
+ /**
2129
+ * Create a buffer pool with default configuration
2130
+ */
2131
+ declare function createBufferPool(config?: Partial<BufferPoolConfig>): BufferPool;
2132
+ /**
2133
+ * Create a zero-copy buffer
2134
+ */
2135
+ declare function createZeroCopyBuffer(size?: number): ZeroCopyBuffer;
2136
+ /**
2137
+ * Create a zero-copy serializer
2138
+ */
2139
+ declare function createSerializer(initialSize?: number): ZeroCopySerializer;
2140
+ /**
2141
+ * Copy bytes without allocation (if possible)
2142
+ */
2143
+ declare function copyBytes(src: Uint8Array, dst: Uint8Array, dstOffset?: number): void;
2144
+ /**
2145
+ * Create a zero-copy view of a buffer
2146
+ */
2147
+ declare function createView(buffer: ArrayBuffer, offset: number, length: number): Uint8Array;
2148
+
2149
+ type index_AffinityConfig = AffinityConfig;
2150
+ type index_AlignedBuffer = AlignedBuffer;
2151
+ declare const index_AlignedBuffer: typeof AlignedBuffer;
2152
+ type index_AsyncSocket = AsyncSocket;
2153
+ declare const index_AsyncSocket: typeof AsyncSocket;
2154
+ type index_BranchOptimizer = BranchOptimizer;
2155
+ declare const index_BranchOptimizer: typeof BranchOptimizer;
2156
+ type index_BufferPool = BufferPool;
2157
+ declare const index_BufferPool: typeof BufferPool;
2158
+ type index_BufferPoolConfig = BufferPoolConfig;
2159
+ type index_BufferView = BufferView;
2160
+ declare const index_CACHE_LINE_SIZE: typeof CACHE_LINE_SIZE;
2161
+ type index_CPUAffinity = CPUAffinity;
2162
+ declare const index_CPUAffinity: typeof CPUAffinity;
2163
+ type index_CPUFeatures = CPUFeatures;
2164
+ type index_CPUTopology = CPUTopology;
2165
+ type index_CacheInfo = CacheInfo;
2166
+ type index_CacheOptimizer = CacheOptimizer;
2167
+ declare const index_CacheOptimizer: typeof CacheOptimizer;
2168
+ type index_ComputeBudgetOptimizer = ComputeBudgetOptimizer;
2169
+ declare const index_ComputeBudgetOptimizer: typeof ComputeBudgetOptimizer;
2170
+ type index_ComputeBudgetStats = ComputeBudgetStats;
2171
+ type index_CryptoSIMD = CryptoSIMD;
2172
+ declare const index_CryptoSIMD: typeof CryptoSIMD;
2173
+ type index_DirectIOFile = DirectIOFile;
2174
+ declare const index_DirectIOFile: typeof DirectIOFile;
2175
+ type index_FastTimeProvider = FastTimeProvider;
2176
+ declare const index_FastTimeProvider: typeof FastTimeProvider;
2177
+ type index_FixedBufferView = FixedBufferView;
2178
+ declare const index_FixedBufferView: typeof FixedBufferView;
2179
+ type index_Float32Vector = Float32Vector;
2180
+ type index_Float32x4 = Float32x4;
2181
+ declare const index_Float32x4: typeof Float32x4;
2182
+ type index_Float64Vector = Float64Vector;
2183
+ type index_FuncCache<T> = FuncCache<T>;
2184
+ declare const index_FuncCache: typeof FuncCache;
2185
+ type index_HardwareMonitor = HardwareMonitor;
2186
+ declare const index_HardwareMonitor: typeof HardwareMonitor;
2187
+ type index_IOBatchProcessor = IOBatchProcessor;
2188
+ declare const index_IOBatchProcessor: typeof IOBatchProcessor;
2189
+ type index_IOOperation = IOOperation;
2190
+ declare const index_IOOperation: typeof IOOperation;
2191
+ type index_IORequest = IORequest;
2192
+ type index_IOResult = IOResult;
2193
+ type index_IOUringConfig = IOUringConfig;
2194
+ type index_InstructionBatcher = InstructionBatcher;
2195
+ declare const index_InstructionBatcher: typeof InstructionBatcher;
2196
+ type index_InstructionGroup = InstructionGroup;
2197
+ type index_Int32Vector = Int32Vector;
2198
+ type index_Int64Vector = Int64Vector;
2199
+ type index_JITConfig = JITConfig;
2200
+ type index_KernelBypassManager = KernelBypassManager;
2201
+ declare const index_KernelBypassManager: typeof KernelBypassManager;
2202
+ type index_LatencyMonitor = LatencyMonitor;
2203
+ declare const index_LatencyMonitor: typeof LatencyMonitor;
2204
+ type index_LatencyOptimizer = LatencyOptimizer;
2205
+ declare const index_LatencyOptimizer: typeof LatencyOptimizer;
2206
+ type index_LatencyStats = LatencyStats;
2207
+ type index_LockFreeQueue<T> = LockFreeQueue<T>;
2208
+ declare const index_LockFreeQueue: typeof LockFreeQueue;
2209
+ type index_LoopOptimizer = LoopOptimizer;
2210
+ declare const index_LoopOptimizer: typeof LoopOptimizer;
2211
+ type index_MPMCQueue<T> = MPMCQueue<T>;
2212
+ declare const index_MPMCQueue: typeof MPMCQueue;
2213
+ type index_MemoryMappedFile = MemoryMappedFile;
2214
+ declare const index_MemoryMappedFile: typeof MemoryMappedFile;
2215
+ type index_MemoryOps = MemoryOps;
2216
+ declare const index_MemoryOps: typeof MemoryOps;
2217
+ type index_MemoryPool<T> = MemoryPool<T>;
2218
+ declare const index_MemoryPool: typeof MemoryPool;
2219
+ type index_NUMAConfig = NUMAConfig;
2220
+ type index_NUMAOptimizer = NUMAOptimizer;
2221
+ declare const index_NUMAOptimizer: typeof NUMAOptimizer;
2222
+ type index_OptimizationResult = OptimizationResult;
2223
+ type index_OptimizedMath = OptimizedMath;
2224
+ declare const index_OptimizedMath: typeof OptimizedMath;
2225
+ type index_PerformanceGovernor = PerformanceGovernor;
2226
+ declare const index_PerformanceGovernor: typeof PerformanceGovernor;
2227
+ type index_ProfileGuidedOptimizer = ProfileGuidedOptimizer;
2228
+ declare const index_ProfileGuidedOptimizer: typeof ProfileGuidedOptimizer;
2229
+ type index_RealtimeConfig = RealtimeConfig;
2230
+ type index_RealtimeTuner = RealtimeTuner;
2231
+ declare const index_RealtimeTuner: typeof RealtimeTuner;
2232
+ type index_SIMDCapabilities = SIMDCapabilities;
2233
+ type index_SIMDConfig = SIMDConfig;
2234
+ type index_SIMDDetector = SIMDDetector;
2235
+ declare const index_SIMDDetector: typeof SIMDDetector;
2236
+ type index_SchedulerPolicy = SchedulerPolicy;
2237
+ declare const index_SchedulerPolicy: typeof SchedulerPolicy;
2238
+ type index_SpinLock = SpinLock;
2239
+ declare const index_SpinLock: typeof SpinLock;
2240
+ type index_SyscallBypassConfig = SyscallBypassConfig;
2241
+ type index_SyscallBypassManager = SyscallBypassManager;
2242
+ declare const index_SyscallBypassManager: typeof SyscallBypassManager;
2243
+ type index_ThreadPriority = ThreadPriority;
2244
+ declare const index_ThreadPriority: typeof ThreadPriority;
2245
+ type index_ThreadPriorityLevel = ThreadPriorityLevel;
2246
+ declare const index_ThreadPriorityLevel: typeof ThreadPriorityLevel;
2247
+ type index_TransactionBuilder = TransactionBuilder;
2248
+ declare const index_TransactionBuilder: typeof TransactionBuilder;
2249
+ type index_TransactionConfig = TransactionConfig;
2250
+ type index_TransactionOptimizer = TransactionOptimizer;
2251
+ declare const index_TransactionOptimizer: typeof TransactionOptimizer;
2252
+ type index_TuningStats = TuningStats;
2253
+ type index_UltraLowLatencyConfig = UltraLowLatencyConfig;
2254
+ type index_VectorizedMath = VectorizedMath;
2255
+ declare const index_VectorizedMath: typeof VectorizedMath;
2256
+ type index_ZeroCopyBuffer = ZeroCopyBuffer;
2257
+ declare const index_ZeroCopyBuffer: typeof ZeroCopyBuffer;
2258
+ type index_ZeroCopySerializable = ZeroCopySerializable;
2259
+ type index_ZeroCopySerializer = ZeroCopySerializer;
2260
+ declare const index_ZeroCopySerializer: typeof ZeroCopySerializer;
2261
+ declare const index_busySpin: typeof busySpin;
2262
+ declare const index_busyWait: typeof busyWait;
2263
+ declare const index_calculateOptimalPrice: typeof calculateOptimalPrice;
2264
+ declare const index_coldPath: typeof coldPath;
2265
+ declare const index_copyBytes: typeof copyBytes;
2266
+ declare const index_createBufferPool: typeof createBufferPool;
2267
+ declare const index_createCPUAffinity: typeof createCPUAffinity;
2268
+ declare const index_createCacheOptimizer: typeof createCacheOptimizer;
2269
+ declare const index_createComputeBudgetOptimizer: typeof createComputeBudgetOptimizer;
2270
+ declare const index_createCryptoSIMD: typeof createCryptoSIMD;
2271
+ declare const index_createHardwareMonitor: typeof createHardwareMonitor;
2272
+ declare const index_createInstructionBatcher: typeof createInstructionBatcher;
2273
+ declare const index_createLatencyMonitor: typeof createLatencyMonitor;
2274
+ declare const index_createLockFreeQueue: typeof createLockFreeQueue;
2275
+ declare const index_createMPMCQueue: typeof createMPMCQueue;
2276
+ declare const index_createMemoryPool: typeof createMemoryPool;
2277
+ declare const index_createNUMAOptimizer: typeof createNUMAOptimizer;
2278
+ declare const index_createPerformanceGovernor: typeof createPerformanceGovernor;
2279
+ declare const index_createRealtimeTuner: typeof createRealtimeTuner;
2280
+ declare const index_createSIMDDetector: typeof createSIMDDetector;
2281
+ declare const index_createSerializer: typeof createSerializer;
2282
+ declare const index_createSyscallBypassManager: typeof createSyscallBypassManager;
2283
+ declare const index_createThreadPriority: typeof createThreadPriority;
2284
+ declare const index_createTimer: typeof createTimer;
2285
+ declare const index_createTransactionBuilder: typeof createTransactionBuilder;
2286
+ declare const index_createTransactionOptimizer: typeof createTransactionOptimizer;
2287
+ declare const index_createVectorizedMath: typeof createVectorizedMath;
2288
+ declare const index_createView: typeof createView;
2289
+ declare const index_createZeroCopyBuffer: typeof createZeroCopyBuffer;
2290
+ declare const index_defaultAffinityConfig: typeof defaultAffinityConfig;
2291
+ declare const index_defaultBufferPoolConfig: typeof defaultBufferPoolConfig;
2292
+ declare const index_defaultIOUringConfig: typeof defaultIOUringConfig;
2293
+ declare const index_defaultJITConfig: typeof defaultJITConfig;
2294
+ declare const index_defaultNUMAConfig: typeof defaultNUMAConfig;
2295
+ declare const index_defaultRealtimeConfig: typeof defaultRealtimeConfig;
2296
+ declare const index_defaultSIMDConfig: typeof defaultSIMDConfig;
2297
+ declare const index_defaultSyscallBypassConfig: typeof defaultSyscallBypassConfig;
2298
+ declare const index_defaultTransactionConfig: typeof defaultTransactionConfig;
2299
+ declare const index_defaultUltraLowLatencyConfig: typeof defaultUltraLowLatencyConfig;
2300
+ declare const index_detectCPUFeatures: typeof detectCPUFeatures;
2301
+ declare const index_estimateCompute: typeof estimateCompute;
2302
+ declare const index_fastInvSqrt: typeof fastInvSqrt;
2303
+ declare const index_fastNowMs: typeof fastNowMs;
2304
+ declare const index_fastNowNs: typeof fastNowNs;
2305
+ declare const index_fastNowUs: typeof fastNowUs;
2306
+ declare const index_getGlobalTimeProvider: typeof getGlobalTimeProvider;
2307
+ declare const index_getKernelBypassManager: typeof getKernelBypassManager;
2308
+ declare const index_getOptimalSIMDWidth: typeof getOptimalSIMDWidth;
2309
+ declare const index_getProfileOptimizer: typeof getProfileOptimizer;
2310
+ declare const index_getSystemCPUInfo: typeof getSystemCPUInfo;
2311
+ declare const index_getSystemMemoryInfo: typeof getSystemMemoryInfo;
2312
+ declare const index_hotPath: typeof hotPath;
2313
+ declare const index_isSIMDAvailable: typeof isSIMDAvailable;
2314
+ declare const index_likely: typeof likely;
2315
+ declare const index_measureTime: typeof measureTime;
2316
+ declare const index_prefetch: typeof prefetch;
2317
+ declare const index_prefetchArray: typeof prefetchArray;
2318
+ declare const index_prefetchHint: typeof prefetchHint;
2319
+ declare const index_profile: typeof profile;
2320
+ declare const index_spinLock: typeof spinLock;
2321
+ declare const index_unlikely: typeof unlikely;
2322
+ declare const index_yieldToEventLoop: typeof yieldToEventLoop;
2323
+ declare namespace index {
2324
+ export { type index_AffinityConfig as AffinityConfig, index_AlignedBuffer as AlignedBuffer, index_AsyncSocket as AsyncSocket, index_BranchOptimizer as BranchOptimizer, index_BufferPool as BufferPool, type index_BufferPoolConfig as BufferPoolConfig, type index_BufferView as BufferView, index_CACHE_LINE_SIZE as CACHE_LINE_SIZE, index_CPUAffinity as CPUAffinity, type index_CPUFeatures as CPUFeatures, type index_CPUTopology as CPUTopology, type index_CacheInfo as CacheInfo, index_CacheOptimizer as CacheOptimizer, index_ComputeBudgetOptimizer as ComputeBudgetOptimizer, type index_ComputeBudgetStats as ComputeBudgetStats, index_CryptoSIMD as CryptoSIMD, index_DirectIOFile as DirectIOFile, index_FastTimeProvider as FastTimeProvider, index_FixedBufferView as FixedBufferView, type index_Float32Vector as Float32Vector, index_Float32x4 as Float32x4, type index_Float64Vector as Float64Vector, index_FuncCache as FuncCache, index_HardwareMonitor as HardwareMonitor, index_IOBatchProcessor as IOBatchProcessor, index_IOOperation as IOOperation, type index_IORequest as IORequest, type index_IOResult as IOResult, type index_IOUringConfig as IOUringConfig, index_InstructionBatcher as InstructionBatcher, type index_InstructionGroup as InstructionGroup, type index_Int32Vector as Int32Vector, type index_Int64Vector as Int64Vector, type index_JITConfig as JITConfig, index_KernelBypassManager as KernelBypassManager, index_LatencyMonitor as LatencyMonitor, index_LatencyOptimizer as LatencyOptimizer, type index_LatencyStats as LatencyStats, index_LockFreeQueue as LockFreeQueue, index_LoopOptimizer as LoopOptimizer, index_MPMCQueue as MPMCQueue, index_MemoryMappedFile as MemoryMappedFile, index_MemoryOps as MemoryOps, index_MemoryPool as MemoryPool, type index_NUMAConfig as NUMAConfig, index_NUMAOptimizer as NUMAOptimizer, type index_OptimizationResult as OptimizationResult, index_OptimizedMath as OptimizedMath, index_PerformanceGovernor as PerformanceGovernor, index_ProfileGuidedOptimizer as ProfileGuidedOptimizer, type index_RealtimeConfig as RealtimeConfig, index_RealtimeTuner as RealtimeTuner, type index_SIMDCapabilities as SIMDCapabilities, type index_SIMDConfig as SIMDConfig, index_SIMDDetector as SIMDDetector, index_SchedulerPolicy as SchedulerPolicy, index_SpinLock as SpinLock, type index_SyscallBypassConfig as SyscallBypassConfig, index_SyscallBypassManager as SyscallBypassManager, index_ThreadPriority as ThreadPriority, index_ThreadPriorityLevel as ThreadPriorityLevel, index_TransactionBuilder as TransactionBuilder, type index_TransactionConfig as TransactionConfig, index_TransactionOptimizer as TransactionOptimizer, type index_TuningStats as TuningStats, type index_UltraLowLatencyConfig as UltraLowLatencyConfig, index_VectorizedMath as VectorizedMath, index_ZeroCopyBuffer as ZeroCopyBuffer, type index_ZeroCopySerializable as ZeroCopySerializable, index_ZeroCopySerializer as ZeroCopySerializer, index_busySpin as busySpin, index_busyWait as busyWait, index_calculateOptimalPrice as calculateOptimalPrice, index_coldPath as coldPath, index_copyBytes as copyBytes, index_createBufferPool as createBufferPool, index_createCPUAffinity as createCPUAffinity, index_createCacheOptimizer as createCacheOptimizer, index_createComputeBudgetOptimizer as createComputeBudgetOptimizer, index_createCryptoSIMD as createCryptoSIMD, index_createHardwareMonitor as createHardwareMonitor, index_createInstructionBatcher as createInstructionBatcher, index_createLatencyMonitor as createLatencyMonitor, index_createLockFreeQueue as createLockFreeQueue, index_createMPMCQueue as createMPMCQueue, index_createMemoryPool as createMemoryPool, index_createNUMAOptimizer as createNUMAOptimizer, index_createPerformanceGovernor as createPerformanceGovernor, index_createRealtimeTuner as createRealtimeTuner, index_createSIMDDetector as createSIMDDetector, index_createSerializer as createSerializer, index_createSyscallBypassManager as createSyscallBypassManager, index_createThreadPriority as createThreadPriority, index_createTimer as createTimer, index_createTransactionBuilder as createTransactionBuilder, index_createTransactionOptimizer as createTransactionOptimizer, index_createVectorizedMath as createVectorizedMath, index_createView as createView, index_createZeroCopyBuffer as createZeroCopyBuffer, index_defaultAffinityConfig as defaultAffinityConfig, index_defaultBufferPoolConfig as defaultBufferPoolConfig, index_defaultIOUringConfig as defaultIOUringConfig, index_defaultJITConfig as defaultJITConfig, index_defaultNUMAConfig as defaultNUMAConfig, index_defaultRealtimeConfig as defaultRealtimeConfig, index_defaultSIMDConfig as defaultSIMDConfig, index_defaultSyscallBypassConfig as defaultSyscallBypassConfig, index_defaultTransactionConfig as defaultTransactionConfig, index_defaultUltraLowLatencyConfig as defaultUltraLowLatencyConfig, index_detectCPUFeatures as detectCPUFeatures, index_estimateCompute as estimateCompute, index_fastInvSqrt as fastInvSqrt, index_fastNowMs as fastNowMs, index_fastNowNs as fastNowNs, index_fastNowUs as fastNowUs, index_getGlobalTimeProvider as getGlobalTimeProvider, index_getKernelBypassManager as getKernelBypassManager, index_getOptimalSIMDWidth as getOptimalSIMDWidth, index_getProfileOptimizer as getProfileOptimizer, index_getSystemCPUInfo as getSystemCPUInfo, index_getSystemMemoryInfo as getSystemMemoryInfo, index_hotPath as hotPath, index_isSIMDAvailable as isSIMDAvailable, index_likely as likely, index_measureTime as measureTime, index_prefetch as prefetch, index_prefetchArray as prefetchArray, index_prefetchHint as prefetchHint, index_profile as profile, index_spinLock as spinLock, index_unlikely as unlikely, index_yieldToEventLoop as yieldToEventLoop };
2325
+ }
2326
+
2327
+ export { type SIMDCapabilities as $, type AffinityConfig as A, BranchOptimizer as B, CACHE_LINE_SIZE as C, DirectIOFile as D, type Int64Vector as E, FastTimeProvider as F, LatencyOptimizer as G, HardwareMonitor as H, IOBatchProcessor as I, type JITConfig as J, KernelBypassManager as K, LatencyMonitor as L, type LatencyStats as M, LockFreeQueue as N, LoopOptimizer as O, MPMCQueue as P, MemoryMappedFile as Q, MemoryOps as R, MemoryPool as S, type NUMAConfig as T, NUMAOptimizer as U, type OptimizationResult as V, OptimizedMath as W, PerformanceGovernor as X, ProfileGuidedOptimizer as Y, type RealtimeConfig as Z, RealtimeTuner as _, AlignedBuffer as a, getKernelBypassManager as a$, type SIMDConfig as a0, SIMDDetector as a1, SchedulerPolicy as a2, SpinLock as a3, type SyscallBypassConfig as a4, SyscallBypassManager as a5, ThreadPriority as a6, ThreadPriorityLevel as a7, TransactionBuilder as a8, type TransactionConfig as a9, createSIMDDetector as aA, createSerializer as aB, createSyscallBypassManager as aC, createThreadPriority as aD, createTimer as aE, createTransactionBuilder as aF, createTransactionOptimizer as aG, createVectorizedMath as aH, createView as aI, createZeroCopyBuffer as aJ, defaultAffinityConfig as aK, defaultBufferPoolConfig as aL, defaultIOUringConfig as aM, defaultJITConfig as aN, defaultNUMAConfig as aO, defaultRealtimeConfig as aP, defaultSIMDConfig as aQ, defaultSyscallBypassConfig as aR, defaultTransactionConfig as aS, defaultUltraLowLatencyConfig as aT, detectCPUFeatures as aU, estimateCompute as aV, fastInvSqrt as aW, fastNowMs as aX, fastNowNs as aY, fastNowUs as aZ, getGlobalTimeProvider as a_, TransactionOptimizer as aa, type TuningStats as ab, type UltraLowLatencyConfig as ac, VectorizedMath as ad, ZeroCopyBuffer as ae, type ZeroCopySerializable as af, ZeroCopySerializer as ag, busySpin as ah, busyWait as ai, calculateOptimalPrice as aj, coldPath as ak, copyBytes as al, createBufferPool as am, createCPUAffinity as an, createCacheOptimizer as ao, createComputeBudgetOptimizer as ap, createCryptoSIMD as aq, createHardwareMonitor as ar, createInstructionBatcher as as, createLatencyMonitor as at, createLockFreeQueue as au, createMPMCQueue as av, createMemoryPool as aw, createNUMAOptimizer as ax, createPerformanceGovernor as ay, createRealtimeTuner as az, AsyncSocket as b, getOptimalSIMDWidth as b0, getProfileOptimizer as b1, getSystemCPUInfo as b2, getSystemMemoryInfo as b3, hotPath as b4, isSIMDAvailable as b5, likely as b6, measureTime as b7, prefetch as b8, prefetchArray as b9, prefetchHint as ba, profile as bb, spinLock as bc, unlikely as bd, yieldToEventLoop as be, BufferPool as c, type BufferPoolConfig as d, type BufferView as e, CPUAffinity as f, type CPUFeatures as g, type CPUTopology as h, index as i, type CacheInfo as j, CacheOptimizer as k, ComputeBudgetOptimizer as l, type ComputeBudgetStats as m, CryptoSIMD as n, FixedBufferView as o, type Float32Vector as p, Float32x4 as q, type Float64Vector as r, FuncCache as s, IOOperation as t, type IORequest as u, type IOResult as v, type IOUringConfig as w, InstructionBatcher as x, type InstructionGroup as y, type Int32Vector as z };