four-flap-meme-sdk 2.2.2 → 2.2.4

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 (472) hide show
  1. package/README.en.md +41 -6
  2. package/README.md +31 -0
  3. package/README.zh-CN.md +41 -6
  4. package/dist/__tests__/subpath-exports.test.d.ts +1 -0
  5. package/dist/__tests__/subpath-exports.test.js +64 -0
  6. package/dist/abis/common.d.ts +85 -0
  7. package/dist/abis/common.js +264 -0
  8. package/dist/abis/contracts/TaxToken.json +969 -0
  9. package/dist/abis/contracts/TokenManager2.json +136 -0
  10. package/dist/abis/contracts/index.d.ts +5 -0
  11. package/dist/abis/contracts/index.js +5 -0
  12. package/dist/abis/flap/index.d.ts +3 -0
  13. package/dist/abis/flap/index.js +3 -0
  14. package/dist/abis/flap/portal-events.d.ts +6 -0
  15. package/dist/abis/flap/portal-events.js +17 -0
  16. package/dist/abis/flap/portal.d.ts +6 -0
  17. package/dist/abis/flap/portal.js +37 -0
  18. package/dist/abis/flap/vault.d.ts +171 -0
  19. package/dist/abis/flap/vault.js +91 -0
  20. package/dist/abis/index.d.ts +8 -0
  21. package/dist/abis/index.js +11 -0
  22. package/dist/bundle-core/__tests__/config-helpers.test.d.ts +1 -0
  23. package/dist/bundle-core/__tests__/config-helpers.test.js +28 -0
  24. package/dist/bundle-core/__tests__/facade-parity.test.d.ts +1 -0
  25. package/dist/bundle-core/__tests__/facade-parity.test.js +33 -0
  26. package/dist/bundle-core/__tests__/sign-context-helpers.test.d.ts +1 -0
  27. package/dist/bundle-core/__tests__/sign-context-helpers.test.js +60 -0
  28. package/dist/bundle-core/__tests__/sign-fixture.test.d.ts +1 -0
  29. package/dist/bundle-core/__tests__/sign-fixture.test.js +220 -0
  30. package/dist/bundle-core/__tests__/sign-fixtures.d.ts +10 -0
  31. package/dist/bundle-core/__tests__/sign-fixtures.js +16 -0
  32. package/dist/bundle-core/config-helpers.d.ts +36 -0
  33. package/dist/bundle-core/config-helpers.js +57 -0
  34. package/dist/bundle-core/errors.d.ts +50 -0
  35. package/dist/bundle-core/errors.js +35 -0
  36. package/dist/bundle-core/four-meme/approve-tokenmanager.d.ts +7 -0
  37. package/dist/bundle-core/four-meme/approve-tokenmanager.js +99 -0
  38. package/dist/bundle-core/four-meme/core-helpers.d.ts +8 -0
  39. package/dist/bundle-core/four-meme/core-helpers.js +40 -0
  40. package/dist/bundle-core/four-meme/core.d.ts +4 -0
  41. package/dist/bundle-core/four-meme/core.js +515 -0
  42. package/dist/bundle-core/four-meme/pancake-proxy.d.ts +28 -0
  43. package/dist/bundle-core/four-meme/pancake-proxy.js +679 -0
  44. package/dist/bundle-core/four-meme/private.d.ts +27 -0
  45. package/dist/bundle-core/four-meme/private.js +465 -0
  46. package/dist/bundle-core/four-meme/sign-context-helpers.d.ts +2 -0
  47. package/dist/bundle-core/four-meme/sign-context-helpers.js +2 -0
  48. package/dist/bundle-core/four-meme/swap-buy-first.d.ts +8 -0
  49. package/dist/bundle-core/four-meme/swap-buy-first.js +493 -0
  50. package/dist/bundle-core/four-meme/swap-hop-helpers.d.ts +6 -0
  51. package/dist/bundle-core/four-meme/swap-hop-helpers.js +63 -0
  52. package/dist/bundle-core/four-meme/swap-internal.d.ts +3 -0
  53. package/dist/bundle-core/four-meme/swap-internal.js +18 -0
  54. package/dist/bundle-core/four-meme/swap-sign-helpers.d.ts +27 -0
  55. package/dist/bundle-core/four-meme/swap-sign-helpers.js +105 -0
  56. package/dist/bundle-core/four-meme/swap.d.ts +17 -0
  57. package/dist/bundle-core/four-meme/swap.js +505 -0
  58. package/dist/bundle-core/four-meme/types/buy-first.d.ts +50 -0
  59. package/dist/bundle-core/four-meme/types/buy-first.js +1 -0
  60. package/dist/bundle-core/four-meme/types/core-flow.d.ts +63 -0
  61. package/dist/bundle-core/four-meme/types/core-flow.js +1 -0
  62. package/dist/bundle-core/four-meme/types/index.d.ts +600 -0
  63. package/dist/bundle-core/four-meme/types/index.js +1 -0
  64. package/dist/bundle-core/four-meme/types/swap-internal.d.ts +19 -0
  65. package/dist/bundle-core/four-meme/types/swap-internal.js +1 -0
  66. package/dist/bundle-core/four-meme/types.d.ts +1 -0
  67. package/dist/bundle-core/four-meme/types.js +1 -0
  68. package/dist/bundle-core/four-meme/utils-disperse.d.ts +7 -0
  69. package/dist/bundle-core/four-meme/utils-disperse.js +396 -0
  70. package/dist/bundle-core/four-meme/utils-pairwise.d.ts +8 -0
  71. package/dist/bundle-core/four-meme/utils-pairwise.js +328 -0
  72. package/dist/bundle-core/four-meme/utils-sweep.d.ts +8 -0
  73. package/dist/bundle-core/four-meme/utils-sweep.js +744 -0
  74. package/dist/bundle-core/index.d.ts +8 -0
  75. package/dist/bundle-core/index.js +8 -0
  76. package/dist/bundle-core/internal.d.ts +21 -0
  77. package/dist/bundle-core/internal.js +182 -0
  78. package/dist/bundle-core/sign-context-helpers.d.ts +25 -0
  79. package/dist/bundle-core/sign-context-helpers.js +67 -0
  80. package/dist/bundle-core/submit.d.ts +293 -0
  81. package/dist/bundle-core/submit.js +727 -0
  82. package/dist/bundle-core/types/index.d.ts +8 -0
  83. package/dist/bundle-core/types/index.js +1 -0
  84. package/dist/bundle-core/types.d.ts +1 -0
  85. package/dist/bundle-core/types.js +1 -0
  86. package/dist/chains/bsc/four/approve-tokenmanager.d.ts +1 -26
  87. package/dist/chains/bsc/four/approve-tokenmanager.js +1 -113
  88. package/dist/chains/bsc/four/config.d.ts +5 -67
  89. package/dist/chains/bsc/four/config.js +2 -114
  90. package/dist/chains/bsc/four/core.d.ts +1 -4
  91. package/dist/chains/bsc/four/core.js +1 -592
  92. package/dist/chains/bsc/four/index.d.ts +6 -6
  93. package/dist/chains/bsc/four/index.js +6 -6
  94. package/dist/chains/bsc/four/internal.d.ts +2 -46
  95. package/dist/chains/bsc/four/internal.js +2 -239
  96. package/dist/chains/bsc/four/pancake-proxy.d.ts +1 -28
  97. package/dist/chains/bsc/four/pancake-proxy.js +1 -687
  98. package/dist/chains/bsc/four/private.d.ts +1 -27
  99. package/dist/chains/bsc/four/private.js +1 -477
  100. package/dist/chains/bsc/four/submit.d.ts +2 -315
  101. package/dist/chains/bsc/four/submit.js +2 -752
  102. package/dist/chains/bsc/four/swap-buy-first.d.ts +2 -55
  103. package/dist/chains/bsc/four/swap-buy-first.js +2 -507
  104. package/dist/chains/bsc/four/swap-internal.d.ts +1 -3
  105. package/dist/chains/bsc/four/swap-internal.js +1 -18
  106. package/dist/chains/bsc/four/swap.d.ts +2 -144
  107. package/dist/chains/bsc/four/swap.js +2 -766
  108. package/dist/chains/bsc/four/types.d.ts +1 -476
  109. package/dist/chains/bsc/four/utils-disperse.d.ts +1 -0
  110. package/dist/chains/bsc/four/utils-disperse.js +1 -0
  111. package/dist/chains/bsc/four/utils-pairwise.d.ts +1 -0
  112. package/dist/chains/bsc/four/utils-pairwise.js +1 -0
  113. package/dist/chains/bsc/four/utils-sweep.d.ts +1 -0
  114. package/dist/chains/bsc/four/utils-sweep.js +1 -0
  115. package/dist/chains/bsc/four/utils.d.ts +5 -18
  116. package/dist/chains/bsc/four/utils.js +5 -1552
  117. package/dist/chains/bsc/iro.d.ts +5 -0
  118. package/dist/chains/bsc/iro.js +4 -0
  119. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +159 -0
  120. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +117 -0
  121. package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -91
  122. package/dist/chains/bsc/pancake/bundle-buy-first.js +97 -212
  123. package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +241 -0
  124. package/dist/chains/bsc/pancake/bundle-swap-helpers.js +565 -0
  125. package/dist/chains/bsc/pancake/bundle-swap.d.ts +1 -79
  126. package/dist/chains/bsc/pancake/bundle-swap.js +114 -726
  127. package/dist/chains/bsc/pancake/index.d.ts +4 -2
  128. package/dist/chains/bsc/pancake/index.js +1 -3
  129. package/dist/chains/bsc/platforms/iro/factory.d.ts +2 -2
  130. package/dist/chains/bsc/platforms/iro/factory.js +3 -1
  131. package/dist/chains/bsc/platforms/iro/index.d.ts +5 -5
  132. package/dist/chains/bsc/platforms/iro/index.js +3 -3
  133. package/dist/chains/bsc/platforms/iro/pool.js +31 -10
  134. package/dist/chains/bsc/platforms/iro/token.js +4 -1
  135. package/dist/chains/eni/batch-router/bundle-approve.js +4 -3
  136. package/dist/chains/eni/batch-router/transfer.js +55 -25
  137. package/dist/chains/eni/batch-router/utils.js +32 -6
  138. package/dist/chains/eni/bundler/sign.js +5 -6
  139. package/dist/chains/eni/bundler/submit.js +1 -4
  140. package/dist/chains/eni/constants.js +1 -1
  141. package/dist/chains/eni/flat-aliases.d.ts +10 -0
  142. package/dist/chains/eni/flat-aliases.js +8 -0
  143. package/dist/chains/eni/index.d.ts +2 -1
  144. package/dist/chains/eni/index.js +1 -0
  145. package/dist/chains/eni/platforms/daoaas/create.js +2 -2
  146. package/dist/chains/eni/platforms/daoaas/index.d.ts +3 -3
  147. package/dist/chains/eni/platforms/daoaas/index.js +3 -3
  148. package/dist/chains/eni/platforms/daoaas/meta.js +9 -6
  149. package/dist/chains/eni/platforms/daoaas/portal-direct.js +28 -44
  150. package/dist/chains/eni/platforms/daoaas/portal.js +10 -6
  151. package/dist/chains/eni/platforms/dswap/liquidity.js +58 -26
  152. package/dist/chains/eni/platforms/fair-launch/index.d.ts +2 -2
  153. package/dist/chains/eni/platforms/fair-launch/index.js +1 -1
  154. package/dist/chains/eni/platforms/fair-launch/launcher.js +87 -46
  155. package/dist/chains/eni/platforms/fair-launch/pool.js +4 -1
  156. package/dist/chains/eni/platforms/fair-launch/presets.js +2 -2
  157. package/dist/chains/eni/platforms/iro/factory.d.ts +2 -2
  158. package/dist/chains/eni/platforms/iro/factory.js +3 -1
  159. package/dist/chains/eni/platforms/iro/index.d.ts +6 -6
  160. package/dist/chains/eni/platforms/iro/index.js +4 -4
  161. package/dist/chains/eni/platforms/iro/pool.js +90 -26
  162. package/dist/chains/eni/platforms/iro/token.js +107 -31
  163. package/dist/chains/eni/platforms/iro/whitelist.js +6 -18
  164. package/dist/chains/eni/submit.d.ts +43 -0
  165. package/dist/chains/eni/submit.js +286 -0
  166. package/dist/chains/index.d.ts +13 -0
  167. package/dist/chains/index.js +13 -0
  168. package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +2 -26
  169. package/dist/chains/xlayer/eip7702/bundle-approve.js +11 -21
  170. package/dist/chains/xlayer/eip7702/bundle-buy.d.ts +2 -6
  171. package/dist/chains/xlayer/eip7702/bundle-buy.js +13 -51
  172. package/dist/chains/xlayer/eip7702/bundle-create.js +93 -59
  173. package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +2 -6
  174. package/dist/chains/xlayer/eip7702/bundle-sell.js +29 -111
  175. package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +3 -65
  176. package/dist/chains/xlayer/eip7702/bundle-swap.js +51 -245
  177. package/dist/chains/xlayer/eip7702/constants.d.ts +1 -16
  178. package/dist/chains/xlayer/eip7702/constants.js +3 -21
  179. package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +13 -0
  180. package/dist/chains/xlayer/eip7702/flat-aliases.js +10 -0
  181. package/dist/chains/xlayer/eip7702/index.d.ts +28 -46
  182. package/dist/chains/xlayer/eip7702/index.js +28 -81
  183. package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.d.ts +79 -0
  184. package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.js +1 -0
  185. package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +2 -203
  186. package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +63 -307
  187. package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +26 -0
  188. package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +57 -0
  189. package/dist/chains/xlayer/eip7702/types.d.ts +88 -0
  190. package/dist/chains/xlayer/eip7702/utils.d.ts +0 -3
  191. package/dist/chains/xlayer/eip7702/utils.js +23 -28
  192. package/dist/chains/xlayer/eip7702/volume-helpers.d.ts +148 -0
  193. package/dist/chains/xlayer/eip7702/volume-helpers.js +48 -0
  194. package/dist/chains/xlayer/eip7702/volume.d.ts +6 -184
  195. package/dist/chains/xlayer/eip7702/volume.js +89 -164
  196. package/dist/chains/xlayer/eoa/constants.js +1 -1
  197. package/dist/chains/xlayer/eoa/dex-helpers.js +5 -5
  198. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +126 -0
  199. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +228 -0
  200. package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +1 -95
  201. package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +66 -299
  202. package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
  203. package/dist/chains/xlayer/eoa/eoa-wash-volume.js +18 -23
  204. package/dist/chains/xlayer/eoa/index.d.ts +10 -6
  205. package/dist/chains/xlayer/eoa/index.js +8 -23
  206. package/dist/chains/xlayer/eoa/portal-ops.js +7 -2
  207. package/dist/chains/xlayer/eoa/router-manager.js +3 -3
  208. package/dist/chains/xlayer/eoa/types.d.ts +2 -2
  209. package/dist/chains/xlayer/eoa/types.js +1 -3
  210. package/dist/chains/xlayer/index.d.ts +3 -2
  211. package/dist/chains/xlayer/index.js +4 -7
  212. package/dist/contracts/helper3.d.ts +20 -5
  213. package/dist/contracts/helper3.js +56 -20
  214. package/dist/contracts/tm-bundle-helpers.d.ts +88 -0
  215. package/dist/contracts/tm-bundle-helpers.js +72 -0
  216. package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +1 -26
  217. package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +1 -113
  218. package/dist/contracts/tm-bundle-merkle/config.d.ts +5 -67
  219. package/dist/contracts/tm-bundle-merkle/config.js +2 -114
  220. package/dist/contracts/tm-bundle-merkle/core.d.ts +1 -4
  221. package/dist/contracts/tm-bundle-merkle/core.js +1 -591
  222. package/dist/contracts/tm-bundle-merkle/index.d.ts +5 -5
  223. package/dist/contracts/tm-bundle-merkle/index.js +5 -5
  224. package/dist/contracts/tm-bundle-merkle/internal.d.ts +2 -46
  225. package/dist/contracts/tm-bundle-merkle/internal.js +2 -238
  226. package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +1 -28
  227. package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +1 -686
  228. package/dist/contracts/tm-bundle-merkle/private.d.ts +1 -27
  229. package/dist/contracts/tm-bundle-merkle/private.js +1 -476
  230. package/dist/contracts/tm-bundle-merkle/submit.d.ts +3 -314
  231. package/dist/contracts/tm-bundle-merkle/submit.js +3 -928
  232. package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +2 -55
  233. package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +2 -506
  234. package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +1 -3
  235. package/dist/contracts/tm-bundle-merkle/swap-internal.js +1 -18
  236. package/dist/contracts/tm-bundle-merkle/swap.d.ts +2 -144
  237. package/dist/contracts/tm-bundle-merkle/swap.js +2 -764
  238. package/dist/contracts/tm-bundle-merkle/types.d.ts +1 -476
  239. package/dist/contracts/tm-bundle-merkle/utils-disperse.d.ts +1 -0
  240. package/dist/contracts/tm-bundle-merkle/utils-disperse.js +1 -0
  241. package/dist/contracts/tm-bundle-merkle/utils-pairwise.d.ts +1 -0
  242. package/dist/contracts/tm-bundle-merkle/utils-pairwise.js +1 -0
  243. package/dist/contracts/tm-bundle-merkle/utils-sweep.d.ts +1 -0
  244. package/dist/contracts/tm-bundle-merkle/utils-sweep.js +1 -0
  245. package/dist/contracts/tm-bundle-merkle/utils.d.ts +6 -18
  246. package/dist/contracts/tm-bundle-merkle/utils.js +6 -1501
  247. package/dist/contracts/tm-bundle.d.ts +3 -51
  248. package/dist/contracts/tm-bundle.js +108 -177
  249. package/dist/contracts/tm.d.ts +3 -2
  250. package/dist/contracts/tm.js +37 -32
  251. package/dist/contracts/tm1.js +9 -4
  252. package/dist/contracts/tm2.js +9 -4
  253. package/dist/dex/direct-router-helpers.d.ts +264 -0
  254. package/dist/dex/direct-router-helpers.js +539 -0
  255. package/dist/dex/direct-router.d.ts +3 -125
  256. package/dist/dex/direct-router.js +237 -666
  257. package/dist/dex/types.d.ts +81 -0
  258. package/dist/dex/types.js +1 -0
  259. package/dist/exports/root-bundle-and-tooling.d.ts +27 -0
  260. package/dist/exports/root-bundle-and-tooling.js +30 -0
  261. package/dist/exports/root-eni-and-bsc-iro.d.ts +26 -0
  262. package/dist/exports/root-eni-and-bsc-iro.js +66 -0
  263. package/dist/exports/root-foundations.d.ts +35 -0
  264. package/dist/exports/root-foundations.js +70 -0
  265. package/dist/exports/root-swap-dex-and-xlayer.d.ts +30 -0
  266. package/dist/exports/root-swap-dex-and-xlayer.js +78 -0
  267. package/dist/flap/index.d.ts +10 -0
  268. package/dist/flap/index.js +8 -0
  269. package/dist/flows/create.d.ts +2 -1
  270. package/dist/flows/create.js +6 -6
  271. package/dist/flows/index.d.ts +1 -0
  272. package/dist/flows/index.js +1 -0
  273. package/dist/index.d.ts +20 -85
  274. package/dist/index.js +20 -215
  275. package/dist/merkle/index.d.ts +12 -0
  276. package/dist/merkle/index.js +11 -0
  277. package/dist/shared/abis/common.d.ts +2 -83
  278. package/dist/shared/abis/common.js +2 -252
  279. package/dist/shared/abis/index.d.ts +5 -6
  280. package/dist/shared/abis/index.js +5 -7
  281. package/dist/shared/clients/blockrazor.js +39 -25
  282. package/dist/shared/clients/club48.d.ts +2 -2
  283. package/dist/shared/clients/club48.js +34 -29
  284. package/dist/shared/clients/emitservice.js +2 -0
  285. package/dist/shared/clients/four.d.ts +21 -6
  286. package/dist/shared/clients/four.js +29 -24
  287. package/dist/shared/clients/index.d.ts +8 -0
  288. package/dist/shared/clients/index.js +8 -0
  289. package/dist/shared/clients/merkle.js +27 -34
  290. package/dist/shared/constants/addresses.d.ts +1 -1
  291. package/dist/shared/constants/addresses.js +11 -2
  292. package/dist/shared/constants/chains.d.ts +1 -1
  293. package/dist/shared/constants/chains.js +1 -1
  294. package/dist/shared/constants/gas.d.ts +1 -1
  295. package/dist/shared/constants/gas.js +2 -6
  296. package/dist/shared/constants/index.d.ts +3 -0
  297. package/dist/shared/constants/index.js +1 -0
  298. package/dist/shared/constants/quote.d.ts +30 -0
  299. package/dist/shared/constants/quote.js +37 -0
  300. package/dist/shared/flap/abi.js +1 -1
  301. package/dist/shared/flap/constants.d.ts +1 -2
  302. package/dist/shared/flap/constants.js +2 -3
  303. package/dist/shared/flap/curve.js +3 -0
  304. package/dist/shared/flap/errors.d.ts +1 -4
  305. package/dist/shared/flap/errors.js +20 -1
  306. package/dist/shared/flap/index.d.ts +5 -4
  307. package/dist/shared/flap/index.js +5 -4
  308. package/dist/shared/flap/meta.d.ts +22 -18
  309. package/dist/shared/flap/meta.js +12 -17
  310. package/dist/shared/flap/permit.js +5 -2
  311. package/dist/shared/flap/pinata.d.ts +22 -6
  312. package/dist/shared/flap/pinata.js +21 -26
  313. package/dist/shared/flap/portal-bundle-merkle/config.d.ts +3 -72
  314. package/dist/shared/flap/portal-bundle-merkle/config.js +4 -124
  315. package/dist/shared/flap/portal-bundle-merkle/core-helpers.d.ts +32 -0
  316. package/dist/shared/flap/portal-bundle-merkle/core-helpers.js +83 -0
  317. package/dist/shared/flap/portal-bundle-merkle/core.d.ts +0 -4
  318. package/dist/shared/flap/portal-bundle-merkle/core.js +96 -277
  319. package/dist/shared/flap/portal-bundle-merkle/create-to-dex.d.ts +7 -2
  320. package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +107 -206
  321. package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +100 -92
  322. package/dist/shared/flap/portal-bundle-merkle/index.d.ts +11 -7
  323. package/dist/shared/flap/portal-bundle-merkle/index.js +4 -7
  324. package/dist/shared/flap/portal-bundle-merkle/pancake-proxy.js +71 -68
  325. package/dist/shared/flap/portal-bundle-merkle/private.js +61 -114
  326. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +125 -0
  327. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.js +113 -0
  328. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.d.ts +1 -64
  329. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.js +66 -247
  330. package/dist/shared/flap/portal-bundle-merkle/swap-helpers.d.ts +149 -0
  331. package/dist/shared/flap/portal-bundle-merkle/swap-helpers.js +259 -0
  332. package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +2 -71
  333. package/dist/shared/flap/portal-bundle-merkle/swap.js +103 -410
  334. package/dist/shared/flap/portal-bundle-merkle/types.d.ts +88 -9
  335. package/dist/shared/flap/portal-bundle-merkle/utils.d.ts +1 -80
  336. package/dist/shared/flap/portal-bundle-merkle/utils.js +145 -265
  337. package/dist/shared/flap/portal-bundle.js +55 -56
  338. package/dist/shared/flap/portal-create-token.d.ts +80 -0
  339. package/dist/shared/flap/portal-create-token.js +257 -0
  340. package/dist/shared/flap/portal.d.ts +14 -3
  341. package/dist/shared/flap/portal.js +50 -25
  342. package/dist/shared/flap/vanity.d.ts +1 -5
  343. package/dist/shared/flap/vanity.js +6 -17
  344. package/dist/shared/flap/vault.d.ts +17 -124
  345. package/dist/shared/flap/vault.js +67 -148
  346. package/dist/shared/foundation/dex/v3-path.d.ts +6 -0
  347. package/dist/shared/foundation/dex/v3-path.js +35 -0
  348. package/dist/shared/foundation/gas/bundle-gas.d.ts +49 -0
  349. package/dist/shared/foundation/gas/bundle-gas.js +93 -0
  350. package/dist/shared/foundation/gas/profit-hop.d.ts +20 -0
  351. package/dist/shared/foundation/gas/profit-hop.js +72 -0
  352. package/dist/shared/foundation/index.d.ts +13 -0
  353. package/dist/shared/foundation/index.js +12 -0
  354. package/dist/shared/foundation/nonce/nonce-manager.d.ts +17 -0
  355. package/dist/shared/foundation/nonce/nonce-manager.js +183 -0
  356. package/dist/shared/foundation/normalize-unknown.d.ts +9 -0
  357. package/dist/shared/foundation/normalize-unknown.js +29 -0
  358. package/dist/shared/foundation/sdk-logger.d.ts +13 -0
  359. package/dist/shared/foundation/sdk-logger.js +12 -0
  360. package/dist/shared/foundation/tx/build-request.d.ts +17 -0
  361. package/dist/shared/foundation/tx/build-request.js +25 -0
  362. package/dist/shared/foundation/tx/sign-batch.d.ts +5 -0
  363. package/dist/shared/foundation/tx/sign-batch.js +26 -0
  364. package/dist/shared/foundation/tx/wallet-sign-patch.d.ts +1 -0
  365. package/dist/shared/foundation/tx/wallet-sign-patch.js +18 -0
  366. package/dist/shared/foundation/types/airdrop-sweep.d.ts +79 -0
  367. package/dist/shared/foundation/types/airdrop-sweep.js +1 -0
  368. package/dist/shared/foundation/types/erc20.d.ts +65 -0
  369. package/dist/shared/foundation/types/erc20.js +1 -0
  370. package/dist/shared/foundation/types/holders-maker.d.ts +64 -0
  371. package/dist/shared/foundation/types/holders-maker.js +1 -0
  372. package/dist/shared/foundation/types/index.d.ts +7 -0
  373. package/dist/shared/foundation/types/index.js +1 -0
  374. package/dist/shared/foundation/types/lp-inspect.d.ts +102 -0
  375. package/dist/shared/foundation/types/lp-inspect.js +1 -0
  376. package/dist/shared/foundation/types/multicall.d.ts +5 -0
  377. package/dist/shared/foundation/types/multicall.js +1 -0
  378. package/dist/shared/foundation/types/private-sale.d.ts +35 -0
  379. package/dist/shared/foundation/types/private-sale.js +1 -0
  380. package/dist/shared/foundation/types/quote-helpers.d.ts +17 -0
  381. package/dist/shared/foundation/types/quote-helpers.js +1 -0
  382. package/dist/shared/four/tax-token.d.ts +1 -1
  383. package/dist/shared/four/tax-token.js +27 -7
  384. package/dist/shared/index.d.ts +6 -0
  385. package/dist/shared/index.js +4 -0
  386. package/dist/types/errors.d.ts +27 -0
  387. package/dist/types/errors.js +34 -0
  388. package/dist/utils/airdrop-sweep.d.ts +4 -76
  389. package/dist/utils/airdrop-sweep.js +42 -55
  390. package/dist/utils/bundle-helpers.d.ts +9 -243
  391. package/dist/utils/bundle-helpers.js +10 -584
  392. package/dist/utils/constants.d.ts +5 -61
  393. package/dist/utils/constants.js +5 -80
  394. package/dist/utils/contract-factory.d.ts +2 -4
  395. package/dist/utils/contract-factory.js +25 -18
  396. package/dist/utils/erc20.d.ts +7 -89
  397. package/dist/utils/erc20.js +94 -125
  398. package/dist/utils/errors.d.ts +12 -1
  399. package/dist/utils/errors.js +60 -1
  400. package/dist/utils/holders-maker/addresses.d.ts +12 -0
  401. package/dist/utils/holders-maker/addresses.js +15 -0
  402. package/dist/utils/holders-maker/buy-tx.d.ts +44 -0
  403. package/dist/utils/holders-maker/buy-tx.js +278 -0
  404. package/dist/utils/holders-maker/constants.d.ts +6 -0
  405. package/dist/utils/holders-maker/constants.js +7 -0
  406. package/dist/utils/holders-maker/disperse.d.ts +18 -0
  407. package/dist/utils/holders-maker/disperse.js +90 -0
  408. package/dist/utils/holders-maker/routing.d.ts +4 -0
  409. package/dist/utils/holders-maker/routing.js +45 -0
  410. package/dist/utils/holders-maker/transfer-tx.d.ts +4 -0
  411. package/dist/utils/holders-maker/transfer-tx.js +67 -0
  412. package/dist/utils/holders-maker-helpers.d.ts +9 -0
  413. package/dist/utils/holders-maker-helpers.js +9 -0
  414. package/dist/utils/holders-maker.d.ts +2 -138
  415. package/dist/utils/holders-maker.js +26 -661
  416. package/dist/utils/hop-chains.d.ts +35 -0
  417. package/dist/utils/hop-chains.js +215 -0
  418. package/dist/utils/lp-inspect-helpers.d.ts +9 -0
  419. package/dist/utils/lp-inspect-helpers.js +109 -0
  420. package/dist/utils/lp-inspect.d.ts +2 -112
  421. package/dist/utils/lp-inspect.js +73 -223
  422. package/dist/utils/mpcExclusive.d.ts +2 -5
  423. package/dist/utils/mpcExclusive.js +4 -3
  424. package/dist/utils/private-sale.d.ts +2 -58
  425. package/dist/utils/private-sale.js +4 -15
  426. package/dist/utils/provider-factory.d.ts +4 -0
  427. package/dist/utils/provider-factory.js +10 -0
  428. package/dist/utils/quote-helpers.d.ts +4 -45
  429. package/dist/utils/quote-helpers.js +17 -74
  430. package/dist/utils/stealth-transfer.d.ts +2 -28
  431. package/dist/utils/stealth-transfer.js +31 -15
  432. package/dist/utils/swap-helpers.d.ts +2 -15
  433. package/dist/utils/swap-helpers.js +6 -11
  434. package/dist/utils/types/airdrop-sweep.d.ts +1 -0
  435. package/dist/utils/types/airdrop-sweep.js +1 -0
  436. package/dist/utils/types/contract-factory.d.ts +1 -0
  437. package/dist/utils/types/contract-factory.js +1 -0
  438. package/dist/utils/types/erc20.d.ts +1 -0
  439. package/dist/utils/types/erc20.js +1 -0
  440. package/dist/utils/types/errors.d.ts +1 -0
  441. package/dist/utils/types/errors.js +1 -0
  442. package/dist/utils/types/holders-maker.d.ts +1 -0
  443. package/dist/utils/types/holders-maker.js +1 -0
  444. package/dist/utils/types/hop-chains.d.ts +8 -0
  445. package/dist/utils/types/hop-chains.js +1 -0
  446. package/dist/utils/types/index.d.ts +13 -0
  447. package/dist/utils/types/index.js +1 -0
  448. package/dist/utils/types/lp-inspect.d.ts +1 -0
  449. package/dist/utils/types/lp-inspect.js +1 -0
  450. package/dist/utils/types/mpc-exclusive.d.ts +5 -0
  451. package/dist/utils/types/mpc-exclusive.js +1 -0
  452. package/dist/utils/types/private-sale.d.ts +1 -0
  453. package/dist/utils/types/private-sale.js +1 -0
  454. package/dist/utils/types/quote-helpers.d.ts +1 -0
  455. package/dist/utils/types/quote-helpers.js +1 -0
  456. package/dist/utils/types/stealth-transfer.d.ts +44 -0
  457. package/dist/utils/types/stealth-transfer.js +1 -0
  458. package/dist/utils/types/wallet.d.ts +25 -0
  459. package/dist/utils/types/wallet.js +1 -0
  460. package/dist/utils/wallet.d.ts +2 -25
  461. package/dist/utils/wallet.js +13 -10
  462. package/dist/vanity/index.d.ts +5 -0
  463. package/dist/vanity/index.js +5 -0
  464. package/package.json +160 -4
  465. package/src/abis/contracts/TaxToken.json +969 -0
  466. package/src/abis/contracts/TokenManager.json +836 -0
  467. package/src/abis/contracts/TokenManager2.json +136 -0
  468. package/src/abis/contracts/TokenManagerHelper3.json +993 -0
  469. package/dist/shared/abis/TaxToken.json +0 -105
  470. package/dist/shared/abis/TokenManager2.json +0 -60
  471. /package/dist/{shared/abis → abis/contracts}/TokenManager.json +0 -0
  472. /package/dist/{shared/abis → abis/contracts}/TokenManagerHelper3.json +0 -0
