four-flap-meme-sdk 1.4.90 → 1.4.92

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 (164) hide show
  1. package/dist/flap/portal-bundle-merkle/create-to-dex.d.ts +1 -1
  2. package/dist/flap/portal-bundle-merkle/create-to-dex.js +51 -13
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.js +24 -0
  5. package/dist/sol/constants.d.ts +126 -0
  6. package/dist/sol/constants.js +145 -0
  7. package/dist/sol/dex/blockrazor/client.d.ts +51 -0
  8. package/dist/sol/dex/blockrazor/client.js +96 -0
  9. package/dist/sol/dex/blockrazor/constants.d.ts +34 -0
  10. package/dist/sol/dex/blockrazor/constants.js +55 -0
  11. package/dist/sol/dex/blockrazor/geyser.d.ts +128 -0
  12. package/dist/sol/dex/blockrazor/geyser.js +530 -0
  13. package/dist/sol/dex/blockrazor/index.d.ts +18 -0
  14. package/dist/sol/dex/blockrazor/index.js +23 -0
  15. package/dist/sol/dex/blockrazor/send.d.ts +135 -0
  16. package/dist/sol/dex/blockrazor/send.js +254 -0
  17. package/dist/sol/dex/blockrazor/types.d.ts +191 -0
  18. package/dist/sol/dex/blockrazor/types.js +5 -0
  19. package/dist/sol/dex/index.d.ts +10 -0
  20. package/dist/sol/dex/index.js +16 -0
  21. package/dist/sol/dex/jup/client.d.ts +33 -0
  22. package/dist/sol/dex/jup/client.js +110 -0
  23. package/dist/sol/dex/jup/index.d.ts +16 -0
  24. package/dist/sol/dex/jup/index.js +148 -0
  25. package/dist/sol/dex/jup/legacy.d.ts +623 -0
  26. package/dist/sol/dex/jup/legacy.js +416 -0
  27. package/dist/sol/dex/jup/lend.d.ts +640 -0
  28. package/dist/sol/dex/jup/lend.js +603 -0
  29. package/dist/sol/dex/jup/portfolio.d.ts +362 -0
  30. package/dist/sol/dex/jup/portfolio.js +367 -0
  31. package/dist/sol/dex/jup/price.d.ts +173 -0
  32. package/dist/sol/dex/jup/price.js +220 -0
  33. package/dist/sol/dex/jup/recurring.d.ts +437 -0
  34. package/dist/sol/dex/jup/recurring.js +320 -0
  35. package/dist/sol/dex/jup/send.d.ts +282 -0
  36. package/dist/sol/dex/jup/send.js +295 -0
  37. package/dist/sol/dex/jup/studio.d.ts +457 -0
  38. package/dist/sol/dex/jup/studio.js +488 -0
  39. package/dist/sol/dex/jup/tokens.d.ts +767 -0
  40. package/dist/sol/dex/jup/tokens.js +697 -0
  41. package/dist/sol/dex/jup/trigger.d.ts +511 -0
  42. package/dist/sol/dex/jup/trigger.js +397 -0
  43. package/dist/sol/dex/jup/types.d.ts +433 -0
  44. package/dist/sol/dex/jup/types.js +5 -0
  45. package/dist/sol/dex/jup/ultra.d.ts +646 -0
  46. package/dist/sol/dex/jup/ultra.js +853 -0
  47. package/dist/sol/dex/meteora/client.d.ts +76 -0
  48. package/dist/sol/dex/meteora/client.js +219 -0
  49. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +61 -0
  50. package/dist/sol/dex/meteora/damm-v1-bundle.js +112 -0
  51. package/dist/sol/dex/meteora/damm-v1.d.ts +118 -0
  52. package/dist/sol/dex/meteora/damm-v1.js +315 -0
  53. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +82 -0
  54. package/dist/sol/dex/meteora/damm-v2-bundle.js +242 -0
  55. package/dist/sol/dex/meteora/damm-v2.d.ts +172 -0
  56. package/dist/sol/dex/meteora/damm-v2.js +632 -0
  57. package/dist/sol/dex/meteora/dbc-bundle.d.ts +123 -0
  58. package/dist/sol/dex/meteora/dbc-bundle.js +304 -0
  59. package/dist/sol/dex/meteora/dbc.d.ts +192 -0
  60. package/dist/sol/dex/meteora/dbc.js +619 -0
  61. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +39 -0
  62. package/dist/sol/dex/meteora/dlmm-bundle.js +189 -0
  63. package/dist/sol/dex/meteora/dlmm.d.ts +157 -0
  64. package/dist/sol/dex/meteora/dlmm.js +671 -0
  65. package/dist/sol/dex/meteora/index.d.ts +25 -0
  66. package/dist/sol/dex/meteora/index.js +65 -0
  67. package/dist/sol/dex/meteora/types.d.ts +787 -0
  68. package/dist/sol/dex/meteora/types.js +110 -0
  69. package/dist/sol/dex/orca/index.d.ts +10 -0
  70. package/dist/sol/dex/orca/index.js +16 -0
  71. package/dist/sol/dex/orca/orca-bundle.d.ts +41 -0
  72. package/dist/sol/dex/orca/orca-bundle.js +173 -0
  73. package/dist/sol/dex/orca/orca.d.ts +65 -0
  74. package/dist/sol/dex/orca/orca.js +474 -0
  75. package/dist/sol/dex/orca/types.d.ts +263 -0
  76. package/dist/sol/dex/orca/types.js +38 -0
  77. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +34 -0
  78. package/dist/sol/dex/orca/wavebreak-bundle.js +198 -0
  79. package/dist/sol/dex/orca/wavebreak-types.d.ts +227 -0
  80. package/dist/sol/dex/orca/wavebreak-types.js +23 -0
  81. package/dist/sol/dex/orca/wavebreak.d.ts +78 -0
  82. package/dist/sol/dex/orca/wavebreak.js +497 -0
  83. package/dist/sol/dex/pump/index.d.ts +9 -0
  84. package/dist/sol/dex/pump/index.js +14 -0
  85. package/dist/sol/dex/pump/pump-bundle.d.ts +92 -0
  86. package/dist/sol/dex/pump/pump-bundle.js +383 -0
  87. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +103 -0
  88. package/dist/sol/dex/pump/pump-swap-bundle.js +380 -0
  89. package/dist/sol/dex/pump/pump-swap.d.ts +46 -0
  90. package/dist/sol/dex/pump/pump-swap.js +199 -0
  91. package/dist/sol/dex/pump/pump.d.ts +35 -0
  92. package/dist/sol/dex/pump/pump.js +352 -0
  93. package/dist/sol/dex/pump/types.d.ts +215 -0
  94. package/dist/sol/dex/pump/types.js +5 -0
  95. package/dist/sol/dex/raydium/index.d.ts +8 -0
  96. package/dist/sol/dex/raydium/index.js +12 -0
  97. package/dist/sol/dex/raydium/launchlab.d.ts +68 -0
  98. package/dist/sol/dex/raydium/launchlab.js +210 -0
  99. package/dist/sol/dex/raydium/raydium-bundle.d.ts +64 -0
  100. package/dist/sol/dex/raydium/raydium-bundle.js +324 -0
  101. package/dist/sol/dex/raydium/raydium.d.ts +40 -0
  102. package/dist/sol/dex/raydium/raydium.js +366 -0
  103. package/dist/sol/dex/raydium/types.d.ts +240 -0
  104. package/dist/sol/dex/raydium/types.js +5 -0
  105. package/dist/sol/index.d.ts +10 -0
  106. package/dist/sol/index.js +16 -0
  107. package/dist/sol/jito/bundle.d.ts +90 -0
  108. package/dist/sol/jito/bundle.js +263 -0
  109. package/dist/sol/jito/index.d.ts +7 -0
  110. package/dist/sol/jito/index.js +7 -0
  111. package/dist/sol/jito/tip.d.ts +51 -0
  112. package/dist/sol/jito/tip.js +83 -0
  113. package/dist/sol/jito/types.d.ts +100 -0
  114. package/dist/sol/jito/types.js +5 -0
  115. package/dist/sol/token/create-complete.d.ts +115 -0
  116. package/dist/sol/token/create-complete.js +235 -0
  117. package/dist/sol/token/create-token.d.ts +57 -0
  118. package/dist/sol/token/create-token.js +230 -0
  119. package/dist/sol/token/index.d.ts +9 -0
  120. package/dist/sol/token/index.js +14 -0
  121. package/dist/sol/token/metadata-upload.d.ts +86 -0
  122. package/dist/sol/token/metadata-upload.js +173 -0
  123. package/dist/sol/token/metadata.d.ts +92 -0
  124. package/dist/sol/token/metadata.js +274 -0
  125. package/dist/sol/token/types.d.ts +153 -0
  126. package/dist/sol/token/types.js +5 -0
  127. package/dist/sol/types.d.ts +176 -0
  128. package/dist/sol/types.js +7 -0
  129. package/dist/sol/utils/balance.d.ts +160 -0
  130. package/dist/sol/utils/balance.js +638 -0
  131. package/dist/sol/utils/connection.d.ts +78 -0
  132. package/dist/sol/utils/connection.js +168 -0
  133. package/dist/sol/utils/index.d.ts +9 -0
  134. package/dist/sol/utils/index.js +9 -0
  135. package/dist/sol/utils/lp-inspect.d.ts +129 -0
  136. package/dist/sol/utils/lp-inspect.js +900 -0
  137. package/dist/sol/utils/transfer.d.ts +196 -0
  138. package/dist/sol/utils/transfer.js +307 -0
  139. package/dist/sol/utils/wallet.d.ts +107 -0
  140. package/dist/sol/utils/wallet.js +210 -0
  141. package/dist/xlayer/aa-account.d.ts +240 -0
  142. package/dist/xlayer/aa-account.js +510 -0
  143. package/dist/xlayer/bundle.d.ts +93 -0
  144. package/dist/xlayer/bundle.js +472 -0
  145. package/dist/xlayer/bundler.d.ts +111 -0
  146. package/dist/xlayer/bundler.js +162 -0
  147. package/dist/xlayer/constants.d.ts +75 -0
  148. package/dist/xlayer/constants.js +145 -0
  149. package/dist/xlayer/dex.d.ts +132 -0
  150. package/dist/xlayer/dex.js +335 -0
  151. package/dist/xlayer/examples/bundle-buy-sell.d.ts +11 -0
  152. package/dist/xlayer/examples/bundle-buy-sell.js +194 -0
  153. package/dist/xlayer/index.d.ts +75 -0
  154. package/dist/xlayer/index.js +130 -0
  155. package/dist/xlayer/portal-ops.d.ts +152 -0
  156. package/dist/xlayer/portal-ops.js +239 -0
  157. package/dist/xlayer/types.d.ts +298 -0
  158. package/dist/xlayer/types.js +6 -0
  159. package/dist/xlayer/volume.d.ts +65 -0
  160. package/dist/xlayer/volume.js +235 -0
  161. package/package.json +38 -3
  162. package/README.zh-CN.pdf +0 -0
  163. package/dist/flap/portal-bundle-merkle/encryption.d.ts +0 -16
  164. package/dist/flap/portal-bundle-merkle/encryption.js +0 -146
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { type FlapSignConfig } from './config.js';
11
11
  import type { MerkleSignedResult } from './types.js';
