four-flap-meme-sdk 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (467) 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.js +1 -3
  36. package/dist/chains/bsc/platforms/iro/index.d.ts +5 -5
  37. package/dist/chains/bsc/platforms/iro/index.js +3 -3
  38. package/dist/chains/bsc/platforms/iro/pool.js +10 -31
  39. package/dist/chains/bsc/platforms/iro/token.js +1 -4
  40. package/dist/chains/eni/batch-router/bundle-approve.js +3 -4
  41. package/dist/chains/eni/batch-router/transfer.js +25 -55
  42. package/dist/chains/eni/batch-router/utils.js +6 -32
  43. package/dist/chains/eni/bundler/sign.js +4 -4
  44. package/dist/chains/eni/bundler/submit.js +4 -1
  45. package/dist/chains/eni/constants.js +1 -1
  46. package/dist/chains/eni/index.d.ts +1 -2
  47. package/dist/chains/eni/index.js +0 -1
  48. package/dist/chains/eni/platforms/daoaas/create.js +2 -2
  49. package/dist/chains/eni/platforms/daoaas/index.d.ts +3 -3
  50. package/dist/chains/eni/platforms/daoaas/index.js +3 -3
  51. package/dist/chains/eni/platforms/daoaas/meta.js +4 -8
  52. package/dist/chains/eni/platforms/daoaas/portal-direct.js +44 -28
  53. package/dist/chains/eni/platforms/daoaas/portal.js +6 -10
  54. package/dist/chains/eni/platforms/dswap/liquidity.js +26 -58
  55. package/dist/chains/eni/platforms/fair-launch/index.d.ts +2 -2
  56. package/dist/chains/eni/platforms/fair-launch/index.js +1 -1
  57. package/dist/chains/eni/platforms/fair-launch/launcher.js +46 -87
  58. package/dist/chains/eni/platforms/fair-launch/pool.js +1 -4
  59. package/dist/chains/eni/platforms/fair-launch/presets.js +2 -2
  60. package/dist/chains/eni/platforms/iro/factory.js +1 -3
  61. package/dist/chains/eni/platforms/iro/index.d.ts +6 -6
  62. package/dist/chains/eni/platforms/iro/index.js +4 -4
  63. package/dist/chains/eni/platforms/iro/pool.js +26 -90
  64. package/dist/chains/eni/platforms/iro/token.js +31 -107
  65. package/dist/chains/eni/platforms/iro/whitelist.js +18 -6
  66. package/dist/chains/index.d.ts +0 -13
  67. package/dist/chains/index.js +0 -13
  68. package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +26 -2
  69. package/dist/chains/xlayer/eip7702/bundle-approve.js +21 -11
  70. package/dist/chains/xlayer/eip7702/bundle-buy.d.ts +6 -2
  71. package/dist/chains/xlayer/eip7702/bundle-buy.js +51 -13
  72. package/dist/chains/xlayer/eip7702/bundle-create.js +59 -93
  73. package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +6 -2
  74. package/dist/chains/xlayer/eip7702/bundle-sell.js +97 -26
  75. package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +65 -3
  76. package/dist/chains/xlayer/eip7702/bundle-swap.js +245 -51
  77. package/dist/chains/xlayer/eip7702/constants.d.ts +16 -1
  78. package/dist/chains/xlayer/eip7702/constants.js +21 -3
  79. package/dist/chains/xlayer/eip7702/index.d.ts +46 -28
  80. package/dist/chains/xlayer/eip7702/index.js +81 -28
  81. package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +203 -2
  82. package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +301 -58
  83. package/dist/chains/xlayer/eip7702/types.d.ts +0 -88
  84. package/dist/chains/xlayer/eip7702/utils.d.ts +3 -0
  85. package/dist/chains/xlayer/eip7702/utils.js +28 -23
  86. package/dist/chains/xlayer/eip7702/volume.d.ts +184 -6
  87. package/dist/chains/xlayer/eip7702/volume.js +158 -83
  88. package/dist/chains/xlayer/eoa/constants.js +1 -1
  89. package/dist/chains/xlayer/eoa/dex-helpers.js +5 -5
  90. package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +95 -1
  91. package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +299 -66
  92. package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
  93. package/dist/chains/xlayer/eoa/eoa-wash-volume.js +23 -18
  94. package/dist/chains/xlayer/eoa/index.d.ts +6 -10
  95. package/dist/chains/xlayer/eoa/index.js +23 -8
  96. package/dist/chains/xlayer/eoa/portal-ops.js +2 -7
  97. package/dist/chains/xlayer/eoa/router-manager.js +3 -3
  98. package/dist/chains/xlayer/eoa/types.d.ts +2 -2
  99. package/dist/chains/xlayer/eoa/types.js +3 -1
  100. package/dist/chains/xlayer/index.d.ts +2 -3
  101. package/dist/chains/xlayer/index.js +7 -4
  102. package/dist/contracts/helper3.d.ts +5 -20
  103. package/dist/contracts/helper3.js +20 -56
  104. package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +26 -1
  105. package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +113 -1
  106. package/dist/contracts/tm-bundle-merkle/config.d.ts +67 -5
  107. package/dist/contracts/tm-bundle-merkle/config.js +114 -2
  108. package/dist/contracts/tm-bundle-merkle/core.d.ts +4 -1
  109. package/dist/contracts/tm-bundle-merkle/core.js +591 -1
  110. package/dist/contracts/tm-bundle-merkle/index.d.ts +5 -5
  111. package/dist/contracts/tm-bundle-merkle/index.js +5 -5
  112. package/dist/contracts/tm-bundle-merkle/internal.d.ts +46 -2
  113. package/dist/contracts/tm-bundle-merkle/internal.js +238 -2
  114. package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +28 -1
  115. package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +686 -1
  116. package/dist/contracts/tm-bundle-merkle/private.d.ts +27 -1
  117. package/dist/contracts/tm-bundle-merkle/private.js +476 -1
  118. package/dist/contracts/tm-bundle-merkle/submit.d.ts +314 -3
  119. package/dist/contracts/tm-bundle-merkle/submit.js +928 -3
  120. package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +55 -2
  121. package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +506 -2
  122. package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +3 -1
  123. package/dist/contracts/tm-bundle-merkle/swap-internal.js +18 -1
  124. package/dist/contracts/tm-bundle-merkle/swap.d.ts +144 -2
  125. package/dist/contracts/tm-bundle-merkle/swap.js +764 -2
  126. package/dist/contracts/tm-bundle-merkle/types.d.ts +476 -1
  127. package/dist/contracts/tm-bundle-merkle/utils.d.ts +18 -6
  128. package/dist/contracts/tm-bundle-merkle/utils.js +1501 -6
  129. package/dist/contracts/tm-bundle.d.ts +51 -3
  130. package/dist/contracts/tm-bundle.js +177 -108
  131. package/dist/contracts/tm.d.ts +2 -3
  132. package/dist/contracts/tm.js +32 -37
  133. package/dist/contracts/tm1.js +4 -9
  134. package/dist/contracts/tm2.js +4 -9
  135. package/dist/dex/direct-router.d.ts +125 -3
  136. package/dist/dex/direct-router.js +666 -237
  137. package/dist/flows/create.d.ts +1 -2
  138. package/dist/flows/create.js +6 -6
  139. package/dist/index.d.ts +85 -20
  140. package/dist/index.js +215 -20
  141. package/dist/shared/abis/TaxToken.json +105 -0
  142. package/dist/shared/abis/TokenManager2.json +60 -0
  143. package/dist/shared/abis/common.d.ts +83 -2
  144. package/dist/shared/abis/common.js +252 -2
  145. package/dist/shared/abis/index.d.ts +6 -5
  146. package/dist/shared/abis/index.js +7 -5
  147. package/dist/shared/clients/blockrazor.js +25 -39
  148. package/dist/shared/clients/club48.d.ts +2 -2
  149. package/dist/shared/clients/club48.js +29 -34
  150. package/dist/shared/clients/emitservice.js +0 -2
  151. package/dist/shared/clients/four.d.ts +5 -5
  152. package/dist/shared/clients/four.js +17 -21
  153. package/dist/shared/clients/merkle.js +34 -27
  154. package/dist/shared/constants/addresses.d.ts +1 -1
  155. package/dist/shared/constants/addresses.js +2 -11
  156. package/dist/shared/constants/chains.d.ts +1 -1
  157. package/dist/shared/constants/chains.js +1 -1
  158. package/dist/shared/constants/gas.d.ts +1 -1
  159. package/dist/shared/constants/gas.js +6 -2
  160. package/dist/shared/constants/index.d.ts +0 -3
  161. package/dist/shared/constants/index.js +0 -1
  162. package/dist/shared/flap/abi.js +1 -1
  163. package/dist/shared/flap/constants.d.ts +2 -1
  164. package/dist/shared/flap/constants.js +3 -2
  165. package/dist/shared/flap/curve.js +0 -3
  166. package/dist/shared/flap/errors.d.ts +4 -1
  167. package/dist/shared/flap/errors.js +1 -20
  168. package/dist/shared/flap/index.d.ts +3 -3
  169. package/dist/shared/flap/index.js +3 -3
  170. package/dist/shared/flap/meta.d.ts +18 -16
  171. package/dist/shared/flap/meta.js +17 -12
  172. package/dist/shared/flap/permit.js +2 -5
  173. package/dist/shared/flap/pinata.d.ts +4 -11
  174. package/dist/shared/flap/pinata.js +16 -21
  175. package/dist/shared/flap/portal-bundle-merkle/config.d.ts +72 -3
  176. package/dist/shared/flap/portal-bundle-merkle/config.js +124 -4
  177. package/dist/shared/flap/portal-bundle-merkle/core.d.ts +4 -0
  178. package/dist/shared/flap/portal-bundle-merkle/core.js +172 -92
  179. package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +99 -106
  180. package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +92 -100
  181. package/dist/shared/flap/portal-bundle-merkle/index.d.ts +7 -11
  182. package/dist/shared/flap/portal-bundle-merkle/index.js +7 -4
  183. package/dist/shared/flap/portal-bundle-merkle/pancake-proxy.js +68 -71
  184. package/dist/shared/flap/portal-bundle-merkle/private.js +114 -61
  185. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.d.ts +64 -1
  186. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.js +247 -66
  187. package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +71 -2
  188. package/dist/shared/flap/portal-bundle-merkle/swap.js +410 -103
  189. package/dist/shared/flap/portal-bundle-merkle/types.d.ts +7 -73
  190. package/dist/shared/flap/portal-bundle-merkle/utils.d.ts +80 -1
  191. package/dist/shared/flap/portal-bundle-merkle/utils.js +265 -145
  192. package/dist/shared/flap/portal-bundle.js +56 -55
  193. package/dist/shared/flap/portal.d.ts +3 -1
  194. package/dist/shared/flap/portal.js +25 -32
  195. package/dist/shared/flap/vanity.d.ts +5 -1
  196. package/dist/shared/flap/vanity.js +17 -6
  197. package/dist/shared/flap/vault.d.ts +124 -17
  198. package/dist/shared/flap/vault.js +148 -67
  199. package/dist/shared/four/tax-token.d.ts +1 -1
  200. package/dist/shared/four/tax-token.js +7 -27
  201. package/dist/shared/index.d.ts +0 -6
  202. package/dist/shared/index.js +0 -4
  203. package/dist/utils/airdrop-sweep.d.ts +76 -4
  204. package/dist/utils/airdrop-sweep.js +54 -40
  205. package/dist/utils/bundle-helpers.d.ts +243 -9
  206. package/dist/utils/bundle-helpers.js +584 -10
  207. package/dist/utils/constants.d.ts +61 -5
  208. package/dist/utils/constants.js +80 -5
  209. package/dist/utils/contract-factory.d.ts +4 -2
  210. package/dist/utils/contract-factory.js +18 -25
  211. package/dist/utils/erc20.d.ts +89 -7
  212. package/dist/utils/erc20.js +125 -94
  213. package/dist/utils/errors.d.ts +1 -12
  214. package/dist/utils/errors.js +1 -60
  215. package/dist/utils/holders-maker.d.ts +138 -2
  216. package/dist/utils/holders-maker.js +661 -26
  217. package/dist/utils/lp-inspect.d.ts +112 -2
  218. package/dist/utils/lp-inspect.js +223 -73
  219. package/dist/utils/mpcExclusive.d.ts +5 -2
  220. package/dist/utils/mpcExclusive.js +3 -4
  221. package/dist/utils/private-sale.d.ts +58 -2
  222. package/dist/utils/private-sale.js +15 -4
  223. package/dist/utils/provider-factory.d.ts +0 -4
  224. package/dist/utils/provider-factory.js +0 -10
  225. package/dist/utils/quote-helpers.d.ts +45 -4
  226. package/dist/utils/quote-helpers.js +74 -17
  227. package/dist/utils/stealth-transfer.d.ts +28 -2
  228. package/dist/utils/stealth-transfer.js +15 -31
  229. package/dist/utils/swap-helpers.d.ts +15 -2
  230. package/dist/utils/swap-helpers.js +10 -5
  231. package/dist/utils/wallet.d.ts +25 -2
  232. package/dist/utils/wallet.js +8 -9
  233. package/package.json +4 -159
  234. package/dist/__tests__/subpath-exports.test.d.ts +0 -1
  235. package/dist/__tests__/subpath-exports.test.js +0 -64
  236. package/dist/abis/common.d.ts +0 -85
  237. package/dist/abis/common.js +0 -260
  238. package/dist/abis/contracts/TaxToken.json +0 -969
  239. package/dist/abis/contracts/TokenManager2.json +0 -136
  240. package/dist/abis/contracts/index.d.ts +0 -5
  241. package/dist/abis/contracts/index.js +0 -5
  242. package/dist/abis/flap/index.d.ts +0 -3
  243. package/dist/abis/flap/index.js +0 -3
  244. package/dist/abis/flap/portal-events.d.ts +0 -6
  245. package/dist/abis/flap/portal-events.js +0 -17
  246. package/dist/abis/flap/portal.d.ts +0 -6
  247. package/dist/abis/flap/portal.js +0 -37
  248. package/dist/abis/flap/vault.d.ts +0 -171
  249. package/dist/abis/flap/vault.js +0 -91
  250. package/dist/abis/index.d.ts +0 -8
  251. package/dist/abis/index.js +0 -11
  252. package/dist/bundle-core/__tests__/config-helpers.test.d.ts +0 -1
  253. package/dist/bundle-core/__tests__/config-helpers.test.js +0 -28
  254. package/dist/bundle-core/__tests__/facade-parity.test.d.ts +0 -1
  255. package/dist/bundle-core/__tests__/facade-parity.test.js +0 -33
  256. package/dist/bundle-core/__tests__/sign-context-helpers.test.d.ts +0 -1
  257. package/dist/bundle-core/__tests__/sign-context-helpers.test.js +0 -60
  258. package/dist/bundle-core/__tests__/sign-fixture.test.d.ts +0 -1
  259. package/dist/bundle-core/__tests__/sign-fixture.test.js +0 -220
  260. package/dist/bundle-core/__tests__/sign-fixtures.d.ts +0 -10
  261. package/dist/bundle-core/__tests__/sign-fixtures.js +0 -16
  262. package/dist/bundle-core/config-helpers.d.ts +0 -36
  263. package/dist/bundle-core/config-helpers.js +0 -57
  264. package/dist/bundle-core/errors.d.ts +0 -50
  265. package/dist/bundle-core/errors.js +0 -34
  266. package/dist/bundle-core/four-meme/approve-tokenmanager.d.ts +0 -7
  267. package/dist/bundle-core/four-meme/approve-tokenmanager.js +0 -99
  268. package/dist/bundle-core/four-meme/core-helpers.d.ts +0 -8
  269. package/dist/bundle-core/four-meme/core-helpers.js +0 -40
  270. package/dist/bundle-core/four-meme/core.d.ts +0 -4
  271. package/dist/bundle-core/four-meme/core.js +0 -515
  272. package/dist/bundle-core/four-meme/pancake-proxy.d.ts +0 -28
  273. package/dist/bundle-core/four-meme/pancake-proxy.js +0 -679
  274. package/dist/bundle-core/four-meme/private.d.ts +0 -27
  275. package/dist/bundle-core/four-meme/private.js +0 -465
  276. package/dist/bundle-core/four-meme/sign-context-helpers.d.ts +0 -2
  277. package/dist/bundle-core/four-meme/sign-context-helpers.js +0 -2
  278. package/dist/bundle-core/four-meme/swap-buy-first.d.ts +0 -8
  279. package/dist/bundle-core/four-meme/swap-buy-first.js +0 -493
  280. package/dist/bundle-core/four-meme/swap-hop-helpers.d.ts +0 -6
  281. package/dist/bundle-core/four-meme/swap-hop-helpers.js +0 -63
  282. package/dist/bundle-core/four-meme/swap-internal.d.ts +0 -3
  283. package/dist/bundle-core/four-meme/swap-internal.js +0 -18
  284. package/dist/bundle-core/four-meme/swap-sign-helpers.d.ts +0 -27
  285. package/dist/bundle-core/four-meme/swap-sign-helpers.js +0 -105
  286. package/dist/bundle-core/four-meme/swap.d.ts +0 -17
  287. package/dist/bundle-core/four-meme/swap.js +0 -505
  288. package/dist/bundle-core/four-meme/types/buy-first.d.ts +0 -50
  289. package/dist/bundle-core/four-meme/types/buy-first.js +0 -1
  290. package/dist/bundle-core/four-meme/types/core-flow.d.ts +0 -63
  291. package/dist/bundle-core/four-meme/types/core-flow.js +0 -1
  292. package/dist/bundle-core/four-meme/types/index.d.ts +0 -600
  293. package/dist/bundle-core/four-meme/types/index.js +0 -1
  294. package/dist/bundle-core/four-meme/types/swap-internal.d.ts +0 -19
  295. package/dist/bundle-core/four-meme/types/swap-internal.js +0 -1
  296. package/dist/bundle-core/four-meme/types.d.ts +0 -1
  297. package/dist/bundle-core/four-meme/types.js +0 -1
  298. package/dist/bundle-core/four-meme/utils-disperse.d.ts +0 -7
  299. package/dist/bundle-core/four-meme/utils-disperse.js +0 -396
  300. package/dist/bundle-core/four-meme/utils-pairwise.d.ts +0 -8
  301. package/dist/bundle-core/four-meme/utils-pairwise.js +0 -328
  302. package/dist/bundle-core/four-meme/utils-sweep.d.ts +0 -8
  303. package/dist/bundle-core/four-meme/utils-sweep.js +0 -744
  304. package/dist/bundle-core/index.d.ts +0 -8
  305. package/dist/bundle-core/index.js +0 -8
  306. package/dist/bundle-core/internal.d.ts +0 -21
  307. package/dist/bundle-core/internal.js +0 -182
  308. package/dist/bundle-core/sign-context-helpers.d.ts +0 -25
  309. package/dist/bundle-core/sign-context-helpers.js +0 -67
  310. package/dist/bundle-core/submit.d.ts +0 -293
  311. package/dist/bundle-core/submit.js +0 -727
  312. package/dist/bundle-core/types/index.d.ts +0 -8
  313. package/dist/bundle-core/types/index.js +0 -1
  314. package/dist/bundle-core/types.d.ts +0 -1
  315. package/dist/bundle-core/types.js +0 -1
  316. package/dist/chains/bsc/four/utils-disperse.d.ts +0 -1
  317. package/dist/chains/bsc/four/utils-disperse.js +0 -1
  318. package/dist/chains/bsc/four/utils-pairwise.d.ts +0 -1
  319. package/dist/chains/bsc/four/utils-pairwise.js +0 -1
  320. package/dist/chains/bsc/four/utils-sweep.d.ts +0 -1
  321. package/dist/chains/bsc/four/utils-sweep.js +0 -1
  322. package/dist/chains/bsc/iro.d.ts +0 -5
  323. package/dist/chains/bsc/iro.js +0 -4
  324. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +0 -159
  325. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +0 -117
  326. package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +0 -241
  327. package/dist/chains/bsc/pancake/bundle-swap-helpers.js +0 -565
  328. package/dist/chains/eni/flat-aliases.d.ts +0 -10
  329. package/dist/chains/eni/flat-aliases.js +0 -8
  330. package/dist/chains/eni/submit.d.ts +0 -43
  331. package/dist/chains/eni/submit.js +0 -286
  332. package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +0 -13
  333. package/dist/chains/xlayer/eip7702/flat-aliases.js +0 -10
  334. package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.d.ts +0 -79
  335. package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.js +0 -1
  336. package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +0 -26
  337. package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +0 -57
  338. package/dist/chains/xlayer/eip7702/volume-helpers.d.ts +0 -148
  339. package/dist/chains/xlayer/eip7702/volume-helpers.js +0 -48
  340. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +0 -126
  341. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +0 -228
  342. package/dist/contracts/tm-bundle-helpers.d.ts +0 -88
  343. package/dist/contracts/tm-bundle-helpers.js +0 -72
  344. package/dist/contracts/tm-bundle-merkle/utils-disperse.d.ts +0 -1
  345. package/dist/contracts/tm-bundle-merkle/utils-disperse.js +0 -1
  346. package/dist/contracts/tm-bundle-merkle/utils-pairwise.d.ts +0 -1
  347. package/dist/contracts/tm-bundle-merkle/utils-pairwise.js +0 -1
  348. package/dist/contracts/tm-bundle-merkle/utils-sweep.d.ts +0 -1
  349. package/dist/contracts/tm-bundle-merkle/utils-sweep.js +0 -1
  350. package/dist/dex/direct-router-helpers.d.ts +0 -264
  351. package/dist/dex/direct-router-helpers.js +0 -539
  352. package/dist/dex/types.d.ts +0 -81
  353. package/dist/dex/types.js +0 -1
  354. package/dist/exports/root-bundle-and-tooling.d.ts +0 -27
  355. package/dist/exports/root-bundle-and-tooling.js +0 -30
  356. package/dist/exports/root-eni-and-bsc-iro.d.ts +0 -26
  357. package/dist/exports/root-eni-and-bsc-iro.js +0 -66
  358. package/dist/exports/root-foundations.d.ts +0 -35
  359. package/dist/exports/root-foundations.js +0 -70
  360. package/dist/exports/root-swap-dex-and-xlayer.d.ts +0 -30
  361. package/dist/exports/root-swap-dex-and-xlayer.js +0 -78
  362. package/dist/flap/index.d.ts +0 -10
  363. package/dist/flap/index.js +0 -8
  364. package/dist/flows/index.d.ts +0 -1
  365. package/dist/flows/index.js +0 -1
  366. package/dist/merkle/index.d.ts +0 -12
  367. package/dist/merkle/index.js +0 -11
  368. package/dist/shared/clients/index.d.ts +0 -8
  369. package/dist/shared/clients/index.js +0 -8
  370. package/dist/shared/constants/quote.d.ts +0 -30
  371. package/dist/shared/constants/quote.js +0 -37
  372. package/dist/shared/flap/portal-bundle-merkle/core-helpers.d.ts +0 -32
  373. package/dist/shared/flap/portal-bundle-merkle/core-helpers.js +0 -83
  374. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +0 -125
  375. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.js +0 -113
  376. package/dist/shared/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -149
  377. package/dist/shared/flap/portal-bundle-merkle/swap-helpers.js +0 -259
  378. package/dist/shared/foundation/dex/v3-path.d.ts +0 -6
  379. package/dist/shared/foundation/dex/v3-path.js +0 -35
  380. package/dist/shared/foundation/gas/bundle-gas.d.ts +0 -39
  381. package/dist/shared/foundation/gas/bundle-gas.js +0 -93
  382. package/dist/shared/foundation/gas/profit-hop.d.ts +0 -20
  383. package/dist/shared/foundation/gas/profit-hop.js +0 -72
  384. package/dist/shared/foundation/index.d.ts +0 -13
  385. package/dist/shared/foundation/index.js +0 -12
  386. package/dist/shared/foundation/nonce/nonce-manager.d.ts +0 -17
  387. package/dist/shared/foundation/nonce/nonce-manager.js +0 -180
  388. package/dist/shared/foundation/normalize-unknown.d.ts +0 -9
  389. package/dist/shared/foundation/normalize-unknown.js +0 -29
  390. package/dist/shared/foundation/sdk-logger.d.ts +0 -13
  391. package/dist/shared/foundation/sdk-logger.js +0 -12
  392. package/dist/shared/foundation/tx/build-request.d.ts +0 -17
  393. package/dist/shared/foundation/tx/build-request.js +0 -25
  394. package/dist/shared/foundation/tx/sign-batch.d.ts +0 -5
  395. package/dist/shared/foundation/tx/sign-batch.js +0 -26
  396. package/dist/shared/foundation/tx/wallet-sign-patch.d.ts +0 -1
  397. package/dist/shared/foundation/tx/wallet-sign-patch.js +0 -18
  398. package/dist/shared/foundation/types/airdrop-sweep.d.ts +0 -79
  399. package/dist/shared/foundation/types/airdrop-sweep.js +0 -1
  400. package/dist/shared/foundation/types/erc20.d.ts +0 -65
  401. package/dist/shared/foundation/types/erc20.js +0 -1
  402. package/dist/shared/foundation/types/holders-maker.d.ts +0 -64
  403. package/dist/shared/foundation/types/holders-maker.js +0 -1
  404. package/dist/shared/foundation/types/index.d.ts +0 -7
  405. package/dist/shared/foundation/types/index.js +0 -1
  406. package/dist/shared/foundation/types/lp-inspect.d.ts +0 -102
  407. package/dist/shared/foundation/types/lp-inspect.js +0 -1
  408. package/dist/shared/foundation/types/multicall.d.ts +0 -5
  409. package/dist/shared/foundation/types/multicall.js +0 -1
  410. package/dist/shared/foundation/types/private-sale.d.ts +0 -35
  411. package/dist/shared/foundation/types/private-sale.js +0 -1
  412. package/dist/shared/foundation/types/quote-helpers.d.ts +0 -17
  413. package/dist/shared/foundation/types/quote-helpers.js +0 -1
  414. package/dist/types/errors.d.ts +0 -27
  415. package/dist/types/errors.js +0 -34
  416. package/dist/utils/holders-maker/addresses.d.ts +0 -12
  417. package/dist/utils/holders-maker/addresses.js +0 -15
  418. package/dist/utils/holders-maker/buy-tx.d.ts +0 -44
  419. package/dist/utils/holders-maker/buy-tx.js +0 -278
  420. package/dist/utils/holders-maker/constants.d.ts +0 -6
  421. package/dist/utils/holders-maker/constants.js +0 -7
  422. package/dist/utils/holders-maker/disperse.d.ts +0 -18
  423. package/dist/utils/holders-maker/disperse.js +0 -90
  424. package/dist/utils/holders-maker/routing.d.ts +0 -4
  425. package/dist/utils/holders-maker/routing.js +0 -45
  426. package/dist/utils/holders-maker/transfer-tx.d.ts +0 -4
  427. package/dist/utils/holders-maker/transfer-tx.js +0 -67
  428. package/dist/utils/holders-maker-helpers.d.ts +0 -9
  429. package/dist/utils/holders-maker-helpers.js +0 -9
  430. package/dist/utils/hop-chains.d.ts +0 -35
  431. package/dist/utils/hop-chains.js +0 -215
  432. package/dist/utils/lp-inspect-helpers.d.ts +0 -9
  433. package/dist/utils/lp-inspect-helpers.js +0 -109
  434. package/dist/utils/types/airdrop-sweep.d.ts +0 -1
  435. package/dist/utils/types/airdrop-sweep.js +0 -1
  436. package/dist/utils/types/contract-factory.d.ts +0 -1
  437. package/dist/utils/types/contract-factory.js +0 -1
  438. package/dist/utils/types/erc20.d.ts +0 -1
  439. package/dist/utils/types/erc20.js +0 -1
  440. package/dist/utils/types/errors.d.ts +0 -1
  441. package/dist/utils/types/errors.js +0 -1
  442. package/dist/utils/types/holders-maker.d.ts +0 -1
  443. package/dist/utils/types/holders-maker.js +0 -1
  444. package/dist/utils/types/hop-chains.d.ts +0 -8
  445. package/dist/utils/types/hop-chains.js +0 -1
  446. package/dist/utils/types/index.d.ts +0 -13
  447. package/dist/utils/types/index.js +0 -1
  448. package/dist/utils/types/lp-inspect.d.ts +0 -1
  449. package/dist/utils/types/lp-inspect.js +0 -1
  450. package/dist/utils/types/mpc-exclusive.d.ts +0 -5
  451. package/dist/utils/types/mpc-exclusive.js +0 -1
  452. package/dist/utils/types/private-sale.d.ts +0 -1
  453. package/dist/utils/types/private-sale.js +0 -1
  454. package/dist/utils/types/quote-helpers.d.ts +0 -1
  455. package/dist/utils/types/quote-helpers.js +0 -1
  456. package/dist/utils/types/stealth-transfer.d.ts +0 -44
  457. package/dist/utils/types/stealth-transfer.js +0 -1
  458. package/dist/utils/types/wallet.d.ts +0 -25
  459. package/dist/utils/types/wallet.js +0 -1
  460. package/dist/vanity/index.d.ts +0 -5
  461. package/dist/vanity/index.js +0 -5
  462. package/src/abis/contracts/TaxToken.json +0 -969
  463. package/src/abis/contracts/TokenManager.json +0 -836
  464. package/src/abis/contracts/TokenManager2.json +0 -136
  465. package/src/abis/contracts/TokenManagerHelper3.json +0 -993
  466. /package/dist/{abis/contracts → shared/abis}/TokenManager.json +0 -0
  467. /package/dist/{abis/contracts → shared/abis}/TokenManagerHelper3.json +0 -0
