four-flap-meme-sdk 1.4.24 → 1.4.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.
Files changed (46) hide show
  1. package/dist/abis/common.d.ts +85 -0
  2. package/dist/abis/common.js +242 -0
  3. package/dist/abis/index.d.ts +1 -0
  4. package/dist/abis/index.js +2 -0
  5. package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +1 -6
  6. package/dist/contracts/tm-bundle-merkle/core.js +9 -16
  7. package/dist/contracts/tm-bundle-merkle/internal.js +6 -8
  8. package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +12 -6
  9. package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +224 -166
  10. package/dist/contracts/tm-bundle-merkle/private.js +6 -19
  11. package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +2 -7
  12. package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +1 -1
  13. package/dist/contracts/tm-bundle-merkle/swap-internal.js +9 -2
  14. package/dist/contracts/tm-bundle-merkle/swap.js +1 -3
  15. package/dist/contracts/tm-bundle-merkle/types.d.ts +20 -0
  16. package/dist/contracts/tm-bundle-merkle/utils.js +164 -175
  17. package/dist/dex/direct-router.d.ts +2 -1
  18. package/dist/dex/direct-router.js +25 -140
  19. package/dist/flap/constants.d.ts +2 -1
  20. package/dist/flap/constants.js +2 -1
  21. package/dist/flap/meta.js +6 -4
  22. package/dist/flap/portal-bundle-merkle/config.js +6 -12
  23. package/dist/flap/portal-bundle-merkle/core.js +8 -11
  24. package/dist/flap/portal-bundle-merkle/pancake-proxy.d.ts +12 -10
  25. package/dist/flap/portal-bundle-merkle/pancake-proxy.js +307 -370
  26. package/dist/flap/portal-bundle-merkle/private.js +1 -1
  27. package/dist/flap/portal-bundle-merkle/swap-buy-first.js +12 -30
  28. package/dist/flap/portal-bundle-merkle/swap.js +13 -26
  29. package/dist/flap/portal-bundle-merkle/types.d.ts +22 -2
  30. package/dist/flap/portal-bundle-merkle/utils.js +11 -16
  31. package/dist/index.d.ts +3 -2
  32. package/dist/index.js +9 -2
  33. package/dist/pancake/bundle-buy-first.js +56 -38
  34. package/dist/pancake/bundle-swap.js +114 -61
  35. package/dist/utils/bundle-helpers.d.ts +28 -0
  36. package/dist/utils/bundle-helpers.js +64 -0
  37. package/dist/utils/constants.d.ts +23 -1
  38. package/dist/utils/constants.js +37 -7
  39. package/dist/utils/erc20.js +17 -25
  40. package/dist/utils/lp-inspect.js +9 -20
  41. package/dist/utils/private-sale.js +1 -2
  42. package/dist/utils/quote-helpers.js +3 -29
  43. package/dist/utils/swap-helpers.js +1 -6
  44. package/dist/utils/wallet.d.ts +8 -13
  45. package/dist/utils/wallet.js +154 -342
  46. package/package.json +1 -1
