four-flap-meme-sdk 1.7.30 → 1.7.32
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.
|
@@ -254,15 +254,16 @@ export async function bundleCreateBuy(params) {
|
|
|
254
254
|
value: buyAmount,
|
|
255
255
|
data: buyData,
|
|
256
256
|
}]]);
|
|
257
|
+
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
257
258
|
calls.push({
|
|
258
259
|
target: buyerWallet.address,
|
|
259
260
|
allowFailure: false,
|
|
260
|
-
value:
|
|
261
|
+
value: 0n,
|
|
261
262
|
callData: buyBatchCall,
|
|
262
263
|
});
|
|
263
264
|
}
|
|
264
|
-
//
|
|
265
|
-
const totalValue =
|
|
265
|
+
// ✅ 修复:各钱包使用自己余额买入,主交易只支付利润和创建费用
|
|
266
|
+
const totalValue = profitAmount + (params.quoteAmt ?? 0n);
|
|
266
267
|
// 构建签名交易
|
|
267
268
|
const signedTransaction = buildEIP7702TransactionSync(mainWallet, authorizations, calls, totalValue, nonces[0], feeData, config);
|
|
268
269
|
return {
|
|
@@ -376,10 +377,11 @@ export async function bundleCreateToDex(params) {
|
|
|
376
377
|
value: buyAmount,
|
|
377
378
|
data: buyData,
|
|
378
379
|
}]]);
|
|
380
|
+
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
379
381
|
calls.push({
|
|
380
382
|
target: buyerWallet.address,
|
|
381
383
|
allowFailure: false,
|
|
382
|
-
value:
|
|
384
|
+
value: 0n,
|
|
383
385
|
callData: buyBatchCall,
|
|
384
386
|
});
|
|
385
387
|
}
|
|
@@ -406,16 +408,17 @@ export async function bundleCreateToDex(params) {
|
|
|
406
408
|
value: buyAmount,
|
|
407
409
|
data: swapData,
|
|
408
410
|
}]]);
|
|
411
|
+
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
409
412
|
calls.push({
|
|
410
413
|
target: buyerWallet.address,
|
|
411
414
|
allowFailure: false,
|
|
412
|
-
value:
|
|
415
|
+
value: 0n,
|
|
413
416
|
callData: dexBatchCall,
|
|
414
417
|
});
|
|
415
418
|
}
|
|
416
419
|
}
|
|
417
|
-
//
|
|
418
|
-
const totalValue =
|
|
420
|
+
// ✅ 修复:各钱包使用自己余额买入,主交易只支付利润和创建费用
|
|
421
|
+
const totalValue = profitAmount + (params.quoteAmt ?? 0n);
|
|
419
422
|
// 构建签名交易(一键发射会触发毕业,使用高 gas limit)
|
|
420
423
|
const toDexConfig = {
|
|
421
424
|
...config,
|
|
@@ -575,10 +578,11 @@ export async function bundleGraduateBuy(params) {
|
|
|
575
578
|
value: amount,
|
|
576
579
|
data: buyData,
|
|
577
580
|
}]]);
|
|
581
|
+
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
578
582
|
calls.push({
|
|
579
583
|
target: wallet.address,
|
|
580
584
|
allowFailure: false,
|
|
581
|
-
value:
|
|
585
|
+
value: 0n,
|
|
582
586
|
callData: buyBatchCall,
|
|
583
587
|
});
|
|
584
588
|
}
|
|
@@ -603,16 +607,17 @@ export async function bundleGraduateBuy(params) {
|
|
|
603
607
|
value: amount,
|
|
604
608
|
data: swapData,
|
|
605
609
|
}]]);
|
|
610
|
+
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
606
611
|
calls.push({
|
|
607
612
|
target: wallet.address,
|
|
608
613
|
allowFailure: false,
|
|
609
|
-
value:
|
|
614
|
+
value: 0n,
|
|
610
615
|
callData: dexBatchCall,
|
|
611
616
|
});
|
|
612
617
|
}
|
|
613
618
|
}
|
|
614
|
-
//
|
|
615
|
-
const totalValue =
|
|
619
|
+
// ✅ 修复:各钱包使用自己余额买入,主交易只支付利润
|
|
620
|
+
const totalValue = profitAmount;
|
|
616
621
|
// 构建签名交易(毕业操作强制使用高 gas limit)
|
|
617
622
|
const graduateConfig = {
|
|
618
623
|
...config,
|
|
@@ -608,7 +608,8 @@ export async function bundleMultiSwap(params) {
|
|
|
608
608
|
// ========================================
|
|
609
609
|
// 构建交易
|
|
610
610
|
// ========================================
|
|
611
|
-
|
|
611
|
+
// ✅ 修复:各钱包使用自己余额买入,主交易只支付利润
|
|
612
|
+
const totalValue = profitAmount;
|
|
612
613
|
const signedTransaction = buildEIP7702TransactionSync(mainWallet, authorizations, calls, totalValue, nonces[mainWalletIndex], feeData, config);
|
|
613
614
|
return {
|
|
614
615
|
signedTransaction,
|
|
@@ -633,28 +634,31 @@ function buildBuyCallInternal(wallet, amount, tokenAddress, tradeType, routerAdd
|
|
|
633
634
|
switch (tradeType) {
|
|
634
635
|
case 'FLAP': {
|
|
635
636
|
const portalCallData = portalInterface.encodeFunctionData('buy', [tokenAddress]);
|
|
637
|
+
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
636
638
|
const batchCalls = [{ target: FLAP_PORTAL_ADDRESS, value: amount, data: portalCallData }];
|
|
637
639
|
return {
|
|
638
640
|
target: wallet.address,
|
|
639
641
|
allowFailure: false,
|
|
640
|
-
value:
|
|
642
|
+
value: 0n,
|
|
641
643
|
callData: delegateInterface.encodeFunctionData('executeBatch', [batchCalls]),
|
|
642
644
|
};
|
|
643
645
|
}
|
|
644
646
|
case 'V2': {
|
|
645
647
|
const path = [WOKB_ADDRESS, tokenAddress];
|
|
648
|
+
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
646
649
|
return {
|
|
647
650
|
target: wallet.address,
|
|
648
651
|
allowFailure: false,
|
|
649
|
-
value:
|
|
652
|
+
value: 0n,
|
|
650
653
|
callData: delegateInterface.encodeFunctionData('executeBuyV2', [routerAddress, path, 0]),
|
|
651
654
|
};
|
|
652
655
|
}
|
|
653
656
|
case 'V3': {
|
|
657
|
+
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
654
658
|
return {
|
|
655
659
|
target: wallet.address,
|
|
656
660
|
allowFailure: false,
|
|
657
|
-
value:
|
|
661
|
+
value: 0n,
|
|
658
662
|
callData: delegateInterface.encodeFunctionData('executeBuy', [
|
|
659
663
|
routerAddress, WOKB_ADDRESS, tokenAddress, fee, 0
|
|
660
664
|
]),
|
|
@@ -306,9 +306,15 @@ export async function sweep(params) {
|
|
|
306
306
|
const feeData = results[1];
|
|
307
307
|
const balances = results[2].map(b => typeof b === 'bigint' ? b : BigInt(b.toString()));
|
|
308
308
|
// 计算转账金额
|
|
309
|
-
|
|
309
|
+
// ✅ 修复:当 percent=100 时,不预留 gas,归集全部余额
|
|
310
|
+
const isFullSweep = percent >= 100;
|
|
311
|
+
const gasReserve = (reserveGas && isNative && !isFullSweep) ? ethers.parseEther('0.001') : 0n;
|
|
310
312
|
const percentBigInt = BigInt(Math.min(100, Math.max(1, percent)));
|
|
311
313
|
const transferAmounts = balances.map(b => {
|
|
314
|
+
if (isFullSweep) {
|
|
315
|
+
// 100% 归集:使用全部余额
|
|
316
|
+
return b;
|
|
317
|
+
}
|
|
312
318
|
const afterReserve = b > gasReserve ? b - gasReserve : 0n;
|
|
313
319
|
return (afterReserve * percentBigInt) / 100n;
|
|
314
320
|
});
|
|
@@ -129,7 +129,8 @@ export async function washVolume(params) {
|
|
|
129
129
|
// ========================================
|
|
130
130
|
// 构建交易
|
|
131
131
|
// ========================================
|
|
132
|
-
|
|
132
|
+
// ✅ 修复:各钱包使用自己余额买入,主交易只支付利润
|
|
133
|
+
const totalValue = profitAmount;
|
|
133
134
|
// ✅ 使用 mainWallet 的 nonce(mainWallet 是交易发起者和 Gas 支付者)
|
|
134
135
|
const signedTransaction = buildEIP7702TransactionSync(mainWallet, authorizations, calls, totalValue, nonces[mainWalletIndex], feeData, config);
|
|
135
136
|
return {
|
|
@@ -286,7 +287,8 @@ export async function bundleVolume(params) {
|
|
|
286
287
|
// ========================================
|
|
287
288
|
// 构建交易
|
|
288
289
|
// ========================================
|
|
289
|
-
|
|
290
|
+
// ✅ 修复:各钱包使用自己余额买入,主交易只支付利润
|
|
291
|
+
const totalValue = profitAmount;
|
|
290
292
|
const signedTransaction = buildEIP7702TransactionSync(mainWallet, authorizations, calls, totalValue, nonces[mainWalletIndex], feeData, config);
|
|
291
293
|
return {
|
|
292
294
|
signedTransaction,
|
|
@@ -422,28 +424,31 @@ function buildBuyCall(wallet, amount, tokenAddress, poolType, routerAddress, fee
|
|
|
422
424
|
switch (poolType) {
|
|
423
425
|
case 'FLAP': {
|
|
424
426
|
const portalCallData = portalInterface.encodeFunctionData('buy', [tokenAddress]);
|
|
427
|
+
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
425
428
|
const batchCalls = [{ target: FLAP_PORTAL_ADDRESS, value: amount, data: portalCallData }];
|
|
426
429
|
return {
|
|
427
430
|
target: wallet.address,
|
|
428
431
|
allowFailure: false,
|
|
429
|
-
value:
|
|
432
|
+
value: 0n,
|
|
430
433
|
callData: delegateInterface.encodeFunctionData('executeBatch', [batchCalls]),
|
|
431
434
|
};
|
|
432
435
|
}
|
|
433
436
|
case 'V2': {
|
|
434
437
|
const path = [WOKB_ADDRESS, tokenAddress];
|
|
438
|
+
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
435
439
|
return {
|
|
436
440
|
target: wallet.address,
|
|
437
441
|
allowFailure: false,
|
|
438
|
-
value:
|
|
442
|
+
value: 0n,
|
|
439
443
|
callData: delegateInterface.encodeFunctionData('executeBuyV2', [routerAddress, path, 0]),
|
|
440
444
|
};
|
|
441
445
|
}
|
|
442
446
|
case 'V3': {
|
|
447
|
+
// ✅ 修复:value 设为 0n,让钱包使用自己余额买入
|
|
443
448
|
return {
|
|
444
449
|
target: wallet.address,
|
|
445
450
|
allowFailure: false,
|
|
446
|
-
value:
|
|
451
|
+
value: 0n,
|
|
447
452
|
callData: delegateInterface.encodeFunctionData('executeBuy', [
|
|
448
453
|
routerAddress, WOKB_ADDRESS, tokenAddress, fee, 0
|
|
449
454
|
]),
|