@@ -1,640 +1,16 @@
1
1
  /**
2
- * ============================================================================
3
- * 刷持有人(Holders Maker)
4
- * ============================================================================
5
- * 一键完成:生成钱包 → 分发资金 → 批量买入(同一个 bundle 完成)
6
- * 支持原生代币(BNB/MON)和 ERC20 代币(USDT/USDC)作为购买资金
2
+ * holders-maker - 主函数
7
3
  */
8
- import { ethers, JsonRpcProvider, Wallet, Contract } from 'ethers';
4
+ import { ethers, JsonRpcProvider, Wallet } from 'ethers';
9
5
  import { generateWallets } from './wallet.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
- */
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';
635
11
  export async function holdersMaker(params) {
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=直接转账)
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=直接转账)
638
14
  } = config;
639
15
  // ENI 链强制使用 EIP-1559 (type 2)
640
16
  const txType = chain === 'ENI' ? 2 : configTxType;
@@ -646,7 +22,7 @@ export async function holdersMaker(params) {
646
22
  signedTransactions: [],
647
23
  batchResults: [],
648
24
  successBatchCount: 0,
649
- totalBatchCount: 0
25
+ totalBatchCount: 0,
650
26
  };
651
27
  const isERC20Mode = baseToken !== 'native';
652
28
  // ✅ ERC20 模式只支持 v2/v3 外盘