@@ -0,0 +1,85 @@
1
+ /**
2
+ * 公共 ABI 定义
3
+ *
4
+ * 将重复的 ABI 提取到这里,统一管理
5
+ */
6
+ /** 完整 ERC20 ABI */
7
+ export declare const ERC20_ABI: string[];
8
+ /** 精简 ERC20 ABI(只有余额查询) */
9
+ export declare const ERC20_BALANCE_ABI: string[];
10
+ /** ERC20 授权相关 ABI */
11
+ export declare const ERC20_ALLOWANCE_ABI: string[];
12
+ export declare const MULTICALL3_ABI: string[];
13
+ /** V2 Router 完整 ABI */
14
+ export declare const V2_ROUTER_ABI: string[];
15
+ /** V2 Router 精简 ABI(只用于报价) */
16
+ export declare const V2_ROUTER_QUOTE_ABI: string[];
17
+ /** V3 SwapRouter02 ABI(新版,deadline 在 multicall 中传递) */
18
+ export declare const V3_ROUTER02_ABI: (string | {
19
+ inputs: {
20
+ components: {
21
+ name: string;
22
+ type: string;
23
+ }[];
24
+ name: string;
25
+ type: string;
26
+ }[];
27
+ name: string;
28
+ outputs: {
29
+ name: string;
30
+ type: string;
31
+ }[];
32
+ stateMutability: string;
33
+ type: string;
34
+ })[];
35
+ /** V3 SwapRouter 旧版 ABI(deadline 在 struct 内部) */
36
+ export declare const V3_ROUTER_LEGACY_ABI: (string | {
37
+ inputs: {
38
+ components: {
39
+ name: string;
40
+ type: string;
41
+ }[];
42
+ name: string;
43
+ type: string;
44
+ }[];
45
+ name: string;
46
+ outputs: {
47
+ name: string;
48
+ type: string;
49
+ }[];
50
+ stateMutability: string;
51
+ type: string;
52
+ })[];
53
+ /**
54
+ * SwapRouter02 的 V2 方法 ABI
55
+ *
56
+ * 注意:SwapRouter02 的 V2 方法只有 token-to-token 交换
57
+ * 没有 swapExactETHForTokens / swapExactTokensForETH
58
+ * 必须通过 multicall 组合 wrapETH/unwrapWETH9 来处理原生代币
59
+ */
60
+ export declare const SWAP_ROUTER02_V2_ABI: string[];
61
+ /** V3 QuoterV2 ABI */
62
+ export declare const V3_QUOTER_ABI: {
63
+ inputs: {
64
+ components: {
65
+ name: string;
66
+ type: string;
67
+ }[];
68
+ name: string;
69
+ type: string;
70
+ }[];
71
+ name: string;
72
+ outputs: {
73
+ name: string;
74
+ type: string;
75
+ }[];
76
+ stateMutability: string;
77
+ type: string;
78
+ }[];
79
+ export declare const V2_FACTORY_ABI: string[];
80
+ export declare const V2_PAIR_ABI: string[];
81
+ export declare const V3_FACTORY_ABI: string[];
82
+ export declare const V3_POOL_ABI: string[];
83
+ export declare const FLAP_PORTAL_ABI: string[];
84
+ export declare const TM2_ABI: string[];
85
+ export declare const HELPER3_ABI: string[];
@@ -0,0 +1,242 @@
1
+ /**
2
+ * 公共 ABI 定义
3
+ *
4
+ * 将重复的 ABI 提取到这里,统一管理
5
+ */
6
+ // ============================================================================
7
+ // ERC20 ABI
8
+ // ============================================================================
9
+ /** 完整 ERC20 ABI */
10
+ export const ERC20_ABI = [
11
+ 'function approve(address spender, uint256 amount) external returns (bool)',
12
+ 'function allowance(address owner, address spender) external view returns (uint256)',
13
+ 'function balanceOf(address account) external view returns (uint256)',
14
+ 'function decimals() external view returns (uint8)',
15
+ 'function name() external view returns (string)',
16
+ 'function symbol() external view returns (string)',
17
+ 'function totalSupply() external view returns (uint256)',
18
+ 'function transfer(address to, uint256 amount) external returns (bool)',
19
+ 'function transferFrom(address from, address to, uint256 amount) external returns (bool)',
20
+ ];
21
+ /** 精简 ERC20 ABI(只有余额查询) */
22
+ export const ERC20_BALANCE_ABI = [
23
+ 'function balanceOf(address account) external view returns (uint256)',
24
+ ];
25
+ /** ERC20 授权相关 ABI */
26
+ export const ERC20_ALLOWANCE_ABI = [
27
+ 'function allowance(address owner, address spender) external view returns (uint256)',
28
+ 'function approve(address spender, uint256 amount) external returns (bool)',
29
+ 'function decimals() external view returns (uint8)',
30
+ ];
31
+ // ============================================================================
32
+ // Multicall3 ABI
33
+ // ============================================================================
34
+ export const MULTICALL3_ABI = [
35
+ 'function aggregate3(tuple(address target, bool allowFailure, bytes callData)[] calls) external payable returns (tuple(bool success, bytes returnData)[])',
36
+ 'function aggregate(tuple(address target, bytes callData)[] calls) public returns (uint256 blockNumber, bytes[] returnData)',
37
+ 'function getEthBalance(address addr) public view returns (uint256 balance)',
38
+ ];
39
+ // ============================================================================
40
+ // PancakeSwap / Uniswap V2 Router ABI
41
+ // ============================================================================
42
+ /** V2 Router 完整 ABI */
43
+ export const V2_ROUTER_ABI = [
44
+ // BNB/ETH → Token (买入)
45
+ 'function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)',
46
+ 'function swapExactETHForTokensSupportingFeeOnTransferTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable',
47
+ // Token → BNB/ETH (卖出)
48
+ 'function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',
49
+ 'function swapExactTokensForETHSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external',
50
+ // Token → Token
51
+ 'function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',
52
+ 'function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external',
53
+ // 报价
54
+ 'function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts)',
55
+ 'function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts)',
56
+ // Factory
57
+ 'function factory() external view returns (address)',
58
+ ];
59
+ /** V2 Router 精简 ABI(只用于报价) */
60
+ export const V2_ROUTER_QUOTE_ABI = [
61
+ 'function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts)',
62
+ ];
63
+ // ============================================================================
64
+ // PancakeSwap / Uniswap V3 Router ABI (SwapRouter02)
65
+ // ============================================================================
66
+ /** V3 SwapRouter02 ABI(新版,deadline 在 multicall 中传递) */
67
+ export const V3_ROUTER02_ABI = [
68
+ // exactInputSingle - 单跳,不含 deadline
69
+ {
70
+ "inputs": [{
71
+ "components": [
72
+ { "name": "tokenIn", "type": "address" },
73
+ { "name": "tokenOut", "type": "address" },
74
+ { "name": "fee", "type": "uint24" },
75
+ { "name": "recipient", "type": "address" },
76
+ { "name": "amountIn", "type": "uint256" },
77
+ { "name": "amountOutMinimum", "type": "uint256" },
78
+ { "name": "sqrtPriceLimitX96", "type": "uint160" }
79
+ ],
80
+ "name": "params",
81
+ "type": "tuple"
82
+ }],
83
+ "name": "exactInputSingle",
84
+ "outputs": [{ "name": "amountOut", "type": "uint256" }],
85
+ "stateMutability": "payable",
86
+ "type": "function"
87
+ },
88
+ // exactInput - 多跳,不含 deadline
89
+ {
90
+ "inputs": [{
91
+ "components": [
92
+ { "name": "path", "type": "bytes" },
93
+ { "name": "recipient", "type": "address" },
94
+ { "name": "amountIn", "type": "uint256" },
95
+ { "name": "amountOutMinimum", "type": "uint256" }
96
+ ],
97
+ "name": "params",
98
+ "type": "tuple"
99
+ }],
100
+ "name": "exactInput",
101
+ "outputs": [{ "name": "amountOut", "type": "uint256" }],
102
+ "stateMutability": "payable",
103
+ "type": "function"
104
+ },
105
+ // multicall - 带 deadline 版本
106
+ 'function multicall(uint256 deadline, bytes[] calldata data) external payable returns (bytes[] memory results)',
107
+ 'function refundETH() external payable',
108
+ 'function unwrapWETH9(uint256 amountMinimum, address recipient) external payable',
109
+ ];
110
+ /** V3 SwapRouter 旧版 ABI(deadline 在 struct 内部) */
111
+ export const V3_ROUTER_LEGACY_ABI = [
112
+ // exactInputSingle - 包含 deadline
113
+ {
114
+ "inputs": [{
115
+ "components": [
116
+ { "name": "tokenIn", "type": "address" },
117
+ { "name": "tokenOut", "type": "address" },
118
+ { "name": "fee", "type": "uint24" },
119
+ { "name": "recipient", "type": "address" },
120
+ { "name": "deadline", "type": "uint256" },
121
+ { "name": "amountIn", "type": "uint256" },
122
+ { "name": "amountOutMinimum", "type": "uint256" },
123
+ { "name": "sqrtPriceLimitX96", "type": "uint160" }
124
+ ],
125
+ "name": "params",
126
+ "type": "tuple"
127
+ }],
128
+ "name": "exactInputSingle",
129
+ "outputs": [{ "name": "amountOut", "type": "uint256" }],
130
+ "stateMutability": "payable",
131
+ "type": "function"
132
+ },
133
+ // multicall - 不带 deadline 版本
134
+ 'function multicall(bytes[] calldata data) external payable returns (bytes[] memory results)',
135
+ 'function refundETH() external payable',
136
+ 'function unwrapWETH9(uint256 amountMinimum, address recipient) external payable',
137
+ ];
138
+ // ============================================================================
139
+ // SwapRouter02 V2 方法 ABI (PotatoSwap/DYORSwap 等)
140
+ // ============================================================================
141
+ /**
142
+ * SwapRouter02 的 V2 方法 ABI
143
+ *
144
+ * 注意:SwapRouter02 的 V2 方法只有 token-to-token 交换
145
+ * 没有 swapExactETHForTokens / swapExactTokensForETH
146
+ * 必须通过 multicall 组合 wrapETH/unwrapWETH9 来处理原生代币
147
+ */
148
+ export const SWAP_ROUTER02_V2_ABI = [
149
+ // V2 交换方法(只有 token-to-token)
150
+ 'function swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to) external payable returns (uint256 amountOut)',
151
+ 'function swapTokensForExactTokens(uint256 amountOut, uint256 amountInMax, address[] calldata path, address to) external payable returns (uint256 amountIn)',
152
+ // Multicall - 多种重载
153
+ 'function multicall(uint256 deadline, bytes[] calldata data) external payable returns (bytes[] memory results)',
154
+ 'function multicall(bytes32 previousBlockhash, bytes[] calldata data) external payable returns (bytes[] memory results)',
155
+ 'function multicall(bytes[] calldata data) external payable returns (bytes[] memory results)',
156
+ // 辅助方法 - ETH/WETH 转换
157
+ 'function wrapETH(uint256 value) external payable',
158
+ 'function unwrapWETH9(uint256 amountMinimum, address recipient) external payable',
159
+ 'function unwrapWETH9(uint256 amountMinimum) external payable',
160
+ 'function refundETH() external payable',
161
+ // 代币操作
162
+ 'function pull(address token, uint256 value) external payable',
163
+ 'function sweepToken(address token, uint256 amountMinimum, address recipient) external payable',
164
+ 'function sweepToken(address token, uint256 amountMinimum) external payable',
165
+ ];
166
+ // ============================================================================
167
+ // V3 Quoter ABI
168
+ // ============================================================================
169
+ /** V3 QuoterV2 ABI */
170
+ export const V3_QUOTER_ABI = [
171
+ {
172
+ "inputs": [{
173
+ "components": [
174
+ { "name": "tokenIn", "type": "address" },
175
+ { "name": "tokenOut", "type": "address" },
176
+ { "name": "amountIn", "type": "uint256" },
177
+ { "name": "fee", "type": "uint24" },
178
+ { "name": "sqrtPriceLimitX96", "type": "uint160" }
179
+ ],
180
+ "name": "params",
181
+ "type": "tuple"
182
+ }],
183
+ "name": "quoteExactInputSingle",
184
+ "outputs": [
185
+ { "name": "amountOut", "type": "uint256" },
186
+ { "name": "sqrtPriceX96After", "type": "uint160" },
187
+ { "name": "initializedTicksCrossed", "type": "uint32" },
188
+ { "name": "gasEstimate", "type": "uint256" }
189
+ ],
190
+ "stateMutability": "nonpayable",
191
+ "type": "function"
192
+ }
193
+ ];
194
+ // ============================================================================
195
+ // Uniswap V2 Factory & Pair ABI
196
+ // ============================================================================
197
+ export const V2_FACTORY_ABI = [
198
+ 'function getPair(address tokenA, address tokenB) external view returns (address pair)',
199
+ ];
200
+ export const V2_PAIR_ABI = [
201
+ 'function token0() external view returns (address)',
202
+ 'function token1() external view returns (address)',
203
+ 'function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast)',
204
+ ];
205
+ // ============================================================================
206
+ // Uniswap V3 Factory & Pool ABI
207
+ // ============================================================================
208
+ export const V3_FACTORY_ABI = [
209
+ 'function getPool(address tokenA, address tokenB, uint24 fee) external view returns (address pool)',
210
+ ];
211
+ export const V3_POOL_ABI = [
212
+ 'function token0() external view returns (address)',
213
+ 'function token1() external view returns (address)',
214
+ 'function fee() external view returns (uint24)',
215
+ 'function slot0() external view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)',
216
+ ];
217
+ // ============================================================================
218
+ // Flap Portal ABI
219
+ // ============================================================================
220
+ export const FLAP_PORTAL_ABI = [
221
+ // 创建代币
222
+ 'function newToken(string name, string symbol, string meta) external payable returns (address)',
223
+ 'function newTokenV2((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint16 taxRate,uint8 migratorType,address quoteToken,uint256 quoteAmt,address beneficiary,bytes permitData)) external payable returns (address)',
224
+ '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)) external payable returns (address)',
225
+ // 交易
226
+ 'function swapExactInput((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)',
227
+ 'function quoteExactInput((address inputToken,address outputToken,uint256 inputAmount)) external view returns (uint256)',
228
+ // 旧版兼容
229
+ 'function buy(address token, uint256 minReceived) external payable returns (uint256)',
230
+ 'function sell(address token, uint256 sellAmount, uint256 minReceived) external returns (uint256)',
231
+ ];
232
+ // ============================================================================
233
+ // Four TokenManager ABI
234
+ // ============================================================================
235
+ export const TM2_ABI = [
236
+ 'function buy(address token, uint256 minReceived) external payable returns (uint256)',
237
+ 'function sell(address token, uint256 sellAmount, uint256 minReceived) external returns (uint256)',
238
+ 'function trySell(address token, uint256 sellAmount) external view returns (uint256)',
239
+ ];
240
+ export const HELPER3_ABI = [
241
+ 'function getTokenInfo(address token) external view returns (tuple(address addr, string name, string symbol, uint8 decimals, uint256 totalSupply, uint256 balance, uint256 price, uint256 marketCap))',
242
+ ];
@@ -2,3 +2,4 @@ import TokenManager from './TokenManager.json';
2
2
  import TokenManager2 from './TokenManager2.json';
