four-flap-meme-sdk 2.0.0 → 2.2.0

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 (220) hide show
  1. package/dist/__tests__/subpath-exports.test.js +64 -0
  2. package/dist/chains/bsc/iro.d.ts +5 -0
  3. package/dist/chains/bsc/iro.js +4 -0
  4. package/dist/chains/eni/flat-aliases.d.ts +10 -0
  5. package/dist/chains/eni/flat-aliases.js +8 -0
  6. package/dist/chains/eni/index.d.ts +1 -0
  7. package/dist/chains/eni/index.js +1 -0
  8. package/dist/chains/index.d.ts +13 -0
  9. package/dist/chains/index.js +13 -0
  10. package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +13 -0
  11. package/dist/chains/xlayer/eip7702/flat-aliases.js +10 -0
  12. package/dist/chains/xlayer/eip7702/index.d.ts +1 -0
  13. package/dist/chains/xlayer/eip7702/index.js +1 -0
  14. package/dist/chains/xlayer/index.d.ts +3 -2
  15. package/dist/chains/xlayer/index.js +4 -7
  16. package/dist/flap/index.d.ts +10 -0
  17. package/dist/flap/index.js +8 -0
  18. package/dist/merkle/index.d.ts +12 -0
  19. package/dist/merkle/index.js +11 -0
  20. package/dist/shared/constants/index.d.ts +2 -0
  21. package/dist/shared/index.d.ts +2 -0
  22. package/dist/vanity/index.d.ts +5 -0
  23. package/dist/vanity/index.js +5 -0
  24. package/package.json +93 -2
  25. package/dist/chains/bsc/four/disperse.d.ts +0 -12
  26. package/dist/chains/bsc/four/disperse.js +0 -470
  27. package/dist/chains/bsc/four/pairwise.d.ts +0 -7
  28. package/dist/chains/bsc/four/pairwise.js +0 -308
  29. package/dist/chains/bsc/four/submit/blockrazor.d.ts +0 -18
  30. package/dist/chains/bsc/four/submit/blockrazor.js +0 -86
  31. package/dist/chains/bsc/four/submit/direct.d.ts +0 -66
  32. package/dist/chains/bsc/four/submit/direct.js +0 -452
  33. package/dist/chains/bsc/four/submit/helpers.d.ts +0 -18
  34. package/dist/chains/bsc/four/submit/helpers.js +0 -57
  35. package/dist/chains/bsc/four/submit/index.d.ts +0 -12
  36. package/dist/chains/bsc/four/submit/index.js +0 -11
  37. package/dist/chains/bsc/four/submit/merkle.d.ts +0 -18
  38. package/dist/chains/bsc/four/submit/merkle.js +0 -74
  39. package/dist/chains/bsc/four/submit/types.d.ts +0 -143
  40. package/dist/chains/bsc/four/swap/index.d.ts +0 -32
  41. package/dist/chains/bsc/four/swap/index.js +0 -829
  42. package/dist/chains/bsc/four/swap/types.d.ts +0 -70
  43. package/dist/chains/bsc/four/swap/types.js +0 -1
  44. package/dist/chains/bsc/four/sweep.d.ts +0 -13
  45. package/dist/chains/bsc/four/sweep.js +0 -788
  46. package/dist/chains/bsc/four/utils/index.d.ts +0 -20
  47. package/dist/chains/bsc/four/utils/index.js +0 -1558
  48. package/dist/chains/bsc/four/utils/types.d.ts +0 -1
  49. package/dist/chains/bsc/four/utils/types.js +0 -1
  50. package/dist/chains/bsc/pancake/bundle-buy-first/index.d.ts +0 -8
  51. package/dist/chains/bsc/pancake/bundle-buy-first/index.js +0 -907
  52. package/dist/chains/bsc/pancake/bundle-buy-first/types.d.ts +0 -73
  53. package/dist/chains/bsc/pancake/bundle-buy-first/types.js +0 -1
  54. package/dist/chains/bsc/pancake/bundle-swap/helpers.d.ts +0 -102
  55. package/dist/chains/bsc/pancake/bundle-swap/helpers.js +0 -572
  56. package/dist/chains/bsc/pancake/bundle-swap/index.d.ts +0 -50
  57. package/dist/chains/bsc/pancake/bundle-swap/index.js +0 -1066
  58. package/dist/chains/bsc/pancake/bundle-swap/types.d.ts +0 -202
  59. package/dist/chains/bsc/pancake/bundle-swap/types.js +0 -3
  60. package/dist/chains/xlayer/eip7702/bundle-swap/index.d.ts +0 -72
  61. package/dist/chains/xlayer/eip7702/bundle-swap/index.js +0 -921
  62. package/dist/chains/xlayer/eip7702/bundle-swap/types.d.ts +0 -65
  63. package/dist/chains/xlayer/eip7702/bundle-swap/types.js +0 -1
  64. package/dist/chains/xlayer/eip7702/multi-hop-transfer/index.d.ts +0 -128
  65. package/dist/chains/xlayer/eip7702/multi-hop-transfer/index.js +0 -857
  66. package/dist/chains/xlayer/eip7702/multi-hop-transfer/types.d.ts +0 -85
  67. package/dist/chains/xlayer/eip7702/multi-hop-transfer/types.js +0 -1
  68. package/dist/chains/xlayer/eip7702/volume/index.d.ts +0 -96
  69. package/dist/chains/xlayer/eip7702/volume/index.js +0 -793
  70. package/dist/chains/xlayer/eip7702/volume/types.d.ts +0 -124
  71. package/dist/chains/xlayer/eip7702/volume/types.js +0 -1
  72. package/dist/chains/xlayer/eoa/types-core.d.ts +0 -363
  73. package/dist/chains/xlayer/eoa/types-core.js +0 -53
  74. package/dist/chains/xlayer/eoa/types-create.d.ts +0 -413
  75. package/dist/chains/xlayer/eoa/types-create.js +0 -9
  76. package/dist/chains/xlayer/eoa/types-volume.d.ts +0 -209
  77. package/dist/chains/xlayer/eoa/types-volume.js +0 -13
  78. package/dist/dex/direct-router/index.d.ts +0 -70
  79. package/dist/dex/direct-router/index.js +0 -1410
  80. package/dist/dex/direct-router/types.d.ts +0 -81
  81. package/dist/dex/direct-router/types.js +0 -1
  82. package/dist/shared/abis/TaxToken.json +0 -969
  83. package/dist/shared/abis/TokenManager.json +0 -836
  84. package/dist/shared/abis/TokenManager2.json +0 -136
  85. package/dist/shared/abis/TokenManagerHelper3.json +0 -993
  86. package/dist/shared/abis 2/TaxToken.json +0 -105
  87. package/dist/shared/abis 2/TokenManager.json +0 -836
  88. package/dist/shared/abis 2/TokenManager2.json +0 -60
  89. package/dist/shared/abis 2/TokenManagerHelper3.json +0 -993
  90. package/dist/shared/abis 2/common.d.ts +0 -85
  91. package/dist/shared/abis 2/common.js +0 -254
  92. package/dist/shared/abis 2/index.d.ts +0 -8
  93. package/dist/shared/abis 2/index.js +0 -8
  94. package/dist/shared/clients 2/blockrazor.d.ts +0 -314
  95. package/dist/shared/clients 2/blockrazor.js +0 -596
  96. package/dist/shared/clients 2/club48.d.ts +0 -154
  97. package/dist/shared/clients 2/club48.js +0 -331
  98. package/dist/shared/clients 2/emitservice.d.ts +0 -47
  99. package/dist/shared/clients 2/emitservice.js +0 -44
  100. package/dist/shared/clients 2/four.d.ts +0 -132
  101. package/dist/shared/clients 2/four.js +0 -281
  102. package/dist/shared/clients 2/merkle.d.ts +0 -210
  103. package/dist/shared/clients 2/merkle.js +0 -400
  104. package/dist/shared/flap/__tests__/curve.test.d.ts +0 -1
  105. package/dist/shared/flap/__tests__/curve.test.js +0 -85
  106. package/dist/shared/flap/portal/index.d.ts +0 -12
  107. package/dist/shared/flap/portal/index.js +0 -11
  108. package/dist/shared/flap/portal/portal.d.ts +0 -47
  109. package/dist/shared/flap/portal/portal.js +0 -218
  110. package/dist/shared/flap/portal/types.d.ts +0 -227
  111. package/dist/shared/flap/portal/types.js +0 -80
  112. package/dist/shared/flap/portal/writer.d.ts +0 -121
  113. package/dist/shared/flap/portal/writer.js +0 -265
  114. package/dist/shared/flap/portal-bundle-merkle/core/index.d.ts +0 -18
  115. package/dist/shared/flap/portal-bundle-merkle/core/index.js +0 -938
  116. package/dist/shared/flap/portal-bundle-merkle/core/types.d.ts +0 -1
  117. package/dist/shared/flap/portal-bundle-merkle/core/types.js +0 -1
  118. package/dist/shared/flap/portal-bundle-merkle/swap/index.d.ts +0 -42
  119. package/dist/shared/flap/portal-bundle-merkle/swap/index.js +0 -1448
  120. package/dist/shared/flap/portal-bundle-merkle/swap/types.d.ts +0 -84
  121. package/dist/shared/flap/portal-bundle-merkle/swap/types.js +0 -1
  122. package/dist/shared/flap/portal-bundle-merkle/utils/index.d.ts +0 -17
  123. package/dist/shared/flap/portal-bundle-merkle/utils/index.js +0 -1024
  124. package/dist/shared/flap/portal-bundle-merkle/utils/types.d.ts +0 -16
  125. package/dist/shared/flap/portal-bundle-merkle/utils/types.js +0 -1
  126. package/dist/shared/flap/portal-bundle-merkle/utils-helpers.d.ts +0 -100
  127. package/dist/shared/flap/portal-bundle-merkle/utils-helpers.js +0 -133
  128. package/dist/shared/flap 2/__tests__/curve.test.d.ts +0 -1
  129. package/dist/shared/flap 2/__tests__/curve.test.js +0 -85
  130. package/dist/shared/flap 2/abi.d.ts +0 -4
  131. package/dist/shared/flap 2/abi.js +0 -4
  132. package/dist/shared/flap 2/constants.d.ts +0 -128
  133. package/dist/shared/flap 2/constants.js +0 -143
  134. package/dist/shared/flap 2/curve.d.ts +0 -33
  135. package/dist/shared/flap 2/curve.js +0 -84
  136. package/dist/shared/flap 2/errors.d.ts +0 -37
  137. package/dist/shared/flap 2/errors.js +0 -114
  138. package/dist/shared/flap 2/index.d.ts +0 -22
  139. package/dist/shared/flap 2/index.js +0 -33
  140. package/dist/shared/flap 2/ipfs.d.ts +0 -21
  141. package/dist/shared/flap 2/ipfs.js +0 -38
  142. package/dist/shared/flap 2/meta.d.ts +0 -30
  143. package/dist/shared/flap 2/meta.js +0 -195
  144. package/dist/shared/flap 2/permit.d.ts +0 -16
  145. package/dist/shared/flap 2/permit.js +0 -67
  146. package/dist/shared/flap 2/pinata.d.ts +0 -40
  147. package/dist/shared/flap 2/pinata.js +0 -106
  148. package/dist/shared/flap 2/portal-bundle-merkle/config.d.ts +0 -79
  149. package/dist/shared/flap 2/portal-bundle-merkle/config.js +0 -133
  150. package/dist/shared/flap 2/portal-bundle-merkle/core.d.ts +0 -18
  151. package/dist/shared/flap 2/portal-bundle-merkle/core.js +0 -938
  152. package/dist/shared/flap 2/portal-bundle-merkle/create-to-dex.d.ts +0 -125
  153. package/dist/shared/flap 2/portal-bundle-merkle/create-to-dex.js +0 -665
  154. package/dist/shared/flap 2/portal-bundle-merkle/curve-to-dex.d.ts +0 -88
  155. package/dist/shared/flap 2/portal-bundle-merkle/curve-to-dex.js +0 -446
  156. package/dist/shared/flap 2/portal-bundle-merkle/index.d.ts +0 -14
  157. package/dist/shared/flap 2/portal-bundle-merkle/index.js +0 -26
  158. package/dist/shared/flap 2/portal-bundle-merkle/pancake-proxy.d.ts +0 -28
  159. package/dist/shared/flap 2/portal-bundle-merkle/pancake-proxy.js +0 -701
  160. package/dist/shared/flap 2/portal-bundle-merkle/private.d.ts +0 -17
  161. package/dist/shared/flap 2/portal-bundle-merkle/private.js +0 -549
  162. package/dist/shared/flap 2/portal-bundle-merkle/swap-buy-first.d.ts +0 -65
  163. package/dist/shared/flap 2/portal-bundle-merkle/swap-buy-first.js +0 -831
  164. package/dist/shared/flap 2/portal-bundle-merkle/swap.d.ts +0 -201
  165. package/dist/shared/flap 2/portal-bundle-merkle/swap.js +0 -1359
  166. package/dist/shared/flap 2/portal-bundle-merkle/types.d.ts +0 -358
  167. package/dist/shared/flap 2/portal-bundle-merkle/types.js +0 -1
  168. package/dist/shared/flap 2/portal-bundle-merkle/utils.d.ts +0 -89
  169. package/dist/shared/flap 2/portal-bundle-merkle/utils.js +0 -963
  170. package/dist/shared/flap 2/portal-bundle.d.ts +0 -119
  171. package/dist/shared/flap 2/portal-bundle.js +0 -584
  172. package/dist/shared/flap 2/portal.d.ts +0 -392
  173. package/dist/shared/flap 2/portal.js +0 -559
  174. package/dist/shared/flap 2/vanity.d.ts +0 -48
  175. package/dist/shared/flap 2/vanity.js +0 -110
  176. package/dist/shared/flap 2/vault.d.ts +0 -240
  177. package/dist/shared/flap 2/vault.js +0 -366
  178. package/dist/shared/four 2/index.d.ts +0 -7
  179. package/dist/shared/four 2/index.js +0 -22
  180. package/dist/shared/four 2/tax-token.d.ts +0 -176
  181. package/dist/shared/four 2/tax-token.js +0 -302
  182. package/dist/shared/index 2.js +0 -10
  183. package/dist/shared/index.d 2.ts +0 -10
  184. package/dist/types/distribute.d.ts +0 -72
  185. package/dist/types/distribute.js +0 -1
  186. package/dist/types 2/errors.d.ts +0 -27
  187. package/dist/types 2/errors.js +0 -34
  188. package/dist/utils/__tests__/errors.test.d.ts +0 -1
  189. package/dist/utils/__tests__/errors.test.js +0 -76
  190. package/dist/utils/airdrop-sweep-types.d.ts +0 -1
  191. package/dist/utils/airdrop-sweep-types.js +0 -1
  192. package/dist/utils/erc20/index.d.ts +0 -242
  193. package/dist/utils/erc20/index.js +0 -645
  194. package/dist/utils/erc20/types.d.ts +0 -77
  195. package/dist/utils/erc20/types.js +0 -1
  196. package/dist/utils/erc20-types.d.ts +0 -1
  197. package/dist/utils/erc20-types.js +0 -1
  198. package/dist/utils/holders-maker/helpers.d.ts +0 -43
  199. package/dist/utils/holders-maker/helpers.js +0 -371
  200. package/dist/utils/holders-maker/index.d.ts +0 -26
  201. package/dist/utils/holders-maker/index.js +0 -218
  202. package/dist/utils/holders-maker/types.d.ts +0 -72
  203. package/dist/utils/holders-maker/types.js +0 -4
  204. package/dist/utils/holders-maker-types.d.ts +0 -1
  205. package/dist/utils/holders-maker-types.js +0 -1
  206. package/dist/utils/lp-inspect/index.d.ts +0 -44
  207. package/dist/utils/lp-inspect/index.js +0 -937
  208. package/dist/utils/lp-inspect/types.d.ts +0 -100
  209. package/dist/utils/lp-inspect/types.js +0 -1
  210. package/dist/utils/lp-inspect-types.d.ts +0 -1
  211. package/dist/utils/lp-inspect-types.js +0 -1
  212. package/dist/utils/private-sale-types.d.ts +0 -1
  213. package/dist/utils/private-sale-types.js +0 -1
  214. package/dist/utils/quote-helpers/index.d.ts +0 -107
  215. package/dist/utils/quote-helpers/index.js +0 -346
  216. package/dist/utils/quote-helpers/types.d.ts +0 -16
  217. package/dist/utils/quote-helpers/types.js +0 -1
  218. package/dist/utils/quote-helpers-types.d.ts +0 -1
  219. package/dist/utils/quote-helpers-types.js +0 -1
  220. /package/dist/{chains/bsc/four/submit/types.js → __tests__/subpath-exports.test.d.ts} +0 -0
