four-flap-meme-sdk 1.3.87 → 1.3.89

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 (122) hide show
  1. package/dist/clients/blockrazor.js +0 -1
  2. package/dist/contracts/tm-bundle-merkle/core.js +6 -3
  3. package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +30 -38
  4. package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +0 -1
  5. package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +4 -3
  6. package/dist/contracts/tm-bundle-merkle/swap.d.ts +0 -3
  7. package/dist/contracts/tm-bundle-merkle/swap.js +2 -2
  8. package/dist/flap/portal-bundle-merkle/core.js +2 -6
  9. package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
  10. package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
  11. package/dist/flap/portal-bundle-merkle/pancake-proxy.js +55 -35
  12. package/dist/flap/portal-bundle-merkle/swap-buy-first.d.ts +0 -2
  13. package/dist/flap/portal-bundle-merkle/swap-buy-first.js +6 -11
  14. package/dist/flap/portal-bundle-merkle/swap.d.ts +0 -2
  15. package/dist/flap/portal-bundle-merkle/swap.js +10 -22
  16. package/dist/index.d.ts +1 -2
  17. package/dist/index.js +0 -1
  18. package/dist/pancake/bundle-buy-first.d.ts +0 -1
  19. package/dist/pancake/bundle-buy-first.js +4 -9
  20. package/dist/pancake/bundle-swap.d.ts +0 -4
  21. package/dist/pancake/bundle-swap.js +7 -14
  22. package/dist/utils/erc20.d.ts +108 -2
  23. package/dist/utils/erc20.js +65 -17
  24. package/package.json +4 -39
  25. package/dist/sol/constants.d.ts +0 -136
  26. package/dist/sol/constants.js +0 -156
  27. package/dist/sol/dex/index.d.ts +0 -8
  28. package/dist/sol/dex/index.js +0 -12
  29. package/dist/sol/dex/meteora/client.d.ts +0 -75
  30. package/dist/sol/dex/meteora/client.js +0 -218
  31. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
  32. package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
  33. package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
  34. package/dist/sol/dex/meteora/damm-v1.js +0 -315
  35. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
  36. package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
  37. package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
  38. package/dist/sol/dex/meteora/damm-v2.js +0 -632
  39. package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
  40. package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
  41. package/dist/sol/dex/meteora/dbc.d.ts +0 -192
  42. package/dist/sol/dex/meteora/dbc.js +0 -619
  43. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
  44. package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
  45. package/dist/sol/dex/meteora/dlmm.d.ts +0 -146
  46. package/dist/sol/dex/meteora/dlmm.js +0 -593
  47. package/dist/sol/dex/meteora/index.d.ts +0 -25
  48. package/dist/sol/dex/meteora/index.js +0 -65
  49. package/dist/sol/dex/meteora/types.d.ts +0 -787
  50. package/dist/sol/dex/meteora/types.js +0 -110
  51. package/dist/sol/dex/orca/index.d.ts +0 -10
  52. package/dist/sol/dex/orca/index.js +0 -16
  53. package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
  54. package/dist/sol/dex/orca/orca-bundle.js +0 -167
  55. package/dist/sol/dex/orca/orca.d.ts +0 -65
  56. package/dist/sol/dex/orca/orca.js +0 -454
  57. package/dist/sol/dex/orca/types.d.ts +0 -263
  58. package/dist/sol/dex/orca/types.js +0 -38
  59. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
  60. package/dist/sol/dex/orca/wavebreak-bundle.js +0 -189
  61. package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
  62. package/dist/sol/dex/orca/wavebreak-types.js +0 -23
  63. package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
  64. package/dist/sol/dex/orca/wavebreak.js +0 -469
  65. package/dist/sol/dex/pump/index.d.ts +0 -9
  66. package/dist/sol/dex/pump/index.js +0 -14
  67. package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
  68. package/dist/sol/dex/pump/pump-bundle.js +0 -383
  69. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
  70. package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
  71. package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
  72. package/dist/sol/dex/pump/pump-swap.js +0 -199
  73. package/dist/sol/dex/pump/pump.d.ts +0 -35
  74. package/dist/sol/dex/pump/pump.js +0 -352
  75. package/dist/sol/dex/pump/types.d.ts +0 -215
  76. package/dist/sol/dex/pump/types.js +0 -5
  77. package/dist/sol/dex/raydium/index.d.ts +0 -8
  78. package/dist/sol/dex/raydium/index.js +0 -12
  79. package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
  80. package/dist/sol/dex/raydium/launchlab.js +0 -210
  81. package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
  82. package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
  83. package/dist/sol/dex/raydium/raydium.d.ts +0 -40
  84. package/dist/sol/dex/raydium/raydium.js +0 -366
  85. package/dist/sol/dex/raydium/types.d.ts +0 -240
  86. package/dist/sol/dex/raydium/types.js +0 -5
  87. package/dist/sol/index.d.ts +0 -10
  88. package/dist/sol/index.js +0 -16
  89. package/dist/sol/jito/bundle.d.ts +0 -90
  90. package/dist/sol/jito/bundle.js +0 -263
  91. package/dist/sol/jito/index.d.ts +0 -7
  92. package/dist/sol/jito/index.js +0 -7
  93. package/dist/sol/jito/tip.d.ts +0 -51
  94. package/dist/sol/jito/tip.js +0 -83
  95. package/dist/sol/jito/types.d.ts +0 -100
  96. package/dist/sol/jito/types.js +0 -5
  97. package/dist/sol/token/create-complete.d.ts +0 -115
  98. package/dist/sol/token/create-complete.js +0 -235
  99. package/dist/sol/token/create-token.d.ts +0 -57
  100. package/dist/sol/token/create-token.js +0 -230
  101. package/dist/sol/token/index.d.ts +0 -9
  102. package/dist/sol/token/index.js +0 -14
  103. package/dist/sol/token/metadata-upload.d.ts +0 -86
  104. package/dist/sol/token/metadata-upload.js +0 -173
  105. package/dist/sol/token/metadata.d.ts +0 -92
  106. package/dist/sol/token/metadata.js +0 -274
  107. package/dist/sol/token/types.d.ts +0 -153
  108. package/dist/sol/token/types.js +0 -5
  109. package/dist/sol/types.d.ts +0 -176
  110. package/dist/sol/types.js +0 -7
  111. package/dist/sol/utils/balance.d.ts +0 -160
  112. package/dist/sol/utils/balance.js +0 -638
  113. package/dist/sol/utils/connection.d.ts +0 -69
  114. package/dist/sol/utils/connection.js +0 -156
  115. package/dist/sol/utils/index.d.ts +0 -9
  116. package/dist/sol/utils/index.js +0 -9
  117. package/dist/sol/utils/lp-inspect.d.ts +0 -129
  118. package/dist/sol/utils/lp-inspect.js +0 -515
  119. package/dist/sol/utils/transfer.d.ts +0 -125
  120. package/dist/sol/utils/transfer.js +0 -220
  121. package/dist/sol/utils/wallet.d.ts +0 -107
  122. package/dist/sol/utils/wallet.js +0 -210