3
3
  import TokenManagerHelper3 from './TokenManagerHelper3.json';
4
4
  export { TokenManager, TokenManager2, TokenManagerHelper3 };
5
+ export * from './common.js';
@@ -2,3 +2,5 @@ import TokenManager from './TokenManager.json' with { type: 'json' };
2
2
  import TokenManager2 from './TokenManager2.json' with { type: 'json' };
3
3
  import TokenManagerHelper3 from './TokenManagerHelper3.json' with { type: 'json' };
4
4
  export { TokenManager, TokenManager2, TokenManagerHelper3 };
5
+ // ✅ 公共 ABI 导出
6
+ export * from './common.js';
@@ -1,14 +1,9 @@
1
1
  import { ethers, Wallet } from 'ethers';
2
2
  import { NonceManager, getOptimizedGasPrice } from '../../utils/bundle-helpers.js';
3
3
  import { ADDRESSES } from '../../utils/constants.js';
4
+ import { ERC20_ABI } from '../../abis/common.js';
4
5
  import { getTxType, getGasPriceConfig } from './config.js';
5
6
  import { batchCheckAllowances } from '../../utils/erc20.js';
6
- // ==================== ERC20 ABI ====================
7
- const ERC20_ABI = [
8
- 'function approve(address spender, uint256 amount) returns (bool)',
9
- 'function allowance(address owner, address spender) view returns (uint256)',
10
- 'function decimals() view returns (uint8)'
11
- ];
12
7
  /**
13
8
  * 批量授权代币给 TokenManager(用于 Private Buy/Sell)
14
9
  * ✅ 直接通过 RPC 提交到链上并等待确认
@@ -1,38 +1,31 @@
1
1
  import { ethers, Wallet, Contract, Interface } from 'ethers';
2
2
  import { NonceManager, getOptimizedGasPrice } from '../../utils/bundle-helpers.js';
3
- import { ADDRESSES } from '../../utils/constants.js';
3
+ import { ADDRESSES, BLOCKRAZOR_BUILDER_EOA, ZERO_ADDRESS } from '../../utils/constants.js';
4
+ import { MULTICALL3_ABI, ERC20_ABI } from '../../abis/common.js';
4
5
  import { FourClient, buildLoginMessage } from '../../clients/four.js';
5
6
  import { getErrorMessage, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount } from './config.js';
6
- // ✅ BlockRazor Builder EOA 地址(用于贿赂)
7
- const BLOCKRAZOR_BUILDER_EOA = '0x1266C6bE60392A8Ff346E8d5ECCd3E69dD9c5F20';
8
- // ✅ 已移除授权检查(前端负责确保授权)
9
7
  import { trySell } from '../tm.js';
10
8
  import Helper3Abi from '../../abis/TokenManagerHelper3.json' with { type: 'json' };
11
- const MULTICALL3_ADDRESS = '0xcA11bde05977b3631167028862bE2a173976CA11';
12
- const MULTICALL3_ABI = [
13
- 'function aggregate3(tuple(address target, bool allowFailure, bytes callData)[] calls) external payable returns (tuple(bool success, bytes returnData)[])'
14
- ];
9
+ // 常量
10
+ const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
11
+ // TM2 扩展 ABI(包含创建代币方法和事件)
12
+ import { TM2_ABI as _TM2_ABI } from '../../abis/common.js';
15
13
  const TM2_ABI = [
14
+ ..._TM2_ABI,
16
15
  'function createToken(bytes args, bytes signature) payable',
17
16
  'function buyTokenAMAP(uint256 origin, address token, address to, uint256 funds, uint256 minAmount) payable',
18
17
  'function sellToken(uint256 origin, address token, uint256 amount, uint256 minFunds)',
19
18
  'event TokenCreate(address indexed creator, address indexed token, uint256 timestamp)'
20
19
  ];
21
- const ERC20_ABI = [
22
- 'function approve(address spender, uint256 amount) returns (bool)',
23
- 'function allowance(address owner, address spender) view returns (uint256)',
24
- 'function balanceOf(address owner) view returns (uint256)'
25
- ];
26
- const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
27
20
  const PLATFORM_CREATE_FEE = ethers.parseEther('0.01');
28
21
  const CHAIN_ID = 56;
22
+ // ✅ 本地 getGasLimit(FourAnyConfig 支持 bigint gasLimit)
29
23
  function getGasLimit(config, defaultGas = 800000) {
30
24
  if (config.gasLimit !== undefined) {
31
25
  return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
32
26
  }
33
27
  const multiplier = config.gasLimitMultiplier ?? 1.0;
34
- const calculatedGas = Math.ceil(defaultGas * multiplier);
35
- return BigInt(calculatedGas);
28
+ return BigInt(Math.ceil(defaultGas * multiplier));
36
29
  }
37
30
  export async function createTokenWithBundleBuyMerkle(params) {
38
31
  const { privateKeys, buyAmounts, tokenInfo, config } = params;
@@ -1,4 +1,6 @@
1
1
  import { ethers, Wallet } from 'ethers';
2
+ import { ADDRESSES } from '../../utils/constants.js';
3
+ import { MULTICALL3_ABI, ERC20_BALANCE_ABI } from '../../abis/common.js';
2
4
  // 内部缓存:ERC20 小数位
3
5
  const decimalsCache = new Map();
4
6
  /**
@@ -57,11 +59,8 @@ export function normalizeAmounts(recipients, amount, amounts) {
57
59
  export async function batchGetBalances(provider, addresses, tokenAddress) {
58
60
  if (addresses.length === 0)
59
61
  return [];
60
- const MULTICALL3_ADDRESS = '0xcA11bde05977b3631167028862bE2a173976CA11';
61
- const MULTICALL3_ABI = [
62
- 'function aggregate3(tuple(address target, bool allowFailure, bytes callData)[] calls) view returns (tuple(bool success, bytes returnData)[] returnData)',
63
- 'function getEthBalance(address addr) view returns (uint256 balance)' // ✅ 新增:原生代币余额查询
64
- ];
62
+ // 使用公共模块
63
+ const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
65
64
  const multicall = new ethers.Contract(MULTICALL3_ADDRESS, MULTICALL3_ABI, provider);
66
65
  if (!tokenAddress) {
67
66
  // ✅ 优化:原生代币使用 Multicall3.getEthBalance 批量获取(单次 RPC 调用)
@@ -92,9 +91,8 @@ export async function batchGetBalances(provider, addresses, tokenAddress) {
92
91
  }
93
92
  }
94
93
  else {
95
- // ERC20 余额:使用 Multicall3 批量获取
96
- const ERC20_ABI = ['function balanceOf(address) view returns (uint256)'];
97
- const iface = new ethers.Interface(ERC20_ABI);
94
+ // ERC20 余额:使用 Multicall3 批量获取
95
+ const iface = new ethers.Interface(ERC20_BALANCE_ABI);
98
96
  const calls = addresses.map(addr => ({
99
97
  target: tokenAddress,
100
98
  allowFailure: true,
@@ -1,22 +1,28 @@
1
+ /**
2
+ * PancakeSwap 官方 Router 交易模块
3
+ *
4
+ * ✅ 使用官方 PancakeSwap V2/V3 Router(非代理合约)
5
+ * - V2 Router: 0x10ED43C718714eb63d5aA57B78B54704E256024E
6
+ * - V3 Router: 0x13f4EA83D0bd40E75C8222255bc855a974568Dd4
7
+ * - V3 Quoter: 0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997
8
+ */
1
9
  import { FourPancakeProxyBatchBuySignParams, FourPancakeProxyBatchBuyResult, FourPancakeProxyBatchSellSignParams, FourPancakeProxyBatchSellResult, FourPancakeProxyApprovalParams, FourPancakeProxyApprovalBatchParams, FourPancakeProxyApprovalBatchResult } from './types.js';