12
- export type CreateToDexChain = 'bsc';
12
+ export type CreateToDexChain = 'bsc' | 'xlayer';
13
13
  export type DexPoolType = 'v2' | 'v3';
14
14
  /** 签名配置 */
15
15
  export interface CreateToDexSignConfig extends FlapSignConfig {
@@ -26,9 +26,39 @@ const ERC20_ABI = [
26
26
  }
27
27
  ];
28
28
  // ==================== 链常量 ====================
29
+ // BSC
29
30
  const BSC_PANCAKE_V2_ROUTER = ADDRESSES.BSC.PancakeV2Router;
30
31
  const BSC_PANCAKE_V3_ROUTER = ADDRESSES.BSC.PancakeV3Router;
31
32
  const BSC_WBNB = ADDRESSES.BSC.WBNB;
33
+ // XLAYER
34
+ const XLAYER_POTATOSWAP_V2_ROUTER = '0x881fb2f98c13d521009464e7d1cbf16e1b394e8e';
35
+ const XLAYER_POTATOSWAP_V3_ROUTER = '0xB45D0149249488333E3F3f9F359807F4b810C1FC';
36
+ const XLAYER_WOKB = '0xe538905cf8410324e03a5a23c1c177a474d59b2b';
37
+ // 链 ID 映射
38
+ const CHAIN_ID_MAP = {
39
+ bsc: 56,
40
+ xlayer: 196,
41
+ };
42
+ // 获取链配置
43
+ function getChainConfig(chain) {
44
+ if (chain === 'xlayer') {
45
+ return {
46
+ chainId: 196,
47
+ v2Router: XLAYER_POTATOSWAP_V2_ROUTER,
48
+ v3Router: XLAYER_POTATOSWAP_V3_ROUTER,
49
+ wrappedNative: XLAYER_WOKB,
50
+ nativeSymbol: 'OKB',
51
+ };
52
+ }
53
+ // 默认 BSC
54
+ return {
55
+ chainId: 56,
56
+ v2Router: BSC_PANCAKE_V2_ROUTER,
57
+ v3Router: BSC_PANCAKE_V3_ROUTER,
58
+ wrappedNative: BSC_WBNB,
59
+ nativeSymbol: 'BNB',
60
+ };
61
+ }
32
62
  // PancakeSwap Router ABI