@@ -1 +1,592 @@
1
- export { createTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle, batchSellWithBundleMerkle, } from '../../../bundle-core/four-meme/core.js';
1
+ import { ethers, Wallet, Contract, Interface } from 'ethers';
2
+ import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
3
+ import { ADDRESSES, BLOCKRAZOR_BUILDER_EOA, ZERO_ADDRESS } from '../../../utils/constants.js';
4
+ import { GAS_LIMITS, CHAINS } from '../../../shared/constants/index.js';
5
+ import { MULTICALL3_ABI, ERC20_ABI } from '../../../shared/abis/common.js';
6
+ import { FourClient, buildLoginMessage } from '../../../shared/clients/four.js';
7
+ import { getErrorMessage, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount } from './config.js';
8
+ import { trySell } from '../../../contracts/tm.js';
9
+ import Helper3Abi from '../../../shared/abis/TokenManagerHelper3.json' with { type: 'json' };
10
+ // ✅ 常量
11
+ const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
12
+ // ✅ TM2 扩展 ABI(包含创建代币方法和事件)
13
+ import { TM2_ABI as _TM2_ABI } from '../../../shared/abis/common.js';
14
+ const TM2_ABI = [
15
+ ..._TM2_ABI,
16
+ 'function createToken(bytes args, bytes signature) payable',
17
+ 'event TokenCreate(address indexed creator, address indexed token, uint256 timestamp)'
18
+ ];
19
+ const PLATFORM_CREATE_FEE = ethers.parseEther('0.01');
20
+ const CHAIN_ID = CHAINS.BSC.chainId;
21
+ // ✅ 本地 getGasLimit(FourAnyConfig 支持 bigint gasLimit)
22
+ function getGasLimit(config, defaultGas = 800000) {
23
+ if (config.gasLimit !== undefined) {
24
+ return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
25
+ }
26
+ const multiplier = config.gasLimitMultiplier ?? 1.0;
27
+ return BigInt(Math.ceil(defaultGas * multiplier));
28
+ }
29
+ export async function createTokenWithBundleBuyMerkle(params) {
30
+ const { privateKeys, buyAmounts, tokenInfo, config } = params;
31
+ // ⚠️ 限制: 只支持创建者买入,不支持其他钱包
32
+ if (privateKeys.length !== 1) {
33
+ throw new Error('只支持创建者买入,privateKeys 只能有1个元素');
34
+ }
35
+ if (buyAmounts.length !== 1) {
36
+ throw new Error('只支持买入一次,buyAmounts 只能有1个元素');
37
+ }
38
+ const creatorKey = privateKeys[0];
39
+ // ✅ 使用公共 BSC RPC 节点(支持浏览器 CORS)
40
+ // 48.club 的 RPC 不支持浏览器跨域访问,所以使用公共节点进行余额查询和 gas 估算
41
+ const rpcUrl = config.rpcUrl || 'https://bsc-dataseed.binance.org';
42
+ const { provider, chainId } = createChainContext(rpcUrl);
43
+ const devWallet = new Wallet(creatorKey, provider);
44
+ const fourClient = new FourClient({ baseUrl: config.fourApiUrl });
45
+ // 🔍 检查创建者余额
46
+ const creatorBalance = await provider.getBalance(devWallet.address);
47
+ const estimatedB0 = ethers.parseEther(params.b0Amount ?? '0');
48
+ const estimatedPreSale = tokenInfo.preSale ? ethers.parseEther(tokenInfo.preSale) : 0n;
49
+ // 计算总需求:创建费用 + b0Amount + preSale + 买入金额 + gas预估
50
+ const buyAmount = ethers.parseEther(buyAmounts[0]);
51
+ let totalRequired = PLATFORM_CREATE_FEE + estimatedB0 + estimatedPreSale + buyAmount;
52
+ totalRequired += ethers.parseEther('0.01'); // 预留 0.01 BNB 作为 gas
53
+ if (creatorBalance < totalRequired) {
54
+ console.warn(`⚠️ 余额可能不足!当前: ${ethers.formatEther(creatorBalance)} BNB, 需要: ${ethers.formatEther(totalRequired)} BNB`);
55
+ }
56
+ const accessToken = await loginFourClient(devWallet, fourClient);
57
+ const imgUrl = await resolveTokenImage(fourClient, tokenInfo, accessToken);
58
+ // ✅ 兼容:历史调用可能把 Dev 首买金额塞在 buyAmounts[0],而不是 tokenInfo.preSale
59
+ // Four 官方 API/链上 createArg 使用 preSale 表达“创建者预购金额”
60
+ const effectivePreSaleStr = (tokenInfo.preSale && String(tokenInfo.preSale).trim().length > 0 ? String(tokenInfo.preSale) : String(buyAmounts[0] ?? '0'));
61
+ const createResp = await fourClient.createToken(accessToken, {
62
+ name: tokenInfo.name,
63
+ shortName: tokenInfo.symbol,
64
+ desc: tokenInfo.description,
65
+ imgUrl,
66
+ launchTime: Date.now(),
67
+ label: tokenInfo.label || 'Meme',
68
+ webUrl: tokenInfo.webUrl,
69
+ twitterUrl: tokenInfo.twitterUrl,
70
+ telegramUrl: tokenInfo.telegramUrl,
71
+ preSale: effectivePreSaleStr || '0',
72
+ onlyMPC: false,
73
+ // ✅ AntiSniperFeeMode(开盘高税模式)
74
+ ...(tokenInfo.feePlan ? { feePlan: true } : {}),
75
+ // ✅ 税币配置(Tax Token, creatorType=5)
76
+ ...(tokenInfo.tokenTaxInfo ? { tokenTaxInfo: tokenInfo.tokenTaxInfo } : {}),
77
+ lpTradingFee: 0.0025,
78
+ symbol: 'BNB',
79
+ totalSupply: 1000000000,
80
+ raisedAmount: 24,
81
+ saleRate: 0.8,
82
+ reserveRate: 0,
83
+ funGroup: false,
84
+ clickFun: false,
85
+ });
86
+ const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
87
+ const nonceManager = new NonceManager(provider);
88
+ const txType = getTxType(config);
89
+ const signedTxs = [];
90
+ const tmCreateAddr = ADDRESSES.BSC.TokenManagerOriginal;
91
+ // ✅ 单笔交易: 和 Four.meme 官网一样
92
+ // 计算利润
93
+ const extractProfit = shouldExtractProfit(config);
94
+ // ✅ 对 create 流程来说,“买入金额”就是 preSale(创建者预购)
95
+ const originalBuyAmount = ethers.parseEther(effectivePreSaleStr || '0');
96
+ let actualBuyFunds;
97
+ let profitAmount;
98
+ if (extractProfit) {
99
+ const { remaining, profit } = calculateProfit(originalBuyAmount, config);
100
+ actualBuyFunds = remaining;
101
+ profitAmount = profit;
102
+ }
103
+ else {
104
+ actualBuyFunds = originalBuyAmount;
105
+ profitAmount = 0n;
106
+ }
107
+ // ✅ 获取贿赂金额
108
+ const bribeAmount = getBribeAmount(config);
109
+ const needBribeTx = bribeAmount > 0n;
110
+ const b0AmountWei = ethers.parseEther(params.b0Amount ?? '0');
111
+ const preSaleWei = effectivePreSaleStr ? ethers.parseEther(effectivePreSaleStr) : 0n;
112
+ // ✅ 关键修复:
113
+ // createToken 的预购金额由 createArg.preSale 决定;因此这里只需要支付:创建费 + b0Amount + preSale
114
+ // 不要把“其它买入金额”额外塞进 msg.value,否则会被合约退回,造成“看起来没买到”的误解。
115
+ const valueWei = PLATFORM_CREATE_FEE + b0AmountWei + preSaleWei;
116
+ const tmCreate = new ethers.Contract(tmCreateAddr, TM2_ABI, devWallet);
117
+ const createTxUnsigned = await tmCreate.createToken.populateTransaction(createResp.createArg, createResp.signature, { value: valueWei });
118
+ // ✅ 贿赂交易放在首位(由 devWallet 发送)
119
+ let bribeNonce;
120
+ if (needBribeTx) {
121
+ bribeNonce = await nonceManager.getNextNonce(devWallet);
122
+ const bribeTx = await devWallet.signTransaction({
123
+ to: BLOCKRAZOR_BUILDER_EOA,
124
+ value: bribeAmount,
125
+ nonce: bribeNonce,
126
+ gasPrice,
127
+ gasLimit: GAS_LIMITS.BRIBE,
128
+ chainId,
129
+ type: txType
130
+ });
131
+ signedTxs.push(bribeTx);
132
+ }
133
+ const createTxRequest = {
134
+ ...createTxUnsigned,
135
+ from: devWallet.address,
136
+ nonce: await nonceManager.getNextNonce(devWallet),
137
+ gasLimit: getGasLimit(config, 1500000),
138
+ gasPrice,
139
+ chainId,
140
+ type: getTxType(config),
141
+ value: valueWei
142
+ };
143
+ signedTxs.push(await devWallet.signTransaction(createTxRequest));
144
+ // ✅ 利润多跳转账(强制 2 跳中转)
145
+ let profitHopWallets;
146
+ if (extractProfit && profitAmount > 0n) {
147
+ const profitNonce = await nonceManager.getNextNonce(devWallet);
148
+ const profitHopResult = await buildProfitHopTransactions({
149
+ provider,
150
+ payerWallet: devWallet,
151
+ profitAmount,
152
+ profitRecipient: getProfitRecipient(),
153
+ hopCount: PROFIT_HOP_COUNT,
154
+ gasPrice,
155
+ chainId,
156
+ txType,
157
+ startNonce: profitNonce
158
+ });
159
+ signedTxs.push(...profitHopResult.signedTransactions);
160
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
161
+ }
162
+ nonceManager.clearTemp();
163
+ // ⚠️ 只返回签名交易,不提交
164
+ // 构建元数据
165
+ const metadata = extractProfit && profitAmount > 0n ? {
166
+ totalBuyAmount: ethers.formatEther(originalBuyAmount),
167
+ profitAmount: ethers.formatEther(profitAmount),
168
+ profitRecipient: getProfitRecipient(),
169
+ buyerCount: 1
170
+ } : undefined;
171
+ return {
172
+ signedTransactions: signedTxs,
173
+ tokenAddress: ZERO_ADDRESS, // ⚠️ 占位符,实际地址需要等交易确认后从事件解析
174
+ profitHopWallets, // ✅ 返回利润多跳钱包
175
+ metadata
176
+ };
177
+ }
178
+ export async function batchBuyWithBundleMerkle(params) {
179
+ const { privateKeys, buyAmounts, tokenAddress, config } = params;
180
+ if (privateKeys.length === 0 || buyAmounts.length !== privateKeys.length) {
181
+ throw new Error(getErrorMessage('KEY_AMOUNT_MISMATCH'));
182
+ }
183
+ const { provider, chainId } = createChainContext(config.rpcUrl);
184
+ const txType = getTxType(config);
185
+ const buyers = createWallets(privateKeys, provider);
186
+ // ✅ 优化:并行初始化 nonceManager 和获取 gasPrice
187
+ const [nonceManager, gasPrice] = await Promise.all([
188
+ Promise.resolve(new NonceManager(provider)),
189
+ getOptimizedGasPrice(provider, getGasPriceConfig(config))
190
+ ]);
191
+ const buyFlow = await executeBuyFlow({
192
+ wallets: buyers,
193
+ buyAmounts,
194
+ tokenAddress,
195
+ config,
196
+ provider,
197
+ nonceManager,
198
+ contractAddress: ADDRESSES.BSC.TokenManagerOriginal,
199
+ gasPrice,
200
+ chainId,
201
+ profitMode: { type: 'aggregated', payer: buyers[0] },
202
+ txType
203
+ });
204
+ nonceManager.clearTemp();
205
+ return {
206
+ signedTransactions: buyFlow.signedTxs,
207
+ profitHopWallets: buyFlow.profitHopWallets, // ✅ 返回利润多跳钱包
208
+ metadata: buyFlow.metadata
209
+ };
210
+ }
211
+ export async function batchSellWithBundleMerkle(params) {
212
+ const { privateKeys, sellAmounts, tokenAddress, minOutputAmounts, config } = params;
213
+ if (privateKeys.length === 0 || sellAmounts.length !== privateKeys.length) {
214
+ throw new Error(getErrorMessage('SELL_KEY_AMOUNT_MISMATCH'));
215
+ }
216
+ const { provider, chainId } = createChainContext(config.rpcUrl);
217
+ const txType = getTxType(config);
218
+ const sellers = createWallets(privateKeys, provider);
219
+ // ✅ 优化:并行初始化 nonceManager 和获取 gasPrice
220
+ const [nonceManager, gasPrice] = await Promise.all([
221
+ Promise.resolve(new NonceManager(provider)),
222
+ getOptimizedGasPrice(provider, getGasPriceConfig(config))
223
+ ]);
224
+ const sellFlow = await executeSellFlow({
225
+ wallets: sellers,
226
+ sellAmounts,
227
+ tokenAddress,
228
+ minOutputAmounts,
229
+ config,
230
+ provider,
231
+ nonceManager,
232
+ contractAddress: ADDRESSES.BSC.TokenManagerOriginal,
233
+ gasPrice,
234
+ chainId,
235
+ rpcUrl: config.rpcUrl,
236
+ txType
237
+ });
238
+ nonceManager.clearTemp();
239
+ return {
240
+ signedTransactions: sellFlow.signedTxs,
241
+ profitHopWallets: sellFlow.profitHopWallets // ✅ 返回利润多跳钱包
242
+ };
243
+ }
244
+ function createChainContext(rpcUrl) {
245
+ const provider = new ethers.JsonRpcProvider(rpcUrl, {
246
+ chainId: CHAIN_ID,
247
+ name: 'BSC'
248
+ });
249
+ return { provider, chainId: CHAIN_ID };
250
+ }
251
+ function createWallets(privateKeys, provider) {
252
+ return privateKeys.map((key) => new Wallet(key, provider));
253
+ }
254
+ async function loginFourClient(wallet, fourClient) {
255
+ const nonce = await fourClient.generateNonce({
256
+ accountAddress: wallet.address,
257
+ verifyType: 'LOGIN',
258
+ networkCode: 'BSC'
259
+ });
260
+ const loginSignature = await wallet.signMessage(buildLoginMessage(nonce));
261
+ return fourClient.loginDex({
262
+ region: 'WEB',
263
+ langType: 'EN',
264
+ verifyInfo: {
265
+ address: wallet.address,
266
+ networkCode: 'BSC',
267
+ signature: loginSignature,
268
+ verifyType: 'LOGIN'
269
+ },
270
+ walletName: 'MetaMask'
271
+ });
272
+ }
273
+ async function resolveTokenImage(fourClient, tokenInfo, accessToken) {
274
+ if (tokenInfo.imageUrl) {
275
+ return tokenInfo.imageUrl;
276
+ }
277
+ if (tokenInfo.imageFile) {
278
+ return fourClient.uploadImage(accessToken, tokenInfo.imageFile);
279
+ }
280
+ throw new Error(getErrorMessage('IMAGE_REQUIRED'));
281
+ }
282
+ async function executeBuyFlow(options) {
283
+ const { wallets, buyAmounts, tokenAddress, config, provider, nonceManager, contractAddress, gasPrice, chainId, profitMode, txType } = options;
284
+ const extractProfit = shouldExtractProfit(config);
285
+ const analysis = analyzeBuyFunds(buyAmounts, config, extractProfit);
286
+ const finalGasLimit = getGasLimit(config);
287
+ // ✅ 获取贿赂金额
288
+ const bribeAmount = getBribeAmount(config);
289
+ const needBribeTx = bribeAmount > 0n;
290
+ const payer = profitMode.type === 'aggregated' ? (profitMode.payer ?? wallets[0]) : wallets[0];
291
+ // ✅ 贿赂交易放在首位
292
+ const signedTxs = [];
293
+ let bribeNonceOffset = 0;
294
+ if (needBribeTx) {
295
+ const bribeNonce = await nonceManager.getNextNonce(payer);
296
+ const bribeTx = await payer.signTransaction({
297
+ to: BLOCKRAZOR_BUILDER_EOA,
298
+ value: bribeAmount,
299
+ nonce: bribeNonce,
300
+ gasPrice,
301
+ gasLimit: GAS_LIMITS.BRIBE,
302
+ chainId,
303
+ type: txType
304
+ });
305
+ signedTxs.push(bribeTx);
306
+ bribeNonceOffset = 1; // payer 的买入交易 nonce 需要偏移
307
+ }
308
+ // ✅ 优化:并行执行 populateBuyTransactions 和批量获取 nonces(JSON-RPC 批量请求)
309
+ const [unsignedBuys, nonces] = await Promise.all([
310
+ populateBuyTransactions({
311
+ buyers: wallets,
312
+ contractAddress,
313
+ tokenAddress,
314
+ fundsList: analysis.fundsList
315
+ }),
316
+ nonceManager.getNextNoncesForWallets(wallets) // ✅ 批量获取 nonce
317
+ ]);
318
+ // ✅ 调整 payer 的 nonce(如果有贿赂交易,需要偏移)
319
+ const payerIndex = wallets.findIndex(w => w.address.toLowerCase() === payer.address.toLowerCase());
320
+ const adjustedNonces = nonces.map((n, i) => i === payerIndex ? n + bribeNonceOffset : n);
321
+ // ✅ 并行签名所有买入交易
322
+ const signedBuys = await Promise.all(unsignedBuys.map((unsigned, index) => wallets[index].signTransaction({
323
+ ...unsigned,
324
+ from: wallets[index].address,
325
+ nonce: adjustedNonces[index],
326
+ gasLimit: finalGasLimit,
327
+ gasPrice,
328
+ chainId,
329
+ type: txType,
330
+ value: analysis.fundsList[index]
331
+ })));
332
+ signedTxs.push(...signedBuys);
333
+ // ✅ 利润多跳转账(强制 2 跳中转)
334
+ let profitHopWallets;
335
+ if (extractProfit && analysis.totalProfit > 0n && profitMode.type === 'aggregated') {
336
+ const profitNonce = await nonceManager.getNextNonce(payer);
337
+ const profitHopResult = await buildProfitHopTransactions({
338
+ provider,
339
+ payerWallet: payer,
340
+ profitAmount: analysis.totalProfit,
341
+ profitRecipient: getProfitRecipient(),
342
+ hopCount: PROFIT_HOP_COUNT,
343
+ gasPrice,
344
+ chainId,
345
+ txType,
346
+ startNonce: profitNonce
347
+ });
348
+ signedTxs.push(...profitHopResult.signedTransactions);
349
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
350
+ }
351
+ const metadata = buildBuyMetadata(extractProfit, analysis.totalBuyAmount, analysis.totalProfit, wallets.length);
352
+ return { signedTxs, metadata, profitHopWallets }; // ✅ 返回利润多跳钱包
353
+ }
354
+ async function executeSellFlow(options) {
355
+ const { wallets, sellAmounts, tokenAddress, minOutputAmounts, config, provider, nonceManager, contractAddress, gasPrice, chainId, rpcUrl, txType } = options;
356
+ const amountsWei = sellAmounts.map((amount) => ethers.parseUnits(amount, 18));
357
+ const finalGasLimit = getGasLimit(config);
358
+ const extractProfit = shouldExtractProfit(config);
359
+ // ✅ 获取贿赂金额
360
+ const bribeAmount = getBribeAmount(config);
361
+ const needBribeTx = bribeAmount > 0n;
362
+ // ✅ 优化:并行执行 resolveSellOutputs、ensureSellerBalances 和批量获取 nonces(已移除授权检查)
363
+ const [sellOutputs, , nonces] = await Promise.all([
364
+ resolveSellOutputs({
365
+ minOutputAmounts,
366
+ sellers: wallets,
367
+ amountsWei,
368
+ rpcUrl,
369
+ tokenAddress
370
+ }),
371
+ ensureSellerBalances({ provider, tokenAddress, sellers: wallets, amountsWei }),
372
+ nonceManager.getNextNoncesForWallets(wallets) // ✅ 批量获取 nonce(JSON-RPC 批量请求)
373
+ ]);
374
+ // ✅ 找出收益最多的钱包作为 payer(贿赂和利润都由它发送)
375
+ const { totalProfit, payer } = summarizeSellProfits(sellOutputs.quotedOutputs, wallets, config);
376
+ const payerWallet = payer ?? wallets[0];
377
+ const payerIndex = wallets.findIndex(w => w.address.toLowerCase() === payerWallet.address.toLowerCase());
378
+ // ✅ 贿赂交易放在首位
379
+ const signedTxs = [];
380
+ let bribeNonceOffset = 0;
381
+ if (needBribeTx) {
382
+ const bribeNonce = nonces[payerIndex];
383
+ const bribeTx = await payerWallet.signTransaction({
384
+ to: BLOCKRAZOR_BUILDER_EOA,
385
+ value: bribeAmount,
386
+ nonce: bribeNonce,
387
+ gasPrice,
388
+ gasLimit: GAS_LIMITS.BRIBE,
389
+ chainId,
390
+ type: txType
391
+ });
392
+ signedTxs.push(bribeTx);
393
+ bribeNonceOffset = 1;
394
+ }
395
+ // ✅ 调整 payer 的 nonce(如果有贿赂交易,需要偏移)
396
+ const adjustedNonces = nonces.map((n, i) => i === payerIndex ? n + bribeNonceOffset : n);
397
+ // ✅ 构建未签名交易
398
+ const unsignedSells = await populateSellTransactions({
399
+ sellers: wallets,
400
+ contractAddress,
401
+ tokenAddress,
402
+ amountsWei,
403
+ minOuts: sellOutputs.minOuts
404
+ });
405
+ // ✅ 并行签名所有卖出交易
406
+ const signedSells = await Promise.all(unsignedSells.map((unsigned, index) => wallets[index].signTransaction({
407
+ ...unsigned,
408
+ from: wallets[index].address,
409
+ nonce: adjustedNonces[index],
410
+ gasLimit: finalGasLimit,
411
+ gasPrice,
412
+ chainId,
413
+ type: txType
414
+ })));
415
+ signedTxs.push(...signedSells);
416
+ // ✅ 利润多跳转账(强制 2 跳中转)
417
+ const profitHopWallets = await appendAggregatedProfitTransfer({
418
+ extractProfit,
419
+ totalProfit,
420
+ payer: payerWallet,
421
+ nonceManager,
422
+ provider,
423
+ gasPrice,
424
+ chainId,
425
+ txType,
426
+ signedTxs,
427
+ baseNonce: adjustedNonces[payerIndex] + 1 // ✅ 传入基础 nonce
428
+ });
429
+ return { signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
430
+ }
431
+ function analyzeBuyFunds(buyAmounts, config, extractProfit) {
432
+ const fundsList = [];
433
+ const profitList = [];
434
+ let totalProfit = 0n;
435
+ let totalBuyAmount = 0n;
436
+ buyAmounts.forEach((amount) => {
437
+ const originalAmount = ethers.parseEther(amount);
438
+ totalBuyAmount += originalAmount;
439
+ if (extractProfit) {
440
+ const { remaining, profit } = calculateProfit(originalAmount, config);
441
+ fundsList.push(remaining);
442
+ profitList.push(profit);
443
+ totalProfit += profit;
444
+ }
445
+ else {
446
+ fundsList.push(originalAmount);
447
+ profitList.push(0n);
448
+ }
449
+ });
450
+ return { fundsList, profitList, totalProfit, totalBuyAmount };
451
+ }
452
+ async function populateBuyTransactions(params) {
453
+ const { buyers, contractAddress, tokenAddress, fundsList } = params;
454
+ const contracts = buyers.map((wallet) => new ethers.Contract(contractAddress, TM2_ABI, wallet));
455
+ return Promise.all(contracts.map((contract, index) => contract.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyers[index].address, fundsList[index], 0n, { value: fundsList[index] })));
456
+ }
457
+ function buildBuyMetadata(extractProfit, totalBuyAmount, totalProfit, buyerCount) {
458
+ if (!extractProfit || totalBuyAmount <= 0n || totalProfit <= 0n) {
459
+ return undefined;
460
+ }
461
+ return {
462
+ totalBuyAmount: ethers.formatEther(totalBuyAmount),
463
+ profitAmount: ethers.formatEther(totalProfit),
464
+ profitRecipient: getProfitRecipient(),
465
+ buyerCount
466
+ };
467
+ }
468
+ /**
469
+ * ✅ 使用 Multicall3 批量获取卖出报价(单次 RPC)
470
+ * 比 Promise.all 更高效,N 个报价只需 1 次网络请求
471
+ */
472
+ async function resolveSellOutputs(params) {
473
+ const { minOutputAmounts, sellers, amountsWei, rpcUrl, tokenAddress } = params;
474
+ // 如果已提供 minOutputAmounts,直接使用,跳过报价查询
475
+ if (minOutputAmounts && minOutputAmounts.length === sellers.length) {
476
+ const minOuts = minOutputAmounts.map((m) => (typeof m === 'string' ? ethers.parseEther(m) : m));
477
+ const quotedOutputs = minOuts.map((value) => (value * 100n) / 95n);
478
+ return { minOuts, quotedOutputs };
479
+ }
480
+ // 如果只有 1 个,直接调用(避免 multicall 开销)
481
+ if (amountsWei.length === 1) {
482
+ try {
483
+ const result = await trySell('BSC', rpcUrl, tokenAddress, amountsWei[0]);
484
+ const quotedOutputs = [result.funds];
485
+ // ✅ 已移除滑点保护:minOuts 固定为 0
486
+ const minOuts = [0n];
487
+ return { minOuts, quotedOutputs };
488
+ }
489
+ catch {
490
+ return { minOuts: [0n], quotedOutputs: [0n] };
491
+ }
492
+ }
493
+ // ✅ 使用 Multicall3 批量获取报价
494
+ const provider = new ethers.JsonRpcProvider(rpcUrl, { chainId: 56, name: 'BSC' });
495
+ const helper3Address = ADDRESSES.BSC.TokenManagerHelper3;
496
+ const helper3Iface = new Interface(Helper3Abi);
497
+ const multicall = new Contract(MULTICALL3_ADDRESS, MULTICALL3_ABI, provider);
498
+ // 构建批量调用
499
+ const calls = amountsWei.map(amount => ({
500
+ target: helper3Address,
501
+ allowFailure: true, // 允许单个失败
502
+ callData: helper3Iface.encodeFunctionData('trySell', [tokenAddress, amount])
503
+ }));
504
+ try {
505
+ const results = await multicall.aggregate3.staticCall(calls);
506
+ const quotedOutputs = results.map((r) => {
507
+ if (r.success && r.returnData && r.returnData !== '0x') {
508
+ try {
509
+ const decoded = helper3Iface.decodeFunctionResult('trySell', r.returnData);
510
+ // trySell 返回 (tokenManager, quote, funds, fee),我们需要 funds
511
+ return BigInt(decoded.funds);
512
+ }
513
+ catch {
514
+ return 0n;
515
+ }
516
+ }
517
+ return 0n;
518
+ });
519
+ // ✅ 已移除滑点保护:minOuts 固定为 0
520
+ const minOuts = quotedOutputs.map(() => 0n);
521
+ return { minOuts, quotedOutputs };
522
+ }
523
+ catch {
524
+ // Multicall 失败,回退到并行调用
525
+ const quotedOutputs = await Promise.all(amountsWei.map(async (amount) => {
526
+ try {
527
+ const result = await trySell('BSC', rpcUrl, tokenAddress, amount);
528
+ return result.funds;
529
+ }
530
+ catch {
531
+ return 0n;
532
+ }
533
+ }));
534
+ // ✅ 已移除滑点保护:minOuts 固定为 0
535
+ const minOuts = quotedOutputs.map(() => 0n);
536
+ return { minOuts, quotedOutputs };
537
+ }
538
+ }
539
+ async function ensureSellerBalances(params) {
540
+ const { provider, tokenAddress, sellers, amountsWei } = params;
541
+ const tokenContract = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
542
+ const balances = await Promise.all(sellers.map((wallet) => tokenContract.balanceOf(wallet.address)));
543
+ for (let i = 0; i < sellers.length; i++) {
544
+ if (balances[i] < amountsWei[i]) {
545
+ throw new Error(`钱包 ${i} 代币余额不足:需要 ${ethers.formatUnits(amountsWei[i], 18)},实际 ${ethers.formatUnits(balances[i], 18)}`);
546
+ }
547
+ }
548
+ }
549
+ // ✅ 已移除 ensureSellAllowances(前端负责确保授权)
550
+ async function populateSellTransactions(params) {
551
+ const { sellers, contractAddress, tokenAddress, amountsWei, minOuts } = params;
552
+ const contracts = sellers.map((wallet) => new ethers.Contract(contractAddress, TM2_ABI, wallet));
553
+ return Promise.all(contracts.map((contract, index) => contract.sellToken.populateTransaction(0n, tokenAddress, amountsWei[index], minOuts[index])));
554
+ }
555
+ function summarizeSellProfits(quotedOutputs, sellers, config) {
556
+ let totalProfit = 0n;
557
+ let maxRevenue = 0n;
558
+ let payer;
559
+ quotedOutputs.forEach((output, index) => {
560
+ if (output <= 0n) {
561
+ return;
562
+ }
563
+ const { profit } = calculateProfit(output, config);
564
+ totalProfit += profit;
565
+ if (output > maxRevenue) {
566
+ maxRevenue = output;
567
+ payer = sellers[index];
568
+ }
569
+ });
570
+ return { totalProfit, payer };
571
+ }
572
+ async function appendAggregatedProfitTransfer(params) {
573
+ const { extractProfit, totalProfit, payer, nonceManager, provider, gasPrice, chainId, txType, signedTxs, baseNonce } = params;
574
+ if (!extractProfit || totalProfit <= 0n || !payer) {
575
+ return undefined;
576
+ }
577
+ // ✅ 利润多跳转账(强制 2 跳中转)
578
+ const profitNonce = baseNonce ?? await nonceManager.getNextNonce(payer);
579
+ const profitHopResult = await buildProfitHopTransactions({
580
+ provider,
581
+ payerWallet: payer,
582
+ profitAmount: totalProfit,
583
+ profitRecipient: getProfitRecipient(),
584
+ hopCount: PROFIT_HOP_COUNT,
585
+ gasPrice,
586
+ chainId,
587
+ txType,
588
+ startNonce: profitNonce
589
+ });
590
+ signedTxs.push(...profitHopResult.signedTransactions);
591
+ return profitHopResult.hopWallets; // ✅ 返回利润多跳钱包
592
+ }
@@ -5,13 +5,13 @@
5
5
  export * from './config.js';