@@ -1,469 +0,0 @@
1
- /**
2
- * Orca Wavebreak 核心功能
3
- * Wavebreak 是 Orca 的代币发射平台(类似 Pump.fun)
4
- *
5
- * 由于 Wavebreak SDK 使用 @solana/kit(与 @solana/web3.js 类型不兼容),
6
- * 我们使用 SDK 的编码器和数学函数,但手动构建 @solana/web3.js 的交易指令。
7
- */
8
- import { PublicKey, Keypair, Transaction, TransactionInstruction, SystemProgram, ComputeBudgetProgram, } from '@solana/web3.js';
9
- import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, ASSOCIATED_TOKEN_PROGRAM_ID, } from '@solana/spl-token';
10
- import { createConnection } from '../../utils/connection.js';
11
- import { WAVEBREAK_CONSTANTS } from './wavebreak-types.js';
12
- // ============================================================================
13
- // Wavebreak SDK 导入(动态导入以避免类型冲突)
14
- // ============================================================================
15
- let wavebreakSdk = null;
16
- async function loadWavebreakSdk() {
17
- if (!wavebreakSdk) {
18
- wavebreakSdk = await import('@orca-so/wavebreak');
19
- }
20
- return wavebreakSdk;
21
- }
22
- // ============================================================================
23
- // PDA 计算
24
- // ============================================================================
25
- /**
26
- * 计算 Bonding Curve PDA 地址
27
- */
28
- export async function getWavebreakBondingCurveAddress(baseMint) {
29
- const sdk = await loadWavebreakSdk();
30
- const mintStr = typeof baseMint === 'string' ? baseMint : baseMint.toBase58();
31
- const [address] = await sdk.getBondingCurveAddress(mintStr);
32
- return new PublicKey(address);
33
- }
34
- /**
35
- * 同步计算 Bonding Curve PDA 地址(使用 @solana/web3.js)
36
- */
37
- export function getWavebreakBondingCurveAddressSync(baseMint) {
38
- const mintPubkey = typeof baseMint === 'string' ? new PublicKey(baseMint) : baseMint;
39
- const [bondingCurve] = PublicKey.findProgramAddressSync([Buffer.from('bonding_curve'), mintPubkey.toBuffer()], new PublicKey(WAVEBREAK_CONSTANTS.PROGRAM_ID));
40
- return bondingCurve;
41
- }
42
- /**
43
- * 计算 Quote Vault PDA 地址
44
- */
45
- export function getWavebreakQuoteVaultAddressSync(bondingCurve) {
46
- const bcPubkey = typeof bondingCurve === 'string' ? new PublicKey(bondingCurve) : bondingCurve;
47
- const [quoteVault] = PublicKey.findProgramAddressSync([Buffer.from('quote_vault'), bcPubkey.toBuffer()], new PublicKey(WAVEBREAK_CONSTANTS.PROGRAM_ID));
48
- return quoteVault;
49
- }
50
- /**
51
- * 计算 LP Escrow PDA 地址
52
- */
53
- export function getWavebreakLpEscrowAddressSync(bondingCurve) {
54
- const bcPubkey = typeof bondingCurve === 'string' ? new PublicKey(bondingCurve) : bondingCurve;
55
- const [lpEscrow] = PublicKey.findProgramAddressSync([Buffer.from('lp_escrow'), bcPubkey.toBuffer()], new PublicKey(WAVEBREAK_CONSTANTS.PROGRAM_ID));
56
- return lpEscrow;
57
- }
58
- // ============================================================================
59
- // 账户数据获取和解析
60
- // ============================================================================
61
- /**
62
- * 获取 Wavebreak Bonding Curve 信息
63
- */
64
- export async function getWavebreakBondingCurveInfo(bondingCurveOrMint, connection) {
65
- const conn = connection || createConnection();
66
- const sdk = await loadWavebreakSdk();
67
- // 判断是 Bonding Curve 地址还是 Mint 地址
68
- let bondingCurveAddress;
69
- try {
70
- const inputPubkey = new PublicKey(bondingCurveOrMint);
71
- // 尝试作为 Mint 地址获取 Bonding Curve PDA
72
- const calculatedBC = getWavebreakBondingCurveAddressSync(inputPubkey);
73
- // 检查计算出的地址是否存在
74
- const bcAccountInfo = await conn.getAccountInfo(calculatedBC);
75
- if (bcAccountInfo) {
76
- bondingCurveAddress = calculatedBC;
77
- }
78
- else {
79
- // 假设输入的就是 Bonding Curve 地址
80
- bondingCurveAddress = inputPubkey;
81
- }
82
- }
83
- catch {
84
- return null;
85
- }
86
- try {
87
- const accountInfo = await conn.getAccountInfo(bondingCurveAddress);
88
- if (!accountInfo)
89
- return null;
90
- // 使用 SDK 的解码器解析账户数据
91
- const decoder = sdk.getBondingCurveDecoder();
92
- const data = decoder.decode(accountInfo.data);
93
- // 构建价格曲线
94
- const priceCurve = {
95
- startPrice: data.startPrice,
96
- endPrice: data.endPrice,
97
- controlPoints: data.controlPoints,
98
- };
99
- // 计算当前价格
100
- const currentPriceSqrt = sdk.tokenPrice(priceCurve, data.quoteAmount, data.graduationTarget);
101
- const currentPrice = sdk.sqrtPriceToPrice(currentPriceSqrt, 9, 9);
102
- // 计算进度
103
- const progressPercent = Number(data.quoteAmount * BigInt(100) / data.graduationTarget);
104
- const isGraduated = data.quoteAmount >= data.graduationTarget;
105
- return {
106
- bondingCurveAddress: bondingCurveAddress.toBase58(),
107
- baseMint: data.baseMint,
108
- quoteMint: data.quoteMint,
109
- creator: data.creator,
110
- quoteAmount: data.quoteAmount,
111
- baseAmount: data.baseAmount,
112
- startPrice: data.startPrice,
113
- endPrice: data.endPrice,
114
- graduationTarget: data.graduationTarget,
115
- launchTime: data.launchTime,
116
- graduationTime: data.graduationTime,
117
- swapFeeBps: data.swapFeeBps,
118
- isGraduated,
119
- currentPrice,
120
- progressPercent,
121
- };
122
- }
123
- catch (error) {
124
- console.error('获取 Bonding Curve 信息失败:', error);
125
- return null;
126
- }
127
- }
128
- // ============================================================================
129
- // 报价计算
130
- // ============================================================================
131
- /**
132
- * 获取买入报价
133
- */
134
- export async function getWavebreakBuyQuote(bondingCurveOrMint, amountIn, connection) {
135
- const info = await getWavebreakBondingCurveInfo(bondingCurveOrMint, connection);
136
- if (!info)
137
- return null;
138
- try {
139
- const sdk = await loadWavebreakSdk();
140
- const priceCurve = {
141
- startPrice: info.startPrice,
142
- endPrice: info.endPrice,
143
- controlPoints: [3333, 3333, 6667, 6667], // 默认线性曲线
144
- };
145
- const quote = sdk.exactInBuyQuote(priceCurve, amountIn, info.swapFeeBps, info.quoteAmount, info.graduationTarget, BigInt('18446744073709551615') // max u64
146
- );
147
- // 计算价格影响
148
- const priceImpact = amountIn > 0
149
- ? Number(quote.feeAmount) / Number(amountIn) * 100
150
- : 0;
151
- return {
152
- amountIn: quote.amountIn,
153
- amountOut: quote.amountOut,
154
- feeAmount: quote.feeAmount,
155
- priceImpact,
156
- };
157
- }
158
- catch (error) {
159
- console.error('获取买入报价失败:', error);
160
- return null;
161
- }
162
- }
163
- /**
164
- * 获取卖出报价
165
- */
166
- export async function getWavebreakSellQuote(bondingCurveOrMint, amountIn, connection) {
167
- const info = await getWavebreakBondingCurveInfo(bondingCurveOrMint, connection);
168
- if (!info)
169
- return null;
170
- try {
171
- const sdk = await loadWavebreakSdk();
172
- const priceCurve = {
173
- startPrice: info.startPrice,
174
- endPrice: info.endPrice,
175
- controlPoints: [3333, 3333, 6667, 6667],
176
- };
177
- const quote = sdk.exactInSellQuote(priceCurve, amountIn, info.swapFeeBps, info.quoteAmount, info.graduationTarget, BigInt('18446744073709551615'));
178
- const priceImpact = amountIn > 0
179
- ? Number(quote.feeAmount) / Number(amountIn) * 100
180
- : 0;
181
- return {
182
- amountIn: quote.amountIn,
183
- amountOut: quote.amountOut,
184
- feeAmount: quote.feeAmount,
185
- priceImpact,
186
- };
187
- }
188
- catch (error) {
189
- console.error('获取卖出报价失败:', error);
190
- return null;
191
- }
192
- }
193
- // ============================================================================
194
- // 指令构建
195
- // ============================================================================
196
- /**
197
- * 构建 Wavebreak 买入交易指令
198
- *
199
- * 使用 SDK 的编码器生成正确的指令数据
200
- */
201
- export async function buildWavebreakBuyInstruction(params, buyer, connection) {
202
- const conn = connection || createConnection();
203
- const sdk = await loadWavebreakSdk();
204
- const info = await getWavebreakBondingCurveInfo(params.bondingCurveOrMint, conn);
205
- if (!info) {
206
- throw new Error('Bonding Curve 不存在');
207
- }
208
- const baseMint = new PublicKey(info.baseMint);
209
- const quoteMint = new PublicKey(info.quoteMint);
210
- const bondingCurve = new PublicKey(info.bondingCurveAddress);
211
- // 获取 ATA 地址
212
- const baseAta = getAssociatedTokenAddressSync(baseMint, buyer, false, TOKEN_2022_PROGRAM_ID);
213
- const quoteAta = getAssociatedTokenAddressSync(quoteMint, buyer, false, TOKEN_PROGRAM_ID);
214
- // Quote Vault PDA
215
- const quoteVault = getWavebreakQuoteVaultAddressSync(bondingCurve);
216
- // 使用 SDK 编码器生成指令数据
217
- const encoder = sdk.getTokenBuyExactInInstructionDataEncoder();
218
- const encodedData = encoder.encode({
219
- amountIn: params.amountIn,
220
- allowPartialFill: params.allowPartialFill ?? true,
221
- priceThreshold: null, // 不设置价格阈值
222
- });
223
- // 账户顺序(从 SDK 类型定义):
224
- // 0: buyer (signer, writable)
225
- // 1: bondingCurve (writable)
226
- // 2: baseMint (writable)
227
- // 3: baseAta (writable)
228
- // 4: quoteMint (readonly)
229
- // 5: quoteVault (writable)
230
- // 6: quoteAta (writable)
231
- // 7: systemProgram (readonly)
232
- // 8: ataProgram (readonly)
233
- // 9: baseTokenProgram (readonly)
234
- // 10: quoteTokenProgram (readonly)
235
- const keys = [
236
- { pubkey: buyer, isSigner: true, isWritable: true },
237
- { pubkey: bondingCurve, isSigner: false, isWritable: true },
238
- { pubkey: baseMint, isSigner: false, isWritable: true },
239
- { pubkey: baseAta, isSigner: false, isWritable: true },
240
- { pubkey: quoteMint, isSigner: false, isWritable: false },
241
- { pubkey: quoteVault, isSigner: false, isWritable: true },
242
- { pubkey: quoteAta, isSigner: false, isWritable: true },
243
- { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
244
- { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
245
- { pubkey: TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
246
- { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
247
- ];
248
- return new TransactionInstruction({
249
- programId: new PublicKey(WAVEBREAK_CONSTANTS.PROGRAM_ID),
250
- keys,
251
- data: Buffer.from(encodedData),
252
- });
253
- }
254
- /**
255
- * 构建 Wavebreak 卖出交易指令
256
- */
257
- export async function buildWavebreakSellInstruction(params, seller, connection) {
258
- const conn = connection || createConnection();
259
- const sdk = await loadWavebreakSdk();
260
- const info = await getWavebreakBondingCurveInfo(params.bondingCurveOrMint, conn);
261
- if (!info) {
262
- throw new Error('Bonding Curve 不存在');
263
- }
264
- const baseMint = new PublicKey(info.baseMint);
265
- const quoteMint = new PublicKey(info.quoteMint);
266
- const bondingCurve = new PublicKey(info.bondingCurveAddress);
267
- const baseAta = getAssociatedTokenAddressSync(baseMint, seller, false, TOKEN_2022_PROGRAM_ID);
268
- const quoteAta = getAssociatedTokenAddressSync(quoteMint, seller, false, TOKEN_PROGRAM_ID);
269
- const quoteVault = getWavebreakQuoteVaultAddressSync(bondingCurve);
270
- // 使用 SDK 编码器
271
- const encoder = sdk.getTokenSellExactInInstructionDataEncoder();
272
- const encodedData = encoder.encode({
273
- amountIn: params.amountIn,
274
- allowPartialFill: params.allowPartialFill ?? true,
275
- priceThreshold: null,
276
- });
277
- const keys = [
278
- { pubkey: seller, isSigner: true, isWritable: true },
279
- { pubkey: bondingCurve, isSigner: false, isWritable: true },
280
- { pubkey: baseMint, isSigner: false, isWritable: true },
281
- { pubkey: baseAta, isSigner: false, isWritable: true },
282
- { pubkey: quoteMint, isSigner: false, isWritable: false },
283
- { pubkey: quoteVault, isSigner: false, isWritable: true },
284
- { pubkey: quoteAta, isSigner: false, isWritable: true },
285
- { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
286
- { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
287
- { pubkey: TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
288
- { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
289
- ];
290
- return new TransactionInstruction({
291
- programId: new PublicKey(WAVEBREAK_CONSTANTS.PROGRAM_ID),
292
- keys,
293
- data: Buffer.from(encodedData),
294
- });
295
- }
296
- /**
297
- * 构建 Wavebreak 创建代币发射指令
298
- */
299
- export async function buildWavebreakCreateLaunchInstruction(params, creator, baseMintKeypair, connection) {
300
- const sdk = await loadWavebreakSdk();
301
- const baseMint = baseMintKeypair.publicKey;
302
- const quoteMint = new PublicKey(params.quoteMint || WAVEBREAK_CONSTANTS.SOL_MINT);
303
- // 计算 PDA
304
- const bondingCurve = getWavebreakBondingCurveAddressSync(baseMint);
305
- const quoteVault = getWavebreakQuoteVaultAddressSync(bondingCurve);
306
- // Mint Config PDA
307
- const [mintConfig] = PublicKey.findProgramAddressSync([Buffer.from('mint_config')], new PublicKey(WAVEBREAK_CONSTANTS.PROGRAM_ID));
308
- // Metadata PDA
309
- const [metadata] = PublicKey.findProgramAddressSync([
310
- Buffer.from('metadata'),
311
- new PublicKey(WAVEBREAK_CONSTANTS.METAPLEX_PROGRAM_ID).toBuffer(),
312
- baseMint.toBuffer(),
313
- ], new PublicKey(WAVEBREAK_CONSTANTS.METAPLEX_PROGRAM_ID));
314
- // 使用 SDK 编码器
315
- const encoder = sdk.getCreateLaunchInstructionDataEncoder();
316
- const encodedData = encoder.encode({
317
- name: params.name,
318
- symbol: params.symbol,
319
- uri: params.uri,
320
- startPrice: params.startPrice ?? null,
321
- endPrice: params.endPrice ?? null,
322
- controlPoints: null, // 使用默认曲线
323
- graduationTarget: params.graduationTarget ?? null,
324
- graduationMethods: null, // 使用默认
325
- launchTime: params.launchTime ?? null,
326
- graduationTime: params.graduationTime ?? null,
327
- baseAllocationBps: params.baseAllocationBps ?? null,
328
- });
329
- // 账户顺序(从 SDK 类型定义):
330
- // 0: creator (signer, writable)
331
- // 1: bondingCurve (writable)
332
- // 2: baseMint (signer, writable) - 新创建的 mint
333
- // 3: quoteMint (readonly)
334
- // 4: quoteVault (writable)
335
- // 5: mintConfig (readonly)
336
- // 6: metadata (writable)
337
- // 7: systemProgram (readonly)
338
- // 8: baseTokenProgram (readonly)
339
- // 9: quoteTokenProgram (readonly)
340
- // 10: ataProgram (readonly)
341
- // 11: metaplexProgram (readonly)
342
- const keys = [
343
- { pubkey: creator, isSigner: true, isWritable: true },
344
- { pubkey: bondingCurve, isSigner: false, isWritable: true },
345
- { pubkey: baseMint, isSigner: true, isWritable: true },
346
- { pubkey: quoteMint, isSigner: false, isWritable: false },
347
- { pubkey: quoteVault, isSigner: false, isWritable: true },
348
- { pubkey: mintConfig, isSigner: false, isWritable: false },
349
- { pubkey: metadata, isSigner: false, isWritable: true },
350
- { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
351
- { pubkey: TOKEN_2022_PROGRAM_ID, isSigner: false, isWritable: false },
352
- { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
353
- { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
354
- { pubkey: new PublicKey(WAVEBREAK_CONSTANTS.METAPLEX_PROGRAM_ID), isSigner: false, isWritable: false },
355
- ];
356
- return new TransactionInstruction({
357
- programId: new PublicKey(WAVEBREAK_CONSTANTS.PROGRAM_ID),
358
- keys,
359
- data: Buffer.from(encodedData),
360
- });
361
- }
362
- // ============================================================================
363
- // 交易签名
364
- // ============================================================================
365
- /**
366
- * 签名 Wavebreak 买入交易
367
- */
368
- export async function signWavebreakBuy(params, payer, connection) {
369
- const conn = connection || createConnection();
370
- const info = await getWavebreakBondingCurveInfo(params.bondingCurveOrMint, conn);
371
- if (!info) {
372
- throw new Error('Bonding Curve 不存在');
373
- }
374
- const quote = await getWavebreakBuyQuote(params.bondingCurveOrMint, params.amountIn, conn);
375
- const tx = new Transaction();
376
- tx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 300000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
377
- const buyIx = await buildWavebreakBuyInstruction(params, payer.publicKey, conn);
378
- tx.add(buyIx);
379
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
380
- tx.recentBlockhash = blockhash;
381
- tx.lastValidBlockHeight = lastValidBlockHeight;
382
- tx.feePayer = payer.publicKey;
383
- tx.sign(payer);
384
- return {
385
- signedTransaction: tx,
386
- type: 'buy',
387
- bondingCurveAddress: info.bondingCurveAddress,
388
- baseMint: info.baseMint,
389
- metadata: {
390
- estimatedAmountOut: quote?.amountOut.toString(),
391
- feeAmount: quote?.feeAmount.toString(),
392
- },
393
- };
394
- }
395
- /**
396
- * 签名 Wavebreak 卖出交易
397
- */
398
- export async function signWavebreakSell(params, payer, connection) {
399
- const conn = connection || createConnection();
400
- const info = await getWavebreakBondingCurveInfo(params.bondingCurveOrMint, conn);
401
- if (!info) {
402
- throw new Error('Bonding Curve 不存在');
403
- }
404
- const quote = await getWavebreakSellQuote(params.bondingCurveOrMint, params.amountIn, conn);
405
- const tx = new Transaction();
406
- tx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 300000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
407
- const sellIx = await buildWavebreakSellInstruction(params, payer.publicKey, conn);
408
- tx.add(sellIx);
409
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
410
- tx.recentBlockhash = blockhash;
411
- tx.lastValidBlockHeight = lastValidBlockHeight;
412
- tx.feePayer = payer.publicKey;
413
- tx.sign(payer);
414
- return {
415
- signedTransaction: tx,
416
- type: 'sell',
417
- bondingCurveAddress: info.bondingCurveAddress,
418
- baseMint: info.baseMint,
419
- metadata: {
420
- estimatedAmountOut: quote?.amountOut.toString(),
421
- feeAmount: quote?.feeAmount.toString(),
422
- },
423
- };
424
- }
425
- /**
426
- * 签名 Wavebreak 创建代币发射交易
427
- */
428
- export async function signWavebreakCreateLaunch(params, creator, connection) {
429
- const conn = connection || createConnection();
430
- const baseMintKeypair = Keypair.generate();
431
- const bondingCurve = getWavebreakBondingCurveAddressSync(baseMintKeypair.publicKey);
432
- const tx = new Transaction();
433
- tx.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 500000 }), ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 100000 }));
434
- const createIx = await buildWavebreakCreateLaunchInstruction(params, creator.publicKey, baseMintKeypair, conn);
435
- tx.add(createIx);
436
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
437
- tx.recentBlockhash = blockhash;
438
- tx.lastValidBlockHeight = lastValidBlockHeight;
439
- tx.feePayer = creator.publicKey;
440
- tx.sign(creator, baseMintKeypair);
441
- return {
442
- signedTransaction: tx,
443
- type: 'createLaunch',
444
- bondingCurveAddress: bondingCurve.toBase58(),
445
- baseMint: baseMintKeypair.publicKey.toBase58(),
446
- baseMintKeypair,
447
- };
448
- }
449
- // ============================================================================
450
- // API 转换
451
- // ============================================================================
452
- /**
453
- * 将签名结果转换为后端 API 请求格式
454
- */
455
- export function toWavebreakApiRequest(result) {
456
- const tx = result.signedTransaction;
457
- const serialized = tx instanceof Transaction
458
- ? tx.serialize()
459
- : tx.serialize();
460
- return {
461
- transaction: Buffer.from(serialized).toString('base64'),
462
- metadata: {
463
- type: result.type,
464
- bondingCurveAddress: result.bondingCurveAddress,
465
- baseMint: result.baseMint,
466
- ...result.metadata,
467
- },
468
- };
469
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Pump.fun 模块导出
3
- * @module sol/dex/pump
4
- */
5
- export * from './types.js';
6
- export * from './pump.js';
7
- export * from './pump-swap.js';
8
- export * from './pump-bundle.js';
9
- export * from './pump-swap-bundle.js';
@@ -1,14 +0,0 @@
1
- /**
2
- * Pump.fun 模块导出
3
- * @module sol/dex/pump
4
- */
5
- // 类型
6
- export * from './types.js';
7
- // Pump 核心功能(Bonding Curve 阶段)
8
- export * from './pump.js';
9
- // Pump Swap LP 管理(Pool 阶段)
10
- export * from './pump-swap.js';
11
- // Pump Bundle 批量签名(用于 Jito - Bonding Curve 阶段)
12
- export * from './pump-bundle.js';
13
- // Pump Swap Bundle 批量签名(用于 Jito - Pool 阶段)
14
- export * from './pump-swap-bundle.js';
@@ -1,92 +0,0 @@
1
- /**
2
- * Pump.fun 批量签名(用于 Jito Bundle)
3
- * 只构建指令和签名,不发送交易,提交到后端服务器通过 Jito 广播
4
- * @module sol/dex/pump/pump-bundle
5
- */
6
- import { Connection, Keypair } from '@solana/web3.js';
7
- import type { SignedBundleData } from '../../jito/types.js';
8
- /**
9
- * 批量买入项
10
- */
11
- export interface PumpBundleBuyItem {
12
- wallet: Keypair;
13
- solAmount: bigint;
14
- }
15
- /**
16
- * 批量卖出项
17
- */
18
- export interface PumpBundleSellItem {
19
- wallet: Keypair;
20
- tokenAmount: bigint;
21
- }
22
- /**
23
- * 批量签名结果
24
- */
25
- export interface PumpBundleSignResult {
26
- success: boolean;
27
- /** 签名后的 Bundle 数据(用于提交后端) */
28
- bundleData?: SignedBundleData;
29
- /** 错误信息 */
30
- error?: string;
31
- }
32
- /**
33
- * 构建批量买入指令(用于 Jito Bundle)
34
- * 每个钱包一笔交易,最后加 Tip 交易
35
- *
36
- * @param connection Solana 连接
37
- * @param mint 代币 Mint 地址
38
- * @param buyers 买入列表
39
- * @param tipPayer Tip 支付者
40
- * @param tipLamports Tip 金额
41
- * @param slippageBps 滑点(基点)
42
- */
43
- export declare function signPumpBundleBuy(connection: Connection, params: {
44
- mint: string;
45
- buyers: PumpBundleBuyItem[];
46
- tipPayer: Keypair;
47
- tipLamports?: bigint;
48
- slippageBps?: number;
49
- }): Promise<PumpBundleSignResult>;
50
- /**
51
- * 构建批量卖出指令(用于 Jito Bundle)
52
- */
53
- export declare function signPumpBundleSell(connection: Connection, params: {
54
- mint: string;
55
- sellers: PumpBundleSellItem[];
56
- tipPayer: Keypair;
57
- tipLamports?: bigint;
58
- slippageBps?: number;
59
- }): Promise<PumpBundleSignResult>;
60
- /**
61
- * 构建创建代币 + 批量买入的 Bundle
62
- * 第一笔:创建代币 + 创建者购买
63
- * 后续:其他钱包购买
64
- * 最后:Tip
65
- */
66
- export declare function signPumpBundleCreateAndBuy(connection: Connection, params: {
67
- name: string;
68
- symbol: string;
69
- uri: string;
70
- creator: Keypair;
71
- mintKeypair?: Keypair;
72
- creatorBuyAmount?: bigint;
73
- buyers: PumpBundleBuyItem[];
74
- tipPayer: Keypair;
75
- tipLamports?: bigint;
76
- slippageBps?: number;
77
- mayhemMode?: boolean;
78
- }): Promise<PumpBundleSignResult & {
79
- mintAddress?: string;
80
- }>;
81
- /**
82
- * 将 Bundle 数据转换为后端 API 格式
83
- */
84
- export declare function toBundleApiRequest(bundleData: SignedBundleData): {
85
- transactions: string[];
86
- signatures: string[];
87
- tipAccount: string;
88
- tipLamports: string;
89
- recentBlockhash: string;
90
- lastValidBlockHeight: number;
91
- timestamp: number;
92
- };