four-flap-meme-sdk 1.7.26 → 1.7.27

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.
@@ -52,18 +52,35 @@ function encodeCreateCallV4(params) {
52
52
  return portalIface.encodeFunctionData('newTokenV4', [params]);
53
53
  }
54
54
  /**
55
- * 编码内盘买入调用 (swapExactInputV3)
55
+ * 编码内盘买入调用
56
+ *
57
+ * 根据是否需要 extensionData 选择使用 swapExactInput 或 swapExactInputV3
58
+ * - V2 代币:使用 swapExactInput(无 extensionData)
59
+ * - V3/V4 代币:使用 swapExactInputV3(支持 extensionData)
56
60
  */
57
- function encodeFlapBuyCall(tokenAddress, inputAmount, extensionData = '0x') {
61
+ function encodeFlapBuyCall(tokenAddress, inputAmount, useV3OrV4 = false, extensionData = '0x') {
58
62
  const portalIface = new Interface(FLAP_PORTAL_ABI);
59
- return portalIface.encodeFunctionData('swapExactInputV3', [{
60
- inputToken: ZERO_ADDRESS,
61
- outputToken: tokenAddress,
62
- inputAmount,
63
- minOutputAmount: 0n,
64
- permitData: '0x',
65
- extensionData,
66
- }]);
63
+ if (useV3OrV4) {
64
+ // V3/V4 代币使用 swapExactInputV3(支持 extensionData)
65
+ return portalIface.encodeFunctionData('swapExactInputV3', [{
66
+ inputToken: ZERO_ADDRESS,
67
+ outputToken: tokenAddress,
68
+ inputAmount,
69
+ minOutputAmount: 0n,
70
+ permitData: '0x',
71
+ extensionData,
72
+ }]);
73
+ }
74
+ else {
75
+ // V2 代币使用 swapExactInput
76
+ return portalIface.encodeFunctionData('swapExactInput', [{
77
+ inputToken: ZERO_ADDRESS,
78
+ outputToken: tokenAddress,
79
+ inputAmount,
80
+ minOutputAmount: 0n,
81
+ permitData: '0x',
82
+ }]);
83
+ }
67
84
  }
68
85
  /**
69
86
  * 编码外盘 V3 买入调用
@@ -226,11 +243,12 @@ export async function bundleCreateBuy(params) {
226
243
  });
227
244
  // 3. 买家买入
228
245
  const extensionData = params.extensionData ?? '0x';
246
+ const useV3OrV4 = useV4 || useV3; // 根据代币版本选择买入函数
229
247
  for (let i = 0; i < buyerWallets.length; i++) {
230
248
  const buyerWallet = buyerWallets[i];
231
249
  const buyAmount = buyAmountsWei[i];
232
- // 使用 executeBatch 从 buyerWallet 调用 Portal.swapExactInputV3
233
- const buyData = encodeFlapBuyCall(tokenAddress, buyAmount, extensionData);
250
+ // 使用 executeBatch 从 buyerWallet 调用 Portal
251
+ const buyData = encodeFlapBuyCall(tokenAddress, buyAmount, useV3OrV4, extensionData);
234
252
  const buyBatchCall = delegateInterface.encodeFunctionData('executeBatch', [[{
235
253
  target: FLAP_PORTAL_ADDRESS,
236
254
  value: buyAmount,
@@ -347,12 +365,12 @@ export async function bundleCreateToDex(params) {
347
365
  value: params.quoteAmt ?? 0n,
348
366
  callData: createBatchCall,
349
367
  });
350
- // 3. 内盘买入
368
+ // 3. 内盘买入(一键发射始终使用 V4,所以 useV3OrV4 = true)
351
369
  const extensionData = params.extensionData ?? '0x';
352
370
  for (let i = 0; i < curveBuyerWallets.length; i++) {
353
371
  const buyerWallet = curveBuyerWallets[i];
354
372
  const buyAmount = curveBuyAmountsWei[i];
355
- const buyData = encodeFlapBuyCall(tokenAddress, buyAmount, extensionData);
373
+ const buyData = encodeFlapBuyCall(tokenAddress, buyAmount, true, extensionData);
356
374
  const buyBatchCall = delegateInterface.encodeFunctionData('executeBatch', [[{
357
375
  target: FLAP_PORTAL_ADDRESS,
358
376
  value: buyAmount,
@@ -547,9 +565,11 @@ export async function bundleGraduateBuy(params) {
547
565
  calls.push(buildProfitCall(payerWallet.address, profitAmount, profitRecipient, delegateInterface));
548
566
  }
549
567
  // 2. 内盘买入
568
+ // lpFeeProfile >= 0 表示 V3 池子,需要使用 swapExactInputV3
569
+ const useV3OrV4 = lpFeeProfile !== undefined && lpFeeProfile >= 0;
550
570
  for (let i = 0; i < curveBuyers.length; i++) {
551
571
  const { wallet, amount } = curveBuyers[i];
552
- const buyData = encodeFlapBuyCall(tokenAddress, amount, extensionData);
572
+ const buyData = encodeFlapBuyCall(tokenAddress, amount, useV3OrV4, extensionData);
553
573
  const buyBatchCall = delegateInterface.encodeFunctionData('executeBatch', [[{
554
574
  target: FLAP_PORTAL_ADDRESS,
555
575
  value: amount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.7.26",
3
+ "version": "1.7.27",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",