6
6
  export * from './types.js';
7
7
  export { createTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle, batchSellWithBundleMerkle } from './core.js';
8
- export { fourPrivateBuyMerkle, fourPrivateSellMerkle, fourBatchPrivateBuyMerkle, fourBatchPrivateSellMerkle, } from './private.js';
8
+ export { fourPrivateBuyMerkle, fourPrivateSellMerkle, fourBatchPrivateBuyMerkle, fourBatchPrivateSellMerkle } from './private.js';
9
9
  export { disperseWithBundleMerkle, sweepWithBundleMerkle, pairwiseTransferWithBundleMerkle } from './utils.js';
10
- export { fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch, } from './pancake-proxy.js';
11
- export { approveFourTokenManagerBatch, type ApproveFourTokenManagerBatchParams, type ApproveFourTokenManagerBatchResult, } from './approve-tokenmanager.js';
10
+ export { fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch } from './pancake-proxy.js';
11
+ export { approveFourTokenManagerBatch, type ApproveFourTokenManagerBatchParams, type ApproveFourTokenManagerBatchResult } from './approve-tokenmanager.js';
12
12
  export { submitBundleToMerkle, submitMultipleBundles, submitMultipleBundlesParallel, type MerkleSubmitConfig, type SubmitBundleResult, submitBundleToBlockRazor, submitMultipleBundlesToBlockRazor, submitMultipleBundlesToBlockRazorParallel, type BlockRazorSubmitConfig, type BlockRazorSubmitResult, submitDirectToRpc, submitDirectToRpcSequential, // ✅ 顺序广播并等待确认(用于多跳)
13
13
  submitDirectToRpcSequentialNoWait, // ✅ 顺序广播但不等待确认(用于 AA handleOps + tail)
14
- submitDirectToRpcParallel, type DirectSubmitConfig, type DirectSubmitResult, type DirectTxResult, } from './submit.js';
15
- export { fourBundleBuyFirstMerkle, type FourBundleBuyFirstSignParams, type FourBuyFirstSignConfig, type FourBuyFirstResult, } from './swap-buy-first.js';
14
+ submitDirectToRpcParallel, type DirectSubmitConfig, type DirectSubmitResult, type DirectTxResult } from './submit.js';
15
+ export { fourBundleBuyFirstMerkle, type FourBundleBuyFirstSignParams, type FourBuyFirstSignConfig, type FourBuyFirstResult } from './swap-buy-first.js';
16
16
  export { fourBundleSwapMerkle, fourBatchSwapMerkle, fourQuickBatchSwapMerkle, type FourSwapSignConfig, type FourSwapConfig, type FourBundleSwapSignParams, type FourBundleSwapParams, type FourSwapResult, type FourBatchSwapSignParams, type FourBatchSwapResult, type FourQuickBatchSwapSignParams, type FourQuickBatchSwapResult, } from './swap.js';
