four-flap-meme-sdk 1.9.1 → 1.9.2
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 +83 -2
- package/dist/abis/common.js +250 -2
- package/dist/abis/index.d.ts +5 -7
- package/dist/abis/index.js +6 -7
- package/dist/chains/bsc/constants.d.ts +2 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -0
- package/dist/chains/bsc/pancake/bundle-buy-first.js +14 -10
- package/dist/chains/bsc/pancake/bundle-swap.d.ts +1 -0
- package/dist/chains/bsc/pancake/bundle-swap.js +21 -24
- package/dist/chains/eni/batch-router/bundle-approve.d.ts +13 -0
- package/dist/chains/eni/batch-router/bundle-approve.js +40 -0
- package/dist/chains/eni/batch-router/bundle-buy.d.ts +19 -0
- package/dist/chains/eni/batch-router/bundle-buy.js +62 -0
- package/dist/chains/eni/batch-router/bundle-sell.d.ts +18 -0
- package/dist/chains/eni/batch-router/bundle-sell.js +47 -0
- package/dist/chains/eni/batch-router/bundle-swap.d.ts +29 -0
- package/dist/chains/eni/batch-router/bundle-swap.js +107 -0
- package/dist/chains/eni/batch-router/constants.d.ts +23 -0
- package/dist/chains/eni/batch-router/constants.js +58 -0
- package/dist/chains/eni/batch-router/index.d.ts +14 -0
- package/dist/chains/eni/batch-router/index.js +38 -0
- package/dist/chains/eni/batch-router/transfer.d.ts +53 -0
- package/dist/chains/eni/batch-router/transfer.js +104 -0
- package/dist/chains/eni/batch-router/types.d.ts +95 -0
- package/dist/chains/eni/batch-router/types.js +9 -0
- package/dist/chains/eni/batch-router/utils.d.ts +69 -0
- package/dist/chains/eni/batch-router/utils.js +155 -0
- package/dist/chains/eni/batch-router/volume.d.ts +41 -0
- package/dist/chains/eni/batch-router/volume.js +60 -0
- package/dist/chains/eni/constants.d.ts +53 -0
- package/dist/chains/eni/constants.js +83 -0
- package/dist/chains/eni/index.d.ts +16 -0
- package/dist/chains/eni/index.js +23 -0
- package/dist/chains/eni/platforms/daoaas/create.d.ts +20 -0
- package/dist/chains/eni/platforms/daoaas/create.js +82 -0
- package/dist/chains/eni/platforms/daoaas/graduation.d.ts +27 -0
- package/dist/chains/eni/platforms/daoaas/graduation.js +48 -0
- package/dist/chains/eni/platforms/daoaas/index.d.ts +13 -0
- package/dist/chains/eni/platforms/daoaas/index.js +27 -0
- package/dist/chains/eni/platforms/daoaas/meta.d.ts +32 -0
- package/dist/chains/eni/platforms/daoaas/meta.js +86 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct.d.ts +38 -0
- package/dist/chains/eni/platforms/daoaas/portal-direct.js +424 -0
- package/dist/chains/eni/platforms/daoaas/portal.d.ts +57 -0
- package/dist/chains/eni/platforms/daoaas/portal.js +146 -0
- package/dist/chains/eni/platforms/daoaas/types.d.ts +115 -0
- package/dist/chains/eni/platforms/daoaas/types.js +15 -0
- package/dist/chains/eni/platforms/fair-launch/constants.d.ts +22 -0
- package/dist/chains/eni/platforms/fair-launch/constants.js +24 -0
- package/dist/chains/eni/platforms/fair-launch/index.d.ts +11 -0
- package/dist/chains/eni/platforms/fair-launch/index.js +22 -0
- package/dist/chains/eni/platforms/fair-launch/launcher.d.ts +63 -0
- package/dist/chains/eni/platforms/fair-launch/launcher.js +274 -0
- package/dist/chains/eni/platforms/fair-launch/presets.d.ts +44 -0
- package/dist/chains/eni/platforms/fair-launch/presets.js +177 -0
- package/dist/chains/eni/platforms/fair-launch/types.d.ts +98 -0
- package/dist/chains/eni/platforms/fair-launch/types.js +21 -0
- package/dist/chains/eni/platforms/index.d.ts +5 -0
- package/dist/chains/eni/platforms/index.js +7 -0
- package/dist/chains/index.d.ts +1 -0
- package/dist/chains/index.js +2 -0
- package/dist/clients/blockrazor.d.ts +235 -2
- package/dist/clients/blockrazor.js +425 -2
- package/dist/clients/club48.d.ts +152 -2
- package/dist/clients/club48.js +329 -2
- package/dist/clients/four.d.ts +71 -4
- package/dist/clients/four.js +104 -4
- package/dist/clients/merkle.d.ts +208 -2
- package/dist/clients/merkle.js +390 -2
- package/dist/dex/direct-router.d.ts +12 -7
- package/dist/dex/direct-router.js +22 -5
- package/dist/eip7702/xlayer/approve.d.ts +141 -0
- package/dist/eip7702/xlayer/approve.js +168 -0
- package/dist/eip7702/xlayer/broadcast.d.ts +63 -0
- package/dist/eip7702/xlayer/broadcast.js +112 -0
- package/dist/eip7702/xlayer/builders.d.ts +34 -0
- package/dist/eip7702/xlayer/builders.js +100 -0
- package/dist/eip7702/xlayer/bundle.d.ts +70 -0
- package/dist/eip7702/xlayer/bundle.js +233 -0
- package/dist/eip7702/xlayer/check.d.ts +150 -0
- package/dist/eip7702/xlayer/check.js +346 -0
- package/dist/eip7702/xlayer/constants.d.ts +55 -63
- package/dist/eip7702/xlayer/constants.js +71 -170
- package/dist/eip7702/xlayer/create-to-dex.d.ts +103 -0
- package/dist/eip7702/xlayer/create-to-dex.js +369 -0
- package/dist/eip7702/xlayer/curve-to-dex.d.ts +87 -0
- package/dist/eip7702/xlayer/curve-to-dex.js +334 -0
- package/dist/eip7702/xlayer/disperse.d.ts +103 -0
- package/dist/eip7702/xlayer/disperse.js +325 -0
- package/dist/eip7702/xlayer/index.d.ts +62 -4
- package/dist/eip7702/xlayer/index.js +76 -4
- package/dist/eip7702/xlayer/profit.d.ts +105 -0
- package/dist/eip7702/xlayer/profit.js +136 -0
- package/dist/eip7702/xlayer/sign.d.ts +184 -0
- package/dist/eip7702/xlayer/sign.js +440 -0
- package/dist/eip7702/xlayer/sweep.d.ts +106 -0
- package/dist/eip7702/xlayer/sweep.js +375 -0
- package/dist/eip7702/xlayer/trade.d.ts +115 -0
- package/dist/eip7702/xlayer/trade.js +176 -0
- package/dist/eip7702/xlayer/types.d.ts +60 -474
- package/dist/eip7702/xlayer/types.js +1 -1
- package/dist/flap/abi.d.ts +1 -1
- package/dist/flap/abi.js +13 -1
- package/dist/flap/constants.d.ts +127 -1
- package/dist/flap/constants.js +142 -1
- package/dist/flap/curve.d.ts +33 -1
- package/dist/flap/curve.js +84 -1
- package/dist/flap/errors.d.ts +37 -1
- package/dist/flap/errors.js +114 -1
- package/dist/flap/ipfs.d.ts +21 -1
- package/dist/flap/ipfs.js +38 -1
- package/dist/flap/meta.d.ts +30 -1
- package/dist/flap/meta.js +195 -1
- package/dist/flap/permit.d.ts +16 -1
- package/dist/flap/permit.js +67 -1
- package/dist/flap/pinata.d.ts +40 -1
- package/dist/flap/pinata.js +106 -1
- package/dist/flap/portal-bundle-merkle/config.d.ts +1 -1
- package/dist/flap/portal-bundle-merkle/core.js +42 -179
- package/dist/flap/portal-bundle-merkle/create-to-dex.d.ts +114 -1
- package/dist/flap/portal-bundle-merkle/create-to-dex.js +555 -1
- package/dist/flap/portal-bundle-merkle/curve-to-dex.d.ts +88 -1
- package/dist/flap/portal-bundle-merkle/curve-to-dex.js +424 -1
- package/dist/flap/portal-bundle-merkle/index.d.ts +14 -1
- package/dist/flap/portal-bundle-merkle/index.js +23 -1
- package/dist/flap/portal-bundle-merkle/pancake-proxy.js +2 -3
- package/dist/flap/portal-bundle-merkle/private.js +4 -5
- package/dist/flap/portal-bundle-merkle/swap-buy-first.d.ts +65 -1
- package/dist/flap/portal-bundle-merkle/swap-buy-first.js +830 -1
- package/dist/flap/portal-bundle-merkle/swap.d.ts +201 -1
- package/dist/flap/portal-bundle-merkle/swap.js +1357 -1
- package/dist/flap/portal-bundle-merkle/types.d.ts +0 -37
- package/dist/flap/portal-bundle-merkle/utils.js +8 -7
- package/dist/flap/portal-bundle.d.ts +119 -1
- package/dist/flap/portal-bundle.js +583 -1
- package/dist/flap/portal.d.ts +301 -1
- package/dist/flap/portal.js +500 -1
- package/dist/flap/vanity.d.ts +45 -1
- package/dist/flap/vanity.js +95 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +39 -2
- package/dist/pancake/bundle-buy-first.d.ts +90 -1
- package/dist/pancake/bundle-buy-first.js +858 -1
- package/dist/pancake/bundle-swap.d.ts +212 -1
- package/dist/pancake/bundle-swap.js +1617 -1
- package/dist/shared/clients/emitservice.d.ts +47 -0
- package/dist/shared/clients/emitservice.js +44 -0
- package/dist/shared/constants/addresses.d.ts +33 -0
- package/dist/shared/constants/addresses.js +57 -1
- package/dist/shared/constants/chains.d.ts +16 -0
- package/dist/shared/constants/chains.js +19 -0
- package/dist/shared/constants/index.d.ts +2 -2
- package/dist/shared/constants/index.js +2 -2
- package/dist/shared/constants/profit.js +1 -0
- package/dist/utils/airdrop-sweep.d.ts +0 -4
- package/dist/utils/airdrop-sweep.js +19 -12
- package/dist/utils/erc20.js +32 -15
- package/dist/utils/holders-maker.d.ts +4 -2
- package/dist/utils/holders-maker.js +61 -22
- package/dist/utils/lp-inspect.d.ts +11 -2
- package/dist/utils/lp-inspect.js +69 -2
- package/dist/utils/quote-helpers.d.ts +7 -1
- package/dist/utils/quote-helpers.js +12 -2
- package/dist/utils/wallet.js +1 -0
- package/dist/xlayer/constants.d.ts +33 -35
- package/dist/xlayer/constants.js +50 -49
- package/dist/xlayer/eoa-bundle-swap.js +3 -4
- package/dist/xlayer/index.d.ts +117 -4
- package/dist/xlayer/index.js +238 -4
- package/dist/xlayer/portal-ops.d.ts +0 -27
- package/dist/xlayer/portal-ops.js +0 -6
- package/package.json +1 -1
- package/dist/clients/index.d.ts +0 -14
- package/dist/clients/index.js +0 -14
- package/dist/eip7702/xlayer/bundle-approve.d.ts +0 -67
- package/dist/eip7702/xlayer/bundle-approve.js +0 -158
- package/dist/eip7702/xlayer/bundle-buy.d.ts +0 -52
- package/dist/eip7702/xlayer/bundle-buy.js +0 -247
- package/dist/eip7702/xlayer/bundle-create.d.ts +0 -45
- package/dist/eip7702/xlayer/bundle-create.js +0 -726
- package/dist/eip7702/xlayer/bundle-sell.d.ts +0 -52
- package/dist/eip7702/xlayer/bundle-sell.js +0 -413
- package/dist/eip7702/xlayer/bundle-swap.d.ts +0 -134
- package/dist/eip7702/xlayer/bundle-swap.js +0 -917
- package/dist/eip7702/xlayer/multi-hop-transfer.d.ts +0 -210
- package/dist/eip7702/xlayer/multi-hop-transfer.js +0 -930
- package/dist/eip7702/xlayer/utils.d.ts +0 -90
- package/dist/eip7702/xlayer/utils.js +0 -491
- package/dist/eip7702/xlayer/volume.d.ts +0 -215
- package/dist/eip7702/xlayer/volume.js +0 -775
- package/dist/flap/index.d.ts +0 -5
- package/dist/flap/index.js +0 -5
- package/dist/flap/portal-bundle-merkle/encryption.d.ts +0 -16
- package/dist/flap/portal-bundle-merkle/encryption.js +0 -146
- package/dist/pancake/index.d.ts +0 -5
- package/dist/pancake/index.js +0 -5
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.js +0 -8
- package/dist/xlayer/eoa-wash-volume.d.ts +0 -90
- package/dist/xlayer/eoa-wash-volume.js +0 -202
package/dist/abis/common.d.ts
CHANGED
|
@@ -1,4 +1,85 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 公共 ABI 定义
|
|
3
|
+
*
|
|
4
|
+
* 将重复的 ABI 提取到这里,统一管理
|
|
3
5
|
*/
|
|
4
|
-
|
|
6
|
+
/** 完整 ERC20 ABI */
|
|
7
|
+
export declare const ERC20_ABI: string[];
|
|
8
|
+
/** 精简 ERC20 ABI(余额查询 + decimals) */
|
|
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[];
|
package/dist/abis/common.js
CHANGED
|
@@ -1,4 +1,252 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 公共 ABI 定义
|
|
3
|
+
*
|
|
4
|
+
* 将重复的 ABI 提取到这里,统一管理
|
|
3
5
|
*/
|
|
4
|
-
|
|
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(余额查询 + decimals) */
|
|
22
|
+
export const ERC20_BALANCE_ABI = [
|
|
23
|
+
'function balanceOf(address account) external view returns (uint256)',
|
|
24
|
+
'function decimals() external view returns (uint8)',
|
|
25
|
+
];
|
|
26
|
+
/** ERC20 授权相关 ABI */
|
|
27
|
+
export const ERC20_ALLOWANCE_ABI = [
|
|
28
|
+
'function allowance(address owner, address spender) external view returns (uint256)',
|
|
29
|
+
'function approve(address spender, uint256 amount) external returns (bool)',
|
|
30
|
+
'function decimals() external view returns (uint8)',
|
|
31
|
+
];
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Multicall3 ABI
|
|
34
|
+
// ============================================================================
|
|
35
|
+
export const MULTICALL3_ABI = [
|
|
36
|
+
// ✅ 标记为 view,确保 ethers.js v6 使用 call 而不是 sendTransaction
|
|
37
|
+
'function aggregate3(tuple(address target, bool allowFailure, bytes callData)[] calls) view returns (tuple(bool success, bytes returnData)[])',
|
|
38
|
+
'function aggregate(tuple(address target, bytes callData)[] calls) view returns (uint256 blockNumber, bytes[] returnData)',
|
|
39
|
+
'function getEthBalance(address addr) view returns (uint256 balance)',
|
|
40
|
+
];
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// PancakeSwap / Uniswap V2 Router ABI
|
|
43
|
+
// ============================================================================
|
|
44
|
+
/** V2 Router 完整 ABI */
|
|
45
|
+
export const V2_ROUTER_ABI = [
|
|
46
|
+
// BNB/ETH → Token (买入)
|
|
47
|
+
'function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)',
|
|
48
|
+
'function swapExactETHForTokensSupportingFeeOnTransferTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable',
|
|
49
|
+
// Token → BNB/ETH (卖出)
|
|
50
|
+
'function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',
|
|
51
|
+
'function swapExactTokensForETHSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external',
|
|
52
|
+
// Token → Token
|
|
53
|
+
'function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',
|
|
54
|
+
'function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external',
|
|
55
|
+
// 报价
|
|
56
|
+
'function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts)',
|
|
57
|
+
'function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts)',
|
|
58
|
+
// Factory
|
|
59
|
+
'function factory() external view returns (address)',
|
|
60
|
+
];
|
|
61
|
+
/** V2 Router 精简 ABI(只用于报价) */
|
|
62
|
+
export const V2_ROUTER_QUOTE_ABI = [
|
|
63
|
+
'function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts)',
|
|
64
|
+
];
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// PancakeSwap / Uniswap V3 Router ABI (SwapRouter02)
|
|
67
|
+
// ============================================================================
|
|
68
|
+
/** V3 SwapRouter02 ABI(新版,deadline 在 multicall 中传递) */
|
|
69
|
+
export const V3_ROUTER02_ABI = [
|
|
70
|
+
// exactInputSingle - 单跳,不含 deadline
|
|
71
|
+
{
|
|
72
|
+
"inputs": [{
|
|
73
|
+
"components": [
|
|
74
|
+
{ "name": "tokenIn", "type": "address" },
|
|
75
|
+
{ "name": "tokenOut", "type": "address" },
|
|
76
|
+
{ "name": "fee", "type": "uint24" },
|
|
77
|
+
{ "name": "recipient", "type": "address" },
|
|
78
|
+
{ "name": "amountIn", "type": "uint256" },
|
|
79
|
+
{ "name": "amountOutMinimum", "type": "uint256" },
|
|
80
|
+
{ "name": "sqrtPriceLimitX96", "type": "uint160" }
|
|
81
|
+
],
|
|
82
|
+
"name": "params",
|
|
83
|
+
"type": "tuple"
|
|
84
|
+
}],
|
|
85
|
+
"name": "exactInputSingle",
|
|
86
|
+
"outputs": [{ "name": "amountOut", "type": "uint256" }],
|
|
87
|
+
"stateMutability": "payable",
|
|
88
|
+
"type": "function"
|
|
89
|
+
},
|
|
90
|
+
// exactInput - 多跳,不含 deadline
|
|
91
|
+
{
|
|
92
|
+
"inputs": [{
|
|
93
|
+
"components": [
|
|
94
|
+
{ "name": "path", "type": "bytes" },
|
|
95
|
+
{ "name": "recipient", "type": "address" },
|
|
96
|
+
{ "name": "amountIn", "type": "uint256" },
|
|
97
|
+
{ "name": "amountOutMinimum", "type": "uint256" }
|
|
98
|
+
],
|
|
99
|
+
"name": "params",
|
|
100
|
+
"type": "tuple"
|
|
101
|
+
}],
|
|
102
|
+
"name": "exactInput",
|
|
103
|
+
"outputs": [{ "name": "amountOut", "type": "uint256" }],
|
|
104
|
+
"stateMutability": "payable",
|
|
105
|
+
"type": "function"
|
|
106
|
+
},
|
|
107
|
+
// multicall - 带 deadline 版本
|
|
108
|
+
'function multicall(uint256 deadline, bytes[] calldata data) external payable returns (bytes[] memory results)',
|
|
109
|
+
'function refundETH() external payable',
|
|
110
|
+
'function unwrapWETH9(uint256 amountMinimum, address recipient) external payable',
|
|
111
|
+
];
|
|
112
|
+
/** V3 SwapRouter 旧版 ABI(deadline 在 struct 内部) */
|
|
113
|
+
export const V3_ROUTER_LEGACY_ABI = [
|
|
114
|
+
// exactInputSingle - 包含 deadline
|
|
115
|
+
{
|
|
116
|
+
"inputs": [{
|
|
117
|
+
"components": [
|
|
118
|
+
{ "name": "tokenIn", "type": "address" },
|
|
119
|
+
{ "name": "tokenOut", "type": "address" },
|
|
120
|
+
{ "name": "fee", "type": "uint24" },
|
|
121
|
+
{ "name": "recipient", "type": "address" },
|
|
122
|
+
{ "name": "deadline", "type": "uint256" },
|
|
123
|
+
{ "name": "amountIn", "type": "uint256" },
|
|
124
|
+
{ "name": "amountOutMinimum", "type": "uint256" },
|
|
125
|
+
{ "name": "sqrtPriceLimitX96", "type": "uint160" }
|
|
126
|
+
],
|
|
127
|
+
"name": "params",
|
|
128
|
+
"type": "tuple"
|
|
129
|
+
}],
|
|
130
|
+
"name": "exactInputSingle",
|
|
131
|
+
"outputs": [{ "name": "amountOut", "type": "uint256" }],
|
|
132
|
+
"stateMutability": "payable",
|
|
133
|
+
"type": "function"
|
|
134
|
+
},
|
|
135
|
+
// multicall - 不带 deadline 版本
|
|
136
|
+
'function multicall(bytes[] calldata data) external payable returns (bytes[] memory results)',
|
|
137
|
+
'function refundETH() external payable',
|
|
138
|
+
'function unwrapWETH9(uint256 amountMinimum, address recipient) external payable',
|
|
139
|
+
];
|
|
140
|
+
// ============================================================================
|
|
141
|
+
// SwapRouter02 V2 方法 ABI (PotatoSwap/DYORSwap 等)
|
|
142
|
+
// ============================================================================
|
|
143
|
+
/**
|
|
144
|
+
* SwapRouter02 的 V2 方法 ABI
|
|
145
|
+
*
|
|
146
|
+
* 注意:SwapRouter02 的 V2 方法只有 token-to-token 交换
|
|
147
|
+
* 没有 swapExactETHForTokens / swapExactTokensForETH
|
|
148
|
+
* 必须通过 multicall 组合 wrapETH/unwrapWETH9 来处理原生代币
|
|
149
|
+
*/
|
|
150
|
+
export const SWAP_ROUTER02_V2_ABI = [
|
|
151
|
+
// V2 交换方法(只有 token-to-token)
|
|
152
|
+
'function swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to) external payable returns (uint256 amountOut)',
|
|
153
|
+
'function swapTokensForExactTokens(uint256 amountOut, uint256 amountInMax, address[] calldata path, address to) external payable returns (uint256 amountIn)',
|
|
154
|
+
// Multicall - 多种重载
|
|
155
|
+
'function multicall(uint256 deadline, bytes[] calldata data) external payable returns (bytes[] memory results)',
|
|
156
|
+
'function multicall(bytes32 previousBlockhash, bytes[] calldata data) external payable returns (bytes[] memory results)',
|
|
157
|
+
'function multicall(bytes[] calldata data) external payable returns (bytes[] memory results)',
|
|
158
|
+
// 辅助方法 - ETH/WETH 转换
|
|
159
|
+
'function wrapETH(uint256 value) external payable',
|
|
160
|
+
'function unwrapWETH9(uint256 amountMinimum, address recipient) external payable',
|
|
161
|
+
'function unwrapWETH9(uint256 amountMinimum) external payable',
|
|
162
|
+
'function refundETH() external payable',
|
|
163
|
+
// 代币操作
|
|
164
|
+
'function pull(address token, uint256 value) external payable',
|
|
165
|
+
'function sweepToken(address token, uint256 amountMinimum, address recipient) external payable',
|
|
166
|
+
'function sweepToken(address token, uint256 amountMinimum) external payable',
|
|
167
|
+
];
|
|
168
|
+
// ============================================================================
|
|
169
|
+
// V3 Quoter ABI
|
|
170
|
+
// ============================================================================
|
|
171
|
+
/** V3 QuoterV2 ABI */
|
|
172
|
+
export const V3_QUOTER_ABI = [
|
|
173
|
+
{
|
|
174
|
+
"inputs": [{
|
|
175
|
+
"components": [
|
|
176
|
+
{ "name": "tokenIn", "type": "address" },
|
|
177
|
+
{ "name": "tokenOut", "type": "address" },
|
|
178
|
+
{ "name": "amountIn", "type": "uint256" },
|
|
179
|
+
{ "name": "fee", "type": "uint24" },
|
|
180
|
+
{ "name": "sqrtPriceLimitX96", "type": "uint160" }
|
|
181
|
+
],
|
|
182
|
+
"name": "params",
|
|
183
|
+
"type": "tuple"
|
|
184
|
+
}],
|
|
185
|
+
"name": "quoteExactInputSingle",
|
|
186
|
+
"outputs": [
|
|
187
|
+
{ "name": "amountOut", "type": "uint256" },
|
|
188
|
+
{ "name": "sqrtPriceX96After", "type": "uint160" },
|
|
189
|
+
{ "name": "initializedTicksCrossed", "type": "uint32" },
|
|
190
|
+
{ "name": "gasEstimate", "type": "uint256" }
|
|
191
|
+
],
|
|
192
|
+
"stateMutability": "nonpayable",
|
|
193
|
+
"type": "function"
|
|
194
|
+
}
|
|
195
|
+
];
|
|
196
|
+
// ============================================================================
|
|
197
|
+
// Uniswap V2 Factory & Pair ABI
|
|
198
|
+
// ============================================================================
|
|
199
|
+
export const V2_FACTORY_ABI = [
|
|
200
|
+
'function getPair(address tokenA, address tokenB) external view returns (address pair)',
|
|
201
|
+
];
|
|
202
|
+
export const V2_PAIR_ABI = [
|
|
203
|
+
'function token0() external view returns (address)',
|
|
204
|
+
'function token1() external view returns (address)',
|
|
205
|
+
'function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast)',
|
|
206
|
+
];
|
|
207
|
+
// ============================================================================
|
|
208
|
+
// Uniswap V3 Factory & Pool ABI
|
|
209
|
+
// ============================================================================
|
|
210
|
+
export const V3_FACTORY_ABI = [
|
|
211
|
+
'function getPool(address tokenA, address tokenB, uint24 fee) external view returns (address pool)',
|
|
212
|
+
];
|
|
213
|
+
export const V3_POOL_ABI = [
|
|
214
|
+
'function token0() external view returns (address)',
|
|
215
|
+
'function token1() external view returns (address)',
|
|
216
|
+
'function fee() external view returns (uint24)',
|
|
217
|
+
'function slot0() external view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)',
|
|
218
|
+
];
|
|
219
|
+
// ============================================================================
|
|
220
|
+
// Flap Portal ABI
|
|
221
|
+
// ============================================================================
|
|
222
|
+
export const FLAP_PORTAL_ABI = [
|
|
223
|
+
// 创建代币
|
|
224
|
+
'function newToken(string name, string symbol, string meta) external payable returns (address)',
|
|
225
|
+
'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)',
|
|
226
|
+
'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)',
|
|
227
|
+
// ✅ V4:支持 dexId / lpFeeProfile(与 portal-bundle-merkle/core.ts 的 newTokenV4.populateTransaction 对齐)
|
|
228
|
+
'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)) external payable returns (address)',
|
|
229
|
+
// 交易
|
|
230
|
+
'function swapExactInput((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)',
|
|
231
|
+
// ✅ V3:支持 extensionData(注意:这里的 V3 指“扩展交易接口版本”,不是“外盘 V3 池子”)
|
|
232
|
+
'function swapExactInputV3((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData,bytes extensionData)) external payable returns (uint256)',
|
|
233
|
+
'function quoteExactInput((address inputToken,address outputToken,uint256 inputAmount)) external view returns (uint256)',
|
|
234
|
+
// 旧版兼容
|
|
235
|
+
'function buy(address token, uint256 minReceived) external payable returns (uint256)',
|
|
236
|
+
'function sell(address token, uint256 sellAmount, uint256 minReceived) external returns (uint256)',
|
|
237
|
+
];
|
|
238
|
+
// ============================================================================
|
|
239
|
+
// Four TokenManager ABI
|
|
240
|
+
// ============================================================================
|
|
241
|
+
export const TM2_ABI = [
|
|
242
|
+
// 新版方法(Four.meme TokenManager2)
|
|
243
|
+
'function buyTokenAMAP(uint256 origin, address token, address to, uint256 funds, uint256 minAmount) external payable',
|
|
244
|
+
'function sellToken(uint256 origin, address token, uint256 amount, uint256 minFunds) external',
|
|
245
|
+
// 旧版兼容方法
|
|
246
|
+
'function buy(address token, uint256 minReceived) external payable returns (uint256)',
|
|
247
|
+
'function sell(address token, uint256 sellAmount, uint256 minReceived) external returns (uint256)',
|
|
248
|
+
'function trySell(address token, uint256 sellAmount) external view returns (uint256)',
|
|
249
|
+
];
|
|
250
|
+
export const HELPER3_ABI = [
|
|
251
|
+
'function getTokenInfo(address token) external view returns (tuple(address addr, string name, string symbol, uint8 decimals, uint256 totalSupply, uint256 balance, uint256 price, uint256 marketCap))',
|
|
252
|
+
];
|
package/dist/abis/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
export * from '../shared/abis/index.js';
|
|
1
|
+
import TokenManager from './TokenManager.json';
|
|
2
|
+
import TokenManager2 from './TokenManager2.json';
|
|
3
|
+
import TokenManagerHelper3 from './TokenManagerHelper3.json';
|
|
4
|
+
export { TokenManager, TokenManager2, TokenManagerHelper3 };
|
|
5
|
+
export * from './common.js';
|
package/dist/abis/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export * from '../shared/abis/index.js';
|
|
1
|
+
import TokenManager from './TokenManager.json' with { type: 'json' };
|
|
2
|
+
import TokenManager2 from './TokenManager2.json' with { type: 'json' };
|
|
3
|
+
import TokenManagerHelper3 from './TokenManagerHelper3.json' with { type: 'json' };
|
|
4
|
+
export { TokenManager, TokenManager2, TokenManagerHelper3 };
|
|
5
|
+
// ✅ 公共 ABI 导出
|
|
6
|
+
export * from './common.js';
|
|
@@ -24,6 +24,8 @@ export declare const BSC_ADDRESSES: {
|
|
|
24
24
|
readonly PancakeV3Factory: "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865";
|
|
25
25
|
readonly Multicall3: "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
26
26
|
readonly BlockRazorBuilder: "0x1266C6bE60392A8Ff346E8d5ECCd3E69dD9c5F20";
|
|
27
|
+
readonly IroSwapV2Factory: "0x637D87a4165C5fF8f6cdDa8EC8cA394b1f0CEcdf";
|
|
28
|
+
readonly IroSwapV2Router: "0xe90fb729E458092592a79EdaFefB3404ecb3C463";
|
|
27
29
|
};
|
|
28
30
|
export declare const WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
|
|
29
31
|
export declare const USDT: "0x55d398326f99059fF775485246999027B3197955";
|
|
@@ -189,7 +189,8 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
189
189
|
buyer,
|
|
190
190
|
seller,
|
|
191
191
|
tokenAddress,
|
|
192
|
-
useNativeToken
|
|
192
|
+
useNativeToken,
|
|
193
|
+
v2RouterAddress: config.v2RouterAddress
|
|
193
194
|
});
|
|
194
195
|
const finalGasLimit = getGasLimit(config);
|
|
195
196
|
const gasPrice = await getGasPrice(context.provider, config);
|
|
@@ -411,13 +412,14 @@ async function quoteTokenOutput({ routeParams, buyerFundsWei, provider }) {
|
|
|
411
412
|
/**
|
|
412
413
|
* ✅ 构建多笔买入和卖出交易
|
|
413
414
|
*/
|
|
414
|
-
async function buildMultiRouteTransactions({ routeParams, buyAmountsWei, sellAmountsWei, buyer, seller, tokenAddress, useNativeToken = true }) {
|
|
415
|
+
async function buildMultiRouteTransactions({ routeParams, buyAmountsWei, sellAmountsWei, buyer, seller, tokenAddress, useNativeToken = true, v2RouterAddress }) {
|
|
415
416
|
const deadline = getDeadline();
|
|
416
417
|
if (routeParams.routeType === 'v2') {
|
|
417
418
|
const { v2Path } = routeParams;
|
|
418
419
|
const reversePath = [...v2Path].reverse();
|
|
419
|
-
const
|
|
420
|
-
const
|
|
420
|
+
const v2Addr = v2RouterAddress || PANCAKE_V2_ROUTER_ADDRESS;
|
|
421
|
+
const v2RouterBuyer = new Contract(v2Addr, PANCAKE_V2_ROUTER_ABI, buyer);
|
|
422
|
+
const v2RouterSeller = new Contract(v2Addr, PANCAKE_V2_ROUTER_ABI, seller);
|
|
421
423
|
// ✅ 根据是否使用原生代币选择不同的函数
|
|
422
424
|
if (useNativeToken) {
|
|
423
425
|
// BNB 池子:使用 swapExactETHForTokens / swapExactTokensForETH
|
|
@@ -717,7 +719,8 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
717
719
|
buyer,
|
|
718
720
|
tokenAddress,
|
|
719
721
|
useNativeToken,
|
|
720
|
-
deadline
|
|
722
|
+
deadline,
|
|
723
|
+
v2RouterAddress: config.v2RouterAddress
|
|
721
724
|
});
|
|
722
725
|
return buyer.signTransaction({
|
|
723
726
|
...unsigned,
|
|
@@ -737,7 +740,8 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
737
740
|
seller,
|
|
738
741
|
tokenAddress,
|
|
739
742
|
useNativeToken,
|
|
740
|
-
deadline
|
|
743
|
+
deadline,
|
|
744
|
+
v2RouterAddress: config.v2RouterAddress
|
|
741
745
|
});
|
|
742
746
|
return seller.signTransaction({
|
|
743
747
|
...unsigned,
|
|
@@ -800,10 +804,10 @@ async function pancakeBundleBuyFirstMultiWallet(params) {
|
|
|
800
804
|
};
|
|
801
805
|
}
|
|
802
806
|
// ✅ 构建单笔买入交易
|
|
803
|
-
async function buildSingleBuyTx({ routeParams, buyAmount, buyer, tokenAddress, useNativeToken, deadline }) {
|
|
807
|
+
async function buildSingleBuyTx({ routeParams, buyAmount, buyer, tokenAddress, useNativeToken, deadline, v2RouterAddress }) {
|
|
804
808
|
if (routeParams.routeType === 'v2') {
|
|
805
809
|
const { v2Path } = routeParams;
|
|
806
|
-
const v2Router = new Contract(PANCAKE_V2_ROUTER_ADDRESS, PANCAKE_V2_ROUTER_ABI, buyer);
|
|
810
|
+
const v2Router = new Contract(v2RouterAddress || PANCAKE_V2_ROUTER_ADDRESS, PANCAKE_V2_ROUTER_ABI, buyer);
|
|
807
811
|
if (useNativeToken) {
|
|
808
812
|
return await v2Router.swapExactETHForTokensSupportingFeeOnTransferTokens.populateTransaction(0n, v2Path, buyer.address, deadline, { value: buyAmount });
|
|
809
813
|
}
|
|
@@ -830,11 +834,11 @@ async function buildSingleBuyTx({ routeParams, buyAmount, buyer, tokenAddress, u
|
|
|
830
834
|
throw new Error('V3 多跳路由暂不支持');
|
|
831
835
|
}
|
|
832
836
|
// ✅ 构建单笔卖出交易
|
|
833
|
-
async function buildSingleSellTx({ routeParams, sellAmount, seller, tokenAddress, useNativeToken, deadline }) {
|
|
837
|
+
async function buildSingleSellTx({ routeParams, sellAmount, seller, tokenAddress, useNativeToken, deadline, v2RouterAddress }) {
|
|
834
838
|
if (routeParams.routeType === 'v2') {
|
|
835
839
|
const { v2Path } = routeParams;
|
|
836
840
|
const reversePath = [...v2Path].reverse();
|
|
837
|
-
const v2Router = new Contract(PANCAKE_V2_ROUTER_ADDRESS, PANCAKE_V2_ROUTER_ABI, seller);
|
|
841
|
+
const v2Router = new Contract(v2RouterAddress || PANCAKE_V2_ROUTER_ADDRESS, PANCAKE_V2_ROUTER_ABI, seller);
|
|
838
842
|
if (useNativeToken) {
|
|
839
843
|
return await v2Router.swapExactTokensForETHSupportingFeeOnTransferTokens.populateTransaction(sellAmount, 0n, reversePath, seller.address, deadline);
|
|
840
844
|
}
|
|
@@ -12,6 +12,7 @@ export interface PancakeSwapSignConfig {
|
|
|
12
12
|
reserveGasBNB?: number;
|
|
13
13
|
userType?: UserType;
|
|
14
14
|
bribeAmount?: number;
|
|
15
|
+
v2RouterAddress?: string;
|
|
15
16
|
}
|
|
16
17
|
export type SwapRouteType = 'v2' | 'v3-single' | 'v3-multi';
|
|
17
18
|
export interface PancakeSwapConfig extends CommonBundleConfig {
|
|
@@ -235,7 +235,7 @@ function createPancakeContext(config) {
|
|
|
235
235
|
});
|
|
236
236
|
return { chainId, provider };
|
|
237
237
|
}
|
|
238
|
-
async function quoteSellOutput({ routeParams, sellAmountWei, provider }) {
|
|
238
|
+
async function quoteSellOutput({ routeParams, sellAmountWei, provider, v2RouterAddress }) {
|
|
239
239
|
console.log(`[quoteSellOutput] 开始报价, routeType=${routeParams.routeType}, sellAmount=${sellAmountWei} wei`);
|
|
240
240
|
// ==================== V2 报价 ====================
|
|
241
241
|
if (routeParams.routeType === 'v2') {
|
|
@@ -243,8 +243,7 @@ async function quoteSellOutput({ routeParams, sellAmountWei, provider }) {
|
|
|
243
243
|
const tokenIn = v2Path[0];
|
|
244
244
|
const tokenOut = v2Path[v2Path.length - 1];
|
|
245
245
|
console.log(`[quoteSellOutput] V2 路径: ${v2Path.join(' → ')}`);
|
|
246
|
-
|
|
247
|
-
const result = await quoteV2(provider, tokenIn, tokenOut, sellAmountWei, 'BSC');
|
|
246
|
+
const result = await quoteV2(provider, tokenIn, tokenOut, sellAmountWei, 'BSC', v2RouterAddress);
|
|
248
247
|
if (result.amountOut > 0n) {
|
|
249
248
|
console.log(`[quoteSellOutput] V2 报价成功: ${ethers.formatEther(result.amountOut)} BNB`);
|
|
250
249
|
return { estimatedBNBOut: result.amountOut };
|
|
@@ -283,16 +282,15 @@ async function quoteSellOutput({ routeParams, sellAmountWei, provider }) {
|
|
|
283
282
|
}
|
|
284
283
|
throw new Error(`不支持的路由类型: ${routeParams.routeType}`);
|
|
285
284
|
}
|
|
286
|
-
async function buildSwapTransactions({ routeParams, sellAmountWei, buyAmountBNB, buyer, seller, tokenAddress, useNativeToken = true }) {
|
|
285
|
+
async function buildSwapTransactions({ routeParams, sellAmountWei, buyAmountBNB, buyer, seller, tokenAddress, useNativeToken = true, v2RouterAddress }) {
|
|
287
286
|
const deadline = getDeadline();
|
|
288
|
-
// ✅ ERC20 购买时,value = 0(通过代币授权支付)
|
|
289
287
|
const buyValue = useNativeToken ? buyAmountBNB + FLAT_FEE : 0n;
|
|
290
288
|
if (routeParams.routeType === 'v2') {
|
|
291
289
|
const { v2Path } = routeParams;
|
|
292
290
|
const reversePath = [...v2Path].reverse();
|
|
293
|
-
|
|
294
|
-
const v2RouterSeller = new Contract(
|
|
295
|
-
const v2RouterBuyer = new Contract(
|
|
291
|
+
const routerAddr = v2RouterAddress || PANCAKE_V2_ROUTER_ADDRESS;
|
|
292
|
+
const v2RouterSeller = new Contract(routerAddr, PANCAKE_V2_ROUTER_ABI, seller);
|
|
293
|
+
const v2RouterBuyer = new Contract(routerAddr, PANCAKE_V2_ROUTER_ABI, buyer);
|
|
296
294
|
let sellUnsigned;
|
|
297
295
|
let buyUnsigned;
|
|
298
296
|
if (useNativeToken) {
|
|
@@ -609,7 +607,8 @@ export async function pancakeBundleSwapMerkle(params) {
|
|
|
609
607
|
const quoteResult = await quoteSellOutput({
|
|
610
608
|
routeParams,
|
|
611
609
|
sellAmountWei,
|
|
612
|
-
provider: context.provider
|
|
610
|
+
provider: context.provider,
|
|
611
|
+
v2RouterAddress: config.v2RouterAddress
|
|
613
612
|
});
|
|
614
613
|
const buyerBudget = await calculateBuyerBudget({
|
|
615
614
|
buyer,
|
|
@@ -627,7 +626,8 @@ export async function pancakeBundleSwapMerkle(params) {
|
|
|
627
626
|
buyer,
|
|
628
627
|
seller,
|
|
629
628
|
tokenAddress,
|
|
630
|
-
useNativeToken
|
|
629
|
+
useNativeToken,
|
|
630
|
+
v2RouterAddress: config.v2RouterAddress
|
|
631
631
|
});
|
|
632
632
|
// ✅ 修复:利润计算应基于 BNB 数量,不是 ERC20 数量
|
|
633
633
|
// 如果输出是原生代币(BNB),直接使用报价结果
|
|
@@ -787,11 +787,11 @@ export async function pancakeBatchSwapMerkle(params) {
|
|
|
787
787
|
calculateSellAmount(context.provider, tokenAddress, seller.address, sellAmount, sellPercentage)
|
|
788
788
|
]);
|
|
789
789
|
const { amount: sellAmountWei, decimals } = sellAmountResult;
|
|
790
|
-
// ✅ 获取卖出报价
|
|
791
790
|
const quoteResult = await quoteSellOutput({
|
|
792
791
|
routeParams,
|
|
793
792
|
sellAmountWei,
|
|
794
|
-
provider: context.provider
|
|
793
|
+
provider: context.provider,
|
|
794
|
+
v2RouterAddress: config.v2RouterAddress
|
|
795
795
|
});
|
|
796
796
|
const estimatedBNBOut = quoteResult.estimatedBNBOut;
|
|
797
797
|
// ✅ 计算每个买方的买入金额(已移除滑点保护:直接使用报价金额)
|
|
@@ -837,13 +837,13 @@ export async function pancakeBatchSwapMerkle(params) {
|
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
839
|
}));
|
|
840
|
-
// ✅ 构建卖出交易(使用官方 Router)
|
|
841
840
|
const deadline = getDeadline();
|
|
842
841
|
const v3RouterIface = new ethers.Interface(PANCAKE_V3_ROUTER_ABI);
|
|
842
|
+
const batchV2Addr = config.v2RouterAddress || PANCAKE_V2_ROUTER_ADDRESS;
|
|
843
843
|
let sellUnsigned;
|
|
844
844
|
if (routeParams.routeType === 'v2') {
|
|
845
845
|
const { v2Path } = routeParams;
|
|
846
|
-
const v2RouterSeller = new Contract(
|
|
846
|
+
const v2RouterSeller = new Contract(batchV2Addr, PANCAKE_V2_ROUTER_ABI, seller);
|
|
847
847
|
if (useNativeToken) {
|
|
848
848
|
// ✅ 原生代币模式(BNB):Token → WBNB → BNB
|
|
849
849
|
sellUnsigned = await v2RouterSeller.swapExactTokensForETHSupportingFeeOnTransferTokens.populateTransaction(sellAmountWei, 0n, v2Path, seller.address, deadline);
|
|
@@ -878,15 +878,13 @@ export async function pancakeBatchSwapMerkle(params) {
|
|
|
878
878
|
else {
|
|
879
879
|
throw new Error('V3 多跳路由暂不支持官方合约,请使用 V2 路由或 V3 单跳');
|
|
880
880
|
}
|
|
881
|
-
// ✅ 并行构建多个买入交易(使用官方 Router)
|
|
882
881
|
const buyUnsignedList = await Promise.all(buyers.map(async (buyer, i) => {
|
|
883
882
|
const buyAmount = buyAmountsWei[i];
|
|
884
|
-
// ✅ ERC20 模式:value = 0(通过代币授权支付)
|
|
885
883
|
const buyValue = useNativeToken ? buyAmount + FLAT_FEE : 0n;
|
|
886
884
|
if (routeParams.routeType === 'v2') {
|
|
887
885
|
const { v2Path } = routeParams;
|
|
888
886
|
const reversePath = [...v2Path].reverse();
|
|
889
|
-
const v2RouterBuyer = new Contract(
|
|
887
|
+
const v2RouterBuyer = new Contract(batchV2Addr, PANCAKE_V2_ROUTER_ABI, buyer);
|
|
890
888
|
if (useNativeToken) {
|
|
891
889
|
// ✅ 原生代币模式(BNB):BNB → WBNB → Token
|
|
892
890
|
return await v2RouterBuyer.swapExactETHForTokensSupportingFeeOnTransferTokens.populateTransaction(0n, reversePath, buyer.address, deadline, { value: buyValue });
|
|
@@ -1149,11 +1147,11 @@ export async function pancakeQuickBatchSwapMerkle(params) {
|
|
|
1149
1147
|
v3TokenOut: routeParams.v3TokenOut,
|
|
1150
1148
|
v3Fee: routeParams.v3Fee
|
|
1151
1149
|
}));
|
|
1152
|
-
// ✅ 获取卖出报价
|
|
1153
1150
|
const quoteResult = await quoteSellOutput({
|
|
1154
1151
|
routeParams,
|
|
1155
1152
|
sellAmountWei,
|
|
1156
|
-
provider: context.provider
|
|
1153
|
+
provider: context.provider,
|
|
1154
|
+
v2RouterAddress: config.v2RouterAddress
|
|
1157
1155
|
});
|
|
1158
1156
|
const estimatedOutput = quoteResult.estimatedBNBOut;
|
|
1159
1157
|
const outputFormatted = useNativeToken
|
|
@@ -1240,12 +1238,13 @@ export async function pancakeQuickBatchSwapMerkle(params) {
|
|
|
1240
1238
|
});
|
|
1241
1239
|
console.log(`[pancakeQuickBatchSwapMerkle] 贿赂交易已签名`);
|
|
1242
1240
|
}
|
|
1243
|
-
// ==================== 2.
|
|
1241
|
+
// ==================== 2. 卖出交易 ====================
|
|
1244
1242
|
const v3RouterIface2 = new ethers.Interface(PANCAKE_V3_ROUTER_ABI);
|
|
1243
|
+
const quickV2Addr = config.v2RouterAddress || PANCAKE_V2_ROUTER_ADDRESS;
|
|
1245
1244
|
let sellUnsigned;
|
|
1246
1245
|
if (routeParams.routeType === 'v2') {
|
|
1247
1246
|
const { v2Path } = routeParams;
|
|
1248
|
-
const v2RouterSeller = new Contract(
|
|
1247
|
+
const v2RouterSeller = new Contract(quickV2Addr, PANCAKE_V2_ROUTER_ABI, seller);
|
|
1249
1248
|
if (useNativeToken) {
|
|
1250
1249
|
// ✅ 原生代币模式(BNB):Token → WBNB → BNB
|
|
1251
1250
|
sellUnsigned = await v2RouterSeller.swapExactTokensForETHSupportingFeeOnTransferTokens.populateTransaction(sellAmountWei, 0n, v2Path, seller.address, deadline);
|
|
@@ -1387,13 +1386,11 @@ export async function pancakeQuickBatchSwapMerkle(params) {
|
|
|
1387
1386
|
if (routeParams.routeType === 'v2') {
|
|
1388
1387
|
const { v2Path } = routeParams;
|
|
1389
1388
|
const reversePath = [...v2Path].reverse();
|
|
1390
|
-
const v2RouterBuyer = new Contract(
|
|
1389
|
+
const v2RouterBuyer = new Contract(quickV2Addr, PANCAKE_V2_ROUTER_ABI, buyer);
|
|
1391
1390
|
if (useNativeToken) {
|
|
1392
|
-
// ✅ 原生代币模式(BNB):BNB → WBNB → Token
|
|
1393
1391
|
buyUnsigned = await v2RouterBuyer.swapExactETHForTokensSupportingFeeOnTransferTokens.populateTransaction(0n, reversePath, buyer.address, deadline, { value: buyValue });
|
|
1394
1392
|
}
|
|
1395
1393
|
else {
|
|
1396
|
-
// ✅ ERC20 模式(USDT):USDT → Token
|
|
1397
1394
|
buyUnsigned = await v2RouterBuyer.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(buyAmount, 0n, reversePath, buyer.address, deadline);
|
|
1398
1395
|
}
|
|
1399
1396
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ENI BatchRouter — 批量授权
|
|
3
|
+
*
|
|
4
|
+
* 各钱包独立签名 approve(BatchRouter, MaxUint256)
|
|
5
|
+
* ENI 不支持 EIP-7702,所以无法在一笔 tx 中完成多钱包 approve
|
|
6
|
+
* 采用并行广播策略
|
|
7
|
+
*/
|
|
8
|
+
import type { BatchApproveParams, BatchApproveResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* 批量 approve — 各钱包并行签名
|
|
11
|
+
* 一次性 approve MaxUint256,后续无需重复授权
|
|
12
|
+
*/
|
|
13
|
+
export declare function batchApprove(params: BatchApproveParams): Promise<BatchApproveResult>;
|