four-flap-meme-sdk 1.5.6 → 1.5.9

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 (160) hide show
  1. package/README.zh-CN.pdf +0 -0
  2. package/dist/abis/common.js +2 -0
  3. package/dist/contracts/tm-bundle-merkle/config.d.ts +0 -1
  4. package/dist/contracts/tm-bundle-merkle/config.js +0 -1
  5. package/dist/contracts/tm-bundle-merkle/core.js +13 -9
  6. package/dist/contracts/tm-bundle-merkle/submit.js +58 -0
  7. package/dist/flap/portal-bundle-merkle/config.d.ts +0 -1
  8. package/dist/flap/portal-bundle-merkle/config.js +0 -1
  9. package/dist/flap/portal-bundle-merkle/create-to-dex.d.ts +8 -2
  10. package/dist/flap/portal-bundle-merkle/create-to-dex.js +170 -128
  11. package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
  12. package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
  13. package/dist/flap/portal-bundle-merkle/private.js +8 -4
  14. package/dist/index.d.ts +0 -1
  15. package/dist/index.js +1 -1
  16. package/package.json +5 -41
  17. package/dist/sol/constants.d.ts +0 -150
  18. package/dist/sol/constants.js +0 -188
  19. package/dist/sol/dex/blockrazor/client.d.ts +0 -51
  20. package/dist/sol/dex/blockrazor/client.js +0 -96
  21. package/dist/sol/dex/blockrazor/constants.d.ts +0 -34
  22. package/dist/sol/dex/blockrazor/constants.js +0 -55
  23. package/dist/sol/dex/blockrazor/geyser.d.ts +0 -128
  24. package/dist/sol/dex/blockrazor/geyser.js +0 -530
  25. package/dist/sol/dex/blockrazor/index.d.ts +0 -18
  26. package/dist/sol/dex/blockrazor/index.js +0 -23
  27. package/dist/sol/dex/blockrazor/send.d.ts +0 -135
  28. package/dist/sol/dex/blockrazor/send.js +0 -254
  29. package/dist/sol/dex/blockrazor/types.d.ts +0 -191
  30. package/dist/sol/dex/blockrazor/types.js +0 -5
  31. package/dist/sol/dex/index.d.ts +0 -10
  32. package/dist/sol/dex/index.js +0 -16
  33. package/dist/sol/dex/jup/client.d.ts +0 -33
  34. package/dist/sol/dex/jup/client.js +0 -110
  35. package/dist/sol/dex/jup/index.d.ts +0 -16
  36. package/dist/sol/dex/jup/index.js +0 -148
  37. package/dist/sol/dex/jup/legacy.d.ts +0 -623
  38. package/dist/sol/dex/jup/legacy.js +0 -416
  39. package/dist/sol/dex/jup/lend.d.ts +0 -640
  40. package/dist/sol/dex/jup/lend.js +0 -603
  41. package/dist/sol/dex/jup/portfolio.d.ts +0 -362
  42. package/dist/sol/dex/jup/portfolio.js +0 -367
  43. package/dist/sol/dex/jup/price.d.ts +0 -173
  44. package/dist/sol/dex/jup/price.js +0 -220
  45. package/dist/sol/dex/jup/recurring.d.ts +0 -437
  46. package/dist/sol/dex/jup/recurring.js +0 -320
  47. package/dist/sol/dex/jup/send.d.ts +0 -282
  48. package/dist/sol/dex/jup/send.js +0 -295
  49. package/dist/sol/dex/jup/studio.d.ts +0 -457
  50. package/dist/sol/dex/jup/studio.js +0 -488
  51. package/dist/sol/dex/jup/tokens.d.ts +0 -767
  52. package/dist/sol/dex/jup/tokens.js +0 -697
  53. package/dist/sol/dex/jup/trigger.d.ts +0 -511
  54. package/dist/sol/dex/jup/trigger.js +0 -397
  55. package/dist/sol/dex/jup/types.d.ts +0 -433
  56. package/dist/sol/dex/jup/types.js +0 -5
  57. package/dist/sol/dex/jup/ultra.d.ts +0 -646
  58. package/dist/sol/dex/jup/ultra.js +0 -853
  59. package/dist/sol/dex/meteora/client.d.ts +0 -76
  60. package/dist/sol/dex/meteora/client.js +0 -219
  61. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
  62. package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
  63. package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
  64. package/dist/sol/dex/meteora/damm-v1.js +0 -315
  65. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
  66. package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
  67. package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
  68. package/dist/sol/dex/meteora/damm-v2.js +0 -632
  69. package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
  70. package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
  71. package/dist/sol/dex/meteora/dbc.d.ts +0 -192
  72. package/dist/sol/dex/meteora/dbc.js +0 -619
  73. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
  74. package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
  75. package/dist/sol/dex/meteora/dlmm.d.ts +0 -157
  76. package/dist/sol/dex/meteora/dlmm.js +0 -671
  77. package/dist/sol/dex/meteora/index.d.ts +0 -25
  78. package/dist/sol/dex/meteora/index.js +0 -65
  79. package/dist/sol/dex/meteora/types.d.ts +0 -787
  80. package/dist/sol/dex/meteora/types.js +0 -110
  81. package/dist/sol/dex/orca/index.d.ts +0 -10
  82. package/dist/sol/dex/orca/index.js +0 -16
  83. package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
  84. package/dist/sol/dex/orca/orca-bundle.js +0 -173
  85. package/dist/sol/dex/orca/orca.d.ts +0 -65
  86. package/dist/sol/dex/orca/orca.js +0 -474
  87. package/dist/sol/dex/orca/types.d.ts +0 -263
  88. package/dist/sol/dex/orca/types.js +0 -38
  89. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
  90. package/dist/sol/dex/orca/wavebreak-bundle.js +0 -198
  91. package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
  92. package/dist/sol/dex/orca/wavebreak-types.js +0 -23
  93. package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
  94. package/dist/sol/dex/orca/wavebreak.js +0 -497
  95. package/dist/sol/dex/pump/index.d.ts +0 -9
  96. package/dist/sol/dex/pump/index.js +0 -14
  97. package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
  98. package/dist/sol/dex/pump/pump-bundle.js +0 -383
  99. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
  100. package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
  101. package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
  102. package/dist/sol/dex/pump/pump-swap.js +0 -199
  103. package/dist/sol/dex/pump/pump.d.ts +0 -35
  104. package/dist/sol/dex/pump/pump.js +0 -352
  105. package/dist/sol/dex/pump/types.d.ts +0 -215
  106. package/dist/sol/dex/pump/types.js +0 -5
  107. package/dist/sol/dex/raydium/index.d.ts +0 -8
  108. package/dist/sol/dex/raydium/index.js +0 -12
  109. package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
  110. package/dist/sol/dex/raydium/launchlab.js +0 -210
  111. package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
  112. package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
  113. package/dist/sol/dex/raydium/raydium.d.ts +0 -40
  114. package/dist/sol/dex/raydium/raydium.js +0 -366
  115. package/dist/sol/dex/raydium/types.d.ts +0 -240
  116. package/dist/sol/dex/raydium/types.js +0 -5
  117. package/dist/sol/index.d.ts +0 -11
  118. package/dist/sol/index.js +0 -18
  119. package/dist/sol/jito/bundle.d.ts +0 -90
  120. package/dist/sol/jito/bundle.js +0 -263
  121. package/dist/sol/jito/index.d.ts +0 -7
  122. package/dist/sol/jito/index.js +0 -7
  123. package/dist/sol/jito/tip.d.ts +0 -51
  124. package/dist/sol/jito/tip.js +0 -83
  125. package/dist/sol/jito/types.d.ts +0 -100
  126. package/dist/sol/jito/types.js +0 -5
  127. package/dist/sol/nozomi/client.d.ts +0 -63
  128. package/dist/sol/nozomi/client.js +0 -222
  129. package/dist/sol/nozomi/index.d.ts +0 -8
  130. package/dist/sol/nozomi/index.js +0 -8
  131. package/dist/sol/nozomi/tip.d.ts +0 -50
  132. package/dist/sol/nozomi/tip.js +0 -80
  133. package/dist/sol/nozomi/types.d.ts +0 -96
  134. package/dist/sol/nozomi/types.js +0 -5
  135. package/dist/sol/token/create-complete.d.ts +0 -115
  136. package/dist/sol/token/create-complete.js +0 -235
  137. package/dist/sol/token/create-token.d.ts +0 -57
  138. package/dist/sol/token/create-token.js +0 -230
  139. package/dist/sol/token/index.d.ts +0 -9
  140. package/dist/sol/token/index.js +0 -14
  141. package/dist/sol/token/metadata-upload.d.ts +0 -86
  142. package/dist/sol/token/metadata-upload.js +0 -173
  143. package/dist/sol/token/metadata.d.ts +0 -92
  144. package/dist/sol/token/metadata.js +0 -274
  145. package/dist/sol/token/types.d.ts +0 -153
  146. package/dist/sol/token/types.js +0 -5
  147. package/dist/sol/types.d.ts +0 -176
  148. package/dist/sol/types.js +0 -7
  149. package/dist/sol/utils/balance.d.ts +0 -160
  150. package/dist/sol/utils/balance.js +0 -638
  151. package/dist/sol/utils/connection.d.ts +0 -78
  152. package/dist/sol/utils/connection.js +0 -168
  153. package/dist/sol/utils/index.d.ts +0 -9
  154. package/dist/sol/utils/index.js +0 -9
  155. package/dist/sol/utils/lp-inspect.d.ts +0 -129
  156. package/dist/sol/utils/lp-inspect.js +0 -900
  157. package/dist/sol/utils/transfer.d.ts +0 -196
  158. package/dist/sol/utils/transfer.js +0 -307
  159. package/dist/sol/utils/wallet.d.ts +0 -107
  160. package/dist/sol/utils/wallet.js +0 -210