2
10
  /**
3
- * 授权代币给 PancakeSwapProxy
11
+ * 授权代币给 PancakeSwap Router(根据 routeType 选择 V2/V3)
4
12
  */
5
13
  export declare function approveFourPancakeProxy(params: FourPancakeProxyApprovalParams): Promise<{
6
14
  txHash: string;
7
15
  approved: boolean;
8
16
  }>;
9
17
  /**
10
- * 批量授权代币给 PancakeSwapProxy(内部直接广播提交)
18
+ * 批量授权代币给 PancakeSwap Router
11
19
  */
12
20
  export declare function approveFourPancakeProxyBatch(params: FourPancakeProxyApprovalBatchParams): Promise<FourPancakeProxyApprovalBatchResult>;
13
21
  /**
14
- * 使用 PancakeSwapProxy 批量购买代币(Merkle 版本)
22
+ * 使用 PancakeSwap 官方 Router 批量购买代币
15
23
  */
16
24
  export declare function fourPancakeProxyBatchBuyMerkle(params: FourPancakeProxyBatchBuySignParams): Promise<FourPancakeProxyBatchBuyResult>;
17
25
  /**
18
- * 使用 PancakeSwapProxy 批量卖出代币(仅签名版本 - 不依赖 Merkle)
19
- * ✅ 精简版:只负责签名交易,不提交到 Merkle
20
- * ✅ 自动检查授权,智能处理授权+卖出
26
+ * 使用 PancakeSwap 官方 Router 批量卖出代币
21
27
  */
22
28
  export declare function fourPancakeProxyBatchSellMerkle(params: FourPancakeProxyBatchSellSignParams): Promise<FourPancakeProxyBatchSellResult>;