sol-trade-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +390 -0
  2. package/dist/chunk-MMQAMIKR.mjs +3735 -0
  3. package/dist/chunk-NEZDFAYA.mjs +7744 -0
  4. package/dist/clients-VITWK7B6.mjs +1370 -0
  5. package/dist/index-1BK_FXsW.d.mts +2327 -0
  6. package/dist/index-1BK_FXsW.d.ts +2327 -0
  7. package/dist/index.d.mts +2659 -0
  8. package/dist/index.d.ts +2659 -0
  9. package/dist/index.js +13265 -0
  10. package/dist/index.mjs +562 -0
  11. package/dist/perf/index.d.mts +2 -0
  12. package/dist/perf/index.d.ts +2 -0
  13. package/dist/perf/index.js +3742 -0
  14. package/dist/perf/index.mjs +214 -0
  15. package/package.json +101 -0
  16. package/src/__tests__/complete_sdk.test.ts +354 -0
  17. package/src/__tests__/hotpath.test.ts +486 -0
  18. package/src/__tests__/nonce.test.ts +45 -0
  19. package/src/__tests__/sdk.test.ts +425 -0
  20. package/src/address-lookup/index.ts +197 -0
  21. package/src/cache/cache.ts +308 -0
  22. package/src/calc/index.ts +1058 -0
  23. package/src/calc/pumpfun.ts +124 -0
  24. package/src/common/bonding_curve.ts +272 -0
  25. package/src/common/compute-budget.ts +148 -0
  26. package/src/common/confirm-any-signature.ts +184 -0
  27. package/src/common/fast-timing.ts +481 -0
  28. package/src/common/fast_fn.ts +150 -0
  29. package/src/common/gas-fee-strategy.ts +253 -0
  30. package/src/common/map-pool.ts +23 -0
  31. package/src/common/nonce.ts +40 -0
  32. package/src/common/sdk-log.ts +460 -0
  33. package/src/common/seed.ts +381 -0
  34. package/src/common/spl-token.ts +578 -0
  35. package/src/common/subscription-handle.ts +644 -0
  36. package/src/common/trading-utils.ts +239 -0
  37. package/src/common/wsol-manager.ts +325 -0
  38. package/src/compute/compute_budget_manager.ts +187 -0
  39. package/src/compute/index.ts +21 -0
  40. package/src/constants/index.ts +96 -0
  41. package/src/execution/execution.ts +532 -0
  42. package/src/execution/index.ts +42 -0
  43. package/src/hotpath/executor.ts +464 -0
  44. package/src/hotpath/index.ts +64 -0
  45. package/src/hotpath/state.ts +435 -0
  46. package/src/index.ts +2117 -0
  47. package/src/instruction/bonk_builder.ts +730 -0
  48. package/src/instruction/index.ts +24 -0
  49. package/src/instruction/meteora_damm_v2_builder.ts +509 -0
  50. package/src/instruction/pumpfun_builder.ts +1183 -0
  51. package/src/instruction/pumpswap.ts +1123 -0
  52. package/src/instruction/raydium_amm_v4_builder.ts +692 -0
  53. package/src/instruction/raydium_cpmm_builder.ts +795 -0
  54. package/src/middleware/traits.ts +407 -0
  55. package/src/params/index.ts +483 -0
  56. package/src/perf/compiler-optimization.ts +529 -0
  57. package/src/perf/hardware.ts +631 -0
  58. package/src/perf/index.ts +9 -0
  59. package/src/perf/kernel-bypass.ts +656 -0
  60. package/src/perf/protocol.ts +682 -0
  61. package/src/perf/realtime.ts +592 -0
  62. package/src/perf/simd.ts +668 -0
  63. package/src/perf/syscall-bypass.ts +331 -0
  64. package/src/perf/ultra-low-latency.ts +505 -0
  65. package/src/perf/zero-copy.ts +589 -0
  66. package/src/pool/pool.ts +294 -0
  67. package/src/rpc/client.ts +345 -0
  68. package/src/sdk-errors.ts +13 -0
  69. package/src/security/index.ts +26 -0
  70. package/src/security/secure-key.ts +303 -0
  71. package/src/security/validators.ts +281 -0
  72. package/src/seed/pda.ts +262 -0
  73. package/src/serialization/index.ts +28 -0
  74. package/src/serialization/serialization.ts +288 -0
  75. package/src/swqos/clients.ts +1754 -0
  76. package/src/swqos/index.ts +50 -0
  77. package/src/swqos/providers.ts +1707 -0
  78. package/src/trading/core/async-executor.ts +702 -0
  79. package/src/trading/core/confirmation-monitor.ts +711 -0
  80. package/src/trading/core/index.ts +82 -0
  81. package/src/trading/core/retry-handler.ts +683 -0
  82. package/src/trading/core/transaction-pool.ts +780 -0
  83. package/src/trading/executor.ts +385 -0
  84. package/src/trading/factory.ts +282 -0
  85. package/src/trading/index.ts +30 -0
  86. package/src/types.ts +8 -0
  87. package/src/utils/index.ts +155 -0
