sol-trade-sdk 0.1.0 → 0.1.2

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 (50) hide show
  1. package/README.md +12 -5
  2. package/dist/cache/index.d.mts +70 -0
  3. package/dist/cache/index.d.ts +70 -0
  4. package/dist/cache/index.js +259 -0
  5. package/dist/cache/index.mjs +19 -0
  6. package/dist/chunk-64JY4YH6.mjs +227 -0
  7. package/dist/chunk-6BWS3CLP.mjs +16 -0
  8. package/dist/{chunk-NEZDFAYA.mjs → chunk-H4ZUMTTP.mjs} +864 -336
  9. package/dist/{chunk-MMQAMIKR.mjs → chunk-L6RZIXXN.mjs} +4 -11
  10. package/dist/{clients-VITWK7B6.mjs → chunk-V7QDWUXJ.mjs} +39 -39
  11. package/dist/clients-PSG35HN4.mjs +107 -0
  12. package/dist/index-hZh5hrGj.d.mts +3089 -0
  13. package/dist/index-yJ5AsNfm.d.ts +3089 -0
  14. package/dist/index.d.mts +2 -2658
  15. package/dist/index.d.ts +2 -2658
  16. package/dist/index.js +794 -278
  17. package/dist/index.mjs +21 -4
  18. package/dist/perf/index.mjs +2 -1
  19. package/dist/pool/index.d.mts +88 -0
  20. package/dist/pool/index.d.ts +88 -0
  21. package/dist/pool/index.js +262 -0
  22. package/dist/pool/index.mjs +233 -0
  23. package/dist/rpc/index.d.mts +77 -0
  24. package/dist/rpc/index.d.ts +77 -0
  25. package/dist/rpc/index.js +447 -0
  26. package/dist/rpc/index.mjs +223 -0
  27. package/dist/swqos/index.d.mts +416 -0
  28. package/dist/swqos/index.d.ts +416 -0
  29. package/dist/swqos/index.js +3450 -0
  30. package/dist/swqos/index.mjs +1375 -0
  31. package/dist/trading/index.d.mts +998 -0
  32. package/dist/trading/index.d.ts +998 -0
  33. package/dist/trading/index.js +4302 -0
  34. package/dist/trading/index.mjs +2097 -0
  35. package/package.json +5 -4
  36. package/src/__tests__/hotpath.test.ts +33 -0
  37. package/src/__tests__/parser-compat.test.ts +82 -0
  38. package/src/__tests__/protocol-parity.test.ts +242 -0
  39. package/src/__tests__/sdk.test.ts +16 -0
  40. package/src/cache/index.ts +1 -0
  41. package/src/hotpath/executor.ts +25 -18
  42. package/src/index.ts +330 -92
  43. package/src/instruction/meteora_damm_v2_builder.ts +88 -20
  44. package/src/instruction/pumpfun_builder.ts +133 -43
  45. package/src/instruction/raydium_amm_v4_builder.ts +244 -35
  46. package/src/instruction/raydium_cpmm_builder.ts +87 -69
  47. package/src/params/index.ts +38 -5
  48. package/src/pool/index.ts +1 -0
  49. package/src/rpc/index.ts +1 -0
  50. package/src/trading/factory.ts +10 -0
