four-flap-meme-sdk 1.4.20 → 1.4.21

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 (103) hide show
  1. package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
  2. package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.js +0 -1
  5. package/package.json +3 -38
  6. package/dist/sol/constants.d.ts +0 -126
  7. package/dist/sol/constants.js +0 -145
  8. package/dist/sol/dex/index.d.ts +0 -8
  9. package/dist/sol/dex/index.js +0 -12
  10. package/dist/sol/dex/meteora/client.d.ts +0 -76
  11. package/dist/sol/dex/meteora/client.js +0 -219
  12. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
  13. package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
  14. package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
  15. package/dist/sol/dex/meteora/damm-v1.js +0 -315
  16. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
  17. package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
  18. package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
  19. package/dist/sol/dex/meteora/damm-v2.js +0 -632
  20. package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
  21. package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
  22. package/dist/sol/dex/meteora/dbc.d.ts +0 -192
  23. package/dist/sol/dex/meteora/dbc.js +0 -619
  24. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
  25. package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
  26. package/dist/sol/dex/meteora/dlmm.d.ts +0 -157
  27. package/dist/sol/dex/meteora/dlmm.js +0 -671
  28. package/dist/sol/dex/meteora/index.d.ts +0 -25
  29. package/dist/sol/dex/meteora/index.js +0 -65
  30. package/dist/sol/dex/meteora/types.d.ts +0 -787
  31. package/dist/sol/dex/meteora/types.js +0 -110
  32. package/dist/sol/dex/orca/index.d.ts +0 -10
  33. package/dist/sol/dex/orca/index.js +0 -16
  34. package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
  35. package/dist/sol/dex/orca/orca-bundle.js +0 -173
  36. package/dist/sol/dex/orca/orca.d.ts +0 -65
  37. package/dist/sol/dex/orca/orca.js +0 -474
  38. package/dist/sol/dex/orca/types.d.ts +0 -263
  39. package/dist/sol/dex/orca/types.js +0 -38
  40. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
  41. package/dist/sol/dex/orca/wavebreak-bundle.js +0 -198
  42. package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
  43. package/dist/sol/dex/orca/wavebreak-types.js +0 -23
  44. package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
  45. package/dist/sol/dex/orca/wavebreak.js +0 -497
  46. package/dist/sol/dex/pump/index.d.ts +0 -9
  47. package/dist/sol/dex/pump/index.js +0 -14
  48. package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
  49. package/dist/sol/dex/pump/pump-bundle.js +0 -383
  50. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
  51. package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
  52. package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
  53. package/dist/sol/dex/pump/pump-swap.js +0 -199
  54. package/dist/sol/dex/pump/pump.d.ts +0 -35
  55. package/dist/sol/dex/pump/pump.js +0 -352
  56. package/dist/sol/dex/pump/types.d.ts +0 -215
  57. package/dist/sol/dex/pump/types.js +0 -5
  58. package/dist/sol/dex/raydium/index.d.ts +0 -8
  59. package/dist/sol/dex/raydium/index.js +0 -12
  60. package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
  61. package/dist/sol/dex/raydium/launchlab.js +0 -210
  62. package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
  63. package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
  64. package/dist/sol/dex/raydium/raydium.d.ts +0 -40
  65. package/dist/sol/dex/raydium/raydium.js +0 -366
  66. package/dist/sol/dex/raydium/types.d.ts +0 -240
  67. package/dist/sol/dex/raydium/types.js +0 -5
  68. package/dist/sol/index.d.ts +0 -10
  69. package/dist/sol/index.js +0 -16
  70. package/dist/sol/jito/bundle.d.ts +0 -90
  71. package/dist/sol/jito/bundle.js +0 -263
  72. package/dist/sol/jito/index.d.ts +0 -7
  73. package/dist/sol/jito/index.js +0 -7
  74. package/dist/sol/jito/tip.d.ts +0 -51
  75. package/dist/sol/jito/tip.js +0 -83
  76. package/dist/sol/jito/types.d.ts +0 -100
  77. package/dist/sol/jito/types.js +0 -5
  78. package/dist/sol/token/create-complete.d.ts +0 -115
  79. package/dist/sol/token/create-complete.js +0 -235
  80. package/dist/sol/token/create-token.d.ts +0 -57
  81. package/dist/sol/token/create-token.js +0 -230
  82. package/dist/sol/token/index.d.ts +0 -9
  83. package/dist/sol/token/index.js +0 -14
  84. package/dist/sol/token/metadata-upload.d.ts +0 -86
  85. package/dist/sol/token/metadata-upload.js +0 -173
  86. package/dist/sol/token/metadata.d.ts +0 -92
  87. package/dist/sol/token/metadata.js +0 -274
  88. package/dist/sol/token/types.d.ts +0 -153
  89. package/dist/sol/token/types.js +0 -5
  90. package/dist/sol/types.d.ts +0 -176
  91. package/dist/sol/types.js +0 -7
  92. package/dist/sol/utils/balance.d.ts +0 -160
  93. package/dist/sol/utils/balance.js +0 -638
  94. package/dist/sol/utils/connection.d.ts +0 -78
  95. package/dist/sol/utils/connection.js +0 -168
  96. package/dist/sol/utils/index.d.ts +0 -9
  97. package/dist/sol/utils/index.js +0 -9
  98. package/dist/sol/utils/lp-inspect.d.ts +0 -129
  99. package/dist/sol/utils/lp-inspect.js +0 -900
  100. package/dist/sol/utils/transfer.d.ts +0 -125
  101. package/dist/sol/utils/transfer.js +0 -220
  102. package/dist/sol/utils/wallet.d.ts +0 -107
  103. package/dist/sol/utils/wallet.js +0 -210
