four-flap-meme-sdk 1.5.4 → 1.5.6

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 (158) hide show
  1. package/dist/abis/common.js +0 -2
  2. package/dist/contracts/tm-bundle-merkle/config.d.ts +1 -0
  3. package/dist/contracts/tm-bundle-merkle/config.js +1 -0
  4. package/dist/contracts/tm-bundle-merkle/core.js +9 -13
  5. package/dist/flap/portal-bundle-merkle/config.d.ts +1 -0
  6. package/dist/flap/portal-bundle-merkle/config.js +1 -0
  7. package/dist/flap/portal-bundle-merkle/create-to-dex.d.ts +2 -8
  8. package/dist/flap/portal-bundle-merkle/create-to-dex.js +126 -154
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +1 -1
  11. package/dist/sol/constants.d.ts +150 -0
  12. package/dist/sol/constants.js +188 -0
  13. package/dist/sol/dex/blockrazor/client.d.ts +51 -0
  14. package/dist/sol/dex/blockrazor/client.js +96 -0
  15. package/dist/sol/dex/blockrazor/constants.d.ts +34 -0
  16. package/dist/sol/dex/blockrazor/constants.js +55 -0
  17. package/dist/sol/dex/blockrazor/geyser.d.ts +128 -0
  18. package/dist/sol/dex/blockrazor/geyser.js +530 -0
  19. package/dist/sol/dex/blockrazor/index.d.ts +18 -0
  20. package/dist/sol/dex/blockrazor/index.js +23 -0
  21. package/dist/sol/dex/blockrazor/send.d.ts +135 -0
  22. package/dist/sol/dex/blockrazor/send.js +254 -0
  23. package/dist/sol/dex/blockrazor/types.d.ts +191 -0
  24. package/dist/sol/dex/blockrazor/types.js +5 -0
  25. package/dist/sol/dex/index.d.ts +10 -0
  26. package/dist/sol/dex/index.js +16 -0
  27. package/dist/sol/dex/jup/client.d.ts +33 -0
  28. package/dist/sol/dex/jup/client.js +110 -0
  29. package/dist/sol/dex/jup/index.d.ts +16 -0
  30. package/dist/sol/dex/jup/index.js +148 -0
  31. package/dist/sol/dex/jup/legacy.d.ts +623 -0
  32. package/dist/sol/dex/jup/legacy.js +416 -0
  33. package/dist/sol/dex/jup/lend.d.ts +640 -0
  34. package/dist/sol/dex/jup/lend.js +603 -0
  35. package/dist/sol/dex/jup/portfolio.d.ts +362 -0
  36. package/dist/sol/dex/jup/portfolio.js +367 -0
  37. package/dist/sol/dex/jup/price.d.ts +173 -0
  38. package/dist/sol/dex/jup/price.js +220 -0
  39. package/dist/sol/dex/jup/recurring.d.ts +437 -0
  40. package/dist/sol/dex/jup/recurring.js +320 -0
  41. package/dist/sol/dex/jup/send.d.ts +282 -0
  42. package/dist/sol/dex/jup/send.js +295 -0
  43. package/dist/sol/dex/jup/studio.d.ts +457 -0
  44. package/dist/sol/dex/jup/studio.js +488 -0
  45. package/dist/sol/dex/jup/tokens.d.ts +767 -0
  46. package/dist/sol/dex/jup/tokens.js +697 -0
  47. package/dist/sol/dex/jup/trigger.d.ts +511 -0
  48. package/dist/sol/dex/jup/trigger.js +397 -0
  49. package/dist/sol/dex/jup/types.d.ts +433 -0
  50. package/dist/sol/dex/jup/types.js +5 -0
  51. package/dist/sol/dex/jup/ultra.d.ts +646 -0
  52. package/dist/sol/dex/jup/ultra.js +853 -0
  53. package/dist/sol/dex/meteora/client.d.ts +76 -0
  54. package/dist/sol/dex/meteora/client.js +219 -0
  55. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +61 -0
  56. package/dist/sol/dex/meteora/damm-v1-bundle.js +112 -0
  57. package/dist/sol/dex/meteora/damm-v1.d.ts +118 -0
  58. package/dist/sol/dex/meteora/damm-v1.js +315 -0
  59. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +82 -0
  60. package/dist/sol/dex/meteora/damm-v2-bundle.js +242 -0
  61. package/dist/sol/dex/meteora/damm-v2.d.ts +172 -0
  62. package/dist/sol/dex/meteora/damm-v2.js +632 -0
  63. package/dist/sol/dex/meteora/dbc-bundle.d.ts +123 -0
  64. package/dist/sol/dex/meteora/dbc-bundle.js +304 -0
  65. package/dist/sol/dex/meteora/dbc.d.ts +192 -0
  66. package/dist/sol/dex/meteora/dbc.js +619 -0
  67. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +39 -0
  68. package/dist/sol/dex/meteora/dlmm-bundle.js +189 -0
  69. package/dist/sol/dex/meteora/dlmm.d.ts +157 -0
  70. package/dist/sol/dex/meteora/dlmm.js +671 -0
  71. package/dist/sol/dex/meteora/index.d.ts +25 -0
  72. package/dist/sol/dex/meteora/index.js +65 -0
  73. package/dist/sol/dex/meteora/types.d.ts +787 -0
  74. package/dist/sol/dex/meteora/types.js +110 -0
  75. package/dist/sol/dex/orca/index.d.ts +10 -0
  76. package/dist/sol/dex/orca/index.js +16 -0
  77. package/dist/sol/dex/orca/orca-bundle.d.ts +41 -0
  78. package/dist/sol/dex/orca/orca-bundle.js +173 -0
  79. package/dist/sol/dex/orca/orca.d.ts +65 -0
  80. package/dist/sol/dex/orca/orca.js +474 -0
  81. package/dist/sol/dex/orca/types.d.ts +263 -0
  82. package/dist/sol/dex/orca/types.js +38 -0
  83. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +34 -0
  84. package/dist/sol/dex/orca/wavebreak-bundle.js +198 -0
  85. package/dist/sol/dex/orca/wavebreak-types.d.ts +227 -0
  86. package/dist/sol/dex/orca/wavebreak-types.js +23 -0
  87. package/dist/sol/dex/orca/wavebreak.d.ts +78 -0
  88. package/dist/sol/dex/orca/wavebreak.js +497 -0
  89. package/dist/sol/dex/pump/index.d.ts +9 -0
  90. package/dist/sol/dex/pump/index.js +14 -0
  91. package/dist/sol/dex/pump/pump-bundle.d.ts +92 -0
  92. package/dist/sol/dex/pump/pump-bundle.js +383 -0
  93. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +103 -0
  94. package/dist/sol/dex/pump/pump-swap-bundle.js +380 -0
  95. package/dist/sol/dex/pump/pump-swap.d.ts +46 -0
  96. package/dist/sol/dex/pump/pump-swap.js +199 -0
  97. package/dist/sol/dex/pump/pump.d.ts +35 -0
  98. package/dist/sol/dex/pump/pump.js +352 -0
  99. package/dist/sol/dex/pump/types.d.ts +215 -0
  100. package/dist/sol/dex/pump/types.js +5 -0
  101. package/dist/sol/dex/raydium/index.d.ts +8 -0
  102. package/dist/sol/dex/raydium/index.js +12 -0
  103. package/dist/sol/dex/raydium/launchlab.d.ts +68 -0
  104. package/dist/sol/dex/raydium/launchlab.js +210 -0
  105. package/dist/sol/dex/raydium/raydium-bundle.d.ts +64 -0
  106. package/dist/sol/dex/raydium/raydium-bundle.js +324 -0
  107. package/dist/sol/dex/raydium/raydium.d.ts +40 -0
  108. package/dist/sol/dex/raydium/raydium.js +366 -0
  109. package/dist/sol/dex/raydium/types.d.ts +240 -0
  110. package/dist/sol/dex/raydium/types.js +5 -0
  111. package/dist/sol/index.d.ts +11 -0
  112. package/dist/sol/index.js +18 -0
  113. package/dist/sol/jito/bundle.d.ts +90 -0
  114. package/dist/sol/jito/bundle.js +263 -0
  115. package/dist/sol/jito/index.d.ts +7 -0
  116. package/dist/sol/jito/index.js +7 -0
  117. package/dist/sol/jito/tip.d.ts +51 -0
  118. package/dist/sol/jito/tip.js +83 -0
  119. package/dist/sol/jito/types.d.ts +100 -0
  120. package/dist/sol/jito/types.js +5 -0
  121. package/dist/sol/nozomi/client.d.ts +63 -0
  122. package/dist/sol/nozomi/client.js +222 -0
  123. package/dist/sol/nozomi/index.d.ts +8 -0
  124. package/dist/sol/nozomi/index.js +8 -0
  125. package/dist/sol/nozomi/tip.d.ts +50 -0
  126. package/dist/sol/nozomi/tip.js +80 -0
  127. package/dist/sol/nozomi/types.d.ts +96 -0
  128. package/dist/sol/nozomi/types.js +5 -0
  129. package/dist/sol/token/create-complete.d.ts +115 -0
  130. package/dist/sol/token/create-complete.js +235 -0
  131. package/dist/sol/token/create-token.d.ts +57 -0
  132. package/dist/sol/token/create-token.js +230 -0
  133. package/dist/sol/token/index.d.ts +9 -0
  134. package/dist/sol/token/index.js +14 -0
  135. package/dist/sol/token/metadata-upload.d.ts +86 -0
  136. package/dist/sol/token/metadata-upload.js +173 -0
  137. package/dist/sol/token/metadata.d.ts +92 -0
  138. package/dist/sol/token/metadata.js +274 -0
  139. package/dist/sol/token/types.d.ts +153 -0
  140. package/dist/sol/token/types.js +5 -0
  141. package/dist/sol/types.d.ts +176 -0
  142. package/dist/sol/types.js +7 -0
  143. package/dist/sol/utils/balance.d.ts +160 -0
  144. package/dist/sol/utils/balance.js +638 -0
  145. package/dist/sol/utils/connection.d.ts +78 -0
  146. package/dist/sol/utils/connection.js +168 -0
  147. package/dist/sol/utils/index.d.ts +9 -0
  148. package/dist/sol/utils/index.js +9 -0
  149. package/dist/sol/utils/lp-inspect.d.ts +129 -0
  150. package/dist/sol/utils/lp-inspect.js +900 -0
  151. package/dist/sol/utils/transfer.d.ts +196 -0
  152. package/dist/sol/utils/transfer.js +307 -0
  153. package/dist/sol/utils/wallet.d.ts +107 -0
  154. package/dist/sol/utils/wallet.js +210 -0
  155. package/package.json +41 -5
  156. package/README.zh-CN.pdf +0 -0
  157. package/dist/flap/portal-bundle-merkle/encryption.d.ts +0 -16
  158. package/dist/flap/portal-bundle-merkle/encryption.js +0 -146