@@ -0,0 +1,3089 @@
1
+ import { TransactionInstruction, PublicKey, Keypair, Connection, Transaction, Commitment, Finality, AccountInfo, SimulateTransactionConfig, AddressLookupTableAccount as AddressLookupTableAccount$1, BlockhashWithExpiryBlockHeight } from '@solana/web3.js';
2
+ import './index-1BK_FXsW.mjs';
3
+
4
+ /**
5
+ * Gas Fee Strategy for Sol Trade SDK
6
+ */
7
+ declare enum TradeType$2 {
8
+ Buy = "Buy",
9
+ Sell = "Sell"
10
+ }
11
+ declare enum SwqosType$1 {
12
+ Default = "Default",
13
+ Jito = "Jito",
14
+ Bloxroute = "Bloxroute",
15
+ ZeroSlot = "ZeroSlot",
16
+ Temporal = "Temporal",
17
+ FlashBlock = "FlashBlock",
18
+ BlockRazor = "BlockRazor",
19
+ Node1 = "Node1",
20
+ Astralane = "Astralane",
21
+ NextBlock = "NextBlock",
22
+ Helius = "Helius",
23
+ Stellium = "Stellium",
24
+ Lightspeed = "Lightspeed",
25
+ Soyas = "Soyas",
26
+ Speedlanding = "Speedlanding",
27
+ Triton = "Triton",
28
+ QuickNode = "QuickNode",
29
+ Syndica = "Syndica",
30
+ Figment = "Figment",
31
+ Alchemy = "Alchemy"
32
+ }
33
+ declare enum GasFeeStrategyType {
34
+ Normal = "Normal",
35
+ LowTipHighCuPrice = "LowTipHighCuPrice",
36
+ HighTipLowCuPrice = "HighTipLowCuPrice"
37
+ }
38
+ interface GasFeeStrategyValue {
39
+ cuLimit: number;
40
+ cuPrice: number;
41
+ tip: number;
42
+ }
43
+ declare class GasFeeStrategy {
44
+ private strategies;
45
+ constructor();
46
+ /**
47
+ * Set global fee strategy for all SWQOS types
48
+ */
49
+ setGlobalFeeStrategy(buyCuLimit: number, sellCuLimit: number, buyCuPrice: number, sellCuPrice: number, buyTip: number, sellTip: number): void;
50
+ /**
51
+ * Set high-low fee strategies for multiple SWQOS types
52
+ */
53
+ setHighLowFeeStrategies(swqosTypes: SwqosType$1[], tradeType: TradeType$2, cuLimit: number, lowCuPrice: number, highCuPrice: number, lowTip: number, highTip: number): void;
54
+ /**
55
+ * Set a specific gas fee strategy
56
+ */
57
+ set(swqosType: SwqosType$1, tradeType: TradeType$2, strategyType: GasFeeStrategyType, cuLimit: number, cuPrice: number, tip: number): void;
58
+ /**
59
+ * Get a specific gas fee strategy
60
+ */
61
+ get(swqosType: SwqosType$1, tradeType: TradeType$2, strategyType: GasFeeStrategyType): GasFeeStrategyValue | undefined;
62
+ /**
63
+ * Delete a specific gas fee strategy
64
+ */
65
+ delete(swqosType: SwqosType$1, tradeType: TradeType$2, strategyType: GasFeeStrategyType): void;
66
+ /**
67
+ * Delete all strategies for a SWQOS type and trade type
68
+ */
69
+ deleteAll(swqosType: SwqosType$1, tradeType: TradeType$2): void;
70
+ /**
71
+ * Get all strategies for a trade type
72
+ */
73
+ getStrategies(tradeType: TradeType$2): Array<{
74
+ swqosType: SwqosType$1;
75
+ strategyType: GasFeeStrategyType;
76
+ value: GasFeeStrategyValue;
77
+ }>;
78
+ /**
79
+ * Update buy tip for all strategies
80
+ */
81
+ updateBuyTip(buyTip: number): void;
82
+ /**
83
+ * Update sell tip for all strategies
84
+ */
85
+ updateSellTip(sellTip: number): void;
86
+ /**
87
+ * Clear all strategies
88
+ */
89
+ clear(): void;
90
+ private getKey;
91
+ private parseKey;
92
+ }
93
+
94
+ /**
95
+ * Shared SDK errors (avoids circular imports with `index` / `swqos`).
96
+ */
97
+ declare class TradeError extends Error {
98
+ code: number;
99
+ cause?: Error | undefined;
100
+ constructor(code: number, message: string, cause?: Error | undefined);
101
+ }
102
+
103
+ /**
104
+ * Middleware trait definitions.
105
+ * Based on sol-trade-sdk Rust implementation.
106
+ */
107
+
108
+ /**
109
+ * Instruction middleware interface
110
+ * Used to modify, add or remove instructions before transaction execution
111
+ */
112
+ interface InstructionMiddleware {
113
+ /** Middleware name */
114
+ name(): string;
115
+ /**
116
+ * Process protocol instructions
117
+ * @param protocolInstructions - Current instruction list
118
+ * @param protocolName - Protocol name
119
+ * @param isBuy - Whether the transaction is a buy transaction
120
+ * @returns Modified instruction list
121
+ */
122
+ processProtocolInstructions(protocolInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
123
+ /**
124
+ * Process full instructions
125
+ * @param fullInstructions - Current instruction list
126
+ * @param protocolName - Protocol name
127
+ * @param isBuy - Whether the transaction is a buy transaction
128
+ * @returns Modified instruction list
129
+ */
130
+ processFullInstructions(fullInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
131
+ /** Clone middleware */
132
+ clone(): InstructionMiddleware;
133
+ }
134
+ /**
135
+ * Middleware manager
136
+ */
137
+ declare class MiddlewareManager {
138
+ private middlewares;
139
+ /**
140
+ * Create new middleware manager
141
+ */
142
+ constructor();
143
+ /**
144
+ * Add middleware
145
+ */
146
+ addMiddleware(middleware: InstructionMiddleware): this;
147
+ /**
148
+ * Apply all middlewares to process protocol instructions
149
+ */
150
+ applyMiddlewaresProcessProtocolInstructions(protocolInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
151
+ /**
152
+ * Apply all middlewares to process full instructions
153
+ */
154
+ applyMiddlewaresProcessFullInstructions(fullInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
155
+ /**
156
+ * Clone the manager
157
+ */
158
+ clone(): MiddlewareManager;
159
+ /**
160
+ * Create manager with common middlewares
161
+ */
162
+ static withCommonMiddlewares(): MiddlewareManager;
163
+ }
164
+ /**
165
+ * Logging middleware - Records instruction information
166
+ */
167
+ declare class LoggingMiddleware implements InstructionMiddleware {
168
+ name(): string;
169
+ processProtocolInstructions(protocolInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
170
+ processFullInstructions(fullInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
171
+ clone(): InstructionMiddleware;
172
+ }
173
+ /**
174
+ * Timer middleware - Measures execution time
175
+ */
176
+ declare class TimerMiddleware implements InstructionMiddleware {
177
+ private enabled;
178
+ name(): string;
179
+ setEnabled(enabled: boolean): void;
180
+ processProtocolInstructions(protocolInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
181
+ processFullInstructions(fullInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
182
+ clone(): InstructionMiddleware;
183
+ }
184
+ /**
185
+ * Validation middleware - Validates instructions before processing
186
+ */
187
+ declare class ValidationMiddleware implements InstructionMiddleware {
188
+ private maxInstructions;
189
+ private maxDataSize;
190
+ constructor(maxInstructions?: number, maxDataSize?: number);
191
+ name(): string;
192
+ private validate;
193
+ processProtocolInstructions(protocolInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
194
+ processFullInstructions(fullInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
195
+ clone(): InstructionMiddleware;
196
+ }
197
+ /**
198
+ * Filter middleware - Filters instructions based on program ID
199
+ */
200
+ declare class FilterMiddleware implements InstructionMiddleware {
201
+ private mode;
202
+ private allowedPrograms;
203
+ constructor(programs: PublicKey[], mode?: 'allow' | 'block');
204
+ name(): string;
205
+ private filter;
206
+ processProtocolInstructions(protocolInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
207
+ processFullInstructions(fullInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
208
+ clone(): InstructionMiddleware;
209
+ }
210
+ /**
211
+ * Metrics middleware - Collects metrics about instruction processing
212
+ */
213
+ declare class MetricsMiddleware implements InstructionMiddleware {
214
+ private instructionCounts;
215
+ private totalInstructions;
216
+ private totalDataSize;
217
+ name(): string;
218
+ private record;
219
+ processProtocolInstructions(protocolInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
220
+ processFullInstructions(fullInstructions: TransactionInstruction[], protocolName: string, isBuy: boolean): TransactionInstruction[];
221
+ clone(): InstructionMiddleware;
222
+ /**
223
+ * Get collected metrics
224
+ */
225
+ getMetrics(): {
226
+ instructionCounts: Record<string, number>;
227
+ totalInstructions: number;
228
+ totalDataSize: number;
229
+ };
230
+ /**
231
+ * Reset metrics
232
+ */
233
+ reset(): void;
234
+ }
235
+ /**
236
+ * Create manager with standard middlewares
237
+ */
238
+ declare function withStandardMiddlewares(): MiddlewareManager;
239
+ /**
240
+ * Create manager with all builtin middlewares
241
+ */
242
+ declare function withAllBuiltinMiddlewares(): MiddlewareManager;
243
+
244
+ /**
245
+ * Constants for Sol Trade SDK
246
+ */
247
+
248
+ declare const SYSTEM_PROGRAM: PublicKey;
249
+ declare const TOKEN_PROGRAM: PublicKey;
250
+ declare const TOKEN_PROGRAM_2022: PublicKey;
251
+ declare const SOL_TOKEN_ACCOUNT: PublicKey;
252
+ declare const WSOL_TOKEN_ACCOUNT: PublicKey;
253
+ declare const USD1_TOKEN_ACCOUNT: PublicKey;
254
+ declare const USDC_TOKEN_ACCOUNT: PublicKey;
255
+ declare const ASSOCIATED_TOKEN_PROGRAM: PublicKey;
256
+ declare const RENT: PublicKey;
257
+ declare const PUMPFUN_PROGRAM: PublicKey;
258
+ /** PumpSwap AMM program (same as `instruction/pumpswap` PUMPSWAP_PROGRAM) */
259
+ declare const PUMPSWAP_PROGRAM_ID: PublicKey;
260
+ declare const BONK_PROGRAM: PublicKey;
261
+ declare const RAYDIUM_CPMM_PROGRAM: PublicKey;
262
+ declare const RAYDIUM_AMM_V4_PROGRAM: PublicKey;
263
+ declare const METEORA_DAMM_V2_PROGRAM: PublicKey;
264
+ declare const SDK_FEE_RECIPIENT: PublicKey;
265
+ declare const SDK_MAYHEM_FEE_RECIPIENTS: PublicKey[];
266
+ declare const PUMPFUN_DISCRIMINATORS: {
267
+ BUY: Buffer<ArrayBuffer>;
268
+ SELL: Buffer<ArrayBuffer>;
269
+ BUY_EXACT_SOL_IN: Buffer<ArrayBuffer>;
270
+ CLAIM_CASHBACK: Buffer<ArrayBuffer>;
271
+ };
272
+ declare const PUMPSWAP_DISCRIMINATORS: {
273
+ SWAP: Buffer<ArrayBuffer>;
274
+ DEPOSIT: Buffer<ArrayBuffer>;
275
+ WITHDRAW: Buffer<ArrayBuffer>;
276
+ };
277
+ declare const DEFAULT_SLIPPAGE = 500;
278
+ declare const DEFAULT_COMPUTE_UNITS = 200000;
279
+ declare const DEFAULT_PRIORITY_FEE = 100000;
280
+ declare const DEFAULT_TIP_LAMPORTS = 100000;
281
+ /** Aggregate for consumers expecting a single `CONSTANTS` object (matches historical `index` export). */
282
+ declare const CONSTANTS: {
283
+ readonly SYSTEM_PROGRAM: PublicKey;
284
+ readonly TOKEN_PROGRAM: PublicKey;
285
+ readonly TOKEN_PROGRAM_2022: PublicKey;
286
+ readonly SOL_TOKEN_ACCOUNT: PublicKey;
287
+ readonly WSOL_TOKEN_ACCOUNT: PublicKey;
288
+ readonly USD1_TOKEN_ACCOUNT: PublicKey;
289
+ readonly USDC_TOKEN_ACCOUNT: PublicKey;
290
+ readonly ASSOCIATED_TOKEN_PROGRAM: PublicKey;
291
+ readonly RENT: PublicKey;
292
+ readonly PUMPFUN_PROGRAM: PublicKey;
293
+ readonly PUMPSWAP_PROGRAM: PublicKey;
294
+ readonly BONK_PROGRAM: PublicKey;
295
+ readonly RAYDIUM_CPMM_PROGRAM: PublicKey;
296
+ readonly RAYDIUM_AMM_V4_PROGRAM: PublicKey;
297
+ readonly METEORA_DAMM_V2_PROGRAM: PublicKey;
298
+ readonly DEFAULT_SLIPPAGE: 500;
299
+ readonly DEFAULT_COMPUTE_UNITS: 200000;
300
+ readonly DEFAULT_PRIORITY_FEE: 100000;
301
+ readonly DEFAULT_TIP_LAMPORTS: 100000;
302
+ };
303
+ declare const SWQOS_ENDPOINTS: Record<string, Record<string, string>>;
304
+
305
+ /**
306
+ * PumpFun Protocol Instruction Builder
307
+ *
308
+ * Production-grade instruction builder for PumpFun bonding curve protocol.
309
+ * Supports buy, sell, and cashback claim operations.
310
+ * 100% port from Rust: src/instruction/pumpfun.rs
311
+ */
312
+
313
+ /** PumpFun program ID */
314
+ declare const PUMPFUN_PROGRAM_ID: PublicKey;
315
+ /** Event Authority for PumpFun */
316
+ declare const PUMPFUN_EVENT_AUTHORITY: PublicKey;
317
+ /** Fee Program */
318
+ declare const PUMPFUN_FEE_PROGRAM: PublicKey;
319
+ /** Global Volume Accumulator */
320
+ declare const PUMPFUN_GLOBAL_VOLUME_ACCUMULATOR: PublicKey;
321
+ /** Fee Config */
322
+ declare const PUMPFUN_FEE_CONFIG: PublicKey;
323
+ /** Global Account */
324
+ declare const PUMPFUN_GLOBAL_ACCOUNT: PublicKey;
325
+ /** Fee Recipient */
326
+ declare const PUMPFUN_FEE_RECIPIENT: PublicKey;
327
+ /** Non-mayhem: random among primary + Pump.fun AMM protocol fee recipients (Rust `get_standard_fee_recipient_meta_random`). */
328
+ declare const PUMPFUN_STANDARD_FEE_RECIPIENTS: PublicKey[];
329
+ /**
330
+ * Protocol extra fee recipients (Apr 2026 breaking upgrade).
331
+ * One pubkey is appended after bonding-curve-v2 on buy/sell; account must be writable.
332
+ * @see https://github.com/pump-fun/pump-public-docs/blob/main/docs/BREAKING_FEE_RECIPIENT.md
333
+ */
334
+ declare const PUMPFUN_PROTOCOL_EXTRA_FEE_RECIPIENTS: PublicKey[];
335
+ /** V2 buyback fee recipients (same static pool as Rust `get_buyback_fee_recipient_random`). */
336
+ declare const PUMPFUN_BUYBACK_FEE_RECIPIENTS: PublicKey[];
337
+ /** Mayhem Fee Recipients */
338
+ declare const PUMPFUN_MAYHEM_FEE_RECIPIENTS: PublicKey[];
339
+ /** Buy instruction discriminator */
340
+ declare const PUMPFUN_BUY_DISCRIMINATOR: Buffer;
341
+ /** Buy exact SOL in discriminator */
342
+ declare const PUMPFUN_BUY_EXACT_SOL_IN_DISCRIMINATOR: Buffer;
343
+ /** Sell instruction discriminator */
344
+ declare const PUMPFUN_SELL_DISCRIMINATOR: Buffer;
345
+ /** PumpFun V2 buy instruction discriminator */
346
+ declare const PUMPFUN_BUY_V2_DISCRIMINATOR: Buffer;
347
+ /** PumpFun V2 sell instruction discriminator */
348
+ declare const PUMPFUN_SELL_V2_DISCRIMINATOR: Buffer;
349
+ /** PumpFun V2 exact quote-in buy discriminator */
350
+ declare const PUMPFUN_BUY_EXACT_QUOTE_IN_V2_DISCRIMINATOR: Buffer;
351
+ /** Claim cashback discriminator */
352
+ declare const PUMPFUN_CLAIM_CASHBACK_DISCRIMINATOR: Buffer;
353
+ declare const PUMPFUN_BONDING_CURVE_SEED: Buffer<ArrayBuffer>;
354
+ declare const PUMPFUN_BONDING_CURVE_V2_SEED: Buffer<ArrayBuffer>;
355
+ declare const PUMPFUN_CREATOR_VAULT_SEED: Buffer<ArrayBuffer>;
356
+ declare const PUMPFUN_USER_VOLUME_ACCUMULATOR_SEED: Buffer<ArrayBuffer>;
357
+ declare const PUMPFUN_SHARING_CONFIG_SEED: Buffer<ArrayBuffer>;
358
+ /**
359
+ * Derive the bonding curve PDA for a given mint
360
+ */
361
+ declare function getBondingCurvePda(mint: PublicKey): PublicKey;
362
+ /**
363
+ * Derive the bonding curve v2 PDA for a given mint
364
+ */
365
+ declare function getBondingCurveV2Pda(mint: PublicKey): PublicKey;
366
+ /**
367
+ * Derive the creator vault PDA for a given creator
368
+ */
369
+ declare function getCreatorVaultPda(creator: PublicKey): PublicKey;
370
+ /**
371
+ * Derive the user volume accumulator PDA for a given user
372
+ */
373
+ declare function getPumpFunUserVolumeAccumulatorPda(user: PublicKey): PublicKey;
374
+ /**
375
+ * Derive the fee sharing config PDA for a PumpFun mint.
376
+ */
377
+ declare function getPumpFunFeeSharingConfigPda(mint: PublicKey): PublicKey;
378
+ /**
379
+ * Get a random Mayhem fee recipient
380
+ */
381
+ declare function getRandomMayhemFeeRecipient(): PublicKey;
382
+ declare function getStandardFeeRecipientRandom(): PublicKey;
383
+ /** Random protocol extra fee recipient (after bonding-curve-v2, mutable). */
384
+ declare function getPumpFunProtocolExtraFeeRecipientRandom(): PublicKey;
385
+ /** Random PumpFun V2 buyback fee recipient. */
386
+ declare function getPumpFunBuybackFeeRecipientRandom(): PublicKey;
387
+ /**
388
+ * Account #2 fee recipient: prefer gRPC/event `feeRecipient`; if `default` pubkey, random from mayhem or standard pool (Rust `pump_fun_fee_recipient_meta`).
389
+ */
390
+ declare function pumpFunFeeRecipientMeta(fromStream: PublicKey | undefined, isMayhemMode: boolean): PublicKey;
391
+ interface PumpFunBondingCurve {
392
+ account: PublicKey;
393
+ virtualTokenReserves: bigint;
394
+ virtualSolReserves: bigint;
395
+ realTokenReserves: bigint;
396
+ creator?: PublicKey;
397
+ isMayhemMode: boolean;
398
+ isCashbackCoin: boolean;
399
+ }
400
+ interface PumpFunParams$2 {
401
+ bondingCurve: PumpFunBondingCurve;
402
+ creatorVault: PublicKey;
403
+ tokenProgram: PublicKey;
404
+ associatedBondingCurve?: PublicKey;
405
+ observedTradeCreator?: PublicKey;
406
+ feeSharingCreatorVaultIfActive?: PublicKey;
407
+ closeTokenAccountWhenSell?: boolean;
408
+ /** From parser/gRPC (`tradeEvent.feeRecipient`); default pubkey → random pool */
409
+ feeRecipient?: PublicKey;
410
+ /** Layout selector: default/Solscan SOL sentinel keeps legacy SOL; WSOL/USDC selects V2. */
411
+ quoteMint?: PublicKey;
412
+ }
413
+ interface PumpFunBuildBuyParams {
414
+ payer: Keypair | PublicKey;
415
+ inputMint?: PublicKey;
416
+ outputMint: PublicKey;
417
+ inputAmount: bigint;
418
+ slippageBasisPoints?: bigint;
419
+ fixedOutputAmount?: bigint;
420
+ createOutputMintAta?: boolean;
421
+ createInputMintAta?: boolean;
422
+ closeInputMintAta?: boolean;
423
+ protocolParams: PumpFunParams$2;
424
+ useExactSolAmount?: boolean;
425
+ }
426
+ interface PumpFunBuildSellParams {
427
+ payer: Keypair | PublicKey;
428
+ inputMint: PublicKey;
429
+ outputMint?: PublicKey;
430
+ inputAmount: bigint;
431
+ slippageBasisPoints?: bigint;
432
+ fixedOutputAmount?: bigint;
433
+ createOutputMintAta?: boolean;
434
+ closeInputMintAta?: boolean;
435
+ protocolParams: PumpFunParams$2;
436
+ }
437
+ /**
438
+ * Build buy instructions for PumpFun protocol
439
+ * 100% port from Rust: src/instruction/pumpfun.rs build_buy_instructions
440
+ */
441
+ declare function buildPumpFunBuyInstructions(params: PumpFunBuildBuyParams): TransactionInstruction[];
442
+ /**
443
+ * Build sell instructions for PumpFun protocol
444
+ * 100% port from Rust: src/instruction/pumpfun.rs build_sell_instructions
445
+ */
446
+ declare function buildPumpFunSellInstructions(params: PumpFunBuildSellParams): TransactionInstruction[];
447
+ /**
448
+ * Build PumpFun V2 buy instructions (`buy_v2` / `buy_exact_quote_in_v2`).
449
+ */
450
+ declare function buildPumpFunBuyV2Instructions(params: PumpFunBuildBuyParams): TransactionInstruction[];
451
+ /**
452
+ * Build PumpFun V2 sell instructions (`sell_v2`).
453
+ */
454
+ declare function buildPumpFunSellV2Instructions(params: PumpFunBuildSellParams): TransactionInstruction[];
455
+ /**
456
+ * Build claim cashback instruction for PumpFun
457
+ */
458
+ declare function buildPumpFunClaimCashbackInstruction(payer: PublicKey): TransactionInstruction;
459
+ /**
460
+ * Fetch bonding curve account from RPC.
461
+ * 100% from Rust: src/instruction/utils/pumpfun.rs fetch_bonding_curve_account
462
+ */
463
+ declare function fetchBondingCurveAccount(connection: {
464
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
465
+ value?: {
466
+ data: Buffer;
467
+ };
468
+ }>;
469
+ }, mint: PublicKey): Promise<{
470
+ bondingCurve: PumpFunBondingCurve;
471
+ bondingCurvePda: PublicKey;
472
+ } | null>;
473
+ /**
474
+ * Get creator from creator vault PDA.
475
+ * 100% from Rust: src/instruction/utils/pumpfun.rs get_creator
476
+ */
477
+ declare function getCreator(creatorVaultPda: PublicKey): PublicKey;
478
+ /**
479
+ * Get buy price (tokens received for SOL).
480
+ * 100% from Rust: src/instruction/utils/pumpfun.rs get_buy_price
481
+ */
482
+ declare function getBuyPrice(amount: bigint, virtualSolReserves: bigint, virtualTokenReserves: bigint, realTokenReserves: bigint): bigint;
483
+
484
+ /**
485
+ * PumpSwap instruction builder - Production-grade implementation
486
+ * 100% port from Rust sol-trade-sdk
487
+ */
488
+
489
+ declare const PUMPSWAP_PROGRAM: PublicKey;
490
+ declare const PUMPSWAP_PUMP_PROGRAM_ID: PublicKey;
491
+ declare const PUMPSWAP_FEE_PROGRAM: PublicKey;
492
+ declare const PUMPSWAP_FEE_RECIPIENT: PublicKey;
493
+ declare const PUMPSWAP_GLOBAL_ACCOUNT: PublicKey;
494
+ declare const PUMPSWAP_EVENT_AUTHORITY: PublicKey;
495
+ declare const PUMPSWAP_GLOBAL_VOLUME_ACCUMULATOR: PublicKey;
496
+ declare const PUMPSWAP_FEE_CONFIG: PublicKey;
497
+ declare const PUMPSWAP_DEFAULT_COIN_CREATOR_VAULT_AUTHORITY: PublicKey;
498
+ declare const PUMPSWAP_MAYHEM_FEE_RECIPIENTS: PublicKey[];
499
+ /** Protocol extra fee recipients (Apr 2026); after pool-v2: readonly, then quote ATA (mutable). */
500
+ declare const PUMPSWAP_PROTOCOL_EXTRA_FEE_RECIPIENTS: PublicKey[];
501
+ declare const PUMPSWAP_BUY_DISCRIMINATOR: Buffer<ArrayBuffer>;
502
+ declare const PUMPSWAP_BUY_EXACT_QUOTE_IN_DISCRIMINATOR: Buffer<ArrayBuffer>;
503
+ declare const PUMPSWAP_SELL_DISCRIMINATOR: Buffer<ArrayBuffer>;
504
+ declare const PUMPSWAP_CLAIM_CASHBACK_DISCRIMINATOR: Buffer<ArrayBuffer>;
505
+ /**
506
+ * Get a random Mayhem fee recipient
507
+ */
508
+ declare function getMayhemFeeRecipientRandom(): PublicKey;
509
+ declare function getPumpSwapProtocolExtraFeeRecipientRandom(): PublicKey;
510
+ /**
511
+ * Pool v2 PDA (seeds: ["pool-v2", base_mint])
512
+ */
513
+ declare function getPoolV2PDA(baseMint: PublicKey): PublicKey;
514
+ /**
515
+ * Pump program pool-authority PDA (for canonical pool)
516
+ */
517
+ declare function getPumpPoolAuthorityPDA(mint: PublicKey): PublicKey;
518
+ /**
519
+ * Canonical Pump pool PDA
520
+ */
521
+ declare function getCanonicalPoolPDA(mint: PublicKey): PublicKey;
522
+ /**
523
+ * Coin creator vault authority PDA
524
+ */
525
+ declare function getCoinCreatorVaultAuthority(coinCreator: PublicKey): PublicKey;
526
+ /**
527
+ * Coin creator vault ATA
528
+ */
529
+ declare function getCoinCreatorVaultAta(coinCreator: PublicKey, quoteMint: PublicKey): PublicKey;
530
+ /**
531
+ * Fee recipient ATA
532
+ */
533
+ declare function getFeeRecipientAta(feeRecipient: PublicKey, quoteMint: PublicKey): PublicKey;
534
+ /**
535
+ * User volume accumulator PDA
536
+ */
537
+ declare function getUserVolumeAccumulatorPDA(user: PublicKey): PublicKey;
538
+ /**
539
+ * WSOL ATA of UserVolumeAccumulator (for buy cashback)
540
+ */
541
+ declare function getUserVolumeAccumulatorWsolAta(user: PublicKey): PublicKey;
542
+ /**
543
+ * Quote-mint ATA of UserVolumeAccumulator (for sell cashback)
544
+ */
545
+ declare function getUserVolumeAccumulatorQuoteAta(user: PublicKey, quoteMint: PublicKey, quoteTokenProgram: PublicKey): PublicKey;
546
+ /**
547
+ * Global volume accumulator PDA
548
+ * Seeds: ["global_volume_accumulator"], owner: PUMPSWAP_PROGRAM
549
+ */
550
+ declare function getGlobalVolumeAccumulatorPDA(): PublicKey;
551
+ /**
552
+ * Get associated token address
553
+ */
554
+ declare function getAssociatedTokenAddress(owner: PublicKey, mint: PublicKey, tokenProgram?: PublicKey): PublicKey;
555
+ /**
556
+ * Create WSOL ATA and wrap SOL
557
+ * Returns instructions for: create ATA (idempotent), transfer SOL, sync_native
558
+ */
559
+ declare function handleWsol(owner: PublicKey, amount: bigint): TransactionInstruction[];
560
+ /**
561
+ * Close WSOL ATA and reclaim rent
562
+ */
563
+ declare function closeWsol(owner: PublicKey): TransactionInstruction;
564
+ /**
565
+ * Create associated token account idempotent
566
+ */
567
+ declare function createAssociatedTokenAccountIdempotent(payer: PublicKey, owner: PublicKey, mint: PublicKey, tokenProgram?: PublicKey): TransactionInstruction;
568
+ interface PumpSwapParams$2 {
569
+ pool: PublicKey;
570
+ baseMint: PublicKey;
571
+ quoteMint: PublicKey;
572
+ poolBaseTokenAccount: PublicKey;
573
+ poolQuoteTokenAccount: PublicKey;
574
+ poolBaseTokenReserves: bigint;
575
+ poolQuoteTokenReserves: bigint;
576
+ coinCreatorVaultAta: PublicKey;
577
+ coinCreatorVaultAuthority: PublicKey;
578
+ baseTokenProgram: PublicKey;
579
+ quoteTokenProgram: PublicKey;
580
+ isMayhemMode: boolean;
581
+ isCashbackCoin: boolean;
582
+ }
583
+ interface BuildBuyParams {
584
+ payer: PublicKey;
585
+ inputAmount: bigint;
586
+ slippageBasisPoints: bigint;
587
+ protocolParams: PumpSwapParams$2;
588
+ createInputMintAta?: boolean;
589
+ closeInputMintAta?: boolean;
590
+ createOutputMintAta?: boolean;
591
+ useExactQuoteAmount?: boolean;
592
+ fixedOutputAmount?: bigint;
593
+ }
594
+ interface BuildSellParams {
595
+ payer: PublicKey;
596
+ inputAmount: bigint;
597
+ slippageBasisPoints: bigint;
598
+ protocolParams: PumpSwapParams$2;
599
+ createOutputMintAta?: boolean;
600
+ closeOutputMintAta?: boolean;
601
+ closeInputMintAta?: boolean;
602
+ fixedOutputAmount?: bigint;
603
+ }
604
+ /**
605
+ * Build buy instructions for PumpSwap
606
+ * 100% port from Rust: src/instruction/pumpswap.rs build_buy_instructions
607
+ */
608
+ declare function buildBuyInstructions(params: BuildBuyParams): TransactionInstruction[];
609
+ /**
610
+ * Build sell instructions for PumpSwap
611
+ * 100% port from Rust: src/instruction/pumpswap.rs build_sell_instructions
612
+ */
613
+ declare function buildSellInstructions(params: BuildSellParams): TransactionInstruction[];
614
+ /**
615
+ * Build claim cashback instruction for PumpSwap
616
+ */
617
+ declare function buildClaimCashbackInstruction(payer: PublicKey, quoteMint: PublicKey, quoteTokenProgram: PublicKey): TransactionInstruction;
618
+ /**
619
+ * Pool size in bytes (244 bytes as per pump-public-docs)
620
+ */
621
+ declare const POOL_SIZE = 244;
622
+ /**
623
+ * PumpSwap Pool structure
624
+ * Matches Rust: src/instruction/utils/pumpswap_types.rs Pool struct
625
+ */
626
+ interface PumpSwapPool {
627
+ poolBump: number;
628
+ index: number;
629
+ creator: PublicKey;
630
+ baseMint: PublicKey;
631
+ quoteMint: PublicKey;
632
+ lpMint: PublicKey;
633
+ poolBaseTokenAccount: PublicKey;
634
+ poolQuoteTokenAccount: PublicKey;
635
+ lpSupply: bigint;
636
+ coinCreator: PublicKey;
637
+ isMayhemMode: boolean;
638
+ isCashbackCoin: boolean;
639
+ }
640
+ /**
641
+ * Decode a PumpSwap pool from account data
642
+ * Uses Borsh deserialization
643
+ */
644
+ declare function decodePool(data: Buffer): PumpSwapPool | null;
645
+ /**
646
+ * Get fee config PDA
647
+ */
648
+ declare function getFeeConfigPDA(): PublicKey;
649
+ /**
650
+ * Fetch a PumpSwap pool from RPC.
651
+ * 100% from Rust: src/instruction/utils/pumpswap.rs fetch_pool
652
+ */
653
+ declare function fetchPool(connection: {
654
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
655
+ value?: {
656
+ data: Buffer;
657
+ };
658
+ }>;
659
+ }, poolAddress: PublicKey): Promise<PumpSwapPool | null>;
660
+ /**
661
+ * Get token balances for a pool's token accounts.
662
+ * 100% from Rust: src/instruction/utils/pumpswap.rs get_token_balances
663
+ */
664
+ declare function getTokenBalances(connection: {
665
+ getTokenAccountBalance: (pubkey: PublicKey) => Promise<{
666
+ value?: {
667
+ amount: string;
668
+ };
669
+ }>;
670
+ }, pool: PumpSwapPool): Promise<{
671
+ baseBalance: bigint;
672
+ quoteBalance: bigint;
673
+ } | null>;
674
+ /**
675
+ * Find a PumpSwap pool by mint with full RPC lookup.
676
+ * 100% from Rust: src/instruction/utils/pumpswap.rs find_by_mint
677
+ * Search order:
678
+ * 1. Pool v2 PDA ["pool-v2", base_mint]
679
+ * 2. Canonical pool PDA
680
+ * 3. getProgramAccounts by base_mint / quote_mint (optional fallback)
681
+ */
682
+ declare function findByMint(connection: {
683
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
684
+ value?: {
685
+ data: Buffer;
686
+ };
687
+ }>;
688
+ getProgramAccounts?: (programId: PublicKey, config?: unknown) => Promise<Array<{
689
+ pubkey: PublicKey;
690
+ account: {
691
+ data: Buffer;
692
+ };
693
+ }>>;
694
+ }, mint: PublicKey): Promise<{
695
+ poolAddress: PublicKey;
696
+ pool: PumpSwapPool;
697
+ } | null>;
698
+ /**
699
+ * Find a PumpSwap pool by base mint using getProgramAccounts.
700
+ * 100% from Rust: src/instruction/utils/pumpswap.rs find_by_base_mint
701
+ * base_mint offset: 8(discriminator) + 1(bump) + 2(index) + 32(creator) = 43
702
+ */
703
+ declare function findByBaseMint(connection: {
704
+ getProgramAccounts: (programId: PublicKey, config?: {
705
+ filters?: Array<{
706
+ dataSize?: number;
707
+ memcmp?: {
708
+ offset: number;
709
+ bytes: string;
710
+ };
711
+ }>;
712
+ encoding?: string;
713
+ }) => Promise<Array<{
714
+ pubkey: PublicKey;
715
+ account: {
716
+ data: Buffer;
717
+ };
718
+ }>>;
719
+ }, baseMint: PublicKey): Promise<{
720
+ poolAddress: PublicKey;
721
+ pool: PumpSwapPool;
722
+ } | null>;
723
+ /**
724
+ * Find a PumpSwap pool by quote mint using getProgramAccounts.
725
+ * 100% from Rust: src/instruction/utils/pumpswap.rs find_by_quote_mint
726
+ * quote_mint offset: 8 + 1 + 2 + 32 + 32 = 75
727
+ */
728
+ declare function findByQuoteMint(connection: {
729
+ getProgramAccounts: (programId: PublicKey, config?: {
730
+ filters?: Array<{
731
+ dataSize?: number;
732
+ memcmp?: {
733
+ offset: number;
734
+ bytes: string;
735
+ };
736
+ }>;
737
+ encoding?: string;
738
+ }) => Promise<Array<{
739
+ pubkey: PublicKey;
740
+ account: {
741
+ data: Buffer;
742
+ };
743
+ }>>;
744
+ }, quoteMint: PublicKey): Promise<{
745
+ poolAddress: PublicKey;
746
+ pool: PumpSwapPool;
747
+ } | null>;
748
+
749
+ /**
750
+ * Bonk Protocol Instruction Builder
751
+ *
752
+ * Production-grade instruction builder for Bonk AMM protocol.
753
+ * Supports buy and sell operations with WSOL and USD1 pools.
754
+ * 100% port from Rust: src/instruction/bonk.rs
755
+ */
756
+
757
+ /** Bonk program ID */
758
+ declare const BONK_PROGRAM_ID: PublicKey;
759
+ /** Bonk Authority */
760
+ declare const BONK_AUTHORITY: PublicKey;
761
+ /** Bonk Global Config */
762
+ declare const BONK_GLOBAL_CONFIG: PublicKey;
763
+ /** Bonk USD1 Global Config */
764
+ declare const BONK_USD1_GLOBAL_CONFIG: PublicKey;
765
+ /** Bonk Event Authority */
766
+ declare const BONK_EVENT_AUTHORITY: PublicKey;
767
+ /** WSOL Token Account (mint) */
768
+ declare const WSOL_MINT: PublicKey;
769
+ /** USD1 Token Account (mint) */
770
+ declare const USD1_MINT: PublicKey;
771
+ /** USDC Token Account (mint) */
772
+ declare const USDC_MINT: PublicKey;
773
+ /** Fee rates - from Rust */
774
+ declare const BONK_PLATFORM_FEE_RATE: bigint;
775
+ declare const BONK_PROTOCOL_FEE_RATE: bigint;
776
+ declare const BONK_SHARE_FEE_RATE: bigint;
777
+ /** Buy exact in instruction discriminator */
778
+ declare const BONK_BUY_EXACT_IN_DISCRIMINATOR: Buffer;
779
+ /** Sell exact in instruction discriminator */
780
+ declare const BONK_SELL_EXACT_IN_DISCRIMINATOR: Buffer;
781
+ declare const BONK_POOL_SEED: Buffer<ArrayBuffer>;
782
+ declare const BONK_POOL_VAULT_SEED: Buffer<ArrayBuffer>;
783
+ /**
784
+ * Derive the pool PDA for given base and quote mints
785
+ */
786
+ declare function getBonkPoolPda(baseMint: PublicKey, quoteMint: PublicKey): PublicKey;
787
+ /**
788
+ * Derive the vault PDA for given pool and mint
789
+ */
790
+ declare function getBonkVaultPda(poolState: PublicKey, mint: PublicKey): PublicKey;
791
+ /**
792
+ * Get platform associated account PDA
793
+ */
794
+ declare function getBonkPlatformAssociatedAccount(platformConfig: PublicKey): PublicKey;
795
+ /**
796
+ * Get creator associated account PDA
797
+ */
798
+ declare function getBonkCreatorAssociatedAccount(creator: PublicKey): PublicKey;
799
+ interface BonkParams$2 {
800
+ poolState: PublicKey;
801
+ baseVault: PublicKey;
802
+ quoteVault: PublicKey;
803
+ virtualBase: bigint;
804
+ virtualQuote: bigint;
805
+ realBase: bigint;
806
+ realQuote: bigint;
807
+ mintTokenProgram: PublicKey;
808
+ platformConfig: PublicKey;
809
+ platformAssociatedAccount: PublicKey;
810
+ creatorAssociatedAccount: PublicKey;
811
+ globalConfig?: PublicKey;
812
+ }
813
+ interface BonkBuildBuyParams {
814
+ payer: Keypair | PublicKey;
815
+ outputMint: PublicKey;
816
+ inputAmount: bigint;
817
+ slippageBasisPoints?: bigint;
818
+ fixedOutputAmount?: bigint;
819
+ createInputMintAta?: boolean;
820
+ createOutputMintAta?: boolean;
821
+ closeInputMintAta?: boolean;
822
+ protocolParams: BonkParams$2;
823
+ }
824
+ interface BonkBuildSellParams {
825
+ payer: Keypair | PublicKey;
826
+ inputMint: PublicKey;
827
+ inputAmount: bigint;
828
+ slippageBasisPoints?: bigint;
829
+ fixedOutputAmount?: bigint;
830
+ createOutputMintAta?: boolean;
831
+ closeOutputMintAta?: boolean;
832
+ closeInputMintAta?: boolean;
833
+ protocolParams: BonkParams$2;
834
+ }
835
+ /**
836
+ * Build buy instructions for Bonk protocol
837
+ * 100% port from Rust: src/instruction/bonk.rs build_buy_instructions
838
+ */
839
+ declare function buildBonkBuyInstructions(params: BonkBuildBuyParams): TransactionInstruction[];
840
+ /**
841
+ * Build sell instructions for Bonk protocol
842
+ * 100% port from Rust: src/instruction/bonk.rs build_sell_instructions
843
+ */
844
+ declare function buildBonkSellInstructions(params: BonkBuildSellParams): TransactionInstruction[];
845
+ declare const BONK_POOL_STATE_SIZE = 421;
846
+ interface BonkVestingSchedule {
847
+ totalLockedAmount: bigint;
848
+ cliffPeriod: bigint;
849
+ unlockPeriod: bigint;
850
+ startTime: bigint;
851
+ allocatedShareAmount: bigint;
852
+ }
853
+ interface BonkPoolState {
854
+ epoch: bigint;
855
+ authBump: number;
856
+ status: number;
857
+ baseDecimals: number;
858
+ quoteDecimals: number;
859
+ migrateType: number;
860
+ supply: bigint;
861
+ totalBaseSell: bigint;
862
+ virtualBase: bigint;
863
+ virtualQuote: bigint;
864
+ realBase: bigint;
865
+ realQuote: bigint;
866
+ totalQuoteFundRaising: bigint;
867
+ quoteProtocolFee: bigint;
868
+ platformFee: bigint;
869
+ migrateFee: bigint;
870
+ vestingSchedule: BonkVestingSchedule;
871
+ globalConfig: PublicKey;
872
+ platformConfig: PublicKey;
873
+ baseMint: PublicKey;
874
+ quoteMint: PublicKey;
875
+ baseVault: PublicKey;
876
+ quoteVault: PublicKey;
877
+ creator: PublicKey;
878
+ }
879
+ /**
880
+ * Decode a Bonk pool state from account data
881
+ * 100% from Rust: src/instruction/utils/bonk_types.rs pool_state_decode
882
+ */
883
+ declare function decodeBonkPoolState(data: Buffer): BonkPoolState | null;
884
+ /**
885
+ * Fetch a Bonk pool state from RPC.
886
+ * 100% from Rust: src/instruction/utils/bonk.rs fetch_pool_state
887
+ */
888
+ declare function fetchBonkPoolState(connection: {
889
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
890
+ value?: {
891
+ data: Buffer;
892
+ };
893
+ }>;
894
+ }, poolAddress: PublicKey): Promise<BonkPoolState | null>;
895
+ /**
896
+ * Get pool PDA for Bonk.
897
+ * Seeds: ["pool", base_mint, quote_mint]
898
+ */
899
+ declare function getBonkPoolPDA(baseMint: PublicKey, quoteMint: PublicKey): PublicKey;
900
+ /**
901
+ * Get vault PDA for Bonk.
902
+ * Seeds: ["pool_vault", pool_state, mint]
903
+ */
904
+ declare function getBonkVaultPDA(poolState: PublicKey, mint: PublicKey): PublicKey;
905
+
906
+ /**
907
+ * Raydium CPMM (Concentrated Pool Market Maker) Protocol Instruction Builder
908
+ *
909
+ * Production-grade instruction builder for Raydium CPMM protocol.
910
+ * 100% port of Rust implementation.
911
+ */
912
+
913
+ /** Raydium CPMM program ID */
914
+ declare const RAYDIUM_CPMM_PROGRAM_ID: PublicKey;
915
+ /** Authority */
916
+ declare const RAYDIUM_CPMM_AUTHORITY: PublicKey;
917
+ /** Fee rates */
918
+ declare const RAYDIUM_CPMM_FEE_RATE_DENOMINATOR_VALUE: bigint;
919
+ declare const RAYDIUM_CPMM_TRADE_FEE_RATE: bigint;
920
+ declare const RAYDIUM_CPMM_CREATOR_FEE_RATE: bigint;
921
+ declare const RAYDIUM_CPMM_PROTOCOL_FEE_RATE: bigint;
922
+ declare const RAYDIUM_CPMM_FUND_FEE_RATE: bigint;
923
+ /** Swap base in instruction discriminator */
924
+ declare const RAYDIUM_CPMM_SWAP_BASE_IN_DISCRIMINATOR: Buffer;
925
+ /** Swap base out instruction discriminator */
926
+ declare const RAYDIUM_CPMM_SWAP_BASE_OUT_DISCRIMINATOR: Buffer;
927
+ declare const RAYDIUM_CPMM_POOL_SEED: Buffer<ArrayBuffer>;
928
+ declare const RAYDIUM_CPMM_POOL_VAULT_SEED: Buffer<ArrayBuffer>;
929
+ declare const RAYDIUM_CPMM_OBSERVATION_STATE_SEED: Buffer<ArrayBuffer>;
930
+ /**
931
+ * Derive the pool PDA for given config and mints
932
+ */
933
+ declare function getRaydiumCpmmPoolPda(ammConfig: PublicKey, mint1: PublicKey, mint2: PublicKey): PublicKey;
934
+ /**
935
+ * Derive the vault PDA for a pool and mint
936
+ */
937
+ declare function getRaydiumCpmmVaultPda(poolState: PublicKey, mint: PublicKey): PublicKey;
938
+ /**
939
+ * Derive the observation state PDA for a pool
940
+ */
941
+ declare function getRaydiumCpmmObservationStatePda(poolState: PublicKey): PublicKey;
942
+ /**
943
+ * Compute swap amount for CPMM
944
+ */
945
+ declare function computeRaydiumCpmmSwapAmount(baseReserve: bigint, quoteReserve: bigint, isBaseIn: boolean, amountIn: bigint, slippageBasisPoints: bigint): {
946
+ amountOut: bigint;
947
+ minAmountOut: bigint;
948
+ };
949
+ interface RaydiumCpmmParams$2 {
950
+ poolState?: PublicKey;
951
+ ammConfig: PublicKey;
952
+ baseMint: PublicKey;
953
+ quoteMint: PublicKey;
954
+ baseTokenProgram: PublicKey;
955
+ quoteTokenProgram: PublicKey;
956
+ baseVault?: PublicKey;
957
+ quoteVault?: PublicKey;
958
+ baseReserve: bigint;
959
+ quoteReserve: bigint;
960
+ observationState?: PublicKey;
961
+ }
962
+ interface BuildRaydiumCpmmBuyInstructionsParams {
963
+ payer: Keypair | PublicKey;
964
+ outputMint: PublicKey;
965
+ inputAmount: bigint;
966
+ slippageBasisPoints?: bigint;
967
+ fixedOutputAmount?: bigint;
968
+ createInputMintAta?: boolean;
969
+ createOutputMintAta?: boolean;
970
+ closeInputMintAta?: boolean;
971
+ protocolParams: RaydiumCpmmParams$2;
972
+ }
973
+ interface BuildRaydiumCpmmSellInstructionsParams {
974
+ payer: Keypair | PublicKey;
975
+ inputMint: PublicKey;
976
+ inputAmount: bigint;
977
+ slippageBasisPoints?: bigint;
978
+ fixedOutputAmount?: bigint;
979
+ createOutputMintAta?: boolean;
980
+ closeOutputMintAta?: boolean;
981
+ closeInputMintAta?: boolean;
982
+ protocolParams: RaydiumCpmmParams$2;
983
+ }
984
+ /**
985
+ * Build buy instructions for Raydium CPMM protocol
986
+ */
987
+ declare function buildRaydiumCpmmBuyInstructions(params: BuildRaydiumCpmmBuyInstructionsParams): TransactionInstruction[];
988
+ /**
989
+ * Build sell instructions for Raydium CPMM protocol
990
+ */
991
+ declare function buildRaydiumCpmmSellInstructions(params: BuildRaydiumCpmmSellInstructionsParams): TransactionInstruction[];
992
+ declare const RAYDIUM_CPMM_POOL_STATE_SIZE = 629;
993
+ interface RaydiumCPMMpoolState {
994
+ ammConfig: PublicKey;
995
+ poolCreator: PublicKey;
996
+ token0Vault: PublicKey;
997
+ token1Vault: PublicKey;
998
+ lpMint: PublicKey;
999
+ token0Mint: PublicKey;
1000
+ token1Mint: PublicKey;
1001
+ token0Program: PublicKey;
1002
+ token1Program: PublicKey;
1003
+ observationKey: PublicKey;
1004
+ authBump: number;
1005
+ status: number;
1006
+ lpMintDecimals: number;
1007
+ mint0Decimals: number;
1008
+ mint1Decimals: number;
1009
+ lpSupply: bigint;
1010
+ protocolFeesToken0: bigint;
1011
+ protocolFeesToken1: bigint;
1012
+ fundFeesToken0: bigint;
1013
+ fundFeesToken1: bigint;
1014
+ openTime: bigint;
1015
+ recentEpoch: bigint;
1016
+ }
1017
+ /**
1018
+ * Decode a Raydium CPMM pool state from account data
1019
+ * 100% from Rust: src/instruction/utils/raydium_cpmm_types.rs pool_state_decode
1020
+ */
1021
+ declare function decodeRaydiumCPMMpoolState(data: Buffer): RaydiumCPMMpoolState | null;
1022
+ /**
1023
+ * Fetch a Raydium CPMM pool state from RPC.
1024
+ * 100% from Rust: src/instruction/utils/raydium_cpmm.rs fetch_pool_state
1025
+ */
1026
+ declare function fetchRaydiumCPMMpoolState(connection: {
1027
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
1028
+ value?: {
1029
+ data: Buffer;
1030
+ };
1031
+ }>;
1032
+ }, poolAddress: PublicKey): Promise<RaydiumCPMMpoolState | null>;
1033
+ /**
1034
+ * Get pool PDA for Raydium CPMM.
1035
+ * Seeds: ["pool", amm_config, mint1, mint2]
1036
+ */
1037
+ declare function getRaydiumCPMMpoolPDA(ammConfig: PublicKey, mint1: PublicKey, mint2: PublicKey): PublicKey;
1038
+ /**
1039
+ * Get vault PDA for Raydium CPMM.
1040
+ * Seeds: ["pool_vault", pool_state, mint]
1041
+ */
1042
+ declare function getRaydiumCPMMvaultPDA(poolState: PublicKey, mint: PublicKey): PublicKey;
1043
+ /**
1044
+ * Get observation state PDA for Raydium CPMM.
1045
+ * Seeds: ["observation", pool_state]
1046
+ */
1047
+ declare function getRaydiumCPMMobservationStatePDA(poolState: PublicKey): PublicKey;
1048
+ /**
1049
+ * Get token balances for a Raydium CPMM pool.
1050
+ * 100% from Rust: src/instruction/utils/raydium_cpmm.rs get_pool_token_balances
1051
+ */
1052
+ declare function getRaydiumCPMMpoolTokenBalances(connection: {
1053
+ getTokenAccountBalance: (pubkey: PublicKey) => Promise<{
1054
+ value?: {
1055
+ amount: string;
1056
+ };
1057
+ }>;
1058
+ }, poolState: PublicKey, token0Mint: PublicKey, token1Mint: PublicKey): Promise<{
1059
+ token0Balance: bigint;
1060
+ token1Balance: bigint;
1061
+ } | null>;
1062
+
1063
+ /**
1064
+ * Raydium AMM V4 Protocol Instruction Builder
1065
+ *
1066
+ * Production-grade instruction builder for Raydium AMM V4 protocol.
1067
+ * 100% port of Rust implementation.
1068
+ */
1069
+
1070
+ /** Raydium AMM V4 program ID */
1071
+ declare const RAYDIUM_AMM_V4_PROGRAM_ID: PublicKey;
1072
+ /** Authority */
1073
+ declare const RAYDIUM_AMM_V4_AUTHORITY: PublicKey;
1074
+ /** Fee rates */
1075
+ declare const RAYDIUM_AMM_V4_TRADE_FEE_NUMERATOR: bigint;
1076
+ declare const RAYDIUM_AMM_V4_TRADE_FEE_DENOMINATOR: bigint;
1077
+ declare const RAYDIUM_AMM_V4_SWAP_FEE_NUMERATOR: bigint;
1078
+ declare const RAYDIUM_AMM_V4_SWAP_FEE_DENOMINATOR: bigint;
1079
+ /** Swap base in instruction discriminator (single byte) */
1080
+ declare const RAYDIUM_AMM_V4_SWAP_BASE_IN_DISCRIMINATOR: Buffer;
1081
+ /** Swap base out instruction discriminator (single byte) */
1082
+ declare const RAYDIUM_AMM_V4_SWAP_BASE_OUT_DISCRIMINATOR: Buffer;
1083
+ declare const RAYDIUM_AMM_V4_POOL_SEED: Buffer<ArrayBuffer>;
1084
+ /**
1085
+ * Compute swap amount for AMM V4
1086
+ */
1087
+ declare function computeRaydiumAmmV4SwapAmount(coinReserve: bigint, pcReserve: bigint, isCoinIn: boolean, amountIn: bigint, slippageBasisPoints: bigint): {
1088
+ amountOut: bigint;
1089
+ minAmountOut: bigint;
1090
+ };
1091
+ interface RaydiumAmmV4Params$2 {
1092
+ amm: PublicKey;
1093
+ coinMint: PublicKey;
1094
+ pcMint: PublicKey;
1095
+ tokenCoin: PublicKey;
1096
+ tokenPc: PublicKey;
1097
+ ammOpenOrders: PublicKey;
1098
+ ammTargetOrders: PublicKey;
1099
+ serumProgram: PublicKey;
1100
+ serumMarket: PublicKey;
1101
+ serumBids: PublicKey;
1102
+ serumAsks: PublicKey;
1103
+ serumEventQueue: PublicKey;
1104
+ serumCoinVaultAccount: PublicKey;
1105
+ serumPcVaultAccount: PublicKey;
1106
+ serumVaultSigner: PublicKey;
1107
+ coinReserve: bigint;
1108
+ pcReserve: bigint;
1109
+ }
1110
+ interface BuildRaydiumAmmV4BuyInstructionsParams {
1111
+ payer: Keypair | PublicKey;
1112
+ outputMint: PublicKey;
1113
+ inputAmount: bigint;
1114
+ slippageBasisPoints?: bigint;
1115
+ fixedOutputAmount?: bigint;
1116
+ createInputMintAta?: boolean;
1117
+ createOutputMintAta?: boolean;
1118
+ closeInputMintAta?: boolean;
1119
+ protocolParams: RaydiumAmmV4Params$2;
1120
+ }
1121
+ interface BuildRaydiumAmmV4SellInstructionsParams {
1122
+ payer: Keypair | PublicKey;
1123
+ inputMint: PublicKey;
1124
+ outputMint?: PublicKey;
1125
+ inputAmount: bigint;
1126
+ slippageBasisPoints?: bigint;
1127
+ fixedOutputAmount?: bigint;
1128
+ createOutputMintAta?: boolean;
1129
+ closeOutputMintAta?: boolean;
1130
+ closeInputMintAta?: boolean;
1131
+ protocolParams: RaydiumAmmV4Params$2;
1132
+ }
1133
+ /**
1134
+ * Build buy instructions for Raydium AMM V4 protocol
1135
+ */
1136
+ declare function buildRaydiumAmmV4BuyInstructions(params: BuildRaydiumAmmV4BuyInstructionsParams): TransactionInstruction[];
1137
+ /**
1138
+ * Build sell instructions for Raydium AMM V4 protocol
1139
+ */
1140
+ declare function buildRaydiumAmmV4SellInstructions(params: BuildRaydiumAmmV4SellInstructionsParams): TransactionInstruction[];
1141
+ declare const AMM_INFO_SIZE = 752;
1142
+ interface RaydiumAmmFees {
1143
+ minSeparateNumerator: bigint;
1144
+ minSeparateDenominator: bigint;
1145
+ tradeFeeNumerator: bigint;
1146
+ tradeFeeDenominator: bigint;
1147
+ pnlNumerator: bigint;
1148
+ pnlDenominator: bigint;
1149
+ swapFeeNumerator: bigint;
1150
+ swapFeeDenominator: bigint;
1151
+ }
1152
+ interface RaydiumAmmOutputData {
1153
+ needTakePnlCoin: bigint;
1154
+ needTakePnlPc: bigint;
1155
+ totalPnlPc: bigint;
1156
+ totalPnlCoin: bigint;
1157
+ poolOpenTime: bigint;
1158
+ punishPcAmount: bigint;
1159
+ punishCoinAmount: bigint;
1160
+ orderbookToInitTime: bigint;
1161
+ swapCoinInAmount: bigint;
1162
+ swapPcOutAmount: bigint;
1163
+ swapTakePcFee: bigint;
1164
+ swapPcInAmount: bigint;
1165
+ swapCoinOutAmount: bigint;
1166
+ swapTakeCoinFee: bigint;
1167
+ }
1168
+ interface RaydiumAmmInfo {
1169
+ status: bigint;
1170
+ nonce: bigint;
1171
+ orderNum: bigint;
1172
+ depth: bigint;
1173
+ coinDecimals: bigint;
1174
+ pcDecimals: bigint;
1175
+ state: bigint;
1176
+ resetFlag: bigint;
1177
+ minSize: bigint;
1178
+ volMaxCutRatio: bigint;
1179
+ amountWave: bigint;
1180
+ coinLotSize: bigint;
1181
+ pcLotSize: bigint;
1182
+ minPriceMultiplier: bigint;
1183
+ maxPriceMultiplier: bigint;
1184
+ sysDecimalValue: bigint;
1185
+ fees: RaydiumAmmFees;
1186
+ output: RaydiumAmmOutputData;
1187
+ tokenCoin: PublicKey;
1188
+ tokenPc: PublicKey;
1189
+ coinMint: PublicKey;
1190
+ pcMint: PublicKey;
1191
+ lpMint: PublicKey;
1192
+ openOrders: PublicKey;
1193
+ market: PublicKey;
1194
+ serumDex: PublicKey;
1195
+ targetOrders: PublicKey;
1196
+ withdrawQueue: PublicKey;
1197
+ tokenTempLp: PublicKey;
1198
+ ammOwner: PublicKey;
1199
+ lpAmount: bigint;
1200
+ clientOrderId: bigint;
1201
+ }
1202
+ interface RaydiumMarketState {
1203
+ vaultSignerNonce: bigint;
1204
+ serumCoinVaultAccount: PublicKey;
1205
+ serumPcVaultAccount: PublicKey;
1206
+ serumEventQueue: PublicKey;
1207
+ serumBids: PublicKey;
1208
+ serumAsks: PublicKey;
1209
+ }
1210
+ declare const MARKET_STATE_SIZE = 388;
1211
+ /**
1212
+ * Decode Raydium AMM v4 info from account data.
1213
+ * 100% from Rust: src/instruction/utils/raydium_amm_v4_types.rs amm_info_decode
1214
+ */
1215
+ declare function decodeAmmInfo(data: Buffer): RaydiumAmmInfo | null;
1216
+ declare function decodeMarketState(data: Buffer): RaydiumMarketState | null;
1217
+ declare function deriveSerumVaultSigner(serumProgram: PublicKey, serumMarket: PublicKey, vaultSignerNonce: bigint): PublicKey;
1218
+ /**
1219
+ * Fetch AMM info from RPC.
1220
+ * 100% from Rust: src/instruction/utils/raydium_amm_v4.rs fetch_amm_info
1221
+ */
1222
+ declare function fetchAmmInfo(connection: {
1223
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
1224
+ value?: {
1225
+ data: Buffer;
1226
+ };
1227
+ }>;
1228
+ }, amm: PublicKey): Promise<RaydiumAmmInfo | null>;
1229
+ declare function fetchMarketState(connection: {
1230
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
1231
+ value?: {
1232
+ data: Buffer;
1233
+ };
1234
+ }>;
1235
+ }, market: PublicKey): Promise<RaydiumMarketState | null>;
1236
+
1237
+ /**
1238
+ * Meteora DAMM V2 Protocol Instruction Builder
1239
+ *
1240
+ * Production-grade instruction builder for Meteora DAMM V2 protocol.
1241
+ * 100% port of Rust implementation.
1242
+ */
1243
+
1244
+ /** Meteora DAMM V2 program ID */
1245
+ declare const METEORA_DAMM_V2_PROGRAM_ID: PublicKey;
1246
+ /** Authority */
1247
+ declare const METEORA_DAMM_V2_AUTHORITY: PublicKey;
1248
+ /** Swap instruction discriminator */
1249
+ declare const METEORA_DAMM_V2_SWAP_DISCRIMINATOR: Buffer;
1250
+ declare const METEORA_DAMM_V2_SWAP2_DISCRIMINATOR: Buffer;
1251
+ declare const METEORA_DAMM_V2_SWAP_MODE_PARTIAL_FILL = 1;
1252
+ declare const METEORA_DAMM_V2_EVENT_AUTHORITY_SEED: Buffer<ArrayBuffer>;
1253
+ /**
1254
+ * Derive the event authority PDA
1255
+ */
1256
+ declare function getMeteoraDammV2EventAuthorityPda(): PublicKey;
1257
+ interface MeteoraDammV2Params$2 {
1258
+ pool: PublicKey;
1259
+ tokenAMint: PublicKey;
1260
+ tokenBMint: PublicKey;
1261
+ tokenAVault: PublicKey;
1262
+ tokenBVault: PublicKey;
1263
+ tokenAProgram: PublicKey;
1264
+ tokenBProgram: PublicKey;
1265
+ }
1266
+ interface BuildMeteoraDammV2BuyInstructionsParams {
1267
+ payer: Keypair | PublicKey;
1268
+ inputMint: PublicKey;
1269
+ outputMint: PublicKey;
1270
+ inputAmount: bigint;
1271
+ slippageBasisPoints?: bigint;
1272
+ fixedOutputAmount?: bigint;
1273
+ createInputMintAta?: boolean;
1274
+ createOutputMintAta?: boolean;
1275
+ closeInputMintAta?: boolean;
1276
+ protocolParams: MeteoraDammV2Params$2;
1277
+ }
1278
+ interface BuildMeteoraDammV2SellInstructionsParams {
1279
+ payer: Keypair | PublicKey;
1280
+ inputMint: PublicKey;
1281
+ outputMint: PublicKey;
1282
+ inputAmount: bigint;
1283
+ slippageBasisPoints?: bigint;
1284
+ fixedOutputAmount?: bigint;
1285
+ createOutputMintAta?: boolean;
1286
+ closeOutputMintAta?: boolean;
1287
+ closeInputMintAta?: boolean;
1288
+ protocolParams: MeteoraDammV2Params$2;
1289
+ }
1290
+ /**
1291
+ * Build buy instructions for Meteora DAMM V2 protocol
1292
+ */
1293
+ declare function buildMeteoraDammV2BuyInstructions(params: BuildMeteoraDammV2BuyInstructionsParams): TransactionInstruction[];
1294
+ /**
1295
+ * Build sell instructions for Meteora DAMM V2 protocol
1296
+ */
1297
+ declare function buildMeteoraDammV2SellInstructions(params: BuildMeteoraDammV2SellInstructionsParams): TransactionInstruction[];
1298
+ /** Pool size in bytes */
1299
+ declare const METEORA_POOL_SIZE = 1104;
1300
+ /**
1301
+ * Meteora DAMM V2 Pool structure (simplified for essential fields)
1302
+ * 100% from Rust: src/instruction/utils/meteora_damm_v2_types.rs Pool
1303
+ */
1304
+ interface MeteoraDammV2Pool {
1305
+ tokenAMint: PublicKey;
1306
+ tokenBMint: PublicKey;
1307
+ tokenAVault: PublicKey;
1308
+ tokenBVault: PublicKey;
1309
+ liquidity: bigint;
1310
+ sqrtPrice: bigint;
1311
+ poolStatus: number;
1312
+ tokenAFlag: number;
1313
+ tokenBFlag: number;
1314
+ }
1315
+ /**
1316
+ * Decode a Meteora DAMM V2 pool from account data.
1317
+ * 100% from Rust: src/instruction/utils/meteora_damm_v2_types.rs pool_decode
1318
+ */
1319
+ declare function decodeMeteoraPool(data: Buffer): MeteoraDammV2Pool | null;
1320
+ /**
1321
+ * Fetch a Meteora DAMM V2 pool from RPC.
1322
+ * 100% from Rust: src/instruction/utils/meteora_damm_v2.rs fetch_pool
1323
+ */
1324
+ declare function fetchMeteoraPool(connection: {
1325
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
1326
+ value?: {
1327
+ data: Buffer;
1328
+ owner?: PublicKey;
1329
+ };
1330
+ }>;
1331
+ }, poolAddress: PublicKey): Promise<MeteoraDammV2Pool | null>;
1332
+
1333
+ /**
1334
+ * Utility functions for Sol Trade SDK
1335
+ */
1336
+
1337
+ /**
1338
+ * Calculate amount with slippage for buy operations
1339
+ *
1340
+ * Note: Basis points are clamped to MAX_SLIPPAGE_BASIS_POINTS (9999 = 99.99%)
1341
+ * to prevent the amount from doubling when slippageBasisPoints = 10000.
1342
+ */
1343
+ declare function calculateWithSlippageBuy(amount: bigint, slippageBasisPoints: number): bigint;
1344
+ /**
1345
+ * Calculate amount with slippage for sell operations
1346
+ */
1347
+ declare function calculateWithSlippageSell(amount: bigint, slippageBasisPoints: number): bigint;
1348
+ /**
1349
+ * Calculate buy token amount from SOL amount for PumpFun
1350
+ */
1351
+ declare function getBuyTokenAmountFromSolAmount(virtualTokenReserves: bigint, virtualSolReserves: bigint, _realTokenReserves: bigint, _creatorFee: number, solAmount: bigint): bigint;
1352
+ /**
1353
+ * Calculate sell SOL amount from token amount for PumpFun
1354
+ */
1355
+ declare function getSellSolAmountFromTokenAmount(virtualTokenReserves: bigint, virtualSolReserves: bigint, _creatorFee: number, tokenAmount: bigint): bigint;
1356
+ /**
1357
+ * Convert lamports to SOL
1358
+ */
1359
+ declare function lamportsToSol(lamports: number | bigint): number;
1360
+ /**
1361
+ * Convert SOL to lamports
1362
+ */
1363
+ declare function solToLamports(sol: number): bigint;
1364
+ /**
1365
+ * Get current timestamp in microseconds
1366
+ */
1367
+ declare function nowMicroseconds(): bigint;
1368
+ /**
1369
+ * Validate public key string
1370
+ */
1371
+ declare function isValidPublicKey(key: string): boolean;
1372
+ /**
1373
+ * Sleep for specified milliseconds
1374
+ */
1375
+ declare function sleep(ms: number): Promise<void>;
1376
+ /**
1377
+ * Format public key for display (truncated)
1378
+ */
1379
+ declare function formatPublicKey(key: PublicKey | string, chars?: number): string;
1380
+ /**
1381
+ * Calculate price impact percentage
1382
+ */
1383
+ declare function calculatePriceImpact(reserveIn: bigint, amountIn: bigint): number;
1384
+ /**
1385
+ * Retry a function with exponential backoff
1386
+ */
1387
+ declare function retryWithBackoff<T>(fn: () => Promise<T>, maxRetries?: number, baseDelayMs?: number): Promise<T>;
1388
+
1389
+ /**
1390
+ * Hot Path State Management for Sol Trade SDK
1391
+ *
1392
+ * Manages prefetched blockchain state for zero-latency trading execution.
1393
+ * NO RPC calls are made during trading - all data is prefetched.
1394
+ *
1395
+ * Key principle: Prepare everything before the trade, execute with minimal latency.
1396
+ */
1397
+
1398
+ interface HotPathConfig {
1399
+ blockhashRefreshIntervalMs: number;
1400
+ cacheTtlMs: number;
1401
+ enablePrefetch: boolean;
1402
+ prefetchTimeoutMs: number;
1403
+ }
1404
+ declare function defaultHotPathConfig(): HotPathConfig;
1405
+ interface PrefetchedData {
1406
+ blockhash: string;
1407
+ lastValidBlockHeight: number;
1408
+ slot: number;
1409
+ fetchedAt: number;
1410
+ }
1411
+ interface AccountState {
1412
+ pubkey: string;
1413
+ data: Buffer;
1414
+ lamports: bigint;
1415
+ owner: string;
1416
+ executable: boolean;
1417
+ rentEpoch: number;
1418
+ slot: number;
1419
+ fetchedAt: number;
1420
+ }
1421
+ interface PoolState {
1422
+ poolAddress: string;
1423
+ poolType: 'pumpfun' | 'pumpswap' | 'raydium' | 'meteora';
1424
+ mintA: string;
1425
+ mintB: string;
1426
+ vaultA: string;
1427
+ vaultB: string;
1428
+ reserveA: bigint;
1429
+ reserveB: bigint;
1430
+ feeRate: number;
1431
+ fetchedAt: number;
1432
+ rawData?: Buffer;
1433
+ }
1434
+ declare class HotPathState {
1435
+ private config;
1436
+ private connection;
1437
+ private currentData;
1438
+ private accounts;
1439
+ private pools;
1440
+ private prefetchTimer?;
1441
+ private isRunning;
1442
+ private onBlockhashUpdateCallback?;
1443
+ private metrics;
1444
+ constructor(connection: Connection, config?: Partial<HotPathConfig>);
1445
+ /**
1446
+ * Start background prefetching
1447
+ * Call this BEFORE any hot path execution
1448
+ */
1449
+ start(): Promise<void>;
1450
+ /**
1451
+ * Stop background prefetching
1452
+ */
1453
+ stop(): void;
1454
+ /**
1455
+ * Check if prefetching is active
1456
+ */
1457
+ isActive(): boolean;
1458
+ /**
1459
+ * Prefetch latest blockhash - RPC call happens here (background only)
1460
+ */
1461
+ private prefetchBlockhash;
1462
+ /**
1463
+ * Get current cached blockhash - NO RPC CALL
1464
+ */
1465
+ getBlockhash(): {
1466
+ blockhash: string;
1467
+ lastValidBlockHeight: number;
1468
+ } | null;
1469
+ /**
1470
+ * Check if prefetched data is still valid
1471
+ */
1472
+ isDataFresh(): boolean;
1473
+ /**
1474
+ * Get all prefetched data
1475
+ */
1476
+ getPrefetchedData(): PrefetchedData | null;
1477
+ /**
1478
+ * Set callback for blockhash updates
1479
+ */
1480
+ onBlockhashUpdate(callback: (blockhash: string, lastValidBlockHeight: number) => void): void;
1481
+ /**
1482
+ * Update account state in cache
1483
+ */
1484
+ updateAccount(pubkey: string, state: AccountState): void;
1485
+ /**
1486
+ * Get account state from cache - NO RPC CALL
1487
+ */
1488
+ getAccount(pubkey: string): AccountState | null;
1489
+ /**
1490
+ * Get multiple account states - NO RPC CALL
1491
+ */
1492
+ getAccounts(pubkeys: string[]): Map<string, AccountState>;
1493
+ /**
1494
+ * Prefetch accounts - RPC call happens here (before trading)
1495
+ * Call this BEFORE entering the hot path
1496
+ */
1497
+ prefetchAccounts(pubkeys: string[]): Promise<void>;
1498
+ /**
1499
+ * Update pool state in cache
1500
+ */
1501
+ updatePool(poolAddress: string, state: PoolState): void;
1502
+ /**
1503
+ * Get pool state from cache - NO RPC CALL
1504
+ */
1505
+ getPool(poolAddress: string): PoolState | null;
1506
+ getMetrics(): {
1507
+ prefetchCount: number;
1508
+ prefetchErrors: number;
1509
+ lastPrefetchTime: number;
1510
+ accountsCached: number;
1511
+ poolsCached: number;
1512
+ dataFresh: boolean;
1513
+ };
1514
+ }
1515
+ /**
1516
+ * Trading context with all prefetched data needed for a trade.
1517
+ * Created BEFORE hot path execution, contains all necessary state.
1518
+ * NO RPC calls during trade execution.
1519
+ */
1520
+ declare class TradingContext {
1521
+ readonly payer: string;
1522
+ readonly blockhash: string;
1523
+ readonly lastValidBlockHeight: number;
1524
+ readonly createdAt: number;
1525
+ readonly accountStates: Map<string, AccountState>;
1526
+ readonly poolStates: Map<string, PoolState>;
1527
+ constructor(hotPathState: HotPathState, payer: string);
1528
+ /**
1529
+ * Add account state from cache
1530
+ */
1531
+ addAccount(pubkey: string, hotPathState: HotPathState): boolean;
1532
+ /**
1533
+ * Add pool state from cache
1534
+ */
1535
+ addPool(poolAddress: string, hotPathState: HotPathState): boolean;
1536
+ /**
1537
+ * Get age of context in milliseconds
1538
+ */
1539
+ age(): number;
1540
+ /**
1541
+ * Check if context is still valid
1542
+ */
1543
+ isValid(maxAgeMs?: number): boolean;
1544
+ /**
1545
+ * Get token account data from context
1546
+ */
1547
+ getTokenAccountData(pubkey: string): Buffer | undefined;
1548
+ }
1549
+ declare class HotPathError extends Error {
1550
+ constructor(message: string);
1551
+ }
1552
+ declare class StaleBlockhashError extends HotPathError {
1553
+ constructor(message?: string);
1554
+ }
1555
+ declare class MissingAccountError extends HotPathError {
1556
+ constructor(message?: string);
1557
+ }
1558
+ declare class ContextExpiredError extends HotPathError {
1559
+ constructor(message?: string);
1560
+ }
1561
+
1562
+ /**
1563
+ * SWQOS Clients for Sol Trade SDK
1564
+ * Implements various SWQOS (Solana Write Queue Operating System) providers.
1565
+ */
1566
+
1567
+ declare function randomChoice<T>(arr: T[]): T;
1568
+ declare const MIN_TIP_JITO = 0.00001;
1569
+ declare const MIN_TIP_BLOXROUTE = 0.0001;
1570
+ declare const MIN_TIP_ZERO_SLOT = 0.0001;
1571
+ declare const MIN_TIP_TEMPORAL = 0.0001;
1572
+ declare const MIN_TIP_FLASH_BLOCK = 0.0001;
1573
+ declare const MIN_TIP_BLOCK_RAZOR = 0.0001;
1574
+ declare const MIN_TIP_NODE1 = 0.0001;
1575
+ declare const MIN_TIP_ASTRALANE = 0.00001;
1576
+ declare const MIN_TIP_HELIUS = 0.000005;
1577
+ declare const MIN_TIP_HELIUS_NORMAL = 0.0002;
1578
+ declare const MIN_TIP_STELLIUM = 0.0001;
1579
+ declare const MIN_TIP_LIGHTSPEED = 0.0001;
1580
+ declare const MIN_TIP_NEXT_BLOCK = 0.001;
1581
+ declare const MIN_TIP_SOYAS = 0.001;
1582
+ declare const MIN_TIP_SPEEDLANDING = 0.001;
1583
+ declare const MIN_TIP_DEFAULT = 0;
1584
+ declare const JITO_ENDPOINTS: Record<SwqosRegion, string>;
1585
+ declare const BLOXROUTE_ENDPOINTS: Record<SwqosRegion, string>;
1586
+ declare const ZERO_SLOT_ENDPOINTS: Record<SwqosRegion, string>;
1587
+ declare const TEMPORAL_ENDPOINTS: Record<SwqosRegion, string>;
1588
+ declare const FLASH_BLOCK_ENDPOINTS: Record<SwqosRegion, string>;
1589
+ declare const HELIUS_ENDPOINTS: Record<SwqosRegion, string>;
1590
+ declare const NODE1_ENDPOINTS: Record<SwqosRegion, string>;
1591
+ declare const BLOCK_RAZOR_ENDPOINTS: Record<SwqosRegion, string>;
1592
+ declare const ASTRALANE_ENDPOINTS: Record<SwqosRegion, string>;
1593
+ declare const ASTRALANE_QUIC_HOSTS: Record<SwqosRegion, string>;
1594
+ declare const STELLIUM_ENDPOINTS: Record<SwqosRegion, string>;
1595
+ declare const NEXT_BLOCK_ENDPOINTS: Record<SwqosRegion, string>;
1596
+ declare const SOYAS_ENDPOINTS: Record<SwqosRegion, string>;
1597
+ declare const SPEEDLANDING_ENDPOINTS: Record<SwqosRegion, string>;
1598
+ interface SwqosClient {
1599
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1600
+ sendTransactions(tradeType: TradeType, transactions: Buffer[], waitConfirmation: boolean): Promise<string[]>;
1601
+ getTipAccount(): string;
1602
+ getSwqosType(): SwqosType;
1603
+ minTipSol(): number;
1604
+ }
1605
+ declare abstract class BaseClient implements SwqosClient {
1606
+ abstract getTipAccount(): string;
1607
+ abstract getSwqosType(): SwqosType;
1608
+ abstract minTipSol(): number;
1609
+ abstract sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1610
+ sendTransactions(tradeType: TradeType, transactions: Buffer[], waitConfirmation: boolean): Promise<string[]>;
1611
+ protected post(url: string, payload: unknown, headers?: Record<string, string>): Promise<unknown>;
1612
+ protected postRaw(url: string, body: string, headers?: Record<string, string>): Promise<unknown>;
1613
+ }
1614
+ declare class JitoClient extends BaseClient {
1615
+ private rpcUrl;
1616
+ private endpoint;
1617
+ private authToken?;
1618
+ private tipAccounts;
1619
+ constructor(rpcUrl: string, endpoint: string, authToken?: string | undefined);
1620
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1621
+ sendTransactions(tradeType: TradeType, transactions: Buffer[], waitConfirmation: boolean): Promise<string[]>;
1622
+ getTipAccount(): string;
1623
+ getSwqosType(): SwqosType;
1624
+ minTipSol(): number;
1625
+ }
1626
+ declare class BloxrouteClient extends BaseClient {
1627
+ private rpcUrl;
1628
+ private endpoint;
1629
+ private authToken?;
1630
+ private tipAccounts;
1631
+ constructor(rpcUrl: string, endpoint: string, authToken?: string | undefined);
1632
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1633
+ getTipAccount(): string;
1634
+ getSwqosType(): SwqosType;
1635
+ minTipSol(): number;
1636
+ }
1637
+ declare class ZeroSlotClient extends BaseClient {
1638
+ private rpcUrl;
1639
+ private endpoint;
1640
+ private authToken?;
1641
+ private tipAccounts;
1642
+ constructor(rpcUrl: string, endpoint: string, authToken?: string | undefined);
1643
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1644
+ getTipAccount(): string;
1645
+ getSwqosType(): SwqosType;
1646
+ minTipSol(): number;
1647
+ }
1648
+ declare class TemporalClient extends BaseClient {
1649
+ private rpcUrl;
1650
+ private endpoint;
1651
+ private authToken?;
1652
+ private tipAccounts;
1653
+ constructor(rpcUrl: string, endpoint: string, authToken?: string | undefined);
1654
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1655
+ getTipAccount(): string;
1656
+ getSwqosType(): SwqosType;
1657
+ minTipSol(): number;
1658
+ }
1659
+ declare class FlashBlockClient extends BaseClient {
1660
+ private rpcUrl;
1661
+ private endpoint;
1662
+ private authToken?;
1663
+ private tipAccounts;
1664
+ constructor(rpcUrl: string, endpoint: string, authToken?: string | undefined);
1665
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1666
+ getTipAccount(): string;
1667
+ getSwqosType(): SwqosType;
1668
+ minTipSol(): number;
1669
+ }
1670
+ declare class HeliusClient extends BaseClient {
1671
+ private rpcUrl;
1672
+ private endpoint;
1673
+ private apiKey?;
1674
+ private swqosOnly;
1675
+ private tipAccounts;
1676
+ constructor(rpcUrl: string, endpoint: string, apiKey?: string | undefined, swqosOnly?: boolean);
1677
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1678
+ getTipAccount(): string;
1679
+ getSwqosType(): SwqosType;
1680
+ minTipSol(): number;
1681
+ }
1682
+ declare class Node1Client extends BaseClient {
1683
+ private rpcUrl;
1684
+ private endpoint;
1685
+ private authToken?;
1686
+ private tipAccounts;
1687
+ constructor(rpcUrl: string, endpoint: string, authToken?: string | undefined);
1688
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1689
+ getTipAccount(): string;
1690
+ getSwqosType(): SwqosType;
1691
+ minTipSol(): number;
1692
+ }
1693
+ declare class Node1QuicClient implements SwqosClient {
1694
+ private readonly rpcUrl;
1695
+ private readonly endpoint;
1696
+ private readonly authToken;
1697
+ private readonly tipAccounts;
1698
+ private readonly host;
1699
+ private readonly port;
1700
+ constructor(rpcUrl: string, endpoint: string, authToken: string);
1701
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1702
+ sendTransactions(tradeType: TradeType, transactions: Buffer[], waitConfirmation: boolean): Promise<string[]>;
1703
+ getTipAccount(): string;
1704
+ getSwqosType(): SwqosType;
1705
+ minTipSol(): number;
1706
+ }
1707
+ declare class BlockRazorClient extends BaseClient {
1708
+ private rpcUrl;
1709
+ private endpoint;
1710
+ private authToken?;
1711
+ private mevProtection;
1712
+ private tipAccounts;
1713
+ constructor(rpcUrl: string, endpoint: string, authToken?: string | undefined, mevProtection?: boolean);
1714
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1715
+ getTipAccount(): string;
1716
+ getSwqosType(): SwqosType;
1717
+ minTipSol(): number;
1718
+ }
1719
+ declare class AstralaneClient extends BaseClient {
1720
+ private rpcUrl;
1721
+ private endpoint;
1722
+ private authToken?;
1723
+ private tipAccounts;
1724
+ constructor(rpcUrl: string, endpoint: string, authToken?: string | undefined);
1725
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1726
+ getTipAccount(): string;
1727
+ getSwqosType(): SwqosType;
1728
+ minTipSol(): number;
1729
+ }
1730
+ declare class AstralaneQuicClient implements SwqosClient {
1731
+ private readonly rpcUrl;
1732
+ private readonly endpoint;
1733
+ private readonly authToken;
1734
+ private readonly tipAccounts;
1735
+ private readonly host;
1736
+ private readonly port;
1737
+ constructor(rpcUrl: string, endpoint: string, authToken: string);
1738
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1739
+ sendTransactions(tradeType: TradeType, transactions: Buffer[], waitConfirmation: boolean): Promise<string[]>;
1740
+ getTipAccount(): string;
1741
+ getSwqosType(): SwqosType;
1742
+ minTipSol(): number;
1743
+ }
1744
+ declare class StelliumClient extends BaseClient {
1745
+ private rpcUrl;
1746
+ private endpoint;
1747
+ private authToken?;
1748
+ private tipAccounts;
1749
+ constructor(rpcUrl: string, endpoint: string, authToken?: string | undefined);
1750
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1751
+ getTipAccount(): string;
1752
+ getSwqosType(): SwqosType;
1753
+ minTipSol(): number;
1754
+ }
1755
+ declare class LightspeedClient extends BaseClient {
1756
+ private rpcUrl;
1757
+ private customUrl;
1758
+ constructor(rpcUrl: string, customUrl: string);
1759
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1760
+ getTipAccount(): string;
1761
+ getSwqosType(): SwqosType;
1762
+ minTipSol(): number;
1763
+ }
1764
+ declare class NextBlockClient extends BaseClient {
1765
+ private rpcUrl;
1766
+ private endpoint;
1767
+ private authToken?;
1768
+ private tipAccounts;
1769
+ constructor(rpcUrl: string, endpoint: string, authToken?: string | undefined);
1770
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1771
+ getTipAccount(): string;
1772
+ getSwqosType(): SwqosType;
1773
+ minTipSol(): number;
1774
+ }
1775
+ declare class DefaultClient extends BaseClient {
1776
+ private rpcUrl;
1777
+ constructor(rpcUrl: string);
1778
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1779
+ getTipAccount(): string;
1780
+ getSwqosType(): SwqosType;
1781
+ minTipSol(): number;
1782
+ }
1783
+ /**
1784
+ * Soyas SWQOS client.
1785
+ *
1786
+ * Transport: QUIC with self-signed Ed25519 cert, ALPN "solana-tpu".
1787
+ * Endpoint: host:port (e.g. nyc.landing.soyas.xyz:9000)
1788
+ * SNI: "soyas-landing" (matches Rust SDK SOYAS_SERVER constant)
1789
+ * Requires: npm install @matrixai/quic selfsigned
1790
+ */
1791
+ declare class SoyasClient implements SwqosClient {
1792
+ private readonly rpcUrl;
1793
+ private readonly endpoint;
1794
+ private readonly apiKey?;
1795
+ private readonly tipAccount;
1796
+ private readonly host;
1797
+ private readonly port;
1798
+ constructor(rpcUrl: string, endpoint: string, apiKey?: string | undefined);
1799
+ sendTransaction(_tradeType: TradeType, transaction: Buffer, _waitConfirmation: boolean): Promise<string>;
1800
+ sendTransactions(tradeType: TradeType, transactions: Buffer[], waitConfirmation: boolean): Promise<string[]>;
1801
+ getTipAccount(): string;
1802
+ getSwqosType(): SwqosType;
1803
+ minTipSol(): number;
1804
+ }
1805
+ /**
1806
+ * Speedlanding SWQOS client.
1807
+ *
1808
+ * Transport: QUIC with self-signed Ed25519 cert, ALPN "solana-tpu".
1809
+ * Endpoint: host:port (e.g. nyc.speedlanding.trade:17778)
1810
+ * SNI: derived from hostname; falls back to "speed-landing" for bare IPs
1811
+ * (matches Rust SDK behavior).
1812
+ * Requires: npm install @matrixai/quic selfsigned
1813
+ */
1814
+ declare class SpeedlandingClient implements SwqosClient {
1815
+ private readonly rpcUrl;
1816
+ private readonly endpoint;
1817
+ private readonly apiKey?;
1818
+ private readonly tipAccount;
1819
+ private readonly host;
1820
+ private readonly port;
1821
+ private readonly serverName;
1822
+ constructor(rpcUrl: string, endpoint: string, apiKey?: string | undefined);
1823
+ sendTransaction(_tradeType: TradeType, transaction: Buffer, _waitConfirmation: boolean): Promise<string>;
1824
+ sendTransactions(tradeType: TradeType, transactions: Buffer[], waitConfirmation: boolean): Promise<string[]>;
1825
+ getTipAccount(): string;
1826
+ getSwqosType(): SwqosType;
1827
+ minTipSol(): number;
1828
+ }
1829
+ interface SwqosClientConfig {
1830
+ type: SwqosType;
1831
+ region?: SwqosRegion;
1832
+ customUrl?: string;
1833
+ apiKey?: string;
1834
+ mevProtection?: boolean;
1835
+ transport?: SwqosTransport;
1836
+ astralaneTransport?: AstralaneTransport;
1837
+ swqosOnly?: boolean;
1838
+ }
1839
+ declare class ClientFactory {
1840
+ static createClient(config: SwqosClientConfig, rpcUrl: string): SwqosClient;
1841
+ }
1842
+ declare function createSwqosClient(swqosType: SwqosType, rpcUrl: string, authToken?: string, region?: SwqosRegion, customUrl?: string, mevProtection?: boolean): SwqosClient;
1843
+
1844
+ /**
1845
+ * Hot Path Executor for Sol Trade SDK
1846
+ *
1847
+ * Executes trades with ZERO RPC calls in the hot path.
1848
+ * All data must be prefetched before execution.
1849
+ *
1850
+ * Key principle: Prepare everything, then execute with minimal latency.
1851
+ */
1852
+
1853
+ interface ExecuteOptions {
1854
+ parallelSubmit: boolean;
1855
+ timeoutMs: number;
1856
+ skipBlockhashValidation: boolean;
1857
+ maxRetries: number;
1858
+ }
1859
+ declare function defaultExecuteOptions(): ExecuteOptions;
1860
+ interface ExecuteResult {
1861
+ signature: string;
1862
+ success: boolean;
1863
+ error?: string;
1864
+ latencyMs: number;
1865
+ swqosType?: SwqosType;
1866
+ blockhashUsed: string;
1867
+ }
1868
+ interface GasFeeConfig {
1869
+ computeUnitLimit: number;
1870
+ computeUnitPrice: number;
1871
+ }
1872
+ declare class HotPathMetrics {
1873
+ private totalTrades;
1874
+ private successTrades;
1875
+ private failedTrades;
1876
+ private totalLatencyMs;
1877
+ record(success: boolean, latencyMs: number): void;
1878
+ getStats(): {
1879
+ totalTrades: number;
1880
+ successTrades: number;
1881
+ failedTrades: number;
1882
+ avgLatencyMs: number;
1883
+ };
1884
+ }
1885
+ /**
1886
+ * Executes trades with ZERO RPC calls in the hot path.
1887
+ *
1888
+ * Usage:
1889
+ * 1. Create executor with RPC connection
1890
+ * 2. Call start() to begin background prefetching
1891
+ * 3. Prefetch required accounts/pools BEFORE trading
1892
+ * 4. Build transaction with prefetched blockhash
1893
+ * 5. Execute - no RPC calls during this phase
1894
+ */
1895
+ declare class HotPathExecutor {
1896
+ private state;
1897
+ private config;
1898
+ private connection;
1899
+ private swqosClients;
1900
+ private metrics;
1901
+ constructor(connection: Connection, config?: Partial<HotPathConfig>);
1902
+ /**
1903
+ * Add a SWQoS client for transaction submission
1904
+ */
1905
+ addSwqosClient(client: SwqosClient): void;
1906
+ /**
1907
+ * Remove a SWQoS client
1908
+ */
1909
+ removeSwqosClient(swqosType: SwqosType): void;
1910
+ /**
1911
+ * Get SWQoS client by type
1912
+ */
1913
+ getSwqosClient(swqosType: SwqosType): SwqosClient | undefined;
1914
+ /**
1915
+ * Start background prefetching
1916
+ */
1917
+ start(): Promise<void>;
1918
+ /**
1919
+ * Stop background prefetching
1920
+ */
1921
+ stop(): void;
1922
+ /**
1923
+ * Get hot path state for external access
1924
+ */
1925
+ getState(): HotPathState;
1926
+ /**
1927
+ * Check if executor is ready for hot path execution
1928
+ */
1929
+ isReady(): boolean;
1930
+ /**
1931
+ * Wait until executor is ready
1932
+ */
1933
+ waitForReady(checkIntervalMs?: number, timeoutMs?: number): Promise<boolean>;
1934
+ /**
1935
+ * Prefetch accounts - call BEFORE hot path execution
1936
+ */
1937
+ prefetchAccounts(pubkeys: string[]): Promise<void>;
1938
+ /**
1939
+ * Create trading context with prefetched data - NO RPC
1940
+ */
1941
+ createTradingContext(payer: string): TradingContext;
1942
+ /**
1943
+ * Execute a pre-signed transaction - NO RPC CALLS
1944
+ *
1945
+ * Transaction must already be signed with valid blockhash.
1946
+ * All state should be prefetched before calling this.
1947
+ */
1948
+ execute(tradeType: TradeType, transactionBytes: Buffer, opts?: ExecuteOptions): Promise<ExecuteResult>;
1949
+ /**
1950
+ * Submit to all SWQoS clients in parallel - NO RPC
1951
+ */
1952
+ private executeParallel;
1953
+ /**
1954
+ * Submit to SWQoS clients sequentially - NO RPC
1955
+ */
1956
+ private executeSequential;
1957
+ /**
1958
+ * Execute multiple transactions in parallel
1959
+ */
1960
+ executeMultiple(tradeType: TradeType, transactions: Buffer[], opts?: ExecuteOptions): Promise<ExecuteResult[]>;
1961
+ /**
1962
+ * Get cached blockhash - NO RPC CALL
1963
+ * Use this to build transactions before execution
1964
+ */
1965
+ getBlockhash(): {
1966
+ blockhash: string;
1967
+ lastValidBlockHeight: number;
1968
+ } | null;
1969
+ /**
1970
+ * Get execution metrics
1971
+ */
1972
+ getMetrics(): ReturnType<HotPathMetrics['getStats']>;
1973
+ private sleep;
1974
+ }
1975
+ /**
1976
+ * Builds transactions using prefetched data - NO RPC CALLS
1977
+ *
1978
+ * Use this to construct transactions before hot path execution.
1979
+ */
1980
+ declare class TransactionBuilder {
1981
+ private executor;
1982
+ constructor(executor: HotPathExecutor);
1983
+ /**
1984
+ * Build a transaction using prefetched blockhash - NO RPC
1985
+ */
1986
+ buildTransaction(payer: PublicKey, instructions: TransactionInstruction[], signers: any[], // Keypair[]
1987
+ gasConfig?: GasFeeConfig): Promise<Transaction | null>;
1988
+ }
1989
+ /**
1990
+ * Create a hot path executor with default configuration.
1991
+ *
1992
+ * Usage:
1993
+ * const executor = createHotPathExecutor(
1994
+ * connection,
1995
+ * [jitoClient, bloxrouteClient]
1996
+ * );
1997
+ * await executor.start();
1998
+ *
1999
+ * // Prefetch required data
2000
+ * await executor.prefetchAccounts([tokenAccountPubkey]);
2001
+ *
2002
+ * // Now ready for hot path execution
2003
+ * const result = await executor.execute('buy', txBytes);
2004
+ */
2005
+ declare function createHotPathExecutor(connection: Connection, swqosClients?: SwqosClient[], config?: Partial<HotPathConfig>): HotPathExecutor;
2006
+
2007
+ /**
2008
+ * Execution: instruction preprocessing, cache prefetch, branch hints.
2009
+ * 执行模块:指令预处理、缓存预取、分支提示。
2010
+ *
2011
+ * Based on sol-trade-sdk Rust implementation patterns.
2012
+ */
2013
+
2014
+ declare const BYTES_PER_ACCOUNT = 32;
2015
+ declare const MAX_INSTRUCTIONS_WARN = 64;
2016
+ /**
2017
+ * Cache prefetching utilities.
2018
+ * Call once on hot-path refs to reduce cache-miss latency.
2019
+ */
2020
+ declare class Prefetch {
2021
+ /**
2022
+ * Prefetch instruction data into cache
2023
+ * Accepts any instruction-shaped array (Rust: `Prefetch::instructions`).
2024
+ */
2025
+ static instructions(instructions: ReadonlyArray<unknown>): void;
2026
+ /**
2027
+ * Prefetch pubkey into cache
2028
+ */
2029
+ static pubkey(pubkey: Uint8Array): void;
2030
+ /**
2031
+ * Prefetch keypair data into cache
2032
+ */
2033
+ static keypair(keypair: unknown): void;
2034
+ }
2035
+ /**
2036
+ * Handles instruction preprocessing and validation.
2037
+ * Based on Rust's InstructionProcessor pattern.
2038
+ */
2039
+ declare class InstructionProcessor {
2040
+ /**
2041
+ * Validate and prepare instructions for execution.
2042
+ * Rust: `InstructionProcessor::preprocess` (empty check, prefetch, warn when count exceeds {@link MAX_INSTRUCTIONS_WARN}).
2043
+ */
2044
+ static preprocess(instructions: ReadonlyArray<unknown>): void;
2045
+ /**
2046
+ * Calculate total size for buffer allocation (web3 `keys` or internal `accounts`).
2047
+ */
2048
+ static calculateSize(instructions: ReadonlyArray<{
2049
+ data: {
2050
+ length: number;
2051
+ };
2052
+ keys?: readonly unknown[];
2053
+ accounts?: readonly unknown[];
2054
+ }>): number;
2055
+ }
2056
+ /**
2057
+ * Trade direction and execution path utilities
2058
+ */
2059
+ declare class ExecutionPath {
2060
+ /**
2061
+ * Rust `ExecutionPath::is_buy`: input mint is quote-side (SOL / WSOL / USD1 / USDC).
2062
+ */
2063
+ static isBuy(inputMint: PublicKey): boolean;
2064
+ /**
2065
+ * Select between fast and slow path
2066
+ */
2067
+ static select<T>(condition: boolean, fastPath: () => T, slowPath: () => T): T;
2068
+ }
2069
+
2070
+ /**
2071
+ * Poll multiple transaction signatures until one reaches confirmed/finalized without error.
2072
+ * Rust: `swqos::common::poll_any_transaction_confirmation`.
2073
+ */
2074
+
2075
+ /**
2076
+ * Map RPC `Commitment` to `getTransaction` `Finality` (web3: only `confirmed` | `finalized`).
2077
+ * `processed` / unknown → `confirmed`.
2078
+ */
2079
+ declare function commitmentToGetTxFinality(c: Commitment | undefined): Finality;
2080
+ interface ConfirmAnySignatureOptions {
2081
+ commitment?: Commitment;
2082
+ /**
2083
+ * `getTransaction` lookup commitment (Rust: `CommitmentConfig::confirmed()`).
2084
+ * Defaults from {@link commitmentToGetTxFinality}(`commitment`).
2085
+ */
2086
+ getTransactionCommitment?: Finality;
2087
+ /** Default 15000 (Rust uses 15s). */
2088
+ timeoutMs?: number;
2089
+ pollIntervalMs?: number;
2090
+ /**
2091
+ * Rust waits until `poll_count >= 10` before `get_transaction_with_config` on the first landed signature.
2092
+ * @default 10
2093
+ */
2094
+ pollsBeforeGetTransaction?: number;
2095
+ }
2096
+ /** Rust: log line patterns for user-facing failure hints. */
2097
+ declare function extractHintsFromLogs(logs: readonly string[] | null | undefined): string;
2098
+ /**
2099
+ * Map `TransactionError` JSON (meta.err) to a numeric code; prefers Custom instruction code like Rust.
2100
+ */
2101
+ declare function instructionErrorCodeFromMetaErr(err: unknown): {
2102
+ code: number;
2103
+ instructionIndex?: number;
2104
+ };
2105
+ /**
2106
+ * Wait until any signature in `signatures` is confirmed successfully on-chain.
2107
+ * Single-signature path uses `connection.confirmTransaction` (blockhash strategy when applicable).
2108
+ */
2109
+ declare function confirmAnyTransactionSignature(connection: Connection, signatures: string[], options?: ConfirmAnySignatureOptions): Promise<string>;
2110
+
2111
+ /**
2112
+ * Bounded concurrency for async work (Rust SWQOS worker pool parity, best-effort in JS).
2113
+ */
2114
+ declare function mapWithConcurrencyLimit<T, R>(items: readonly T[], concurrency: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
2115
+
2116
+ /**
2117
+ * Durable nonce helpers — aligned with Rust `src/common/nonce_cache.rs` `fetch_nonce_info`.
2118
+ */
2119
+
2120
+ /** Same shape as `DurableNonceInfo` in `index.ts` (used for `buy`/`sell` without circular imports). */
2121
+ interface FetchedDurableNonce {
2122
+ nonceAccount: PublicKey;
2123
+ authority: PublicKey;
2124
+ /** Base58-encoded current nonce blockhash (32 bytes), for `recentBlockhash` / `nonceHash`. */
2125
+ nonceHash: string;
2126
+ /** Duplicate of `nonceHash` for parity with existing `DurableNonceInfo.recentBlockhash`. */
2127
+ recentBlockhash: string;
2128
+ }
2129
+ /**
2130
+ * Fetch durable nonce authority + current blockhash from a nonce account (RPC).
2131
+ * Layout matches Rust: version (4) + authority_type (4) + authority (32) + blockhash (32) starting at offset 40.
2132
+ */
2133
+ declare function fetchDurableNonceInfo(connection: Pick<Connection, 'getAccountInfo'>, nonceAccount: PublicKey): Promise<FetchedDurableNonce | null>;
2134
+
2135
+ /**
2136
+ * Secure key storage and management for Sol Trade SDK
2137
+ *
2138
+ * Implements secure memory handling for private keys with:
2139
+ * - Memory encryption at rest
2140
+ * - Secure zeroing after use
2141
+ * - Context manager for automatic cleanup
2142
+ */
2143
+
2144
+ /**
2145
+ * Error thrown when secure key operation fails
2146
+ */
2147
+ declare class SecureKeyError extends Error {
2148
+ constructor(message: string);
2149
+ }
2150
+ /**
2151
+ * Error thrown when trying to access a cleared key
2152
+ */
2153
+ declare class KeyNotAvailableError extends SecureKeyError {
2154
+ constructor(message?: string);
2155
+ }
2156
+ /**
2157
+ * Metadata about a stored key
2158
+ */
2159
+ interface KeyMetadata {
2160
+ pubkey: string;
2161
+ createdAt: number;
2162
+ lastAccessed?: number;
2163
+ accessCount: number;
2164
+ }
2165
+ /**
2166
+ * Secure storage for Solana private keys.
2167
+ *
2168
+ * Features:
2169
+ * - Keys are encrypted in memory when not in use
2170
+ * - Automatic secure zeroing of key material
2171
+ * - Context manager support for temporary key access
2172
+ */
2173
+ declare class SecureKeyStorage {
2174
+ private encryptedKey;
2175
+ private salt;
2176
+ private pubkey;
2177
+ private isUnlocked;
2178
+ private unlockedKey;
2179
+ private metadata;
2180
+ private passwordProtected;
2181
+ private constructor();
2182
+ /**
2183
+ * Create secure storage from a Keypair.
2184
+ */
2185
+ static fromKeypair(keypair: Keypair, password?: string): SecureKeyStorage;
2186
+ /**
2187
+ * Create secure storage from a seed.
2188
+ */
2189
+ static fromSeed(seed: Uint8Array, password?: string): SecureKeyStorage;
2190
+ /**
2191
+ * Create secure storage from a mnemonic phrase.
2192
+ */
2193
+ static fromMnemonic(mnemonic: string, password?: string): SecureKeyStorage;
2194
+ private encryptWithPassword;
2195
+ private decryptWithPassword;
2196
+ private xorEncrypt;
2197
+ /**
2198
+ * Securely zero out sensitive data from memory
2199
+ */
2200
+ private static secureZero;
2201
+ private secureZero;
2202
+ /**
2203
+ * Temporarily access the keypair.
2204
+ * Key is automatically cleared after callback completes.
2205
+ */
2206
+ withKeypair<T>(callback: (keypair: Keypair) => Promise<T>, password?: string): Promise<T>;
2207
+ /**
2208
+ * Sign a message without exposing the keypair.
2209
+ */
2210
+ signMessage(message: Buffer | Uint8Array, password?: string): Promise<Buffer>;
2211
+ /**
2212
+ * Get the public key (safe to access)
2213
+ */
2214
+ getPublicKey(): string;
2215
+ /**
2216
+ * Check if storage requires password
2217
+ */
2218
+ get isPasswordProtected(): boolean;
2219
+ /**
2220
+ * Get key metadata
2221
+ */
2222
+ getMetadata(): KeyMetadata | null;
2223
+ /**
2224
+ * Permanently clear all key material
2225
+ */
2226
+ clear(): void;
2227
+ }
2228
+ /**
2229
+ * Convenience function for quick signing
2230
+ */
2231
+ declare function signWithKeypair(keypair: Keypair, message: Buffer | Uint8Array, clearAfter?: boolean): Promise<Buffer>;
2232
+
2233
+ /**
2234
+ * Input validators for Sol Trade SDK
2235
+ *
2236
+ * Provides secure input validation for:
2237
+ * - RPC URLs
2238
+ * - Program IDs
2239
+ * - Amounts
2240
+ * - Slippage values
2241
+ */
2242
+
2243
+ /**
2244
+ * Error thrown when input validation fails
2245
+ */
2246
+ declare class ValidationError extends Error {
2247
+ constructor(message: string);
2248
+ }
2249
+ /**
2250
+ * Known legitimate Solana program IDs
2251
+ */
2252
+ declare const KNOWN_PROGRAM_IDS: Record<string, string[]>;
2253
+ /**
2254
+ * Validate RPC URL format and security.
2255
+ */
2256
+ declare function validateRpcUrl(url: string, allowHttp?: boolean): string;
2257
+ /**
2258
+ * Validate a Solana program ID.
2259
+ */
2260
+ declare function validateProgramId(programId: string, expectedProgram?: string): string;
2261
+ /**
2262
+ * Validate an amount value.
2263
+ */
2264
+ declare function validateAmount(amount: number | bigint, name?: string, allowZero?: boolean): bigint;
2265
+ /**
2266
+ * Validate slippage in basis points.
2267
+ */
2268
+ declare function validateSlippage(slippageBasisPoints: number): number;
2269
+ /**
2270
+ * Validate a Solana public key.
2271
+ */
2272
+ declare function validatePubkey(pubkey: string | PublicKey, name?: string): PublicKey;
2273
+ /**
2274
+ * Validate a trading pair.
2275
+ */
2276
+ declare function validateMintPair(inputMint: string, outputMint: string): void;
2277
+ /**
2278
+ * Validate transaction size.
2279
+ */
2280
+ declare function validateTransactionSize(transactionBytes: Buffer | Uint8Array, maxSize?: number): void;
2281
+ /**
2282
+ * Validate a signature string.
2283
+ */
2284
+ declare function validateSignature(signature: string): string;
2285
+
2286
+ /**
2287
+ * Address Lookup Table support for Solana transactions.
2288
+ *
2289
+ * This module provides functionality to fetch and use Address Lookup Tables (ALT)
2290
+ * to reduce transaction size by storing frequently used addresses in a lookup table.
2291
+ */
2292
+
2293
+ /**
2294
+ * Represents an address lookup table account.
2295
+ */
2296
+ interface AddressLookupTableAccount {
2297
+ key: PublicKey;
2298
+ addresses: PublicKey[];
2299
+ }
2300
+ /**
2301
+ * Fetch an address lookup table account from the blockchain.
2302
+ *
2303
+ * @param connection - Solana RPC connection
2304
+ * @param lookupTableAddress - The address of the lookup table
2305
+ * @param commitment - Commitment level for the query
2306
+ * @returns AddressLookupTableAccount if found, null otherwise
2307
+ */
2308
+ declare function fetchAddressLookupTableAccount(connection: Connection, lookupTableAddress: PublicKey, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<AddressLookupTableAccount | null>;
2309
+ /**
2310
+ * Parse an address lookup table from account data.
2311
+ *
2312
+ * @param key - The lookup table public key
2313
+ * @param accountInfo - The account info containing the lookup table data
2314
+ * @returns AddressLookupTableAccount
2315
+ */
2316
+ declare function parseAddressLookupTable(key: PublicKey, accountInfo: AccountInfo<Buffer>): AddressLookupTableAccount | null;
2317
+ /**
2318
+ * Cache for address lookup tables to avoid repeated RPC calls.
2319
+ */
2320
+ declare class AddressLookupTableCache {
2321
+ private cache;
2322
+ /**
2323
+ * Get lookup table from cache or fetch from RPC.
2324
+ *
2325
+ * @param connection - Solana RPC connection
2326
+ * @param lookupTableAddress - The lookup table address
2327
+ * @returns AddressLookupTableAccount if found, null otherwise
2328
+ */
2329
+ getLookupTable(connection: Connection, lookupTableAddress: PublicKey): Promise<AddressLookupTableAccount | null>;
2330
+ /**
2331
+ * Get multiple lookup tables from cache or fetch from RPC.
2332
+ *
2333
+ * @param connection - Solana RPC connection
2334
+ * @param lookupTableAddresses - Array of lookup table addresses
2335
+ * @returns Array of AddressLookupTableAccount (null for not found)
2336
+ */
2337
+ getLookupTables(connection: Connection, lookupTableAddresses: PublicKey[]): Promise<(AddressLookupTableAccount | null)[]>;
2338
+ /**
2339
+ * Clear the cache.
2340
+ */
2341
+ clear(): void;
2342
+ /**
2343
+ * Remove a specific lookup table from cache.
2344
+ *
2345
+ * @param lookupTableAddress - The lookup table address to remove
2346
+ */
2347
+ remove(lookupTableAddress: PublicKey): void;
2348
+ /**
2349
+ * Get cache size.
2350
+ */
2351
+ get size(): number;
2352
+ }
2353
+ /**
2354
+ * Default global cache instance.
2355
+ */
2356
+ declare const addressLookupTableCache: AddressLookupTableCache;
2357
+
2358
+ /**
2359
+ * Trading factory and executor for Sol Trade SDK
2360
+ *
2361
+ * Provides factory methods for creating trade executors for different DEX protocols
2362
+ */
2363
+
2364
+ declare enum DexType$1 {
2365
+ PumpFun = "PumpFun",
2366
+ PumpSwap = "PumpSwap",
2367
+ Bonk = "Bonk",
2368
+ RaydiumCpmm = "RaydiumCpmm",
2369
+ RaydiumAmmV4 = "RaydiumAmmV4",
2370
+ MeteoraDammV2 = "MeteoraDammV2"
2371
+ }
2372
+ declare enum TradeType$1 {
2373
+ Buy = "Buy",
2374
+ Sell = "Sell",
2375
+ Create = "Create",
2376
+ CreateAndBuy = "CreateAndBuy"
2377
+ }
2378
+ interface TradeResult$1 {
2379
+ signature: string;
2380
+ success: boolean;
2381
+ error?: string;
2382
+ confirmationTimeMs?: number;
2383
+ submittedAt?: Date;
2384
+ confirmedAt?: Date;
2385
+ retries?: number;
2386
+ }
2387
+ interface BatchTradeResult {
2388
+ results: TradeResult$1[];
2389
+ totalTimeMs: number;
2390
+ successCount: number;
2391
+ failedCount: number;
2392
+ }
2393
+ interface TradeExecuteOptions {
2394
+ waitConfirmation?: boolean;
2395
+ maxRetries?: number;
2396
+ retryDelayMs?: number;
2397
+ parallelSubmit?: boolean;
2398
+ timeoutMs?: number;
2399
+ priority?: number;
2400
+ skipPreflight?: boolean;
2401
+ }
2402
+ declare function defaultTradeExecuteOptions(): TradeExecuteOptions;
2403
+ interface PumpFunParams$1 {
2404
+ bondingCurve?: any;
2405
+ associatedBondingCurve?: PublicKey;
2406
+ creatorVault?: PublicKey;
2407
+ tokenProgram?: PublicKey;
2408
+ closeTokenAccountWhenSell?: boolean;
2409
+ }
2410
+ interface PumpSwapParams$1 {
2411
+ pool?: PublicKey;
2412
+ baseMint?: PublicKey;
2413
+ quoteMint?: PublicKey;
2414
+ poolBaseTokenAccount?: PublicKey;
2415
+ poolQuoteTokenAccount?: PublicKey;
2416
+ poolBaseTokenReserves?: bigint;
2417
+ poolQuoteTokenReserves?: bigint;
2418
+ coinCreatorVaultAta?: PublicKey;
2419
+ coinCreatorVaultAuthority?: PublicKey;
2420
+ baseTokenProgram?: PublicKey;
2421
+ quoteTokenProgram?: PublicKey;
2422
+ isMayhemMode?: boolean;
2423
+ isCashbackCoin?: boolean;
2424
+ }
2425
+ interface BonkParams$1 {
2426
+ virtualBase?: bigint;
2427
+ virtualQuote?: bigint;
2428
+ realBase?: bigint;
2429
+ realQuote?: bigint;
2430
+ poolState?: PublicKey;
2431
+ baseVault?: PublicKey;
2432
+ quoteVault?: PublicKey;
2433
+ mintTokenProgram?: PublicKey;
2434
+ platformConfig?: PublicKey;
2435
+ platformAssociatedAccount?: PublicKey;
2436
+ creatorAssociatedAccount?: PublicKey;
2437
+ globalConfig?: PublicKey;
2438
+ }
2439
+ interface RaydiumCpmmParams$1 {
2440
+ poolState?: PublicKey;
2441
+ ammConfig?: PublicKey;
2442
+ baseMint?: PublicKey;
2443
+ quoteMint?: PublicKey;
2444
+ baseReserve?: bigint;
2445
+ quoteReserve?: bigint;
2446
+ baseVault?: PublicKey;
2447
+ quoteVault?: PublicKey;
2448
+ baseTokenProgram?: PublicKey;
2449
+ quoteTokenProgram?: PublicKey;
2450
+ observationState?: PublicKey;
2451
+ }
2452
+ interface RaydiumAmmV4Params$1 {
2453
+ amm?: PublicKey;
2454
+ coinMint?: PublicKey;
2455
+ pcMint?: PublicKey;
2456
+ tokenCoin?: PublicKey;
2457
+ tokenPc?: PublicKey;
2458
+ ammOpenOrders?: PublicKey;
2459
+ ammTargetOrders?: PublicKey;
2460
+ serumProgram?: PublicKey;
2461
+ serumMarket?: PublicKey;
2462
+ serumBids?: PublicKey;
2463
+ serumAsks?: PublicKey;
2464
+ serumEventQueue?: PublicKey;
2465
+ serumCoinVaultAccount?: PublicKey;
2466
+ serumPcVaultAccount?: PublicKey;
2467
+ serumVaultSigner?: PublicKey;
2468
+ coinReserve?: bigint;
2469
+ pcReserve?: bigint;
2470
+ }
2471
+ interface MeteoraDammV2Params$1 {
2472
+ pool?: PublicKey;
2473
+ tokenAVault?: PublicKey;
2474
+ tokenBVault?: PublicKey;
2475
+ tokenAMint?: PublicKey;
2476
+ tokenBMint?: PublicKey;
2477
+ tokenAProgram?: PublicKey;
2478
+ tokenBProgram?: PublicKey;
2479
+ }
2480
+ interface ITradeExecutor {
2481
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2482
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2483
+ }
2484
+ declare abstract class BaseExecutor implements ITradeExecutor {
2485
+ abstract executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2486
+ abstract executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2487
+ protected buildResult(signature: string, success: boolean, error?: string): TradeResult$1;
2488
+ }
2489
+ declare class PumpFunExecutor extends BaseExecutor {
2490
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2491
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2492
+ }
2493
+ declare class PumpSwapExecutor extends BaseExecutor {
2494
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2495
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2496
+ }
2497
+ declare class BonkExecutor extends BaseExecutor {
2498
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2499
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2500
+ }
2501
+ declare class RaydiumCpmmExecutor extends BaseExecutor {
2502
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2503
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2504
+ }
2505
+ declare class RaydiumAmmV4Executor extends BaseExecutor {
2506
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2507
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2508
+ }
2509
+ declare class MeteoraDammV2Executor extends BaseExecutor {
2510
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2511
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2512
+ }
2513
+ declare class TradeExecutorFactory {
2514
+ private static executors;
2515
+ /**
2516
+ * Create a trade executor for the given DEX type
2517
+ */
2518
+ static createExecutor(dexType: DexType$1): ITradeExecutor;
2519
+ /**
2520
+ * Register a custom executor factory
2521
+ */
2522
+ static registerExecutor(dexType: DexType$1, factory: () => ITradeExecutor): void;
2523
+ /**
2524
+ * Get supported DEX types
2525
+ */
2526
+ static getSupportedDexTypes(): DexType$1[];
2527
+ }
2528
+
2529
+ /**
2530
+ * Sol Trade SDK - TypeScript SDK for Solana DEX trading
2531
+ *
2532
+ * A comprehensive SDK for seamless Solana DEX trading with support for
2533
+ * PumpFun, PumpSwap, Bonk, Raydium CPMM, Raydium AMM V4, and Meteora DAMM V2.
2534
+ */
2535
+
2536
+ /**
2537
+ * Supported DEX protocols
2538
+ */
2539
+ declare enum DexType {
2540
+ PumpFun = "PumpFun",
2541
+ PumpSwap = "PumpSwap",
2542
+ Bonk = "Bonk",
2543
+ RaydiumCpmm = "RaydiumCpmm",
2544
+ RaydiumAmmV4 = "RaydiumAmmV4",
2545
+ MeteoraDammV2 = "MeteoraDammV2"
2546
+ }
2547
+ /**
2548
+ * Type of token to trade
2549
+ */
2550
+ declare enum TradeTokenType {
2551
+ SOL = "SOL",
2552
+ WSOL = "WSOL",
2553
+ USD1 = "USD1",
2554
+ USDC = "USDC"
2555
+ }
2556
+ /**
2557
+ * Trade operation type
2558
+ */
2559
+ declare enum TradeType {
2560
+ Buy = "Buy",
2561
+ Sell = "Sell"
2562
+ }
2563
+ /**
2564
+ * SWQOS service regions
2565
+ */
2566
+ declare enum SwqosRegion {
2567
+ Frankfurt = "Frankfurt",
2568
+ NewYork = "NewYork",
2569
+ Amsterdam = "Amsterdam",
2570
+ Dublin = "Dublin",
2571
+ Tokyo = "Tokyo",
2572
+ Singapore = "Singapore",
2573
+ SLC = "SLC",
2574
+ London = "London",
2575
+ LosAngeles = "LosAngeles",
2576
+ Default = "Default"
2577
+ }
2578
+ /**
2579
+ * SWQOS service types
2580
+ */
2581
+ declare enum SwqosType {
2582
+ Default = "Default",
2583
+ Jito = "Jito",
2584
+ Bloxroute = "Bloxroute",
2585
+ ZeroSlot = "ZeroSlot",
2586
+ Temporal = "Temporal",
2587
+ FlashBlock = "FlashBlock",
2588
+ BlockRazor = "BlockRazor",
2589
+ Node1 = "Node1",
2590
+ Astralane = "Astralane",
2591
+ NextBlock = "NextBlock",
2592
+ Helius = "Helius",
2593
+ Stellium = "Stellium",
2594
+ Lightspeed = "Lightspeed",
2595
+ Soyas = "Soyas",
2596
+ Speedlanding = "Speedlanding",
2597
+ Triton = "Triton",
2598
+ QuickNode = "QuickNode",
2599
+ Syndica = "Syndica",
2600
+ Figment = "Figment",
2601
+ Alchemy = "Alchemy"
2602
+ }
2603
+ declare enum SwqosTransport {
2604
+ Http = "Http",
2605
+ Grpc = "Grpc",
2606
+ Quic = "Quic"
2607
+ }
2608
+ declare enum AstralaneTransport {
2609
+ Binary = "Binary",
2610
+ Plain = "Plain",
2611
+ Quic = "Quic"
2612
+ }
2613
+ /**
2614
+ * SWQOS service configuration
2615
+ */
2616
+ interface SwqosConfig {
2617
+ type: SwqosType;
2618
+ region: SwqosRegion;
2619
+ apiKey: string;
2620
+ customUrl?: string;
2621
+ mevProtection?: boolean;
2622
+ transport?: SwqosTransport;
2623
+ astralaneTransport?: AstralaneTransport;
2624
+ swqosOnly?: boolean;
2625
+ }
2626
+ /**
2627
+ * Gas fee strategy configuration
2628
+ */
2629
+ interface GasFeeStrategyConfig {
2630
+ buyPriorityFee: number;
2631
+ sellPriorityFee: number;
2632
+ buyComputeUnits: number;
2633
+ sellComputeUnits: number;
2634
+ buyTipLamports: number;
2635
+ sellTipLamports: number;
2636
+ }
2637
+ /**
2638
+ * Durable nonce information
2639
+ *
2640
+ * Populate via `fetchDurableNonceInfo` (Rust `fetch_nonce_info` parity) or manually.
2641
+ */
2642
+ interface DurableNonceInfo {
2643
+ nonceAccount: PublicKey;
2644
+ authority: PublicKey;
2645
+ nonceHash: string;
2646
+ recentBlockhash: string;
2647
+ }
2648
+ /**
2649
+ * Buy trade parameters
2650
+ */
2651
+ interface TradeBuyParams {
2652
+ dexType: DexType;
2653
+ inputTokenType: TradeTokenType;
2654
+ mint: PublicKey;
2655
+ inputTokenAmount: number;
2656
+ slippageBasisPoints?: number;
2657
+ recentBlockhash?: string;
2658
+ extensionParams: DexParamEnum;
2659
+ addressLookupTableAccount?: AddressLookupTableAccount$1;
2660
+ waitTxConfirmed?: boolean;
2661
+ createInputTokenAta?: boolean;
2662
+ closeInputTokenAta?: boolean;
2663
+ createMintAta?: boolean;
2664
+ durableNonce?: DurableNonceInfo;
2665
+ fixedOutputTokenAmount?: number;
2666
+ gasFeeStrategy?: GasFeeStrategyConfig;
2667
+ simulate?: boolean;
2668
+ useExactSolAmount?: boolean;
2669
+ grpcRecvUs?: number;
2670
+ }
2671
+ /**
2672
+ * Sell trade parameters
2673
+ */
2674
+ interface TradeSellParams {
2675
+ dexType: DexType;
2676
+ outputTokenType: TradeTokenType;
2677
+ mint: PublicKey;
2678
+ inputTokenAmount: number;
2679
+ slippageBasisPoints?: number;
2680
+ recentBlockhash?: string;
2681
+ withTip?: boolean;
2682
+ extensionParams: DexParamEnum;
2683
+ addressLookupTableAccount?: AddressLookupTableAccount$1;
2684
+ waitTxConfirmed?: boolean;
2685
+ createOutputTokenAta?: boolean;
2686
+ closeOutputTokenAta?: boolean;
2687
+ closeMintTokenAta?: boolean;
2688
+ durableNonce?: DurableNonceInfo;
2689
+ fixedOutputTokenAmount?: number;
2690
+ gasFeeStrategy?: GasFeeStrategyConfig;
2691
+ simulate?: boolean;
2692
+ grpcRecvUs?: number;
2693
+ }
2694
+ /**
2695
+ * Trade execution result
2696
+ */
2697
+ interface TradeResult {
2698
+ success: boolean;
2699
+ signatures: string[];
2700
+ error?: TradeError;
2701
+ timings: SwqosTiming[];
2702
+ /**
2703
+ * Set when `simulate: true` on buy/sell — Rust `simulate_transaction` (`units_consumed`, `logs`).
2704
+ */
2705
+ simulation?: {
2706
+ unitsConsumed?: number;
2707
+ logs?: string[] | null;
2708
+ };
2709
+ }
2710
+ /**
2711
+ * SWQOS timing information
2712
+ */
2713
+ interface SwqosTiming {
2714
+ swqosType: SwqosType;
2715
+ duration: number;
2716
+ /** Present when `TradeConfig.gasStrategy` expands multiple Rust `GasFeeStrategyType` rows. */
2717
+ gasFeeStrategyType?: GasFeeStrategyType;
2718
+ }
2719
+
2720
+ /**
2721
+ * Bonding curve account state
2722
+ */
2723
+ interface BondingCurveAccount {
2724
+ discriminator: number;
2725
+ account: PublicKey;
2726
+ virtualTokenReserves: number;
2727
+ virtualSolReserves: number;
2728
+ realTokenReserves: number;
2729
+ realSolReserves: number;
2730
+ tokenTotalSupply: number;
2731
+ complete: boolean;
2732
+ creator: PublicKey;
2733
+ isMayhemMode: boolean;
2734
+ isCashbackCoin: boolean;
2735
+ }
2736
+ /**
2737
+ * PumpFun protocol parameters
2738
+ */
2739
+ interface PumpFunParams {
2740
+ bondingCurve: BondingCurveAccount;
2741
+ associatedBondingCurve: PublicKey;
2742
+ creatorVault: PublicKey;
2743
+ tokenProgram: PublicKey;
2744
+ observedTradeCreator?: PublicKey;
2745
+ feeSharingCreatorVaultIfActive?: PublicKey;
2746
+ closeTokenAccountWhenSell?: boolean;
2747
+ /** Parser/gRPC fee recipient; omit or `PublicKey.default` for SDK random pool (Rust parity). */
2748
+ feeRecipient?: PublicKey;
2749
+ /** PumpFun V2 quote mint; omit or default pubkey for WSOL. */
2750
+ quoteMint?: PublicKey;
2751
+ }
2752
+ interface ParserPumpFunTradeEvent {
2753
+ mint?: string | PublicKey;
2754
+ bonding_curve?: string | PublicKey;
2755
+ associated_bonding_curve?: string | PublicKey;
2756
+ creator?: string | PublicKey;
2757
+ creator_vault?: string | PublicKey;
2758
+ virtual_token_reserves?: bigint | number | string;
2759
+ virtual_sol_reserves?: bigint | number | string;
2760
+ virtual_quote_reserves?: bigint | number | string;
2761
+ real_token_reserves?: bigint | number | string;
2762
+ real_sol_reserves?: bigint | number | string;
2763
+ real_quote_reserves?: bigint | number | string;
2764
+ token_program?: string | PublicKey;
2765
+ fee_recipient?: string | PublicKey;
2766
+ quote_mint?: string | PublicKey;
2767
+ is_cashback_coin?: boolean;
2768
+ mayhem_mode?: boolean;
2769
+ }
2770
+ /**
2771
+ * Build PumpFun params directly from a sol-parser-sdk PumpFunTradeEvent.
2772
+ * The parser's `virtual_quote_reserves` / `real_quote_reserves` are mapped to
2773
+ * the SDK's quote reserve fields used by slippage calculation.
2774
+ */
2775
+ declare function pumpFunParamsFromParserTrade(event: ParserPumpFunTradeEvent, closeTokenAccountWhenSell?: boolean): PumpFunParams;
2776
+ /**
2777
+ * PumpSwap protocol parameters
2778
+ */
2779
+ interface PumpSwapParams {
2780
+ pool: PublicKey;
2781
+ baseMint: PublicKey;
2782
+ quoteMint: PublicKey;
2783
+ poolBaseTokenAccount: PublicKey;
2784
+ poolQuoteTokenAccount: PublicKey;
2785
+ poolBaseTokenReserves: number;
2786
+ poolQuoteTokenReserves: number;
2787
+ coinCreatorVaultAta: PublicKey;
2788
+ coinCreatorVaultAuthority: PublicKey;
2789
+ baseTokenProgram: PublicKey;
2790
+ quoteTokenProgram: PublicKey;
2791
+ isMayhemMode: boolean;
2792
+ isCashbackCoin: boolean;
2793
+ }
2794
+ interface ParserPumpSwapTradeEvent {
2795
+ pool?: string | PublicKey;
2796
+ base_mint?: string | PublicKey;
2797
+ quote_mint?: string | PublicKey;
2798
+ pool_base_token_account?: string | PublicKey;
2799
+ pool_quote_token_account?: string | PublicKey;
2800
+ pool_base_token_reserves?: bigint | number | string;
2801
+ pool_quote_token_reserves?: bigint | number | string;
2802
+ coin_creator_vault_ata?: string | PublicKey;
2803
+ coin_creator_vault_authority?: string | PublicKey;
2804
+ base_token_program?: string | PublicKey;
2805
+ quote_token_program?: string | PublicKey;
2806
+ is_mayhem_mode?: boolean;
2807
+ is_cashback_coin?: boolean;
2808
+ }
2809
+ declare function pumpSwapParamsFromParserTrade(event: ParserPumpSwapTradeEvent): PumpSwapParams;
2810
+ /**
2811
+ * Bonk protocol parameters
2812
+ */
2813
+ interface BonkParams {
2814
+ virtualBase: bigint;
2815
+ virtualQuote: bigint;
2816
+ realBase: bigint;
2817
+ realQuote: bigint;
2818
+ poolState: PublicKey;
2819
+ baseVault: PublicKey;
2820
+ quoteVault: PublicKey;
2821
+ mintTokenProgram: PublicKey;
2822
+ platformConfig: PublicKey;
2823
+ platformAssociatedAccount: PublicKey;
2824
+ creatorAssociatedAccount: PublicKey;
2825
+ globalConfig: PublicKey;
2826
+ }
2827
+ /**
2828
+ * Raydium CPMM protocol parameters
2829
+ */
2830
+ interface RaydiumCpmmParams {
2831
+ poolState: PublicKey;
2832
+ ammConfig: PublicKey;
2833
+ baseMint: PublicKey;
2834
+ quoteMint: PublicKey;
2835
+ baseReserve: number;
2836
+ quoteReserve: number;
2837
+ baseVault: PublicKey;
2838
+ quoteVault: PublicKey;
2839
+ baseTokenProgram: PublicKey;
2840
+ quoteTokenProgram: PublicKey;
2841
+ observationState: PublicKey;
2842
+ }
2843
+ /**
2844
+ * Raydium AMM V4 protocol parameters
2845
+ */
2846
+ interface RaydiumAmmV4Params {
2847
+ amm: PublicKey;
2848
+ coinMint: PublicKey;
2849
+ pcMint: PublicKey;
2850
+ tokenCoin: PublicKey;
2851
+ tokenPc: PublicKey;
2852
+ ammOpenOrders: PublicKey;
2853
+ ammTargetOrders: PublicKey;
2854
+ serumProgram: PublicKey;
2855
+ serumMarket: PublicKey;
2856
+ serumBids: PublicKey;
2857
+ serumAsks: PublicKey;
2858
+ serumEventQueue: PublicKey;
2859
+ serumCoinVaultAccount: PublicKey;
2860
+ serumPcVaultAccount: PublicKey;
2861
+ serumVaultSigner: PublicKey;
2862
+ coinReserve: bigint;
2863
+ pcReserve: bigint;
2864
+ }
2865
+ /**
2866
+ * Meteora DAMM V2 protocol parameters
2867
+ */
2868
+ interface MeteoraDammV2Params {
2869
+ pool: PublicKey;
2870
+ tokenAVault: PublicKey;
2871
+ tokenBVault: PublicKey;
2872
+ tokenAMint: PublicKey;
2873
+ tokenBMint: PublicKey;
2874
+ tokenAProgram: PublicKey;
2875
+ tokenBProgram: PublicKey;
2876
+ }
2877
+ /**
2878
+ * Union type for DEX parameters
2879
+ */
2880
+ type DexParamEnum = {
2881
+ type: 'PumpFun';
2882
+ params: PumpFunParams;
2883
+ } | {
2884
+ type: 'PumpSwap';
2885
+ params: PumpSwapParams;
2886
+ } | {
2887
+ type: 'Bonk';
2888
+ params: BonkParams;
2889
+ } | {
2890
+ type: 'RaydiumCpmm';
2891
+ params: RaydiumCpmmParams;
2892
+ } | {
2893
+ type: 'RaydiumAmmV4';
2894
+ params: RaydiumAmmV4Params;
2895
+ } | {
2896
+ type: 'MeteoraDammV2';
2897
+ params: MeteoraDammV2Params;
2898
+ };
2899
+ /**
2900
+ * Trading configuration
2901
+ */
2902
+ interface TradeConfig {
2903
+ rpcUrl: string;
2904
+ swqosConfigs: SwqosConfig[];
2905
+ commitment?: Commitment;
2906
+ logEnabled?: boolean;
2907
+ checkMinTip?: boolean;
2908
+ mevProtection?: boolean;
2909
+ /** Default gas/CU settings when trade params omit `gasFeeStrategy`. */
2910
+ gasFeeStrategy?: GasFeeStrategyConfig;
2911
+ /**
2912
+ * Per-SWQOS gas table (Rust `GasFeeStrategy`). Used when neither trade nor `gasFeeStrategy` flat config is set.
2913
+ * Lookup uses the first SWQOS entry after `withTip` / `checkMinTip` filtering.
2914
+ */
2915
+ gasStrategy?: GasFeeStrategy;
2916
+ /** Reserved for Rust parity (seed-optimized ATA); instruction builders may ignore if not wired. */
2917
+ useSeedOptimize?: boolean;
2918
+ /** Prefer assigning SWQOS submit threads from the end of the CPU core list. */
2919
+ swqosCoresFromEnd?: boolean;
2920
+ /** If true, best-effort background WSOL ATA creation after connect (Rust `create_wsol_ata_on_startup`). */
2921
+ createWsolAtaOnStartup?: boolean;
2922
+ /**
2923
+ * Rust `MiddlewareManager`: `process_protocol_instructions` before gas/tip wiring;
2924
+ * `process_full_instructions` after nonce + tip + compute budget + protocol (see `transaction_builder.rs`).
2925
+ */
2926
+ middlewareManager?: MiddlewareManager;
2927
+ /**
2928
+ * Deprecated compatibility field. Submit hot path starts every SWQOS/default RPC route
2929
+ * immediately so the required default RPC lane is never delayed behind a local cap.
2930
+ */
2931
+ maxSwqosSubmitConcurrency?: number;
2932
+ }
2933
+ /**
2934
+ * Builder for TradeConfig - makes all options discoverable via IDE autocomplete.
2935
+ *
2936
+ * @example
2937
+ * const config = TradeConfigBuilder.create(rpcUrl)
2938
+ * .swqosConfigs([{ type: SwqosType.Jito, apiKey: 'your-key' }])
2939
+ * // .mevProtection(true) // Enable MEV protection (BlockRazor: sandwichMitigation, Astralane: port 9000)
2940
+ * .build();
2941
+ */
2942
+ declare class TradeConfigBuilder {
2943
+ private _rpcUrl;
2944
+ private _swqosConfigs;
2945
+ private _commitment?;
2946
+ private _logEnabled;
2947
+ private _checkMinTip;
2948
+ private _mevProtection;
2949
+ private _useSeedOptimize;
2950
+ private _swqosCoresFromEnd;
2951
+ private _createWsolAtaOnStartup;
2952
+ private _gasFeeStrategy?;
2953
+ private _gasStrategy?;
2954
+ private _middlewareManager?;
2955
+ private _maxSwqosSubmitConcurrency?;
2956
+ private constructor();
2957
+ static create(rpcUrl: string): TradeConfigBuilder;
2958
+ swqosConfigs(configs: SwqosConfig[]): this;
2959
+ commitment(commitment: Commitment): this;
2960
+ logEnabled(enabled: boolean): this;
2961
+ checkMinTip(check: boolean): this;
2962
+ /**
2963
+ * Enable MEV protection (default: false).
2964
+ * When enabled:
2965
+ * - BlockRazor uses mode=sandwichMitigation
2966
+ * - Astralane uses port 9000 MEV-protected QUIC endpoint
2967
+ */
2968
+ mevProtection(enabled: boolean): this;
2969
+ useSeedOptimize(enabled: boolean): this;
2970
+ swqosCoresFromEnd(enabled: boolean): this;
2971
+ createWsolAtaOnStartup(enabled: boolean): this;
2972
+ gasFeeStrategy(config: GasFeeStrategyConfig): this;
2973
+ gasStrategy(strategy: GasFeeStrategy): this;
2974
+ /** Rust `SolanaTrade::with_middleware_manager` parity. */
2975
+ middlewareManager(manager: MiddlewareManager): this;
2976
+ /**
2977
+ * Limit parallel SWQOS submits (Rust `max_sender_concurrency` / worker pool).
2978
+ */
2979
+ maxSwqosSubmitConcurrency(limit: number | undefined): this;
2980
+ build(): TradeConfig;
2981
+ }
2982
+ declare function recommendedSenderThreadCoreIndices(swqosCount: number, availableCores?: number, fromEnd?: boolean): number[];
2983
+ /**
2984
+ * Middleware context
2985
+ */
2986
+ interface MiddlewareContext {
2987
+ tradeType: TradeType;
2988
+ inputMint: PublicKey;
2989
+ outputMint: PublicKey;
2990
+ inputAmount: number;
2991
+ payer: PublicKey;
2992
+ additionalData?: Record<string, unknown>;
2993
+ }
2994
+ /**
2995
+ * Middleware interface
2996
+ */
2997
+ interface Middleware {
2998
+ process(instructions: TransactionInstruction[], context: MiddlewareContext): Promise<TransactionInstruction[]>;
2999
+ name: string;
3000
+ }
3001
+ /**
3002
+ * 按 mint 查找池地址(与 Rust `find_pool_by_mint` 一致:当前仅 PumpSwap)。
3003
+ */
3004
+ declare function findPoolByMint(connection: Connection, mint: PublicKey, dexType: DexType): Promise<PublicKey>;
3005
+ /** Rust `executor::simulate_transaction` / `RpcSimulateTransactionConfig` (processed, inner ix, no sig verify). */
3006
+ declare const RUST_PARITY_SIMULATE_CONFIG: SimulateTransactionConfig;
3007
+ /**
3008
+ * Main trading client for Solana DEX operations(指令构建与 Rust SDK 对齐,经 `instruction/*` 实现)
3009
+ */
3010
+ declare class TradingClient {
3011
+ private payer;
3012
+ private connection;
3013
+ private _config;
3014
+ private middlewares;
3015
+ private _logEnabled;
3016
+ private _swqosModulePromise?;
3017
+ private _swqosClientCache;
3018
+ constructor(payer: Keypair, config: TradeConfig);
3019
+ private getSwqosModule;
3020
+ private swqosClientCacheKey;
3021
+ private getSwqosClient;
3022
+ /** Get the current configuration */
3023
+ get config(): TradeConfig;
3024
+ /** Check if logging is enabled */
3025
+ get isLogEnabled(): boolean;
3026
+ /**
3027
+ * Get the underlying connection
3028
+ */
3029
+ getConnection(): Connection;
3030
+ /**
3031
+ * Get the payer public key
3032
+ */
3033
+ getPayer(): PublicKey;
3034
+ private rpcCommitment;
3035
+ /**
3036
+ * Add middleware to the chain
3037
+ */
3038
+ addMiddleware(middleware: Middleware): this;
3039
+ /**
3040
+ * Execute a buy order
3041
+ */
3042
+ buy(params: TradeBuyParams): Promise<TradeResult>;
3043
+ /**
3044
+ * Execute a sell order
3045
+ */
3046
+ sell(params: TradeSellParams): Promise<TradeResult>;
3047
+ /**
3048
+ * Execute a sell order for a percentage of tokens
3049
+ */
3050
+ sellByPercent(params: TradeSellParams, totalAmount: number, percent: number): Promise<TradeResult>;
3051
+ /**
3052
+ * Get latest blockhash
3053
+ */
3054
+ getLatestBlockhash(): Promise<BlockhashWithExpiryBlockHeight>;
3055
+ /**
3056
+ * Wrap SOL to WSOL
3057
+ */
3058
+ wrapSolToWsol(amount: number): Promise<string>;
3059
+ /**
3060
+ * Close WSOL account and unwrap to SOL
3061
+ */
3062
+ closeWsol(): Promise<string>;
3063
+ /**
3064
+ * Claim PumpFun bonding-curve cashback (SOL → wallet).
3065
+ */
3066
+ claimCashbackPumpfun(): Promise<string>;
3067
+ /**
3068
+ * Claim PumpSwap AMM cashback(会先走 WSOL ATA idempotent 创建,与 Rust 一致)。
3069
+ */
3070
+ claimCashbackPumpswap(): Promise<string>;
3071
+ private sendSingleInstruction;
3072
+ private sendInstructions;
3073
+ private buildBuyInstructions;
3074
+ private buildSellInstructions;
3075
+ private getInputMint;
3076
+ private getOutputMint;
3077
+ private processMiddlewares;
3078
+ private executeTransaction;
3079
+ }
3080
+ /**
3081
+ * Create a new gas fee strategy with defaults
3082
+ */
3083
+ declare function createGasFeeStrategy(): GasFeeStrategy;
3084
+ /**
3085
+ * Create a new trade config (shorthand for {@link TradeConfig} / {@link TradeConfigBuilder}).
3086
+ */
3087
+ declare function createTradeConfig(rpcUrl: string, swqosConfigs?: SwqosConfig[], options?: Partial<Omit<TradeConfig, 'rpcUrl' | 'swqosConfigs'>>): TradeConfig;
3088
+
3089
+ export { MIN_TIP_LIGHTSPEED as $, ASTRALANE_ENDPOINTS as A, type BatchTradeResult as B, ClientFactory as C, DexType$1 as D, DefaultClient as E, FLASH_BLOCK_ENDPOINTS as F, GasFeeStrategy as G, FlashBlockClient as H, type ITradeExecutor as I, HELIUS_ENDPOINTS as J, HeliusClient as K, JITO_ENDPOINTS as L, MeteoraDammV2Executor as M, JitoClient as N, LightspeedClient as O, PumpFunExecutor as P, MIN_TIP_ASTRALANE as Q, RaydiumAmmV4Executor as R, type SwqosClientConfig as S, TradeType$2 as T, MIN_TIP_BLOCK_RAZOR as U, MIN_TIP_BLOXROUTE as V, MIN_TIP_DEFAULT as W, MIN_TIP_FLASH_BLOCK as X, MIN_TIP_HELIUS as Y, MIN_TIP_HELIUS_NORMAL as Z, MIN_TIP_JITO as _, SwqosType$1 as a, DEFAULT_COMPUTE_UNITS as a$, MIN_TIP_NEXT_BLOCK as a0, MIN_TIP_NODE1 as a1, MIN_TIP_SOYAS as a2, MIN_TIP_SPEEDLANDING as a3, MIN_TIP_STELLIUM as a4, MIN_TIP_TEMPORAL as a5, MIN_TIP_ZERO_SLOT as a6, NEXT_BLOCK_ENDPOINTS as a7, NODE1_ENDPOINTS as a8, NextBlockClient as a9, BONK_POOL_STATE_SIZE as aA, BONK_POOL_VAULT_SEED as aB, BONK_PROGRAM as aC, BONK_PROGRAM_ID as aD, BONK_PROTOCOL_FEE_RATE as aE, BONK_SELL_EXACT_IN_DISCRIMINATOR as aF, BONK_SHARE_FEE_RATE as aG, BONK_USD1_GLOBAL_CONFIG as aH, BYTES_PER_ACCOUNT as aI, BaseExecutor as aJ, type BondingCurveAccount as aK, type BonkBuildBuyParams as aL, type BonkBuildSellParams as aM, type BonkParams as aN, type BonkPoolState as aO, type BonkVestingSchedule as aP, type BuildBuyParams as aQ, type BuildMeteoraDammV2BuyInstructionsParams as aR, type BuildMeteoraDammV2SellInstructionsParams as aS, type BuildRaydiumAmmV4BuyInstructionsParams as aT, type BuildRaydiumAmmV4SellInstructionsParams as aU, type BuildRaydiumCpmmBuyInstructionsParams as aV, type BuildRaydiumCpmmSellInstructionsParams as aW, type BuildSellParams as aX, CONSTANTS as aY, type ConfirmAnySignatureOptions as aZ, ContextExpiredError as a_, Node1Client as aa, Node1QuicClient as ab, SOYAS_ENDPOINTS as ac, SPEEDLANDING_ENDPOINTS as ad, STELLIUM_ENDPOINTS as ae, SoyasClient as af, SpeedlandingClient as ag, StelliumClient as ah, TEMPORAL_ENDPOINTS as ai, TemporalClient as aj, ZERO_SLOT_ENDPOINTS as ak, ZeroSlotClient as al, createSwqosClient as am, randomChoice as an, AMM_INFO_SIZE as ao, ASSOCIATED_TOKEN_PROGRAM as ap, type AccountState as aq, type AddressLookupTableAccount as ar, AddressLookupTableCache as as, AstralaneTransport as at, BONK_AUTHORITY as au, BONK_BUY_EXACT_IN_DISCRIMINATOR as av, BONK_EVENT_AUTHORITY as aw, BONK_GLOBAL_CONFIG as ax, BONK_PLATFORM_FEE_RATE as ay, BONK_POOL_SEED as az, type SwqosClient as b, PUMPFUN_SELL_DISCRIMINATOR as b$, DEFAULT_PRIORITY_FEE as b0, DEFAULT_SLIPPAGE as b1, DEFAULT_TIP_LAMPORTS as b2, type DexParamEnum as b3, DexType as b4, type DurableNonceInfo as b5, type ExecuteOptions as b6, type ExecuteResult as b7, ExecutionPath as b8, type FetchedDurableNonce as b9, type MeteoraDammV2Pool as bA, MetricsMiddleware as bB, type Middleware as bC, type MiddlewareContext as bD, MiddlewareManager as bE, MissingAccountError as bF, POOL_SIZE as bG, PUMPFUN_BONDING_CURVE_SEED as bH, PUMPFUN_BONDING_CURVE_V2_SEED as bI, PUMPFUN_BUYBACK_FEE_RECIPIENTS as bJ, PUMPFUN_BUY_DISCRIMINATOR as bK, PUMPFUN_BUY_EXACT_QUOTE_IN_V2_DISCRIMINATOR as bL, PUMPFUN_BUY_EXACT_SOL_IN_DISCRIMINATOR as bM, PUMPFUN_BUY_V2_DISCRIMINATOR as bN, PUMPFUN_CLAIM_CASHBACK_DISCRIMINATOR as bO, PUMPFUN_CREATOR_VAULT_SEED as bP, PUMPFUN_DISCRIMINATORS as bQ, PUMPFUN_EVENT_AUTHORITY as bR, PUMPFUN_FEE_CONFIG as bS, PUMPFUN_FEE_PROGRAM as bT, PUMPFUN_FEE_RECIPIENT as bU, PUMPFUN_GLOBAL_ACCOUNT as bV, PUMPFUN_GLOBAL_VOLUME_ACCUMULATOR as bW, PUMPFUN_MAYHEM_FEE_RECIPIENTS as bX, PUMPFUN_PROGRAM as bY, PUMPFUN_PROGRAM_ID as bZ, PUMPFUN_PROTOCOL_EXTRA_FEE_RECIPIENTS as b_, FilterMiddleware as ba, type GasFeeConfig as bb, type GasFeeStrategyConfig as bc, type GasFeeStrategyValue as bd, type HotPathConfig as be, HotPathError as bf, HotPathExecutor as bg, HotPathMetrics as bh, HotPathState as bi, type InstructionMiddleware as bj, InstructionProcessor as bk, KNOWN_PROGRAM_IDS as bl, type KeyMetadata as bm, KeyNotAvailableError as bn, LoggingMiddleware as bo, MARKET_STATE_SIZE as bp, MAX_INSTRUCTIONS_WARN as bq, METEORA_DAMM_V2_AUTHORITY as br, METEORA_DAMM_V2_EVENT_AUTHORITY_SEED as bs, METEORA_DAMM_V2_PROGRAM as bt, METEORA_DAMM_V2_PROGRAM_ID as bu, METEORA_DAMM_V2_SWAP2_DISCRIMINATOR as bv, METEORA_DAMM_V2_SWAP_DISCRIMINATOR as bw, METEORA_DAMM_V2_SWAP_MODE_PARTIAL_FILL as bx, METEORA_POOL_SIZE as by, type MeteoraDammV2Params as bz, GasFeeStrategyType as c, type RaydiumCpmmParams as c$, PUMPFUN_SELL_V2_DISCRIMINATOR as c0, PUMPFUN_SHARING_CONFIG_SEED as c1, PUMPFUN_STANDARD_FEE_RECIPIENTS as c2, PUMPFUN_USER_VOLUME_ACCUMULATOR_SEED as c3, PUMPSWAP_BUY_DISCRIMINATOR as c4, PUMPSWAP_BUY_EXACT_QUOTE_IN_DISCRIMINATOR as c5, PUMPSWAP_CLAIM_CASHBACK_DISCRIMINATOR as c6, PUMPSWAP_DEFAULT_COIN_CREATOR_VAULT_AUTHORITY as c7, PUMPSWAP_DISCRIMINATORS as c8, PUMPSWAP_EVENT_AUTHORITY as c9, RAYDIUM_AMM_V4_SWAP_BASE_IN_DISCRIMINATOR as cA, RAYDIUM_AMM_V4_SWAP_BASE_OUT_DISCRIMINATOR as cB, RAYDIUM_AMM_V4_SWAP_FEE_DENOMINATOR as cC, RAYDIUM_AMM_V4_SWAP_FEE_NUMERATOR as cD, RAYDIUM_AMM_V4_TRADE_FEE_DENOMINATOR as cE, RAYDIUM_AMM_V4_TRADE_FEE_NUMERATOR as cF, RAYDIUM_CPMM_AUTHORITY as cG, RAYDIUM_CPMM_CREATOR_FEE_RATE as cH, RAYDIUM_CPMM_FEE_RATE_DENOMINATOR_VALUE as cI, RAYDIUM_CPMM_FUND_FEE_RATE as cJ, RAYDIUM_CPMM_OBSERVATION_STATE_SEED as cK, RAYDIUM_CPMM_POOL_SEED as cL, RAYDIUM_CPMM_POOL_STATE_SIZE as cM, RAYDIUM_CPMM_POOL_VAULT_SEED as cN, RAYDIUM_CPMM_PROGRAM as cO, RAYDIUM_CPMM_PROGRAM_ID as cP, RAYDIUM_CPMM_PROTOCOL_FEE_RATE as cQ, RAYDIUM_CPMM_SWAP_BASE_IN_DISCRIMINATOR as cR, RAYDIUM_CPMM_SWAP_BASE_OUT_DISCRIMINATOR as cS, RAYDIUM_CPMM_TRADE_FEE_RATE as cT, RENT as cU, RUST_PARITY_SIMULATE_CONFIG as cV, type RaydiumAmmFees as cW, type RaydiumAmmInfo as cX, type RaydiumAmmOutputData as cY, type RaydiumAmmV4Params as cZ, type RaydiumCPMMpoolState as c_, PUMPSWAP_FEE_CONFIG as ca, PUMPSWAP_FEE_PROGRAM as cb, PUMPSWAP_FEE_RECIPIENT as cc, PUMPSWAP_GLOBAL_ACCOUNT as cd, PUMPSWAP_GLOBAL_VOLUME_ACCUMULATOR as ce, PUMPSWAP_MAYHEM_FEE_RECIPIENTS as cf, PUMPSWAP_PROGRAM as cg, PUMPSWAP_PROGRAM_ID as ch, PUMPSWAP_PROTOCOL_EXTRA_FEE_RECIPIENTS as ci, PUMPSWAP_PUMP_PROGRAM_ID as cj, PUMPSWAP_SELL_DISCRIMINATOR as ck, type ParserPumpFunTradeEvent as cl, type ParserPumpSwapTradeEvent as cm, type PoolState as cn, Prefetch as co, type PrefetchedData as cp, type PumpFunBondingCurve as cq, type PumpFunBuildBuyParams as cr, type PumpFunBuildSellParams as cs, type PumpFunParams as ct, type PumpSwapParams as cu, type PumpSwapPool as cv, RAYDIUM_AMM_V4_AUTHORITY as cw, RAYDIUM_AMM_V4_POOL_SEED as cx, RAYDIUM_AMM_V4_PROGRAM as cy, RAYDIUM_AMM_V4_PROGRAM_ID as cz, SwqosType as d, createTradeConfig as d$, type RaydiumMarketState as d0, SDK_FEE_RECIPIENT as d1, SDK_MAYHEM_FEE_RECIPIENTS as d2, SOL_TOKEN_ACCOUNT as d3, SWQOS_ENDPOINTS as d4, SYSTEM_PROGRAM as d5, SecureKeyError as d6, SecureKeyStorage as d7, StaleBlockhashError as d8, type SwqosConfig as d9, buildBonkBuyInstructions as dA, buildBonkSellInstructions as dB, buildBuyInstructions as dC, buildClaimCashbackInstruction as dD, buildMeteoraDammV2BuyInstructions as dE, buildMeteoraDammV2SellInstructions as dF, buildPumpFunBuyInstructions as dG, buildPumpFunBuyV2Instructions as dH, buildPumpFunClaimCashbackInstruction as dI, buildPumpFunSellInstructions as dJ, buildPumpFunSellV2Instructions as dK, buildRaydiumAmmV4BuyInstructions as dL, buildRaydiumAmmV4SellInstructions as dM, buildRaydiumCpmmBuyInstructions as dN, buildRaydiumCpmmSellInstructions as dO, buildSellInstructions as dP, calculatePriceImpact as dQ, calculateWithSlippageBuy as dR, calculateWithSlippageSell as dS, closeWsol as dT, commitmentToGetTxFinality as dU, computeRaydiumAmmV4SwapAmount as dV, computeRaydiumCpmmSwapAmount as dW, confirmAnyTransactionSignature as dX, createAssociatedTokenAccountIdempotent as dY, createGasFeeStrategy as dZ, createHotPathExecutor as d_, SwqosRegion as da, type SwqosTiming as db, SwqosTransport as dc, TOKEN_PROGRAM as dd, TOKEN_PROGRAM_2022 as de, TimerMiddleware as df, type TradeBuyParams as dg, type TradeConfig as dh, TradeConfigBuilder as di, TradeError as dj, type TradeResult as dk, type TradeSellParams as dl, TradeTokenType as dm, TradingClient as dn, TradingContext as dp, TransactionBuilder as dq, USD1_MINT as dr, USD1_TOKEN_ACCOUNT as ds, USDC_MINT as dt, USDC_TOKEN_ACCOUNT as du, ValidationError as dv, ValidationMiddleware as dw, WSOL_MINT as dx, WSOL_TOKEN_ACCOUNT as dy, addressLookupTableCache as dz, TradeType as e, getUserVolumeAccumulatorPDA as e$, decodeAmmInfo as e0, decodeBonkPoolState as e1, decodeMarketState as e2, decodeMeteoraPool as e3, decodePool as e4, decodeRaydiumCPMMpoolState as e5, defaultExecuteOptions as e6, defaultHotPathConfig as e7, deriveSerumVaultSigner as e8, extractHintsFromLogs as e9, getCoinCreatorVaultAta as eA, getCoinCreatorVaultAuthority as eB, getCreator as eC, getCreatorVaultPda as eD, getFeeConfigPDA as eE, getFeeRecipientAta as eF, getGlobalVolumeAccumulatorPDA as eG, getMayhemFeeRecipientRandom as eH, getMeteoraDammV2EventAuthorityPda as eI, getPoolV2PDA as eJ, getPumpFunBuybackFeeRecipientRandom as eK, getPumpFunFeeSharingConfigPda as eL, getPumpFunProtocolExtraFeeRecipientRandom as eM, getPumpFunUserVolumeAccumulatorPda as eN, getPumpPoolAuthorityPDA as eO, getPumpSwapProtocolExtraFeeRecipientRandom as eP, getRandomMayhemFeeRecipient as eQ, getRaydiumCPMMobservationStatePDA as eR, getRaydiumCPMMpoolPDA as eS, getRaydiumCPMMpoolTokenBalances as eT, getRaydiumCPMMvaultPDA as eU, getRaydiumCpmmObservationStatePda as eV, getRaydiumCpmmPoolPda as eW, getRaydiumCpmmVaultPda as eX, getSellSolAmountFromTokenAmount as eY, getStandardFeeRecipientRandom as eZ, getTokenBalances as e_, fetchAddressLookupTableAccount as ea, fetchAmmInfo as eb, fetchBondingCurveAccount as ec, fetchBonkPoolState as ed, fetchDurableNonceInfo as ee, fetchMarketState as ef, fetchMeteoraPool as eg, fetchPool as eh, fetchRaydiumCPMMpoolState as ei, findByBaseMint as ej, findByMint as ek, findByQuoteMint as el, findPoolByMint as em, formatPublicKey as en, getAssociatedTokenAddress as eo, getBondingCurvePda as ep, getBondingCurveV2Pda as eq, getBonkCreatorAssociatedAccount as er, getBonkPlatformAssociatedAccount as es, getBonkPoolPDA as et, getBonkPoolPda as eu, getBonkVaultPDA as ev, getBonkVaultPda as ew, getBuyPrice as ex, getBuyTokenAmountFromSolAmount as ey, getCanonicalPoolPDA as ez, BonkExecutor as f, getUserVolumeAccumulatorQuoteAta as f0, getUserVolumeAccumulatorWsolAta as f1, handleWsol as f2, instructionErrorCodeFromMetaErr as f3, isValidPublicKey as f4, lamportsToSol as f5, mapWithConcurrencyLimit as f6, nowMicroseconds as f7, parseAddressLookupTable as f8, pumpFunFeeRecipientMeta as f9, pumpFunParamsFromParserTrade as fa, pumpSwapParamsFromParserTrade as fb, recommendedSenderThreadCoreIndices as fc, retryWithBackoff as fd, signWithKeypair as fe, sleep as ff, solToLamports as fg, validateAmount as fh, validateMintPair as fi, validateProgramId as fj, validatePubkey as fk, validateRpcUrl as fl, validateSignature as fm, validateSlippage as fn, validateTransactionSize as fo, withAllBuiltinMiddlewares as fp, withStandardMiddlewares as fq, type BonkParams$1 as g, type TradeResult$1 as h, TradeType$1 as i, type MeteoraDammV2Params$1 as j, type PumpFunParams$1 as k, PumpSwapExecutor as l, type PumpSwapParams$1 as m, type RaydiumAmmV4Params$1 as n, RaydiumCpmmExecutor as o, type RaydiumCpmmParams$1 as p, type TradeExecuteOptions as q, TradeExecutorFactory as r, defaultTradeExecuteOptions as s, ASTRALANE_QUIC_HOSTS as t, AstralaneClient as u, AstralaneQuicClient as v, BLOCK_RAZOR_ENDPOINTS as w, BLOXROUTE_ENDPOINTS as x, BlockRazorClient as y, BloxrouteClient as z };