four-flap-meme-sdk 1.5.42 → 1.5.43

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.
@@ -91,9 +91,6 @@ export declare class BundleExecutor {
91
91
  * 捆绑发射代币 + 购买(签名版本)
92
92
  */
93
93
  bundleCreateBuySign(params: BundleCreateBuySignParams): Promise<BundleCreateBuySignResult>;
94
- /**
95
- * 捆绑发射代币 + 购买(执行版本)
96
- */
97
94
  bundleCreateBuy(params: BundleCreateBuyParams): Promise<BundleCreateBuyResult>;
98
95
  /**
99
96
  * 检查多个 AA 账户的授权状态
@@ -1131,13 +1131,10 @@ export class BundleExecutor {
1131
1131
  console.log('token:', tokenInfo.symbol);
1132
1132
  console.log('dev:', devWallet.address);
1133
1133
  console.log('buyers:', buyerWallets.length);
1134
- // 1. 准备代币地址
1135
1134
  const tokenAddress = params.tokenAddress || ZERO_ADDRESS;
1136
- // 2. 构造 UserOperations
1137
- const mainOps = [];
1138
- const profitOps = [];
1135
+ // 2. 构造 UserOperations (主要涵盖发币和购买)
1136
+ const ops = [];
1139
1137
  const nonceMap = new AANonceMap();
1140
- // 2a. Dev 发射代币
1141
1138
  const devAccount = await this.aaManager.getAccountInfo(devWallet.address);
1142
1139
  nonceMap.init(devAccount.sender, devAccount.nonce);
1143
1140
  const useV4 = params.dexId !== undefined || params.lpFeeProfile !== undefined;
@@ -1206,8 +1203,7 @@ export class BundleExecutor {
1206
1203
  deployed: devAccount.deployed
1207
1204
  });
1208
1205
  const signedDevOp = await this.aaManager.signUserOp(devCreateOp.userOp, devWallet);
1209
- mainOps.push(signedDevOp.userOp);
1210
- // 2b. Buyers 买入
1206
+ ops.push(signedDevOp.userOp);
1211
1207
  const profitSettings = resolveProfitSettings(effConfig);
1212
1208
  const inputToken = params.quoteToken && params.quoteToken !== ZERO_ADDRESS ? params.quoteToken : ZERO_ADDRESS;
1213
1209
  const useNativeToken = inputToken === ZERO_ADDRESS;
@@ -1215,7 +1211,6 @@ export class BundleExecutor {
1215
1211
  let totalBuyWei = 0n;
1216
1212
  let totalBuyProfitWei = 0n;
1217
1213
  const buyerSenders = [];
1218
- const profitWeis = [];
1219
1214
  const portalIface = new Interface(PORTAL_ABI);
1220
1215
  for (let i = 0; i < buyerWallets.length; i++) {
1221
1216
  const buyer = buyerWallets[i];
@@ -1230,7 +1225,6 @@ export class BundleExecutor {
1230
1225
  }
1231
1226
  totalBuyWei += buyWei;
1232
1227
  totalBuyProfitWei += profitWei;
1233
- profitWeis.push(profitWei);
1234
1228
  const buyerAccount = await this.aaManager.getAccountInfo(buyer.address);
1235
1229
  buyerSenders.push(buyerAccount.sender);
1236
1230
  nonceMap.init(buyerAccount.sender, buyerAccount.nonce);
@@ -1252,11 +1246,11 @@ export class BundleExecutor {
1252
1246
  deployed: buyerAccount.deployed
1253
1247
  });
1254
1248
  const signedBuyOp = await this.aaManager.signUserOp(buyOp.userOp, buyer);
1255
- mainOps.push(signedBuyOp.userOp);
1249
+ ops.push(signedBuyOp.userOp);
1256
1250
  }
1257
- // 刮取利润:单独作为一个交易签名
1251
+ let nativeProfitAmount = 0n;
1258
1252
  if (profitSettings.extractProfit && totalBuyProfitWei > 0n) {
1259
- let nativeProfitAmount = totalBuyProfitWei;
1253
+ nativeProfitAmount = totalBuyProfitWei;
1260
1254
  if (!useNativeToken) {
1261
1255
  try {
1262
1256
  const dq = new DexQuery(effConfig);
@@ -1272,47 +1266,30 @@ export class BundleExecutor {
1272
1266
  }
1273
1267
  }
1274
1268
  }
1275
- if (nativeProfitAmount > 0n) {
1276
- const maxProfitIndex = profitWeis.reduce((maxIdx, p, idx) => p > (profitWeis[maxIdx] ?? 0n) ? idx : maxIdx, 0);
1277
- const pOwner = buyerWallets[maxProfitIndex];
1278
- const pSender = buyerSenders[maxProfitIndex];
1279
- const profitCallData = encodeExecute(profitSettings.profitRecipient, nativeProfitAmount, '0x');
1280
- const profitOp = await this.aaManager.buildUserOpWithFixedGas({
1281
- ownerWallet: pOwner,
1282
- sender: pSender,
1283
- callData: profitCallData,
1284
- nonce: nonceMap.next(pSender),
1285
- initCode: '0x',
1286
- deployed: true,
1287
- fixedGas: {
1288
- ...(effConfig.fixedGas ?? {}),
1289
- callGasLimit: effConfig.fixedGas?.callGasLimit ?? DEFAULT_CALL_GAS_LIMIT_WITHDRAW,
1290
- }
1291
- });
1292
- const signedProfitOp = await this.aaManager.signUserOp(profitOp.userOp, pOwner);
1293
- profitOps.push(signedProfitOp.userOp);
1294
- }
1295
1269
  }
1296
- // 3. 签名 handleOps 交易
1297
1270
  const provider = this.aaManager.getProvider();
1298
1271
  const startNonce = params.payerStartNonce ?? await provider.getTransactionCount(payer.address, 'pending');
1299
1272
  const signedTransactions = [];
1300
- // 3a. 签名主交易
1301
1273
  const signedMainTx = await this.signHandleOpsTx({
1302
- ops: mainOps,
1274
+ ops,
1303
1275
  payerWallet: payer,
1304
1276
  beneficiary: useBeneficiary,
1305
1277
  nonce: startNonce
1306
1278
  });
1307
1279
  signedTransactions.push(signedMainTx);
1308
- // 3b. 签名利润交易
1309
- if (profitOps.length > 0) {
1310
- const signedProfitTx = await this.signHandleOpsTx({
1311
- ops: profitOps,
1312
- payerWallet: payer,
1313
- beneficiary: useBeneficiary,
1314
- nonce: startNonce + 1
1315
- });
1280
+ if (nativeProfitAmount > 0n) {
1281
+ console.log(`[利润提取-签名] 非 AA 转账: ${useNativeToken ? formatOkb(nativeProfitAmount) : `${formatOkb(totalBuyProfitWei)} (ERC20) -> ${formatOkb(nativeProfitAmount)} (OKB)`} -> ${profitSettings.profitRecipient}`);
1282
+ const feeData = await provider.getFeeData();
1283
+ const gasPrice = feeData.gasPrice ?? 100000000n;
1284
+ const profitTxRequest = {
1285
+ to: profitSettings.profitRecipient,
1286
+ value: nativeProfitAmount,
1287
+ nonce: startNonce + 1,
1288
+ gasLimit: 21000n,
1289
+ gasPrice: gasPrice,
1290
+ chainId: (await provider.getNetwork()).chainId
1291
+ };
1292
+ const signedProfitTx = await payer.signTransaction(profitTxRequest);
1316
1293
  signedTransactions.push(signedProfitTx);
1317
1294
  }
1318
1295
  return {
@@ -1328,9 +1305,6 @@ export class BundleExecutor {
1328
1305
  }
1329
1306
  };
1330
1307
  }
1331
- /**
1332
- * 捆绑发射代币 + 购买(执行版本)
1333
- */
1334
1308
  async bundleCreateBuy(params) {
1335
1309
  const signResult = await this.bundleCreateBuySign({
1336
1310
  ...params,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.5.42",
3
+ "version": "1.5.43",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",