four-flap-meme-sdk 1.6.47 → 1.6.48
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.
|
@@ -644,17 +644,14 @@ export class AAPortalSwapExecutor {
|
|
|
644
644
|
const buyAmount = buyAmountsWei[buyerIdx] ?? 0n;
|
|
645
645
|
if (buyAmount <= 0n)
|
|
646
646
|
continue;
|
|
647
|
-
//
|
|
648
|
-
const hopPrefunds = chainHops.map((hop, idx) => {
|
|
649
|
-
const isLastHop = idx === chainHops.length - 1;
|
|
650
|
-
// 最后一个 hop 转账给 buyer,中间 hop 转账给下一个 hop
|
|
651
|
-
return estimatePrefund(HOP_CALL_GAS_LIMIT, hop.deployed);
|
|
652
|
-
});
|
|
653
|
-
const totalHopPrefund = hopPrefunds.reduce((a, b) => a + b, 0n);
|
|
654
|
-
// 计算 buyer 的 prefund(用于买入,使用常量)
|
|
647
|
+
// ✅ 计算 buyer 的 prefund(用于买入,使用常量)
|
|
655
648
|
const buyerPrefund = estimatePrefund(PORTAL_BUY_CALL_GAS_LIMIT, buyerAi.deployed);
|
|
656
|
-
//
|
|
657
|
-
|
|
649
|
+
// ✅ 关键修复:分发金额计算与 dex-bundle-swap.ts 保持一致
|
|
650
|
+
// - 预充值模式:hop 已有 prefund,分发金额 = 买入金额 + buyer prefund
|
|
651
|
+
// - Paymaster 模式:prefund = 0,分发金额 = 买入金额 + buyer prefund
|
|
652
|
+
// 注意:无论哪种模式,都不需要在分发中包含 hop 的 prefund
|
|
653
|
+
//(预充值模式下 hop 已有余额,Paymaster 模式下 prefund=0)
|
|
654
|
+
const chainTotalAmount = buyAmount + buyerPrefund;
|
|
658
655
|
// 1) seller → hop0
|
|
659
656
|
const hop0 = chainHops[0];
|
|
660
657
|
let callData0;
|
|
@@ -693,13 +690,12 @@ export class AAPortalSwapExecutor {
|
|
|
693
690
|
});
|
|
694
691
|
outOps.push(signedSellerToHop0.userOp);
|
|
695
692
|
// 2) hop[j] → hop[j+1] (中间跳)
|
|
696
|
-
|
|
693
|
+
// ✅ 预充值模式下,hop 钱包自己有 prefund,只需要传递买入金额 + buyer prefund
|
|
697
694
|
for (let j = 0; j < chainHops.length - 1; j++) {
|
|
698
695
|
const currentHop = chainHops[j];
|
|
699
696
|
const nextHop = chainHops[j + 1];
|
|
700
|
-
//
|
|
701
|
-
|
|
702
|
-
const amountToTransfer = buyAmount + remainingPrefund + buyerPrefund;
|
|
697
|
+
// 传递金额 = 买入金额 + buyer prefund(hop 自己的 gas 从预充值中支付)
|
|
698
|
+
const amountToTransfer = buyAmount + buyerPrefund;
|
|
703
699
|
let callData;
|
|
704
700
|
if (useNativeToken) {
|
|
705
701
|
callData = encodeExecute(nextHop.sender, amountToTransfer, '0x');
|