four-flap-meme-sdk 1.2.61 → 1.2.62

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.
@@ -40,6 +40,21 @@ export async function createTokenWithBundleBuyMerkle(params) {
40
40
  const { provider, chainId } = createChainContext(config.rpcUrl);
41
41
  const devWallet = new Wallet(creatorKey, provider);
42
42
  const fourClient = new FourClient({ baseUrl: config.fourApiUrl });
43
+ // 🔍 检查创建者余额(如果创建者也是买家,需要更多余额)
44
+ const creatorBalance = await provider.getBalance(devWallet.address);
45
+ const estimatedB0 = ethers.parseEther(params.b0Amount ?? '0');
46
+ const estimatedPreSale = tokenInfo.preSale ? ethers.parseEther(tokenInfo.preSale) : 0n;
47
+ // 计算总需求:创建费用 + b0Amount + preSale + 买入金额 + 利润 + gas预估
48
+ let totalRequired = PLATFORM_CREATE_FEE + estimatedB0 + estimatedPreSale;
49
+ for (const amount of buyAmounts) {
50
+ const buyAmountWei = ethers.parseEther(amount);
51
+ const profitWei = (buyAmountWei * BigInt(30)) / 10000n; // 0.3% 利润
52
+ totalRequired += buyAmountWei + profitWei;
53
+ }
54
+ totalRequired += ethers.parseEther('0.01'); // 预留 0.01 BNB 作为 gas
55
+ if (creatorBalance < totalRequired) {
56
+ console.warn(`⚠️ 余额可能不足!当前: ${ethers.formatEther(creatorBalance)} BNB, 需要: ${ethers.formatEther(totalRequired)} BNB`);
57
+ }
43
58
  const accessToken = await loginFourClient(devWallet, fourClient);
44
59
  const imgUrl = await resolveTokenImage(fourClient, tokenInfo, accessToken);
45
60
  const createResp = await fourClient.createToken(accessToken, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.2.61",
3
+ "version": "1.2.62",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",