four-flap-meme-sdk 1.7.25 → 1.7.26
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.
|
@@ -142,13 +142,15 @@ function buildFlapSellCalls(wallets, sellAmounts, tokenAddress) {
|
|
|
142
142
|
const amount = sellAmounts[i];
|
|
143
143
|
if (amount <= 0n)
|
|
144
144
|
continue;
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
const portalCallData = portalInterface.encodeFunctionData('
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
// ✅ 使用 swapExactInput 卖出(与 AA 模式保持一致)
|
|
146
|
+
// outputToken = 0x0 表示卖出换取原生代币 (OKB)
|
|
147
|
+
const portalCallData = portalInterface.encodeFunctionData('swapExactInput', [{
|
|
148
|
+
inputToken: tokenAddress,
|
|
149
|
+
outputToken: ethers.ZeroAddress, // 0x0 = OKB
|
|
150
|
+
inputAmount: amount,
|
|
151
|
+
minOutputAmount: 0n, // 无滑点保护
|
|
152
|
+
permitData: '0x', // 无 permit
|
|
153
|
+
}]);
|
|
152
154
|
const batchCalls = [{
|
|
153
155
|
target: FLAP_PORTAL_ADDRESS,
|
|
154
156
|
value: 0n,
|
|
@@ -109,15 +109,19 @@ function buildSellAndTransferCall(sellerWallet, sellAmount, tokenAddress, recipi
|
|
|
109
109
|
const portalInterface = new ethers.Interface(FLAP_PORTAL_ABI);
|
|
110
110
|
switch (tradeType) {
|
|
111
111
|
case 'FLAP': {
|
|
112
|
-
// FLAP:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
// ✅ FLAP: 使用 swapExactInput 卖出(与 AA 模式保持一致)
|
|
113
|
+
const portalCallData = portalInterface.encodeFunctionData('swapExactInput', [{
|
|
114
|
+
inputToken: tokenAddress,
|
|
115
|
+
outputToken: ethers.ZeroAddress, // 0x0 = OKB
|
|
116
|
+
inputAmount: sellAmount,
|
|
117
|
+
minOutputAmount: 0n,
|
|
118
|
+
permitData: '0x',
|
|
119
|
+
}]);
|
|
120
|
+
// 通过 executeBatch 让 seller 钱包调用 Portal
|
|
121
|
+
const batchCalls = [{ target: FLAP_PORTAL_ADDRESS, value: 0n, data: portalCallData }];
|
|
122
|
+
const callData = delegateInterface.encodeFunctionData('executeBatch', [batchCalls]);
|
|
119
123
|
return {
|
|
120
|
-
target:
|
|
124
|
+
target: sellerWallet.address,
|
|
121
125
|
allowFailure: false,
|
|
122
126
|
value: 0n,
|
|
123
127
|
callData,
|
|
@@ -661,7 +665,14 @@ function buildBuyCallInternal(wallet, amount, tokenAddress, tradeType, routerAdd
|
|
|
661
665
|
function buildSellCallWithAmountInternal(wallet, amount, tokenAddress, tradeType, routerAddress, fee, delegateInterface, portalInterface) {
|
|
662
666
|
switch (tradeType) {
|
|
663
667
|
case 'FLAP': {
|
|
664
|
-
|
|
668
|
+
// ✅ 使用 swapExactInput 卖出(与 AA 模式保持一致)
|
|
669
|
+
const portalCallData = portalInterface.encodeFunctionData('swapExactInput', [{
|
|
670
|
+
inputToken: tokenAddress,
|
|
671
|
+
outputToken: ethers.ZeroAddress, // 0x0 = OKB
|
|
672
|
+
inputAmount: amount,
|
|
673
|
+
minOutputAmount: 0n,
|
|
674
|
+
permitData: '0x',
|
|
675
|
+
}]);
|
|
665
676
|
const batchCalls = [{ target: FLAP_PORTAL_ADDRESS, value: 0n, data: portalCallData }];
|
|
666
677
|
return {
|
|
667
678
|
target: wallet.address,
|
|
@@ -456,8 +456,16 @@ function buildSellCall(wallet, tokenAddress, sellPercent, tokenDecimals, poolTyp
|
|
|
456
456
|
// 或者使用 executeSell 指定百分比
|
|
457
457
|
switch (poolType) {
|
|
458
458
|
case 'FLAP': {
|
|
459
|
-
//
|
|
460
|
-
|
|
459
|
+
// ✅ 使用 swapExactInput 卖出(与 AA 模式保持一致)
|
|
460
|
+
// 注意:inputAmount=0 会失败,FLAP 需要先获取余额再调用
|
|
461
|
+
// 这里需要传入实际的代币余额,外层调用者应该提前查询
|
|
462
|
+
const portalCallData = portalInterface.encodeFunctionData('swapExactInput', [{
|
|
463
|
+
inputToken: tokenAddress,
|
|
464
|
+
outputToken: ethers.ZeroAddress, // 0x0 = OKB
|
|
465
|
+
inputAmount: 0n, // 需要外层传入实际余额
|
|
466
|
+
minOutputAmount: 0n,
|
|
467
|
+
permitData: '0x',
|
|
468
|
+
}]);
|
|
461
469
|
const batchCalls = [{ target: FLAP_PORTAL_ADDRESS, value: 0n, data: portalCallData }];
|
|
462
470
|
return {
|
|
463
471
|
target: wallet.address,
|
|
@@ -490,7 +498,14 @@ function buildSellCall(wallet, tokenAddress, sellPercent, tokenDecimals, poolTyp
|
|
|
490
498
|
function buildSellCallWithAmount(wallet, amount, tokenAddress, poolType, routerAddress, fee, delegateInterface, portalInterface) {
|
|
491
499
|
switch (poolType) {
|
|
492
500
|
case 'FLAP': {
|
|
493
|
-
|
|
501
|
+
// ✅ 使用 swapExactInput 卖出(与 AA 模式保持一致)
|
|
502
|
+
const portalCallData = portalInterface.encodeFunctionData('swapExactInput', [{
|
|
503
|
+
inputToken: tokenAddress,
|
|
504
|
+
outputToken: ethers.ZeroAddress, // 0x0 = OKB
|
|
505
|
+
inputAmount: amount,
|
|
506
|
+
minOutputAmount: 0n,
|
|
507
|
+
permitData: '0x',
|
|
508
|
+
}]);
|
|
494
509
|
const batchCalls = [{ target: FLAP_PORTAL_ADDRESS, value: 0n, data: portalCallData }];
|
|
495
510
|
return {
|
|
496
511
|
target: wallet.address,
|