four-flap-meme-sdk 2.2.8 → 2.2.11

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 (474) hide show
  1. package/README.en.md +6 -41
  2. package/README.md +0 -31
  3. package/README.zh-CN.md +6 -41
  4. package/dist/chains/bsc/four/approve-tokenmanager.d.ts +26 -1
  5. package/dist/chains/bsc/four/approve-tokenmanager.js +113 -1
  6. package/dist/chains/bsc/four/config.d.ts +67 -5
  7. package/dist/chains/bsc/four/config.js +114 -2
  8. package/dist/chains/bsc/four/core.d.ts +4 -1
  9. package/dist/chains/bsc/four/core.js +592 -1
  10. package/dist/chains/bsc/four/index.d.ts +6 -6
  11. package/dist/chains/bsc/four/index.js +6 -6
  12. package/dist/chains/bsc/four/internal.d.ts +46 -2
  13. package/dist/chains/bsc/four/internal.js +239 -2
  14. package/dist/chains/bsc/four/pancake-proxy.d.ts +28 -1
  15. package/dist/chains/bsc/four/pancake-proxy.js +687 -1
  16. package/dist/chains/bsc/four/private.d.ts +27 -1
  17. package/dist/chains/bsc/four/private.js +477 -1
  18. package/dist/chains/bsc/four/submit.d.ts +315 -2
  19. package/dist/chains/bsc/four/submit.js +752 -2
  20. package/dist/chains/bsc/four/swap-buy-first.d.ts +55 -2
  21. package/dist/chains/bsc/four/swap-buy-first.js +507 -2
  22. package/dist/chains/bsc/four/swap-internal.d.ts +3 -1
  23. package/dist/chains/bsc/four/swap-internal.js +18 -1
  24. package/dist/chains/bsc/four/swap.d.ts +144 -2
  25. package/dist/chains/bsc/four/swap.js +766 -2
  26. package/dist/chains/bsc/four/types.d.ts +476 -1
  27. package/dist/chains/bsc/four/utils.d.ts +18 -5
  28. package/dist/chains/bsc/four/utils.js +1552 -5
  29. package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +91 -1
  30. package/dist/chains/bsc/pancake/bundle-buy-first.js +212 -97
  31. package/dist/chains/bsc/pancake/bundle-swap.d.ts +79 -1
  32. package/dist/chains/bsc/pancake/bundle-swap.js +726 -114
  33. package/dist/chains/bsc/pancake/index.d.ts +2 -4
  34. package/dist/chains/bsc/pancake/index.js +3 -1
  35. package/dist/chains/bsc/platforms/iro/factory.d.ts +2 -2
  36. package/dist/chains/bsc/platforms/iro/factory.js +1 -3
  37. package/dist/chains/bsc/platforms/iro/index.d.ts +5 -5
  38. package/dist/chains/bsc/platforms/iro/index.js +3 -3
  39. package/dist/chains/bsc/platforms/iro/pool.js +10 -31
  40. package/dist/chains/bsc/platforms/iro/token.js +1 -4
  41. package/dist/chains/eni/batch-router/bundle-approve.js +3 -4
  42. package/dist/chains/eni/batch-router/transfer.js +25 -55
  43. package/dist/chains/eni/batch-router/utils.js +6 -32
  44. package/dist/chains/eni/bundler/sign.js +6 -5
  45. package/dist/chains/eni/bundler/submit.js +4 -1
  46. package/dist/chains/eni/constants.js +1 -1
  47. package/dist/chains/eni/index.d.ts +1 -2
  48. package/dist/chains/eni/index.js +0 -1
  49. package/dist/chains/eni/platforms/daoaas/create.js +2 -2
  50. package/dist/chains/eni/platforms/daoaas/index.d.ts +3 -3
  51. package/dist/chains/eni/platforms/daoaas/index.js +3 -3
  52. package/dist/chains/eni/platforms/daoaas/meta.js +6 -9
  53. package/dist/chains/eni/platforms/daoaas/portal-direct.js +44 -28
  54. package/dist/chains/eni/platforms/daoaas/portal.js +6 -10
  55. package/dist/chains/eni/platforms/dswap/liquidity.js +26 -58
  56. package/dist/chains/eni/platforms/fair-launch/index.d.ts +2 -2
  57. package/dist/chains/eni/platforms/fair-launch/index.js +1 -1
  58. package/dist/chains/eni/platforms/fair-launch/launcher.js +46 -87
  59. package/dist/chains/eni/platforms/fair-launch/pool.js +1 -4
  60. package/dist/chains/eni/platforms/fair-launch/presets.js +2 -2
  61. package/dist/chains/eni/platforms/iro/factory.d.ts +2 -2
  62. package/dist/chains/eni/platforms/iro/factory.js +1 -3
  63. package/dist/chains/eni/platforms/iro/index.d.ts +6 -6
  64. package/dist/chains/eni/platforms/iro/index.js +4 -4
  65. package/dist/chains/eni/platforms/iro/pool.js +26 -90
  66. package/dist/chains/eni/platforms/iro/token.js +31 -107
  67. package/dist/chains/eni/platforms/iro/whitelist.js +18 -6
  68. package/dist/chains/index.d.ts +0 -13
  69. package/dist/chains/index.js +0 -13
  70. package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +26 -2
  71. package/dist/chains/xlayer/eip7702/bundle-approve.js +21 -11
  72. package/dist/chains/xlayer/eip7702/bundle-buy.d.ts +6 -2
  73. package/dist/chains/xlayer/eip7702/bundle-buy.js +51 -13
  74. package/dist/chains/xlayer/eip7702/bundle-create.js +59 -93
  75. package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +6 -2
  76. package/dist/chains/xlayer/eip7702/bundle-sell.js +111 -29
  77. package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +65 -3
  78. package/dist/chains/xlayer/eip7702/bundle-swap.js +245 -51
  79. package/dist/chains/xlayer/eip7702/constants.d.ts +16 -1
  80. package/dist/chains/xlayer/eip7702/constants.js +21 -3
  81. package/dist/chains/xlayer/eip7702/index.d.ts +46 -28
  82. package/dist/chains/xlayer/eip7702/index.js +81 -28
  83. package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +203 -2
  84. package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +307 -63
  85. package/dist/chains/xlayer/eip7702/types.d.ts +0 -88
  86. package/dist/chains/xlayer/eip7702/utils.d.ts +3 -0
  87. package/dist/chains/xlayer/eip7702/utils.js +28 -23
  88. package/dist/chains/xlayer/eip7702/volume.d.ts +184 -6
  89. package/dist/chains/xlayer/eip7702/volume.js +164 -89
  90. package/dist/chains/xlayer/eoa/constants.js +1 -1
  91. package/dist/chains/xlayer/eoa/dex-helpers.js +5 -5
  92. package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +95 -1
  93. package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +299 -66
  94. package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
  95. package/dist/chains/xlayer/eoa/eoa-wash-volume.js +23 -18
  96. package/dist/chains/xlayer/eoa/index.d.ts +6 -10
  97. package/dist/chains/xlayer/eoa/index.js +23 -8
  98. package/dist/chains/xlayer/eoa/portal-ops.js +2 -7
  99. package/dist/chains/xlayer/eoa/router-manager.js +3 -3
  100. package/dist/chains/xlayer/eoa/types.d.ts +2 -2
  101. package/dist/chains/xlayer/eoa/types.js +3 -1
  102. package/dist/chains/xlayer/index.d.ts +2 -3
  103. package/dist/chains/xlayer/index.js +7 -4
  104. package/dist/contracts/helper3.d.ts +5 -20
  105. package/dist/contracts/helper3.js +20 -56
  106. package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +26 -1
  107. package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +113 -1
  108. package/dist/contracts/tm-bundle-merkle/config.d.ts +67 -5
  109. package/dist/contracts/tm-bundle-merkle/config.js +114 -2
  110. package/dist/contracts/tm-bundle-merkle/core.d.ts +4 -1
  111. package/dist/contracts/tm-bundle-merkle/core.js +591 -1
  112. package/dist/contracts/tm-bundle-merkle/index.d.ts +5 -5
  113. package/dist/contracts/tm-bundle-merkle/index.js +5 -5
  114. package/dist/contracts/tm-bundle-merkle/internal.d.ts +46 -2
  115. package/dist/contracts/tm-bundle-merkle/internal.js +238 -2
  116. package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +28 -1
  117. package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +686 -1
  118. package/dist/contracts/tm-bundle-merkle/private.d.ts +27 -1
  119. package/dist/contracts/tm-bundle-merkle/private.js +476 -1
  120. package/dist/contracts/tm-bundle-merkle/submit.d.ts +314 -3
  121. package/dist/contracts/tm-bundle-merkle/submit.js +928 -3
  122. package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +55 -2
  123. package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +506 -2
  124. package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +3 -1
  125. package/dist/contracts/tm-bundle-merkle/swap-internal.js +18 -1
  126. package/dist/contracts/tm-bundle-merkle/swap.d.ts +144 -2
  127. package/dist/contracts/tm-bundle-merkle/swap.js +764 -2
  128. package/dist/contracts/tm-bundle-merkle/types.d.ts +476 -1
  129. package/dist/contracts/tm-bundle-merkle/utils.d.ts +18 -6
  130. package/dist/contracts/tm-bundle-merkle/utils.js +1501 -6
  131. package/dist/contracts/tm-bundle.d.ts +51 -3
  132. package/dist/contracts/tm-bundle.js +177 -108
  133. package/dist/contracts/tm.d.ts +2 -3
  134. package/dist/contracts/tm.js +32 -37
  135. package/dist/contracts/tm1.js +4 -9
  136. package/dist/contracts/tm2.js +4 -9
  137. package/dist/dex/direct-router.d.ts +125 -3
  138. package/dist/dex/direct-router.js +666 -237
  139. package/dist/flows/create.d.ts +1 -2
  140. package/dist/flows/create.js +6 -6
  141. package/dist/index.d.ts +87 -20
  142. package/dist/index.js +217 -20
  143. package/dist/shared/abis/TaxToken.json +105 -0
  144. package/dist/shared/abis/TokenManager2.json +60 -0
  145. package/dist/shared/abis/common.d.ts +83 -2
  146. package/dist/shared/abis/common.js +254 -2
  147. package/dist/shared/abis/index.d.ts +6 -5
  148. package/dist/shared/abis/index.js +7 -5
  149. package/dist/shared/clients/blockrazor.js +25 -39
  150. package/dist/shared/clients/club48.d.ts +2 -2
  151. package/dist/shared/clients/club48.js +29 -34
  152. package/dist/shared/clients/emitservice.js +0 -2
  153. package/dist/shared/clients/four.d.ts +6 -21
  154. package/dist/shared/clients/four.js +24 -29
  155. package/dist/shared/clients/merkle.js +34 -27
  156. package/dist/shared/constants/addresses.d.ts +1 -1
  157. package/dist/shared/constants/addresses.js +2 -11
  158. package/dist/shared/constants/chains.d.ts +1 -1
  159. package/dist/shared/constants/chains.js +1 -1
  160. package/dist/shared/constants/gas.d.ts +1 -1
  161. package/dist/shared/constants/gas.js +6 -2
  162. package/dist/shared/constants/index.d.ts +0 -3
  163. package/dist/shared/constants/index.js +0 -1
  164. package/dist/shared/flap/abi.js +1 -1
  165. package/dist/shared/flap/constants.d.ts +2 -1
  166. package/dist/shared/flap/constants.js +4 -3
  167. package/dist/shared/flap/curve.js +0 -3
  168. package/dist/shared/flap/errors.d.ts +4 -1
  169. package/dist/shared/flap/errors.js +1 -20
  170. package/dist/shared/flap/index.d.ts +5 -4
  171. package/dist/shared/flap/index.js +5 -4
  172. package/dist/shared/flap/launch-v6.d.ts +127 -0
  173. package/dist/shared/flap/launch-v6.js +123 -0
  174. package/dist/shared/flap/meta.d.ts +18 -22
  175. package/dist/shared/flap/meta.js +17 -12
  176. package/dist/shared/flap/permit.js +2 -5
  177. package/dist/shared/flap/pinata.d.ts +6 -22
  178. package/dist/shared/flap/pinata.js +26 -21
  179. package/dist/shared/flap/portal-bundle-merkle/config.d.ts +72 -3
  180. package/dist/shared/flap/portal-bundle-merkle/config.js +124 -4
  181. package/dist/shared/flap/portal-bundle-merkle/core.d.ts +4 -0
  182. package/dist/shared/flap/portal-bundle-merkle/core.js +151 -142
  183. package/dist/shared/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -17
  184. package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +86 -86
  185. package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +92 -100
  186. package/dist/shared/flap/portal-bundle-merkle/index.d.ts +7 -11
  187. package/dist/shared/flap/portal-bundle-merkle/index.js +7 -4
  188. package/dist/shared/flap/portal-bundle-merkle/pancake-proxy.js +68 -71
  189. package/dist/shared/flap/portal-bundle-merkle/private.js +114 -61
  190. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.d.ts +64 -1
  191. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.js +247 -66
  192. package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +71 -2
  193. package/dist/shared/flap/portal-bundle-merkle/swap.js +410 -103
  194. package/dist/shared/flap/portal-bundle-merkle/types.d.ts +12 -88
  195. package/dist/shared/flap/portal-bundle-merkle/utils.d.ts +80 -1
  196. package/dist/shared/flap/portal-bundle-merkle/utils.js +265 -145
  197. package/dist/shared/flap/portal-bundle.js +56 -55
  198. package/dist/shared/flap/portal-create-token.d.ts +19 -37
  199. package/dist/shared/flap/portal-create-token.js +124 -121
  200. package/dist/shared/flap/portal.d.ts +2 -1
  201. package/dist/shared/flap/portal.js +28 -36
  202. package/dist/shared/flap/vanity.d.ts +6 -6
  203. package/dist/shared/flap/vanity.js +21 -15
  204. package/dist/shared/flap/vault.d.ts +93 -25
  205. package/dist/shared/flap/vault.js +126 -75
  206. package/dist/shared/four/tax-token.d.ts +1 -1
  207. package/dist/shared/four/tax-token.js +7 -27
  208. package/dist/shared/index.d.ts +0 -6
  209. package/dist/shared/index.js +0 -4
  210. package/dist/utils/airdrop-sweep.d.ts +76 -4
  211. package/dist/utils/airdrop-sweep.js +55 -42
  212. package/dist/utils/bundle-helpers.d.ts +243 -9
  213. package/dist/utils/bundle-helpers.js +584 -10
  214. package/dist/utils/constants.d.ts +61 -5
  215. package/dist/utils/constants.js +80 -5
  216. package/dist/utils/contract-factory.d.ts +4 -2
  217. package/dist/utils/contract-factory.js +18 -25
  218. package/dist/utils/erc20.d.ts +89 -7
  219. package/dist/utils/erc20.js +125 -94
  220. package/dist/utils/errors.d.ts +1 -12
  221. package/dist/utils/errors.js +1 -60
  222. package/dist/utils/holders-maker.d.ts +138 -2
  223. package/dist/utils/holders-maker.js +661 -26
  224. package/dist/utils/lp-inspect.d.ts +112 -2
  225. package/dist/utils/lp-inspect.js +223 -73
  226. package/dist/utils/mpcExclusive.d.ts +5 -2
  227. package/dist/utils/mpcExclusive.js +3 -4
  228. package/dist/utils/private-sale.d.ts +58 -2
  229. package/dist/utils/private-sale.js +15 -4
  230. package/dist/utils/provider-factory.d.ts +0 -4
  231. package/dist/utils/provider-factory.js +0 -10
  232. package/dist/utils/quote-helpers.d.ts +45 -4
  233. package/dist/utils/quote-helpers.js +74 -17
  234. package/dist/utils/stealth-transfer.d.ts +28 -2
  235. package/dist/utils/stealth-transfer.js +15 -31
  236. package/dist/utils/swap-helpers.d.ts +15 -2
  237. package/dist/utils/swap-helpers.js +11 -6
  238. package/dist/utils/wallet.d.ts +25 -2
  239. package/dist/utils/wallet.js +10 -13
  240. package/package.json +4 -160
  241. package/dist/__tests__/subpath-exports.test.d.ts +0 -1
  242. package/dist/__tests__/subpath-exports.test.js +0 -64
  243. package/dist/abis/common.d.ts +0 -85
  244. package/dist/abis/common.js +0 -264
  245. package/dist/abis/contracts/TaxToken.json +0 -969
  246. package/dist/abis/contracts/TokenManager2.json +0 -136
  247. package/dist/abis/contracts/index.d.ts +0 -5
  248. package/dist/abis/contracts/index.js +0 -5
  249. package/dist/abis/flap/index.d.ts +0 -3
  250. package/dist/abis/flap/index.js +0 -3
  251. package/dist/abis/flap/portal-events.d.ts +0 -6
  252. package/dist/abis/flap/portal-events.js +0 -17
  253. package/dist/abis/flap/portal.d.ts +0 -6
  254. package/dist/abis/flap/portal.js +0 -37
  255. package/dist/abis/flap/vault.d.ts +0 -171
  256. package/dist/abis/flap/vault.js +0 -91
  257. package/dist/abis/index.d.ts +0 -8
  258. package/dist/abis/index.js +0 -11
  259. package/dist/bundle-core/__tests__/config-helpers.test.d.ts +0 -1
  260. package/dist/bundle-core/__tests__/config-helpers.test.js +0 -28
  261. package/dist/bundle-core/__tests__/facade-parity.test.d.ts +0 -1
  262. package/dist/bundle-core/__tests__/facade-parity.test.js +0 -33
  263. package/dist/bundle-core/__tests__/sign-context-helpers.test.d.ts +0 -1
  264. package/dist/bundle-core/__tests__/sign-context-helpers.test.js +0 -60
  265. package/dist/bundle-core/__tests__/sign-fixture.test.d.ts +0 -1
  266. package/dist/bundle-core/__tests__/sign-fixture.test.js +0 -220
  267. package/dist/bundle-core/__tests__/sign-fixtures.d.ts +0 -10
  268. package/dist/bundle-core/__tests__/sign-fixtures.js +0 -16
  269. package/dist/bundle-core/config-helpers.d.ts +0 -36
  270. package/dist/bundle-core/config-helpers.js +0 -57
  271. package/dist/bundle-core/errors.d.ts +0 -50
  272. package/dist/bundle-core/errors.js +0 -35
  273. package/dist/bundle-core/four-meme/approve-tokenmanager.d.ts +0 -7
  274. package/dist/bundle-core/four-meme/approve-tokenmanager.js +0 -99
  275. package/dist/bundle-core/four-meme/core-helpers.d.ts +0 -8
  276. package/dist/bundle-core/four-meme/core-helpers.js +0 -40
  277. package/dist/bundle-core/four-meme/core.d.ts +0 -4
  278. package/dist/bundle-core/four-meme/core.js +0 -515
  279. package/dist/bundle-core/four-meme/pancake-proxy.d.ts +0 -28
  280. package/dist/bundle-core/four-meme/pancake-proxy.js +0 -679
  281. package/dist/bundle-core/four-meme/private.d.ts +0 -27
  282. package/dist/bundle-core/four-meme/private.js +0 -465
  283. package/dist/bundle-core/four-meme/sign-context-helpers.d.ts +0 -2
  284. package/dist/bundle-core/four-meme/sign-context-helpers.js +0 -2
  285. package/dist/bundle-core/four-meme/swap-buy-first.d.ts +0 -8
  286. package/dist/bundle-core/four-meme/swap-buy-first.js +0 -493
  287. package/dist/bundle-core/four-meme/swap-hop-helpers.d.ts +0 -6
  288. package/dist/bundle-core/four-meme/swap-hop-helpers.js +0 -63
  289. package/dist/bundle-core/four-meme/swap-internal.d.ts +0 -3
  290. package/dist/bundle-core/four-meme/swap-internal.js +0 -18
  291. package/dist/bundle-core/four-meme/swap-sign-helpers.d.ts +0 -27
  292. package/dist/bundle-core/four-meme/swap-sign-helpers.js +0 -105
  293. package/dist/bundle-core/four-meme/swap.d.ts +0 -17
  294. package/dist/bundle-core/four-meme/swap.js +0 -505
  295. package/dist/bundle-core/four-meme/types/buy-first.d.ts +0 -50
  296. package/dist/bundle-core/four-meme/types/buy-first.js +0 -1
  297. package/dist/bundle-core/four-meme/types/core-flow.d.ts +0 -63
  298. package/dist/bundle-core/four-meme/types/core-flow.js +0 -1
  299. package/dist/bundle-core/four-meme/types/index.d.ts +0 -600
  300. package/dist/bundle-core/four-meme/types/index.js +0 -1
  301. package/dist/bundle-core/four-meme/types/swap-internal.d.ts +0 -19
  302. package/dist/bundle-core/four-meme/types/swap-internal.js +0 -1
  303. package/dist/bundle-core/four-meme/types.d.ts +0 -1
  304. package/dist/bundle-core/four-meme/types.js +0 -1
  305. package/dist/bundle-core/four-meme/utils-disperse.d.ts +0 -7
  306. package/dist/bundle-core/four-meme/utils-disperse.js +0 -396
  307. package/dist/bundle-core/four-meme/utils-pairwise.d.ts +0 -8
  308. package/dist/bundle-core/four-meme/utils-pairwise.js +0 -328
  309. package/dist/bundle-core/four-meme/utils-sweep.d.ts +0 -8
  310. package/dist/bundle-core/four-meme/utils-sweep.js +0 -744
  311. package/dist/bundle-core/index.d.ts +0 -8
  312. package/dist/bundle-core/index.js +0 -8
  313. package/dist/bundle-core/internal.d.ts +0 -21
  314. package/dist/bundle-core/internal.js +0 -182
  315. package/dist/bundle-core/sign-context-helpers.d.ts +0 -25
  316. package/dist/bundle-core/sign-context-helpers.js +0 -67
  317. package/dist/bundle-core/submit.d.ts +0 -293
  318. package/dist/bundle-core/submit.js +0 -727
  319. package/dist/bundle-core/types/index.d.ts +0 -8
  320. package/dist/bundle-core/types/index.js +0 -1
  321. package/dist/bundle-core/types.d.ts +0 -1
  322. package/dist/bundle-core/types.js +0 -1
  323. package/dist/chains/bsc/four/utils-disperse.d.ts +0 -1
  324. package/dist/chains/bsc/four/utils-disperse.js +0 -1
  325. package/dist/chains/bsc/four/utils-pairwise.d.ts +0 -1
  326. package/dist/chains/bsc/four/utils-pairwise.js +0 -1
  327. package/dist/chains/bsc/four/utils-sweep.d.ts +0 -1
  328. package/dist/chains/bsc/four/utils-sweep.js +0 -1
  329. package/dist/chains/bsc/iro.d.ts +0 -5
  330. package/dist/chains/bsc/iro.js +0 -4
  331. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +0 -159
  332. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +0 -117
  333. package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +0 -241
  334. package/dist/chains/bsc/pancake/bundle-swap-helpers.js +0 -565
  335. package/dist/chains/eni/flat-aliases.d.ts +0 -10
  336. package/dist/chains/eni/flat-aliases.js +0 -8
  337. package/dist/chains/eni/submit.d.ts +0 -43
  338. package/dist/chains/eni/submit.js +0 -286
  339. package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +0 -13
  340. package/dist/chains/xlayer/eip7702/flat-aliases.js +0 -10
  341. package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.d.ts +0 -79
  342. package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.js +0 -1
  343. package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +0 -26
  344. package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +0 -57
  345. package/dist/chains/xlayer/eip7702/volume-helpers.d.ts +0 -148
  346. package/dist/chains/xlayer/eip7702/volume-helpers.js +0 -48
  347. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +0 -126
  348. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +0 -228
  349. package/dist/contracts/tm-bundle-helpers.d.ts +0 -88
  350. package/dist/contracts/tm-bundle-helpers.js +0 -72
  351. package/dist/contracts/tm-bundle-merkle/utils-disperse.d.ts +0 -1
  352. package/dist/contracts/tm-bundle-merkle/utils-disperse.js +0 -1
  353. package/dist/contracts/tm-bundle-merkle/utils-pairwise.d.ts +0 -1
  354. package/dist/contracts/tm-bundle-merkle/utils-pairwise.js +0 -1
  355. package/dist/contracts/tm-bundle-merkle/utils-sweep.d.ts +0 -1
  356. package/dist/contracts/tm-bundle-merkle/utils-sweep.js +0 -1
  357. package/dist/dex/direct-router-helpers.d.ts +0 -264
  358. package/dist/dex/direct-router-helpers.js +0 -539
  359. package/dist/dex/types.d.ts +0 -81
  360. package/dist/dex/types.js +0 -1
  361. package/dist/exports/root-bundle-and-tooling.d.ts +0 -27
  362. package/dist/exports/root-bundle-and-tooling.js +0 -30
  363. package/dist/exports/root-eni-and-bsc-iro.d.ts +0 -26
  364. package/dist/exports/root-eni-and-bsc-iro.js +0 -66
  365. package/dist/exports/root-foundations.d.ts +0 -35
  366. package/dist/exports/root-foundations.js +0 -70
  367. package/dist/exports/root-swap-dex-and-xlayer.d.ts +0 -30
  368. package/dist/exports/root-swap-dex-and-xlayer.js +0 -78
  369. package/dist/flap/index.d.ts +0 -10
  370. package/dist/flap/index.js +0 -8
  371. package/dist/flows/index.d.ts +0 -1
  372. package/dist/flows/index.js +0 -1
  373. package/dist/merkle/index.d.ts +0 -12
  374. package/dist/merkle/index.js +0 -11
  375. package/dist/shared/clients/index.d.ts +0 -8
  376. package/dist/shared/clients/index.js +0 -8
  377. package/dist/shared/constants/quote.d.ts +0 -30
  378. package/dist/shared/constants/quote.js +0 -37
  379. package/dist/shared/flap/portal-bundle-merkle/core-helpers.d.ts +0 -32
  380. package/dist/shared/flap/portal-bundle-merkle/core-helpers.js +0 -83
  381. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +0 -125
  382. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.js +0 -113
  383. package/dist/shared/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -149
  384. package/dist/shared/flap/portal-bundle-merkle/swap-helpers.js +0 -259
  385. package/dist/shared/foundation/dex/v3-path.d.ts +0 -6
  386. package/dist/shared/foundation/dex/v3-path.js +0 -35
  387. package/dist/shared/foundation/gas/bundle-gas.d.ts +0 -49
  388. package/dist/shared/foundation/gas/bundle-gas.js +0 -93
  389. package/dist/shared/foundation/gas/profit-hop.d.ts +0 -20
  390. package/dist/shared/foundation/gas/profit-hop.js +0 -72
  391. package/dist/shared/foundation/index.d.ts +0 -13
  392. package/dist/shared/foundation/index.js +0 -12
  393. package/dist/shared/foundation/nonce/nonce-manager.d.ts +0 -17
  394. package/dist/shared/foundation/nonce/nonce-manager.js +0 -183
  395. package/dist/shared/foundation/normalize-unknown.d.ts +0 -9
  396. package/dist/shared/foundation/normalize-unknown.js +0 -29
  397. package/dist/shared/foundation/sdk-logger.d.ts +0 -13
  398. package/dist/shared/foundation/sdk-logger.js +0 -12
  399. package/dist/shared/foundation/tx/build-request.d.ts +0 -17
  400. package/dist/shared/foundation/tx/build-request.js +0 -25
  401. package/dist/shared/foundation/tx/sign-batch.d.ts +0 -5
  402. package/dist/shared/foundation/tx/sign-batch.js +0 -26
  403. package/dist/shared/foundation/tx/wallet-sign-patch.d.ts +0 -1
  404. package/dist/shared/foundation/tx/wallet-sign-patch.js +0 -18
  405. package/dist/shared/foundation/types/airdrop-sweep.d.ts +0 -79
  406. package/dist/shared/foundation/types/airdrop-sweep.js +0 -1
  407. package/dist/shared/foundation/types/erc20.d.ts +0 -65
  408. package/dist/shared/foundation/types/erc20.js +0 -1
  409. package/dist/shared/foundation/types/holders-maker.d.ts +0 -64
  410. package/dist/shared/foundation/types/holders-maker.js +0 -1
  411. package/dist/shared/foundation/types/index.d.ts +0 -7
  412. package/dist/shared/foundation/types/index.js +0 -1
  413. package/dist/shared/foundation/types/lp-inspect.d.ts +0 -102
  414. package/dist/shared/foundation/types/lp-inspect.js +0 -1
  415. package/dist/shared/foundation/types/multicall.d.ts +0 -5
  416. package/dist/shared/foundation/types/multicall.js +0 -1
  417. package/dist/shared/foundation/types/private-sale.d.ts +0 -35
  418. package/dist/shared/foundation/types/private-sale.js +0 -1
  419. package/dist/shared/foundation/types/quote-helpers.d.ts +0 -17
  420. package/dist/shared/foundation/types/quote-helpers.js +0 -1
  421. package/dist/types/errors.d.ts +0 -27
  422. package/dist/types/errors.js +0 -34
  423. package/dist/utils/holders-maker/addresses.d.ts +0 -12
  424. package/dist/utils/holders-maker/addresses.js +0 -15
  425. package/dist/utils/holders-maker/buy-tx.d.ts +0 -44
  426. package/dist/utils/holders-maker/buy-tx.js +0 -278
  427. package/dist/utils/holders-maker/constants.d.ts +0 -6
  428. package/dist/utils/holders-maker/constants.js +0 -7
  429. package/dist/utils/holders-maker/disperse.d.ts +0 -18
  430. package/dist/utils/holders-maker/disperse.js +0 -90
  431. package/dist/utils/holders-maker/routing.d.ts +0 -4
  432. package/dist/utils/holders-maker/routing.js +0 -45
  433. package/dist/utils/holders-maker/transfer-tx.d.ts +0 -4
  434. package/dist/utils/holders-maker/transfer-tx.js +0 -67
  435. package/dist/utils/holders-maker-helpers.d.ts +0 -9
  436. package/dist/utils/holders-maker-helpers.js +0 -9
  437. package/dist/utils/hop-chains.d.ts +0 -35
  438. package/dist/utils/hop-chains.js +0 -215
  439. package/dist/utils/lp-inspect-helpers.d.ts +0 -9
  440. package/dist/utils/lp-inspect-helpers.js +0 -109
  441. package/dist/utils/types/airdrop-sweep.d.ts +0 -1
  442. package/dist/utils/types/airdrop-sweep.js +0 -1
  443. package/dist/utils/types/contract-factory.d.ts +0 -1
  444. package/dist/utils/types/contract-factory.js +0 -1
  445. package/dist/utils/types/erc20.d.ts +0 -1
  446. package/dist/utils/types/erc20.js +0 -1
  447. package/dist/utils/types/errors.d.ts +0 -1
  448. package/dist/utils/types/errors.js +0 -1
  449. package/dist/utils/types/holders-maker.d.ts +0 -1
  450. package/dist/utils/types/holders-maker.js +0 -1
  451. package/dist/utils/types/hop-chains.d.ts +0 -8
  452. package/dist/utils/types/hop-chains.js +0 -1
  453. package/dist/utils/types/index.d.ts +0 -13
  454. package/dist/utils/types/index.js +0 -1
  455. package/dist/utils/types/lp-inspect.d.ts +0 -1
  456. package/dist/utils/types/lp-inspect.js +0 -1
  457. package/dist/utils/types/mpc-exclusive.d.ts +0 -5
  458. package/dist/utils/types/mpc-exclusive.js +0 -1
  459. package/dist/utils/types/private-sale.d.ts +0 -1
  460. package/dist/utils/types/private-sale.js +0 -1
  461. package/dist/utils/types/quote-helpers.d.ts +0 -1
  462. package/dist/utils/types/quote-helpers.js +0 -1
  463. package/dist/utils/types/stealth-transfer.d.ts +0 -44
  464. package/dist/utils/types/stealth-transfer.js +0 -1
  465. package/dist/utils/types/wallet.d.ts +0 -25
  466. package/dist/utils/types/wallet.js +0 -1
  467. package/dist/vanity/index.d.ts +0 -5
  468. package/dist/vanity/index.js +0 -5
  469. package/src/abis/contracts/TaxToken.json +0 -969
  470. package/src/abis/contracts/TokenManager.json +0 -836
  471. package/src/abis/contracts/TokenManager2.json +0 -136
  472. package/src/abis/contracts/TokenManagerHelper3.json +0 -993
  473. /package/dist/{abis/contracts → shared/abis}/TokenManager.json +0 -0
  474. /package/dist/{abis/contracts → shared/abis}/TokenManagerHelper3.json +0 -0