@@ -1,619 +0,0 @@
1
- /**
2
- * Meteora Dynamic Bonding Curve (DBC) 集成
3
- *
4
- * 基于 https://github.com/MeteoraAg/dynamic-bonding-curve-sdk 源码分析
5
- * DBC 是 Meteora 的代币发射平台,类似于 Pump.fun
6
- */
7
- import { PublicKey, } from '@solana/web3.js';
8
- import BN from 'bn.js';
9
- import { getCurrentPoint } from '@meteora-ag/dynamic-bonding-curve-sdk';
10
- import { getConnection, getDbcClient } from './client.js';
11
- // ============================================================================
12
- // 池信息查询
13
- // ============================================================================
14
- /**
15
- * 获取 DBC 池信息
16
- * @param poolAddress 池地址
17
- * @param connection 可选连接
18
- */
19
- export async function getDbcPoolInfo(poolAddress, connection) {
20
- const client = getDbcClient(connection);
21
- const poolPubkey = new PublicKey(poolAddress);
22
- const poolState = await client.state.getPool(poolPubkey);
23
- const configState = await client.state.getPoolConfig(poolState.config);
24
- // 计算当前价格
25
- const currentSqrtPrice = poolState.sqrtPrice;
26
- const baseDecimals = 9;
27
- const quoteDecimals = 9;
28
- const sqrtPriceNum = currentSqrtPrice.toNumber() / Math.pow(2, 64);
29
- const currentPrice = sqrtPriceNum * sqrtPriceNum * Math.pow(10, quoteDecimals - baseDecimals);
30
- // 计算进度
31
- const quoteReserve = poolState.quoteReserve;
32
- const migrationThreshold = configState.migrationQuoteThreshold;
33
- const progressPercent = migrationThreshold.gt(new BN(0))
34
- ? (quoteReserve.toNumber() / migrationThreshold.toNumber()) * 100
35
- : 0;
36
- return {
37
- poolAddress,
38
- configAddress: poolState.config.toBase58(),
39
- baseMint: poolState.baseMint.toBase58(),
40
- quoteMint: configState.quoteMint.toBase58(),
41
- creator: poolState.creator.toBase58(),
42
- baseReserve: poolState.baseReserve.toString(),
43
- quoteReserve: poolState.quoteReserve.toString(),
44
- currentPrice,
45
- migrationQuoteThreshold: migrationThreshold.toString(),
46
- isMigrated: quoteReserve.gte(migrationThreshold),
47
- progressPercent: Math.min(progressPercent, 100),
48
- totalSupply: poolState.baseReserve.toString(),
49
- circulatingSupply: '0',
50
- };
51
- }
52
- /**
53
- * 通过 Base Mint 查找 DBC 池
54
- * @param baseMint Base Mint 地址
55
- * @param connection 可选连接
56
- */
57
- export async function findDbcPoolByBaseMint(baseMint, connection) {
58
- const client = getDbcClient(connection);
59
- try {
60
- const pool = await client.state.getPoolByBaseMint(baseMint);
61
- if (pool) {
62
- return pool.publicKey.toBase58();
63
- }
64
- }
65
- catch (e) {
66
- // 池不存在
67
- }
68
- return null;
69
- }
70
- // ============================================================================
71
- // Swap 报价
72
- // ============================================================================
73
- /**
74
- * 获取 DBC Swap 报价
75
- * @param params Swap 参数
76
- * @param connection 可选连接
77
- */
78
- export async function getDbcSwapQuote(params, connection) {
79
- const conn = getConnection(connection);
80
- const client = getDbcClient(connection);
81
- const poolPubkey = new PublicKey(params.poolAddress);
82
- const poolState = await client.state.getPool(poolPubkey);
83
- const configState = await client.state.getPoolConfig(poolState.config);
84
- const currentPoint = await getCurrentPoint(conn, configState.activationType);
85
- const quote = client.pool.swapQuote({
86
- virtualPool: poolState,
87
- config: configState,
88
- swapBaseForQuote: !params.isBuy,
89
- amountIn: params.amountIn,
90
- hasReferral: false,
91
- currentPoint,
92
- slippageBps: params.slippageBps || 100,
93
- });
94
- return {
95
- amountIn: params.amountIn,
96
- amountOut: quote.outputAmount,
97
- fee: quote.tradingFee,
98
- nextSqrtPrice: quote.nextSqrtPrice,
99
- };
100
- }
101
- // ============================================================================
102
- // Swap 签名
103
- // ============================================================================
104
- /**
105
- * 签名 DBC Swap 交易
106
- * @param params Swap 参数
107
- * @param wallet 钱包
108
- * @param connection 可选连接
109
- */
110
- export async function signDbcSwap(params, wallet, connection) {
111
- const conn = getConnection(connection);
112
- const client = getDbcClient(connection);
113
- const poolPubkey = new PublicKey(params.poolAddress);
114
- const swapTx = await client.pool.swap({
115
- owner: wallet.publicKey,
116
- pool: poolPubkey,
117
- amountIn: params.amountIn,
118
- minimumAmountOut: params.minAmountOut,
119
- swapBaseForQuote: !params.isBuy,
120
- referralTokenAccount: null,
121
- });
122
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
123
- swapTx.recentBlockhash = blockhash;
124
- swapTx.lastValidBlockHeight = lastValidBlockHeight;
125
- swapTx.feePayer = wallet.publicKey;
126
- swapTx.sign(wallet);
127
- return {
128
- signedTransaction: swapTx,
129
- type: params.isBuy ? 'dbc_buy' : 'dbc_sell',
130
- poolAddress: params.poolAddress,
131
- metadata: {
132
- amountIn: params.amountIn.toString(),
133
- minAmountOut: params.minAmountOut.toString(),
134
- isBuy: params.isBuy,
135
- },
136
- };
137
- }
138
- // ============================================================================
139
- // 迁移功能
140
- // ============================================================================
141
- /**
142
- * 签名迁移到 DAMM V1 交易
143
- */
144
- export async function signDbcMigrateToDammV1(poolAddress, dammConfig, wallet, connection) {
145
- const conn = getConnection(connection);
146
- const client = getDbcClient(connection);
147
- const poolPubkey = new PublicKey(poolAddress);
148
- const migrateTx = await client.migration.migrateToDammV1({
149
- payer: wallet.publicKey,
150
- virtualPool: poolPubkey,
151
- dammConfig: new PublicKey(dammConfig),
152
- });
153
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
154
- migrateTx.recentBlockhash = blockhash;
155
- migrateTx.lastValidBlockHeight = lastValidBlockHeight;
156
- migrateTx.feePayer = wallet.publicKey;
157
- migrateTx.sign(wallet);
158
- return {
159
- signedTransaction: migrateTx,
160
- type: 'dbc_migrate_damm_v1',
161
- poolAddress,
162
- metadata: { dammConfig },
163
- };
164
- }
165
- /**
166
- * 签名迁移到 DAMM V2 交易
167
- */
168
- export async function signDbcMigrateToDammV2(poolAddress, dammV2Config, wallet, connection) {
169
- const conn = getConnection(connection);
170
- const client = getDbcClient(connection);
171
- const poolPubkey = new PublicKey(poolAddress);
172
- const migrateResponse = await client.migration.migrateToDammV2({
173
- payer: wallet.publicKey,
174
- virtualPool: poolPubkey,
175
- dammConfig: new PublicKey(dammV2Config),
176
- });
177
- const tx = migrateResponse.transaction;
178
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
179
- tx.recentBlockhash = blockhash;
180
- tx.lastValidBlockHeight = lastValidBlockHeight;
181
- tx.feePayer = wallet.publicKey;
182
- tx.sign(wallet);
183
- return {
184
- signedTransaction: tx,
185
- type: 'dbc_migrate_damm_v2',
186
- poolAddress,
187
- metadata: { dammV2Config },
188
- };
189
- }
190
- // ============================================================================
191
- // 费用领取
192
- // ============================================================================
193
- /**
194
- * 签名领取创建者交易费
195
- */
196
- export async function signDbcClaimCreatorFee(poolAddress, wallet, maxBaseAmount, maxQuoteAmount, connection) {
197
- const conn = getConnection(connection);
198
- const client = getDbcClient(connection);
199
- const poolPubkey = new PublicKey(poolAddress);
200
- const claimTx = await client.creator.claimCreatorTradingFee({
201
- creator: wallet.publicKey,
202
- payer: wallet.publicKey,
203
- pool: poolPubkey,
204
- maxBaseAmount,
205
- maxQuoteAmount,
206
- });
207
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
208
- claimTx.recentBlockhash = blockhash;
209
- claimTx.lastValidBlockHeight = lastValidBlockHeight;
210
- claimTx.feePayer = wallet.publicKey;
211
- claimTx.sign(wallet);
212
- return {
213
- signedTransaction: claimTx,
214
- type: 'dbc_claim_creator_fee',
215
- poolAddress,
216
- metadata: {
217
- maxBaseAmount: maxBaseAmount.toString(),
218
- maxQuoteAmount: maxQuoteAmount.toString(),
219
- },
220
- };
221
- }
222
- /**
223
- * 签名领取 Partner 交易费
224
- */
225
- export async function signDbcClaimPartnerFee(poolAddress, wallet, maxBaseAmount, maxQuoteAmount, connection) {
226
- const conn = getConnection(connection);
227
- const client = getDbcClient(connection);
228
- const poolPubkey = new PublicKey(poolAddress);
229
- const claimTx = await client.partner.claimPartnerTradingFee({
230
- feeClaimer: wallet.publicKey,
231
- payer: wallet.publicKey,
232
- pool: poolPubkey,
233
- maxBaseAmount,
234
- maxQuoteAmount,
235
- });
236
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
237
- claimTx.recentBlockhash = blockhash;
238
- claimTx.lastValidBlockHeight = lastValidBlockHeight;
239
- claimTx.feePayer = wallet.publicKey;
240
- claimTx.sign(wallet);
241
- return {
242
- signedTransaction: claimTx,
243
- type: 'dbc_claim_partner_fee',
244
- poolAddress,
245
- metadata: {
246
- maxBaseAmount: maxBaseAmount.toString(),
247
- maxQuoteAmount: maxQuoteAmount.toString(),
248
- },
249
- };
250
- }
251
- // ============================================================================
252
- // Vesting 锁仓
253
- // ============================================================================
254
- /**
255
- * 签名创建锁仓交易
256
- */
257
- export async function signDbcCreateLocker(poolAddress, wallet, connection) {
258
- const conn = getConnection(connection);
259
- const client = getDbcClient(connection);
260
- const poolPubkey = new PublicKey(poolAddress);
261
- const lockerTx = await client.migration.createLocker({
262
- payer: wallet.publicKey,
263
- virtualPool: poolPubkey,
264
- });
265
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
266
- lockerTx.recentBlockhash = blockhash;
267
- lockerTx.lastValidBlockHeight = lastValidBlockHeight;
268
- lockerTx.feePayer = wallet.publicKey;
269
- lockerTx.sign(wallet);
270
- return {
271
- signedTransaction: lockerTx,
272
- type: 'dbc_create_locker',
273
- poolAddress,
274
- metadata: {},
275
- };
276
- }
277
- /**
278
- * 计算锁仓 Vesting 参数
279
- */
280
- export function calculateLockedVestingParams(totalVestingAmount, cliffDurationSeconds, vestingDurationSeconds, vestingFrequencySeconds, cliffUnlockPercent) {
281
- const numberOfPeriod = Math.floor(vestingDurationSeconds / vestingFrequencySeconds);
282
- const cliffUnlockAmount = totalVestingAmount.muln(cliffUnlockPercent).divn(100);
283
- const remainingAmount = totalVestingAmount.sub(cliffUnlockAmount);
284
- const amountPerPeriod = remainingAmount.divn(numberOfPeriod);
285
- return {
286
- amountPerPeriod,
287
- cliffDurationFromMigrationTime: new BN(cliffDurationSeconds),
288
- frequency: new BN(vestingFrequencySeconds),
289
- numberOfPeriod: new BN(numberOfPeriod),
290
- cliffUnlockAmount,
291
- };
292
- }
293
- // ============================================================================
294
- // 创建配置和池
295
- // ============================================================================
296
- /**
297
- * 签名创建 DBC Config 交易
298
- * @param params 配置参数
299
- * @param configKeypair Config Keypair
300
- * @param wallet 钱包
301
- * @param connection 可选连接
302
- */
303
- export async function signDbcCreateConfig(params, configKeypair, wallet, connection) {
304
- const conn = getConnection(connection);
305
- const client = getDbcClient(connection);
306
- const createConfigTx = await client.partner.createConfig({
307
- payer: wallet.publicKey,
308
- config: configKeypair.publicKey,
309
- feeClaimer: new PublicKey(params.feeClaimer),
310
- leftoverReceiver: new PublicKey(params.leftoverReceiver),
311
- quoteMint: new PublicKey(params.quoteMint),
312
- poolFees: params.poolFees,
313
- activationType: params.activationType,
314
- collectFeeMode: params.collectFeeMode,
315
- migrationOption: params.migrationOption,
316
- tokenType: params.tokenType,
317
- tokenDecimal: params.tokenDecimal,
318
- migrationQuoteThreshold: params.migrationQuoteThreshold,
319
- partnerLpPercentage: params.partnerLpPercentage,
320
- creatorLpPercentage: params.creatorLpPercentage,
321
- partnerLockedLpPercentage: params.partnerLockedLpPercentage,
322
- creatorLockedLpPercentage: params.creatorLockedLpPercentage,
323
- sqrtStartPrice: params.sqrtStartPrice,
324
- lockedVesting: params.lockedVesting,
325
- migrationFeeOption: params.migrationFeeOption,
326
- tokenSupply: params.tokenSupply,
327
- creatorTradingFeePercentage: params.creatorTradingFeePercentage,
328
- tokenUpdateAuthority: params.tokenUpdateAuthority,
329
- migrationFee: params.migrationFee,
330
- migratedPoolFee: params.migratedPoolFee || { collectFeeMode: 0, dynamicFee: 0, poolFeeBps: 0 },
331
- padding: [],
332
- curve: params.curve,
333
- });
334
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
335
- createConfigTx.recentBlockhash = blockhash;
336
- createConfigTx.lastValidBlockHeight = lastValidBlockHeight;
337
- createConfigTx.feePayer = wallet.publicKey;
338
- createConfigTx.sign(wallet, configKeypair);
339
- return {
340
- signedTransaction: createConfigTx,
341
- type: 'dbc_create_config',
342
- metadata: {
343
- config: configKeypair.publicKey.toBase58(),
344
- },
345
- };
346
- }
347
- /**
348
- * 签名创建 DBC Pool 交易
349
- * @param params 创建池参数
350
- * @param baseMintKeypair Base Mint Keypair
351
- * @param wallet 钱包
352
- * @param connection 可选连接
353
- */
354
- export async function signDbcCreatePool(params, baseMintKeypair, wallet, connection) {
355
- const conn = getConnection(connection);
356
- const client = getDbcClient(connection);
357
- const createPoolTx = await client.pool.createPool({
358
- baseMint: baseMintKeypair.publicKey,
359
- config: new PublicKey(params.config),
360
- name: params.name,
361
- symbol: params.symbol,
362
- uri: params.uri,
363
- payer: wallet.publicKey,
364
- poolCreator: wallet.publicKey,
365
- });
366
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
367
- createPoolTx.recentBlockhash = blockhash;
368
- createPoolTx.lastValidBlockHeight = lastValidBlockHeight;
369
- createPoolTx.feePayer = wallet.publicKey;
370
- createPoolTx.sign(wallet, baseMintKeypair);
371
- // 派生池地址
372
- const [poolAddress] = PublicKey.findProgramAddressSync([Buffer.from('pool'), baseMintKeypair.publicKey.toBuffer()], new PublicKey('dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN'));
373
- return {
374
- signedTransaction: createPoolTx,
375
- type: 'dbc_create_pool',
376
- poolAddress: poolAddress.toBase58(),
377
- metadata: {
378
- baseMint: baseMintKeypair.publicKey.toBase58(),
379
- name: params.name,
380
- symbol: params.symbol,
381
- },
382
- };
383
- }
384
- /**
385
- * 签名创建 DBC Pool 并首次买入交易
386
- * @param params 创建池并买入参数
387
- * @param baseMintKeypair Base Mint Keypair
388
- * @param wallet 钱包
389
- * @param connection 可选连接
390
- */
391
- export async function signDbcCreatePoolWithFirstBuy(params, baseMintKeypair, wallet, connection) {
392
- const conn = getConnection(connection);
393
- const client = getDbcClient(connection);
394
- const { createPoolTx, swapBuyTx } = await client.pool.createPoolWithFirstBuy({
395
- createPoolParam: {
396
- baseMint: baseMintKeypair.publicKey,
397
- config: new PublicKey(params.config),
398
- name: params.name,
399
- symbol: params.symbol,
400
- uri: params.uri,
401
- payer: wallet.publicKey,
402
- poolCreator: wallet.publicKey,
403
- },
404
- firstBuyParam: {
405
- buyer: wallet.publicKey,
406
- buyAmount: params.buyAmount,
407
- minimumAmountOut: params.minimumAmountOut || new BN(1),
408
- referralTokenAccount: null,
409
- },
410
- });
411
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
412
- // 签名创建池交易
413
- createPoolTx.recentBlockhash = blockhash;
414
- createPoolTx.lastValidBlockHeight = lastValidBlockHeight;
415
- createPoolTx.feePayer = wallet.publicKey;
416
- createPoolTx.sign(wallet, baseMintKeypair);
417
- // 派生池地址
418
- const [poolAddress] = PublicKey.findProgramAddressSync([Buffer.from('pool'), baseMintKeypair.publicKey.toBuffer()], new PublicKey('dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN'));
419
- const createPoolResult = {
420
- signedTransaction: createPoolTx,
421
- type: 'dbc_create_pool',
422
- poolAddress: poolAddress.toBase58(),
423
- metadata: {
424
- baseMint: baseMintKeypair.publicKey.toBase58(),
425
- name: params.name,
426
- symbol: params.symbol,
427
- },
428
- };
429
- let buyResult;
430
- if (swapBuyTx) {
431
- swapBuyTx.recentBlockhash = blockhash;
432
- swapBuyTx.lastValidBlockHeight = lastValidBlockHeight;
433
- swapBuyTx.feePayer = wallet.publicKey;
434
- swapBuyTx.sign(wallet);
435
- buyResult = {
436
- signedTransaction: swapBuyTx,
437
- type: 'dbc_first_buy',
438
- poolAddress: poolAddress.toBase58(),
439
- metadata: {
440
- buyAmount: params.buyAmount.toString(),
441
- },
442
- };
443
- }
444
- return { createPoolResult, buyResult };
445
- }
446
- // ============================================================================
447
- // 费用提取
448
- // ============================================================================
449
- /**
450
- * 签名 Partner 提取迁移费用交易
451
- */
452
- export async function signDbcPartnerWithdrawMigrationFee(poolAddress, wallet, connection) {
453
- const conn = getConnection(connection);
454
- const client = getDbcClient(connection);
455
- const withdrawTx = await client.partner.partnerWithdrawMigrationFee({
456
- virtualPool: new PublicKey(poolAddress),
457
- sender: wallet.publicKey,
458
- });
459
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
460
- withdrawTx.recentBlockhash = blockhash;
461
- withdrawTx.lastValidBlockHeight = lastValidBlockHeight;
462
- withdrawTx.feePayer = wallet.publicKey;
463
- withdrawTx.sign(wallet);
464
- return {
465
- signedTransaction: withdrawTx,
466
- type: 'dbc_partner_withdraw_migration_fee',
467
- poolAddress,
468
- metadata: {},
469
- };
470
- }
471
- /**
472
- * 签名 Partner 提取剩余资金交易
473
- */
474
- export async function signDbcPartnerWithdrawSurplus(poolAddress, wallet, connection) {
475
- const conn = getConnection(connection);
476
- const client = getDbcClient(connection);
477
- const withdrawTx = await client.partner.partnerWithdrawSurplus({
478
- feeClaimer: wallet.publicKey,
479
- virtualPool: new PublicKey(poolAddress),
480
- });
481
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
482
- withdrawTx.recentBlockhash = blockhash;
483
- withdrawTx.lastValidBlockHeight = lastValidBlockHeight;
484
- withdrawTx.feePayer = wallet.publicKey;
485
- withdrawTx.sign(wallet);
486
- return {
487
- signedTransaction: withdrawTx,
488
- type: 'dbc_partner_withdraw_surplus',
489
- poolAddress,
490
- metadata: {},
491
- };
492
- }
493
- /**
494
- * 签名 Creator 提取迁移费用交易
495
- */
496
- export async function signDbcCreatorWithdrawMigrationFee(poolAddress, wallet, connection) {
497
- const conn = getConnection(connection);
498
- const client = getDbcClient(connection);
499
- const withdrawTx = await client.creator.creatorWithdrawMigrationFee({
500
- virtualPool: new PublicKey(poolAddress),
501
- sender: wallet.publicKey,
502
- });
503
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
504
- withdrawTx.recentBlockhash = blockhash;
505
- withdrawTx.lastValidBlockHeight = lastValidBlockHeight;
506
- withdrawTx.feePayer = wallet.publicKey;
507
- withdrawTx.sign(wallet);
508
- return {
509
- signedTransaction: withdrawTx,
510
- type: 'dbc_creator_withdraw_migration_fee',
511
- poolAddress,
512
- metadata: {},
513
- };
514
- }
515
- /**
516
- * 签名 Creator 提取剩余资金交易
517
- */
518
- export async function signDbcCreatorWithdrawSurplus(poolAddress, wallet, connection) {
519
- const conn = getConnection(connection);
520
- const client = getDbcClient(connection);
521
- const withdrawTx = await client.creator.creatorWithdrawSurplus({
522
- creator: wallet.publicKey,
523
- virtualPool: new PublicKey(poolAddress),
524
- });
525
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
526
- withdrawTx.recentBlockhash = blockhash;
527
- withdrawTx.lastValidBlockHeight = lastValidBlockHeight;
528
- withdrawTx.feePayer = wallet.publicKey;
529
- withdrawTx.sign(wallet);
530
- return {
531
- signedTransaction: withdrawTx,
532
- type: 'dbc_creator_withdraw_surplus',
533
- poolAddress,
534
- metadata: {},
535
- };
536
- }
537
- // ============================================================================
538
- // Vesting 相关
539
- // ============================================================================
540
- /**
541
- * 签名领取迁移后的 LP Token (用于 DAMM V1 迁移)
542
- * 当池子迁移到 DAMM V1 后,创建者或合作伙伴可以通过此方法领取锁定的 LP Token
543
- * @param poolAddress 池地址
544
- * @param dammConfig DAMM 配置地址
545
- * @param isPartner 是否是合作伙伴领取
546
- * @param wallet 钱包
547
- * @param connection 可选连接
548
- */
549
- export async function signDbcClaimDammV1LpToken(poolAddress, dammConfig, isPartner, wallet, connection) {
550
- const conn = getConnection(connection);
551
- const client = getDbcClient(connection);
552
- const poolPubkey = new PublicKey(poolAddress);
553
- // 使用 migration 服务领取 DAMM V1 LP Token
554
- const claimTx = await client.migration.claimDammV1LpToken({
555
- payer: wallet.publicKey,
556
- virtualPool: poolPubkey,
557
- dammConfig: new PublicKey(dammConfig),
558
- isPartner,
559
- });
560
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
561
- claimTx.recentBlockhash = blockhash;
562
- claimTx.lastValidBlockHeight = lastValidBlockHeight;
563
- claimTx.feePayer = wallet.publicKey;
564
- claimTx.sign(wallet);
565
- return {
566
- signedTransaction: claimTx,
567
- type: 'dbc_claim_damm_v1_lp_token',
568
- poolAddress,
569
- metadata: {
570
- dammConfig,
571
- isPartner,
572
- },
573
- };
574
- }
575
- // ============================================================================
576
- // 状态查询
577
- // ============================================================================
578
- /**
579
- * 获取 DBC Config 信息
580
- */
581
- export async function getDbcConfigInfo(configAddress, connection) {
582
- const client = getDbcClient(connection);
583
- const configState = await client.state.getPoolConfig(new PublicKey(configAddress));
584
- return configState;
585
- }
586
- /**
587
- * 获取所有 DBC 池
588
- */
589
- export async function getAllDbcPools(connection) {
590
- const client = getDbcClient(connection);
591
- const pools = await client.state.getPools();
592
- return pools;
593
- }
594
- /**
595
- * 获取用户在 DBC 池中的余额
596
- */
597
- export async function getDbcUserBalance(poolAddress, userAddress, connection) {
598
- const conn = getConnection(connection);
599
- const client = getDbcClient(connection);
600
- const poolPubkey = new PublicKey(poolAddress);
601
- const userPubkey = new PublicKey(userAddress);
602
- const poolState = await client.state.getPool(poolPubkey);
603
- // 获取用户的 Base Token 余额
604
- const { getAssociatedTokenAddressSync } = await import('@solana/spl-token');
605
- try {
606
- const baseAta = getAssociatedTokenAddressSync(poolState.baseMint, userPubkey);
607
- const baseAccount = await conn.getTokenAccountBalance(baseAta);
608
- return {
609
- baseBalance: baseAccount.value.amount,
610
- quoteBalance: '0', // Quote 余额需要单独查询
611
- };
612
- }
613
- catch {
614
- return {
615
- baseBalance: '0',
616
- quoteBalance: '0',
617
- };
618
- }
619
- }
@@ -1,39 +0,0 @@
1
- /**
2
- * Meteora DLMM Bundle 批量交易
3
- *
4
- * 支持 Jito Bundle 的批量买卖
5
- */
6
- import { Connection } from '@solana/web3.js';
7
- import type { DlmmBundleSwapParams, MeteoraBundleSignedResult } from './types.js';
8
- /**
9
- * 签名 DLMM Bundle 批量买入交易
10
- *
11
- * @param params Bundle 参数
12
- * @param connection 可选连接
13
- */
14
- export declare function signDlmmBundleBuy(params: DlmmBundleSwapParams, connection?: Connection): Promise<MeteoraBundleSignedResult>;
15
- /**
16
- * 签名 DLMM Bundle 批量卖出交易
17
- *
18
- * @param params Bundle 参数
19
- * @param connection 可选连接
20
- */
21
- export declare function signDlmmBundleSell(params: DlmmBundleSwapParams, connection?: Connection): Promise<MeteoraBundleSignedResult>;
22
- /**
23
- * 签名 DLMM Bundle 通用 Swap 交易
24
- *
25
- * @param params Bundle 参数
26
- * @param swapForY 是否用 X 换 Y (true = 卖出, false = 买入)
27
- * @param connection 可选连接
28
- */
29
- export declare function signDlmmBundleSwap(params: DlmmBundleSwapParams, swapForY: boolean, connection?: Connection): Promise<MeteoraBundleSignedResult>;
30
- /**
31
- * 将 Bundle 结果转换为后端 API 请求格式
32
- */
33
- export declare function toDlmmBundleApiRequest(result: MeteoraBundleSignedResult): {
34
- transactions: string[];
35
- type: string;
36
- poolAddress: string;
37
- tradeCount: number;
38
- jitoTipLamports: number;
39
- };