33
63
  const PANCAKE_V3_ROUTER_ABI = [
34
64
  {
@@ -78,7 +108,8 @@ const USD1_V3_FEE = 100;
78
108
  const DEFAULT_V3_FEE = 2500;
79
109
  // ==================== 工具函数 ====================
80
110
  /** 构建 ERC20 approve 交易 */
81
- async function buildApproveTransaction(wallet, tokenAddress, spenderAddress, amount, nonce, gasPrice, txType) {
111
+ async function buildApproveTransaction(wallet, tokenAddress, spenderAddress, amount, nonce, gasPrice, txType, chainId = 56 // ✅ 添加 chainId 参数
112
+ ) {
82
113
  const erc20Interface = new ethers.Interface(ERC20_ABI);
83
114
  const data = erc20Interface.encodeFunctionData('approve', [spenderAddress, amount]);
84
115
  const tx = {
@@ -87,7 +118,7 @@ async function buildApproveTransaction(wallet, tokenAddress, spenderAddress, amo
87
118
  from: wallet.address,
88
119
  nonce,
89
120
  gasLimit: BigInt(100000), // approve 交易 gas 较低
90
- chainId: 56,
121
+ chainId,
91
122
  type: txType
92
123
  };
93
124
  if (txType === 2) {
@@ -154,9 +185,12 @@ export async function flapBundleCreateToDex(params) {
154
185
  // 判断是否使用原生代币
155
186
  const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
156
187
  const inputToken = useNativeToken ? ZERO_ADDRESS : quoteToken;
188
+ // ✅ 获取链配置
189
+ const chainConfig = getChainConfig(chain);
190
+ const chainId = chainConfig.chainId;
157
191
  // 创建 Provider
158
192
  const provider = new ethers.JsonRpcProvider(config.rpcUrl, {
159
- chainId: chain === 'bsc' ? 56 : 56,
193
+ chainId,
160
194
  name: chain.toUpperCase()
161
195
  });
162
196
  const portalAddress = FLAP_PORTAL_ADDRESSES[chain.toUpperCase()];
@@ -228,7 +262,7 @@ export async function flapBundleCreateToDex(params) {
228
262
  nonce: bribeNonce,
229
263
  gasPrice,
230
264
  gasLimit: 21000n,
231
- chainId: 56,
265
+ chainId,
232
266
  type: txType
233
267
  });
234
268
  allTransactions.push(bribeTx);
@@ -305,7 +339,7 @@ export async function flapBundleCreateToDex(params) {
305
339
  from: devWallet.address,
306
340
  nonce: devNonce,
307
341
  gasLimit: finalGasLimit,
308
- chainId: 56,
342
+ chainId,
309
343
  type: txType
310
344
  };
311
345
  if (txType === 2) {
@@ -328,7 +362,8 @@ export async function flapBundleCreateToDex(params) {
328
362
  if (!useNativeToken) {
329
363
  const approveNonce = noncesMap.get(addr);
330
364
  noncesMap.set(addr, approveNonce + 1);
331
- const approveTx = await buildApproveTransaction(wallet, quoteToken, portalAddress, curveBuyAmounts[i], approveNonce, gasPrice, txType);
365
+ const approveTx = await buildApproveTransaction(wallet, quoteToken, portalAddress, curveBuyAmounts[i], approveNonce, gasPrice, txType, chainId // ✅ 传递 chainId
366
+ );
332
367
  signedTxs.push(approveTx);
333
368
  }
334
369
  // 构建买入交易
@@ -350,7 +385,7 @@ export async function flapBundleCreateToDex(params) {
350
385
  from: wallet.address,
351
386
  nonce: buyNonce,
352
387
  gasLimit: buyGasLimit,
353
- chainId: 56,
388
+ chainId,
354
389
  type: txType,
355
390
  value: useNativeToken ? curveBuyAmounts[i] : 0n
356
391
  };
@@ -375,14 +410,17 @@ export async function flapBundleCreateToDex(params) {
375
410
  const addr = wallet.address.toLowerCase();
376
411
  const signedTxs = [];
377
412
  const buyAmount = dexBuyAmounts[i];
378
- const smartRouter = dexPoolType === 'v3' ? BSC_PANCAKE_V3_ROUTER : BSC_PANCAKE_V2_ROUTER;
413
+ // 使用动态 Router 地址
414
+ const smartRouter = dexPoolType === 'v3' ? chainConfig.v3Router : chainConfig.v2Router;
415
+ const wrappedNative = chainConfig.wrappedNative;
379
416
  // ✅ 根据 quoteToken 选择 V3 费率
380
417
  const actualV3Fee = v3Fee || (useNativeToken ? DEFAULT_V3_FEE : USD1_V3_FEE);
381
418
  // ✅ ERC20: 先构建 approve 交易
382
419
  if (!useNativeToken) {
383
420
  const approveNonce = noncesMap.get(addr);
384
421
  noncesMap.set(addr, approveNonce + 1);
385
- const approveTx = await buildApproveTransaction(wallet, quoteToken, smartRouter, buyAmount, approveNonce, gasPrice, txType);
422
+ const approveTx = await buildApproveTransaction(wallet, quoteToken, smartRouter, buyAmount, approveNonce, gasPrice, txType, chainId // ✅ 传递 chainId
423
+ );
386
424
  signedTxs.push(approveTx);
387
425
  }
388
426
  // 构建买入交易
@@ -394,7 +432,7 @@ export async function flapBundleCreateToDex(params) {
394
432
  if (dexPoolType === 'v3') {
395
433
  // V3: exactInputSingle
396
434
  const params = {
397
- tokenIn: useNativeToken ? BSC_WBNB : quoteToken,
435
+ tokenIn: useNativeToken ? wrappedNative : quoteToken,
398
436
  tokenOut: tokenAddress,
399
437
  fee: actualV3Fee,
400
438
  recipient: wallet.address,
@@ -407,7 +445,7 @@ export async function flapBundleCreateToDex(params) {
407
445
  }
408
446
  else {
409
447
  // V2: swapExactTokensForTokens
410
- const path = useNativeToken ? [BSC_WBNB, tokenAddress] : [quoteToken, tokenAddress];
448
+ const path = useNativeToken ? [wrappedNative, tokenAddress] : [quoteToken, tokenAddress];
411
449
  const swapData = routerInterface.encodeFunctionData('swapExactTokensForTokens', [buyAmount, 0n, path, wallet.address]);
412
450
  multicallData = [swapData];
413
451
  value = useNativeToken ? buyAmount : 0n;
@@ -419,7 +457,7 @@ export async function flapBundleCreateToDex(params) {
419
457
  from: wallet.address,
420
458
  nonce: buyNonce,
421
459
  gasLimit: BigInt(500000),
422
- chainId: 56,
460
+ chainId,
423
461
  type: txType,
424
462
  value
425
463
  };
@@ -450,7 +488,7 @@ export async function flapBundleCreateToDex(params) {
450
488
  profitRecipient: getProfitRecipient(),
451
489
  hopCount: PROFIT_HOP_COUNT,
452
490
  gasPrice,
453
- chainId: 56,
491
+ chainId,
454
492
  txType,
455
493
  startNonce: profitNonce
456
494
  });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * as Abis from './abis/index.js';
2
+ export * as Sol from './sol/index.js';
2
3
  export { ERC20_ABI, ERC20_BALANCE_ABI, ERC20_ALLOWANCE_ABI, MULTICALL3_ABI, V2_ROUTER_ABI, V2_ROUTER_QUOTE_ABI, V3_ROUTER02_ABI, V3_ROUTER_LEGACY_ABI, V3_QUOTER_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, V3_POOL_ABI, FLAP_PORTAL_ABI, TM2_ABI, HELPER3_ABI, } from './abis/common.js';
3
4
  export { ADDRESSES, CHAIN, BLOCKRAZOR_BUILDER_EOA as BUILDER_EOA, ZERO_ADDRESS as COMMON_ZERO_ADDRESS, DEFAULT_DEADLINE_MINUTES, V3_FEE_TIERS as COMMON_V3_FEE_TIERS, } from './utils/constants.js';
4
5
  export { isExclusiveOnChain, isExclusiveOffChain } from './utils/mpcExclusive.js';
@@ -52,3 +53,5 @@ export { quoteV2, quoteV3, quote, getTokenToNativeQuote, getNativeToTokenQuote,
52
53
  export { submitDirectToRpc, submitDirectToRpcSequential, // ✅ 新增:顺序广播并等待确认(用于多跳)
53
54
  submitDirectToRpcParallel, type DirectSubmitConfig, type DirectSubmitResult, type DirectTxResult } from './contracts/tm-bundle-merkle/submit.js';
54
55
  export { directV2BatchBuy, directV2BatchSell, directV3BatchBuy, directV3BatchSell, getRouterAddress, DIRECT_ROUTERS, type DirectV2BuyParams, type DirectV2SellParams, type DirectV3BuyParams, type DirectV3SellParams, type DirectRouterResult, type DirectRouterSignConfig, type DexKey, type RouterVersion, } from './dex/index.js';
56
+ export * as XLayer from './xlayer/index.js';
57
+ export { bundleBuy as xlayerBundleBuy, bundleSell as xlayerBundleSell, bundleBuySell as xlayerBundleBuySell, createBundleExecutor as xlayerCreateBundleExecutor, BundleExecutor as XLayerBundleExecutor, makeVolume as xlayerMakeVolume, singleRoundVolume as xlayerSingleRoundVolume, createVolumeExecutor as xlayerCreateVolumeExecutor, VolumeExecutor as XLayerVolumeExecutor, createDexExecutor as xlayerCreateDexExecutor, createDexQuery as xlayerCreateDexQuery, quoteOkbToToken as xlayerQuoteOkbToToken, quoteTokenToOkb as xlayerQuoteTokenToOkb, DexExecutor as XLayerDexExecutor, DexQuery as XLayerDexQuery, createAAAccountManager as xlayerCreateAAAccountManager, predictSender as xlayerPredictSender, createWallet as xlayerCreateWallet, AAAccountManager as XLayerAAAccountManager, generateAAWallets as xlayerGenerateAAWallets, generateAAWalletsFromMnemonic as xlayerGenerateAAWalletsFromMnemonic, predictSendersFromPrivateKeys as xlayerPredictSendersFromPrivateKeys, createBundlerClient as xlayerCreateBundlerClient, BundlerClient as XLayerBundlerClient, createPortalQuery as xlayerCreatePortalQuery, PortalQuery as XLayerPortalQuery, encodeBuyCall as xlayerEncodeBuyCall, encodeSellCall as xlayerEncodeSellCall, encodeApproveCall as xlayerEncodeApproveCall, parseOkb as xlayerParseOkb, formatOkb as xlayerFormatOkb, XLAYER_CHAIN_ID, FLAP_PORTAL as XLAYER_FLAP_PORTAL, ENTRYPOINT_V06 as XLAYER_ENTRYPOINT, SIMPLE_ACCOUNT_FACTORY as XLAYER_FACTORY, PARTICLE_BUNDLER_URL as XLAYER_BUNDLER_URL, WOKB as XLAYER_WOKB, POTATOSWAP_V2_ROUTER as XLAYER_POTATOSWAP_ROUTER, type XLayerConfig, type BundleBuyParams as XLayerBundleBuyParams, type BundleSellParams as XLayerBundleSellParams, type BundleBuySellParams as XLayerBundleBuySellParams, type VolumeParams as XLayerVolumeParams, type BundleBuyResult as XLayerBundleBuyResult, type BundleSellResult as XLayerBundleSellResult, type BundleBuySellResult as XLayerBundleBuySellResult, type VolumeResult as XLayerVolumeResult, type HandleOpsResult as XLayerHandleOpsResult, type AAAccount as XLayerAAAccount, type UserOperation as XLayerUserOperation, type GeneratedAAWallet as XLayerGeneratedAAWallet, type GenerateAAWalletsParams as XLayerGenerateAAWalletsParams, type GenerateAAWalletsResult as XLayerGenerateAAWalletsResult, } from './xlayer/index.js';
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // 公共 ABI(统一管理)
3
3
  // ============================================================================
4
4
  export * as Abis from './abis/index.js';
5
+ export * as Sol from './sol/index.js';
5
6
  export { ERC20_ABI, ERC20_BALANCE_ABI, ERC20_ALLOWANCE_ABI, MULTICALL3_ABI, V2_ROUTER_ABI, V2_ROUTER_QUOTE_ABI, V3_ROUTER02_ABI, V3_ROUTER_LEGACY_ABI, V3_QUOTER_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, V3_POOL_ABI, FLAP_PORTAL_ABI, TM2_ABI, HELPER3_ABI, } from './abis/common.js';
6
7
  // ============================================================================
7
8
  // 公共常量(统一管理)
@@ -95,3 +96,26 @@ directV3BatchBuy, directV3BatchSell,
95
96
  getRouterAddress,
96
97
  // 常量
97
98
  DIRECT_ROUTERS, } from './dex/index.js';
99
+ // ============================================================
100
+ // ✅ XLayer SDK(ERC-4337 AA 钱包模式)
101
+ // ============================================================
102
+ export * as XLayer from './xlayer/index.js';
103
+ export {
104
+ // 捆绑交易
105
+ bundleBuy as xlayerBundleBuy, bundleSell as xlayerBundleSell, bundleBuySell as xlayerBundleBuySell, createBundleExecutor as xlayerCreateBundleExecutor, BundleExecutor as XLayerBundleExecutor,
106
+ // 刷量
107
+ makeVolume as xlayerMakeVolume, singleRoundVolume as xlayerSingleRoundVolume, createVolumeExecutor as xlayerCreateVolumeExecutor, VolumeExecutor as XLayerVolumeExecutor,
108
+ // DEX 交易
109
+ createDexExecutor as xlayerCreateDexExecutor, createDexQuery as xlayerCreateDexQuery, quoteOkbToToken as xlayerQuoteOkbToToken, quoteTokenToOkb as xlayerQuoteTokenToOkb, DexExecutor as XLayerDexExecutor, DexQuery as XLayerDexQuery,
110
+ // AA 账户管理
111
+ createAAAccountManager as xlayerCreateAAAccountManager, predictSender as xlayerPredictSender, createWallet as xlayerCreateWallet, AAAccountManager as XLayerAAAccountManager,
112
+ // 批量生成钱包工具
113
+ generateAAWallets as xlayerGenerateAAWallets, generateAAWalletsFromMnemonic as xlayerGenerateAAWalletsFromMnemonic, predictSendersFromPrivateKeys as xlayerPredictSendersFromPrivateKeys,
114
+ // Bundler 客户端
115
+ createBundlerClient as xlayerCreateBundlerClient, BundlerClient as XLayerBundlerClient,
116
+ // Portal 操作
117
+ createPortalQuery as xlayerCreatePortalQuery, PortalQuery as XLayerPortalQuery, encodeBuyCall as xlayerEncodeBuyCall, encodeSellCall as xlayerEncodeSellCall, encodeApproveCall as xlayerEncodeApproveCall,
118
+ // 工具函数
119
+ parseOkb as xlayerParseOkb, formatOkb as xlayerFormatOkb,
120
+ // 常量
121
+ XLAYER_CHAIN_ID, FLAP_PORTAL as XLAYER_FLAP_PORTAL, ENTRYPOINT_V06 as XLAYER_ENTRYPOINT, SIMPLE_ACCOUNT_FACTORY as XLAYER_FACTORY, PARTICLE_BUNDLER_URL as XLAYER_BUNDLER_URL, WOKB as XLAYER_WOKB, POTATOSWAP_V2_ROUTER as XLAYER_POTATOSWAP_ROUTER, } from './xlayer/index.js';
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Solana SDK 常量配置
3
+ * @module sol/constants
4
+ */
5
+ /**
6
+ * Jito 配置
7
+ *
8
+ * 注意:BLOCK_ENGINE_URL 需要由前端传入,不在 SDK 中写死
9
+ */
10
+ export declare const JITO_CONFIG: {
11
+ /** Tip 账户列表(随机选择一个)- 这些是 Jito 官方账户,固定不变 */
12
+ readonly TIP_ACCOUNTS: readonly ["96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5", "HFqU5x63VTqvQss8hp11i4bVmkzdNaVB6PYjYgNd4W5U", "Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY", "ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49", "DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh", "ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt", "DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL", "3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT"];
13
+ /** 最小 Tip(lamports) */
14
+ readonly MIN_TIP_LAMPORTS: 1000;
15
+ /** 默认 Tip(lamports)- 0.00001 SOL */
16
+ readonly DEFAULT_TIP_LAMPORTS: 10000;
17
+ };
18
+ /**
19
+ * Solana 系统程序地址
20
+ */
21
+ export declare const SYSTEM_PROGRAMS: {
22
+ /** Token Program */
23
+ readonly TOKEN_PROGRAM: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
24
+ /** Token-2022 Program */
25
+ readonly TOKEN_2022_PROGRAM: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
26
+ /** Associated Token Account Program */
27
+ readonly ATA_PROGRAM: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
28
+ /** Metaplex Token Metadata Program */
29
+ readonly METADATA_PROGRAM: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
30
+ /** System Program */
31
+ readonly SYSTEM_PROGRAM: "11111111111111111111111111111111";
32
+ /** Rent Sysvar */
33
+ readonly RENT_SYSVAR: "SysvarRent111111111111111111111111111111111";
34
+ };
35
+ /**
36
+ * Pump.fun 程序地址
37
+ */
38
+ export declare const PUMP_PROGRAMS: {
39
+ /** Pump Program ID */
40
+ readonly PUMP_PROGRAM: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";
41
+ /** Pump Swap Program ID */
42
+ readonly PUMP_SWAP_PROGRAM: "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";
43
+ /** Global Config */
44
+ readonly GLOBAL_CONFIG: "4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf";
45
+ };
46
+ /**
47
+ * Raydium 程序地址
48
+ */
49
+ export declare const RAYDIUM_PROGRAMS: {
50
+ /** AMM Program ID */
51
+ readonly AMM_PROGRAM: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8";
52
+ /** CLMM Program ID */
53
+ readonly CLMM_PROGRAM: "CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK";
54
+ /** LaunchLab Program ID */
55
+ readonly LAUNCHLAB_PROGRAM: "LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj";
56
+ };
57
+ /**
58
+ * Orca 程序地址
59
+ */
60
+ export declare const ORCA_PROGRAMS: {
61
+ /** Whirlpool Program ID */
62
+ readonly WHIRLPOOL_PROGRAM: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc";
63
+ };
64
+ /**
65
+ * Meteora 程序地址
66
+ */
67
+ export declare const METEORA_PROGRAMS: {
68
+ /** DLMM Program ID */
69
+ readonly DLMM_PROGRAM: "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
70
+ /** DAMM v2 Program ID */
71
+ readonly DAMM_V2_PROGRAM: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
72
+ /** DBC Program ID */
73
+ readonly DBC_PROGRAM: "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN";
74
+ };
75
+ /**
76
+ * 常用代币地址
77
+ */
78
+ export declare const TOKENS: {
79
+ /** Wrapped SOL */
80
+ readonly SOL: "So11111111111111111111111111111111111111112";
81
+ /** USDC */
82
+ readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
83
+ /** USDT */
84
+ readonly USDT: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
85
+ };
86
+ /**
87
+ * 交易默认配置
88
+ */
89
+ export declare const TX_CONFIG: {
90
+ /** 默认滑点 1% */
91
+ readonly DEFAULT_SLIPPAGE: 1;
92
+ /** 最大滑点 50% */
93
+ readonly MAX_SLIPPAGE: 50;
94
+ /** 计算单元限制 */
95
+ readonly COMPUTE_UNIT_LIMIT: 200000;
96
+ /** 计算单元价格(microlamports) */
97
+ readonly COMPUTE_UNIT_PRICE: 50000;
98
+ /** 确认超时(毫秒) */
99
+ readonly CONFIRMATION_TIMEOUT: 60000;
100
+ /** 默认 commitment */
101
+ readonly DEFAULT_COMMITMENT: "confirmed";
102
+ };
103
+ /**
104
+ * 账户大小(用于计算租金)
105
+ */
106
+ export declare const ACCOUNT_SIZE: {
107
+ /** Mint 账户大小 */
108
+ readonly MINT: 82;
109
+ /** Token 账户大小 */
110
+ readonly TOKEN_ACCOUNT: 165;
111
+ /** Metadata 账户大小(近似值) */
112
+ readonly METADATA: 679;
113
+ };
114
+ /**
115
+ * SOL 单位换算
116
+ */
117
+ export declare const SOL_DECIMALS = 9;
118
+ export declare const LAMPORTS_PER_SOL = 1000000000;
119
+ /**
120
+ * 将 SOL 转换为 lamports
121
+ */
122
+ export declare function solToLamports(sol: number): bigint;
123
+ /**
124
+ * 将 lamports 转换为 SOL
125
+ */
126
+ export declare function lamportsToSol(lamports: bigint): number;
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Solana SDK 常量配置
3
+ * @module sol/constants
4
+ */
5
+ // ==================== Jito Bundle 配置 ====================
6
+ /**
7
+ * Jito 配置
8
+ *
9
+ * 注意:BLOCK_ENGINE_URL 需要由前端传入,不在 SDK 中写死
10
+ */
11
+ export const JITO_CONFIG = {
12
+ /** Tip 账户列表(随机选择一个)- 这些是 Jito 官方账户,固定不变 */
13
+ TIP_ACCOUNTS: [
14
+ '96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5',
15
+ 'HFqU5x63VTqvQss8hp11i4bVmkzdNaVB6PYjYgNd4W5U',
16
+ 'Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY',
17
+ 'ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49',
18
+ 'DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh',
19
+ 'ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt',
20
+ 'DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL',
21
+ '3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT',
22
+ ],
23
+ /** 最小 Tip(lamports) */
24
+ MIN_TIP_LAMPORTS: 1000,
25
+ /** 默认 Tip(lamports)- 0.00001 SOL */
26
+ DEFAULT_TIP_LAMPORTS: 10000,
27
+ };
28
+ // ==================== 程序地址 ====================
29
+ /**
30
+ * Solana 系统程序地址
31
+ */
32
+ export const SYSTEM_PROGRAMS = {
33
+ /** Token Program */
34
+ TOKEN_PROGRAM: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
35
+ /** Token-2022 Program */
36
+ TOKEN_2022_PROGRAM: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
37
+ /** Associated Token Account Program */
38
+ ATA_PROGRAM: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
39
+ /** Metaplex Token Metadata Program */
40
+ METADATA_PROGRAM: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
41
+ /** System Program */
42
+ SYSTEM_PROGRAM: '11111111111111111111111111111111',
43
+ /** Rent Sysvar */
44
+ RENT_SYSVAR: 'SysvarRent111111111111111111111111111111111',
45
+ };
46
+ /**
47
+ * Pump.fun 程序地址
48
+ */
49
+ export const PUMP_PROGRAMS = {
50
+ /** Pump Program ID */
51
+ PUMP_PROGRAM: '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P',
52
+ /** Pump Swap Program ID */
53
+ PUMP_SWAP_PROGRAM: 'pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA',
54
+ /** Global Config */
55
+ GLOBAL_CONFIG: '4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf',
56
+ };
57
+ /**
58
+ * Raydium 程序地址
59
+ */
60
+ export const RAYDIUM_PROGRAMS = {
61
+ /** AMM Program ID */
62
+ AMM_PROGRAM: '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8',
63
+ /** CLMM Program ID */
64
+ CLMM_PROGRAM: 'CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK',
65
+ /** LaunchLab Program ID */
66
+ LAUNCHLAB_PROGRAM: 'LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj',
67
+ };
68
+ /**
69
+ * Orca 程序地址
70
+ */
71
+ export const ORCA_PROGRAMS = {
72
+ /** Whirlpool Program ID */
73
+ WHIRLPOOL_PROGRAM: 'whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc',
74
+ };
75
+ /**
76
+ * Meteora 程序地址
77
+ */
78
+ export const METEORA_PROGRAMS = {
79
+ /** DLMM Program ID */
80
+ DLMM_PROGRAM: 'LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo',
81
+ /** DAMM v2 Program ID */
82
+ DAMM_V2_PROGRAM: 'cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG',
83
+ /** DBC Program ID */
84
+ DBC_PROGRAM: 'dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN',
85
+ };
86
+ // ==================== 常用代币地址 ====================
87
+ /**
88
+ * 常用代币地址
89
+ */
90
+ export const TOKENS = {
91
+ /** Wrapped SOL */
92
+ SOL: 'So11111111111111111111111111111111111111112',
93
+ /** USDC */
94
+ USDC: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
95
+ /** USDT */
96
+ USDT: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
97
+ };
98
+ // ==================== 交易配置 ====================
99
+ /**
100
+ * 交易默认配置
101
+ */
102
+ export const TX_CONFIG = {
103
+ /** 默认滑点 1% */
104
+ DEFAULT_SLIPPAGE: 1,
105
+ /** 最大滑点 50% */
106
+ MAX_SLIPPAGE: 50,
107
+ /** 计算单元限制 */
108
+ COMPUTE_UNIT_LIMIT: 200000,
109
+ /** 计算单元价格(microlamports) */
110
+ COMPUTE_UNIT_PRICE: 50000,
111
+ /** 确认超时(毫秒) */
112
+ CONFIRMATION_TIMEOUT: 60000,
113
+ /** 默认 commitment */
114
+ DEFAULT_COMMITMENT: 'confirmed',
115
+ };
116
+ // ==================== 账户大小 ====================
117
+ /**
118
+ * 账户大小(用于计算租金)
119
+ */
120
+ export const ACCOUNT_SIZE = {
121
+ /** Mint 账户大小 */
122
+ MINT: 82,
123
+ /** Token 账户大小 */
124
+ TOKEN_ACCOUNT: 165,
125
+ /** Metadata 账户大小(近似值) */
126
+ METADATA: 679,
127
+ };
128
+ // ==================== 单位换算 ====================
129
+ /**
130
+ * SOL 单位换算
131
+ */
132
+ export const SOL_DECIMALS = 9;
133
+ export const LAMPORTS_PER_SOL = 1000000000;
134
+ /**
135
+ * 将 SOL 转换为 lamports
136
+ */
137
+ export function solToLamports(sol) {
138
+ return BigInt(Math.floor(sol * LAMPORTS_PER_SOL));
139
+ }
140
+ /**
141
+ * 将 lamports 转换为 SOL
142
+ */
143
+ export function lamportsToSol(lamports) {
144
+ return Number(lamports) / LAMPORTS_PER_SOL;
145
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * BlockRazor 客户端配置管理
3
+ * @module sol/dex/blockrazor/client
4
+ */
5
+ import type { BlockRazorConfig, BlockRazorSendParams } from './types.js';
6
+ /**
7
+ * 设置默认 BlockRazor 配置
8
+ *
9
+ * @param config 配置
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { Sol } from 'four-flap-meme-sdk'
14
+ *
15
+ * Sol.setBlockRazorConfig({
16
+ * apiKey: 'your-auth-token',
17
+ * region: 'frankfurt',
18
+ * })
19
+ * ```
20
+ */
21
+ export declare function setBlockRazorConfig(config: BlockRazorConfig): void;
22
+ /**
23
+ * 获取 BlockRazor 配置
24
+ *
25
+ * @param config 可选配置(覆盖默认配置)
26
+ * @returns 配置对象
27
+ * @throws 未配置时抛出错误
28
+ */
29
+ export declare function getBlockRazorConfig(config?: BlockRazorConfig): BlockRazorConfig;
30
+ /**
31
+ * 获取端点 URL
32
+ *
33
+ * @param config 可选配置
34
+ * @returns 端点 URL
35
+ */
36
+ export declare function getBlockRazorEndpoint(config?: BlockRazorConfig): string;
37
+ /**
38
+ * 获取随机 BlockRazor Tip 账户
39
+ *
40
+ * 避免因地址占用导致的性能下降,建议轮换 Tip 账户。
41
+ *
42
+ * @returns 随机 Tip 账户地址
43
+ */
44
+ export declare function getRandomBlockRazorTipAccount(): string;
45
+ /**
46
+ * 验证发送交易参数
47
+ *
48
+ * @param params 发送参数
49
+ * @throws 参数无效时抛出错误
50
+ */
51
+ export declare function validateSendParams(params: BlockRazorSendParams): void;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * BlockRazor 客户端配置管理
3
+ * @module sol/dex/blockrazor/client
4
+ */
5
+ import { BLOCKRAZOR_ENDPOINTS, BLOCKRAZOR_TIP_ACCOUNTS } from './constants.js';
6
+ // ============================================================================
7
+ // 客户端管理
8
+ // ============================================================================
9
+ let defaultConfig = null;
10
+ /**
11
+ * 设置默认 BlockRazor 配置
12
+ *
13
+ * @param config 配置
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { Sol } from 'four-flap-meme-sdk'
18
+ *
19
+ * Sol.setBlockRazorConfig({
20
+ * apiKey: 'your-auth-token',
21
+ * region: 'frankfurt',
22
+ * })
23
+ * ```
24
+ */
25
+ export function setBlockRazorConfig(config) {
26
+ defaultConfig = config;
27
+ }
28
+ /**
29
+ * 获取 BlockRazor 配置
30
+ *
31
+ * @param config 可选配置(覆盖默认配置)
32
+ * @returns 配置对象
33
+ * @throws 未配置时抛出错误
34
+ */
35
+ export function getBlockRazorConfig(config) {
36
+ const cfg = config || defaultConfig;
37
+ if (!cfg) {
38
+ throw new Error('BlockRazor not configured. Call setBlockRazorConfig() first or pass config.');
39
+ }
40
+ return cfg;
41
+ }
42
+ /**
43
+ * 获取端点 URL
44
+ *
45
+ * @param config 可选配置
46
+ * @returns 端点 URL
47
+ */
48
+ export function getBlockRazorEndpoint(config) {
49
+ const cfg = getBlockRazorConfig(config);
50
+ if (cfg.endpoint) {
51
+ return cfg.endpoint;
52
+ }
53
+ const region = cfg.region || 'frankfurt';
54
+ switch (region) {
55
+ case 'frankfurt':
56
+ return BLOCKRAZOR_ENDPOINTS.FRANKFURT;
57
+ case 'newyork':
58
+ return BLOCKRAZOR_ENDPOINTS.NEW_YORK;
59
+ case 'tokyo':
60
+ return BLOCKRAZOR_ENDPOINTS.TOKYO;
61
+ case 'amsterdam':
62
+ return BLOCKRAZOR_ENDPOINTS.AMSTERDAM;
63
+ default:
64
+ return BLOCKRAZOR_ENDPOINTS.FRANKFURT;
65
+ }
66
+ }
67
+ /**
68
+ * 获取随机 BlockRazor Tip 账户
69
+ *
70
+ * 避免因地址占用导致的性能下降,建议轮换 Tip 账户。
71
+ *
72
+ * @returns 随机 Tip 账户地址
73
+ */
74
+ export function getRandomBlockRazorTipAccount() {
75
+ const index = Math.floor(Math.random() * BLOCKRAZOR_TIP_ACCOUNTS.length);
76
+ return BLOCKRAZOR_TIP_ACCOUNTS[index];
77
+ }
78
+ /**
79
+ * 验证发送交易参数
80
+ *
81
+ * @param params 发送参数
82
+ * @throws 参数无效时抛出错误
83
+ */
84
+ export function validateSendParams(params) {
85
+ if (!params.transaction) {
86
+ throw new Error('transaction is required');
87
+ }
88
+ if (params.mode && !['fast', 'sandwichMitigation'].includes(params.mode)) {
89
+ throw new Error('mode must be "fast" or "sandwichMitigation"');
90
+ }
91
+ if (params.safeWindow !== undefined) {
92
+ if (params.safeWindow < 3 || params.safeWindow > 13) {
93
+ throw new Error('safeWindow must be between 3 and 13');
94
+ }
95
+ }
96
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * BlockRazor 常量
3
+ * @module sol/dex/blockrazor/constants
4
+ */
5
+ /** BlockRazor 区域端点 */
6
+ export declare const BLOCKRAZOR_ENDPOINTS: {
7
+ /** 法兰克福 */
8
+ readonly FRANKFURT: "http://frankfurt.solana.blockrazor.xyz:443";
9
+ /** 纽约 */
10
+ readonly NEW_YORK: "http://newyork.solana.blockrazor.xyz:443";
11
+ /** 东京 */
12
+ readonly TOKYO: "http://tokyo.solana.blockrazor.xyz:443";
13
+ /** 阿姆斯特丹 */
14
+ readonly AMSTERDAM: "http://amsterdam.solana.blockrazor.xyz:443";
15
+ };
16
+ /** BlockRazor Tip 账户列表 */
17
+ export declare const BLOCKRAZOR_TIP_ACCOUNTS: readonly ["Gywj98ophM7GmkDdaWs4isqZnDdFCW7B46TXmKfvyqSm", "FjmZZrFvhnqqb9ThCuMVnENaM3JGVuGWNyCAxRJcFpg9", "6No2i3aawzHsjtThw81iq1EXPJN6rh8eSJCLaYZfKDTG", "A9cWowVAiHe9pJfKAj3TJiN9VpbzMUq6E4kEvf5mUT22", "68Pwb4jS7eZATjDfhmTXgRJjCiZmw1L7Huy4HNpnxJ3o", "4ABhJh5rZPjv63RBJBuyWzBK3g9gWMUQdTZP2kiW31V9", "B2M4NG5eyZp5SBQrSdtemzk5TqVuaWGQnowGaCBt8GyM", "5jA59cXMKQqZAVdtopv8q3yyw9SYfiE3vUCbt7p8MfVf", "5YktoWygr1Bp9wiS1xtMtUki1PeYuuzuCF98tqwYxf61", "295Avbam4qGShBYK7E9H5Ldew4B3WyJGmgmXfiWdeeyV", "EDi4rSy2LZgKJX74mbLTFk4mxoTgT6F7HxxzG2HBAFyK", "BnGKHAC386n4Qmv9xtpBVbRaUTKixjBe3oagkPFKtoy6", "Dd7K2Fp7AtoN8xCghKDRmyqr5U169t48Tw5fEd3wT9mq", "AP6qExwrbRgBAVaehg4b5xHENX815sMabtBzUzVB4v8S"];
18
+ /** 默认 Tip 金额 (lamports) */
19
+ export declare const DEFAULT_TIP_AMOUNT = 1000000;
20
+ /** 最小 Tip 金额 (lamports) */
21
+ export declare const MIN_TIP_AMOUNT = 1000000;
22
+ /** 默认请求超时 (ms) */
23
+ export declare const BLOCKRAZOR_DEFAULT_TIMEOUT = 10000;
24
+ /** Geyser Stream 端点 */
25
+ export declare const GEYSER_STREAM_ENDPOINTS: {
26
+ /** 东京 */
27
+ readonly TOKYO: "geyserstream-tokyo.blockrazor.xyz:443";
28
+ /** 法兰克福 */
29
+ readonly FRANKFURT: "geyserstream-frankfurt.blockrazor.xyz:443";
30
+ /** 纽约 */
31
+ readonly NEW_YORK: "geyserstream-newyork.blockrazor.xyz:443";
32
+ /** 阿姆斯特丹 */
33
+ readonly AMSTERDAM: "geyserstream-amsterdam.blockrazor.xyz:443";
34
+ };