four-flap-meme-sdk 1.2.84 → 1.2.85
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.
|
@@ -84,27 +84,8 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
84
84
|
const signedTxs = [];
|
|
85
85
|
const tmCreateAddr = ADDRESSES.BSC.TokenManagerOriginal;
|
|
86
86
|
const tmBuyAddr = ADDRESSES.BSC.TokenManagerOriginal;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const valueWei = PLATFORM_CREATE_FEE + b0AmountWei + preSaleWei;
|
|
90
|
-
const tmCreate = new ethers.Contract(tmCreateAddr, TM2_ABI, devWallet);
|
|
91
|
-
const createTxUnsigned = await tmCreate.createToken.populateTransaction(createResp.createArg, createResp.signature, { value: valueWei });
|
|
92
|
-
const createTxRequest = {
|
|
93
|
-
...createTxUnsigned,
|
|
94
|
-
from: devWallet.address,
|
|
95
|
-
nonce: await nonceManager.getNextNonce(devWallet),
|
|
96
|
-
gasLimit: getGasLimit(config),
|
|
97
|
-
gasPrice,
|
|
98
|
-
chainId,
|
|
99
|
-
type: getTxType(config),
|
|
100
|
-
value: valueWei
|
|
101
|
-
};
|
|
102
|
-
signedTxs.push(await devWallet.signTransaction(createTxRequest));
|
|
103
|
-
// ✅ Four.meme Bundle 机制:使用 0x0 地址作为占位符
|
|
104
|
-
// ⚠️ 关键:这2笔交易必须在同一个 Bundle 中原子执行!
|
|
105
|
-
const predictedTokenAddress = ZERO_ADDRESS;
|
|
106
|
-
console.log('✅ 使用 Four.meme Bundle 机制:0x0 地址将在 Bundle 执行时被解析为新创建的代币地址');
|
|
107
|
-
// ✅ 生成创建者的买入交易 (支持利润刮取)
|
|
87
|
+
// ✅ 单笔交易: 和 Four.meme 官网一样
|
|
88
|
+
// 计算利润
|
|
108
89
|
const extractProfit = shouldExtractProfit(config);
|
|
109
90
|
const originalBuyAmount = ethers.parseEther(buyAmounts[0]);
|
|
110
91
|
let actualBuyFunds;
|
|
@@ -119,24 +100,26 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
119
100
|
actualBuyFunds = originalBuyAmount;
|
|
120
101
|
profitAmount = 0n;
|
|
121
102
|
}
|
|
122
|
-
const
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
{ value:
|
|
129
|
-
|
|
130
|
-
|
|
103
|
+
const b0AmountWei = ethers.parseEther(params.b0Amount ?? '0');
|
|
104
|
+
const preSaleWei = tokenInfo.preSale ? ethers.parseEther(tokenInfo.preSale) : 0n;
|
|
105
|
+
// ✅ 关键: value = 创建费用 + b0Amount + preSale + 买入金额
|
|
106
|
+
// Four.meme 合约会自动处理: 如果 value > 创建费用,会自动用多余的金额买入
|
|
107
|
+
const valueWei = PLATFORM_CREATE_FEE + b0AmountWei + preSaleWei + actualBuyFunds;
|
|
108
|
+
const tmCreate = new ethers.Contract(tmCreateAddr, TM2_ABI, devWallet);
|
|
109
|
+
const createTxUnsigned = await tmCreate.createToken.populateTransaction(createResp.createArg, createResp.signature, { value: valueWei } // ✅ 包含买入金额
|
|
110
|
+
);
|
|
111
|
+
const createTxRequest = {
|
|
112
|
+
...createTxUnsigned,
|
|
131
113
|
from: devWallet.address,
|
|
132
114
|
nonce: await nonceManager.getNextNonce(devWallet),
|
|
133
|
-
gasLimit: getGasLimit(config),
|
|
115
|
+
gasLimit: getGasLimit(config, 1500000), // ✅ 增加 gas limit (创建+买入)
|
|
134
116
|
gasPrice,
|
|
135
117
|
chainId,
|
|
136
|
-
type:
|
|
137
|
-
value:
|
|
118
|
+
type: getTxType(config),
|
|
119
|
+
value: valueWei
|
|
138
120
|
};
|
|
139
|
-
signedTxs.push(await devWallet.signTransaction(
|
|
121
|
+
signedTxs.push(await devWallet.signTransaction(createTxRequest));
|
|
122
|
+
console.log(`✅ 生成创建+买入交易: value = ${ethers.formatEther(valueWei)} BNB (0.01创建 + ${ethers.formatEther(actualBuyFunds)}买入)`);
|
|
140
123
|
// ✅ 添加利润转账交易
|
|
141
124
|
if (extractProfit && profitAmount > 0n) {
|
|
142
125
|
const profitNonce = await nonceManager.getNextNonce(devWallet);
|
|
@@ -153,10 +136,10 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
153
136
|
console.log(`💸 利润转账交易已生成: ${ethers.formatEther(profitAmount)} BNB → ${getProfitRecipient()}`);
|
|
154
137
|
}
|
|
155
138
|
nonceManager.clearTemp();
|
|
156
|
-
console.log(`✅ 总共生成了 ${signedTxs.length} 个交易签名 (1
|
|
139
|
+
console.log(`✅ 总共生成了 ${signedTxs.length} 个交易签名 (1创建+买入${extractProfit && profitAmount > 0n ? ' + 1利润' : ''})`);
|
|
157
140
|
// ⚠️ 只返回签名交易,不提交
|
|
158
141
|
console.log('📦 交易已签名完成');
|
|
159
|
-
console.log('
|
|
142
|
+
console.log('💡 提示: 可以通过 Merkle Bundle 提交,或直接 broadcastTransaction');
|
|
160
143
|
// 构建元数据
|
|
161
144
|
const metadata = extractProfit && profitAmount > 0n ? {
|
|
162
145
|
totalBuyAmount: ethers.formatEther(originalBuyAmount),
|