@@ -663,20 +39,16 @@ export async function holdersMaker(params) {
663
39
  // ✅ 根据分发多跳数动态计算每批最大钱包数
664
40
  // XLayer 强制禁用分发多跳(ENI 已支持前端分层广播)
665
41
  const effectiveDisperseHopCount = chain === 'XLAYER' ? 0 : disperseHopCount;
666
- const maxWalletsPerBatch = config.maxWalletsPerBatch ||
667
- calculateMaxWalletsPerBatch(isERC20Mode, effectiveDisperseHopCount, chain);
668
- console.log(`[HoldersMaker] chain: ${chain}, 分发多跳数: ${effectiveDisperseHopCount}, 每批最大钱包数: ${maxWalletsPerBatch}`);
42
+ const maxWalletsPerBatch = config.maxWalletsPerBatch || calculateMaxWalletsPerBatch(isERC20Mode, effectiveDisperseHopCount, chain);
669
43
  try {
670
44
  // 1. 初始化
671
45
  const provider = new JsonRpcProvider(rpcUrl);
672
46
  const chainId = configChainId || Number((await provider.getNetwork()).chainId);
673
47
  const payer = new Wallet(payerPrivateKey, provider);
674
48
  const nonceManager = new NonceManager(provider);
675
- console.log(`[HoldersMaker] 开始刷持有人: chain=${chain}, chainId=${chainId}, holdersCount=${holdersCount}, baseToken=${baseToken}`);
676
49
  // 2. 生成新钱包
677
50
  const newWallets = generateWallets(holdersCount);
678
51
  result.newWallets = newWallets;
679
- console.log(`[HoldersMaker] 生成 ${newWallets.length} 个新钱包`);
680
52
  // 3. 计算金额
681
53
  const gasPriceWei = BigInt(Math.floor(gasPriceGwei * 1e9));
682
54
  const gasPrice = await getOptimizedGasPrice(provider, { minGasPrice: gasPriceWei });
@@ -695,24 +67,20 @@ export async function holdersMaker(params) {
695
67
  transferNativePerWallet = gasWithBuffer;
696
68
  // 获取 ERC20 地址
697
69
  erc20TokenAddress = getBaseTokenAddress(baseToken, chain, baseTokenAddress);
698
- console.log(`[HoldersMaker] ERC20 模式: ${baseToken} (${erc20TokenAddress})`);
699
- console.log(`[HoldersMaker] 每个钱包分发: ${ethers.formatEther(transferNativePerWallet)} BNB (Gas) + ${buyAmountPerHolder} ${baseToken.toUpperCase()}`);
700
70
  }
701
71
  else {
702
72
  // 原生代币模式
703
73
  buyAmountWei = ethers.parseEther(buyAmountPerHolder);
704
74
  transferNativePerWallet = buyAmountWei + gasWithBuffer;
705
- console.log(`[HoldersMaker] 每个钱包分发: ${ethers.formatEther(transferNativePerWallet)} BNB (买入 ${buyAmountPerHolder} + Gas ${ethers.formatEther(gasWithBuffer)})`);
706
75
  }
707
76
  // 4. 分批处理
708
77
  const walletBatches = chunkArray(newWallets, maxWalletsPerBatch);
709
78
  result.totalBatchCount = walletBatches.length;
710
- console.log(`[HoldersMaker] 分 ${walletBatches.length} 批处理,每批最多 ${maxWalletsPerBatch} 个钱包`);
711
79
  // 5. 计算利润(基于原生代币)
712
80
  const totalBuyAmountForProfit = isERC20Mode
713
81
  ? ethers.parseEther(buyAmountPerHolder) * BigInt(holdersCount) // 按等值 BNB 计算
714
82
  : buyAmountWei * BigInt(holdersCount);
715
- const profitRateBps = PROFIT_CONFIG.RATE_BPS;
83
+ const profitRateBps = getSharedProfitRateBps('normal');
716
84
  const totalProfit = (totalBuyAmountForProfit * BigInt(profitRateBps)) / 10000n;
717
85
  let profitPerBatch = totalProfit / BigInt(walletBatches.length);
718
86
  if (profitPerBatch > 0n && chain === 'ENI') {
@@ -720,7 +88,7 @@ export async function holdersMaker(params) {
720
88
  }
721
89
  // 利润计算完成
722
90
  // 6. 生成分发多跳路径(如果启用)
723
- let allDisperseHopWallets = [];
91
+ const allDisperseHopWallets = [];
724
92
  const disperseHopPaths = generateDisperseHopPaths(newWallets, effectiveDisperseHopCount, provider);
725
93
  if (effectiveDisperseHopCount > 0) {
726
94
  // 收集所有中间钱包信息用于导出
@@ -728,13 +96,11 @@ export async function holdersMaker(params) {
728
96
  allDisperseHopWallets.push(...path.hopWalletsInfo);
729
97
  }
730
98
  result.disperseHopWallets = allDisperseHopWallets;
731
- console.log(`[HoldersMaker] 分发多跳: ${effectiveDisperseHopCount} 跳,共生成 ${allDisperseHopWallets.length} 个中间钱包`);
732
99
  }
733
100
  // ✅ XLayer/ENI 特殊处理:不需要贿赂和利润多跳
734
101
  const isSimpleChain = chain === 'XLAYER' || chain === 'ENI';
735
102
  const needBribe = !isSimpleChain;
736
103
  const needProfitHop = !isSimpleChain;
737
- const effectiveProfitHopCount = needProfitHop ? PROFIT_HOP_COUNT : 0;
738
104
  // 7. 并行生成所有批次的签名
739
105
  const batchPromises = walletBatches.map(async (batch, batchIdx) => {
740
106
  try {
@@ -745,7 +111,7 @@ export async function holdersMaker(params) {
745
111
  // BSC 原生模式(有多跳H): 贿赂 1 + 分发首跳 N + 利润 (PROFIT_HOP_COUNT + 1)
746
112
  // BSC ERC20模式(无多跳): 贿赂 1 + 分发BNB N + 分发ERC20 N + 利润 (PROFIT_HOP_COUNT + 1)
747
113
  const bribeCount = needBribe ? 1 : 0;
748
- const profitCount = needProfitHop ? (PROFIT_HOP_COUNT + 1) : 1; // XLayer 只有 1 笔利润转账
114
+ const profitCount = needProfitHop ? PROFIT_HOP_COUNT + 1 : 1; // XLayer 只有 1 笔利润转账
749
115
  const payerNonceCount = isERC20Mode
750
116
  ? bribeCount + batch.length * 2 + profitCount
751
117
  : bribeCount + batch.length + profitCount;
@@ -762,8 +128,7 @@ export async function holdersMaker(params) {
762
128
  // (2) 分发原生代币(支持多跳)
763
129
  for (let i = 0; i < batch.length; i++) {
764
130
  const path = batchPaths[i];
765
- const { signedTxs: hopTxs } = await buildDisperseHopChainNative(payer, path, transferNativePerWallet, gasPrice, chainId, txType, payerNonces[payerNonceIdx++], isERC20Mode // ✅ ERC20 模式下,中间钱包需要预留 ERC20 转账 gas
766
- );
131
+ const { signedTxs: hopTxs } = await buildDisperseHopChainNative(payer, path, transferNativePerWallet, gasPrice, chainId, txType, payerNonces[payerNonceIdx++], isERC20Mode);
767
132
  signedTxs.push(...hopTxs);
768
133
  }
769
134
  // (3) ERC20 模式:分发 ERC20 代币(支持多跳)
@@ -844,7 +209,7 @@ export async function holdersMaker(params) {
844
209
  gasPrice,
845
210
  chainId,
846
211
  txType,
847
- startNonce: payerNonces[payerNonceIdx]
212
+ startNonce: payerNonces[payerNonceIdx],
848
213
  });
849
214
  signedTxs.push(...profitHopResult.signedTransactions);
850
215
  profitHopWallets = profitHopResult.hopWallets;
@@ -860,15 +225,15 @@ export async function holdersMaker(params) {
860
225
  success: true,
861
226
  signedTransactions: signedTxs,
862
227
  walletCount: batch.length,
863
- profitHopWallets // ✅ 返回利润多跳钱包
228
+ profitHopWallets, // ✅ 返回利润多跳钱包
864
229
  };
865
230
  }
866
231
  catch (error) {
867
232
  return {
868
233
  batchIndex: batchIdx,
869
234
  success: false,
870
- error: error.message,
871
- walletCount: batch.length
235
+ error: getErrorMessageFromUnknown(error),
236
+ walletCount: batch.length,
872
237
  };
873
238
  }
874
239
  });
@@ -890,7 +255,7 @@ export async function holdersMaker(params) {
890
255
  signedTransactions: res.signedTransactions,
891
256
  error: res.error,
892
257
  walletCount: res.walletCount,
893
- disperseHopCount: effectiveDisperseHopCount // ✅ 添加分发多跳数
258
+ disperseHopCount: effectiveDisperseHopCount, // ✅ 添加分发多跳数
894
259
  });
895
260
  }
896
261
  // ✅ 添加利润多跳钱包到结果
@@ -900,11 +265,11 @@ export async function holdersMaker(params) {
900
265
  // ✅ 添加分发多跳数到结果
901
266
  result.disperseHopCount = effectiveDisperseHopCount;
902
267
  result.success = result.successBatchCount > 0;
903
- console.log(`[HoldersMaker] 完成: ${result.successBatchCount}/${result.totalBatchCount} 批成功`);
904
268
  }
905
269
  catch (error) {
906
- result.error = error.message;
907
- console.error(`[HoldersMaker] 整体失败:`, error.message);
270
+ const msg = getErrorMessageFromUnknown(error);
271
+ result.error = msg;
272
+ console.error(`[HoldersMaker] 整体失败:`, msg);
908
273
  }
909
274
  return result;
910
275
  }
@@ -912,7 +277,7 @@ export async function holdersMaker(params) {
912
277
  * 获取刷持有人预估费用
913
278
  */
914
279
  export function estimateHoldersMakerCost(params) {
915
- const { holdersCount, buyAmountPerHolder, baseToken = 'native', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI } = params;
280
+ const { holdersCount, buyAmountPerHolder, baseToken = 'native', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI, } = params;
916
281
  const isERC20Mode = baseToken !== 'native';
917
282
  const gasMultiplier = isERC20Mode ? 2 : 1; // ERC20 模式需要授权+购买
918
283
  const gasFeePerWallet = (gasLimit * gasPriceGwei * gasMultiplier) / 1e9;
@@ -929,7 +294,7 @@ export function estimateHoldersMakerCost(params) {
929
294
  totalNativeCost: totalNativeCost.toFixed(6),
930
295
  totalERC20Cost: totalERC20Cost.toFixed(6),
931
296
  gasEstimate: (gasWithBuffer * holdersCount).toFixed(6),
932
- batchCount
297
+ batchCount,
933
298
  };
934
299
  }
935
300
  else {
@@ -939,7 +304,7 @@ export function estimateHoldersMakerCost(params) {
939
304
  return {
940
305
  totalNativeCost: totalNativeCost.toFixed(6),
941
306
  gasEstimate: (gasWithBuffer * holdersCount).toFixed(6),
942
- batchCount
307
+ batchCount,
943
308
  };
944
309
  }
945
310
  }