@@ -1,88 +0,0 @@
1
- /**
2
- * Flap Protocol 内盘买到外盘捆绑交易
3
- *
4
- * 功能:在一个 Bundle 中完成:
5
- * 1. 多个钱包在 Bonding Curve(内盘)买入代币
6
- * 2. 最后一个买家触发毕业(代币上 DEX)
7
- * 3. 多个钱包在 PancakeSwap(外盘)继续买入
8
- */
9
- import { FlapSignConfig } from './config.js';
10
- import type { MerkleSignedResult } from './types.js';
11
- export type CurveToDexChain = 'bsc' | 'base';
12
- export type DexPoolType = 'v2' | 'v3';
13
- /** 签名配置 */
14
- export interface CurveToDexSignConfig extends FlapSignConfig {
15
- reserveGasETH?: number;
16
- skipQuoteOnError?: boolean;
17
- }
18
- /** 内盘买入钱包配置 */
19
- export interface CurveBuyerConfig {
20
- privateKey: string;
21
- /** 买入金额(BNB 或 USD1),为空则自动分配 */
22
- buyAmount?: string;
23
- }
24
- /** 外盘买入钱包配置 */
25
- export interface DexBuyerConfig {
26
- privateKey: string;
27
- /** 买入金额(BNB 或 USD1),为空则自动分配 */
28
- buyAmount?: string;
29
- }
30
- /** 内盘买到外盘参数 */
31
- export interface FlapCurveToDexParams {
32
- chain: CurveToDexChain;
33
- /** 代币地址(已存在的代币) */
34
- tokenAddress: string;
35
- /** 报价代币(BNB 或 USD1),不传默认 BNB */
36
- quoteToken?: string;
37
- /** 报价代币精度,默认 18 */
38
- quoteTokenDecimals?: number;
39
- /** 内盘买入钱包(这些钱包会在 Bonding Curve 上买入) */
40
- curveBuyers: CurveBuyerConfig[];
41
- /** 内盘总买入金额(用于自动分配) */
42
- curveTotalBuyAmount?: string;
43
- /** 是否触发毕业(上 DEX) */
44
- triggerGraduate?: boolean;
45
- /** 毕业触发者(内盘最后一个买家,如果不提供则使用 curveBuyers 的最后一个) */
46
- graduateWallet?: {
47
- privateKey: string;
48
- buyAmount?: string;
49
- };
50
- /** 外盘买入钱包(这些钱包会在 PancakeSwap 上买入) */
51
- dexBuyers?: DexBuyerConfig[];
52
- /** 外盘总买入金额(用于自动分配) */
53
- dexTotalBuyAmount?: string;
54
- /** 外盘池类型(V2 或 V3),默认 V3 */
55
- dexPoolType?: DexPoolType;
56
- /** V3 费率(100/500/2500/10000),默认 2500 */
57
- v3Fee?: number;
58
- /** 配置 */
59
- config: CurveToDexSignConfig;
60
- }
61
- /** 结果类型 */
62
- export interface FlapCurveToDexResult extends MerkleSignedResult {
63
- metadata?: {
64
- /** 内盘买入钱包数 */
65
- curveBuyerCount: number;
66
- /** 内盘总买入金额 */
67
- curveTotalBuy: string;
68
- /** 是否触发毕业 */
69
- graduated: boolean;
70
- /** 外盘买入钱包数 */
71
- dexBuyerCount: number;
72
- /** 外盘总买入金额 */
73
- dexTotalBuy: string;
74
- /** 利润金额 */
75
- profitAmount?: string;
76
- };
77
- }
78
- /**
79
- * Flap 内盘买到外盘捆绑交易
80
- *
81
- * 交易顺序:
82
- * 1. 贿赂交易(BlockRazor)
83
- * 2. 内盘买入(多个钱包在 Bonding Curve 买入)
84
- * 3. 毕业触发(最后一个买家买入触发上 DEX)
85
- * 4. 外盘买入(多个钱包在 PancakeSwap 买入)
86
- * 5. 利润多跳转账
87
- */
88
- export declare function flapBundleCurveToDex(params: FlapCurveToDexParams): Promise<FlapCurveToDexResult>;
@@ -1,446 +0,0 @@
1
- /**
2
- * Flap Protocol 内盘买到外盘捆绑交易
3
- *
4
- * 功能:在一个 Bundle 中完成:
5
- * 1. 多个钱包在 Bonding Curve(内盘)买入代币
6
- * 2. 最后一个买家触发毕业(代币上 DEX)
7
- * 3. 多个钱包在 PancakeSwap(外盘)继续买入
8
- */
9
- import { ethers, Contract, Wallet } from 'ethers';
10
- import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
11
- import { FLAP_PORTAL_ADDRESSES } from '../constants.js';
12
- import { PROFIT_CONFIG, ADDRESSES, ZERO_ADDRESS } from '../../../utils/constants.js';
13
- import { GAS_LIMITS } from '../../constants/index.js';
14
- import { getGasPriceConfig, getTxType, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI } from './config.js';
15
- // ==================== 链常量 ====================
16
- // ✅ V2/V3 统一使用 PancakeSwap SmartRouter(支持 multicall + V2 swapExactTokensForTokens + V3 exactInputSingle)
17
- // 参考: flap-bundle-release 官方示例统一使用 smartRouter(0x13f4EA83D0bd40E75C8222255bc855a974568Dd4)
18
- // ⚠️ 注意:老 V2 Router(0x10ED...024E)的 swapExactTokensForTokens 有 5 个参数(含 deadline),
19
- // 且不支持 multicall,与本文件使用的 PANCAKE_V3_ROUTER_ABI 不兼容!
20
- const BSC_PANCAKE_SMART_ROUTER = ADDRESSES.BSC.PancakeV3Router;
21
- const BSC_WBNB = ADDRESSES.BSC.WBNB;
22
- // ✅ Base 链 DEX 常量(Uniswap V3 SwapRouter02)
23
- const BASE_UNISWAP_SMART_ROUTER = '0x2626664c2603336E57B271c5C0b26F421741e481';
24
- const BASE_WETH = ADDRESSES.BASE.WETH;
25
- // PancakeSwap Router ABI
26
- const PANCAKE_V3_ROUTER_ABI = [
27
- {
28
- "type": "function",
29
- "name": "exactInputSingle",
30
- "inputs": [
31
- {
32
- "name": "params",
33
- "type": "tuple",
34
- "components": [
35
- { "name": "tokenIn", "type": "address" },
36
- { "name": "tokenOut", "type": "address" },
37
- { "name": "fee", "type": "uint24" },
38
- { "name": "recipient", "type": "address" },
39
- { "name": "amountIn", "type": "uint256" },
40
- { "name": "amountOutMinimum", "type": "uint256" },
41
- { "name": "sqrtPriceLimitX96", "type": "uint160" }
42
- ]
43
- }
44
- ],
45
- "outputs": [{ "name": "amountOut", "type": "uint256" }],
46
- "stateMutability": "payable"
47
- },
48
- {
49
- "type": "function",
50
- "name": "multicall",
51
- "inputs": [{ "name": "data", "type": "bytes[]" }],
52
- "outputs": [{ "name": "results", "type": "bytes[]" }],
53
- "stateMutability": "payable"
54
- },
55
- {
56
- "type": "function",
57
- "name": "selfPermit",
58
- "inputs": [
59
- { "name": "token", "type": "address" },
60
- { "name": "value", "type": "uint256" },
61
- { "name": "deadline", "type": "uint256" },
62
- { "name": "v", "type": "uint8" },
63
- { "name": "r", "type": "bytes32" },
64
- { "name": "s", "type": "bytes32" }
65
- ],
66
- "outputs": [],
67
- "stateMutability": "payable"
68
- },
69
- {
70
- "type": "function",
71
- "name": "swapExactTokensForTokens",
72
- "inputs": [
73
- { "name": "amountIn", "type": "uint256" },
74
- { "name": "amountOutMin", "type": "uint256" },
75
- { "name": "path", "type": "address[]" },
76
- { "name": "to", "type": "address" }
77
- ],
78
- "outputs": [{ "name": "amountOut", "type": "uint256" }],
79
- "stateMutability": "payable"
80
- }
81
- ];
82
- // ==================== 链配置 ====================
83
- function getCurveToDexChainConfig(chain) {
84
- switch (chain) {
85
- case 'base':
86
- return { chainId: 8453, smartRouter: BASE_UNISWAP_SMART_ROUTER, wrappedNative: BASE_WETH };
87
- case 'bsc':
88
- default:
89
- return { chainId: 56, smartRouter: BSC_PANCAKE_SMART_ROUTER, wrappedNative: BSC_WBNB };
90
- }
91
- }
92
- // ==================== 工具函数 ====================
93
- function getGasLimit(config, defaultGas = 800000) {
94
- if (config.gasLimit !== undefined) {
95
- return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
96
- }
97
- const multiplier = config.gasLimitMultiplier ?? 1.0;
98
- return BigInt(Math.ceil(defaultGas * multiplier));
99
- }
100
- /** 将金额拆分成多份(权重随机) */
101
- function splitAmount(totalAmount, count) {
102
- if (count <= 0)
103
- throw new Error('拆分份数必须大于 0');
104
- if (count === 1)
105
- return [totalAmount];
106
- const weights = [];
107
- for (let i = 0; i < count; i++) {
108
- weights.push(0.5 + Math.random());
109
- }
110
- const totalWeight = weights.reduce((a, b) => a + b, 0);
111
- const amounts = [];
112
- let allocated = 0n;
113
- for (let i = 0; i < count - 1; i++) {
114
- const ratio = weights[i] / totalWeight;
115
- const amount = BigInt(Math.floor(Number(totalAmount) * ratio));
116
- amounts.push(amount);
117
- allocated += amount;
118
- }
119
- amounts.push(totalAmount - allocated);
120
- // 随机打乱
121
- for (let i = amounts.length - 1; i > 0; i--) {
122
- const j = Math.floor(Math.random() * (i + 1));
123
- [amounts[i], amounts[j]] = [amounts[j], amounts[i]];
124
- }
125
- return amounts;
126
- }
127
- // ==================== 主函数 ====================
128
- /**
129
- * Flap 内盘买到外盘捆绑交易
130
- *
131
- * 交易顺序:
132
- * 1. 贿赂交易(BlockRazor)
133
- * 2. 内盘买入(多个钱包在 Bonding Curve 买入)
134
- * 3. 毕业触发(最后一个买家买入触发上 DEX)
135
- * 4. 外盘买入(多个钱包在 PancakeSwap 买入)
136
- * 5. 利润多跳转账
137
- */
138
- export async function flapBundleCurveToDex(params) {
139
- const { chain, tokenAddress, quoteToken, quoteTokenDecimals = 18, curveBuyers, curveTotalBuyAmount, triggerGraduate = true, graduateWallet, dexBuyers = [], dexTotalBuyAmount, dexPoolType = 'v3', v3Fee = 2500, config } = params;
140
- // 验证参数
141
- if (curveBuyers.length === 0) {
142
- throw new Error('至少需要一个内盘买入钱包');
143
- }
144
- // 判断是否使用原生代币
145
- const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
146
- const inputToken = useNativeToken ? ZERO_ADDRESS : quoteToken;
147
- // ✅ 获取链配置
148
- const chainConfig = getCurveToDexChainConfig(chain);
149
- const chainId = chainConfig.chainId;
150
- // 创建 Provider
151
- const provider = new ethers.JsonRpcProvider(config.rpcUrl, {
152
- chainId,
153
- name: chain.toUpperCase()
154
- });
155
- const portalAddress = FLAP_PORTAL_ADDRESSES[chain.toUpperCase()];
156
- const nonceManager = new NonceManager(provider);
157
- // 创建钱包实例
158
- const curveWallets = curveBuyers.map(b => ({
159
- wallet: new Wallet(b.privateKey, provider),
160
- buyAmount: b.buyAmount
161
- }));
162
- const graduateWalletInfo = graduateWallet ? {
163
- wallet: new Wallet(graduateWallet.privateKey, provider),
164
- buyAmount: graduateWallet.buyAmount
165
- } : null;
166
- const dexWallets = dexBuyers.map(b => ({
167
- wallet: new Wallet(b.privateKey, provider),
168
- buyAmount: b.buyAmount
169
- }));
170
- // 使用第一个内盘买家作为主钱包(支付贿赂和利润)
171
- const mainWallet = curveWallets[0].wallet;
172
- // ✅ 第一批并行:获取 gasPrice + 所有钱包 nonces
173
- const allWallets = [
174
- ...curveWallets.map(c => c.wallet),
175
- ...(graduateWalletInfo ? [graduateWalletInfo.wallet] : []),
176
- ...dexWallets.map(d => d.wallet)
177
- ];
178
- const uniqueWallets = allWallets.filter((w, i) => {
179
- const addr = w.address.toLowerCase();
180
- return allWallets.findIndex(x => x.address.toLowerCase() === addr) === i;
181
- });
182
- const [gasPrice, noncesArray] = await Promise.all([
183
- getOptimizedGasPrice(provider, getGasPriceConfig(config)),
184
- nonceManager.getNextNoncesForWallets(uniqueWallets)
185
- ]);
186
- // 构建 nonces Map
187
- const noncesMap = new Map();
188
- uniqueWallets.forEach((wallet, i) => {
189
- noncesMap.set(wallet.address.toLowerCase(), noncesArray[i]);
190
- });
191
- const finalGasLimit = getGasLimit(config);
192
- const txType = getTxType(config);
193
- const priorityFee = gasPrice / 10n === 0n ? 1n : gasPrice / 10n;
194
- const bribeAmount = getBribeAmount(config);
195
- const needBribeTx = bribeAmount > 0n;
196
- // ✅ 计算内盘买入金额
197
- let curveBuyAmounts;
198
- if (curveTotalBuyAmount) {
199
- const total = useNativeToken
200
- ? ethers.parseEther(curveTotalBuyAmount)
201
- : ethers.parseUnits(curveTotalBuyAmount, quoteTokenDecimals);
202
- curveBuyAmounts = splitAmount(total, curveBuyers.length);
203
- }
204
- else {
205
- // 使用各自指定的金额
206
- curveBuyAmounts = curveBuyers.map(b => {
207
- if (!b.buyAmount)
208
- throw new Error('未指定 curveTotalBuyAmount 时,每个钱包必须指定 buyAmount');
209
- return useNativeToken
210
- ? ethers.parseEther(b.buyAmount)
211
- : ethers.parseUnits(b.buyAmount, quoteTokenDecimals);
212
- });
213
- }
214
- // ✅ 计算毕业买入金额
215
- let graduateBuyAmount = 0n;
216
- if (triggerGraduate && graduateWalletInfo) {
217
- if (graduateWalletInfo.buyAmount) {
218
- graduateBuyAmount = useNativeToken
219
- ? ethers.parseEther(graduateWalletInfo.buyAmount)
220
- : ethers.parseUnits(graduateWalletInfo.buyAmount, quoteTokenDecimals);
221
- }
222
- else {
223
- throw new Error('触发毕业时必须指定 graduateWallet.buyAmount');
224
- }
225
- }
226
- // ✅ 计算外盘买入金额
227
- let dexBuyAmounts = [];
228
- if (dexBuyers.length > 0) {
229
- if (dexTotalBuyAmount) {
230
- const total = useNativeToken
231
- ? ethers.parseEther(dexTotalBuyAmount)
232
- : ethers.parseUnits(dexTotalBuyAmount, quoteTokenDecimals);
233
- dexBuyAmounts = splitAmount(total, dexBuyers.length);
234
- }
235
- else {
236
- dexBuyAmounts = dexBuyers.map(b => {
237
- if (!b.buyAmount)
238
- throw new Error('未指定 dexTotalBuyAmount 时,每个钱包必须指定 buyAmount');
239
- return useNativeToken
240
- ? ethers.parseEther(b.buyAmount)
241
- : ethers.parseUnits(b.buyAmount, quoteTokenDecimals);
242
- });
243
- }
244
- }
245
- // ✅ 计算利润
246
- const totalBuyAmount = curveBuyAmounts.reduce((a, b) => a + b, 0n)
247
- + graduateBuyAmount
248
- + dexBuyAmounts.reduce((a, b) => a + b, 0n);
249
- const profitAmount = (totalBuyAmount * BigInt(PROFIT_CONFIG.RATE_BPS)) / 10000n;
250
- // ==================== 构建交易 ====================
251
- const allTransactions = [];
252
- // 1. 贿赂交易
253
- if (needBribeTx) {
254
- const mainAddr = mainWallet.address.toLowerCase();
255
- const bribeNonce = noncesMap.get(mainAddr);
256
- noncesMap.set(mainAddr, bribeNonce + 1);
257
- const bribeTx = await mainWallet.signTransaction({
258
- to: BLOCKRAZOR_BUILDER_EOA,
259
- value: bribeAmount,
260
- nonce: bribeNonce,
261
- gasPrice,
262
- gasLimit: GAS_LIMITS.BRIBE,
263
- chainId,
264
- type: txType
265
- });
266
- allTransactions.push(bribeTx);
267
- }
268
- // 2. 内盘买入交易
269
- const curveBuyTxPromises = curveWallets.map(async ({ wallet }, i) => {
270
- const addr = wallet.address.toLowerCase();
271
- const nonce = noncesMap.get(addr);
272
- noncesMap.set(addr, nonce + 1);
273
- const portal = new Contract(portalAddress, PORTAL_ABI, wallet);
274
- const unsigned = await portal.swapExactInput.populateTransaction({
275
- inputToken,
276
- outputToken: tokenAddress,
277
- inputAmount: curveBuyAmounts[i],
278
- minOutputAmount: 0n,
279
- permitData: '0x'
280
- }, useNativeToken ? { value: curveBuyAmounts[i] } : {});
281
- const tx = {
282
- ...unsigned,
283
- from: wallet.address,
284
- nonce,
285
- gasLimit: finalGasLimit,
286
- chainId,
287
- type: txType,
288
- value: useNativeToken ? curveBuyAmounts[i] : 0n
289
- };
290
- if (txType === 2) {
291
- tx.maxFeePerGas = gasPrice;
292
- tx.maxPriorityFeePerGas = priorityFee;
293
- }
294
- else {
295
- tx.gasPrice = gasPrice;
296
- }
297
- return wallet.signTransaction(tx);
298
- });
299
- const signedCurveBuys = await Promise.all(curveBuyTxPromises);
300
- allTransactions.push(...signedCurveBuys);
301
- // 3. 毕业触发交易
302
- if (triggerGraduate && graduateWalletInfo && graduateBuyAmount > 0n) {
303
- const { wallet } = graduateWalletInfo;
304
- const addr = wallet.address.toLowerCase();
305
- const nonce = noncesMap.get(addr);
306
- noncesMap.set(addr, nonce + 1);
307
- const portal = new Contract(portalAddress, PORTAL_ABI, wallet);
308
- const unsigned = await portal.swapExactInput.populateTransaction({
309
- inputToken,
310
- outputToken: tokenAddress,
311
- inputAmount: graduateBuyAmount,
312
- minOutputAmount: 0n,
313
- permitData: '0x'
314
- }, useNativeToken ? { value: graduateBuyAmount } : {});
315
- const tx = {
316
- ...unsigned,
317
- from: wallet.address,
318
- nonce,
319
- gasLimit: BigInt(1500000), // 毕业交易需要更多 gas
320
- chainId,
321
- type: txType,
322
- value: useNativeToken ? graduateBuyAmount : 0n
323
- };
324
- if (txType === 2) {
325
- tx.maxFeePerGas = gasPrice;
326
- tx.maxPriorityFeePerGas = priorityFee;
327
- }
328
- else {
329
- tx.gasPrice = gasPrice;
330
- }
331
- const graduateTx = await wallet.signTransaction(tx);
332
- allTransactions.push(graduateTx);
333
- }
334
- // 4. 外盘买入交易(PancakeSwap)
335
- if (dexWallets.length > 0) {
336
- const dexBuyTxPromises = dexWallets.map(async ({ wallet }, i) => {
337
- const addr = wallet.address.toLowerCase();
338
- const nonce = noncesMap.get(addr);
339
- noncesMap.set(addr, nonce + 1);
340
- const buyAmount = dexBuyAmounts[i];
341
- // ✅ 使用链配置中的 SmartRouter 和 WrappedNative(支持 BSC/Base)
342
- const smartRouter = chainConfig.smartRouter;
343
- const wrappedNative = chainConfig.wrappedNative;
344
- let calldata;
345
- let value;
346
- if (dexPoolType === 'v3') {
347
- // V3: exactInputSingle
348
- if (useNativeToken) {
349
- const params = {
350
- tokenIn: wrappedNative,
351
- tokenOut: tokenAddress,
352
- fee: v3Fee,
353
- recipient: wallet.address,
354
- amountIn: buyAmount,
355
- amountOutMinimum: 0n,
356
- sqrtPriceLimitX96: 0n
357
- };
358
- const exactInputSingleData = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('exactInputSingle', [params]);
359
- calldata = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('multicall', [[exactInputSingleData]]);
360
- value = buyAmount;
361
- }
362
- else {
363
- // ERC20 需要先 approve,这里简化处理(假设已授权)
364
- const params = {
365
- tokenIn: quoteToken,
366
- tokenOut: tokenAddress,
367
- fee: v3Fee,
368
- recipient: wallet.address,
369
- amountIn: buyAmount,
370
- amountOutMinimum: 0n,
371
- sqrtPriceLimitX96: 0n
372
- };
373
- const exactInputSingleData = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('exactInputSingle', [params]);
374
- calldata = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('multicall', [[exactInputSingleData]]);
375
- value = 0n;
376
- }
377
- }
378
- else {
379
- // V2: swapExactTokensForTokens
380
- if (useNativeToken) {
381
- const swapData = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('swapExactTokensForTokens', [buyAmount, 0n, [wrappedNative, tokenAddress], wallet.address]);
382
- calldata = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('multicall', [[swapData]]);
383
- value = buyAmount;
384
- }
385
- else {
386
- const swapData = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('swapExactTokensForTokens', [buyAmount, 0n, [quoteToken, tokenAddress], wallet.address]);
387
- calldata = new ethers.Interface(PANCAKE_V3_ROUTER_ABI).encodeFunctionData('multicall', [[swapData]]);
388
- value = 0n;
389
- }
390
- }
391
- const tx = {
392
- to: smartRouter,
393
- data: calldata,
394
- from: wallet.address,
395
- nonce,
396
- gasLimit: BigInt(500000),
397
- chainId,
398
- type: txType,
399
- value
400
- };
401
- if (txType === 2) {
402
- tx.maxFeePerGas = gasPrice;
403
- tx.maxPriorityFeePerGas = priorityFee;
404
- }
405
- else {
406
- tx.gasPrice = gasPrice;
407
- }
408
- return wallet.signTransaction(tx);
409
- });
410
- const signedDexBuys = await Promise.all(dexBuyTxPromises);
411
- allTransactions.push(...signedDexBuys);
412
- }
413
- // 5. 利润多跳转账
414
- let profitHopWallets;
415
- if (profitAmount > 0n) {
416
- const mainAddr = mainWallet.address.toLowerCase();
417
- const profitNonce = noncesMap.get(mainAddr);
418
- const profitResult = await buildProfitHopTransactions({
419
- provider,
420
- payerWallet: mainWallet,
421
- profitAmount,
422
- profitRecipient: getProfitRecipient(),
423
- hopCount: PROFIT_HOP_COUNT,
424
- gasPrice,
425
- chainId,
426
- txType,
427
- startNonce: profitNonce
428
- });
429
- allTransactions.push(...profitResult.signedTransactions);
430
- profitHopWallets = profitResult.hopWallets;
431
- }
432
- nonceManager.clearTemp();
433
- // 返回结果
434
- return {
435
- signedTransactions: allTransactions,
436
- profitHopWallets,
437
- metadata: {
438
- curveBuyerCount: curveBuyers.length,
439
- curveTotalBuy: ethers.formatEther(curveBuyAmounts.reduce((a, b) => a + b, 0n)),
440
- graduated: triggerGraduate,
441
- dexBuyerCount: dexBuyers.length,
442
- dexTotalBuy: ethers.formatEther(dexBuyAmounts.reduce((a, b) => a + b, 0n)),
443
- profitAmount: profitAmount > 0n ? ethers.formatEther(profitAmount) : undefined
444
- }
445
- };
446
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Flap Protocol Bundle 交易方法(Merkle 版本)
3
- * 使用 Merkle.io Bundle 服务实现原子化交易
4
- */
5
- export * from './config.js';
6
- export * from './types.js';
7
- export { createTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle, batchSellWithBundleMerkle } from './core.js';
8
- export { flapBundleBuyFirstMerkle, type FlapChain, type FlapBuyFirstSignConfig, type FlapBuyFirstConfig, type FlapBundleBuyFirstSignParams, type FlapBundleBuyFirstParams, type FlapBuyFirstResult } from './swap-buy-first.js';
9
- export { flapPrivateBuyMerkle, flapPrivateSellMerkle, flapBatchPrivateBuyMerkle, flapBatchPrivateSellMerkle } from './private.js';
10
- export { pancakeProxyBatchBuyMerkle, pancakeProxyBatchSellMerkle, approvePancakeProxy, approvePancakeProxyBatch } from './pancake-proxy.js';
11
- export { flapDisperseWithBundleMerkle, flapSweepWithBundleMerkle, type FlapDisperseSignParams, type FlapDisperseMerkleResult, type FlapSweepSignParams, type FlapSweepMerkleResult } from './utils.js';
12
- export { flapBundleCurveToDex, type CurveToDexChain, type DexPoolType, type CurveToDexSignConfig, type CurveBuyerConfig, type DexBuyerConfig, type FlapCurveToDexParams, type FlapCurveToDexResult } from './curve-to-dex.js';
13
- export { flapBundleCreateToDex, type CreateToDexChain, type CreateToDexSignConfig, type CreateTokenInfo, type FlapCreateToDexParams, type FlapCreateToDexResult, type CurveBuyerConfig as CreateCurveBuyerConfig, type DexBuyerConfig as CreateDexBuyerConfig, type DexPoolType as CreateDexPoolType } from './create-to-dex.js';
14
- export { flapBundleSwapMerkle, flapBatchSwapMerkle, flapQuickBatchSwapMerkle, flapCrossSwapMerkle, type FlapSwapSignConfig, type FlapSwapConfig, type FlapBundleSwapSignParams, type FlapBundleSwapParams, type FlapSwapResult, type FlapBatchSwapSignParams, type FlapBatchSwapResult, type FlapQuickBatchSwapSignParams, type FlapQuickBatchSwapResult, type FlapCrossSwapParams, type FlapCrossSwapResult, type UserType } from './swap.js';
@@ -1,26 +0,0 @@
1
- /**
2
- * Flap Protocol Bundle 交易方法(Merkle 版本)
3
- * 使用 Merkle.io Bundle 服务实现原子化交易
4
- */
5
- // 配置和类型
6
- export * from './config.js';
7
- export * from './types.js';
8
- // 核心交易方法(使用 Flap Portal)
9
- export { createTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle, batchSellWithBundleMerkle } from './core.js';
10
- // BuyFirst 换手方法
11
- export { flapBundleBuyFirstMerkle } from './swap-buy-first.js';
12
- // 私有交易方法(使用 Flap Portal)
13
- export { flapPrivateBuyMerkle, flapPrivateSellMerkle, flapBatchPrivateBuyMerkle, flapBatchPrivateSellMerkle } from './private.js';
14
- // PancakeSwapProxy 代理交易方法(使用自定义代理合约)
15
- export { pancakeProxyBatchBuyMerkle, pancakeProxyBatchSellMerkle, approvePancakeProxy, approvePancakeProxyBatch } from './pancake-proxy.js';
16
- // ✅ 归集和分散方法(支持利润提取、余额最大钱包支付、多跳、ERC20→原生代币报价、Multicall3)
17
- export { flapDisperseWithBundleMerkle, flapSweepWithBundleMerkle } from './utils.js';
18
- // ✅ 内盘买到外盘(Bonding Curve → DEX)- 已存在代币
19
- export { flapBundleCurveToDex } from './curve-to-dex.js';
20
- // ✅ 发币 + 一键买到外盘(Create → Curve → DEX)- 新代币
21
- export { flapBundleCreateToDex } from './create-to-dex.js';
22
- // ✅ 内盘换手方法(一卖一买、一卖多买、快捷资金利用率、交叉换手)
23
- export { flapBundleSwapMerkle, flapBatchSwapMerkle, flapQuickBatchSwapMerkle, flapCrossSwapMerkle } from './swap.js';
24
- // ✅ Tax Vault 金库类型(types.ts 中 TaxV2Config.vaultConfig 使用的类型)
25
- // 注意:TaxVaultConfig 完整导出在 flap/index.ts → vault.js 中
26
- // 这里仅从 types.ts 导出 TaxV2Config 中嵌套使用时的类型引用
@@ -1,28 +0,0 @@
1
- /**
2
- * PancakeSwap 官方 Router 交易模块(Flap 版本,支持多链)
3
- *
4
- * ✅ 使用官方 PancakeSwap V2/V3 Router(非代理合约)
5
- * - V2 Router (BSC): 0x10ED43C718714eb63d5aA57B78B54704E256024E
6
- * - V3 Router (BSC): 0x13f4EA83D0bd40E75C8222255bc855a974568Dd4
7
- * - V3 Quoter (BSC): 0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997
8
- */
9
- import { PancakeProxyBatchBuySignParams, PancakeProxyBatchBuyResult, PancakeProxyBatchSellSignParams, PancakeProxyBatchSellResult, PancakeProxyApprovalParams, PancakeProxyApprovalBatchParams, PancakeProxyApprovalBatchResult } from './types.js';
10
- /**
11
- * ✅ 授权代币给 PancakeSwap Router
12
- */
13
- export declare function approvePancakeProxy(params: PancakeProxyApprovalParams): Promise<{
14
- txHash: string;
15
- approved: boolean;
16
- }>;
17
- /**
18
- * ✅ 批量授权代币给 PancakeSwap Router
19
- */
20
- export declare function approvePancakeProxyBatch(params: PancakeProxyApprovalBatchParams): Promise<PancakeProxyApprovalBatchResult>;
21
- /**
22
- * ✅ 使用 PancakeSwap 官方 Router 批量购买代币
23
- */
24
- export declare function pancakeProxyBatchBuyMerkle(params: PancakeProxyBatchBuySignParams): Promise<PancakeProxyBatchBuyResult>;
25
- /**
26
- * ✅ 使用 PancakeSwap 官方 Router 批量卖出代币
27
- */
28
- export declare function pancakeProxyBatchSellMerkle(params: PancakeProxyBatchSellSignParams): Promise<PancakeProxyBatchSellResult>;