@@ -0,0 +1,2659 @@
1
+ import { TransactionInstruction, PublicKey, Keypair, Connection, Transaction, Commitment, Finality, AccountInfo, SimulateTransactionConfig, AddressLookupTableAccount as AddressLookupTableAccount$1, BlockhashWithExpiryBlockHeight } from '@solana/web3.js';
2
+ export { i as perf } from './index-1BK_FXsW.js';
3
+
4
+ /**
5
+ * Gas Fee Strategy for Sol Trade SDK
6
+ */
7
+ declare enum TradeType$1 {
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$1, 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$1, 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$1, strategyType: GasFeeStrategyType): GasFeeStrategyValue | undefined;
62
+ /**
63
+ * Delete a specific gas fee strategy
64
+ */
65
+ delete(swqosType: SwqosType$1, tradeType: TradeType$1, strategyType: GasFeeStrategyType): void;
66
+ /**
67
+ * Delete all strategies for a SWQOS type and trade type
68
+ */
69
+ deleteAll(swqosType: SwqosType$1, tradeType: TradeType$1): void;
70
+ /**
71
+ * Get all strategies for a trade type
72
+ */
73
+ getStrategies(tradeType: TradeType$1): 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$1 {
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
+ /** Quote mint for V2 instructions; default means WSOL. */
411
+ quoteMint?: PublicKey;
412
+ /** Per-params V2 toggle; global `TradeConfig.usePumpfunV2` also maps here. */
413
+ useV2Ix?: boolean;
414
+ }
415
+ interface PumpFunBuildBuyParams {
416
+ payer: Keypair | PublicKey;
417
+ outputMint: PublicKey;
418
+ inputAmount: bigint;
419
+ slippageBasisPoints?: bigint;
420
+ fixedOutputAmount?: bigint;
421
+ createOutputMintAta?: boolean;
422
+ createInputMintAta?: boolean;
423
+ protocolParams: PumpFunParams$1;
424
+ useExactSolAmount?: boolean;
425
+ usePumpFunV2?: boolean;
426
+ }
427
+ interface PumpFunBuildSellParams {
428
+ payer: Keypair | PublicKey;
429
+ inputMint: PublicKey;
430
+ inputAmount: bigint;
431
+ slippageBasisPoints?: bigint;
432
+ fixedOutputAmount?: bigint;
433
+ createOutputMintAta?: boolean;
434
+ closeInputMintAta?: boolean;
435
+ protocolParams: PumpFunParams$1;
436
+ usePumpFunV2?: boolean;
437
+ }
438
+ /**
439
+ * Build buy instructions for PumpFun protocol
440
+ * 100% port from Rust: src/instruction/pumpfun.rs build_buy_instructions
441
+ */
442
+ declare function buildPumpFunBuyInstructions(params: PumpFunBuildBuyParams): TransactionInstruction[];
443
+ /**
444
+ * Build sell instructions for PumpFun protocol
445
+ * 100% port from Rust: src/instruction/pumpfun.rs build_sell_instructions
446
+ */
447
+ declare function buildPumpFunSellInstructions(params: PumpFunBuildSellParams): TransactionInstruction[];
448
+ /**
449
+ * Build PumpFun V2 buy instructions (`buy_v2` / `buy_exact_quote_in_v2`).
450
+ */
451
+ declare function buildPumpFunBuyV2Instructions(params: PumpFunBuildBuyParams): TransactionInstruction[];
452
+ /**
453
+ * Build PumpFun V2 sell instructions (`sell_v2`).
454
+ */
455
+ declare function buildPumpFunSellV2Instructions(params: PumpFunBuildSellParams): TransactionInstruction[];
456
+ /**
457
+ * Build claim cashback instruction for PumpFun
458
+ */
459
+ declare function buildPumpFunClaimCashbackInstruction(payer: PublicKey): TransactionInstruction;
460
+ /**
461
+ * Fetch bonding curve account from RPC.
462
+ * 100% from Rust: src/instruction/utils/pumpfun.rs fetch_bonding_curve_account
463
+ */
464
+ declare function fetchBondingCurveAccount(connection: {
465
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
466
+ value?: {
467
+ data: Buffer;
468
+ };
469
+ }>;
470
+ }, mint: PublicKey): Promise<{
471
+ bondingCurve: PumpFunBondingCurve;
472
+ bondingCurvePda: PublicKey;
473
+ } | null>;
474
+ /**
475
+ * Get creator from creator vault PDA.
476
+ * 100% from Rust: src/instruction/utils/pumpfun.rs get_creator
477
+ */
478
+ declare function getCreator(creatorVaultPda: PublicKey): PublicKey;
479
+ /**
480
+ * Get buy price (tokens received for SOL).
481
+ * 100% from Rust: src/instruction/utils/pumpfun.rs get_buy_price
482
+ */
483
+ declare function getBuyPrice(amount: bigint, virtualSolReserves: bigint, virtualTokenReserves: bigint, realTokenReserves: bigint): bigint;
484
+
485
+ /**
486
+ * PumpSwap instruction builder - Production-grade implementation
487
+ * 100% port from Rust sol-trade-sdk
488
+ */
489
+
490
+ declare const PUMPSWAP_PROGRAM: PublicKey;
491
+ declare const PUMPSWAP_PUMP_PROGRAM_ID: PublicKey;
492
+ declare const PUMPSWAP_FEE_PROGRAM: PublicKey;
493
+ declare const PUMPSWAP_FEE_RECIPIENT: PublicKey;
494
+ declare const PUMPSWAP_GLOBAL_ACCOUNT: PublicKey;
495
+ declare const PUMPSWAP_EVENT_AUTHORITY: PublicKey;
496
+ declare const PUMPSWAP_GLOBAL_VOLUME_ACCUMULATOR: PublicKey;
497
+ declare const PUMPSWAP_FEE_CONFIG: PublicKey;
498
+ declare const PUMPSWAP_DEFAULT_COIN_CREATOR_VAULT_AUTHORITY: PublicKey;
499
+ declare const PUMPSWAP_MAYHEM_FEE_RECIPIENTS: PublicKey[];
500
+ /** Protocol extra fee recipients (Apr 2026); after pool-v2: readonly, then quote ATA (mutable). */
501
+ declare const PUMPSWAP_PROTOCOL_EXTRA_FEE_RECIPIENTS: PublicKey[];
502
+ declare const PUMPSWAP_BUY_DISCRIMINATOR: Buffer<ArrayBuffer>;
503
+ declare const PUMPSWAP_BUY_EXACT_QUOTE_IN_DISCRIMINATOR: Buffer<ArrayBuffer>;
504
+ declare const PUMPSWAP_SELL_DISCRIMINATOR: Buffer<ArrayBuffer>;
505
+ declare const PUMPSWAP_CLAIM_CASHBACK_DISCRIMINATOR: Buffer<ArrayBuffer>;
506
+ /**
507
+ * Get a random Mayhem fee recipient
508
+ */
509
+ declare function getMayhemFeeRecipientRandom(): PublicKey;
510
+ declare function getPumpSwapProtocolExtraFeeRecipientRandom(): PublicKey;
511
+ /**
512
+ * Pool v2 PDA (seeds: ["pool-v2", base_mint])
513
+ */
514
+ declare function getPoolV2PDA(baseMint: PublicKey): PublicKey;
515
+ /**
516
+ * Pump program pool-authority PDA (for canonical pool)
517
+ */
518
+ declare function getPumpPoolAuthorityPDA(mint: PublicKey): PublicKey;
519
+ /**
520
+ * Canonical Pump pool PDA
521
+ */
522
+ declare function getCanonicalPoolPDA(mint: PublicKey): PublicKey;
523
+ /**
524
+ * Coin creator vault authority PDA
525
+ */
526
+ declare function getCoinCreatorVaultAuthority(coinCreator: PublicKey): PublicKey;
527
+ /**
528
+ * Coin creator vault ATA
529
+ */
530
+ declare function getCoinCreatorVaultAta(coinCreator: PublicKey, quoteMint: PublicKey): PublicKey;
531
+ /**
532
+ * Fee recipient ATA
533
+ */
534
+ declare function getFeeRecipientAta(feeRecipient: PublicKey, quoteMint: PublicKey): PublicKey;
535
+ /**
536
+ * User volume accumulator PDA
537
+ */
538
+ declare function getUserVolumeAccumulatorPDA(user: PublicKey): PublicKey;
539
+ /**
540
+ * WSOL ATA of UserVolumeAccumulator (for buy cashback)
541
+ */
542
+ declare function getUserVolumeAccumulatorWsolAta(user: PublicKey): PublicKey;
543
+ /**
544
+ * Quote-mint ATA of UserVolumeAccumulator (for sell cashback)
545
+ */
546
+ declare function getUserVolumeAccumulatorQuoteAta(user: PublicKey, quoteMint: PublicKey, quoteTokenProgram: PublicKey): PublicKey;
547
+ /**
548
+ * Global volume accumulator PDA
549
+ * Seeds: ["global_volume_accumulator"], owner: PUMPSWAP_PROGRAM
550
+ */
551
+ declare function getGlobalVolumeAccumulatorPDA(): PublicKey;
552
+ /**
553
+ * Get associated token address
554
+ */
555
+ declare function getAssociatedTokenAddress(owner: PublicKey, mint: PublicKey, tokenProgram?: PublicKey): PublicKey;
556
+ /**
557
+ * Create WSOL ATA and wrap SOL
558
+ * Returns instructions for: create ATA (idempotent), transfer SOL, sync_native
559
+ */
560
+ declare function handleWsol(owner: PublicKey, amount: bigint): TransactionInstruction[];
561
+ /**
562
+ * Close WSOL ATA and reclaim rent
563
+ */
564
+ declare function closeWsol(owner: PublicKey): TransactionInstruction;
565
+ /**
566
+ * Create associated token account idempotent
567
+ */
568
+ declare function createAssociatedTokenAccountIdempotent(payer: PublicKey, owner: PublicKey, mint: PublicKey, tokenProgram?: PublicKey): TransactionInstruction;
569
+ interface PumpSwapParams$1 {
570
+ pool: PublicKey;
571
+ baseMint: PublicKey;
572
+ quoteMint: PublicKey;
573
+ poolBaseTokenAccount: PublicKey;
574
+ poolQuoteTokenAccount: PublicKey;
575
+ poolBaseTokenReserves: bigint;
576
+ poolQuoteTokenReserves: bigint;
577
+ coinCreatorVaultAta: PublicKey;
578
+ coinCreatorVaultAuthority: PublicKey;
579
+ baseTokenProgram: PublicKey;
580
+ quoteTokenProgram: PublicKey;
581
+ isMayhemMode: boolean;
582
+ isCashbackCoin: boolean;
583
+ }
584
+ interface BuildBuyParams {
585
+ payer: PublicKey;
586
+ inputAmount: bigint;
587
+ slippageBasisPoints: bigint;
588
+ protocolParams: PumpSwapParams$1;
589
+ createInputMintAta?: boolean;
590
+ closeInputMintAta?: boolean;
591
+ createOutputMintAta?: boolean;
592
+ useExactQuoteAmount?: boolean;
593
+ fixedOutputAmount?: bigint;
594
+ }
595
+ interface BuildSellParams {
596
+ payer: PublicKey;
597
+ inputAmount: bigint;
598
+ slippageBasisPoints: bigint;
599
+ protocolParams: PumpSwapParams$1;
600
+ createOutputMintAta?: boolean;
601
+ closeOutputMintAta?: boolean;
602
+ closeInputMintAta?: boolean;
603
+ fixedOutputAmount?: bigint;
604
+ }
605
+ /**
606
+ * Build buy instructions for PumpSwap
607
+ * 100% port from Rust: src/instruction/pumpswap.rs build_buy_instructions
608
+ */
609
+ declare function buildBuyInstructions(params: BuildBuyParams): TransactionInstruction[];
610
+ /**
611
+ * Build sell instructions for PumpSwap
612
+ * 100% port from Rust: src/instruction/pumpswap.rs build_sell_instructions
613
+ */
614
+ declare function buildSellInstructions(params: BuildSellParams): TransactionInstruction[];
615
+ /**
616
+ * Build claim cashback instruction for PumpSwap
617
+ */
618
+ declare function buildClaimCashbackInstruction(payer: PublicKey, quoteMint: PublicKey, quoteTokenProgram: PublicKey): TransactionInstruction;
619
+ /**
620
+ * Pool size in bytes (244 bytes as per pump-public-docs)
621
+ */
622
+ declare const POOL_SIZE = 244;
623
+ /**
624
+ * PumpSwap Pool structure
625
+ * Matches Rust: src/instruction/utils/pumpswap_types.rs Pool struct
626
+ */
627
+ interface PumpSwapPool {
628
+ poolBump: number;
629
+ index: number;
630
+ creator: PublicKey;
631
+ baseMint: PublicKey;
632
+ quoteMint: PublicKey;
633
+ lpMint: PublicKey;
634
+ poolBaseTokenAccount: PublicKey;
635
+ poolQuoteTokenAccount: PublicKey;
636
+ lpSupply: bigint;
637
+ coinCreator: PublicKey;
638
+ isMayhemMode: boolean;
639
+ isCashbackCoin: boolean;
640
+ }
641
+ /**
642
+ * Decode a PumpSwap pool from account data
643
+ * Uses Borsh deserialization
644
+ */
645
+ declare function decodePool(data: Buffer): PumpSwapPool | null;
646
+ /**
647
+ * Get fee config PDA
648
+ */
649
+ declare function getFeeConfigPDA(): PublicKey;
650
+ /**
651
+ * Fetch a PumpSwap pool from RPC.
652
+ * 100% from Rust: src/instruction/utils/pumpswap.rs fetch_pool
653
+ */
654
+ declare function fetchPool(connection: {
655
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
656
+ value?: {
657
+ data: Buffer;
658
+ };
659
+ }>;
660
+ }, poolAddress: PublicKey): Promise<PumpSwapPool | null>;
661
+ /**
662
+ * Get token balances for a pool's token accounts.
663
+ * 100% from Rust: src/instruction/utils/pumpswap.rs get_token_balances
664
+ */
665
+ declare function getTokenBalances(connection: {
666
+ getTokenAccountBalance: (pubkey: PublicKey) => Promise<{
667
+ value?: {
668
+ amount: string;
669
+ };
670
+ }>;
671
+ }, pool: PumpSwapPool): Promise<{
672
+ baseBalance: bigint;
673
+ quoteBalance: bigint;
674
+ } | null>;
675
+ /**
676
+ * Find a PumpSwap pool by mint with full RPC lookup.
677
+ * 100% from Rust: src/instruction/utils/pumpswap.rs find_by_mint
678
+ * Search order:
679
+ * 1. Pool v2 PDA ["pool-v2", base_mint]
680
+ * 2. Canonical pool PDA
681
+ * 3. getProgramAccounts by base_mint / quote_mint (optional fallback)
682
+ */
683
+ declare function findByMint(connection: {
684
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
685
+ value?: {
686
+ data: Buffer;
687
+ };
688
+ }>;
689
+ getProgramAccounts?: (programId: PublicKey, config?: unknown) => Promise<Array<{
690
+ pubkey: PublicKey;
691
+ account: {
692
+ data: Buffer;
693
+ };
694
+ }>>;
695
+ }, mint: PublicKey): Promise<{
696
+ poolAddress: PublicKey;
697
+ pool: PumpSwapPool;
698
+ } | null>;
699
+ /**
700
+ * Find a PumpSwap pool by base mint using getProgramAccounts.
701
+ * 100% from Rust: src/instruction/utils/pumpswap.rs find_by_base_mint
702
+ * base_mint offset: 8(discriminator) + 1(bump) + 2(index) + 32(creator) = 43
703
+ */
704
+ declare function findByBaseMint(connection: {
705
+ getProgramAccounts: (programId: PublicKey, config?: {
706
+ filters?: Array<{
707
+ dataSize?: number;
708
+ memcmp?: {
709
+ offset: number;
710
+ bytes: string;
711
+ };
712
+ }>;
713
+ encoding?: string;
714
+ }) => Promise<Array<{
715
+ pubkey: PublicKey;
716
+ account: {
717
+ data: Buffer;
718
+ };
719
+ }>>;
720
+ }, baseMint: PublicKey): Promise<{
721
+ poolAddress: PublicKey;
722
+ pool: PumpSwapPool;
723
+ } | null>;
724
+ /**
725
+ * Find a PumpSwap pool by quote mint using getProgramAccounts.
726
+ * 100% from Rust: src/instruction/utils/pumpswap.rs find_by_quote_mint
727
+ * quote_mint offset: 8 + 1 + 2 + 32 + 32 = 75
728
+ */
729
+ declare function findByQuoteMint(connection: {
730
+ getProgramAccounts: (programId: PublicKey, config?: {
731
+ filters?: Array<{
732
+ dataSize?: number;
733
+ memcmp?: {
734
+ offset: number;
735
+ bytes: string;
736
+ };
737
+ }>;
738
+ encoding?: string;
739
+ }) => Promise<Array<{
740
+ pubkey: PublicKey;
741
+ account: {
742
+ data: Buffer;
743
+ };
744
+ }>>;
745
+ }, quoteMint: PublicKey): Promise<{
746
+ poolAddress: PublicKey;
747
+ pool: PumpSwapPool;
748
+ } | null>;
749
+
750
+ /**
751
+ * Bonk Protocol Instruction Builder
752
+ *
753
+ * Production-grade instruction builder for Bonk AMM protocol.
754
+ * Supports buy and sell operations with WSOL and USD1 pools.
755
+ * 100% port from Rust: src/instruction/bonk.rs
756
+ */
757
+
758
+ /** Bonk program ID */
759
+ declare const BONK_PROGRAM_ID: PublicKey;
760
+ /** Bonk Authority */
761
+ declare const BONK_AUTHORITY: PublicKey;
762
+ /** Bonk Global Config */
763
+ declare const BONK_GLOBAL_CONFIG: PublicKey;
764
+ /** Bonk USD1 Global Config */
765
+ declare const BONK_USD1_GLOBAL_CONFIG: PublicKey;
766
+ /** Bonk Event Authority */
767
+ declare const BONK_EVENT_AUTHORITY: PublicKey;
768
+ /** WSOL Token Account (mint) */
769
+ declare const WSOL_MINT: PublicKey;
770
+ /** USD1 Token Account (mint) */
771
+ declare const USD1_MINT: PublicKey;
772
+ /** USDC Token Account (mint) */
773
+ declare const USDC_MINT: PublicKey;
774
+ /** Fee rates - from Rust */
775
+ declare const BONK_PLATFORM_FEE_RATE: bigint;
776
+ declare const BONK_PROTOCOL_FEE_RATE: bigint;
777
+ declare const BONK_SHARE_FEE_RATE: bigint;
778
+ /** Buy exact in instruction discriminator */
779
+ declare const BONK_BUY_EXACT_IN_DISCRIMINATOR: Buffer;
780
+ /** Sell exact in instruction discriminator */
781
+ declare const BONK_SELL_EXACT_IN_DISCRIMINATOR: Buffer;
782
+ declare const BONK_POOL_SEED: Buffer<ArrayBuffer>;
783
+ declare const BONK_POOL_VAULT_SEED: Buffer<ArrayBuffer>;
784
+ /**
785
+ * Derive the pool PDA for given base and quote mints
786
+ */
787
+ declare function getBonkPoolPda(baseMint: PublicKey, quoteMint: PublicKey): PublicKey;
788
+ /**
789
+ * Derive the vault PDA for given pool and mint
790
+ */
791
+ declare function getBonkVaultPda(poolState: PublicKey, mint: PublicKey): PublicKey;
792
+ /**
793
+ * Get platform associated account PDA
794
+ */
795
+ declare function getBonkPlatformAssociatedAccount(platformConfig: PublicKey): PublicKey;
796
+ /**
797
+ * Get creator associated account PDA
798
+ */
799
+ declare function getBonkCreatorAssociatedAccount(creator: PublicKey): PublicKey;
800
+ interface BonkParams$1 {
801
+ poolState: PublicKey;
802
+ baseVault: PublicKey;
803
+ quoteVault: PublicKey;
804
+ virtualBase: bigint;
805
+ virtualQuote: bigint;
806
+ realBase: bigint;
807
+ realQuote: bigint;
808
+ mintTokenProgram: PublicKey;
809
+ platformConfig: PublicKey;
810
+ platformAssociatedAccount: PublicKey;
811
+ creatorAssociatedAccount: PublicKey;
812
+ globalConfig?: PublicKey;
813
+ }
814
+ interface BonkBuildBuyParams {
815
+ payer: Keypair | PublicKey;
816
+ outputMint: PublicKey;
817
+ inputAmount: bigint;
818
+ slippageBasisPoints?: bigint;
819
+ fixedOutputAmount?: bigint;
820
+ createInputMintAta?: boolean;
821
+ createOutputMintAta?: boolean;
822
+ closeInputMintAta?: boolean;
823
+ protocolParams: BonkParams$1;
824
+ }
825
+ interface BonkBuildSellParams {
826
+ payer: Keypair | PublicKey;
827
+ inputMint: PublicKey;
828
+ inputAmount: bigint;
829
+ slippageBasisPoints?: bigint;
830
+ fixedOutputAmount?: bigint;
831
+ createOutputMintAta?: boolean;
832
+ closeOutputMintAta?: boolean;
833
+ closeInputMintAta?: boolean;
834
+ protocolParams: BonkParams$1;
835
+ }
836
+ /**
837
+ * Build buy instructions for Bonk protocol
838
+ * 100% port from Rust: src/instruction/bonk.rs build_buy_instructions
839
+ */
840
+ declare function buildBonkBuyInstructions(params: BonkBuildBuyParams): TransactionInstruction[];
841
+ /**
842
+ * Build sell instructions for Bonk protocol
843
+ * 100% port from Rust: src/instruction/bonk.rs build_sell_instructions
844
+ */
845
+ declare function buildBonkSellInstructions(params: BonkBuildSellParams): TransactionInstruction[];
846
+ declare const BONK_POOL_STATE_SIZE = 421;
847
+ interface BonkVestingSchedule {
848
+ totalLockedAmount: bigint;
849
+ cliffPeriod: bigint;
850
+ unlockPeriod: bigint;
851
+ startTime: bigint;
852
+ allocatedShareAmount: bigint;
853
+ }
854
+ interface BonkPoolState {
855
+ epoch: bigint;
856
+ authBump: number;
857
+ status: number;
858
+ baseDecimals: number;
859
+ quoteDecimals: number;
860
+ migrateType: number;
861
+ supply: bigint;
862
+ totalBaseSell: bigint;
863
+ virtualBase: bigint;
864
+ virtualQuote: bigint;
865
+ realBase: bigint;
866
+ realQuote: bigint;
867
+ totalQuoteFundRaising: bigint;
868
+ quoteProtocolFee: bigint;
869
+ platformFee: bigint;
870
+ migrateFee: bigint;
871
+ vestingSchedule: BonkVestingSchedule;
872
+ globalConfig: PublicKey;
873
+ platformConfig: PublicKey;
874
+ baseMint: PublicKey;
875
+ quoteMint: PublicKey;
876
+ baseVault: PublicKey;
877
+ quoteVault: PublicKey;
878
+ creator: PublicKey;
879
+ }
880
+ /**
881
+ * Decode a Bonk pool state from account data
882
+ * 100% from Rust: src/instruction/utils/bonk_types.rs pool_state_decode
883
+ */
884
+ declare function decodeBonkPoolState(data: Buffer): BonkPoolState | null;
885
+ /**
886
+ * Fetch a Bonk pool state from RPC.
887
+ * 100% from Rust: src/instruction/utils/bonk.rs fetch_pool_state
888
+ */
889
+ declare function fetchBonkPoolState(connection: {
890
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
891
+ value?: {
892
+ data: Buffer;
893
+ };
894
+ }>;
895
+ }, poolAddress: PublicKey): Promise<BonkPoolState | null>;
896
+ /**
897
+ * Get pool PDA for Bonk.
898
+ * Seeds: ["pool", base_mint, quote_mint]
899
+ */
900
+ declare function getBonkPoolPDA(baseMint: PublicKey, quoteMint: PublicKey): PublicKey;
901
+ /**
902
+ * Get vault PDA for Bonk.
903
+ * Seeds: ["pool_vault", pool_state, mint]
904
+ */
905
+ declare function getBonkVaultPDA(poolState: PublicKey, mint: PublicKey): PublicKey;
906
+
907
+ /**
908
+ * Raydium CPMM (Concentrated Pool Market Maker) Protocol Instruction Builder
909
+ *
910
+ * Production-grade instruction builder for Raydium CPMM protocol.
911
+ * 100% port of Rust implementation.
912
+ */
913
+
914
+ /** Raydium CPMM program ID */
915
+ declare const RAYDIUM_CPMM_PROGRAM_ID: PublicKey;
916
+ /** Authority */
917
+ declare const RAYDIUM_CPMM_AUTHORITY: PublicKey;
918
+ /** Fee rates */
919
+ declare const RAYDIUM_CPMM_FEE_RATE_DENOMINATOR_VALUE: bigint;
920
+ declare const RAYDIUM_CPMM_TRADE_FEE_RATE: bigint;
921
+ declare const RAYDIUM_CPMM_CREATOR_FEE_RATE: bigint;
922
+ declare const RAYDIUM_CPMM_PROTOCOL_FEE_RATE: bigint;
923
+ declare const RAYDIUM_CPMM_FUND_FEE_RATE: bigint;
924
+ /** Swap base in instruction discriminator */
925
+ declare const RAYDIUM_CPMM_SWAP_BASE_IN_DISCRIMINATOR: Buffer;
926
+ /** Swap base out instruction discriminator */
927
+ declare const RAYDIUM_CPMM_SWAP_BASE_OUT_DISCRIMINATOR: Buffer;
928
+ declare const RAYDIUM_CPMM_POOL_SEED: Buffer<ArrayBuffer>;
929
+ declare const RAYDIUM_CPMM_POOL_VAULT_SEED: Buffer<ArrayBuffer>;
930
+ declare const RAYDIUM_CPMM_OBSERVATION_STATE_SEED: Buffer<ArrayBuffer>;
931
+ /**
932
+ * Derive the pool PDA for given config and mints
933
+ */
934
+ declare function getRaydiumCpmmPoolPda(ammConfig: PublicKey, mint1: PublicKey, mint2: PublicKey): PublicKey;
935
+ /**
936
+ * Derive the vault PDA for a pool and mint
937
+ */
938
+ declare function getRaydiumCpmmVaultPda(poolState: PublicKey, mint: PublicKey): PublicKey;
939
+ /**
940
+ * Derive the observation state PDA for a pool
941
+ */
942
+ declare function getRaydiumCpmmObservationStatePda(poolState: PublicKey): PublicKey;
943
+ /**
944
+ * Compute swap amount for CPMM
945
+ */
946
+ declare function computeRaydiumCpmmSwapAmount(baseReserve: bigint, quoteReserve: bigint, isBaseIn: boolean, amountIn: bigint, slippageBasisPoints: bigint): {
947
+ amountOut: bigint;
948
+ minAmountOut: bigint;
949
+ };
950
+ interface RaydiumCpmmParams$1 {
951
+ poolState?: PublicKey;
952
+ ammConfig: PublicKey;
953
+ baseMint: PublicKey;
954
+ quoteMint: PublicKey;
955
+ baseTokenProgram: PublicKey;
956
+ quoteTokenProgram: PublicKey;
957
+ baseVault?: PublicKey;
958
+ quoteVault?: PublicKey;
959
+ baseReserve: bigint;
960
+ quoteReserve: bigint;
961
+ observationState?: PublicKey;
962
+ }
963
+ interface BuildRaydiumCpmmBuyInstructionsParams {
964
+ payer: Keypair | PublicKey;
965
+ outputMint: PublicKey;
966
+ inputAmount: bigint;
967
+ slippageBasisPoints?: bigint;
968
+ fixedOutputAmount?: bigint;
969
+ createInputMintAta?: boolean;
970
+ createOutputMintAta?: boolean;
971
+ closeInputMintAta?: boolean;
972
+ protocolParams: RaydiumCpmmParams$1;
973
+ }
974
+ interface BuildRaydiumCpmmSellInstructionsParams {
975
+ payer: Keypair | PublicKey;
976
+ inputMint: PublicKey;
977
+ inputAmount: bigint;
978
+ slippageBasisPoints?: bigint;
979
+ fixedOutputAmount?: bigint;
980
+ createOutputMintAta?: boolean;
981
+ closeOutputMintAta?: boolean;
982
+ closeInputMintAta?: boolean;
983
+ protocolParams: RaydiumCpmmParams$1;
984
+ }
985
+ /**
986
+ * Build buy instructions for Raydium CPMM protocol
987
+ */
988
+ declare function buildRaydiumCpmmBuyInstructions(params: BuildRaydiumCpmmBuyInstructionsParams): TransactionInstruction[];
989
+ /**
990
+ * Build sell instructions for Raydium CPMM protocol
991
+ */
992
+ declare function buildRaydiumCpmmSellInstructions(params: BuildRaydiumCpmmSellInstructionsParams): TransactionInstruction[];
993
+ declare const RAYDIUM_CPMM_POOL_STATE_SIZE = 629;
994
+ interface RaydiumCPMMpoolState {
995
+ ammConfig: PublicKey;
996
+ poolCreator: PublicKey;
997
+ token0Vault: PublicKey;
998
+ token1Vault: PublicKey;
999
+ lpMint: PublicKey;
1000
+ token0Mint: PublicKey;
1001
+ token1Mint: PublicKey;
1002
+ token0Program: PublicKey;
1003
+ token1Program: PublicKey;
1004
+ observationKey: PublicKey;
1005
+ authBump: number;
1006
+ status: number;
1007
+ lpMintDecimals: number;
1008
+ mint0Decimals: number;
1009
+ mint1Decimals: number;
1010
+ lpSupply: bigint;
1011
+ protocolFeesToken0: bigint;
1012
+ protocolFeesToken1: bigint;
1013
+ fundFeesToken0: bigint;
1014
+ fundFeesToken1: bigint;
1015
+ openTime: bigint;
1016
+ recentEpoch: bigint;
1017
+ }
1018
+ /**
1019
+ * Decode a Raydium CPMM pool state from account data
1020
+ * 100% from Rust: src/instruction/utils/raydium_cpmm_types.rs pool_state_decode
1021
+ */
1022
+ declare function decodeRaydiumCPMMpoolState(data: Buffer): RaydiumCPMMpoolState | null;
1023
+ /**
1024
+ * Fetch a Raydium CPMM pool state from RPC.
1025
+ * 100% from Rust: src/instruction/utils/raydium_cpmm.rs fetch_pool_state
1026
+ */
1027
+ declare function fetchRaydiumCPMMpoolState(connection: {
1028
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
1029
+ value?: {
1030
+ data: Buffer;
1031
+ };
1032
+ }>;
1033
+ }, poolAddress: PublicKey): Promise<RaydiumCPMMpoolState | null>;
1034
+ /**
1035
+ * Get pool PDA for Raydium CPMM.
1036
+ * Seeds: ["pool", amm_config, mint1, mint2]
1037
+ */
1038
+ declare function getRaydiumCPMMpoolPDA(ammConfig: PublicKey, mint1: PublicKey, mint2: PublicKey): PublicKey;
1039
+ /**
1040
+ * Get vault PDA for Raydium CPMM.
1041
+ * Seeds: ["pool_vault", pool_state, mint]
1042
+ */
1043
+ declare function getRaydiumCPMMvaultPDA(poolState: PublicKey, mint: PublicKey): PublicKey;
1044
+ /**
1045
+ * Get observation state PDA for Raydium CPMM.
1046
+ * Seeds: ["observation", pool_state]
1047
+ */
1048
+ declare function getRaydiumCPMMobservationStatePDA(poolState: PublicKey): PublicKey;
1049
+ /**
1050
+ * Get token balances for a Raydium CPMM pool.
1051
+ * 100% from Rust: src/instruction/utils/raydium_cpmm.rs get_pool_token_balances
1052
+ */
1053
+ declare function getRaydiumCPMMpoolTokenBalances(connection: {
1054
+ getTokenAccountBalance: (pubkey: PublicKey) => Promise<{
1055
+ value?: {
1056
+ amount: string;
1057
+ };
1058
+ }>;
1059
+ }, poolState: PublicKey, token0Mint: PublicKey, token1Mint: PublicKey): Promise<{
1060
+ token0Balance: bigint;
1061
+ token1Balance: bigint;
1062
+ } | null>;
1063
+
1064
+ /**
1065
+ * Raydium AMM V4 Protocol Instruction Builder
1066
+ *
1067
+ * Production-grade instruction builder for Raydium AMM V4 protocol.
1068
+ * 100% port of Rust implementation.
1069
+ */
1070
+
1071
+ /** Raydium AMM V4 program ID */
1072
+ declare const RAYDIUM_AMM_V4_PROGRAM_ID: PublicKey;
1073
+ /** Authority */
1074
+ declare const RAYDIUM_AMM_V4_AUTHORITY: PublicKey;
1075
+ /** Fee rates */
1076
+ declare const RAYDIUM_AMM_V4_TRADE_FEE_NUMERATOR: bigint;
1077
+ declare const RAYDIUM_AMM_V4_TRADE_FEE_DENOMINATOR: bigint;
1078
+ declare const RAYDIUM_AMM_V4_SWAP_FEE_NUMERATOR: bigint;
1079
+ declare const RAYDIUM_AMM_V4_SWAP_FEE_DENOMINATOR: bigint;
1080
+ /** Swap base in instruction discriminator (single byte) */
1081
+ declare const RAYDIUM_AMM_V4_SWAP_BASE_IN_DISCRIMINATOR: Buffer;
1082
+ /** Swap base out instruction discriminator (single byte) */
1083
+ declare const RAYDIUM_AMM_V4_SWAP_BASE_OUT_DISCRIMINATOR: Buffer;
1084
+ declare const RAYDIUM_AMM_V4_POOL_SEED: Buffer<ArrayBuffer>;
1085
+ /**
1086
+ * Compute swap amount for AMM V4
1087
+ */
1088
+ declare function computeRaydiumAmmV4SwapAmount(coinReserve: bigint, pcReserve: bigint, isCoinIn: boolean, amountIn: bigint, slippageBasisPoints: bigint): {
1089
+ amountOut: bigint;
1090
+ minAmountOut: bigint;
1091
+ };
1092
+ interface RaydiumAmmV4Params$1 {
1093
+ amm: PublicKey;
1094
+ coinMint: PublicKey;
1095
+ pcMint: PublicKey;
1096
+ tokenCoin: PublicKey;
1097
+ tokenPc: PublicKey;
1098
+ coinReserve: bigint;
1099
+ pcReserve: bigint;
1100
+ }
1101
+ interface BuildRaydiumAmmV4BuyInstructionsParams {
1102
+ payer: Keypair | PublicKey;
1103
+ outputMint: PublicKey;
1104
+ inputAmount: bigint;
1105
+ slippageBasisPoints?: bigint;
1106
+ fixedOutputAmount?: bigint;
1107
+ createInputMintAta?: boolean;
1108
+ createOutputMintAta?: boolean;
1109
+ closeInputMintAta?: boolean;
1110
+ protocolParams: RaydiumAmmV4Params$1;
1111
+ }
1112
+ interface BuildRaydiumAmmV4SellInstructionsParams {
1113
+ payer: Keypair | PublicKey;
1114
+ inputMint: PublicKey;
1115
+ inputAmount: bigint;
1116
+ slippageBasisPoints?: bigint;
1117
+ fixedOutputAmount?: bigint;
1118
+ createOutputMintAta?: boolean;
1119
+ closeOutputMintAta?: boolean;
1120
+ closeInputMintAta?: boolean;
1121
+ protocolParams: RaydiumAmmV4Params$1;
1122
+ }
1123
+ /**
1124
+ * Build buy instructions for Raydium AMM V4 protocol
1125
+ */
1126
+ declare function buildRaydiumAmmV4BuyInstructions(params: BuildRaydiumAmmV4BuyInstructionsParams): TransactionInstruction[];
1127
+ /**
1128
+ * Build sell instructions for Raydium AMM V4 protocol
1129
+ */
1130
+ declare function buildRaydiumAmmV4SellInstructions(params: BuildRaydiumAmmV4SellInstructionsParams): TransactionInstruction[];
1131
+ declare const AMM_INFO_SIZE = 752;
1132
+ interface RaydiumAmmFees {
1133
+ minSeparateNumerator: bigint;
1134
+ minSeparateDenominator: bigint;
1135
+ tradeFeeNumerator: bigint;
1136
+ tradeFeeDenominator: bigint;
1137
+ pnlNumerator: bigint;
1138
+ pnlDenominator: bigint;
1139
+ swapFeeNumerator: bigint;
1140
+ swapFeeDenominator: bigint;
1141
+ }
1142
+ interface RaydiumAmmOutputData {
1143
+ needTakePnlCoin: bigint;
1144
+ needTakePnlPc: bigint;
1145
+ totalPnlPc: bigint;
1146
+ totalPnlCoin: bigint;
1147
+ poolOpenTime: bigint;
1148
+ punishPcAmount: bigint;
1149
+ punishCoinAmount: bigint;
1150
+ orderbookToInitTime: bigint;
1151
+ swapCoinInAmount: bigint;
1152
+ swapPcOutAmount: bigint;
1153
+ swapTakePcFee: bigint;
1154
+ swapPcInAmount: bigint;
1155
+ swapCoinOutAmount: bigint;
1156
+ swapTakeCoinFee: bigint;
1157
+ }
1158
+ interface RaydiumAmmInfo {
1159
+ status: bigint;
1160
+ nonce: bigint;
1161
+ orderNum: bigint;
1162
+ depth: bigint;
1163
+ coinDecimals: bigint;
1164
+ pcDecimals: bigint;
1165
+ state: bigint;
1166
+ resetFlag: bigint;
1167
+ minSize: bigint;
1168
+ volMaxCutRatio: bigint;
1169
+ amountWave: bigint;
1170
+ coinLotSize: bigint;
1171
+ pcLotSize: bigint;
1172
+ minPriceMultiplier: bigint;
1173
+ maxPriceMultiplier: bigint;
1174
+ sysDecimalValue: bigint;
1175
+ fees: RaydiumAmmFees;
1176
+ output: RaydiumAmmOutputData;
1177
+ tokenCoin: PublicKey;
1178
+ tokenPc: PublicKey;
1179
+ coinMint: PublicKey;
1180
+ pcMint: PublicKey;
1181
+ lpMint: PublicKey;
1182
+ openOrders: PublicKey;
1183
+ market: PublicKey;
1184
+ serumDex: PublicKey;
1185
+ targetOrders: PublicKey;
1186
+ withdrawQueue: PublicKey;
1187
+ tokenTempLp: PublicKey;
1188
+ ammOwner: PublicKey;
1189
+ lpAmount: bigint;
1190
+ clientOrderId: bigint;
1191
+ }
1192
+ /**
1193
+ * Decode Raydium AMM v4 info from account data.
1194
+ * 100% from Rust: src/instruction/utils/raydium_amm_v4_types.rs amm_info_decode
1195
+ */
1196
+ declare function decodeAmmInfo(data: Buffer): RaydiumAmmInfo | null;
1197
+ /**
1198
+ * Fetch AMM info from RPC.
1199
+ * 100% from Rust: src/instruction/utils/raydium_amm_v4.rs fetch_amm_info
1200
+ */
1201
+ declare function fetchAmmInfo(connection: {
1202
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
1203
+ value?: {
1204
+ data: Buffer;
1205
+ };
1206
+ }>;
1207
+ }, amm: PublicKey): Promise<RaydiumAmmInfo | null>;
1208
+
1209
+ /**
1210
+ * Meteora DAMM V2 Protocol Instruction Builder
1211
+ *
1212
+ * Production-grade instruction builder for Meteora DAMM V2 protocol.
1213
+ * 100% port of Rust implementation.
1214
+ */
1215
+
1216
+ /** Meteora DAMM V2 program ID */
1217
+ declare const METEORA_DAMM_V2_PROGRAM_ID: PublicKey;
1218
+ /** Authority */
1219
+ declare const METEORA_DAMM_V2_AUTHORITY: PublicKey;
1220
+ /** Swap instruction discriminator */
1221
+ declare const METEORA_DAMM_V2_SWAP_DISCRIMINATOR: Buffer;
1222
+ declare const METEORA_DAMM_V2_EVENT_AUTHORITY_SEED: Buffer<ArrayBuffer>;
1223
+ /**
1224
+ * Derive the event authority PDA
1225
+ */
1226
+ declare function getMeteoraDammV2EventAuthorityPda(): PublicKey;
1227
+ interface MeteoraDammV2Params$1 {
1228
+ pool: PublicKey;
1229
+ tokenAMint: PublicKey;
1230
+ tokenBMint: PublicKey;
1231
+ tokenAVault: PublicKey;
1232
+ tokenBVault: PublicKey;
1233
+ tokenAProgram: PublicKey;
1234
+ tokenBProgram: PublicKey;
1235
+ }
1236
+ interface BuildMeteoraDammV2BuyInstructionsParams {
1237
+ payer: Keypair | PublicKey;
1238
+ inputMint: PublicKey;
1239
+ outputMint: PublicKey;
1240
+ inputAmount: bigint;
1241
+ slippageBasisPoints?: bigint;
1242
+ fixedOutputAmount?: bigint;
1243
+ createInputMintAta?: boolean;
1244
+ createOutputMintAta?: boolean;
1245
+ closeInputMintAta?: boolean;
1246
+ protocolParams: MeteoraDammV2Params$1;
1247
+ }
1248
+ interface BuildMeteoraDammV2SellInstructionsParams {
1249
+ payer: Keypair | PublicKey;
1250
+ inputMint: PublicKey;
1251
+ outputMint: PublicKey;
1252
+ inputAmount: bigint;
1253
+ slippageBasisPoints?: bigint;
1254
+ fixedOutputAmount?: bigint;
1255
+ createOutputMintAta?: boolean;
1256
+ closeOutputMintAta?: boolean;
1257
+ closeInputMintAta?: boolean;
1258
+ protocolParams: MeteoraDammV2Params$1;
1259
+ }
1260
+ /**
1261
+ * Build buy instructions for Meteora DAMM V2 protocol
1262
+ */
1263
+ declare function buildMeteoraDammV2BuyInstructions(params: BuildMeteoraDammV2BuyInstructionsParams): TransactionInstruction[];
1264
+ /**
1265
+ * Build sell instructions for Meteora DAMM V2 protocol
1266
+ */
1267
+ declare function buildMeteoraDammV2SellInstructions(params: BuildMeteoraDammV2SellInstructionsParams): TransactionInstruction[];
1268
+ /** Pool size in bytes */
1269
+ declare const METEORA_POOL_SIZE = 1104;
1270
+ /**
1271
+ * Meteora DAMM V2 Pool structure (simplified for essential fields)
1272
+ * 100% from Rust: src/instruction/utils/meteora_damm_v2_types.rs Pool
1273
+ */
1274
+ interface MeteoraDammV2Pool {
1275
+ tokenAMint: PublicKey;
1276
+ tokenBMint: PublicKey;
1277
+ tokenAVault: PublicKey;
1278
+ tokenBVault: PublicKey;
1279
+ liquidity: bigint;
1280
+ sqrtPrice: bigint;
1281
+ poolStatus: number;
1282
+ tokenAFlag: number;
1283
+ tokenBFlag: number;
1284
+ }
1285
+ /**
1286
+ * Decode a Meteora DAMM V2 pool from account data.
1287
+ * 100% from Rust: src/instruction/utils/meteora_damm_v2_types.rs pool_decode
1288
+ */
1289
+ declare function decodeMeteoraPool(data: Buffer): MeteoraDammV2Pool | null;
1290
+ /**
1291
+ * Fetch a Meteora DAMM V2 pool from RPC.
1292
+ * 100% from Rust: src/instruction/utils/meteora_damm_v2.rs fetch_pool
1293
+ */
1294
+ declare function fetchMeteoraPool(connection: {
1295
+ getAccountInfo: (pubkey: PublicKey) => Promise<{
1296
+ value?: {
1297
+ data: Buffer;
1298
+ owner?: PublicKey;
1299
+ };
1300
+ }>;
1301
+ }, poolAddress: PublicKey): Promise<MeteoraDammV2Pool | null>;
1302
+
1303
+ /**
1304
+ * Utility functions for Sol Trade SDK
1305
+ */
1306
+
1307
+ /**
1308
+ * Calculate amount with slippage for buy operations
1309
+ *
1310
+ * Note: Basis points are clamped to MAX_SLIPPAGE_BASIS_POINTS (9999 = 99.99%)
1311
+ * to prevent the amount from doubling when slippageBasisPoints = 10000.
1312
+ */
1313
+ declare function calculateWithSlippageBuy(amount: bigint, slippageBasisPoints: number): bigint;
1314
+ /**
1315
+ * Calculate amount with slippage for sell operations
1316
+ */
1317
+ declare function calculateWithSlippageSell(amount: bigint, slippageBasisPoints: number): bigint;
1318
+ /**
1319
+ * Calculate buy token amount from SOL amount for PumpFun
1320
+ */
1321
+ declare function getBuyTokenAmountFromSolAmount(virtualTokenReserves: bigint, virtualSolReserves: bigint, _realTokenReserves: bigint, _creatorFee: number, solAmount: bigint): bigint;
1322
+ /**
1323
+ * Calculate sell SOL amount from token amount for PumpFun
1324
+ */
1325
+ declare function getSellSolAmountFromTokenAmount(virtualTokenReserves: bigint, virtualSolReserves: bigint, _creatorFee: number, tokenAmount: bigint): bigint;
1326
+ /**
1327
+ * Convert lamports to SOL
1328
+ */
1329
+ declare function lamportsToSol(lamports: number | bigint): number;
1330
+ /**
1331
+ * Convert SOL to lamports
1332
+ */
1333
+ declare function solToLamports(sol: number): bigint;
1334
+ /**
1335
+ * Get current timestamp in microseconds
1336
+ */
1337
+ declare function nowMicroseconds(): bigint;
1338
+ /**
1339
+ * Validate public key string
1340
+ */
1341
+ declare function isValidPublicKey(key: string): boolean;
1342
+ /**
1343
+ * Sleep for specified milliseconds
1344
+ */
1345
+ declare function sleep(ms: number): Promise<void>;
1346
+ /**
1347
+ * Format public key for display (truncated)
1348
+ */
1349
+ declare function formatPublicKey(key: PublicKey | string, chars?: number): string;
1350
+ /**
1351
+ * Calculate price impact percentage
1352
+ */
1353
+ declare function calculatePriceImpact(reserveIn: bigint, amountIn: bigint): number;
1354
+ /**
1355
+ * Retry a function with exponential backoff
1356
+ */
1357
+ declare function retryWithBackoff<T>(fn: () => Promise<T>, maxRetries?: number, baseDelayMs?: number): Promise<T>;
1358
+
1359
+ /**
1360
+ * Hot Path State Management for Sol Trade SDK
1361
+ *
1362
+ * Manages prefetched blockchain state for zero-latency trading execution.
1363
+ * NO RPC calls are made during trading - all data is prefetched.
1364
+ *
1365
+ * Key principle: Prepare everything before the trade, execute with minimal latency.
1366
+ */
1367
+
1368
+ interface HotPathConfig {
1369
+ blockhashRefreshIntervalMs: number;
1370
+ cacheTtlMs: number;
1371
+ enablePrefetch: boolean;
1372
+ prefetchTimeoutMs: number;
1373
+ }
1374
+ declare function defaultHotPathConfig(): HotPathConfig;
1375
+ interface PrefetchedData {
1376
+ blockhash: string;
1377
+ lastValidBlockHeight: number;
1378
+ slot: number;
1379
+ fetchedAt: number;
1380
+ }
1381
+ interface AccountState {
1382
+ pubkey: string;
1383
+ data: Buffer;
1384
+ lamports: bigint;
1385
+ owner: string;
1386
+ executable: boolean;
1387
+ rentEpoch: number;
1388
+ slot: number;
1389
+ fetchedAt: number;
1390
+ }
1391
+ interface PoolState {
1392
+ poolAddress: string;
1393
+ poolType: 'pumpfun' | 'pumpswap' | 'raydium' | 'meteora';
1394
+ mintA: string;
1395
+ mintB: string;
1396
+ vaultA: string;
1397
+ vaultB: string;
1398
+ reserveA: bigint;
1399
+ reserveB: bigint;
1400
+ feeRate: number;
1401
+ fetchedAt: number;
1402
+ rawData?: Buffer;
1403
+ }
1404
+ declare class HotPathState {
1405
+ private config;
1406
+ private connection;
1407
+ private currentData;
1408
+ private accounts;
1409
+ private pools;
1410
+ private prefetchTimer?;
1411
+ private isRunning;
1412
+ private onBlockhashUpdateCallback?;
1413
+ private metrics;
1414
+ constructor(connection: Connection, config?: Partial<HotPathConfig>);
1415
+ /**
1416
+ * Start background prefetching
1417
+ * Call this BEFORE any hot path execution
1418
+ */
1419
+ start(): Promise<void>;
1420
+ /**
1421
+ * Stop background prefetching
1422
+ */
1423
+ stop(): void;
1424
+ /**
1425
+ * Check if prefetching is active
1426
+ */
1427
+ isActive(): boolean;
1428
+ /**
1429
+ * Prefetch latest blockhash - RPC call happens here (background only)
1430
+ */
1431
+ private prefetchBlockhash;
1432
+ /**
1433
+ * Get current cached blockhash - NO RPC CALL
1434
+ */
1435
+ getBlockhash(): {
1436
+ blockhash: string;
1437
+ lastValidBlockHeight: number;
1438
+ } | null;
1439
+ /**
1440
+ * Check if prefetched data is still valid
1441
+ */
1442
+ isDataFresh(): boolean;
1443
+ /**
1444
+ * Get all prefetched data
1445
+ */
1446
+ getPrefetchedData(): PrefetchedData | null;
1447
+ /**
1448
+ * Set callback for blockhash updates
1449
+ */
1450
+ onBlockhashUpdate(callback: (blockhash: string, lastValidBlockHeight: number) => void): void;
1451
+ /**
1452
+ * Update account state in cache
1453
+ */
1454
+ updateAccount(pubkey: string, state: AccountState): void;
1455
+ /**
1456
+ * Get account state from cache - NO RPC CALL
1457
+ */
1458
+ getAccount(pubkey: string): AccountState | null;
1459
+ /**
1460
+ * Get multiple account states - NO RPC CALL
1461
+ */
1462
+ getAccounts(pubkeys: string[]): Map<string, AccountState>;
1463
+ /**
1464
+ * Prefetch accounts - RPC call happens here (before trading)
1465
+ * Call this BEFORE entering the hot path
1466
+ */
1467
+ prefetchAccounts(pubkeys: string[]): Promise<void>;
1468
+ /**
1469
+ * Update pool state in cache
1470
+ */
1471
+ updatePool(poolAddress: string, state: PoolState): void;
1472
+ /**
1473
+ * Get pool state from cache - NO RPC CALL
1474
+ */
1475
+ getPool(poolAddress: string): PoolState | null;
1476
+ getMetrics(): {
1477
+ prefetchCount: number;
1478
+ prefetchErrors: number;
1479
+ lastPrefetchTime: number;
1480
+ accountsCached: number;
1481
+ poolsCached: number;
1482
+ dataFresh: boolean;
1483
+ };
1484
+ }
1485
+ /**
1486
+ * Trading context with all prefetched data needed for a trade.
1487
+ * Created BEFORE hot path execution, contains all necessary state.
1488
+ * NO RPC calls during trade execution.
1489
+ */
1490
+ declare class TradingContext {
1491
+ readonly payer: string;
1492
+ readonly blockhash: string;
1493
+ readonly lastValidBlockHeight: number;
1494
+ readonly createdAt: number;
1495
+ readonly accountStates: Map<string, AccountState>;
1496
+ readonly poolStates: Map<string, PoolState>;
1497
+ constructor(hotPathState: HotPathState, payer: string);
1498
+ /**
1499
+ * Add account state from cache
1500
+ */
1501
+ addAccount(pubkey: string, hotPathState: HotPathState): boolean;
1502
+ /**
1503
+ * Add pool state from cache
1504
+ */
1505
+ addPool(poolAddress: string, hotPathState: HotPathState): boolean;
1506
+ /**
1507
+ * Get age of context in milliseconds
1508
+ */
1509
+ age(): number;
1510
+ /**
1511
+ * Check if context is still valid
1512
+ */
1513
+ isValid(maxAgeMs?: number): boolean;
1514
+ /**
1515
+ * Get token account data from context
1516
+ */
1517
+ getTokenAccountData(pubkey: string): Buffer | undefined;
1518
+ }
1519
+ declare class HotPathError extends Error {
1520
+ constructor(message: string);
1521
+ }
1522
+ declare class StaleBlockhashError extends HotPathError {
1523
+ constructor(message?: string);
1524
+ }
1525
+ declare class MissingAccountError extends HotPathError {
1526
+ constructor(message?: string);
1527
+ }
1528
+ declare class ContextExpiredError extends HotPathError {
1529
+ constructor(message?: string);
1530
+ }
1531
+
1532
+ /**
1533
+ * SWQOS Clients for Sol Trade SDK
1534
+ * Implements various SWQOS (Solana Write Queue Operating System) providers.
1535
+ */
1536
+
1537
+ interface SwqosClient {
1538
+ sendTransaction(tradeType: TradeType, transaction: Buffer, waitConfirmation: boolean): Promise<string>;
1539
+ sendTransactions(tradeType: TradeType, transactions: Buffer[], waitConfirmation: boolean): Promise<string[]>;
1540
+ getTipAccount(): string;
1541
+ getSwqosType(): SwqosType;
1542
+ minTipSol(): number;
1543
+ }
1544
+
1545
+ /**
1546
+ * Hot Path Executor for Sol Trade SDK
1547
+ *
1548
+ * Executes trades with ZERO RPC calls in the hot path.
1549
+ * All data must be prefetched before execution.
1550
+ *
1551
+ * Key principle: Prepare everything, then execute with minimal latency.
1552
+ */
1553
+
1554
+ interface ExecuteOptions {
1555
+ parallelSubmit: boolean;
1556
+ timeoutMs: number;
1557
+ skipBlockhashValidation: boolean;
1558
+ maxRetries: number;
1559
+ }
1560
+ declare function defaultExecuteOptions(): ExecuteOptions;
1561
+ interface ExecuteResult {
1562
+ signature: string;
1563
+ success: boolean;
1564
+ error?: string;
1565
+ latencyMs: number;
1566
+ swqosType?: SwqosType;
1567
+ blockhashUsed: string;
1568
+ }
1569
+ interface GasFeeConfig {
1570
+ computeUnitLimit: number;
1571
+ computeUnitPrice: number;
1572
+ }
1573
+ declare class HotPathMetrics {
1574
+ private totalTrades;
1575
+ private successTrades;
1576
+ private failedTrades;
1577
+ private totalLatencyMs;
1578
+ record(success: boolean, latencyMs: number): void;
1579
+ getStats(): {
1580
+ totalTrades: number;
1581
+ successTrades: number;
1582
+ failedTrades: number;
1583
+ avgLatencyMs: number;
1584
+ };
1585
+ }
1586
+ /**
1587
+ * Executes trades with ZERO RPC calls in the hot path.
1588
+ *
1589
+ * Usage:
1590
+ * 1. Create executor with RPC connection
1591
+ * 2. Call start() to begin background prefetching
1592
+ * 3. Prefetch required accounts/pools BEFORE trading
1593
+ * 4. Build transaction with prefetched blockhash
1594
+ * 5. Execute - no RPC calls during this phase
1595
+ */
1596
+ declare class HotPathExecutor {
1597
+ private state;
1598
+ private config;
1599
+ private connection;
1600
+ private swqosClients;
1601
+ private metrics;
1602
+ constructor(connection: Connection, config?: Partial<HotPathConfig>);
1603
+ /**
1604
+ * Add a SWQoS client for transaction submission
1605
+ */
1606
+ addSwqosClient(client: SwqosClient): void;
1607
+ /**
1608
+ * Remove a SWQoS client
1609
+ */
1610
+ removeSwqosClient(swqosType: SwqosType): void;
1611
+ /**
1612
+ * Get SWQoS client by type
1613
+ */
1614
+ getSwqosClient(swqosType: SwqosType): SwqosClient | undefined;
1615
+ /**
1616
+ * Start background prefetching
1617
+ */
1618
+ start(): Promise<void>;
1619
+ /**
1620
+ * Stop background prefetching
1621
+ */
1622
+ stop(): void;
1623
+ /**
1624
+ * Get hot path state for external access
1625
+ */
1626
+ getState(): HotPathState;
1627
+ /**
1628
+ * Check if executor is ready for hot path execution
1629
+ */
1630
+ isReady(): boolean;
1631
+ /**
1632
+ * Wait until executor is ready
1633
+ */
1634
+ waitForReady(checkIntervalMs?: number, timeoutMs?: number): Promise<boolean>;
1635
+ /**
1636
+ * Prefetch accounts - call BEFORE hot path execution
1637
+ */
1638
+ prefetchAccounts(pubkeys: string[]): Promise<void>;
1639
+ /**
1640
+ * Create trading context with prefetched data - NO RPC
1641
+ */
1642
+ createTradingContext(payer: string): TradingContext;
1643
+ /**
1644
+ * Execute a pre-signed transaction - NO RPC CALLS
1645
+ *
1646
+ * Transaction must already be signed with valid blockhash.
1647
+ * All state should be prefetched before calling this.
1648
+ */
1649
+ execute(tradeType: TradeType, transactionBytes: Buffer, opts?: ExecuteOptions): Promise<ExecuteResult>;
1650
+ /**
1651
+ * Submit to all SWQoS clients in parallel - NO RPC
1652
+ */
1653
+ private executeParallel;
1654
+ /**
1655
+ * Submit to SWQoS clients sequentially - NO RPC
1656
+ */
1657
+ private executeSequential;
1658
+ /**
1659
+ * Execute multiple transactions in parallel
1660
+ */
1661
+ executeMultiple(tradeType: TradeType, transactions: Buffer[], opts?: ExecuteOptions): Promise<ExecuteResult[]>;
1662
+ /**
1663
+ * Get cached blockhash - NO RPC CALL
1664
+ * Use this to build transactions before execution
1665
+ */
1666
+ getBlockhash(): {
1667
+ blockhash: string;
1668
+ lastValidBlockHeight: number;
1669
+ } | null;
1670
+ /**
1671
+ * Get execution metrics
1672
+ */
1673
+ getMetrics(): ReturnType<HotPathMetrics['getStats']>;
1674
+ private sleep;
1675
+ }
1676
+ /**
1677
+ * Builds transactions using prefetched data - NO RPC CALLS
1678
+ *
1679
+ * Use this to construct transactions before hot path execution.
1680
+ */
1681
+ declare class TransactionBuilder {
1682
+ private executor;
1683
+ constructor(executor: HotPathExecutor);
1684
+ /**
1685
+ * Build a transaction using prefetched blockhash - NO RPC
1686
+ */
1687
+ buildTransaction(payer: PublicKey, instructions: TransactionInstruction[], signers: any[], // Keypair[]
1688
+ gasConfig?: GasFeeConfig): Promise<Transaction | null>;
1689
+ }
1690
+ /**
1691
+ * Create a hot path executor with default configuration.
1692
+ *
1693
+ * Usage:
1694
+ * const executor = createHotPathExecutor(
1695
+ * connection,
1696
+ * [jitoClient, bloxrouteClient]
1697
+ * );
1698
+ * await executor.start();
1699
+ *
1700
+ * // Prefetch required data
1701
+ * await executor.prefetchAccounts([tokenAccountPubkey]);
1702
+ *
1703
+ * // Now ready for hot path execution
1704
+ * const result = await executor.execute('buy', txBytes);
1705
+ */
1706
+ declare function createHotPathExecutor(connection: Connection, swqosClients?: SwqosClient[], config?: Partial<HotPathConfig>): HotPathExecutor;
1707
+
1708
+ /**
1709
+ * Execution: instruction preprocessing, cache prefetch, branch hints.
1710
+ * 执行模块:指令预处理、缓存预取、分支提示。
1711
+ *
1712
+ * Based on sol-trade-sdk Rust implementation patterns.
1713
+ */
1714
+
1715
+ declare const BYTES_PER_ACCOUNT = 32;
1716
+ declare const MAX_INSTRUCTIONS_WARN = 64;
1717
+ /**
1718
+ * Cache prefetching utilities.
1719
+ * Call once on hot-path refs to reduce cache-miss latency.
1720
+ */
1721
+ declare class Prefetch {
1722
+ /**
1723
+ * Prefetch instruction data into cache
1724
+ * Accepts any instruction-shaped array (Rust: `Prefetch::instructions`).
1725
+ */
1726
+ static instructions(instructions: ReadonlyArray<unknown>): void;
1727
+ /**
1728
+ * Prefetch pubkey into cache
1729
+ */
1730
+ static pubkey(pubkey: Uint8Array): void;
1731
+ /**
1732
+ * Prefetch keypair data into cache
1733
+ */
1734
+ static keypair(keypair: unknown): void;
1735
+ }
1736
+ /**
1737
+ * Handles instruction preprocessing and validation.
1738
+ * Based on Rust's InstructionProcessor pattern.
1739
+ */
1740
+ declare class InstructionProcessor {
1741
+ /**
1742
+ * Validate and prepare instructions for execution.
1743
+ * Rust: `InstructionProcessor::preprocess` (empty check, prefetch, warn when count exceeds {@link MAX_INSTRUCTIONS_WARN}).
1744
+ */
1745
+ static preprocess(instructions: ReadonlyArray<unknown>): void;
1746
+ /**
1747
+ * Calculate total size for buffer allocation (web3 `keys` or internal `accounts`).
1748
+ */
1749
+ static calculateSize(instructions: ReadonlyArray<{
1750
+ data: {
1751
+ length: number;
1752
+ };
1753
+ keys?: readonly unknown[];
1754
+ accounts?: readonly unknown[];
1755
+ }>): number;
1756
+ }
1757
+ /**
1758
+ * Trade direction and execution path utilities
1759
+ */
1760
+ declare class ExecutionPath {
1761
+ /**
1762
+ * Rust `ExecutionPath::is_buy`: input mint is quote-side (SOL / WSOL / USD1 / USDC).
1763
+ */
1764
+ static isBuy(inputMint: PublicKey): boolean;
1765
+ /**
1766
+ * Select between fast and slow path
1767
+ */
1768
+ static select<T>(condition: boolean, fastPath: () => T, slowPath: () => T): T;
1769
+ }
1770
+
1771
+ /**
1772
+ * Poll multiple transaction signatures until one reaches confirmed/finalized without error.
1773
+ * Rust: `swqos::common::poll_any_transaction_confirmation`.
1774
+ */
1775
+
1776
+ /**
1777
+ * Map RPC `Commitment` to `getTransaction` `Finality` (web3: only `confirmed` | `finalized`).
1778
+ * `processed` / unknown → `confirmed`.
1779
+ */
1780
+ declare function commitmentToGetTxFinality(c: Commitment | undefined): Finality;
1781
+ interface ConfirmAnySignatureOptions {
1782
+ commitment?: Commitment;
1783
+ /**
1784
+ * `getTransaction` lookup commitment (Rust: `CommitmentConfig::confirmed()`).
1785
+ * Defaults from {@link commitmentToGetTxFinality}(`commitment`).
1786
+ */
1787
+ getTransactionCommitment?: Finality;
1788
+ /** Default 15000 (Rust uses 15s). */
1789
+ timeoutMs?: number;
1790
+ pollIntervalMs?: number;
1791
+ /**
1792
+ * Rust waits until `poll_count >= 10` before `get_transaction_with_config` on the first landed signature.
1793
+ * @default 10
1794
+ */
1795
+ pollsBeforeGetTransaction?: number;
1796
+ }
1797
+ /** Rust: log line patterns for user-facing failure hints. */
1798
+ declare function extractHintsFromLogs(logs: readonly string[] | null | undefined): string;
1799
+ /**
1800
+ * Map `TransactionError` JSON (meta.err) to a numeric code; prefers Custom instruction code like Rust.
1801
+ */
1802
+ declare function instructionErrorCodeFromMetaErr(err: unknown): {
1803
+ code: number;
1804
+ instructionIndex?: number;
1805
+ };
1806
+ /**
1807
+ * Wait until any signature in `signatures` is confirmed successfully on-chain.
1808
+ * Single-signature path uses `connection.confirmTransaction` (blockhash strategy when applicable).
1809
+ */
1810
+ declare function confirmAnyTransactionSignature(connection: Connection, signatures: string[], options?: ConfirmAnySignatureOptions): Promise<string>;
1811
+
1812
+ /**
1813
+ * Bounded concurrency for async work (Rust SWQOS worker pool parity, best-effort in JS).
1814
+ */
1815
+ declare function mapWithConcurrencyLimit<T, R>(items: readonly T[], concurrency: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
1816
+
1817
+ /**
1818
+ * Durable nonce helpers — aligned with Rust `src/common/nonce_cache.rs` `fetch_nonce_info`.
1819
+ */
1820
+
1821
+ /** Same shape as `DurableNonceInfo` in `index.ts` (used for `buy`/`sell` without circular imports). */
1822
+ interface FetchedDurableNonce {
1823
+ nonceAccount: PublicKey;
1824
+ authority: PublicKey;
1825
+ /** Base58-encoded current nonce blockhash (32 bytes), for `recentBlockhash` / `nonceHash`. */
1826
+ nonceHash: string;
1827
+ /** Duplicate of `nonceHash` for parity with existing `DurableNonceInfo.recentBlockhash`. */
1828
+ recentBlockhash: string;
1829
+ }
1830
+ /**
1831
+ * Fetch durable nonce authority + current blockhash from a nonce account (RPC).
1832
+ * Layout matches Rust: version (4) + authority_type (4) + authority (32) + blockhash (32) starting at offset 40.
1833
+ */
1834
+ declare function fetchDurableNonceInfo(connection: Pick<Connection, 'getAccountInfo'>, nonceAccount: PublicKey): Promise<FetchedDurableNonce | null>;
1835
+
1836
+ /**
1837
+ * Secure key storage and management for Sol Trade SDK
1838
+ *
1839
+ * Implements secure memory handling for private keys with:
1840
+ * - Memory encryption at rest
1841
+ * - Secure zeroing after use
1842
+ * - Context manager for automatic cleanup
1843
+ */
1844
+
1845
+ /**
1846
+ * Error thrown when secure key operation fails
1847
+ */
1848
+ declare class SecureKeyError extends Error {
1849
+ constructor(message: string);
1850
+ }
1851
+ /**
1852
+ * Error thrown when trying to access a cleared key
1853
+ */
1854
+ declare class KeyNotAvailableError extends SecureKeyError {
1855
+ constructor(message?: string);
1856
+ }
1857
+ /**
1858
+ * Metadata about a stored key
1859
+ */
1860
+ interface KeyMetadata {
1861
+ pubkey: string;
1862
+ createdAt: number;
1863
+ lastAccessed?: number;
1864
+ accessCount: number;
1865
+ }
1866
+ /**
1867
+ * Secure storage for Solana private keys.
1868
+ *
1869
+ * Features:
1870
+ * - Keys are encrypted in memory when not in use
1871
+ * - Automatic secure zeroing of key material
1872
+ * - Context manager support for temporary key access
1873
+ */
1874
+ declare class SecureKeyStorage {
1875
+ private encryptedKey;
1876
+ private salt;
1877
+ private pubkey;
1878
+ private isUnlocked;
1879
+ private unlockedKey;
1880
+ private metadata;
1881
+ private passwordProtected;
1882
+ private constructor();
1883
+ /**
1884
+ * Create secure storage from a Keypair.
1885
+ */
1886
+ static fromKeypair(keypair: Keypair, password?: string): SecureKeyStorage;
1887
+ /**
1888
+ * Create secure storage from a seed.
1889
+ */
1890
+ static fromSeed(seed: Uint8Array, password?: string): SecureKeyStorage;
1891
+ /**
1892
+ * Create secure storage from a mnemonic phrase.
1893
+ */
1894
+ static fromMnemonic(mnemonic: string, password?: string): SecureKeyStorage;
1895
+ private encryptWithPassword;
1896
+ private decryptWithPassword;
1897
+ private xorEncrypt;
1898
+ /**
1899
+ * Securely zero out sensitive data from memory
1900
+ */
1901
+ private static secureZero;
1902
+ private secureZero;
1903
+ /**
1904
+ * Temporarily access the keypair.
1905
+ * Key is automatically cleared after callback completes.
1906
+ */
1907
+ withKeypair<T>(callback: (keypair: Keypair) => Promise<T>, password?: string): Promise<T>;
1908
+ /**
1909
+ * Sign a message without exposing the keypair.
1910
+ */
1911
+ signMessage(message: Buffer | Uint8Array, password?: string): Promise<Buffer>;
1912
+ /**
1913
+ * Get the public key (safe to access)
1914
+ */
1915
+ getPublicKey(): string;
1916
+ /**
1917
+ * Check if storage requires password
1918
+ */
1919
+ get isPasswordProtected(): boolean;
1920
+ /**
1921
+ * Get key metadata
1922
+ */
1923
+ getMetadata(): KeyMetadata | null;
1924
+ /**
1925
+ * Permanently clear all key material
1926
+ */
1927
+ clear(): void;
1928
+ }
1929
+ /**
1930
+ * Convenience function for quick signing
1931
+ */
1932
+ declare function signWithKeypair(keypair: Keypair, message: Buffer | Uint8Array, clearAfter?: boolean): Promise<Buffer>;
1933
+
1934
+ /**
1935
+ * Input validators for Sol Trade SDK
1936
+ *
1937
+ * Provides secure input validation for:
1938
+ * - RPC URLs
1939
+ * - Program IDs
1940
+ * - Amounts
1941
+ * - Slippage values
1942
+ */
1943
+
1944
+ /**
1945
+ * Error thrown when input validation fails
1946
+ */
1947
+ declare class ValidationError extends Error {
1948
+ constructor(message: string);
1949
+ }
1950
+ /**
1951
+ * Known legitimate Solana program IDs
1952
+ */
1953
+ declare const KNOWN_PROGRAM_IDS: Record<string, string[]>;
1954
+ /**
1955
+ * Validate RPC URL format and security.
1956
+ */
1957
+ declare function validateRpcUrl(url: string, allowHttp?: boolean): string;
1958
+ /**
1959
+ * Validate a Solana program ID.
1960
+ */
1961
+ declare function validateProgramId(programId: string, expectedProgram?: string): string;
1962
+ /**
1963
+ * Validate an amount value.
1964
+ */
1965
+ declare function validateAmount(amount: number | bigint, name?: string, allowZero?: boolean): bigint;
1966
+ /**
1967
+ * Validate slippage in basis points.
1968
+ */
1969
+ declare function validateSlippage(slippageBasisPoints: number): number;
1970
+ /**
1971
+ * Validate a Solana public key.
1972
+ */
1973
+ declare function validatePubkey(pubkey: string | PublicKey, name?: string): PublicKey;
1974
+ /**
1975
+ * Validate a trading pair.
1976
+ */
1977
+ declare function validateMintPair(inputMint: string, outputMint: string): void;
1978
+ /**
1979
+ * Validate transaction size.
1980
+ */
1981
+ declare function validateTransactionSize(transactionBytes: Buffer | Uint8Array, maxSize?: number): void;
1982
+ /**
1983
+ * Validate a signature string.
1984
+ */
1985
+ declare function validateSignature(signature: string): string;
1986
+
1987
+ /**
1988
+ * Address Lookup Table support for Solana transactions.
1989
+ *
1990
+ * This module provides functionality to fetch and use Address Lookup Tables (ALT)
1991
+ * to reduce transaction size by storing frequently used addresses in a lookup table.
1992
+ */
1993
+
1994
+ /**
1995
+ * Represents an address lookup table account.
1996
+ */
1997
+ interface AddressLookupTableAccount {
1998
+ key: PublicKey;
1999
+ addresses: PublicKey[];
2000
+ }
2001
+ /**
2002
+ * Fetch an address lookup table account from the blockchain.
2003
+ *
2004
+ * @param connection - Solana RPC connection
2005
+ * @param lookupTableAddress - The address of the lookup table
2006
+ * @param commitment - Commitment level for the query
2007
+ * @returns AddressLookupTableAccount if found, null otherwise
2008
+ */
2009
+ declare function fetchAddressLookupTableAccount(connection: Connection, lookupTableAddress: PublicKey, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<AddressLookupTableAccount | null>;
2010
+ /**
2011
+ * Parse an address lookup table from account data.
2012
+ *
2013
+ * @param key - The lookup table public key
2014
+ * @param accountInfo - The account info containing the lookup table data
2015
+ * @returns AddressLookupTableAccount
2016
+ */
2017
+ declare function parseAddressLookupTable(key: PublicKey, accountInfo: AccountInfo<Buffer>): AddressLookupTableAccount | null;
2018
+ /**
2019
+ * Cache for address lookup tables to avoid repeated RPC calls.
2020
+ */
2021
+ declare class AddressLookupTableCache {
2022
+ private cache;
2023
+ /**
2024
+ * Get lookup table from cache or fetch from RPC.
2025
+ *
2026
+ * @param connection - Solana RPC connection
2027
+ * @param lookupTableAddress - The lookup table address
2028
+ * @returns AddressLookupTableAccount if found, null otherwise
2029
+ */
2030
+ getLookupTable(connection: Connection, lookupTableAddress: PublicKey): Promise<AddressLookupTableAccount | null>;
2031
+ /**
2032
+ * Get multiple lookup tables from cache or fetch from RPC.
2033
+ *
2034
+ * @param connection - Solana RPC connection
2035
+ * @param lookupTableAddresses - Array of lookup table addresses
2036
+ * @returns Array of AddressLookupTableAccount (null for not found)
2037
+ */
2038
+ getLookupTables(connection: Connection, lookupTableAddresses: PublicKey[]): Promise<(AddressLookupTableAccount | null)[]>;
2039
+ /**
2040
+ * Clear the cache.
2041
+ */
2042
+ clear(): void;
2043
+ /**
2044
+ * Remove a specific lookup table from cache.
2045
+ *
2046
+ * @param lookupTableAddress - The lookup table address to remove
2047
+ */
2048
+ remove(lookupTableAddress: PublicKey): void;
2049
+ /**
2050
+ * Get cache size.
2051
+ */
2052
+ get size(): number;
2053
+ }
2054
+ /**
2055
+ * Default global cache instance.
2056
+ */
2057
+ declare const addressLookupTableCache: AddressLookupTableCache;
2058
+
2059
+ /**
2060
+ * Trading factory and executor for Sol Trade SDK
2061
+ *
2062
+ * Provides factory methods for creating trade executors for different DEX protocols
2063
+ */
2064
+
2065
+ declare enum DexType$1 {
2066
+ PumpFun = "PumpFun",
2067
+ PumpSwap = "PumpSwap",
2068
+ Bonk = "Bonk",
2069
+ RaydiumCpmm = "RaydiumCpmm",
2070
+ RaydiumAmmV4 = "RaydiumAmmV4",
2071
+ MeteoraDammV2 = "MeteoraDammV2"
2072
+ }
2073
+ interface TradeResult$1 {
2074
+ signature: string;
2075
+ success: boolean;
2076
+ error?: string;
2077
+ confirmationTimeMs?: number;
2078
+ submittedAt?: Date;
2079
+ confirmedAt?: Date;
2080
+ retries?: number;
2081
+ }
2082
+ interface BatchTradeResult {
2083
+ results: TradeResult$1[];
2084
+ totalTimeMs: number;
2085
+ successCount: number;
2086
+ failedCount: number;
2087
+ }
2088
+ interface TradeExecuteOptions {
2089
+ waitConfirmation?: boolean;
2090
+ maxRetries?: number;
2091
+ retryDelayMs?: number;
2092
+ parallelSubmit?: boolean;
2093
+ timeoutMs?: number;
2094
+ priority?: number;
2095
+ skipPreflight?: boolean;
2096
+ }
2097
+ declare function defaultTradeExecuteOptions(): TradeExecuteOptions;
2098
+ interface ITradeExecutor {
2099
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2100
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2101
+ }
2102
+ declare abstract class BaseExecutor implements ITradeExecutor {
2103
+ abstract executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2104
+ abstract executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2105
+ protected buildResult(signature: string, success: boolean, error?: string): TradeResult$1;
2106
+ }
2107
+ declare class PumpFunExecutor extends BaseExecutor {
2108
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2109
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2110
+ }
2111
+ declare class PumpSwapExecutor extends BaseExecutor {
2112
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2113
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2114
+ }
2115
+ declare class BonkExecutor extends BaseExecutor {
2116
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2117
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2118
+ }
2119
+ declare class RaydiumCpmmExecutor extends BaseExecutor {
2120
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2121
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2122
+ }
2123
+ declare class RaydiumAmmV4Executor extends BaseExecutor {
2124
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2125
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2126
+ }
2127
+ declare class MeteoraDammV2Executor extends BaseExecutor {
2128
+ executeBuy(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2129
+ executeSell(_params: Record<string, unknown>, _opts?: TradeExecuteOptions): Promise<TradeResult$1>;
2130
+ }
2131
+ declare class TradeExecutorFactory {
2132
+ private static executors;
2133
+ /**
2134
+ * Create a trade executor for the given DEX type
2135
+ */
2136
+ static createExecutor(dexType: DexType$1): ITradeExecutor;
2137
+ /**
2138
+ * Register a custom executor factory
2139
+ */
2140
+ static registerExecutor(dexType: DexType$1, factory: () => ITradeExecutor): void;
2141
+ /**
2142
+ * Get supported DEX types
2143
+ */
2144
+ static getSupportedDexTypes(): DexType$1[];
2145
+ }
2146
+
2147
+ /**
2148
+ * Sol Trade SDK - TypeScript SDK for Solana DEX trading
2149
+ *
2150
+ * A comprehensive SDK for seamless Solana DEX trading with support for
2151
+ * PumpFun, PumpSwap, Bonk, Raydium CPMM, Raydium AMM V4, and Meteora DAMM V2.
2152
+ */
2153
+
2154
+ /**
2155
+ * Supported DEX protocols
2156
+ */
2157
+ declare enum DexType {
2158
+ PumpFun = "PumpFun",
2159
+ PumpSwap = "PumpSwap",
2160
+ Bonk = "Bonk",
2161
+ RaydiumCpmm = "RaydiumCpmm",
2162
+ RaydiumAmmV4 = "RaydiumAmmV4",
2163
+ MeteoraDammV2 = "MeteoraDammV2"
2164
+ }
2165
+ /**
2166
+ * Type of token to trade
2167
+ */
2168
+ declare enum TradeTokenType {
2169
+ SOL = "SOL",
2170
+ WSOL = "WSOL",
2171
+ USD1 = "USD1",
2172
+ USDC = "USDC"
2173
+ }
2174
+ /**
2175
+ * Trade operation type
2176
+ */
2177
+ declare enum TradeType {
2178
+ Buy = "Buy",
2179
+ Sell = "Sell"
2180
+ }
2181
+ /**
2182
+ * SWQOS service regions
2183
+ */
2184
+ declare enum SwqosRegion {
2185
+ Frankfurt = "Frankfurt",
2186
+ NewYork = "NewYork",
2187
+ Amsterdam = "Amsterdam",
2188
+ Dublin = "Dublin",
2189
+ Tokyo = "Tokyo",
2190
+ Singapore = "Singapore",
2191
+ SLC = "SLC",
2192
+ London = "London",
2193
+ LosAngeles = "LosAngeles",
2194
+ Default = "Default"
2195
+ }
2196
+ /**
2197
+ * SWQOS service types
2198
+ */
2199
+ declare enum SwqosType {
2200
+ Default = "Default",
2201
+ Jito = "Jito",
2202
+ Bloxroute = "Bloxroute",
2203
+ ZeroSlot = "ZeroSlot",
2204
+ Temporal = "Temporal",
2205
+ FlashBlock = "FlashBlock",
2206
+ BlockRazor = "BlockRazor",
2207
+ Node1 = "Node1",
2208
+ Astralane = "Astralane",
2209
+ NextBlock = "NextBlock",
2210
+ Helius = "Helius",
2211
+ Stellium = "Stellium",
2212
+ Lightspeed = "Lightspeed",
2213
+ Soyas = "Soyas",
2214
+ Speedlanding = "Speedlanding",
2215
+ Triton = "Triton",
2216
+ QuickNode = "QuickNode",
2217
+ Syndica = "Syndica",
2218
+ Figment = "Figment",
2219
+ Alchemy = "Alchemy"
2220
+ }
2221
+ declare enum SwqosTransport {
2222
+ Http = "Http",
2223
+ Grpc = "Grpc",
2224
+ Quic = "Quic"
2225
+ }
2226
+ declare enum AstralaneTransport {
2227
+ Binary = "Binary",
2228
+ Plain = "Plain",
2229
+ Quic = "Quic"
2230
+ }
2231
+ /**
2232
+ * SWQOS service configuration
2233
+ */
2234
+ interface SwqosConfig {
2235
+ type: SwqosType;
2236
+ region: SwqosRegion;
2237
+ apiKey: string;
2238
+ customUrl?: string;
2239
+ mevProtection?: boolean;
2240
+ transport?: SwqosTransport;
2241
+ astralaneTransport?: AstralaneTransport;
2242
+ swqosOnly?: boolean;
2243
+ }
2244
+ /**
2245
+ * Gas fee strategy configuration
2246
+ */
2247
+ interface GasFeeStrategyConfig {
2248
+ buyPriorityFee: number;
2249
+ sellPriorityFee: number;
2250
+ buyComputeUnits: number;
2251
+ sellComputeUnits: number;
2252
+ buyTipLamports: number;
2253
+ sellTipLamports: number;
2254
+ }
2255
+ /**
2256
+ * Durable nonce information
2257
+ *
2258
+ * Populate via `fetchDurableNonceInfo` (Rust `fetch_nonce_info` parity) or manually.
2259
+ */
2260
+ interface DurableNonceInfo {
2261
+ nonceAccount: PublicKey;
2262
+ authority: PublicKey;
2263
+ nonceHash: string;
2264
+ recentBlockhash: string;
2265
+ }
2266
+ /**
2267
+ * Buy trade parameters
2268
+ */
2269
+ interface TradeBuyParams {
2270
+ dexType: DexType;
2271
+ inputTokenType: TradeTokenType;
2272
+ mint: PublicKey;
2273
+ inputTokenAmount: number;
2274
+ slippageBasisPoints?: number;
2275
+ recentBlockhash?: string;
2276
+ extensionParams: DexParamEnum;
2277
+ addressLookupTableAccount?: AddressLookupTableAccount$1;
2278
+ waitTxConfirmed?: boolean;
2279
+ createInputTokenAta?: boolean;
2280
+ closeInputTokenAta?: boolean;
2281
+ createMintAta?: boolean;
2282
+ durableNonce?: DurableNonceInfo;
2283
+ fixedOutputTokenAmount?: number;
2284
+ gasFeeStrategy?: GasFeeStrategyConfig;
2285
+ simulate?: boolean;
2286
+ useExactSolAmount?: boolean;
2287
+ grpcRecvUs?: number;
2288
+ }
2289
+ /**
2290
+ * Sell trade parameters
2291
+ */
2292
+ interface TradeSellParams {
2293
+ dexType: DexType;
2294
+ outputTokenType: TradeTokenType;
2295
+ mint: PublicKey;
2296
+ inputTokenAmount: number;
2297
+ slippageBasisPoints?: number;
2298
+ recentBlockhash?: string;
2299
+ withTip?: boolean;
2300
+ extensionParams: DexParamEnum;
2301
+ addressLookupTableAccount?: AddressLookupTableAccount$1;
2302
+ waitTxConfirmed?: boolean;
2303
+ createOutputTokenAta?: boolean;
2304
+ closeOutputTokenAta?: boolean;
2305
+ closeMintTokenAta?: boolean;
2306
+ durableNonce?: DurableNonceInfo;
2307
+ fixedOutputTokenAmount?: number;
2308
+ gasFeeStrategy?: GasFeeStrategyConfig;
2309
+ simulate?: boolean;
2310
+ grpcRecvUs?: number;
2311
+ }
2312
+ /**
2313
+ * Trade execution result
2314
+ */
2315
+ interface TradeResult {
2316
+ success: boolean;
2317
+ signatures: string[];
2318
+ error?: TradeError;
2319
+ timings: SwqosTiming[];
2320
+ /**
2321
+ * Set when `simulate: true` on buy/sell — Rust `simulate_transaction` (`units_consumed`, `logs`).
2322
+ */
2323
+ simulation?: {
2324
+ unitsConsumed?: number;
2325
+ logs?: string[] | null;
2326
+ };
2327
+ }
2328
+ /**
2329
+ * SWQOS timing information
2330
+ */
2331
+ interface SwqosTiming {
2332
+ swqosType: SwqosType;
2333
+ duration: number;
2334
+ /** Present when `TradeConfig.gasStrategy` expands multiple Rust `GasFeeStrategyType` rows. */
2335
+ gasFeeStrategyType?: GasFeeStrategyType;
2336
+ }
2337
+
2338
+ /**
2339
+ * Bonding curve account state
2340
+ */
2341
+ interface BondingCurveAccount {
2342
+ discriminator: number;
2343
+ account: PublicKey;
2344
+ virtualTokenReserves: number;
2345
+ virtualSolReserves: number;
2346
+ realTokenReserves: number;
2347
+ realSolReserves: number;
2348
+ tokenTotalSupply: number;
2349
+ complete: boolean;
2350
+ creator: PublicKey;
2351
+ isMayhemMode: boolean;
2352
+ isCashbackCoin: boolean;
2353
+ }
2354
+ /**
2355
+ * PumpFun protocol parameters
2356
+ */
2357
+ interface PumpFunParams {
2358
+ bondingCurve: BondingCurveAccount;
2359
+ associatedBondingCurve: PublicKey;
2360
+ creatorVault: PublicKey;
2361
+ tokenProgram: PublicKey;
2362
+ observedTradeCreator?: PublicKey;
2363
+ feeSharingCreatorVaultIfActive?: PublicKey;
2364
+ closeTokenAccountWhenSell?: boolean;
2365
+ /** Parser/gRPC fee recipient; omit or `PublicKey.default` for SDK random pool (Rust parity). */
2366
+ feeRecipient?: PublicKey;
2367
+ /** PumpFun V2 quote mint; omit or default pubkey for WSOL. */
2368
+ quoteMint?: PublicKey;
2369
+ /** Per-token V2 ix toggle; global `TradeConfig.usePumpfunV2` also enables it. */
2370
+ useV2Ix?: boolean;
2371
+ }
2372
+ /**
2373
+ * PumpSwap protocol parameters
2374
+ */
2375
+ interface PumpSwapParams {
2376
+ pool: PublicKey;
2377
+ baseMint: PublicKey;
2378
+ quoteMint: PublicKey;
2379
+ poolBaseTokenAccount: PublicKey;
2380
+ poolQuoteTokenAccount: PublicKey;
2381
+ poolBaseTokenReserves: number;
2382
+ poolQuoteTokenReserves: number;
2383
+ coinCreatorVaultAta: PublicKey;
2384
+ coinCreatorVaultAuthority: PublicKey;
2385
+ baseTokenProgram: PublicKey;
2386
+ quoteTokenProgram: PublicKey;
2387
+ isMayhemMode: boolean;
2388
+ isCashbackCoin: boolean;
2389
+ }
2390
+ /**
2391
+ * Bonk protocol parameters
2392
+ */
2393
+ interface BonkParams {
2394
+ virtualBase: bigint;
2395
+ virtualQuote: bigint;
2396
+ realBase: bigint;
2397
+ realQuote: bigint;
2398
+ poolState: PublicKey;
2399
+ baseVault: PublicKey;
2400
+ quoteVault: PublicKey;
2401
+ mintTokenProgram: PublicKey;
2402
+ platformConfig: PublicKey;
2403
+ platformAssociatedAccount: PublicKey;
2404
+ creatorAssociatedAccount: PublicKey;
2405
+ globalConfig: PublicKey;
2406
+ }
2407
+ /**
2408
+ * Raydium CPMM protocol parameters
2409
+ */
2410
+ interface RaydiumCpmmParams {
2411
+ poolState: PublicKey;
2412
+ ammConfig: PublicKey;
2413
+ baseMint: PublicKey;
2414
+ quoteMint: PublicKey;
2415
+ baseReserve: number;
2416
+ quoteReserve: number;
2417
+ baseVault: PublicKey;
2418
+ quoteVault: PublicKey;
2419
+ baseTokenProgram: PublicKey;
2420
+ quoteTokenProgram: PublicKey;
2421
+ observationState: PublicKey;
2422
+ }
2423
+ /**
2424
+ * Raydium AMM V4 protocol parameters
2425
+ */
2426
+ interface RaydiumAmmV4Params {
2427
+ amm: PublicKey;
2428
+ coinMint: PublicKey;
2429
+ pcMint: PublicKey;
2430
+ tokenCoin: PublicKey;
2431
+ tokenPc: PublicKey;
2432
+ coinReserve: number;
2433
+ pcReserve: number;
2434
+ }
2435
+ /**
2436
+ * Meteora DAMM V2 protocol parameters
2437
+ */
2438
+ interface MeteoraDammV2Params {
2439
+ pool: PublicKey;
2440
+ tokenAVault: PublicKey;
2441
+ tokenBVault: PublicKey;
2442
+ tokenAMint: PublicKey;
2443
+ tokenBMint: PublicKey;
2444
+ tokenAProgram: PublicKey;
2445
+ tokenBProgram: PublicKey;
2446
+ }
2447
+ /**
2448
+ * Union type for DEX parameters
2449
+ */
2450
+ type DexParamEnum = {
2451
+ type: 'PumpFun';
2452
+ params: PumpFunParams;
2453
+ } | {
2454
+ type: 'PumpSwap';
2455
+ params: PumpSwapParams;
2456
+ } | {
2457
+ type: 'Bonk';
2458
+ params: BonkParams;
2459
+ } | {
2460
+ type: 'RaydiumCpmm';
2461
+ params: RaydiumCpmmParams;
2462
+ } | {
2463
+ type: 'RaydiumAmmV4';
2464
+ params: RaydiumAmmV4Params;
2465
+ } | {
2466
+ type: 'MeteoraDammV2';
2467
+ params: MeteoraDammV2Params;
2468
+ };
2469
+ /**
2470
+ * Trading configuration
2471
+ */
2472
+ interface TradeConfig {
2473
+ rpcUrl: string;
2474
+ swqosConfigs: SwqosConfig[];
2475
+ commitment?: Commitment;
2476
+ logEnabled?: boolean;
2477
+ checkMinTip?: boolean;
2478
+ mevProtection?: boolean;
2479
+ /** Default gas/CU settings when trade params omit `gasFeeStrategy`. */
2480
+ gasFeeStrategy?: GasFeeStrategyConfig;
2481
+ /**
2482
+ * Per-SWQOS gas table (Rust `GasFeeStrategy`). Used when neither trade nor `gasFeeStrategy` flat config is set.
2483
+ * Lookup uses the first SWQOS entry after `withTip` / `checkMinTip` filtering.
2484
+ */
2485
+ gasStrategy?: GasFeeStrategy;
2486
+ /** Reserved for Rust parity (seed-optimized ATA); instruction builders may ignore if not wired. */
2487
+ useSeedOptimize?: boolean;
2488
+ /** Use PumpFun V2 ix layout by default (`buy_v2` / `sell_v2` / quote mint support). */
2489
+ usePumpfunV2?: boolean;
2490
+ /** Prefer assigning SWQOS submit threads from the end of the CPU core list. */
2491
+ swqosCoresFromEnd?: boolean;
2492
+ /** If true, best-effort background WSOL ATA creation after connect (Rust `create_wsol_ata_on_startup`). */
2493
+ createWsolAtaOnStartup?: boolean;
2494
+ /**
2495
+ * Rust `MiddlewareManager`: `process_protocol_instructions` before gas/tip wiring;
2496
+ * `process_full_instructions` after nonce + tip + compute budget + protocol (see `transaction_builder.rs`).
2497
+ */
2498
+ middlewareManager?: MiddlewareManager;
2499
+ /**
2500
+ * Cap concurrent SWQOS `sendTransaction` calls when multiple gas/SWQOS tasks run.
2501
+ * Rust uses a bounded worker pool (`max_sender_concurrency`); set this to approximate that (e.g. 8–18).
2502
+ * Omit or set ≥ task count to keep previous behavior (all tasks parallel).
2503
+ */
2504
+ maxSwqosSubmitConcurrency?: number;
2505
+ }
2506
+ /**
2507
+ * Builder for TradeConfig - makes all options discoverable via IDE autocomplete.
2508
+ *
2509
+ * @example
2510
+ * const config = TradeConfigBuilder.create(rpcUrl)
2511
+ * .swqosConfigs([{ type: SwqosType.Jito, apiKey: 'your-key' }])
2512
+ * // .mevProtection(true) // Enable MEV protection (BlockRazor: sandwichMitigation, Astralane: port 9000)
2513
+ * .build();
2514
+ */
2515
+ declare class TradeConfigBuilder {
2516
+ private _rpcUrl;
2517
+ private _swqosConfigs;
2518
+ private _commitment?;
2519
+ private _logEnabled;
2520
+ private _checkMinTip;
2521
+ private _mevProtection;
2522
+ private _useSeedOptimize;
2523
+ private _usePumpfunV2;
2524
+ private _swqosCoresFromEnd;
2525
+ private _createWsolAtaOnStartup;
2526
+ private _gasFeeStrategy?;
2527
+ private _gasStrategy?;
2528
+ private _middlewareManager?;
2529
+ private _maxSwqosSubmitConcurrency?;
2530
+ private constructor();
2531
+ static create(rpcUrl: string): TradeConfigBuilder;
2532
+ swqosConfigs(configs: SwqosConfig[]): this;
2533
+ commitment(commitment: Commitment): this;
2534
+ logEnabled(enabled: boolean): this;
2535
+ checkMinTip(check: boolean): this;
2536
+ /**
2537
+ * Enable MEV protection (default: false).
2538
+ * When enabled:
2539
+ * - BlockRazor uses mode=sandwichMitigation
2540
+ * - Astralane uses port 9000 MEV-protected QUIC endpoint
2541
+ */
2542
+ mevProtection(enabled: boolean): this;
2543
+ useSeedOptimize(enabled: boolean): this;
2544
+ usePumpfunV2(enabled: boolean): this;
2545
+ swqosCoresFromEnd(enabled: boolean): this;
2546
+ createWsolAtaOnStartup(enabled: boolean): this;
2547
+ gasFeeStrategy(config: GasFeeStrategyConfig): this;
2548
+ gasStrategy(strategy: GasFeeStrategy): this;
2549
+ /** Rust `SolanaTrade::with_middleware_manager` parity. */
2550
+ middlewareManager(manager: MiddlewareManager): this;
2551
+ /**
2552
+ * Limit parallel SWQOS submits (Rust `max_sender_concurrency` / worker pool).
2553
+ */
2554
+ maxSwqosSubmitConcurrency(limit: number | undefined): this;
2555
+ build(): TradeConfig;
2556
+ }
2557
+ declare function recommendedSenderThreadCoreIndices(swqosCount: number, availableCores?: number, fromEnd?: boolean): number[];
2558
+ /**
2559
+ * Middleware context
2560
+ */
2561
+ interface MiddlewareContext {
2562
+ tradeType: TradeType;
2563
+ inputMint: PublicKey;
2564
+ outputMint: PublicKey;
2565
+ inputAmount: number;
2566
+ payer: PublicKey;
2567
+ additionalData?: Record<string, unknown>;
2568
+ }
2569
+ /**
2570
+ * Middleware interface
2571
+ */
2572
+ interface Middleware {
2573
+ process(instructions: TransactionInstruction[], context: MiddlewareContext): Promise<TransactionInstruction[]>;
2574
+ name: string;
2575
+ }
2576
+ /**
2577
+ * 按 mint 查找池地址(与 Rust `find_pool_by_mint` 一致:当前仅 PumpSwap)。
2578
+ */
2579
+ declare function findPoolByMint(connection: Connection, mint: PublicKey, dexType: DexType): Promise<PublicKey>;
2580
+ /** Rust `executor::simulate_transaction` / `RpcSimulateTransactionConfig` (processed, inner ix, no sig verify). */
2581
+ declare const RUST_PARITY_SIMULATE_CONFIG: SimulateTransactionConfig;
2582
+ /**
2583
+ * Main trading client for Solana DEX operations(指令构建与 Rust SDK 对齐,经 `instruction/*` 实现)
2584
+ */
2585
+ declare class TradingClient {
2586
+ private payer;
2587
+ private connection;
2588
+ private _config;
2589
+ private middlewares;
2590
+ private _logEnabled;
2591
+ constructor(payer: Keypair, config: TradeConfig);
2592
+ /** Get the current configuration */
2593
+ get config(): TradeConfig;
2594
+ /** Check if logging is enabled */
2595
+ get isLogEnabled(): boolean;
2596
+ /**
2597
+ * Get the underlying connection
2598
+ */
2599
+ getConnection(): Connection;
2600
+ /**
2601
+ * Get the payer public key
2602
+ */
2603
+ getPayer(): PublicKey;
2604
+ private rpcCommitment;
2605
+ /**
2606
+ * Add middleware to the chain
2607
+ */
2608
+ addMiddleware(middleware: Middleware): this;
2609
+ /**
2610
+ * Execute a buy order
2611
+ */
2612
+ buy(params: TradeBuyParams): Promise<TradeResult>;
2613
+ /**
2614
+ * Execute a sell order
2615
+ */
2616
+ sell(params: TradeSellParams): Promise<TradeResult>;
2617
+ /**
2618
+ * Execute a sell order for a percentage of tokens
2619
+ */
2620
+ sellByPercent(params: TradeSellParams, totalAmount: number, percent: number): Promise<TradeResult>;
2621
+ /**
2622
+ * Get latest blockhash
2623
+ */
2624
+ getLatestBlockhash(): Promise<BlockhashWithExpiryBlockHeight>;
2625
+ /**
2626
+ * Wrap SOL to WSOL
2627
+ */
2628
+ wrapSolToWsol(amount: number): Promise<string>;
2629
+ /**
2630
+ * Close WSOL account and unwrap to SOL
2631
+ */
2632
+ closeWsol(): Promise<string>;
2633
+ /**
2634
+ * Claim PumpFun bonding-curve cashback (SOL → wallet).
2635
+ */
2636
+ claimCashbackPumpfun(): Promise<string>;
2637
+ /**
2638
+ * Claim PumpSwap AMM cashback(会先走 WSOL ATA idempotent 创建,与 Rust 一致)。
2639
+ */
2640
+ claimCashbackPumpswap(): Promise<string>;
2641
+ private sendSingleInstruction;
2642
+ private sendInstructions;
2643
+ private buildBuyInstructions;
2644
+ private buildSellInstructions;
2645
+ private getInputMint;
2646
+ private getOutputMint;
2647
+ private processMiddlewares;
2648
+ private executeTransaction;
2649
+ }
2650
+ /**
2651
+ * Create a new gas fee strategy with defaults
2652
+ */
2653
+ declare function createGasFeeStrategy(): GasFeeStrategy;
2654
+ /**
2655
+ * Create a new trade config (shorthand for {@link TradeConfig} / {@link TradeConfigBuilder}).
2656
+ */
2657
+ declare function createTradeConfig(rpcUrl: string, swqosConfigs?: SwqosConfig[], options?: Partial<Omit<TradeConfig, 'rpcUrl' | 'swqosConfigs'>>): TradeConfig;
2658
+
2659
+ export { AMM_INFO_SIZE, ASSOCIATED_TOKEN_PROGRAM, type AccountState, type AddressLookupTableAccount, AddressLookupTableCache, AstralaneTransport, BONK_AUTHORITY, BONK_BUY_EXACT_IN_DISCRIMINATOR, BONK_EVENT_AUTHORITY, BONK_GLOBAL_CONFIG, BONK_PLATFORM_FEE_RATE, BONK_POOL_SEED, BONK_POOL_STATE_SIZE, BONK_POOL_VAULT_SEED, BONK_PROGRAM, BONK_PROGRAM_ID, BONK_PROTOCOL_FEE_RATE, BONK_SELL_EXACT_IN_DISCRIMINATOR, BONK_SHARE_FEE_RATE, BONK_USD1_GLOBAL_CONFIG, BYTES_PER_ACCOUNT, BaseExecutor, type BatchTradeResult, type BondingCurveAccount, type BonkBuildBuyParams, type BonkBuildSellParams, BonkExecutor, type BonkParams, type BonkPoolState, type BonkVestingSchedule, type BuildBuyParams, type BuildMeteoraDammV2BuyInstructionsParams, type BuildMeteoraDammV2SellInstructionsParams, type BuildRaydiumAmmV4BuyInstructionsParams, type BuildRaydiumAmmV4SellInstructionsParams, type BuildRaydiumCpmmBuyInstructionsParams, type BuildRaydiumCpmmSellInstructionsParams, type BuildSellParams, CONSTANTS, type ConfirmAnySignatureOptions, ContextExpiredError, DEFAULT_COMPUTE_UNITS, DEFAULT_PRIORITY_FEE, DEFAULT_SLIPPAGE, DEFAULT_TIP_LAMPORTS, type DexParamEnum, DexType, type DurableNonceInfo, type ExecuteOptions, type ExecuteResult, ExecutionPath, type FetchedDurableNonce, FilterMiddleware, type GasFeeConfig, GasFeeStrategy, type GasFeeStrategyConfig, GasFeeStrategyType, type GasFeeStrategyValue, type HotPathConfig, HotPathError, HotPathExecutor, HotPathMetrics, HotPathState, type ITradeExecutor, type InstructionMiddleware, InstructionProcessor, KNOWN_PROGRAM_IDS, type KeyMetadata, KeyNotAvailableError, LoggingMiddleware, MAX_INSTRUCTIONS_WARN, METEORA_DAMM_V2_AUTHORITY, METEORA_DAMM_V2_EVENT_AUTHORITY_SEED, METEORA_DAMM_V2_PROGRAM, METEORA_DAMM_V2_PROGRAM_ID, METEORA_DAMM_V2_SWAP_DISCRIMINATOR, METEORA_POOL_SIZE, MeteoraDammV2Executor, type MeteoraDammV2Params, type MeteoraDammV2Pool, MetricsMiddleware, type Middleware, type MiddlewareContext, MiddlewareManager, MissingAccountError, POOL_SIZE, PUMPFUN_BONDING_CURVE_SEED, PUMPFUN_BONDING_CURVE_V2_SEED, PUMPFUN_BUYBACK_FEE_RECIPIENTS, PUMPFUN_BUY_DISCRIMINATOR, PUMPFUN_BUY_EXACT_QUOTE_IN_V2_DISCRIMINATOR, PUMPFUN_BUY_EXACT_SOL_IN_DISCRIMINATOR, PUMPFUN_BUY_V2_DISCRIMINATOR, PUMPFUN_CLAIM_CASHBACK_DISCRIMINATOR, PUMPFUN_CREATOR_VAULT_SEED, PUMPFUN_DISCRIMINATORS, PUMPFUN_EVENT_AUTHORITY, PUMPFUN_FEE_CONFIG, PUMPFUN_FEE_PROGRAM, PUMPFUN_FEE_RECIPIENT, PUMPFUN_GLOBAL_ACCOUNT, PUMPFUN_GLOBAL_VOLUME_ACCUMULATOR, PUMPFUN_MAYHEM_FEE_RECIPIENTS, PUMPFUN_PROGRAM, PUMPFUN_PROGRAM_ID, PUMPFUN_PROTOCOL_EXTRA_FEE_RECIPIENTS, PUMPFUN_SELL_DISCRIMINATOR, PUMPFUN_SELL_V2_DISCRIMINATOR, PUMPFUN_SHARING_CONFIG_SEED, PUMPFUN_STANDARD_FEE_RECIPIENTS, PUMPFUN_USER_VOLUME_ACCUMULATOR_SEED, PUMPSWAP_BUY_DISCRIMINATOR, PUMPSWAP_BUY_EXACT_QUOTE_IN_DISCRIMINATOR, PUMPSWAP_CLAIM_CASHBACK_DISCRIMINATOR, PUMPSWAP_DEFAULT_COIN_CREATOR_VAULT_AUTHORITY, PUMPSWAP_DISCRIMINATORS, PUMPSWAP_EVENT_AUTHORITY, PUMPSWAP_FEE_CONFIG, PUMPSWAP_FEE_PROGRAM, PUMPSWAP_FEE_RECIPIENT, PUMPSWAP_GLOBAL_ACCOUNT, PUMPSWAP_GLOBAL_VOLUME_ACCUMULATOR, PUMPSWAP_MAYHEM_FEE_RECIPIENTS, PUMPSWAP_PROGRAM, PUMPSWAP_PROGRAM_ID, PUMPSWAP_PROTOCOL_EXTRA_FEE_RECIPIENTS, PUMPSWAP_PUMP_PROGRAM_ID, PUMPSWAP_SELL_DISCRIMINATOR, type PoolState, Prefetch, type PrefetchedData, type PumpFunBondingCurve, type PumpFunBuildBuyParams, type PumpFunBuildSellParams, PumpFunExecutor, type PumpFunParams, PumpSwapExecutor, type PumpSwapParams, type PumpSwapPool, RAYDIUM_AMM_V4_AUTHORITY, RAYDIUM_AMM_V4_POOL_SEED, RAYDIUM_AMM_V4_PROGRAM, RAYDIUM_AMM_V4_PROGRAM_ID, RAYDIUM_AMM_V4_SWAP_BASE_IN_DISCRIMINATOR, RAYDIUM_AMM_V4_SWAP_BASE_OUT_DISCRIMINATOR, RAYDIUM_AMM_V4_SWAP_FEE_DENOMINATOR, RAYDIUM_AMM_V4_SWAP_FEE_NUMERATOR, RAYDIUM_AMM_V4_TRADE_FEE_DENOMINATOR, RAYDIUM_AMM_V4_TRADE_FEE_NUMERATOR, RAYDIUM_CPMM_AUTHORITY, RAYDIUM_CPMM_CREATOR_FEE_RATE, RAYDIUM_CPMM_FEE_RATE_DENOMINATOR_VALUE, RAYDIUM_CPMM_FUND_FEE_RATE, RAYDIUM_CPMM_OBSERVATION_STATE_SEED, RAYDIUM_CPMM_POOL_SEED, RAYDIUM_CPMM_POOL_STATE_SIZE, RAYDIUM_CPMM_POOL_VAULT_SEED, RAYDIUM_CPMM_PROGRAM, RAYDIUM_CPMM_PROGRAM_ID, RAYDIUM_CPMM_PROTOCOL_FEE_RATE, RAYDIUM_CPMM_SWAP_BASE_IN_DISCRIMINATOR, RAYDIUM_CPMM_SWAP_BASE_OUT_DISCRIMINATOR, RAYDIUM_CPMM_TRADE_FEE_RATE, RENT, RUST_PARITY_SIMULATE_CONFIG, type RaydiumAmmFees, type RaydiumAmmInfo, type RaydiumAmmOutputData, RaydiumAmmV4Executor, type RaydiumAmmV4Params, type RaydiumCPMMpoolState, RaydiumCpmmExecutor, type RaydiumCpmmParams, SDK_FEE_RECIPIENT, SDK_MAYHEM_FEE_RECIPIENTS, SOL_TOKEN_ACCOUNT, SWQOS_ENDPOINTS, SYSTEM_PROGRAM, SecureKeyError, SecureKeyStorage, StaleBlockhashError, type SwqosConfig, SwqosRegion, type SwqosTiming, SwqosTransport, SwqosType, TOKEN_PROGRAM, TOKEN_PROGRAM_2022, TimerMiddleware, type TradeBuyParams, type TradeConfig, TradeConfigBuilder, TradeError, type TradeExecuteOptions, TradeExecutorFactory, type TradeResult, type TradeSellParams, TradeTokenType, TradeType, TradingClient, TradingContext, TransactionBuilder, USD1_MINT, USD1_TOKEN_ACCOUNT, USDC_MINT, USDC_TOKEN_ACCOUNT, ValidationError, ValidationMiddleware, WSOL_MINT, WSOL_TOKEN_ACCOUNT, addressLookupTableCache, buildBonkBuyInstructions, buildBonkSellInstructions, buildBuyInstructions, buildClaimCashbackInstruction, buildMeteoraDammV2BuyInstructions, buildMeteoraDammV2SellInstructions, buildPumpFunBuyInstructions, buildPumpFunBuyV2Instructions, buildPumpFunClaimCashbackInstruction, buildPumpFunSellInstructions, buildPumpFunSellV2Instructions, buildRaydiumAmmV4BuyInstructions, buildRaydiumAmmV4SellInstructions, buildRaydiumCpmmBuyInstructions, buildRaydiumCpmmSellInstructions, buildSellInstructions, calculatePriceImpact, calculateWithSlippageBuy, calculateWithSlippageSell, closeWsol, commitmentToGetTxFinality, computeRaydiumAmmV4SwapAmount, computeRaydiumCpmmSwapAmount, confirmAnyTransactionSignature, createAssociatedTokenAccountIdempotent, createGasFeeStrategy, createHotPathExecutor, createTradeConfig, decodeAmmInfo, decodeBonkPoolState, decodeMeteoraPool, decodePool, decodeRaydiumCPMMpoolState, defaultExecuteOptions, defaultHotPathConfig, defaultTradeExecuteOptions, extractHintsFromLogs, fetchAddressLookupTableAccount, fetchAmmInfo, fetchBondingCurveAccount, fetchBonkPoolState, fetchDurableNonceInfo, fetchMeteoraPool, fetchPool, fetchRaydiumCPMMpoolState, findByBaseMint, findByMint, findByQuoteMint, findPoolByMint, formatPublicKey, getAssociatedTokenAddress, getBondingCurvePda, getBondingCurveV2Pda, getBonkCreatorAssociatedAccount, getBonkPlatformAssociatedAccount, getBonkPoolPDA, getBonkPoolPda, getBonkVaultPDA, getBonkVaultPda, getBuyPrice, getBuyTokenAmountFromSolAmount, getCanonicalPoolPDA, getCoinCreatorVaultAta, getCoinCreatorVaultAuthority, getCreator, getCreatorVaultPda, getFeeConfigPDA, getFeeRecipientAta, getGlobalVolumeAccumulatorPDA, getMayhemFeeRecipientRandom, getMeteoraDammV2EventAuthorityPda, getPoolV2PDA, getPumpFunBuybackFeeRecipientRandom, getPumpFunFeeSharingConfigPda, getPumpFunProtocolExtraFeeRecipientRandom, getPumpFunUserVolumeAccumulatorPda, getPumpPoolAuthorityPDA, getPumpSwapProtocolExtraFeeRecipientRandom, getRandomMayhemFeeRecipient, getRaydiumCPMMobservationStatePDA, getRaydiumCPMMpoolPDA, getRaydiumCPMMpoolTokenBalances, getRaydiumCPMMvaultPDA, getRaydiumCpmmObservationStatePda, getRaydiumCpmmPoolPda, getRaydiumCpmmVaultPda, getSellSolAmountFromTokenAmount, getStandardFeeRecipientRandom, getTokenBalances, getUserVolumeAccumulatorPDA, getUserVolumeAccumulatorQuoteAta, getUserVolumeAccumulatorWsolAta, handleWsol, instructionErrorCodeFromMetaErr, isValidPublicKey, lamportsToSol, mapWithConcurrencyLimit, nowMicroseconds, parseAddressLookupTable, pumpFunFeeRecipientMeta, recommendedSenderThreadCoreIndices, retryWithBackoff, signWithKeypair, sleep, solToLamports, validateAmount, validateMintPair, validateProgramId, validatePubkey, validateRpcUrl, validateSignature, validateSlippage, validateTransactionSize, withAllBuiltinMiddlewares, withStandardMiddlewares };