four-flap-meme-sdk 1.4.25 → 1.4.27
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/abis/common.d.ts +85 -0
- package/dist/abis/common.js +243 -0
- package/dist/abis/index.d.ts +1 -0
- package/dist/abis/index.js +2 -0
- package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +1 -6
- package/dist/contracts/tm-bundle-merkle/core.js +9 -16
- package/dist/contracts/tm-bundle-merkle/internal.js +6 -8
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +12 -6
- package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +224 -166
- package/dist/contracts/tm-bundle-merkle/private.js +6 -19
- package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +2 -7
- package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +1 -1
- package/dist/contracts/tm-bundle-merkle/swap-internal.js +9 -2
- package/dist/contracts/tm-bundle-merkle/swap.js +1 -3
- package/dist/contracts/tm-bundle-merkle/types.d.ts +20 -0
- package/dist/contracts/tm-bundle-merkle/utils.js +2 -3
- package/dist/dex/direct-router.d.ts +2 -1
- package/dist/dex/direct-router.js +25 -140
- package/dist/flap/constants.d.ts +2 -1
- package/dist/flap/constants.js +2 -1
- package/dist/flap/meta.js +6 -4
- package/dist/flap/portal-bundle-merkle/config.js +6 -12
- package/dist/flap/portal-bundle-merkle/core.js +8 -11
- package/dist/flap/portal-bundle-merkle/pancake-proxy.d.ts +12 -10
- package/dist/flap/portal-bundle-merkle/pancake-proxy.js +307 -370
- package/dist/flap/portal-bundle-merkle/private.js +1 -1
- package/dist/flap/portal-bundle-merkle/swap-buy-first.js +12 -30
- package/dist/flap/portal-bundle-merkle/swap.js +13 -26
- package/dist/flap/portal-bundle-merkle/types.d.ts +22 -2
- package/dist/flap/portal-bundle-merkle/utils.js +11 -16
- package/dist/index.d.ts +3 -2
- package/dist/index.js +9 -2
- package/dist/pancake/bundle-buy-first.js +56 -38
- package/dist/pancake/bundle-swap.js +114 -61
- package/dist/utils/bundle-helpers.d.ts +28 -0
- package/dist/utils/bundle-helpers.js +64 -0
- package/dist/utils/constants.d.ts +23 -1
- package/dist/utils/constants.js +37 -7
- package/dist/utils/erc20.js +17 -25
- package/dist/utils/lp-inspect.js +9 -20
- package/dist/utils/private-sale.js +1 -2
- package/dist/utils/quote-helpers.js +3 -29
- package/dist/utils/swap-helpers.js +1 -6
- package/dist/utils/wallet.d.ts +8 -13
- package/dist/utils/wallet.js +154 -342
- 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,243 @@
|
|
|
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
|
+
// ✅ 标记为 view,确保 ethers.js v6 使用 call 而不是 sendTransaction
|
|
36
|
+
'function aggregate3(tuple(address target, bool allowFailure, bytes callData)[] calls) view returns (tuple(bool success, bytes returnData)[])',
|
|
37
|
+
'function aggregate(tuple(address target, bytes callData)[] calls) view returns (uint256 blockNumber, bytes[] returnData)',
|
|
38
|
+
'function getEthBalance(address addr) view returns (uint256 balance)',
|
|
39
|
+
];
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// PancakeSwap / Uniswap V2 Router ABI
|
|
42
|
+
// ============================================================================
|
|
43
|
+
/** V2 Router 完整 ABI */
|
|
44
|
+
export const V2_ROUTER_ABI = [
|
|
45
|
+
// BNB/ETH → Token (买入)
|
|
46
|
+
'function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)',
|
|
47
|
+
'function swapExactETHForTokensSupportingFeeOnTransferTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable',
|
|
48
|
+
// Token → BNB/ETH (卖出)
|
|
49
|
+
'function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',
|
|
50
|
+
'function swapExactTokensForETHSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external',
|
|
51
|
+
// Token → Token
|
|
52
|
+
'function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',
|
|
53
|
+
'function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external',
|
|
54
|
+
// 报价
|
|
55
|
+
'function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts)',
|
|
56
|
+
'function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts)',
|
|
57
|
+
// Factory
|
|
58
|
+
'function factory() external view returns (address)',
|
|
59
|
+
];
|
|
60
|
+
/** V2 Router 精简 ABI(只用于报价) */
|
|
61
|
+
export const V2_ROUTER_QUOTE_ABI = [
|
|
62
|
+
'function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts)',
|
|
63
|
+
];
|
|
64
|
+
// ============================================================================
|
|
65
|
+
// PancakeSwap / Uniswap V3 Router ABI (SwapRouter02)
|
|
66
|
+
// ============================================================================
|
|
67
|
+
/** V3 SwapRouter02 ABI(新版,deadline 在 multicall 中传递) */
|
|
68
|
+
export const V3_ROUTER02_ABI = [
|
|
69
|
+
// exactInputSingle - 单跳,不含 deadline
|
|
70
|
+
{
|
|
71
|
+
"inputs": [{
|
|
72
|
+
"components": [
|
|
73
|
+
{ "name": "tokenIn", "type": "address" },
|
|
74
|
+
{ "name": "tokenOut", "type": "address" },
|
|
75
|
+
{ "name": "fee", "type": "uint24" },
|
|
76
|
+
{ "name": "recipient", "type": "address" },
|
|
77
|
+
{ "name": "amountIn", "type": "uint256" },
|
|
78
|
+
{ "name": "amountOutMinimum", "type": "uint256" },
|
|
79
|
+
{ "name": "sqrtPriceLimitX96", "type": "uint160" }
|
|
80
|
+
],
|
|
81
|
+
"name": "params",
|
|
82
|
+
"type": "tuple"
|
|
83
|
+
}],
|
|
84
|
+
"name": "exactInputSingle",
|
|
85
|
+
"outputs": [{ "name": "amountOut", "type": "uint256" }],
|
|
86
|
+
"stateMutability": "payable",
|
|
87
|
+
"type": "function"
|
|
88
|
+
},
|
|
89
|
+
// exactInput - 多跳,不含 deadline
|
|
90
|
+
{
|
|
91
|
+
"inputs": [{
|
|
92
|
+
"components": [
|
|
93
|
+
{ "name": "path", "type": "bytes" },
|
|
94
|
+
{ "name": "recipient", "type": "address" },
|
|
95
|
+
{ "name": "amountIn", "type": "uint256" },
|
|
96
|
+
{ "name": "amountOutMinimum", "type": "uint256" }
|
|
97
|
+
],
|
|
98
|
+
"name": "params",
|
|
99
|
+
"type": "tuple"
|
|
100
|
+
}],
|
|
101
|
+
"name": "exactInput",
|
|
102
|
+
"outputs": [{ "name": "amountOut", "type": "uint256" }],
|
|
103
|
+
"stateMutability": "payable",
|
|
104
|
+
"type": "function"
|
|
105
|
+
},
|
|
106
|
+
// multicall - 带 deadline 版本
|
|
107
|
+
'function multicall(uint256 deadline, bytes[] calldata data) external payable returns (bytes[] memory results)',
|
|
108
|
+
'function refundETH() external payable',
|
|
109
|
+
'function unwrapWETH9(uint256 amountMinimum, address recipient) external payable',
|
|
110
|
+
];
|
|
111
|
+
/** V3 SwapRouter 旧版 ABI(deadline 在 struct 内部) */
|
|
112
|
+
export const V3_ROUTER_LEGACY_ABI = [
|
|
113
|
+
// exactInputSingle - 包含 deadline
|
|
114
|
+
{
|
|
115
|
+
"inputs": [{
|
|
116
|
+
"components": [
|
|
117
|
+
{ "name": "tokenIn", "type": "address" },
|
|
118
|
+
{ "name": "tokenOut", "type": "address" },
|
|
119
|
+
{ "name": "fee", "type": "uint24" },
|
|
120
|
+
{ "name": "recipient", "type": "address" },
|
|
121
|
+
{ "name": "deadline", "type": "uint256" },
|
|
122
|
+
{ "name": "amountIn", "type": "uint256" },
|
|
123
|
+
{ "name": "amountOutMinimum", "type": "uint256" },
|
|
124
|
+
{ "name": "sqrtPriceLimitX96", "type": "uint160" }
|
|
125
|
+
],
|
|
126
|
+
"name": "params",
|
|
127
|
+
"type": "tuple"
|
|
128
|
+
}],
|
|
129
|
+
"name": "exactInputSingle",
|
|
130
|
+
"outputs": [{ "name": "amountOut", "type": "uint256" }],
|
|
131
|
+
"stateMutability": "payable",
|
|
132
|
+
"type": "function"
|
|
133
|
+
},
|
|
134
|
+
// multicall - 不带 deadline 版本
|
|
135
|
+
'function multicall(bytes[] calldata data) external payable returns (bytes[] memory results)',
|
|
136
|
+
'function refundETH() external payable',
|
|
137
|
+
'function unwrapWETH9(uint256 amountMinimum, address recipient) external payable',
|
|
138
|
+
];
|
|
139
|
+
// ============================================================================
|
|
140
|
+
// SwapRouter02 V2 方法 ABI (PotatoSwap/DYORSwap 等)
|
|
141
|
+
// ============================================================================
|
|
142
|
+
/**
|
|
143
|
+
* SwapRouter02 的 V2 方法 ABI
|
|
144
|
+
*
|
|
145
|
+
* 注意:SwapRouter02 的 V2 方法只有 token-to-token 交换
|
|
146
|
+
* 没有 swapExactETHForTokens / swapExactTokensForETH
|
|
147
|
+
* 必须通过 multicall 组合 wrapETH/unwrapWETH9 来处理原生代币
|
|
148
|
+
*/
|
|
149
|
+
export const SWAP_ROUTER02_V2_ABI = [
|
|
150
|
+
// V2 交换方法(只有 token-to-token)
|
|
151
|
+
'function swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to) external payable returns (uint256 amountOut)',
|
|
152
|
+
'function swapTokensForExactTokens(uint256 amountOut, uint256 amountInMax, address[] calldata path, address to) external payable returns (uint256 amountIn)',
|
|
153
|
+
// Multicall - 多种重载
|
|
154
|
+
'function multicall(uint256 deadline, bytes[] calldata data) external payable returns (bytes[] memory results)',
|
|
155
|
+
'function multicall(bytes32 previousBlockhash, bytes[] calldata data) external payable returns (bytes[] memory results)',
|
|
156
|
+
'function multicall(bytes[] calldata data) external payable returns (bytes[] memory results)',
|
|
157
|
+
// 辅助方法 - ETH/WETH 转换
|
|
158
|
+
'function wrapETH(uint256 value) external payable',
|
|
159
|
+
'function unwrapWETH9(uint256 amountMinimum, address recipient) external payable',
|
|
160
|
+
'function unwrapWETH9(uint256 amountMinimum) external payable',
|
|
161
|
+
'function refundETH() external payable',
|
|
162
|
+
// 代币操作
|
|
163
|
+
'function pull(address token, uint256 value) external payable',
|
|
164
|
+
'function sweepToken(address token, uint256 amountMinimum, address recipient) external payable',
|
|
165
|
+
'function sweepToken(address token, uint256 amountMinimum) external payable',
|
|
166
|
+
];
|
|
167
|
+
// ============================================================================
|
|
168
|
+
// V3 Quoter ABI
|
|
169
|
+
// ============================================================================
|
|
170
|
+
/** V3 QuoterV2 ABI */
|
|
171
|
+
export const V3_QUOTER_ABI = [
|
|
172
|
+
{
|
|
173
|
+
"inputs": [{
|
|
174
|
+
"components": [
|
|
175
|
+
{ "name": "tokenIn", "type": "address" },
|
|
176
|
+
{ "name": "tokenOut", "type": "address" },
|
|
177
|
+
{ "name": "amountIn", "type": "uint256" },
|
|
178
|
+
{ "name": "fee", "type": "uint24" },
|
|
179
|
+
{ "name": "sqrtPriceLimitX96", "type": "uint160" }
|
|
180
|
+
],
|
|
181
|
+
"name": "params",
|
|
182
|
+
"type": "tuple"
|
|
183
|
+
}],
|
|
184
|
+
"name": "quoteExactInputSingle",
|
|
185
|
+
"outputs": [
|
|
186
|
+
{ "name": "amountOut", "type": "uint256" },
|
|
187
|
+
{ "name": "sqrtPriceX96After", "type": "uint160" },
|
|
188
|
+
{ "name": "initializedTicksCrossed", "type": "uint32" },
|
|
189
|
+
{ "name": "gasEstimate", "type": "uint256" }
|
|
190
|
+
],
|
|
191
|
+
"stateMutability": "nonpayable",
|
|
192
|
+
"type": "function"
|
|
193
|
+
}
|
|
194
|
+
];
|
|
195
|
+
// ============================================================================
|
|
196
|
+
// Uniswap V2 Factory & Pair ABI
|
|
197
|
+
// ============================================================================
|
|
198
|
+
export const V2_FACTORY_ABI = [
|
|
199
|
+
'function getPair(address tokenA, address tokenB) external view returns (address pair)',
|
|
200
|
+
];
|
|
201
|
+
export const V2_PAIR_ABI = [
|
|
202
|
+
'function token0() external view returns (address)',
|
|
203
|
+
'function token1() external view returns (address)',
|
|
204
|
+
'function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast)',
|
|
205
|
+
];
|
|
206
|
+
// ============================================================================
|
|
207
|
+
// Uniswap V3 Factory & Pool ABI
|
|
208
|
+
// ============================================================================
|
|
209
|
+
export const V3_FACTORY_ABI = [
|
|
210
|
+
'function getPool(address tokenA, address tokenB, uint24 fee) external view returns (address pool)',
|
|
211
|
+
];
|
|
212
|
+
export const V3_POOL_ABI = [
|
|
213
|
+
'function token0() external view returns (address)',
|
|
214
|
+
'function token1() external view returns (address)',
|
|
215
|
+
'function fee() external view returns (uint24)',
|
|
216
|
+
'function slot0() external view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)',
|
|
217
|
+
];
|
|
218
|
+
// ============================================================================
|
|
219
|
+
// Flap Portal ABI
|
|
220
|
+
// ============================================================================
|
|
221
|
+
export const FLAP_PORTAL_ABI = [
|
|
222
|
+
// 创建代币
|
|
223
|
+
'function newToken(string name, string symbol, string meta) external payable returns (address)',
|
|
224
|
+
'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)',
|
|
225
|
+
'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)',
|
|
226
|
+
// 交易
|
|
227
|
+
'function swapExactInput((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)',
|
|
228
|
+
'function quoteExactInput((address inputToken,address outputToken,uint256 inputAmount)) external view returns (uint256)',
|
|
229
|
+
// 旧版兼容
|
|
230
|
+
'function buy(address token, uint256 minReceived) external payable returns (uint256)',
|
|
231
|
+
'function sell(address token, uint256 sellAmount, uint256 minReceived) external returns (uint256)',
|
|
232
|
+
];
|
|
233
|
+
// ============================================================================
|
|
234
|
+
// Four TokenManager ABI
|
|
235
|
+
// ============================================================================
|
|
236
|
+
export const TM2_ABI = [
|
|
237
|
+
'function buy(address token, uint256 minReceived) external payable returns (uint256)',
|
|
238
|
+
'function sell(address token, uint256 sellAmount, uint256 minReceived) external returns (uint256)',
|
|
239
|
+
'function trySell(address token, uint256 sellAmount) external view returns (uint256)',
|
|
240
|
+
];
|
|
241
|
+
export const HELPER3_ABI = [
|
|
242
|
+
'function getTokenInfo(address token) external view returns (tuple(address addr, string name, string symbol, uint8 decimals, uint256 totalSupply, uint256 balance, uint256 price, uint256 marketCap))',
|
|
243
|
+
];
|
package/dist/abis/index.d.ts
CHANGED
package/dist/abis/index.js
CHANGED
|
@@ -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
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
61
|
-
const
|
|
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
|
|
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
|
-
* 授权代币给
|
|
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
|
-
* 批量授权代币给
|
|
18
|
+
* ✅ 批量授权代币给 PancakeSwap Router
|
|
11
19
|
*/
|
|
12
20
|
export declare function approveFourPancakeProxyBatch(params: FourPancakeProxyApprovalBatchParams): Promise<FourPancakeProxyApprovalBatchResult>;
|
|
13
21
|
/**
|
|
14
|
-
* 使用
|
|
22
|
+
* ✅ 使用 PancakeSwap 官方 Router 批量购买代币
|
|
15
23
|
*/
|
|
16
24
|
export declare function fourPancakeProxyBatchBuyMerkle(params: FourPancakeProxyBatchBuySignParams): Promise<FourPancakeProxyBatchBuyResult>;
|
|
17
25
|
/**
|
|
18
|
-
* 使用
|
|
19
|
-
* ✅ 精简版:只负责签名交易,不提交到 Merkle
|
|
20
|
-
* ✅ 自动检查授权,智能处理授权+卖出
|
|
26
|
+
* ✅ 使用 PancakeSwap 官方 Router 批量卖出代币
|
|
21
27
|
*/
|
|
22
28
|
export declare function fourPancakeProxyBatchSellMerkle(params: FourPancakeProxyBatchSellSignParams): Promise<FourPancakeProxyBatchSellResult>;
|