four-flap-meme-sdk 1.7.24 → 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,
|
|
@@ -78,6 +78,6 @@ export declare const ERC20_ABI: readonly ["function approve(address spender, uin
|
|
|
78
78
|
export declare const MULTICALL3_ABI: readonly ["function aggregate3Value((address target, bool allowFailure, uint256 value, bytes callData)[] calls) external payable returns ((bool success, bytes returnData)[] returnData)"];
|
|
79
79
|
export declare const V3_ROUTER_ABI: readonly ["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountOut)", "function multicall(uint256 deadline, bytes[] data) external payable returns (bytes[] results)", "function unwrapWETH9(uint256 amountMinimum, address recipient) external payable", "function refundETH() external payable"];
|
|
80
80
|
export declare const V2_ROUTER_ABI: readonly ["function swapExactETHForTokensSupportingFeeOnTransferTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) external payable", "function swapExactTokensForETHSupportingFeeOnTransferTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) external", "function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) external"];
|
|
81
|
-
export declare const FLAP_PORTAL_ABI: readonly ["function buy(address token) external payable returns (uint256)", "function sell(address token, uint256 amount, uint256 minOut) external returns (uint256)", "function swapExactInput((address inputToken, address outputToken, uint256 inputAmount, uint256 minOutputAmount, bytes permitData) params) external payable returns (uint256)", "function swapExactInputV3((address inputToken, address outputToken, uint256 inputAmount, uint256 minOutputAmount, bytes permitData, bytes extensionData) params) external payable returns (uint256)", "function newTokenV2((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt,
|
|
81
|
+
export declare const FLAP_PORTAL_ABI: readonly ["function buy(address token) external payable returns (uint256)", "function sell(address token, uint256 amount, uint256 minOut) external returns (uint256)", "function swapExactInput((address inputToken, address outputToken, uint256 inputAmount, uint256 minOutputAmount, bytes permitData) params) external payable returns (uint256)", "function swapExactInputV3((address inputToken, address outputToken, uint256 inputAmount, uint256 minOutputAmount, bytes permitData, bytes extensionData) params) external payable returns (uint256)", "function newTokenV2((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData) params) external payable returns (address)", "function newTokenV3((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData, bytes32 extensionID, bytes extensionData) params) external payable returns (address)", "function newTokenV4((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData, bytes32 extensionID, bytes extensionData, uint8 dexId, uint8 lpFeeProfile) params) external payable returns (address)", "function getToken(address token) external view returns (tuple(address creator, uint256 supply, uint256 reserve, bool graduated))", "function getTokenV5(address token) external view returns (uint8 status, uint256 reserve, uint256 circulatingSupply, uint256 price, uint8 tokenVersion, uint256 r, uint256 h, uint256 k, uint256 dexSupplyThresh, address quoteTokenAddress, bool nativeToQuoteSwapEnabled, bytes32 extensionID)", "function getTokenV7(address token) external view returns (uint8 status, uint256 reserve, uint256 circulatingSupply, uint256 price, uint8 tokenVersion, uint256 r, uint256 h, uint256 k, uint256 dexSupplyThresh, address quoteTokenAddress, bool nativeToQuoteSwapEnabled, bytes32 extensionID, uint8 taxRate, address pool, uint256 progress, uint8 lpFeeProfile)", "function quoteBuy(address token, uint256 ethIn) external view returns (uint256)", "function quoteSell(address token, uint256 tokenIn) external view returns (uint256)", "function quoteExactInput((address inputToken, address outputToken, uint256 inputAmount) params) external view returns (uint256)"];
|
|
82
82
|
export declare const EIP7702_TX_TYPE = 4;
|
|
83
83
|
export declare const EIP7702_AUTH_PREFIX = 5;
|
|
@@ -166,9 +166,10 @@ export const FLAP_PORTAL_ABI = [
|
|
|
166
166
|
// ========================================
|
|
167
167
|
// 创建代币
|
|
168
168
|
// ========================================
|
|
169
|
-
|
|
170
|
-
'function
|
|
171
|
-
'function
|
|
169
|
+
// ✅ taxRate 必须是 uint16,与 AA 模式的 PORTAL_ABI 保持一致
|
|
170
|
+
'function newTokenV2((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData) params) external payable returns (address)',
|
|
171
|
+
'function newTokenV3((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData, bytes32 extensionID, bytes extensionData) params) external payable returns (address)',
|
|
172
|
+
'function newTokenV4((string name, string symbol, string meta, uint8 dexThresh, bytes32 salt, uint16 taxRate, uint8 migratorType, address quoteToken, uint256 quoteAmt, address beneficiary, bytes permitData, bytes32 extensionID, bytes extensionData, uint8 dexId, uint8 lpFeeProfile) params) external payable returns (address)',
|
|
172
173
|
// ========================================
|
|
173
174
|
// 查询功能
|
|
174
175
|
// ========================================
|
|
@@ -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,
|