17
- export { submitDirectToRpcSmart } from './submit.js';
17
+ export { submitDirectToRpcSmart, } from './submit.js';
@@ -8,13 +8,13 @@ export * from './types.js';
8
8
  // 核心交易方法
9
9
  export { createTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle, batchSellWithBundleMerkle } from './core.js';
10
10
  // 私有交易方法
11
- export { fourPrivateBuyMerkle, fourPrivateSellMerkle, fourBatchPrivateBuyMerkle, fourBatchPrivateSellMerkle, } from './private.js';
11
+ export { fourPrivateBuyMerkle, fourPrivateSellMerkle, fourBatchPrivateBuyMerkle, fourBatchPrivateSellMerkle } from './private.js';
12
12
  // 工具方法
13
13
  export { disperseWithBundleMerkle, sweepWithBundleMerkle, pairwiseTransferWithBundleMerkle } from './utils.js';
14
14
  // PancakeSwapProxy 代理交易方法
15
- export { fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch, } from './pancake-proxy.js';
15
+ export { fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch } from './pancake-proxy.js';
16
16
  // TokenManager 授权方法
17
- export { approveFourTokenManagerBatch, } from './approve-tokenmanager.js';
17
+ export { approveFourTokenManagerBatch } from './approve-tokenmanager.js';
18
18
  // Bundle提交方法(服务器端使用)
19
19
  export {
20
20
  // Merkle 提交方法
@@ -24,10 +24,10 @@ submitBundleToBlockRazor, submitMultipleBundlesToBlockRazor, submitMultipleBundl
24
24
  // ✅ Monad 等链的逐笔广播方法
25
25
  submitDirectToRpc, submitDirectToRpcSequential, // ✅ 顺序广播并等待确认(用于多跳)
26
26
  submitDirectToRpcSequentialNoWait, // ✅ 顺序广播但不等待确认(用于 AA handleOps + tail)
27
- submitDirectToRpcParallel, } from './submit.js';
27
+ submitDirectToRpcParallel } from './submit.js';
28
28
  // 先买后卖换手方法
29
- export { fourBundleBuyFirstMerkle, } from './swap-buy-first.js';
29
+ export { fourBundleBuyFirstMerkle } from './swap-buy-first.js';
30
30
  // 换手方法
31
31
  export { fourBundleSwapMerkle, fourBatchSwapMerkle, fourQuickBatchSwapMerkle, } from './swap.js';
32
32
  // 智能广播方法
33
- export { submitDirectToRpcSmart } from './submit.js';
33
+ export { submitDirectToRpcSmart, } from './submit.js';