@@ -1,263 +0,0 @@
1
- /**
2
- * Orca Whirlpool 类型定义
3
- */
4
- import type { Keypair, Transaction, VersionedTransaction } from '@solana/web3.js';
5
- import type BN from 'bn.js';
6
- /**
7
- * Orca Whirlpool 池信息
8
- */
9
- export interface OrcaPoolInfo {
10
- /** 池地址 */
11
- poolAddress: string;
12
- /** Token A 地址 */
13
- tokenMintA: string;
14
- /** Token B 地址 */
15
- tokenMintB: string;
16
- /** Token A 符号 */
17
- tokenSymbolA?: string;
18
- /** Token B 符号 */
19
- tokenSymbolB?: string;
20
- /** Token A 小数位数 */
21
- tokenDecimalsA: number;
22
- /** Token B 小数位数 */
23
- tokenDecimalsB: number;
24
- /** Token A 金库地址 */
25
- tokenVaultA: string;
26
- /** Token B 金库地址 */
27
- tokenVaultB: string;
28
- /** 当前价格 (Token B / Token A) */
29
- price: number;
30
- /** 当前 sqrt 价格 */
31
- sqrtPrice: string;
32
- /** 当前 tick */
33
- currentTick: number;
34
- /** Tick 间距 */
35
- tickSpacing: number;
36
- /** 费率 (bps) */
37
- feeRate: number;
38
- /** 协议费率 (bps) */
39
- protocolFeeRate: number;
40
- /** 流动性 */
41
- liquidity: string;
42
- /** 费用增长 A */
43
- feeGrowthGlobalA: string;
44
- /** 费用增长 B */
45
- feeGrowthGlobalB: string;
46
- /** 奖励信息 */
47
- rewardInfos: OrcaRewardInfo[];
48
- }
49
- /**
50
- * Orca 奖励信息
51
- */
52
- export interface OrcaRewardInfo {
53
- /** 奖励代币地址 */
54
- mint: string;
55
- /** 奖励金库地址 */
56
- vault: string;
57
- /** 每秒排放量 */
58
- emissionsPerSecond: string;
59
- /** 增长全局 */
60
- growthGlobal: string;
61
- }
62
- /**
63
- * Orca Swap 参数
64
- */
65
- export interface OrcaSwapParams {
66
- /** 池地址 */
67
- poolAddress: string;
68
- /** 输入代币地址 */
69
- inputMint: string;
70
- /** 输出代币地址 */
71
- outputMint: string;
72
- /** 输入金额 (lamports) */
73
- amountIn: BN;
74
- /** 最小输出金额 (lamports) */
75
- minAmountOut: BN;
76
- /** 滑点 (bps, 如 100 = 1%) */
77
- slippageBps?: number;
78
- /** 是否精确输入 */
79
- exactInput?: boolean;
80
- }
81
- /**
82
- * Orca Swap 报价
83
- */
84
- export interface OrcaSwapQuote {
85
- /** 输入金额 */
86
- amountIn: BN;
87
- /** 预估输出金额 */
88
- estimatedAmountOut: BN;
89
- /** 最小输出金额 (考虑滑点) */
90
- minAmountOut: BN;
91
- /** 费用金额 */
92
- feeAmount: BN;
93
- /** 价格影响 (百分比) */
94
- priceImpact: number;
95
- }
96
- /**
97
- * Orca 添加流动性参数
98
- */
99
- export interface OrcaAddLiquidityParams {
100
- /** 池地址 */
101
- poolAddress: string;
102
- /** 下限 tick */
103
- tickLower: number;
104
- /** 上限 tick */
105
- tickUpper: number;
106
- /** Token A 金额 */
107
- tokenAmountA: BN;
108
- /** Token B 金额 */
109
- tokenAmountB: BN;
110
- /** 滑点 (bps) */
111
- slippageBps?: number;
112
- /** 是否创建新 position */
113
- createNewPosition?: boolean;
114
- /** 已有 position 地址 (如果不创建新的) */
115
- positionAddress?: string;
116
- }
117
- /**
118
- * Orca 移除流动性参数
119
- */
120
- export interface OrcaRemoveLiquidityParams {
121
- /** Position 地址 */
122
- positionAddress: string;
123
- /** 流动性金额 (如果不指定,移除全部) */
124
- liquidityAmount?: BN;
125
- /** 最小 Token A 输出 */
126
- minTokenAmountA?: BN;
127
- /** 最小 Token B 输出 */
128
- minTokenAmountB?: BN;
129
- /** 滑点 (bps) */
130
- slippageBps?: number;
131
- /** 是否关闭 position */
132
- closePosition?: boolean;
133
- }
134
- /**
135
- * Orca Position 信息
136
- */
137
- export interface OrcaPositionInfo {
138
- /** Position 地址 */
139
- positionAddress: string;
140
- /** Position Mint 地址 */
141
- positionMint: string;
142
- /** 池地址 */
143
- poolAddress: string;
144
- /** 下限 tick */
145
- tickLower: number;
146
- /** 上限 tick */
147
- tickUpper: number;
148
- /** 流动性 */
149
- liquidity: string;
150
- /** 费用 A 应收 */
151
- feeOwedA: string;
152
- /** 费用 B 应收 */
153
- feeOwedB: string;
154
- /** 奖励应收 */
155
- rewardOwed: string[];
156
- }
157
- /**
158
- * Orca 创建池参数
159
- */
160
- export interface OrcaCreatePoolParams {
161
- /** Whirlpools Config 地址 */
162
- whirlpoolsConfig: string;
163
- /** Token A 地址 */
164
- tokenMintA: string;
165
- /** Token B 地址 */
166
- tokenMintB: string;
167
- /** 初始价格 (Token B / Token A) */
168
- initialPrice: number;
169
- /** Tick 间距 (决定费率) */
170
- tickSpacing?: number;
171
- /** 资金提供者 (默认为签名者) */
172
- funder?: string;
173
- }
174
- /**
175
- * Orca Bundle Swap 参数 (批量交易)
176
- */
177
- export interface OrcaBundleSwapParams {
178
- /** 池地址 */
179
- poolAddress: string;
180
- /** 输入代币地址 */
181
- inputMint: string;
182
- /** 输出代币地址 */
183
- outputMint: string;
184
- /** 交易列表 */
185
- trades: {
186
- /** 钱包 */
187
- wallet: Keypair;
188
- /** 输入金额 */
189
- amountIn: BN;
190
- /** 最小输出金额 */
191
- minAmountOut: BN;
192
- }[];
193
- /** Jito 小费 (lamports) */
194
- jitoTipLamports?: number;
195
- }
196
- /**
197
- * Orca 签名结果
198
- */
199
- export interface OrcaSignedResult {
200
- /** 签名后的交易 */
201
- signedTransaction: Transaction | VersionedTransaction;
202
- /** 交易类型 */
203
- type: 'swap' | 'addLiquidity' | 'removeLiquidity' | 'createPool' | 'collectFees';
204
- /** 池地址 */
205
- poolAddress: string;
206
- /** 额外信息 */
207
- metadata?: {
208
- positionMint?: string;
209
- positionAddress?: string;
210
- estimatedAmountOut?: string;
211
- liquidityAmount?: string;
212
- };
213
- }
214
- /**
215
- * Orca Bundle 签名结果
216
- */
217
- export interface OrcaBundleSignedResult {
218
- /** 签名后的交易列表 */
219
- signedTransactions: (Transaction | VersionedTransaction)[];
220
- /** Bundle 类型 */
221
- type: 'bundleSwap';
222
- /** 池地址 */
223
- poolAddress: string;
224
- /** 交易数量 */
225
- tradeCount: number;
226
- /** Jito 小费 */
227
- jitoTipLamports: number;
228
- }
229
- /**
230
- * Whirlpool 费率等级
231
- * tickSpacing 决定费率
232
- */
233
- export declare const WHIRLPOOL_TICK_SPACING: {
234
- /** 0.01% 费率 */
235
- readonly TICK_SPACING_1: 1;
236
- /** 0.02% 费率 */
237
- readonly TICK_SPACING_2: 2;
238
- /** 0.04% 费率 */
239
- readonly TICK_SPACING_4: 4;
240
- /** 0.08% 费率 */
241
- readonly TICK_SPACING_8: 8;
242
- /** 0.16% 费率 */
243
- readonly TICK_SPACING_16: 16;
244
- /** 0.30% 费率 */
245
- readonly TICK_SPACING_64: 64;
246
- /** 1.00% 费率 */
247
- readonly TICK_SPACING_128: 128;
248
- /** 2.00% 费率 */
249
- readonly TICK_SPACING_256: 256;
250
- };
251
- /**
252
- * Orca Whirlpools Config 地址
253
- */
254
- export declare const ORCA_WHIRLPOOL_CONFIG: {
255
- /** Mainnet Whirlpools Config */
256
- readonly MAINNET: "FcrweFY1G9HJAHG5inkGB6pKg1HZ6x9UC2WioAfWrGkR";
257
- /** Devnet Whirlpools Config */
258
- readonly DEVNET: "FcrweFY1G9HJAHG5inkGB6pKg1HZ6x9UC2WioAfWrGkR";
259
- };
260
- /**
261
- * Orca Whirlpool Program ID
262
- */
263
- export declare const ORCA_WHIRLPOOL_PROGRAM_ID = "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc";
@@ -1,38 +0,0 @@
1
- /**
2
- * Orca Whirlpool 类型定义
3
- */
4
- /**
5
- * Whirlpool 费率等级
6
- * tickSpacing 决定费率
7
- */
8
- export const WHIRLPOOL_TICK_SPACING = {
9
- /** 0.01% 费率 */
10
- TICK_SPACING_1: 1,
11
- /** 0.02% 费率 */
12
- TICK_SPACING_2: 2,
13
- /** 0.04% 费率 */
14
- TICK_SPACING_4: 4,
15
- /** 0.08% 费率 */
16
- TICK_SPACING_8: 8,
17
- /** 0.16% 费率 */
18
- TICK_SPACING_16: 16,
19
- /** 0.30% 费率 */
20
- TICK_SPACING_64: 64,
21
- /** 1.00% 费率 */
22
- TICK_SPACING_128: 128,
23
- /** 2.00% 费率 */
24
- TICK_SPACING_256: 256,
25
- };
26
- /**
27
- * Orca Whirlpools Config 地址
28
- */
29
- export const ORCA_WHIRLPOOL_CONFIG = {
30
- /** Mainnet Whirlpools Config */
31
- MAINNET: 'FcrweFY1G9HJAHG5inkGB6pKg1HZ6x9UC2WioAfWrGkR',
32
- /** Devnet Whirlpools Config */
33
- DEVNET: 'FcrweFY1G9HJAHG5inkGB6pKg1HZ6x9UC2WioAfWrGkR',
34
- };
35
- /**
36
- * Orca Whirlpool Program ID
37
- */
38
- export const ORCA_WHIRLPOOL_PROGRAM_ID = 'whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc';
@@ -1,34 +0,0 @@
1
- /**
2
- * Orca Wavebreak Jito Bundle 批量交易
3
- * 支持批量买卖的原子性交易
4
- */
5
- import { Connection, Keypair } from '@solana/web3.js';
6
- import type { WavebreakBundleBuyParams, WavebreakBundleSellParams, WavebreakBundleCreateAndBuyParams, WavebreakBundleSignedResult } from './wavebreak-types.js';
7
- /**
8
- * 签名 Wavebreak Bundle 批量买入交易
9
- */
10
- export declare function signWavebreakBundleBuy(params: WavebreakBundleBuyParams, connection?: Connection): Promise<WavebreakBundleSignedResult>;
11
- /**
12
- * 签名 Wavebreak Bundle 批量卖出交易
13
- */
14
- export declare function signWavebreakBundleSell(params: WavebreakBundleSellParams, connection?: Connection): Promise<WavebreakBundleSignedResult>;
15
- /**
16
- * 签名 Wavebreak Bundle 创建并买入交易
17
- * 第一笔交易创建代币,后续交易批量买入
18
- */
19
- export declare function signWavebreakBundleCreateAndBuy(params: WavebreakBundleCreateAndBuyParams, connection?: Connection): Promise<WavebreakBundleSignedResult & {
20
- baseMintKeypair: Keypair;
21
- }>;
22
- /**
23
- * 将 Wavebreak Bundle 结果转换为后端 API 请求格式
24
- */
25
- export declare function toWavebreakBundleApiRequest(result: WavebreakBundleSignedResult): {
26
- transactions: string[];
27
- metadata: {
28
- type: string;
29
- bondingCurveAddress: string;
30
- baseMint?: string;
31
- tradeCount: number;
32
- jitoTipLamports: number;
33
- };
34
- };
@@ -1,198 +0,0 @@
1
- /**
2
- * Orca Wavebreak Jito Bundle 批量交易
3
- * 支持批量买卖的原子性交易
4
- */
5
- import { PublicKey, Keypair, Transaction, ComputeBudgetProgram, } from '@solana/web3.js';
6
- // 不再导入 createConnection,强制使用者传入连接
7
- import { buildTipInstruction, getRandomTipAccount } from '../../jito/tip.js';
8
- import { buildWavebreakBuyInstruction, buildWavebreakSellInstruction, buildWavebreakCreateLaunchInstruction, getWavebreakBondingCurveInfo, } from './wavebreak.js';
9
- import { WAVEBREAK_CONSTANTS } from './wavebreak-types.js';
10
- /**
11
- * 默认 Jito 小费 (0.001 SOL)
12
- */
13
- const DEFAULT_JITO_TIP_LAMPORTS = 1000000;
14
- /**
15
- * 签名 Wavebreak Bundle 批量买入交易
16
- */
17
- export async function signWavebreakBundleBuy(params, connection) {
18
- if (!connection) {
19
- throw new Error('Connection is required. Please pass a connection created with user-configured RPC.');
20
- }
21
- const conn = connection;
22
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
23
- // 获取 Bonding Curve 信息
24
- const info = await getWavebreakBondingCurveInfo(params.bondingCurveOrMint, conn);
25
- if (!info) {
26
- throw new Error('Bonding Curve 不存在');
27
- }
28
- const signedTransactions = [];
29
- const jitoTipLamports = params.jitoTipLamports || DEFAULT_JITO_TIP_LAMPORTS;
30
- const slippageBps = params.slippageBps || 100;
31
- for (let i = 0; i < params.trades.length; i++) {
32
- const trade = params.trades[i];
33
- const isLastTrade = i === params.trades.length - 1;
34
- const tx = new Transaction();
35
- // 添加计算预算
36
- tx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 300000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
37
- // 添加买入指令
38
- const buyIx = await buildWavebreakBuyInstruction({
39
- bondingCurveOrMint: info.bondingCurveAddress,
40
- amountIn: trade.amountIn,
41
- allowPartialFill: true,
42
- slippageBps,
43
- }, trade.wallet.publicKey, conn);
44
- tx.add(buyIx);
45
- // 最后一笔交易添加 Jito 小费
46
- if (isLastTrade) {
47
- const tipAccount = getRandomTipAccount();
48
- const tipIx = buildTipInstruction(trade.wallet.publicKey, BigInt(jitoTipLamports), tipAccount);
49
- tx.add(tipIx);
50
- }
51
- // 设置交易参数
52
- tx.recentBlockhash = blockhash;
53
- tx.lastValidBlockHeight = lastValidBlockHeight;
54
- tx.feePayer = trade.wallet.publicKey;
55
- // 签名
56
- tx.sign(trade.wallet);
57
- signedTransactions.push(tx);
58
- }
59
- return {
60
- signedTransactions,
61
- type: 'bundleBuy',
62
- bondingCurveAddress: info.bondingCurveAddress,
63
- baseMint: info.baseMint,
64
- tradeCount: params.trades.length,
65
- jitoTipLamports,
66
- };
67
- }
68
- /**
69
- * 签名 Wavebreak Bundle 批量卖出交易
70
- */
71
- export async function signWavebreakBundleSell(params, connection) {
72
- if (!connection) {
73
- throw new Error('Connection is required. Please pass a connection created with user-configured RPC.');
74
- }
75
- const conn = connection;
76
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
77
- const info = await getWavebreakBondingCurveInfo(params.bondingCurveOrMint, conn);
78
- if (!info) {
79
- throw new Error('Bonding Curve 不存在');
80
- }
81
- const signedTransactions = [];
82
- const jitoTipLamports = params.jitoTipLamports || DEFAULT_JITO_TIP_LAMPORTS;
83
- const slippageBps = params.slippageBps || 100;
84
- for (let i = 0; i < params.trades.length; i++) {
85
- const trade = params.trades[i];
86
- const isLastTrade = i === params.trades.length - 1;
87
- const tx = new Transaction();
88
- tx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 300000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
89
- const sellIx = await buildWavebreakSellInstruction({
90
- bondingCurveOrMint: info.bondingCurveAddress,
91
- amountIn: trade.amountIn,
92
- allowPartialFill: true,
93
- slippageBps,
94
- }, trade.wallet.publicKey, conn);
95
- tx.add(sellIx);
96
- if (isLastTrade) {
97
- const tipAccount = getRandomTipAccount();
98
- const tipIx = buildTipInstruction(trade.wallet.publicKey, BigInt(jitoTipLamports), tipAccount);
99
- tx.add(tipIx);
100
- }
101
- tx.recentBlockhash = blockhash;
102
- tx.lastValidBlockHeight = lastValidBlockHeight;
103
- tx.feePayer = trade.wallet.publicKey;
104
- tx.sign(trade.wallet);
105
- signedTransactions.push(tx);
106
- }
107
- return {
108
- signedTransactions,
109
- type: 'bundleSell',
110
- bondingCurveAddress: info.bondingCurveAddress,
111
- baseMint: info.baseMint,
112
- tradeCount: params.trades.length,
113
- jitoTipLamports,
114
- };
115
- }
116
- /**
117
- * 签名 Wavebreak Bundle 创建并买入交易
118
- * 第一笔交易创建代币,后续交易批量买入
119
- */
120
- export async function signWavebreakBundleCreateAndBuy(params, connection) {
121
- if (!connection) {
122
- throw new Error('Connection is required. Please pass a connection created with user-configured RPC.');
123
- }
124
- const conn = connection;
125
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
126
- const signedTransactions = [];
127
- const jitoTipLamports = params.jitoTipLamports || DEFAULT_JITO_TIP_LAMPORTS;
128
- const slippageBps = params.slippageBps || 100;
129
- // 生成新的 Mint Keypair
130
- const baseMintKeypair = Keypair.generate();
131
- // 计算 Bonding Curve 地址
132
- const [bondingCurve] = PublicKey.findProgramAddressSync([Buffer.from('bonding_curve'), baseMintKeypair.publicKey.toBuffer()], new PublicKey(WAVEBREAK_CONSTANTS.PROGRAM_ID));
133
- // ===== 第一笔交易:创建代币发射 =====
134
- const createTx = new Transaction();
135
- createTx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 500000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
136
- const createIx = await buildWavebreakCreateLaunchInstruction(params.createParams, params.creator.publicKey, baseMintKeypair, conn);
137
- createTx.add(createIx);
138
- // 如果创建者也要买入,在创建交易中添加买入指令
139
- // 这样可以减少一笔交易
140
- createTx.recentBlockhash = blockhash;
141
- createTx.lastValidBlockHeight = lastValidBlockHeight;
142
- createTx.feePayer = params.creator.publicKey;
143
- createTx.sign(params.creator, baseMintKeypair);
144
- signedTransactions.push(createTx);
145
- // ===== 后续交易:批量买入 =====
146
- const totalTrades = params.buyTrades.length;
147
- for (let i = 0; i < totalTrades; i++) {
148
- const trade = params.buyTrades[i];
149
- const isLastTrade = i === totalTrades - 1;
150
- const buyTx = new Transaction();
151
- buyTx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 300000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
152
- const buyIx = await buildWavebreakBuyInstruction({
153
- bondingCurveOrMint: bondingCurve.toBase58(),
154
- amountIn: trade.amountIn,
155
- allowPartialFill: true,
156
- slippageBps,
157
- }, trade.wallet.publicKey, conn);
158
- buyTx.add(buyIx);
159
- // 最后一笔交易添加 Jito 小费
160
- if (isLastTrade) {
161
- const tipAccount = getRandomTipAccount();
162
- const tipIx = buildTipInstruction(trade.wallet.publicKey, BigInt(jitoTipLamports), tipAccount);
163
- buyTx.add(tipIx);
164
- }
165
- buyTx.recentBlockhash = blockhash;
166
- buyTx.lastValidBlockHeight = lastValidBlockHeight;
167
- buyTx.feePayer = trade.wallet.publicKey;
168
- buyTx.sign(trade.wallet);
169
- signedTransactions.push(buyTx);
170
- }
171
- return {
172
- signedTransactions,
173
- type: 'bundleCreateAndBuy',
174
- bondingCurveAddress: bondingCurve.toBase58(),
175
- baseMint: baseMintKeypair.publicKey.toBase58(),
176
- tradeCount: totalTrades + 1, // 包括创建交易
177
- jitoTipLamports,
178
- baseMintKeypair,
179
- };
180
- }
181
- /**
182
- * 将 Wavebreak Bundle 结果转换为后端 API 请求格式
183
- */
184
- export function toWavebreakBundleApiRequest(result) {
185
- const transactions = result.signedTransactions.map(tx => {
186
- return Buffer.from(tx.serialize()).toString('base64');
187
- });
188
- return {
189
- transactions,
190
- metadata: {
191
- type: result.type,
192
- bondingCurveAddress: result.bondingCurveAddress,
193
- baseMint: result.baseMint,
194
- tradeCount: result.tradeCount,
195
- jitoTipLamports: result.jitoTipLamports,
196
- },
197
- };
198
- }