@@ -1,16 +1,640 @@
1
1
  /**
2
- * holders-maker - 主函数
2
+ * ============================================================================
3
+ * 刷持有人(Holders Maker)
4
+ * ============================================================================
5
+ * 一键完成:生成钱包 → 分发资金 → 批量买入(同一个 bundle 完成)
6
+ * 支持原生代币(BNB/MON)和 ERC20 代币(USDT/USDC)作为购买资金
3
7
  */
4
- import { ethers, JsonRpcProvider, Wallet } from 'ethers';
8
+ import { ethers, JsonRpcProvider, Wallet, Contract } from 'ethers';
5
9
  import { generateWallets } from './wallet.js';
6
- import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from './bundle-helpers.js';
7
- import { BLOCKRAZOR_BUILDER_EOA, getProfitRecipient } from '../shared/constants/index.js';
8
- import { getProfitRateBps as getSharedProfitRateBps } from '../shared/constants/index.js';
9
- import { getErrorMessageFromUnknown } from '../shared/foundation/index.js';
10
- import { DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE_GWEI, DEFAULT_MAX_WALLETS_PER_BATCH_ERC20, DEFAULT_MAX_WALLETS_PER_BATCH_NATIVE, GAS_BUFFER_MULTIPLIER, NATIVE_TRANSFER_GAS_LIMIT, buildDaoaasBuyTx, buildDisperseHopChainERC20, buildDisperseHopChainNative, buildERC20ApproveTx, buildFlapBuyTx, buildFourBuyTx, buildNativeTransferTx, buildV2BuyTx, buildV2BuyTxWithERC20, buildV3BuyTx, buildV3BuyTxWithERC20, calculateMaxWalletsPerBatch, chunkArray, generateDisperseHopPaths, getBaseTokenAddress, getRouterAddress, } from './holders-maker-helpers.js';
10
+ import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, getDeadline } from './bundle-helpers.js';
11
+ import { ADDRESSES, BLOCKRAZOR_BUILDER_EOA, PROFIT_CONFIG, getProfitRecipient } from './constants.js';
12
+ import { GAS_LIMITS } from '../shared/constants/index.js';
13
+ import { FLAP_PORTAL_ADDRESSES } from '../shared/flap/constants.js';
14
+ import { V2_ROUTER_ABI, V3_ROUTER02_ABI, V3_ROUTER_LEGACY_ABI, ERC20_ABI } from '../shared/abis/common.js';
15
+ // Four 内盘 ABI
16
+ const FOUR_TM2_ABI = [
17
+ 'function buyTokenAMAP(uint256 origin, address token, address to, uint256 funds, uint256 minAmount) payable'
18
+ ];
19
+ // PancakeSwap Router 地址 (BSC)
20
+ const PANCAKE_V2_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV2Router;
21
+ const PANCAKE_V3_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV3Router;
22
+ const WBNB_ADDRESS = ADDRESSES.BSC.WBNB;
23
+ // ERC20 稳定币地址 (BSC)
24
+ const USDT_ADDRESS = ADDRESSES.BSC.USDT;
25
+ const USDC_ADDRESS = ADDRESSES.BSC.USDC;
26
+ // ✅ XLayer Router 地址
27
+ const XLAYER_V2_ROUTER_ADDRESS = ADDRESSES.XLAYER.PotatoSwapV2Router;
28
+ const XLAYER_V3_ROUTER_ADDRESS = ADDRESSES.XLAYER.PotatoSwapV3Router;
29
+ const WOKB_ADDRESS = ADDRESSES.XLAYER.WOKB;
30
+ // ✅ ENI Router 地址
31
+ const ENI_V2_ROUTER_ADDRESS = ADDRESSES.ENI.DswapV2Router;
32
+ const ENI_DAOAAS_PORTAL_ADDRESS = ADDRESSES.ENI.DaoaasPortal;
33
+ const WEGAS_ADDRESS = ADDRESSES.ENI.WEGAS;
34
+ // ERC20 转账和授权 Gas Limit(使用统一常量)
35
+ const ERC20_TRANSFER_GAS_LIMIT = GAS_LIMITS.ERC20_TRANSFER;
36
+ const ERC20_APPROVE_GAS_LIMIT = 50000n; // 授权 gas 相对固定
37
+ // ============================================================================
38
+ // 常量
39
+ // ============================================================================
40
+ const DEFAULT_GAS_LIMIT = 800000;
41
+ const DEFAULT_GAS_PRICE_GWEI = 3;
42
+ const GAS_BUFFER_MULTIPLIER = 2; // 2倍 Gas 费安全系数
43
+ const NATIVE_TRANSFER_GAS_LIMIT = GAS_LIMITS.NATIVE_TRANSFER;
44
+ /**
45
+ * 动态计算每批最大钱包数
46
+ *
47
+ * Bundle 限制 = 50 笔交易
48
+ * 固定开销:
49
+ * BSC: 贿赂 1 笔 + 利润多跳 (PROFIT_HOP_COUNT + 1) 笔
50
+ * XLayer: 利润 1 笔(无贿赂,无多跳)
51
+ *
52
+ * 原生模式(无分发多跳):
53
+ * 每钱包开销 = 分发 1 + 买入 1 = 2
54
+ * N ≤ (50 - 固定开销) / 2
55
+ *
56
+ * 原生模式(有分发多跳 H):
57
+ * 每钱包开销 = 分发 (H+1) + 买入 1 = H+2
58
+ * N ≤ (50 - 固定开销) / (H+2)
59
+ *
60
+ * ERC20 模式(无分发多跳):
61
+ * 每钱包开销 = 分发BNB 1 + 分发ERC20 1 + 授权 1 + 买入 1 = 4
62
+ * N ≤ (50 - 固定开销) / 4
63
+ *
64
+ * ERC20 模式(有分发多跳 H):
65
+ * 每钱包开销 = 分发BNB (H+1) + 分发ERC20 (H+1) + 授权 1 + 买入 1 = 2H+4
66
+ * N ≤ (50 - 固定开销) / (2H+4)
67
+ */
68
+ function calculateMaxWalletsPerBatch(isERC20Mode, disperseHopCount, chain) {
69
+ // XLayer/ENI 不需要贿赂和利润多跳
70
+ const isSimpleChain = chain === 'XLAYER' || chain === 'ENI';
71
+ const fixedOverhead = isSimpleChain ? 1 : (1 + PROFIT_HOP_COUNT + 1); // XLayer/ENI: 利润 1; BSC: 贿赂 + 利润多跳
72
+ const maxTxs = 50 - fixedOverhead;
73
+ if (isERC20Mode) {
74
+ // ERC20: 分发BNB (H+1) + 分发ERC20 (H+1) + 授权 1 + 买入 1
75
+ const perWalletTxs = 2 * (disperseHopCount + 1) + 2;
76
+ return Math.floor(maxTxs / perWalletTxs);
77
+ }
78
+ else {
79
+ // 原生: 分发 (H+1) + 买入 1
80
+ const perWalletTxs = disperseHopCount + 2;
81
+ return Math.floor(maxTxs / perWalletTxs);
82
+ }
83
+ }
84
+ // 默认值(无分发多跳)
85
+ const DEFAULT_MAX_WALLETS_PER_BATCH_NATIVE = calculateMaxWalletsPerBatch(false, 0);
86
+ const DEFAULT_MAX_WALLETS_PER_BATCH_ERC20 = calculateMaxWalletsPerBatch(true, 0);
87
+ // ============================================================================
88
+ // 辅助函数
89
+ // ============================================================================
90
+ /**
91
+ * 分批数组
92
+ */
93
+ function chunkArray(arr, size) {
94
+ const chunks = [];
95
+ for (let i = 0; i < arr.length; i += size) {
96
+ chunks.push(arr.slice(i, i + size));
97
+ }
98
+ return chunks;
99
+ }
100
+ /**
101
+ * 生成分发多跳路径
102
+ * @param targetWallets 目标钱包地址列表
103
+ * @param hopCount 多跳数量(0=直接转账,1=1个中间钱包,2=2个中间钱包...)
104
+ * @param provider Provider 实例
105
+ * @returns 每个目标钱包的多跳路径
106
+ */
107
+ function generateDisperseHopPaths(targetWallets, hopCount, provider) {
108
+ if (hopCount <= 0) {
109
+ // 无多跳,直接返回空路径
110
+ return targetWallets.map(w => ({
111
+ targetAddress: w.address,
112
+ hopWallets: [],
113
+ hopWalletsInfo: []
114
+ }));
115
+ }
116
+ // 为每个目标钱包生成中间钱包
117
+ return targetWallets.map(targetWallet => {
118
+ const hopWalletsInfo = generateWallets(hopCount);
119
+ const hopWallets = hopWalletsInfo.map(w => new Wallet(w.privateKey, provider));
120
+ return {
121
+ targetAddress: targetWallet.address,
122
+ hopWallets,
123
+ hopWalletsInfo
124
+ };
125
+ });
126
+ }
127
+ /**
128
+ * 构建分发多跳交易链(原生代币)
129
+ *
130
+ * 路径: payer → hop1 → hop2 → ... → target
131
+ *
132
+ * @param isERC20Mode 是否为 ERC20 模式(中间钱包需要预留 ERC20 转账 gas)
133
+ * @returns 签名交易数组
134
+ */
135
+ async function buildDisperseHopChainNative(payer, path, finalAmount, gasPrice, chainId, txType, payerNonce, isERC20Mode = false) {
136
+ const signedTxs = [];
137
+ const hopCount = path.hopWallets.length;
138
+ if (hopCount === 0) {
139
+ // 无多跳,直接转账
140
+ const tx = await buildNativeTransferTx(payer, path.targetAddress, finalAmount, payerNonce, gasPrice, chainId, txType);
141
+ signedTxs.push(tx);
142
+ return { signedTxs, payerNoncesUsed: 1 };
143
+ }
144
+ // 计算每一跳需要转出的金额(需要预留后续跳的 gas 费)
145
+ const hopGasCost = NATIVE_TRANSFER_GAS_LIMIT * gasPrice;
146
+ // ERC20 模式下,中间钱包还需要预留 ERC20 转账的 gas
147
+ const erc20TransferGasCost = isERC20Mode ? ERC20_TRANSFER_GAS_LIMIT * gasPrice : 0n;
148
+ // 从后往前计算每一跳需要的金额
149
+ // 原生模式:
150
+ // 最后一跳(hopN → target)需要: finalAmount + hopGasCost
151
+ // 倒数第二跳需要: finalAmount + 2 * hopGasCost
152
+ // ERC20 模式(中间钱包还需要预留 ERC20 转账 gas):
153
+ // 每个中间钱包额外需要: erc20TransferGasCost
154
+ const amountsPerHop = [];
155
+ for (let i = 0; i < hopCount; i++) {
156
+ const remainingHops = hopCount - i;
157
+ // 中间钱包需要的 BNB = 最终金额 + 后续 BNB 转账 gas + (ERC20模式下) 自己的 ERC20 转账 gas
158
+ const amount = finalAmount
159
+ + hopGasCost * BigInt(remainingHops)
160
+ + (isERC20Mode ? erc20TransferGasCost * BigInt(remainingHops) : 0n);
161
+ amountsPerHop.push(amount);
162
+ }
163
+ // 构建交易链
164
+ // 1. payer → hop1 (使用 payer nonce)
165
+ const firstTx = await buildNativeTransferTx(payer, path.hopWallets[0].address, amountsPerHop[0], payerNonce, gasPrice, chainId, txType);
166
+ signedTxs.push(firstTx);
167
+ // 2. hop1 → hop2 → ... → hopN → target (每个中间钱包 nonce=0)
168
+ for (let i = 0; i < hopCount; i++) {
169
+ const fromWallet = path.hopWallets[i];
170
+ const toAddress = i === hopCount - 1
171
+ ? path.targetAddress // 最后一跳到目标
172
+ : path.hopWallets[i + 1].address; // 中间跳到下一个 hop
173
+ // 最后一跳只需转最终金额,中间跳需要预留后续费用
174
+ const amount = i === hopCount - 1
175
+ ? finalAmount
176
+ : amountsPerHop[i + 1];
177
+ const tx = await buildNativeTransferTx(fromWallet, toAddress, amount, 0, // 中间钱包都是新生成的,nonce=0
178
+ gasPrice, chainId, txType);
179
+ signedTxs.push(tx);
180
+ }
181
+ return { signedTxs, payerNoncesUsed: 1 };
182
+ }
183
+ /**
184
+ * 构建分发多跳交易链(ERC20 代币)
185
+ *
186
+ * 路径: payer → hop1 → hop2 → ... → target
187
+ *
188
+ * 注意:ERC20 多跳需要配合 BNB 多跳使用,中间钱包需要先收到 BNB 作为 gas
189
+ * BNB 多跳先执行,确保中间钱包有 gas 费后再转发 ERC20
190
+ *
191
+ * 中间钱包的 nonce 安排:
192
+ * - nonce=0: BNB 转发(在 buildDisperseHopChainNative 中完成)
193
+ * - nonce=1: ERC20 转发(在本函数中完成)
194
+ */
195
+ async function buildDisperseHopChainERC20(payer, path, erc20Address, erc20Amount, gasPrice, chainId, txType, payerNonce) {
196
+ const signedTxs = [];
197
+ const hopCount = path.hopWallets.length;
198
+ if (hopCount === 0) {
199
+ // 无多跳,直接转账
200
+ const tx = await buildERC20TransferTx(payer, erc20Address, path.targetAddress, erc20Amount, payerNonce, gasPrice, chainId, txType);
201
+ signedTxs.push(tx);
202
+ return { signedTxs, payerNoncesUsed: 1 };
203
+ }
204
+ // 构建交易链
205
+ // payer 发送 ERC20 到 hop1
206
+ const firstTx = await buildERC20TransferTx(payer, erc20Address, path.hopWallets[0].address, erc20Amount, payerNonce, gasPrice, chainId, txType);
207
+ signedTxs.push(firstTx);
208
+ // 每个中间钱包转发 ERC20
209
+ // nonce=1(因为 nonce=0 已经用于 BNB 转发)
210
+ for (let i = 0; i < hopCount; i++) {
211
+ const fromWallet = path.hopWallets[i];
212
+ const toAddress = i === hopCount - 1
213
+ ? path.targetAddress
214
+ : path.hopWallets[i + 1].address;
215
+ const tx = await buildERC20TransferTx(fromWallet, erc20Address, toAddress, erc20Amount, 1, // ✅ nonce=1(nonce=0 用于 BNB 转发)
216
+ gasPrice, chainId, txType);
217
+ signedTxs.push(tx);
218
+ }
219
+ return { signedTxs, payerNoncesUsed: 1 };
220
+ }
221
+ /**
222
+ * 获取 ERC20 稳定币地址
223
+ */
224
+ function getBaseTokenAddress(baseToken, chain, customAddress) {
225
+ if (customAddress)
226
+ return customAddress;
227
+ if (chain === 'ENI') {
228
+ if (baseToken === 'usdt')
229
+ return ADDRESSES.ENI.USDT;
230
+ if (baseToken === 'usdc')
231
+ return ADDRESSES.ENI.USDC;
232
+ }
233
+ if (baseToken === 'usdt')
234
+ return USDT_ADDRESS;
235
+ if (baseToken === 'usdc')
236
+ return USDC_ADDRESS;
237
+ throw new Error(`未知的基础代币类型: ${baseToken}`);
238
+ }
239
+ /**
240
+ * 获取 Router 地址(用于授权)
241
+ */
242
+ function getRouterAddress(tradeType, chain, v2RouterOverride) {
243
+ if (chain === 'ENI') {
244
+ switch (tradeType) {
245
+ case 'v2': return v2RouterOverride || ENI_V2_ROUTER_ADDRESS;
246
+ case 'daoaas': return ENI_DAOAAS_PORTAL_ADDRESS;
247
+ default: throw new Error(`ENI 链不支持交易类型: ${tradeType},仅支持 daoaas/v2`);
248
+ }
249
+ }
250
+ const isXLayer = chain === 'XLAYER';
251
+ switch (tradeType) {
252
+ case 'v2':
253
+ if (v2RouterOverride)
254
+ return v2RouterOverride;
255
+ return isXLayer ? XLAYER_V2_ROUTER_ADDRESS : PANCAKE_V2_ROUTER_ADDRESS;
256
+ case 'v3':
257
+ return isXLayer ? XLAYER_V3_ROUTER_ADDRESS : PANCAKE_V3_ROUTER_ADDRESS;
258
+ default:
259
+ throw new Error(`ERC20 模式不支持交易类型: ${tradeType},仅支持 v2/v3`);
260
+ }
261
+ }
262
+ /**
263
+ * 获取包装原生代币地址
264
+ */
265
+ function getWrappedNativeAddress(chain) {
266
+ if (chain === 'ENI')
267
+ return WEGAS_ADDRESS;
268
+ return chain === 'XLAYER' ? WOKB_ADDRESS : WBNB_ADDRESS;
269
+ }
270
+ /**
271
+ * 构建 ERC20 转账交易
272
+ */
273
+ async function buildERC20TransferTx(wallet, tokenAddress, to, amount, nonce, gasPrice, chainId, txType) {
274
+ const iface = new ethers.Interface(ERC20_ABI);
275
+ const data = iface.encodeFunctionData('transfer', [to, amount]);
276
+ const tx = {
277
+ to: tokenAddress,
278
+ data,
279
+ value: 0n,
280
+ nonce,
281
+ gasLimit: ERC20_TRANSFER_GAS_LIMIT,
282
+ chainId
283
+ };
284
+ if (txType === 2) {
285
+ tx.maxFeePerGas = gasPrice;
286
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
287
+ tx.type = 2;
288
+ }
289
+ else {
290
+ tx.gasPrice = gasPrice;
291
+ tx.type = 0;
292
+ }
293
+ return await wallet.signTransaction(tx);
294
+ }
295
+ /**
296
+ * 构建 ERC20 授权交易
297
+ */
298
+ async function buildERC20ApproveTx(wallet, tokenAddress, spender, amount, nonce, gasPrice, chainId, txType) {
299
+ const iface = new ethers.Interface(ERC20_ABI);
300
+ const data = iface.encodeFunctionData('approve', [spender, amount]);
301
+ const tx = {
302
+ to: tokenAddress,
303
+ data,
304
+ value: 0n,
305
+ nonce,
306
+ gasLimit: ERC20_APPROVE_GAS_LIMIT,
307
+ chainId
308
+ };
309
+ if (txType === 2) {
310
+ tx.maxFeePerGas = gasPrice;
311
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
312
+ tx.type = 2;
313
+ }
314
+ else {
315
+ tx.gasPrice = gasPrice;
316
+ tx.type = 0;
317
+ }
318
+ return await wallet.signTransaction(tx);
319
+ }
320
+ /**
321
+ * 构建原生代币转账交易
322
+ */
323
+ async function buildNativeTransferTx(wallet, to, amount, nonce, gasPrice, chainId, txType) {
324
+ const tx = {
325
+ to,
326
+ value: amount,
327
+ nonce,
328
+ gasLimit: GAS_LIMITS.BRIBE,
329
+ chainId
330
+ };
331
+ if (txType === 2) {
332
+ tx.maxFeePerGas = gasPrice;
333
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
334
+ tx.type = 2;
335
+ }
336
+ else {
337
+ tx.gasPrice = gasPrice;
338
+ tx.type = 0;
339
+ }
340
+ return await wallet.signTransaction(tx);
341
+ }
342
+ /**
343
+ * 构建 Flap 买入交易
344
+ * 使用 swapExactInput 方法
345
+ */
346
+ async function buildFlapBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, chain) {
347
+ const portalAddress = FLAP_PORTAL_ADDRESSES[chain];
348
+ // ✅ 使用正确的 Flap Portal ABI
349
+ const iface = new ethers.Interface([
350
+ 'function swapExactInput((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)'
351
+ ]);
352
+ // ✅ 构建 swapExactInput 参数
353
+ // inputToken = 0x0 表示原生代币(BNB)
354
+ // outputToken = tokenAddress(要买入的代币)
355
+ const data = iface.encodeFunctionData('swapExactInput', [{
356
+ inputToken: ethers.ZeroAddress, // 原生代币(BNB)
357
+ outputToken: tokenAddress, // 要买入的代币
358
+ inputAmount: buyAmount,
359
+ minOutputAmount: 0n, // 不设滑点保护
360
+ permitData: '0x'
361
+ }]);
362
+ const tx = {
363
+ to: portalAddress,
364
+ data,
365
+ value: buyAmount,
366
+ nonce,
367
+ gasLimit: BigInt(gasLimit),
368
+ chainId
369
+ };
370
+ if (txType === 2) {
371
+ tx.maxFeePerGas = gasPrice;
372
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
373
+ tx.type = 2;
374
+ }
375
+ else {
376
+ tx.gasPrice = gasPrice;
377
+ tx.type = 0;
378
+ }
379
+ return await wallet.signTransaction(tx);
380
+ }
381
+ /**
382
+ * 构建 Four 内盘买入交易
383
+ * 使用 buyTokenAMAP 方法
384
+ */
385
+ async function buildFourBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType) {
386
+ const tmAddress = ADDRESSES.BSC.TokenManagerOriginal;
387
+ const iface = new ethers.Interface(FOUR_TM2_ABI);
388
+ const data = iface.encodeFunctionData('buyTokenAMAP', [
389
+ 0n, // origin
390
+ tokenAddress, // token
391
+ wallet.address, // to(接收者为自己)
392
+ buyAmount, // funds
393
+ 0n // minAmount(不设滑点保护)
394
+ ]);
395
+ const tx = {
396
+ to: tmAddress,
397
+ data,
398
+ value: buyAmount,
399
+ nonce,
400
+ gasLimit: BigInt(gasLimit),
401
+ chainId
402
+ };
403
+ if (txType === 2) {
404
+ tx.maxFeePerGas = gasPrice;
405
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
406
+ tx.type = 2;
407
+ }
408
+ else {
409
+ tx.gasPrice = gasPrice;
410
+ tx.type = 0;
411
+ }
412
+ return await wallet.signTransaction(tx);
413
+ }
414
+ /**
415
+ * 构建 DAOaaS 内盘买入交易 (ENI 链)
416
+ * EGAS → Token (使用 DAOaaS Portal buy)
417
+ */
418
+ async function buildDaoaasBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId) {
419
+ const portalAbi = ['function purchaseToken(address token, uint256 AmountMin) payable'];
420
+ const iface = new ethers.Interface(portalAbi);
421
+ const data = iface.encodeFunctionData('purchaseToken', [tokenAddress, 0n]);
422
+ const tx = {
423
+ to: ENI_DAOAAS_PORTAL_ADDRESS,
424
+ data,
425
+ value: buyAmount,
426
+ nonce,
427
+ gasLimit: BigInt(gasLimit),
428
+ chainId,
429
+ type: 2,
430
+ maxFeePerGas: gasPrice,
431
+ maxPriorityFeePerGas: gasPrice / 10n || 1n,
432
+ };
433
+ return await wallet.signTransaction(tx);
434
+ }
435
+ /**
436
+ * 构建 V2 买入交易
437
+ * BNB/OKB → Token (使用 swapExactETHForTokensSupportingFeeOnTransferTokens)
438
+ */
439
+ async function buildV2BuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v2Path, chain, v2RouterOverride) {
440
+ const wrappedNative = getWrappedNativeAddress(chain);
441
+ const routerAddress = v2RouterOverride || getRouterAddress('v2', chain);
442
+ const path = v2Path ? [...v2Path].reverse() : [wrappedNative, tokenAddress];
443
+ const deadline = getDeadline();
444
+ const v2Router = new Contract(routerAddress, V2_ROUTER_ABI, wallet);
445
+ const unsigned = await v2Router.swapExactETHForTokensSupportingFeeOnTransferTokens.populateTransaction(0n, // amountOutMin(不设滑点保护)
446
+ path, wallet.address, deadline, { value: buyAmount });
447
+ const tx = {
448
+ ...unsigned,
449
+ nonce,
450
+ gasLimit: BigInt(gasLimit),
451
+ chainId
452
+ };
453
+ if (txType === 2) {
454
+ tx.maxFeePerGas = gasPrice;
455
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
456
+ tx.type = 2;
457
+ }
458
+ else {
459
+ tx.gasPrice = gasPrice;
460
+ tx.type = 0;
461
+ }
462
+ return await wallet.signTransaction(tx);
463
+ }
464
+ /**
465
+ * 构建 V3 单跳买入交易
466
+ * BNB/OKB → Token (使用 exactInputSingle + multicall)
467
+ *
468
+ * ✅ 修复:根据链类型选择正确的 Router ABI 版本
469
+ * - XLayer/Monad: 旧版 Router(exactInputSingle 包含 deadline,multicall(bytes[]))
470
+ * - BSC: 新版 SwapRouter02(exactInputSingle 不含 deadline,multicall(uint256,bytes[]))
471
+ */
472
+ async function buildV3BuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v3Fee = 2500, // 默认 0.25% 手续费
473
+ chain) {
474
+ const deadline = getDeadline();
475
+ const wrappedNative = getWrappedNativeAddress(chain);
476
+ const routerAddress = chain === 'XLAYER' ? XLAYER_V3_ROUTER_ADDRESS : PANCAKE_V3_ROUTER_ADDRESS;
477
+ // ✅ 根据链类型选择正确的 ABI 版本
478
+ // XLayer/Monad 使用旧版 Router(exactInputSingle 包含 deadline)
479
+ // BSC 使用新版 SwapRouter02(exactInputSingle 不含 deadline)
480
+ const useLegacyRouter = chain === 'XLAYER' || chain === 'MONAD';
481
+ const v3RouterIface = new ethers.Interface(useLegacyRouter ? V3_ROUTER_LEGACY_ABI : V3_ROUTER02_ABI);
482
+ let multicallData;
483
+ if (useLegacyRouter) {
484
+ // ✅ 旧版 Router:swapParams 包含 deadline,multicall(bytes[])
485
+ const swapParams = {
486
+ tokenIn: wrappedNative,
487
+ tokenOut: tokenAddress,
488
+ fee: v3Fee,
489
+ recipient: wallet.address,
490
+ deadline, // ✅ 旧版包含 deadline
491
+ amountIn: buyAmount,
492
+ amountOutMinimum: 0n,
493
+ sqrtPriceLimitX96: 0n
494
+ };
495
+ const exactInputSingleData = v3RouterIface.encodeFunctionData('exactInputSingle', [swapParams]);
496
+ const refundETHData = v3RouterIface.encodeFunctionData('refundETH', []);
497
+ // ✅ 旧版 multicall:只有 bytes[] 参数
498
+ multicallData = v3RouterIface.encodeFunctionData('multicall(bytes[])', [
499
+ [exactInputSingleData, refundETHData]
500
+ ]);
501
+ }
502
+ else {
503
+ // ✅ 新版 SwapRouter02:swapParams 不含 deadline,multicall(uint256,bytes[])
504
+ const swapParams = {
505
+ tokenIn: wrappedNative,
506
+ tokenOut: tokenAddress,
507
+ fee: v3Fee,
508
+ recipient: wallet.address,
509
+ amountIn: buyAmount,
510
+ amountOutMinimum: 0n,
511
+ sqrtPriceLimitX96: 0n
512
+ };
513
+ const exactInputSingleData = v3RouterIface.encodeFunctionData('exactInputSingle', [swapParams]);
514
+ const refundETHData = v3RouterIface.encodeFunctionData('refundETH', []);
515
+ // ✅ 新版 multicall:deadline 作为第一个参数
516
+ multicallData = v3RouterIface.encodeFunctionData('multicall(uint256,bytes[])', [
517
+ deadline,
518
+ [exactInputSingleData, refundETHData]
519
+ ]);
520
+ }
521
+ const tx = {
522
+ to: routerAddress,
523
+ data: multicallData,
524
+ value: buyAmount,
525
+ nonce,
526
+ gasLimit: BigInt(gasLimit),
527
+ chainId
528
+ };
529
+ if (txType === 2) {
530
+ tx.maxFeePerGas = gasPrice;
531
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
532
+ tx.type = 2;
533
+ }
534
+ else {
535
+ tx.gasPrice = gasPrice;
536
+ tx.type = 0;
537
+ }
538
+ return await wallet.signTransaction(tx);
539
+ }
540
+ /**
541
+ * 构建 V2 买入交易(ERC20 输入)
542
+ * USDT/USDC → Token (使用 swapExactTokensForTokensSupportingFeeOnTransferTokens)
543
+ */
544
+ async function buildV2BuyTxWithERC20(wallet, tokenAddress, baseTokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v2RouterOverride, chain) {
545
+ const path = [baseTokenAddress, tokenAddress];
546
+ const deadline = getDeadline();
547
+ const routerAddress = v2RouterOverride || getRouterAddress('v2', chain);
548
+ const v2Router = new Contract(routerAddress, V2_ROUTER_ABI, wallet);
549
+ const unsigned = await v2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(buyAmount, // amountIn
550
+ 0n, // amountOutMin(不设滑点保护)
551
+ path, wallet.address, deadline);
552
+ const tx = {
553
+ ...unsigned,
554
+ nonce,
555
+ gasLimit: BigInt(gasLimit),
556
+ chainId
557
+ };
558
+ if (txType === 2) {
559
+ tx.maxFeePerGas = gasPrice;
560
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
561
+ tx.type = 2;
562
+ }
563
+ else {
564
+ tx.gasPrice = gasPrice;
565
+ tx.type = 0;
566
+ }
567
+ return await wallet.signTransaction(tx);
568
+ }
569
+ /**
570
+ * 构建 V3 买入交易(ERC20 输入)
571
+ * USDT/USDC → Token (使用 exactInputSingle + multicall)
572
+ *
573
+ * ✅ 修复:使用 ethers.Interface 手动编码 calldata,避免 multicall 重载问题
574
+ */
575
+ async function buildV3BuyTxWithERC20(wallet, tokenAddress, baseTokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v3Fee = 2500) {
576
+ const deadline = getDeadline();
577
+ const v3RouterIface = new ethers.Interface(V3_ROUTER02_ABI);
578
+ // 构建 exactInputSingle calldata
579
+ const swapParams = {
580
+ tokenIn: baseTokenAddress,
581
+ tokenOut: tokenAddress,
582
+ fee: v3Fee,
583
+ recipient: wallet.address,
584
+ amountIn: buyAmount,
585
+ amountOutMinimum: 0n,
586
+ sqrtPriceLimitX96: 0n
587
+ };
588
+ const exactInputSingleData = v3RouterIface.encodeFunctionData('exactInputSingle', [swapParams]);
589
+ // ✅ 使用明确的函数签名编码 multicall,避免重载问题
590
+ const multicallData = v3RouterIface.encodeFunctionData('multicall(uint256,bytes[])', [
591
+ deadline,
592
+ [exactInputSingleData]
593
+ ]);
594
+ const tx = {
595
+ to: PANCAKE_V3_ROUTER_ADDRESS,
596
+ data: multicallData,
597
+ value: 0n,
598
+ nonce,
599
+ gasLimit: BigInt(gasLimit),
600
+ chainId
601
+ };
602
+ if (txType === 2) {
603
+ tx.maxFeePerGas = gasPrice;
604
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
605
+ tx.type = 2;
606
+ }
607
+ else {
608
+ tx.gasPrice = gasPrice;
609
+ tx.type = 0;
610
+ }
611
+ return await wallet.signTransaction(tx);
612
+ }
613
+ // ============================================================================
614
+ // 主方法
615
+ // ============================================================================
616
+ /**
617
+ * 刷持有人(一个 bundle 完成分发+买入)
618
+ *
619
+ * 原生代币模式流程(同一个 bundle):
620
+ * 1. 贿赂交易
621
+ * 2. 分发原生代币(dev → 新钱包)
622
+ * 3. 买入交易(新钱包 nonce=0)
623
+ * 4. 利润多跳
624
+ *
625
+ * ERC20 模式流程(同一个 bundle):
626
+ * 1. 贿赂交易
627
+ * 2. 分发原生代币(gas 费)
628
+ * 3. 分发 ERC20 代币(购买资金)
629
+ * 4. 授权交易(新钱包 nonce=0)
630
+ * 5. 买入交易(新钱包 nonce=1)
631
+ * 6. 利润多跳
632
+ *
633
+ * @returns 包含所有签名交易的结果,由前端提交
634
+ */
11
635
  export async function holdersMaker(params) {
12
- const { payerPrivateKey, holdersCount, buyAmountPerHolder, tokenAddress, baseToken = 'native', baseTokenAddress, baseTokenDecimals = 18, config, } = params;
13
- const { rpcUrl, chain = 'BSC', chainId: configChainId, tradeType = 'flap', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI, bribeAmount = 0.000001, txType: configTxType = 0, disperseHopCount = 0, // ✅ 分发多跳数(默认0=直接转账)
636
+ const { payerPrivateKey, holdersCount, buyAmountPerHolder, tokenAddress, baseToken = 'native', baseTokenAddress, baseTokenDecimals = 18, config } = params;
637
+ const { rpcUrl, chain = 'BSC', chainId: configChainId, tradeType = 'flap', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI, bribeAmount = 0.000001, txType: configTxType = 0, disperseHopCount = 0 // ✅ 分发多跳数(默认0=直接转账)
14
638
  } = config;
15
639
  // ENI 链强制使用 EIP-1559 (type 2)
16
640
  const txType = chain === 'ENI' ? 2 : configTxType;
@@ -22,7 +646,7 @@ export async function holdersMaker(params) {
22
646
  signedTransactions: [],
23
647
  batchResults: [],
24
648
  successBatchCount: 0,
25
- totalBatchCount: 0,
649
+ totalBatchCount: 0
26
650
  };
27
651
  const isERC20Mode = baseToken !== 'native';
28
652
  // ✅ ERC20 模式只支持 v2/v3 外盘
@@ -39,16 +663,20 @@ export async function holdersMaker(params) {
39
663
  // ✅ 根据分发多跳数动态计算每批最大钱包数
40
664
  // XLayer 强制禁用分发多跳(ENI 已支持前端分层广播)
41
665
  const effectiveDisperseHopCount = chain === 'XLAYER' ? 0 : disperseHopCount;
42
- const maxWalletsPerBatch = config.maxWalletsPerBatch || calculateMaxWalletsPerBatch(isERC20Mode, effectiveDisperseHopCount, chain);
666
+ const maxWalletsPerBatch = config.maxWalletsPerBatch ||
667
+ calculateMaxWalletsPerBatch(isERC20Mode, effectiveDisperseHopCount, chain);
668
+ console.log(`[HoldersMaker] chain: ${chain}, 分发多跳数: ${effectiveDisperseHopCount}, 每批最大钱包数: ${maxWalletsPerBatch}`);
43
669
  try {
44
670
  // 1. 初始化
45
671
  const provider = new JsonRpcProvider(rpcUrl);
46
672
  const chainId = configChainId || Number((await provider.getNetwork()).chainId);
47
673
  const payer = new Wallet(payerPrivateKey, provider);
48
674
  const nonceManager = new NonceManager(provider);
675
+ console.log(`[HoldersMaker] 开始刷持有人: chain=${chain}, chainId=${chainId}, holdersCount=${holdersCount}, baseToken=${baseToken}`);
49
676
  // 2. 生成新钱包
50
677
  const newWallets = generateWallets(holdersCount);
51
678
  result.newWallets = newWallets;
679
+ console.log(`[HoldersMaker] 生成 ${newWallets.length} 个新钱包`);
52
680
  // 3. 计算金额
53
681
  const gasPriceWei = BigInt(Math.floor(gasPriceGwei * 1e9));
54
682
  const gasPrice = await getOptimizedGasPrice(provider, { minGasPrice: gasPriceWei });
@@ -67,20 +695,24 @@ export async function holdersMaker(params) {
67
695
  transferNativePerWallet = gasWithBuffer;
68
696
  // 获取 ERC20 地址
69
697
  erc20TokenAddress = getBaseTokenAddress(baseToken, chain, baseTokenAddress);
698
+ console.log(`[HoldersMaker] ERC20 模式: ${baseToken} (${erc20TokenAddress})`);
699
+ console.log(`[HoldersMaker] 每个钱包分发: ${ethers.formatEther(transferNativePerWallet)} BNB (Gas) + ${buyAmountPerHolder} ${baseToken.toUpperCase()}`);
70
700
  }
71
701
  else {
72
702
  // 原生代币模式
73
703
  buyAmountWei = ethers.parseEther(buyAmountPerHolder);
74
704
  transferNativePerWallet = buyAmountWei + gasWithBuffer;
705
+ console.log(`[HoldersMaker] 每个钱包分发: ${ethers.formatEther(transferNativePerWallet)} BNB (买入 ${buyAmountPerHolder} + Gas ${ethers.formatEther(gasWithBuffer)})`);
75
706
  }
76
707
  // 4. 分批处理
77
708
  const walletBatches = chunkArray(newWallets, maxWalletsPerBatch);
78
709
  result.totalBatchCount = walletBatches.length;
710
+ console.log(`[HoldersMaker] 分 ${walletBatches.length} 批处理,每批最多 ${maxWalletsPerBatch} 个钱包`);
79
711
  // 5. 计算利润(基于原生代币)
80
712
  const totalBuyAmountForProfit = isERC20Mode
81
713
  ? ethers.parseEther(buyAmountPerHolder) * BigInt(holdersCount) // 按等值 BNB 计算
82
714
  : buyAmountWei * BigInt(holdersCount);
83
- const profitRateBps = getSharedProfitRateBps('normal');
715
+ const profitRateBps = PROFIT_CONFIG.RATE_BPS;
84
716
  const totalProfit = (totalBuyAmountForProfit * BigInt(profitRateBps)) / 10000n;
85
717
  let profitPerBatch = totalProfit / BigInt(walletBatches.length);
86
718
  if (profitPerBatch > 0n && chain === 'ENI') {
@@ -88,7 +720,7 @@ export async function holdersMaker(params) {
88
720
  }
89
721
  // 利润计算完成
90
722
  // 6. 生成分发多跳路径(如果启用)
91
- const allDisperseHopWallets = [];
723
+ let allDisperseHopWallets = [];
92
724
  const disperseHopPaths = generateDisperseHopPaths(newWallets, effectiveDisperseHopCount, provider);
93
725
  if (effectiveDisperseHopCount > 0) {
94
726
  // 收集所有中间钱包信息用于导出
@@ -96,11 +728,13 @@ export async function holdersMaker(params) {
96
728
  allDisperseHopWallets.push(...path.hopWalletsInfo);
97
729
  }
98
730
  result.disperseHopWallets = allDisperseHopWallets;
731
+ console.log(`[HoldersMaker] 分发多跳: ${effectiveDisperseHopCount} 跳,共生成 ${allDisperseHopWallets.length} 个中间钱包`);
99
732
  }
100
733
  // ✅ XLayer/ENI 特殊处理:不需要贿赂和利润多跳
101
734
  const isSimpleChain = chain === 'XLAYER' || chain === 'ENI';
102
735
  const needBribe = !isSimpleChain;
103
736
  const needProfitHop = !isSimpleChain;
737
+ const effectiveProfitHopCount = needProfitHop ? PROFIT_HOP_COUNT : 0;
104
738
  // 7. 并行生成所有批次的签名
105
739
  const batchPromises = walletBatches.map(async (batch, batchIdx) => {
106
740
  try {
@@ -111,7 +745,7 @@ export async function holdersMaker(params) {
111
745
  // BSC 原生模式(有多跳H): 贿赂 1 + 分发首跳 N + 利润 (PROFIT_HOP_COUNT + 1)
112
746
  // BSC ERC20模式(无多跳): 贿赂 1 + 分发BNB N + 分发ERC20 N + 利润 (PROFIT_HOP_COUNT + 1)
113
747
  const bribeCount = needBribe ? 1 : 0;
114
- const profitCount = needProfitHop ? PROFIT_HOP_COUNT + 1 : 1; // XLayer 只有 1 笔利润转账
748
+ const profitCount = needProfitHop ? (PROFIT_HOP_COUNT + 1) : 1; // XLayer 只有 1 笔利润转账
115
749
  const payerNonceCount = isERC20Mode
116
750
  ? bribeCount + batch.length * 2 + profitCount
117
751
  : bribeCount + batch.length + profitCount;
@@ -128,7 +762,8 @@ export async function holdersMaker(params) {
128
762
  // (2) 分发原生代币(支持多跳)
129
763
  for (let i = 0; i < batch.length; i++) {
130
764
  const path = batchPaths[i];
131
- const { signedTxs: hopTxs } = await buildDisperseHopChainNative(payer, path, transferNativePerWallet, gasPrice, chainId, txType, payerNonces[payerNonceIdx++], isERC20Mode);
765
+ const { signedTxs: hopTxs } = await buildDisperseHopChainNative(payer, path, transferNativePerWallet, gasPrice, chainId, txType, payerNonces[payerNonceIdx++], isERC20Mode // ✅ ERC20 模式下,中间钱包需要预留 ERC20 转账 gas
766
+ );
132
767
  signedTxs.push(...hopTxs);
133
768
  }
134
769
  // (3) ERC20 模式:分发 ERC20 代币(支持多跳)
@@ -209,7 +844,7 @@ export async function holdersMaker(params) {
209
844
  gasPrice,
210
845
  chainId,
211
846
  txType,
212
- startNonce: payerNonces[payerNonceIdx],
847
+ startNonce: payerNonces[payerNonceIdx]
213
848
  });
214
849
  signedTxs.push(...profitHopResult.signedTransactions);
215
850
  profitHopWallets = profitHopResult.hopWallets;
@@ -225,15 +860,15 @@ export async function holdersMaker(params) {
225
860
  success: true,
226
861
  signedTransactions: signedTxs,
227
862
  walletCount: batch.length,
228
- profitHopWallets, // ✅ 返回利润多跳钱包
863
+ profitHopWallets // ✅ 返回利润多跳钱包
229
864
  };
230
865
  }
231
866
  catch (error) {
232
867
  return {
233
868
  batchIndex: batchIdx,
234
869
  success: false,
235
- error: getErrorMessageFromUnknown(error),
236
- walletCount: batch.length,
870
+ error: error.message,
871
+ walletCount: batch.length
237
872
  };
238
873
  }
239
874
  });
@@ -255,7 +890,7 @@ export async function holdersMaker(params) {
255
890
  signedTransactions: res.signedTransactions,
256
891
  error: res.error,
257
892
  walletCount: res.walletCount,
258
- disperseHopCount: effectiveDisperseHopCount, // ✅ 添加分发多跳数
893
+ disperseHopCount: effectiveDisperseHopCount // ✅ 添加分发多跳数
259
894
  });
260
895
  }
261
896
  // ✅ 添加利润多跳钱包到结果
@@ -265,11 +900,11 @@ export async function holdersMaker(params) {
265
900
  // ✅ 添加分发多跳数到结果
266
901
  result.disperseHopCount = effectiveDisperseHopCount;
267
902
  result.success = result.successBatchCount > 0;
903
+ console.log(`[HoldersMaker] 完成: ${result.successBatchCount}/${result.totalBatchCount} 批成功`);
268
904
  }
269
905
  catch (error) {
270
- const msg = getErrorMessageFromUnknown(error);
271
- result.error = msg;
272
- console.error(`[HoldersMaker] 整体失败:`, msg);
906
+ result.error = error.message;
907
+ console.error(`[HoldersMaker] 整体失败:`, error.message);
273
908
  }
274
909
  return result;
275
910
  }
@@ -277,7 +912,7 @@ export async function holdersMaker(params) {
277
912
  * 获取刷持有人预估费用
278
913
  */
279
914
  export function estimateHoldersMakerCost(params) {
280
- const { holdersCount, buyAmountPerHolder, baseToken = 'native', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI, } = params;
915
+ const { holdersCount, buyAmountPerHolder, baseToken = 'native', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI } = params;
281
916
  const isERC20Mode = baseToken !== 'native';
282
917
  const gasMultiplier = isERC20Mode ? 2 : 1; // ERC20 模式需要授权+购买
283
918
  const gasFeePerWallet = (gasLimit * gasPriceGwei * gasMultiplier) / 1e9;
@@ -294,7 +929,7 @@ export function estimateHoldersMakerCost(params) {
294
929
  totalNativeCost: totalNativeCost.toFixed(6),
295
930
  totalERC20Cost: totalERC20Cost.toFixed(6),
296
931
  gasEstimate: (gasWithBuffer * holdersCount).toFixed(6),
297
- batchCount,
932
+ batchCount
298
933
  };
299
934
  }
300
935
  else {
@@ -304,7 +939,7 @@ export function estimateHoldersMakerCost(params) {
304
939
  return {
305
940
  totalNativeCost: totalNativeCost.toFixed(6),
306
941
  gasEstimate: (gasWithBuffer * holdersCount).toFixed(6),
307
- batchCount,
942
+ batchCount
308
943
  };
309
944
  }
310
945
  }