@@ -0,0 +1,23 @@
1
+ /**
2
+ * BlockRazor Solana Service
3
+ * @module sol/dex/blockrazor
4
+ *
5
+ * BlockRazor 提供 Solana 服务:
6
+ * - 高性能交易落地 (Transaction Landing)
7
+ * - 三明治攻击缓解模式 (Sandwich Mitigation)
8
+ * - Revert 保护
9
+ * - Geyser Stream (gRPC 实时数据流)
10
+ *
11
+ * @see https://blockrazor.gitbook.io/blockrazor/solana/send-transaction
12
+ * @see https://blockrazor.gitbook.io/blockrazor/solana/geyser-stream
13
+ */
14
+ // 类型导出
15
+ export * from './types.js';
16
+ // 常量导出
17
+ export * from './constants.js';
18
+ // 客户端管理
19
+ export { setBlockRazorConfig, getBlockRazorConfig, getBlockRazorEndpoint, getRandomBlockRazorTipAccount, validateSendParams, } from './client.js';
20
+ // Send Transaction
21
+ export { blockRazorSendTransaction, blockRazorSendTransactionV2, blockRazorHealth, blockRazorHealthV2, blockRazorFastSend, blockRazorSafeSend, blockRazorSendWithRevertProtection, startBlockRazorKeepAlive, } from './send.js';
22
+ // Geyser Stream
23
+ export { GEYSER_PROTO_DEFINITION, getGeyserEndpoint, buildGeyserSubscribeRequest, createAccountSubscribeConfig, createTransactionSubscribeConfig, createBlockSubscribeConfig, createGeyserSubscription, subscribeGeyserAccounts, subscribeGeyserTransactions, subscribeGeyserBlocks, } from './geyser.js';
@@ -0,0 +1,135 @@
1
+ /**
2
+ * BlockRazor 交易发送服务
3
+ * @module sol/dex/blockrazor/send
4
+ *
5
+ * @see https://blockrazor.gitbook.io/blockrazor/solana/send-transaction
6
+ */
7
+ import type { BlockRazorConfig, BlockRazorMode, BlockRazorSendParams, BlockRazorSendResponse, BlockRazorHealthResponse } from './types.js';
8
+ /**
9
+ * 发送交易 (V1 - HTTP JSON)
10
+ *
11
+ * @param params 发送参数
12
+ * @param config BlockRazor 配置
13
+ * @returns 发送响应
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { Sol } from 'four-flap-meme-sdk'
18
+ *
19
+ * Sol.setBlockRazorConfig({ apiKey: 'your-auth-token' })
20
+ *
21
+ * // 快速模式发送
22
+ * const result = await Sol.blockRazorSendTransaction({
23
+ * transaction: base64SignedTx,
24
+ * mode: 'fast',
25
+ * })
26
+ *
27
+ * console.log(`签名: ${result.signature}`)
28
+ *
29
+ * // 三明治缓解模式
30
+ * const result2 = await Sol.blockRazorSendTransaction({
31
+ * transaction: base64SignedTx,
32
+ * mode: 'sandwichMitigation',
33
+ * safeWindow: 5,
34
+ * })
35
+ * ```
36
+ */
37
+ export declare function blockRazorSendTransaction(params: BlockRazorSendParams, config?: BlockRazorConfig): Promise<BlockRazorSendResponse>;
38
+ /**
39
+ * 发送交易 V2 (更快的 HTTP Plain Text)
40
+ *
41
+ * V2 优势:
42
+ * - 绕过 CORS Preflight (节省 50-100ms)
43
+ * - 使用 Plain Text 而非 JSON
44
+ * - Base64 编码更快
45
+ *
46
+ * @param transaction Base64 编码的已签名交易
47
+ * @param options 可选参数
48
+ * @param config BlockRazor 配置
49
+ * @returns 交易签名
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // 快速发送
54
+ * const signature = await Sol.blockRazorSendTransactionV2(base64Tx)
55
+ *
56
+ * // 带参数发送
57
+ * const signature = await Sol.blockRazorSendTransactionV2(
58
+ * base64Tx,
59
+ * {
60
+ * mode: 'sandwichMitigation',
61
+ * safeWindow: 5,
62
+ * revertProtection: true,
63
+ * },
64
+ * )
65
+ * ```
66
+ */
67
+ export declare function blockRazorSendTransactionV2(transaction: string, options?: {
68
+ mode?: BlockRazorMode;
69
+ safeWindow?: number;
70
+ revertProtection?: boolean;
71
+ }, config?: BlockRazorConfig): Promise<string>;
72
+ /**
73
+ * 健康检查 (V1)
74
+ *
75
+ * 用于保持连接活跃。
76
+ *
77
+ * @param config BlockRazor 配置
78
+ * @returns 健康状态
79
+ */
80
+ export declare function blockRazorHealth(config?: BlockRazorConfig): Promise<BlockRazorHealthResponse>;
81
+ /**
82
+ * 健康检查 V2
83
+ *
84
+ * @param config BlockRazor 配置
85
+ * @returns 是否健康
86
+ */
87
+ export declare function blockRazorHealthV2(config?: BlockRazorConfig): Promise<boolean>;
88
+ /**
89
+ * 快速发送交易
90
+ *
91
+ * 使用 V2 + fast 模式发送。
92
+ *
93
+ * @param transaction Base64 编码的已签名交易
94
+ * @param config BlockRazor 配置
95
+ * @returns 交易签名
96
+ */
97
+ export declare function blockRazorFastSend(transaction: string, config?: BlockRazorConfig): Promise<string>;
98
+ /**
99
+ * 安全发送交易(三明治缓解)
100
+ *
101
+ * 使用 V2 + sandwichMitigation 模式发送。
102
+ *
103
+ * @param transaction Base64 编码的已签名交易
104
+ * @param safeWindow 安全窗口(默认 5)
105
+ * @param config BlockRazor 配置
106
+ * @returns 交易签名
107
+ */
108
+ export declare function blockRazorSafeSend(transaction: string, safeWindow?: number, config?: BlockRazorConfig): Promise<string>;
109
+ /**
110
+ * 发送交易带 Revert 保护
111
+ *
112
+ * @param transaction Base64 编码的已签名交易
113
+ * @param config BlockRazor 配置
114
+ * @returns 交易签名
115
+ */
116
+ export declare function blockRazorSendWithRevertProtection(transaction: string, config?: BlockRazorConfig): Promise<string>;
117
+ /**
118
+ * 启动 Keep-Alive 定时器
119
+ *
120
+ * 定期发送健康检查以保持连接活跃。
121
+ *
122
+ * @param intervalMs 间隔时间(毫秒,默认 30000)
123
+ * @param config BlockRazor 配置
124
+ * @returns 定时器 ID(用于停止)
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * // 启动 keep-alive
129
+ * const timerId = Sol.startBlockRazorKeepAlive(30000)
130
+ *
131
+ * // 停止
132
+ * clearInterval(timerId)
133
+ * ```
134
+ */
135
+ export declare function startBlockRazorKeepAlive(intervalMs?: number, config?: BlockRazorConfig): ReturnType<typeof setInterval>;
@@ -0,0 +1,254 @@
1
+ /**
2
+ * BlockRazor 交易发送服务
3
+ * @module sol/dex/blockrazor/send
4
+ *
5
+ * @see https://blockrazor.gitbook.io/blockrazor/solana/send-transaction
6
+ */
7
+ import { BLOCKRAZOR_DEFAULT_TIMEOUT } from './constants.js';
8
+ import { getBlockRazorConfig, getBlockRazorEndpoint } from './client.js';
9
+ // ============================================================================
10
+ // Send Transaction V1 (HTTP JSON)
11
+ // ============================================================================
12
+ /**
13
+ * 发送交易 (V1 - HTTP JSON)
14
+ *
15
+ * @param params 发送参数
16
+ * @param config BlockRazor 配置
17
+ * @returns 发送响应
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import { Sol } from 'four-flap-meme-sdk'
22
+ *
23
+ * Sol.setBlockRazorConfig({ apiKey: 'your-auth-token' })
24
+ *
25
+ * // 快速模式发送
26
+ * const result = await Sol.blockRazorSendTransaction({
27
+ * transaction: base64SignedTx,
28
+ * mode: 'fast',
29
+ * })
30
+ *
31
+ * console.log(`签名: ${result.signature}`)
32
+ *
33
+ * // 三明治缓解模式
34
+ * const result2 = await Sol.blockRazorSendTransaction({
35
+ * transaction: base64SignedTx,
36
+ * mode: 'sandwichMitigation',
37
+ * safeWindow: 5,
38
+ * })
39
+ * ```
40
+ */
41
+ export async function blockRazorSendTransaction(params, config) {
42
+ const cfg = getBlockRazorConfig(config);
43
+ const endpoint = getBlockRazorEndpoint(cfg);
44
+ const timeout = cfg.timeout || BLOCKRAZOR_DEFAULT_TIMEOUT;
45
+ const url = `${endpoint}/sendTransaction`;
46
+ const body = {
47
+ transaction: params.transaction,
48
+ mode: params.mode || 'fast',
49
+ };
50
+ if (params.safeWindow !== undefined) {
51
+ body.safeWindow = params.safeWindow;
52
+ }
53
+ if (params.revertProtection !== undefined) {
54
+ body.revertProtection = params.revertProtection;
55
+ }
56
+ const controller = new AbortController();
57
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
58
+ try {
59
+ const response = await fetch(url, {
60
+ method: 'POST',
61
+ headers: {
62
+ 'Content-Type': 'application/json',
63
+ 'apikey': cfg.apiKey,
64
+ },
65
+ body: JSON.stringify(body),
66
+ signal: controller.signal,
67
+ });
68
+ const data = await response.json();
69
+ if (data.error) {
70
+ throw new Error(`BlockRazor error: ${data.error}`);
71
+ }
72
+ return data;
73
+ }
74
+ finally {
75
+ clearTimeout(timeoutId);
76
+ }
77
+ }
78
+ // ============================================================================
79
+ // Send Transaction V2 (HTTP Plain Text - Faster)
80
+ // ============================================================================
81
+ /**
82
+ * 发送交易 V2 (更快的 HTTP Plain Text)
83
+ *
84
+ * V2 优势:
85
+ * - 绕过 CORS Preflight (节省 50-100ms)
86
+ * - 使用 Plain Text 而非 JSON
87
+ * - Base64 编码更快
88
+ *
89
+ * @param transaction Base64 编码的已签名交易
90
+ * @param options 可选参数
91
+ * @param config BlockRazor 配置
92
+ * @returns 交易签名
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * // 快速发送
97
+ * const signature = await Sol.blockRazorSendTransactionV2(base64Tx)
98
+ *
99
+ * // 带参数发送
100
+ * const signature = await Sol.blockRazorSendTransactionV2(
101
+ * base64Tx,
102
+ * {
103
+ * mode: 'sandwichMitigation',
104
+ * safeWindow: 5,
105
+ * revertProtection: true,
106
+ * },
107
+ * )
108
+ * ```
109
+ */
110
+ export async function blockRazorSendTransactionV2(transaction, options, config) {
111
+ const cfg = getBlockRazorConfig(config);
112
+ const endpoint = getBlockRazorEndpoint(cfg);
113
+ const timeout = cfg.timeout || BLOCKRAZOR_DEFAULT_TIMEOUT;
114
+ // 构建 URL 参数
115
+ const params = new URLSearchParams();
116
+ params.append('auth', cfg.apiKey);
117
+ if (options?.mode) {
118
+ params.append('mode', options.mode);
119
+ }
120
+ if (options?.safeWindow !== undefined) {
121
+ params.append('safeWindow', options.safeWindow.toString());
122
+ }
123
+ if (options?.revertProtection !== undefined) {
124
+ params.append('revertProtection', options.revertProtection.toString());
125
+ }
126
+ const url = `${endpoint}/v2/sendTransaction?${params.toString()}`;
127
+ const controller = new AbortController();
128
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
129
+ try {
130
+ const response = await fetch(url, {
131
+ method: 'POST',
132
+ headers: {
133
+ 'Content-Type': 'text/plain',
134
+ },
135
+ body: transaction,
136
+ signal: controller.signal,
137
+ });
138
+ if (!response.ok) {
139
+ const errorText = await response.text();
140
+ throw new Error(`BlockRazor V2 error (${response.status}): ${errorText}`);
141
+ }
142
+ // V2 响应直接返回签名
143
+ return await response.text();
144
+ }
145
+ finally {
146
+ clearTimeout(timeoutId);
147
+ }
148
+ }
149
+ // ============================================================================
150
+ // Health Check
151
+ // ============================================================================
152
+ /**
153
+ * 健康检查 (V1)
154
+ *
155
+ * 用于保持连接活跃。
156
+ *
157
+ * @param config BlockRazor 配置
158
+ * @returns 健康状态
159
+ */
160
+ export async function blockRazorHealth(config) {
161
+ const cfg = getBlockRazorConfig(config);
162
+ const endpoint = getBlockRazorEndpoint(cfg);
163
+ const response = await fetch(`${endpoint}/health`, {
164
+ method: 'GET',
165
+ headers: {
166
+ 'apikey': cfg.apiKey,
167
+ },
168
+ });
169
+ return await response.json();
170
+ }
171
+ /**
172
+ * 健康检查 V2
173
+ *
174
+ * @param config BlockRazor 配置
175
+ * @returns 是否健康
176
+ */
177
+ export async function blockRazorHealthV2(config) {
178
+ const cfg = getBlockRazorConfig(config);
179
+ const endpoint = getBlockRazorEndpoint(cfg);
180
+ const params = new URLSearchParams();
181
+ params.append('auth', cfg.apiKey);
182
+ const response = await fetch(`${endpoint}/v2/health?${params.toString()}`, {
183
+ method: 'POST',
184
+ headers: {
185
+ 'Content-Type': 'text/plain',
186
+ },
187
+ body: '',
188
+ });
189
+ return response.ok;
190
+ }
191
+ // ============================================================================
192
+ // 便捷方法
193
+ // ============================================================================
194
+ /**
195
+ * 快速发送交易
196
+ *
197
+ * 使用 V2 + fast 模式发送。
198
+ *
199
+ * @param transaction Base64 编码的已签名交易
200
+ * @param config BlockRazor 配置
201
+ * @returns 交易签名
202
+ */
203
+ export async function blockRazorFastSend(transaction, config) {
204
+ return blockRazorSendTransactionV2(transaction, { mode: 'fast' }, config);
205
+ }
206
+ /**
207
+ * 安全发送交易(三明治缓解)
208
+ *
209
+ * 使用 V2 + sandwichMitigation 模式发送。
210
+ *
211
+ * @param transaction Base64 编码的已签名交易
212
+ * @param safeWindow 安全窗口(默认 5)
213
+ * @param config BlockRazor 配置
214
+ * @returns 交易签名
215
+ */
216
+ export async function blockRazorSafeSend(transaction, safeWindow = 5, config) {
217
+ return blockRazorSendTransactionV2(transaction, { mode: 'sandwichMitigation', safeWindow }, config);
218
+ }
219
+ /**
220
+ * 发送交易带 Revert 保护
221
+ *
222
+ * @param transaction Base64 编码的已签名交易
223
+ * @param config BlockRazor 配置
224
+ * @returns 交易签名
225
+ */
226
+ export async function blockRazorSendWithRevertProtection(transaction, config) {
227
+ return blockRazorSendTransactionV2(transaction, { mode: 'fast', revertProtection: true }, config);
228
+ }
229
+ /**
230
+ * 启动 Keep-Alive 定时器
231
+ *
232
+ * 定期发送健康检查以保持连接活跃。
233
+ *
234
+ * @param intervalMs 间隔时间(毫秒,默认 30000)
235
+ * @param config BlockRazor 配置
236
+ * @returns 定时器 ID(用于停止)
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * // 启动 keep-alive
241
+ * const timerId = Sol.startBlockRazorKeepAlive(30000)
242
+ *
243
+ * // 停止
244
+ * clearInterval(timerId)
245
+ * ```
246
+ */
247
+ export function startBlockRazorKeepAlive(intervalMs = 30000, config) {
248
+ // 立即执行一次
249
+ blockRazorHealthV2(config).catch(console.error);
250
+ // 定时执行
251
+ return setInterval(() => {
252
+ blockRazorHealthV2(config).catch(console.error);
253
+ }, intervalMs);
254
+ }
@@ -0,0 +1,191 @@
1
+ /**
2
+ * BlockRazor 类型定义
3
+ * @module sol/dex/blockrazor/types
4
+ */
5
+ /** 区域类型 */
6
+ export type BlockRazorRegion = 'frankfurt' | 'newyork' | 'tokyo' | 'amsterdam';
7
+ /** 发送模式 */
8
+ export type BlockRazorMode = 'fast' | 'sandwichMitigation';
9
+ /** BlockRazor 配置 */
10
+ export interface BlockRazorConfig {
11
+ /** API Key (auth token) */
12
+ apiKey: string;
13
+ /** 区域(默认: frankfurt) */
14
+ region?: BlockRazorRegion;
15
+ /** 自定义端点 URL */
16
+ endpoint?: string;
17
+ /** 请求超时 (ms,默认: 10000) */
18
+ timeout?: number;
19
+ }
20
+ /** 发送交易参数 */
21
+ export interface BlockRazorSendParams {
22
+ /** Base64 编码的已签名交易 */
23
+ transaction: string;
24
+ /**
25
+ * 发送模式
26
+ * - fast: 最快落地模式(默认)
27
+ * - sandwichMitigation: 三明治攻击缓解模式
28
+ */
29
+ mode?: BlockRazorMode;
30
+ /**
31
+ * 安全窗口(仅 sandwichMitigation 模式生效)
32
+ * 范围: 3-13,默认: 3
33
+ * 值越大防护效果越好,但可能影响落地率
34
+ */
35
+ safeWindow?: number;
36
+ /**
37
+ * Revert 保护
38
+ * 设为 true 时交易不会在链上失败,但会影响落地速度
39
+ */
40
+ revertProtection?: boolean;
41
+ }
42
+ /** 发送交易响应 */
43
+ export interface BlockRazorSendResponse {
44
+ /** 交易签名 */
45
+ signature: string;
46
+ /** 错误信息(如有) */
47
+ error?: string;
48
+ }
49
+ /** 健康检查响应 */
50
+ export interface BlockRazorHealthResponse {
51
+ /** 状态 */
52
+ status: string;
53
+ }
54
+ /** Commitment 级别 */
55
+ export type GeyserCommitment = 'PROCESSED' | 'CONFIRMED' | 'FINALIZED';
56
+ /** Geyser Stream 区域 */
57
+ export type GeyserRegion = 'tokyo' | 'frankfurt' | 'newyork' | 'amsterdam';
58
+ /** Geyser 过滤器 */
59
+ export interface GeyserFilter {
60
+ /** memcmp 过滤器 */
61
+ memcmp?: {
62
+ offset: number;
63
+ bytes: string;
64
+ };
65
+ /** dataSize 过滤器 */
66
+ dataSize?: number;
67
+ }
68
+ /** 账户订阅参数 */
69
+ export interface GeyserAccountParams {
70
+ /** 过滤器 Key */
71
+ filterKey: string;
72
+ /** 拥有者地址列表 */
73
+ owners?: string[];
74
+ /** 特定账户地址列表 */
75
+ accounts?: string[];
76
+ /** 额外过滤器(如 memcmp, datasize) */
77
+ filters?: GeyserFilter[];
78
+ /** 是否只包含有交易签名的更新 */
79
+ nonemptyTxnSignature?: boolean;
80
+ }
81
+ /** 区块订阅参数 */
82
+ export interface GeyserBlockParams {
83
+ /** 过滤器 Key */
84
+ filterKey: string;
85
+ /** 包含涉及这些账户的区块(空表示全部) */
86
+ accountInclude?: string[];
87
+ /** 是否包含交易 */
88
+ includeTransactions?: boolean;
89
+ /** 是否包含账户更新 */
90
+ includeAccounts?: boolean;
91
+ /** 是否包含条目 */
92
+ includeEntries?: boolean;
93
+ }
94
+ /** 交易订阅参数 */
95
+ export interface GeyserTransactionParams {
96
+ /** 过滤器 Key */
97
+ filterKey: string;
98
+ /** 是否只包含投票交易 */
99
+ vote?: boolean;
100
+ /** 是否只包含失败交易 */
101
+ failed?: boolean;
102
+ /** 包含涉及这些账户的交易 */
103
+ accountInclude?: string[];
104
+ /** 排除涉及这些账户的交易 */
105
+ accountExclude?: string[];
106
+ /** 交易必须涉及这些账户 */
107
+ accountRequired?: string[];
108
+ /** 特定交易签名 */
109
+ signature?: string | null;
110
+ }
111
+ /** Geyser 订阅配置 */
112
+ export interface GeyserSubscribeConfig {
113
+ /** Commitment 级别 */
114
+ commitment?: GeyserCommitment;
115
+ /** 是否订阅账户 */
116
+ subscribeAccounts?: boolean;
117
+ /** 账户订阅参数 */
118
+ accountParams?: GeyserAccountParams;
119
+ /** 是否订阅区块 */
120
+ subscribeBlocks?: boolean;
121
+ /** 区块订阅参数 */
122
+ blockParams?: GeyserBlockParams;
123
+ /** 是否订阅交易 */
124
+ subscribeTransactions?: boolean;
125
+ /** 交易订阅参数 */
126
+ transactionParams?: GeyserTransactionParams;
127
+ }
128
+ /** 账户更新 */
129
+ export interface GeyserAccountUpdate {
130
+ slot: string;
131
+ account: {
132
+ pubkey: Uint8Array;
133
+ owner: Uint8Array;
134
+ lamports: string;
135
+ data: Uint8Array;
136
+ executable: boolean;
137
+ rentEpoch: string;
138
+ };
139
+ }
140
+ /** 区块更新 */
141
+ export interface GeyserBlockUpdate {
142
+ slot: string;
143
+ blockhash: string;
144
+ transactions: unknown[];
145
+ parentSlot: string;
146
+ blockTime?: string;
147
+ }
148
+ /** 交易更新 */
149
+ export interface GeyserTransactionUpdate {
150
+ slot: string;
151
+ transaction: {
152
+ signature: Uint8Array;
153
+ isVote: boolean;
154
+ transaction: unknown;
155
+ meta: unknown;
156
+ };
157
+ }
158
+ /** Geyser 更新 */
159
+ export interface GeyserUpdate {
160
+ update_oneof: 'account' | 'block' | 'transaction' | 'ping' | 'pong';
161
+ account?: GeyserAccountUpdate;
162
+ block?: GeyserBlockUpdate;
163
+ transaction?: GeyserTransactionUpdate;
164
+ }
165
+ /** Geyser 客户端配置 */
166
+ export interface GeyserClientConfig {
167
+ /** gRPC 服务地址 */
168
+ host: string;
169
+ /** 认证 Token */
170
+ token: string;
171
+ }
172
+ /** Geyser Stream 事件处理器 */
173
+ export interface GeyserEventHandlers {
174
+ /** 账户更新回调 */
175
+ onAccount?: (update: GeyserAccountUpdate, raw: Uint8Array) => void;
176
+ /** 区块更新回调 */
177
+ onBlock?: (update: GeyserBlockUpdate) => void;
178
+ /** 交易更新回调 */
179
+ onTransaction?: (update: GeyserTransactionUpdate, raw: Uint8Array) => void;
180
+ /** 错误回调 */
181
+ onError?: (error: Error) => void;
182
+ /** 流结束回调 */
183
+ onEnd?: () => void;
184
+ }
185
+ /** Geyser 订阅流控制 */
186
+ export interface GeyserStreamControl {
187
+ /** 关闭流 */
188
+ close: () => void;
189
+ /** 发送数据 */
190
+ write: (data: unknown) => void;
191
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * BlockRazor 类型定义
3
+ * @module sol/dex/blockrazor/types
4
+ */
5
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * DEX 模块导出
3
+ * @module sol/dex
4
+ */
5
+ export * from './pump/index.js';
6
+ export * from './raydium/index.js';
7
+ export * from './orca/index.js';
8
+ export * from './meteora/index.js';
9
+ export * from './jup/index.js';
10
+ export * from './blockrazor/index.js';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * DEX 模块导出
3
+ * @module sol/dex
4
+ */
5
+ // Pump.fun
6
+ export * from './pump/index.js';
7
+ // Raydium
8
+ export * from './raydium/index.js';
9
+ // Orca
10
+ export * from './orca/index.js';
11
+ // Meteora
12
+ export * from './meteora/index.js';
13
+ // Jupiter
14
+ export * from './jup/index.js';
15
+ // BlockRazor
16
+ export * from './blockrazor/index.js';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Jupiter API 客户端
3
+ * @module sol/dex/jup/client
4
+ */
5
+ import type { JupiterConfig } from './types.js';
6
+ /** Jupiter API 基础 URL */
7
+ export declare const JUP_API_BASE_URL = "https://api.jup.ag";
8
+ /** 默认超时时间 (ms) */
9
+ export declare const DEFAULT_TIMEOUT = 30000;
10
+ /**
11
+ * 设置默认 Jupiter 配置
12
+ */
13
+ export declare function setJupiterConfig(config: JupiterConfig): void;
14
+ /**
15
+ * 获取 Jupiter 配置
16
+ */
17
+ export declare function getJupiterConfig(config?: JupiterConfig): JupiterConfig;
18
+ /**
19
+ * 获取基础 URL
20
+ */
21
+ export declare function getBaseUrl(config?: JupiterConfig): string;
22
+ /**
23
+ * 构建请求头
24
+ */
25
+ export declare function buildHeaders(config?: JupiterConfig): Record<string, string>;
26
+ /**
27
+ * 发送 GET 请求
28
+ */
29
+ export declare function jupGet<T>(path: string, params?: Record<string, string | number | boolean | undefined>, config?: JupiterConfig): Promise<T>;
30
+ /**
31
+ * 发送 POST 请求
32
+ */
33
+ export declare function jupPost<T>(path: string, body: Record<string, unknown>, config?: JupiterConfig): Promise<T>;