four-flap-meme-sdk 1.7.42 → 1.7.45
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.
package/dist/clients/merkle.js
CHANGED
|
@@ -31,9 +31,12 @@ export class MerkleClient {
|
|
|
31
31
|
this.blockNumberCache = null;
|
|
32
32
|
this.chainId = config.chainId;
|
|
33
33
|
this.chainName = config.chainId === 56 ? 'bsc' : 'ethereum';
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
// ✅ 修复:移除弃用的 mempool.merkle.io RPC,使用公共 RPC 作为默认值
|
|
35
|
+
// 优先使用用户自定义 RPC,否则使用官方公共 RPC
|
|
36
|
+
const defaultRpc = config.chainId === 56
|
|
37
|
+
? 'https://bsc-dataseed1.bnbchain.org'
|
|
38
|
+
: 'https://eth.llamarpc.com';
|
|
39
|
+
const rpcUrl = config.customRpcUrl || defaultRpc;
|
|
37
40
|
this.provider = new JsonRpcProvider(rpcUrl, {
|
|
38
41
|
chainId: this.chainId,
|
|
39
42
|
name: this.chainName,
|
|
@@ -434,6 +434,7 @@ export async function bundleBatchSwap(params) {
|
|
|
434
434
|
});
|
|
435
435
|
}
|
|
436
436
|
// 最后一个中间钱包转给第一个买家
|
|
437
|
+
// ⚠️ 注意:资金先到第一个买家,然后第一个买家转给其他买家
|
|
437
438
|
if (hopWallets.length > 0) {
|
|
438
439
|
calls.push({
|
|
439
440
|
target: hopWallets[hopWallets.length - 1].address,
|
|
@@ -442,9 +443,26 @@ export async function bundleBatchSwap(params) {
|
|
|
442
443
|
callData: delegateInterface.encodeFunctionData('transferTo', [buyerWallets[0].address]),
|
|
443
444
|
});
|
|
444
445
|
}
|
|
445
|
-
//
|
|
446
|
-
|
|
447
|
-
|
|
446
|
+
// ✅ 修复:计算每个买家分配的 OKB 金额(平分,扣除利润)
|
|
447
|
+
const portalInterface = new ethers.Interface(FLAP_PORTAL_ABI);
|
|
448
|
+
const okbForBuyers = estimatedOkbOut - profitAmount; // 扣除利润后可用于买入的 OKB
|
|
449
|
+
const buyAmountPerBuyer = okbForBuyers / BigInt(buyerWallets.length);
|
|
450
|
+
console.log(`[Bundle Batch Swap] 可用于买入: ${ethers.formatEther(okbForBuyers)} OKB`);
|
|
451
|
+
console.log(`[Bundle Batch Swap] 每个买家分配: ${ethers.formatEther(buyAmountPerBuyer)} OKB`);
|
|
452
|
+
// ✅ 修复:第一个买家收到所有资金后,使用 transferAmount 按比例分配给其他买家
|
|
453
|
+
// 注意:transferTo 会转移全部余额,导致第一个买家无法买入!必须使用 transferAmount 指定金额
|
|
454
|
+
for (let i = 1; i < buyerWallets.length; i++) {
|
|
455
|
+
calls.push({
|
|
456
|
+
target: buyerWallets[0].address, // 第一个买家转账
|
|
457
|
+
allowFailure: false,
|
|
458
|
+
value: 0n,
|
|
459
|
+
callData: delegateInterface.encodeFunctionData('transferAmount', [buyerWallets[i].address, buyAmountPerBuyer]),
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
// ✅ 修复:使用 buildBuyCallInternal(有金额参数)
|
|
463
|
+
for (let i = 0; i < buyerWallets.length; i++) {
|
|
464
|
+
const buyCall = buildBuyCallInternal(buyerWallets[i], buyAmountPerBuyer, // ✅ 使用分配的金额
|
|
465
|
+
tokenAddress, tradeType, actualRouter, fee, delegateInterface, portalInterface);
|
|
448
466
|
calls.push(buyCall);
|
|
449
467
|
}
|
|
450
468
|
// ✅ 利润刮取放在最后(从卖家钱包)
|
|
@@ -646,22 +664,22 @@ function buildBuyCallInternal(wallet, amount, tokenAddress, tradeType, routerAdd
|
|
|
646
664
|
}
|
|
647
665
|
case 'V2': {
|
|
648
666
|
const path = [WOKB_ADDRESS, tokenAddress];
|
|
649
|
-
// ✅
|
|
667
|
+
// ✅ 修复:使用指定的买入金额,而不是 0(使用全部余额会导致严重 bug)
|
|
650
668
|
return {
|
|
651
669
|
target: wallet.address,
|
|
652
670
|
allowFailure: false,
|
|
653
671
|
value: 0n,
|
|
654
|
-
callData: delegateInterface.encodeFunctionData('executeBuyV2', [routerAddress, path,
|
|
672
|
+
callData: delegateInterface.encodeFunctionData('executeBuyV2', [routerAddress, path, amount]),
|
|
655
673
|
};
|
|
656
674
|
}
|
|
657
675
|
case 'V3': {
|
|
658
|
-
// ✅
|
|
676
|
+
// ✅ 修复:使用指定的买入金额,而不是 0(使用全部余额会导致严重 bug)
|
|
659
677
|
return {
|
|
660
678
|
target: wallet.address,
|
|
661
679
|
allowFailure: false,
|
|
662
680
|
value: 0n,
|
|
663
681
|
callData: delegateInterface.encodeFunctionData('executeBuy', [
|
|
664
|
-
routerAddress, WOKB_ADDRESS, tokenAddress, fee,
|
|
682
|
+
routerAddress, WOKB_ADDRESS, tokenAddress, fee, amount
|
|
665
683
|
]),
|
|
666
684
|
};
|
|
667
685
|
}
|