four-flap-meme-sdk 3.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/dist/bundle/four-meme/approve-tokenmanager.d.ts +2 -2
  2. package/dist/bundle/four-meme/approve-tokenmanager.js +3 -3
  3. package/dist/bundle/four-meme/core/buy-flow.d.ts +5 -0
  4. package/dist/bundle/four-meme/core/buy-flow.js +147 -0
  5. package/dist/bundle/four-meme/core/constants.d.ts +6 -0
  6. package/dist/bundle/four-meme/core/constants.js +15 -0
  7. package/dist/bundle/four-meme/core/create-token.d.ts +5 -0
  8. package/dist/bundle/four-meme/core/create-token.js +137 -0
  9. package/dist/bundle/four-meme/core/index.d.ts +14 -0
  10. package/dist/bundle/four-meme/core/index.js +14 -0
  11. package/dist/bundle/four-meme/core/sell-flow.d.ts +5 -0
  12. package/dist/bundle/four-meme/core/sell-flow.js +240 -0
  13. package/dist/bundle/four-meme/core-helpers.js +1 -1
  14. package/dist/bundle/four-meme/core.d.ts +7 -4
  15. package/dist/bundle/four-meme/core.js +5 -513
  16. package/dist/bundle/four-meme/pancake-proxy/approve.d.ts +15 -0
  17. package/dist/bundle/four-meme/pancake-proxy/approve.js +113 -0
  18. package/dist/bundle/four-meme/pancake-proxy/buy.d.ts +8 -0
  19. package/dist/bundle/four-meme/pancake-proxy/buy.js +143 -0
  20. package/dist/bundle/four-meme/pancake-proxy/constants.d.ts +25 -0
  21. package/dist/bundle/four-meme/pancake-proxy/constants.js +14 -0
  22. package/dist/bundle/four-meme/pancake-proxy/helpers.d.ts +45 -0
  23. package/dist/bundle/four-meme/pancake-proxy/helpers.js +232 -0
  24. package/dist/bundle/four-meme/pancake-proxy/index.d.ts +15 -0
  25. package/dist/bundle/four-meme/pancake-proxy/index.js +15 -0
  26. package/dist/bundle/four-meme/pancake-proxy/sell.d.ts +8 -0
  27. package/dist/bundle/four-meme/pancake-proxy/sell.js +194 -0
  28. package/dist/bundle/four-meme/pancake-proxy.d.ts +4 -20
  29. package/dist/bundle/four-meme/pancake-proxy.js +3 -670
  30. package/dist/bundle/four-meme/private/buy.d.ts +16 -0
  31. package/dist/bundle/four-meme/private/buy.js +225 -0
  32. package/dist/bundle/four-meme/private/index.d.ts +11 -0
  33. package/dist/bundle/four-meme/private/index.js +11 -0
  34. package/dist/bundle/four-meme/private/sell.d.ts +18 -0
  35. package/dist/bundle/four-meme/private/sell.js +245 -0
  36. package/dist/bundle/four-meme/private.d.ts +5 -25
  37. package/dist/bundle/four-meme/private.js +5 -463
  38. package/dist/bundle/four-meme/swap/batch.d.ts +8 -0
  39. package/dist/bundle/four-meme/swap/batch.js +170 -0
  40. package/dist/bundle/four-meme/swap/bundle.d.ts +8 -0
  41. package/dist/bundle/four-meme/swap/bundle.js +147 -0
  42. package/dist/bundle/four-meme/swap/index.d.ts +14 -0
  43. package/dist/bundle/four-meme/swap/index.js +13 -0
  44. package/dist/bundle/four-meme/swap/quick-batch.d.ts +8 -0
  45. package/dist/bundle/four-meme/swap/quick-batch.js +206 -0
  46. package/dist/bundle/four-meme/swap-buy-first/helpers.d.ts +20 -0
  47. package/dist/bundle/four-meme/swap-buy-first/helpers.js +39 -0
  48. package/dist/bundle/four-meme/swap-buy-first/index.d.ts +12 -0
  49. package/dist/bundle/four-meme/swap-buy-first/index.js +11 -0
  50. package/dist/bundle/four-meme/swap-buy-first/multi-wallet.d.ts +20 -0
  51. package/dist/bundle/four-meme/swap-buy-first/multi-wallet.js +198 -0
  52. package/dist/bundle/four-meme/swap-buy-first/single.d.ts +7 -0
  53. package/dist/bundle/four-meme/swap-buy-first/single.js +232 -0
  54. package/dist/bundle/four-meme/swap-buy-first.d.ts +4 -3
  55. package/dist/bundle/four-meme/swap-buy-first.js +4 -451
  56. package/dist/bundle/four-meme/swap-hop-helpers.d.ts +2 -2
  57. package/dist/bundle/four-meme/swap-sign-helpers.d.ts +2 -2
  58. package/dist/bundle/four-meme/swap-sign-helpers.js +1 -1
  59. package/dist/bundle/four-meme/swap.d.ts +4 -14
  60. package/dist/bundle/four-meme/swap.js +4 -502
  61. package/dist/bundle/four-meme/types/index.d.ts +1 -1
  62. package/dist/bundle/four-meme/utils-disperse.d.ts +1 -1
  63. package/dist/bundle/four-meme/utils-disperse.js +1 -1
  64. package/dist/bundle/four-meme/utils-pairwise.d.ts +1 -1
  65. package/dist/bundle/four-meme/utils-pairwise.js +1 -1
  66. package/dist/bundle/four-meme/utils-sweep/context.d.ts +39 -0
  67. package/dist/bundle/four-meme/utils-sweep/context.js +7 -0
  68. package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.d.ts +5 -0
  69. package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.js +162 -0
  70. package/dist/bundle/four-meme/utils-sweep/index.d.ts +13 -0
  71. package/dist/bundle/four-meme/utils-sweep/index.js +13 -0
  72. package/dist/bundle/four-meme/utils-sweep/main.d.ts +8 -0
  73. package/dist/bundle/four-meme/utils-sweep/main.js +114 -0
  74. package/dist/bundle/four-meme/utils-sweep/native-no-hop.d.ts +5 -0
  75. package/dist/bundle/four-meme/utils-sweep/native-no-hop.js +156 -0
  76. package/dist/bundle/four-meme/utils-sweep/with-hops.d.ts +6 -0
  77. package/dist/bundle/four-meme/utils-sweep/with-hops.js +382 -0
  78. package/dist/bundle/four-meme/utils-sweep.d.ts +3 -4
  79. package/dist/bundle/four-meme/utils-sweep.js +3 -740
  80. package/dist/bundle/internal.d.ts +2 -2
  81. package/dist/bundle/sign-context-helpers.d.ts +1 -26
  82. package/dist/bundle/sign-context-helpers.js +1 -63
  83. package/dist/bundle/submit/blockrazor.d.ts +94 -0
  84. package/dist/bundle/submit/blockrazor.js +122 -0
  85. package/dist/bundle/submit/direct.d.ts +118 -0
  86. package/dist/bundle/submit/direct.js +484 -0
  87. package/dist/bundle/submit/helpers.d.ts +7 -0
  88. package/dist/bundle/submit/helpers.js +15 -0
  89. package/dist/bundle/submit/index.d.ts +14 -0
  90. package/dist/bundle/submit/index.js +14 -0
  91. package/dist/bundle/submit/merkle.d.ts +84 -0
  92. package/dist/bundle/submit/merkle.js +121 -0
  93. package/dist/bundle/submit.d.ts +3 -286
  94. package/dist/bundle/submit.js +3 -724
  95. package/dist/chains/bsc/four/types.d.ts +1 -1
  96. package/dist/chains/bsc/pancake/bundle-buy-first-build.d.ts +25 -0
  97. package/dist/chains/bsc/pancake/bundle-buy-first-build.js +177 -0
  98. package/dist/chains/bsc/pancake/bundle-buy-first-constants.d.ts +30 -0
  99. package/dist/chains/bsc/pancake/bundle-buy-first-constants.js +24 -0
  100. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +11 -149
  101. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +12 -74
  102. package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.d.ts +9 -0
  103. package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.js +225 -0
  104. package/dist/chains/bsc/pancake/bundle-buy-first-plan.d.ts +14 -0
  105. package/dist/chains/bsc/pancake/bundle-buy-first-plan.js +64 -0
  106. package/dist/chains/bsc/pancake/bundle-buy-first-profit.d.ts +12 -0
  107. package/dist/chains/bsc/pancake/bundle-buy-first-profit.js +22 -0
  108. package/dist/chains/bsc/pancake/bundle-buy-first-quote.d.ts +15 -0
  109. package/dist/chains/bsc/pancake/bundle-buy-first-quote.js +122 -0
  110. package/dist/chains/bsc/pancake/bundle-buy-first-types.d.ts +179 -0
  111. package/dist/chains/bsc/pancake/bundle-buy-first-types.js +1 -0
  112. package/dist/chains/bsc/pancake/bundle-buy-first-validate.d.ts +2 -0
  113. package/dist/chains/bsc/pancake/bundle-buy-first-validate.js +41 -0
  114. package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -1
  115. package/dist/chains/bsc/pancake/bundle-buy-first.js +8 -578
  116. package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +11 -239
  117. package/dist/chains/bsc/pancake/bundle-swap-helpers.js +12 -564
  118. package/dist/chains/bsc/pancake/bundle-swap-types.d.ts +183 -0
  119. package/dist/chains/bsc/pancake/bundle-swap-types.js +17 -0
  120. package/dist/chains/bsc/pancake/bundle-swap.d.ts +10 -132
  121. package/dist/chains/bsc/pancake/bundle-swap.js +12 -1003
  122. package/dist/chains/bsc/pancake/hop-chain.d.ts +18 -0
  123. package/dist/chains/bsc/pancake/hop-chain.js +227 -0
  124. package/dist/chains/bsc/pancake/quote.d.ts +14 -0
  125. package/dist/chains/bsc/pancake/quote.js +84 -0
  126. package/dist/chains/bsc/pancake/swap-batch.d.ts +42 -0
  127. package/dist/chains/bsc/pancake/swap-batch.js +283 -0
  128. package/dist/chains/bsc/pancake/swap-build.d.ts +19 -0
  129. package/dist/chains/bsc/pancake/swap-build.js +226 -0
  130. package/dist/chains/bsc/pancake/swap-cross.d.ts +42 -0
  131. package/dist/chains/bsc/pancake/swap-cross.js +140 -0
  132. package/dist/chains/bsc/pancake/swap-quick.d.ts +54 -0
  133. package/dist/chains/bsc/pancake/swap-quick.js +424 -0
  134. package/dist/chains/bsc/pancake/swap-single.d.ts +2 -0
  135. package/dist/chains/bsc/pancake/swap-single.js +182 -0
  136. package/dist/chains/bsc/platforms/four/index.d.ts +21 -3
  137. package/dist/chains/bsc/platforms/four/index.js +28 -3
  138. package/dist/chains/eni/batch-router/transfer-disperse.d.ts +37 -0
  139. package/dist/chains/eni/batch-router/transfer-disperse.js +302 -0
  140. package/dist/chains/eni/batch-router/transfer-shared.d.ts +9 -0
  141. package/dist/chains/eni/batch-router/transfer-shared.js +10 -0
  142. package/dist/chains/eni/batch-router/transfer-sweep.d.ts +51 -0
  143. package/dist/chains/eni/batch-router/transfer-sweep.js +364 -0
  144. package/dist/chains/eni/batch-router/transfer.d.ts +4 -74
  145. package/dist/chains/eni/batch-router/transfer.js +2 -647
  146. package/dist/chains/eni/platforms/daoaas/portal-direct-profit.d.ts +17 -0
  147. package/dist/chains/eni/platforms/daoaas/portal-direct-profit.js +30 -0
  148. package/dist/chains/eni/platforms/daoaas/portal-direct-submit.d.ts +12 -0
  149. package/dist/chains/eni/platforms/daoaas/portal-direct-submit.js +396 -0
  150. package/dist/chains/eni/platforms/daoaas/portal-direct-tx.d.ts +20 -0
  151. package/dist/chains/eni/platforms/daoaas/portal-direct-tx.js +165 -0
  152. package/dist/chains/eni/platforms/daoaas/portal-direct.d.ts +3 -32
  153. package/dist/chains/eni/platforms/daoaas/portal-direct.js +3 -571
  154. package/dist/chains/eni/submit.js +1 -1
  155. package/dist/chains/xlayer/constants.d.ts +0 -2
  156. package/dist/chains/xlayer/constants.js +0 -2
  157. package/dist/chains/xlayer/eip7702/auth.d.ts +16 -0
  158. package/dist/chains/xlayer/eip7702/auth.js +81 -0
  159. package/dist/chains/xlayer/eip7702/bundle-create-buy.d.ts +22 -0
  160. package/dist/chains/xlayer/eip7702/bundle-create-buy.js +201 -0
  161. package/dist/chains/xlayer/eip7702/bundle-create-helpers.d.ts +114 -0
  162. package/dist/chains/xlayer/eip7702/bundle-create-helpers.js +139 -0
  163. package/dist/chains/xlayer/eip7702/bundle-create-to-dex.d.ts +24 -0
  164. package/dist/chains/xlayer/eip7702/bundle-create-to-dex.js +233 -0
  165. package/dist/chains/xlayer/eip7702/bundle-create.d.ts +3 -35
  166. package/dist/chains/xlayer/eip7702/bundle-create.js +3 -746
  167. package/dist/chains/xlayer/eip7702/bundle-graduate-buy.d.ts +22 -0
  168. package/dist/chains/xlayer/eip7702/bundle-graduate-buy.js +214 -0
  169. package/dist/chains/xlayer/eip7702/bundle-sell.js +1 -1
  170. package/dist/chains/xlayer/eip7702/bundle-swap-batch.d.ts +31 -0
  171. package/dist/chains/xlayer/eip7702/bundle-swap-batch.js +216 -0
  172. package/dist/chains/xlayer/eip7702/bundle-swap-helpers.d.ts +21 -0
  173. package/dist/chains/xlayer/eip7702/bundle-swap-helpers.js +206 -0
  174. package/dist/chains/xlayer/eip7702/bundle-swap-multi.d.ts +33 -0
  175. package/dist/chains/xlayer/eip7702/bundle-swap-multi.js +146 -0
  176. package/dist/chains/xlayer/eip7702/bundle-swap-single.d.ts +31 -0
  177. package/dist/chains/xlayer/eip7702/bundle-swap-single.js +177 -0
  178. package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +6 -61
  179. package/dist/chains/xlayer/eip7702/bundle-swap.js +3 -712
  180. package/dist/chains/xlayer/eip7702/bytes.d.ts +4 -0
  181. package/dist/chains/xlayer/eip7702/bytes.js +31 -0
  182. package/dist/chains/xlayer/eip7702/gas.d.ts +19 -0
  183. package/dist/chains/xlayer/eip7702/gas.js +152 -0
  184. package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.d.ts +5 -0
  185. package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.js +196 -0
  186. package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.d.ts +5 -0
  187. package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.js +188 -0
  188. package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.d.ts +5 -0
  189. package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.js +220 -0
  190. package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +8 -4
  191. package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +5 -591
  192. package/dist/chains/xlayer/eip7702/profit.d.ts +32 -0
  193. package/dist/chains/xlayer/eip7702/profit.js +59 -0
  194. package/dist/chains/xlayer/eip7702/provider.d.ts +3 -0
  195. package/dist/chains/xlayer/eip7702/provider.js +17 -0
  196. package/dist/chains/xlayer/eip7702/time.d.ts +2 -0
  197. package/dist/chains/xlayer/eip7702/time.js +10 -0
  198. package/dist/chains/xlayer/eip7702/tx-build.d.ts +10 -0
  199. package/dist/chains/xlayer/eip7702/tx-build.js +128 -0
  200. package/dist/chains/xlayer/eip7702/utils.d.ts +19 -85
  201. package/dist/chains/xlayer/eip7702/utils.js +19 -484
  202. package/dist/chains/xlayer/eip7702/volume-bundle.d.ts +13 -0
  203. package/dist/chains/xlayer/eip7702/volume-bundle.js +250 -0
  204. package/dist/chains/xlayer/eip7702/volume-internal.d.ts +13 -0
  205. package/dist/chains/xlayer/eip7702/volume-internal.js +169 -0
  206. package/dist/chains/xlayer/eip7702/volume-make.d.ts +8 -0
  207. package/dist/chains/xlayer/eip7702/volume-make.js +38 -0
  208. package/dist/chains/xlayer/eip7702/volume-single-round.d.ts +17 -0
  209. package/dist/chains/xlayer/eip7702/volume-single-round.js +44 -0
  210. package/dist/chains/xlayer/eip7702/volume-swap.d.ts +18 -0
  211. package/dist/chains/xlayer/eip7702/volume-swap.js +30 -0
  212. package/dist/chains/xlayer/eip7702/volume-wash.d.ts +8 -0
  213. package/dist/chains/xlayer/eip7702/volume-wash.js +191 -0
  214. package/dist/chains/xlayer/eip7702/volume.d.ts +7 -35
  215. package/dist/chains/xlayer/eip7702/volume.js +5 -697
  216. package/dist/chains/xlayer/eip7702/wallet.d.ts +6 -0
  217. package/dist/chains/xlayer/eip7702/wallet.js +17 -0
  218. package/dist/chains/xlayer/eoa/aa-types.d.ts +176 -0
  219. package/dist/chains/xlayer/eoa/aa-types.js +6 -0
  220. package/dist/chains/xlayer/eoa/constants.d.ts +0 -2
  221. package/dist/chains/xlayer/eoa/constants.js +0 -2
  222. package/dist/chains/xlayer/eoa/context.d.ts +8 -0
  223. package/dist/chains/xlayer/eoa/context.js +23 -0
  224. package/dist/chains/xlayer/eoa/encoders.d.ts +147 -0
  225. package/dist/chains/xlayer/eoa/encoders.js +147 -0
  226. package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.d.ts +5 -0
  227. package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.js +113 -0
  228. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +10 -123
  229. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +10 -225
  230. package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.d.ts +50 -0
  231. package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.js +170 -0
  232. package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.d.ts +5 -0
  233. package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.js +257 -0
  234. package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.d.ts +99 -0
  235. package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.js +11 -0
  236. package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +5 -47
  237. package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +3 -522
  238. package/dist/chains/xlayer/eoa/eoa-types.d.ts +776 -0
  239. package/dist/chains/xlayer/eoa/eoa-types.js +6 -0
  240. package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +8 -0
  241. package/dist/chains/xlayer/eoa/eoa-wash-volume.js +8 -0
  242. package/dist/chains/xlayer/eoa/format.d.ts +34 -0
  243. package/dist/chains/xlayer/eoa/format.js +56 -0
  244. package/dist/chains/xlayer/eoa/hop-chain.d.ts +4 -0
  245. package/dist/chains/xlayer/eoa/hop-chain.js +87 -0
  246. package/dist/chains/xlayer/eoa/nonce-map.d.ts +20 -0
  247. package/dist/chains/xlayer/eoa/nonce-map.js +51 -0
  248. package/dist/chains/xlayer/eoa/portal-ops.d.ts +9 -292
  249. package/dist/chains/xlayer/eoa/portal-ops.js +9 -486
  250. package/dist/chains/xlayer/eoa/query.d.ts +117 -0
  251. package/dist/chains/xlayer/eoa/query.js +285 -0
  252. package/dist/chains/xlayer/eoa/quote.d.ts +6 -0
  253. package/dist/chains/xlayer/eoa/quote.js +90 -0
  254. package/dist/chains/xlayer/eoa/types.d.ts +9 -959
  255. package/dist/chains/xlayer/eoa/types.js +9 -49
  256. package/dist/core/clients/blockrazor.js +1 -1
  257. package/dist/core/clients/merkle.js +1 -1
  258. package/dist/core/erc20/allowances.d.ts +104 -0
  259. package/dist/core/erc20/allowances.js +205 -0
  260. package/dist/core/erc20/approve.d.ts +141 -0
  261. package/dist/core/erc20/approve.js +325 -0
  262. package/dist/core/erc20/helpers.d.ts +20 -0
  263. package/dist/core/erc20/helpers.js +109 -0
  264. package/dist/core/erc20/index.d.ts +13 -0
  265. package/dist/core/erc20/index.js +12 -0
  266. package/dist/core/gas/bundle-gas.d.ts +6 -1
  267. package/dist/core/index.d.ts +1 -1
  268. package/dist/core/index.js +1 -1
  269. package/dist/core/quote/index.d.ts +1 -0
  270. package/dist/core/quote/index.js +1 -0
  271. package/dist/core/quote/quote-helpers.d.ts +78 -0
  272. package/dist/core/quote/quote-helpers.js +289 -0
  273. package/dist/core/quote/types.d.ts +1 -0
  274. package/dist/core/quote/types.js +1 -0
  275. package/dist/core/sign-context-helpers.d.ts +29 -0
  276. package/dist/core/sign-context-helpers.js +63 -0
  277. package/dist/domains/dex/direct-router-helpers.d.ts +16 -268
  278. package/dist/domains/dex/direct-router-helpers.js +16 -535
  279. package/dist/domains/dex/direct-router-types.d.ts +104 -0
  280. package/dist/domains/dex/direct-router-types.js +81 -0
  281. package/dist/domains/dex/direct-router-v2-buy.d.ts +2 -0
  282. package/dist/domains/dex/direct-router-v2-buy.js +249 -0
  283. package/dist/domains/dex/direct-router-v2-sell.d.ts +5 -0
  284. package/dist/domains/dex/direct-router-v2-sell.js +270 -0
  285. package/dist/domains/dex/direct-router-v2.d.ts +9 -0
  286. package/dist/domains/dex/direct-router-v2.js +9 -0
  287. package/dist/domains/dex/direct-router-v3.d.ts +17 -0
  288. package/dist/domains/dex/direct-router-v3.js +432 -0
  289. package/dist/domains/dex/direct-router.d.ts +11 -26
  290. package/dist/domains/dex/direct-router.js +10 -977
  291. package/dist/domains/dex/dyo-encode.d.ts +62 -0
  292. package/dist/domains/dex/dyo-encode.js +124 -0
  293. package/dist/domains/dex/profit.d.ts +24 -0
  294. package/dist/domains/dex/profit.js +86 -0
  295. package/dist/domains/dex/provider.d.ts +10 -0
  296. package/dist/domains/dex/provider.js +27 -0
  297. package/dist/domains/dex/quote.d.ts +7 -0
  298. package/dist/domains/dex/quote.js +52 -0
  299. package/dist/domains/dex/router.d.ts +56 -0
  300. package/dist/domains/dex/router.js +193 -0
  301. package/dist/domains/flap/portal-bundle/batch.d.ts +9 -0
  302. package/dist/domains/flap/portal-bundle/batch.js +193 -0
  303. package/dist/domains/flap/portal-bundle/create.d.ts +5 -0
  304. package/dist/domains/flap/portal-bundle/create.js +153 -0
  305. package/dist/domains/flap/portal-bundle/helpers.d.ts +32 -0
  306. package/dist/domains/flap/portal-bundle/helpers.js +50 -0
  307. package/dist/domains/flap/portal-bundle/index.d.ts +16 -0
  308. package/dist/domains/flap/portal-bundle/index.js +15 -0
  309. package/dist/domains/flap/portal-bundle/private.d.ts +5 -0
  310. package/dist/domains/flap/portal-bundle/private.js +198 -0
  311. package/dist/domains/flap/portal-bundle/types.d.ts +102 -0
  312. package/dist/domains/flap/portal-bundle/types.js +1 -0
  313. package/dist/domains/flap/portal-bundle-merkle/core-batch.d.ts +13 -0
  314. package/dist/domains/flap/portal-bundle-merkle/core-batch.js +376 -0
  315. package/dist/domains/flap/portal-bundle-merkle/core-helpers.d.ts +75 -7
  316. package/dist/domains/flap/portal-bundle-merkle/core-helpers.js +259 -20
  317. package/dist/domains/flap/portal-bundle-merkle/core.d.ts +2 -13
  318. package/dist/domains/flap/portal-bundle-merkle/core.js +12 -629
  319. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.d.ts +70 -0
  320. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.js +90 -0
  321. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.d.ts +12 -0
  322. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.js +11 -0
  323. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.d.ts +15 -0
  324. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.js +432 -0
  325. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.d.ts +113 -0
  326. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.js +4 -0
  327. package/dist/domains/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -127
  328. package/dist/domains/flap/portal-bundle-merkle/create-to-dex.js +4 -527
  329. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.d.ts +42 -0
  330. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.js +81 -0
  331. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.d.ts +12 -0
  332. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.js +11 -0
  333. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.d.ts +15 -0
  334. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.js +339 -0
  335. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.d.ts +72 -0
  336. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.js +4 -0
  337. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.d.ts +4 -85
  338. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.js +4 -425
  339. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.d.ts +12 -0
  340. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.js +102 -0
  341. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.d.ts +5 -0
  342. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.js +135 -0
  343. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.d.ts +52 -0
  344. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.js +267 -0
  345. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.d.ts +14 -0
  346. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.js +14 -0
  347. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.d.ts +5 -0
  348. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.js +195 -0
  349. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.d.ts +3 -24
  350. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.js +3 -700
  351. package/dist/domains/flap/portal-bundle-merkle/private/buy.d.ts +9 -0
  352. package/dist/domains/flap/portal-bundle-merkle/private/buy.js +188 -0
  353. package/dist/domains/flap/portal-bundle-merkle/private/helpers.d.ts +36 -0
  354. package/dist/domains/flap/portal-bundle-merkle/private/helpers.js +127 -0
  355. package/dist/domains/flap/portal-bundle-merkle/private/index.d.ts +12 -0
  356. package/dist/domains/flap/portal-bundle-merkle/private/index.js +12 -0
  357. package/dist/domains/flap/portal-bundle-merkle/private/sell.d.ts +9 -0
  358. package/dist/domains/flap/portal-bundle-merkle/private/sell.js +191 -0
  359. package/dist/domains/flap/portal-bundle-merkle/private.d.ts +5 -15
  360. package/dist/domains/flap/portal-bundle-merkle/private.js +5 -494
  361. package/dist/domains/flap/portal-bundle-merkle/swap-batch.js +3 -2
  362. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.d.ts +4 -0
  363. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.js +43 -0
  364. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.d.ts +13 -0
  365. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.js +21 -0
  366. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +11 -121
  367. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.js +11 -109
  368. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.d.ts +20 -0
  369. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.js +223 -0
  370. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.d.ts +32 -0
  371. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.js +66 -0
  372. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.d.ts +22 -0
  373. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.js +22 -0
  374. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.d.ts +51 -0
  375. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.js +149 -0
  376. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.d.ts +87 -0
  377. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.js +1 -0
  378. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first.js +5 -404
  379. package/dist/domains/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -1
  380. package/dist/domains/flap/portal-bundle-merkle/swap-helpers.js +0 -7
  381. package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +1 -1
  382. package/dist/domains/flap/portal-bundle-merkle/swap-quick-batch.js +3 -2
  383. package/dist/domains/flap/portal-bundle-merkle/swap-single.js +3 -2
  384. package/dist/domains/flap/portal-bundle-merkle/utils/disperse.d.ts +2 -0
  385. package/dist/domains/flap/portal-bundle-merkle/utils/disperse.js +275 -0
  386. package/dist/domains/flap/portal-bundle-merkle/utils/index.d.ts +11 -0
  387. package/dist/domains/flap/portal-bundle-merkle/utils/index.js +11 -0
  388. package/dist/domains/flap/portal-bundle-merkle/utils/sweep.d.ts +9 -0
  389. package/dist/domains/flap/portal-bundle-merkle/utils/sweep.js +570 -0
  390. package/dist/domains/flap/portal-bundle-merkle/utils.d.ts +5 -8
  391. package/dist/domains/flap/portal-bundle-merkle/utils.js +5 -841
  392. package/dist/domains/flap/portal-bundle.d.ts +5 -117
  393. package/dist/domains/flap/portal-bundle.js +5 -587
  394. package/dist/domains/flap/portal.d.ts +13 -404
  395. package/dist/domains/flap/portal.js +12 -619
  396. package/dist/domains/flap/reader.d.ts +51 -0
  397. package/dist/domains/flap/reader.js +275 -0
  398. package/dist/domains/flap/types.d.ts +246 -0
  399. package/dist/domains/flap/types.js +104 -0
  400. package/dist/domains/flap/vault/constants.d.ts +220 -0
  401. package/dist/domains/flap/vault/constants.js +173 -0
  402. package/dist/domains/flap/vault/encode.d.ts +39 -0
  403. package/dist/domains/flap/vault/encode.js +135 -0
  404. package/dist/domains/flap/vault/index.d.ts +15 -0
  405. package/dist/domains/flap/vault/index.js +14 -0
  406. package/dist/domains/flap/vault/query.d.ts +40 -0
  407. package/dist/domains/flap/vault/query.js +104 -0
  408. package/dist/domains/flap/vault/types.d.ts +147 -0
  409. package/dist/domains/flap/vault/types.js +29 -0
  410. package/dist/domains/flap/vault.d.ts +3 -413
  411. package/dist/domains/flap/vault.js +3 -467
  412. package/dist/domains/flap/writer.d.ts +124 -0
  413. package/dist/domains/flap/writer.js +255 -0
  414. package/dist/domains/four/contracts/tm-bundle-batch.d.ts +35 -0
  415. package/dist/domains/four/contracts/tm-bundle-batch.js +286 -0
  416. package/dist/domains/four/contracts/tm-bundle-create.d.ts +2 -0
  417. package/dist/domains/four/contracts/tm-bundle-create.js +304 -0
  418. package/dist/domains/four/contracts/tm-bundle-helpers.d.ts +2 -1
  419. package/dist/domains/four/contracts/tm-bundle-helpers.js +3 -0
  420. package/dist/domains/four/contracts/tm-bundle-private.d.ts +36 -0
  421. package/dist/domains/four/contracts/tm-bundle-private.js +164 -0
  422. package/dist/domains/four/contracts/tm-bundle.d.ts +10 -71
  423. package/dist/domains/four/contracts/tm-bundle.js +9 -738
  424. package/dist/domains/lp-inspect/inspect-helpers.d.ts +25 -0
  425. package/dist/domains/lp-inspect/inspect-helpers.js +343 -0
  426. package/dist/domains/lp-inspect/inspect.d.ts +8 -0
  427. package/dist/domains/lp-inspect/inspect.js +332 -0
  428. package/dist/domains/lp-inspect/lp-inspect.d.ts +9 -37
  429. package/dist/domains/lp-inspect/lp-inspect.js +9 -775
  430. package/dist/domains/lp-inspect/registry.d.ts +43 -0
  431. package/dist/domains/lp-inspect/registry.js +127 -0
  432. package/dist/domains/merkle/index.d.ts +1 -1
  433. package/dist/exports/root-bundle-and-tooling.d.ts +9 -1
  434. package/dist/exports/root-bundle-and-tooling.js +8 -1
  435. package/dist/exports/root-foundations.d.ts +1 -1
  436. package/dist/exports/root-foundations.js +1 -1
  437. package/dist/exports/root-swap-dex-and-xlayer.d.ts +4 -4
  438. package/dist/exports/root-swap-dex-and-xlayer.js +4 -4
  439. package/dist/index.d.ts +1 -1
  440. package/dist/index.js +1 -1
  441. package/dist/utils/swap-helpers.js +1 -1
  442. package/package.json +1 -85
@@ -0,0 +1,304 @@
1
+ /**
2
+ * tm-bundle-create - 创建代币 + 捆绑购买
3
+ */
4
+ import { ethers, Wallet, JsonRpcProvider } from 'ethers';
5
+ import { Club48Client, sendBatchPrivateTransactions, BUILDER_CONTROL_EOA, } from '../../../core/clients/club48.js';
6
+ import { ADDRESSES, CHAINS, ZERO_ADDRESS } from '../../../core/constants/index.js';
7
+ import { GAS_LIMITS, getProfitRateBps, getProfitRecipient } from '../../../core/constants/index.js';
8
+ import { buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
9
+ import { FourClient, buildLoginMessage } from '../../../core/clients/four.js';
10
+ import { consoleSdkLogger, getErrorMessageFromUnknown } from '../../../core/index.js';
11
+ import { TM2_ABI, getErrorMessage, waitForBundleWithProvider, } from './tm-bundle-helpers.js';
12
+ const sdkLogger = consoleSdkLogger;
13
+ export async function createTokenWithBundleBuy(params) {
14
+ const { privateKeys, buyAmounts, tokenInfo, config } = params;
15
+ if (privateKeys.length === 0) {
16
+ throw new Error(getErrorMessage('NO_PRIVATE_KEY'));
17
+ }
18
+ if (buyAmounts.length !== privateKeys.length - 1) {
19
+ throw new Error(getErrorMessage('AMOUNT_MISMATCH', buyAmounts.length, privateKeys.length - 1));
20
+ }
21
+ const provider = new JsonRpcProvider(config.rpcUrl);
22
+ const devWallet = new Wallet(privateKeys[0], provider);
23
+ // ✅ 只在没有 customSubmitFn 时创建 club48 客户端
24
+ let club48 = null;
25
+ if (!config.customSubmitFn) {
26
+ club48 = new Club48Client({
27
+ endpoint: 'https://puissant-bsc.48.club',
28
+ explorerEndpoint: config.club48ExplorerEndpoint,
29
+ });
30
+ }
31
+ const fourClient = new FourClient({ baseUrl: config.fourApiUrl });
32
+ // 1. 登录 four.meme
33
+ const nonce = await fourClient.generateNonce({
34
+ accountAddress: devWallet.address,
35
+ verifyType: 'LOGIN',
36
+ networkCode: 'BSC',
37
+ });
38
+ const loginSignature = await devWallet.signMessage(buildLoginMessage(nonce));
39
+ const accessToken = await fourClient.loginDex({
40
+ region: 'WEB',
41
+ langType: 'EN',
42
+ verifyInfo: {
43
+ address: devWallet.address,
44
+ networkCode: 'BSC',
45
+ signature: loginSignature,
46
+ verifyType: 'LOGIN',
47
+ },
48
+ walletName: 'MetaMask',
49
+ });
50
+ // 2. 上传图片(如果需要)
51
+ let imgUrl = tokenInfo.imageUrl || '';
52
+ if (!imgUrl && tokenInfo.imageFile) {
53
+ imgUrl = await fourClient.uploadImage(accessToken, tokenInfo.imageFile);
54
+ }
55
+ if (!imgUrl) {
56
+ throw new Error(getErrorMessage('IMAGE_REQUIRED'));
57
+ }
58
+ // 3. 获取创建参数
59
+ const createResp = await fourClient.createToken(accessToken, {
60
+ // 可自定义参数
61
+ name: tokenInfo.name,
62
+ shortName: tokenInfo.symbol,
63
+ desc: tokenInfo.description,
64
+ imgUrl,
65
+ launchTime: Date.now(),
66
+ label: tokenInfo.label || 'Meme',
67
+ webUrl: tokenInfo.webUrl,
68
+ twitterUrl: tokenInfo.twitterUrl,
69
+ telegramUrl: tokenInfo.telegramUrl,
70
+ preSale: tokenInfo.preSale || '0',
71
+ onlyMPC: false,
72
+ // 固定参数
73
+ lpTradingFee: 0.0025,
74
+ symbol: 'BNB',
75
+ totalSupply: 1000000000,
76
+ raisedAmount: 24,
77
+ saleRate: 0.8,
78
+ reserveRate: 0,
79
+ funGroup: false,
80
+ clickFun: false,
81
+ });
82
+ // 4. 构建交易
83
+ const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
84
+ // ✅ 获取 gas price
85
+ let gasPrice;
86
+ if (club48) {
87
+ gasPrice = await club48.getMinGasPrice();
88
+ }
89
+ else {
90
+ // 使用 provider 获取 gas price 并增加 20%
91
+ const currentGasPrice = (await provider.getFeeData()).gasPrice || 3000000000n;
92
+ gasPrice = (currentGasPrice * 120n) / 100n;
93
+ }
94
+ const signedTxs = [];
95
+ const nextNonceMap = new Map();
96
+ const getNextNonce = async (w) => {
97
+ const key = w.address.toLowerCase();
98
+ const cached = nextNonceMap.get(key);
99
+ if (cached !== undefined) {
100
+ const n = cached;
101
+ nextNonceMap.set(key, cached + 1);
102
+ return n;
103
+ }
104
+ const onchain = await w.getNonce();
105
+ nextNonceMap.set(key, onchain + 1);
106
+ return onchain;
107
+ };
108
+ // four.meme 只支持 BNB,固定使用 0 地址
109
+ const tokenAddress = ZERO_ADDRESS;
110
+ // 4.1 创建交易
111
+ // 根据文档:b0Amount(初始金额,默认 8 BNB)+ preSale(预购金额)
112
+ const b0AmountStr = params.b0Amount ?? '8';
113
+ const b0AmountWei = ethers.parseEther(b0AmountStr);
114
+ const preSaleWei = tokenInfo.preSale ? ethers.parseEther(tokenInfo.preSale) : 0n;
115
+ const valueWei = b0AmountWei + preSaleWei;
116
+ const tm2 = new ethers.Contract(tmAddr, TM2_ABI, devWallet);
117
+ const createTxUnsigned = await tm2.createToken.populateTransaction(createResp.createArg, createResp.signature, {
118
+ value: valueWei,
119
+ });
120
+ // 估算 gas 并添加 20% 安全余量
121
+ const estimatedCreateGas = await provider.estimateGas({
122
+ ...createTxUnsigned,
123
+ from: devWallet.address,
124
+ value: valueWei,
125
+ });
126
+ const createGasLimit = (estimatedCreateGas * 120n) / 100n;
127
+ const createTxRequest = {
128
+ ...createTxUnsigned,
129
+ from: devWallet.address,
130
+ nonce: await getNextNonce(devWallet),
131
+ gasLimit: createGasLimit,
132
+ gasPrice: gasPrice,
133
+ chainId: CHAINS.BSC.chainId,
134
+ type: 0, // Legacy transaction (required for BSC on 48.club)
135
+ };
136
+ const signedCreateTx = await devWallet.signTransaction(createTxRequest);
137
+ signedTxs.push(signedCreateTx);
138
+ // 4.2 购买交易
139
+ const buyTxs = [];
140
+ const profitTxs = [];
141
+ const buyAmountsWei = buyAmounts.map((a) => ethers.parseEther(a));
142
+ // 🔍 找出买入金额最多的买家(由他支付所有利润)
143
+ let maxBuyerIndex = 0;
144
+ let maxAmount = buyAmountsWei[0];
145
+ for (let i = 1; i < buyAmountsWei.length; i++) {
146
+ if (buyAmountsWei[i] > maxAmount) {
147
+ maxAmount = buyAmountsWei[i];
148
+ maxBuyerIndex = i;
149
+ }
150
+ }
151
+ // ✅ 并行构建所有购买交易
152
+ const buyerWallets = privateKeys.slice(1).map((pk) => new Wallet(pk, provider));
153
+ // 并行获取所有买家的 nonce
154
+ const buyerNonces = await Promise.all(buyerWallets.map((w) => getNextNonce(w)));
155
+ // 并行构建未签名交易和估算 gas
156
+ const buyTxDataList = await Promise.all(buyAmountsWei.map(async (fundsWei, i) => {
157
+ const buyerWallet = buyerWallets[i];
158
+ const buyTm2 = new ethers.Contract(tmAddr, TM2_ABI, buyerWallet);
159
+ const buyTxUnsigned = await buyTm2.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyerWallet.address, fundsWei, 0n, { value: fundsWei });
160
+ // 估算 gas 并添加 20% 安全余量
161
+ let buyGasLimit;
162
+ try {
163
+ const estimatedBuyGas = await provider.estimateGas({
164
+ ...buyTxUnsigned,
165
+ from: buyerWallet.address,
166
+ value: fundsWei,
167
+ });
168
+ buyGasLimit = (estimatedBuyGas * 120n) / 100n;
169
+ }
170
+ catch {
171
+ buyGasLimit = 600000n; // 兜底值
172
+ }
173
+ return { buyTxUnsigned, buyGasLimit, buyerWallet, fundsWei };
174
+ }));
175
+ // 并行签名所有购买交易
176
+ const signedBuyTxList = await Promise.all(buyTxDataList.map(async (data, i) => {
177
+ const buyTxRequest = {
178
+ ...data.buyTxUnsigned,
179
+ from: data.buyerWallet.address,
180
+ nonce: buyerNonces[i],
181
+ gasLimit: data.buyGasLimit,
182
+ gasPrice: gasPrice,
183
+ chainId: CHAINS.BSC.chainId,
184
+ };
185
+ return data.buyerWallet.signTransaction(buyTxRequest);
186
+ }));
187
+ signedTxs.push(...signedBuyTxList);
188
+ buyTxs.push(...signedBuyTxList);
189
+ // ✅ 聚合利润:由买入最多的人支付总利润(强制 2 跳中转)
190
+ const totalBuyAmount = buyAmountsWei.reduce((sum, amount) => sum + amount, 0n);
191
+ const totalProfitAmount = (totalBuyAmount * BigInt(getProfitRateBps('normal'))) / 10000n;
192
+ let profitHopWallets;
193
+ if (totalProfitAmount > 0n) {
194
+ const payerWallet = new Wallet(privateKeys[maxBuyerIndex + 1], provider);
195
+ const profitNonce = await getNextNonce(payerWallet);
196
+ const profitHopResult = await buildProfitHopTransactions({
197
+ provider,
198
+ payerWallet,
199
+ profitAmount: totalProfitAmount,
200
+ profitRecipient: getProfitRecipient(),
201
+ hopCount: PROFIT_HOP_COUNT,
202
+ gasPrice,
203
+ chainId: CHAINS.BSC.chainId,
204
+ txType: 0,
205
+ startNonce: profitNonce,
206
+ });
207
+ signedTxs.push(...profitHopResult.signedTransactions);
208
+ profitTxs.push(...profitHopResult.signedTransactions);
209
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
210
+ }
211
+ // 可选 tipTx
212
+ if (config.tipAmountWei && config.tipAmountWei > 0n) {
213
+ const tipTx = await devWallet.signTransaction({
214
+ to: BUILDER_CONTROL_EOA,
215
+ value: config.tipAmountWei,
216
+ gasPrice,
217
+ gasLimit: GAS_LIMITS.BRIBE,
218
+ chainId: CHAINS.BSC.chainId,
219
+ type: 0, // Legacy transaction
220
+ nonce: await getNextNonce(devWallet),
221
+ });
222
+ signedTxs.push(tipTx);
223
+ }
224
+ // 5. 提交 Bundle
225
+ let bundleUuid;
226
+ if (config.customSubmitFn) {
227
+ // ✅ 使用自定义提交函数(通过服务器代理)
228
+ bundleUuid = await config.customSubmitFn(signedTxs);
229
+ }
230
+ else if (config.spPrivateKey) {
231
+ await sendBatchPrivateTransactions(signedTxs, config.spPrivateKey, config.club48Endpoint || 'https://puissant-bsc.48.club', {
232
+ spMode: config.spMode ?? 'timestampPersonalSign',
233
+ spVMode: config.spVMode,
234
+ });
235
+ // 批量提交不返回 bundleUuid,使用第一笔交易的 hash 作为标识
236
+ const firstHash = ethers.Transaction.from(signedTxs[0]).hash;
237
+ if (!firstHash) {
238
+ throw new Error('无法解析首笔已签名交易的 hash(48SP 批量提交)');
239
+ }
240
+ bundleUuid = firstHash;
241
+ }
242
+ else {
243
+ // ✅ 直接提交到 48.club Bundle(仅服务器端可用)
244
+ if (!club48) {
245
+ throw new Error('❌ 浏览器环境必须提供 customSubmitFn 或 spPrivateKey 来提交 Bundle(避免 CORS 限制)');
246
+ }
247
+ bundleUuid = await club48.sendBundle({
248
+ txs: signedTxs,
249
+ maxBlockNumber: (await provider.getBlockNumber()) + (config.bundleBlockOffset ?? 100),
250
+ noMerge: config.noMerge,
251
+ }, {
252
+ spMode: config.spMode ?? 'timestampPersonalSign',
253
+ spPrivateKey: config.spPrivateKey || privateKeys[0],
254
+ spVMode: config.spVMode,
255
+ });
256
+ }
257
+ // 6. 等待完成
258
+ let status;
259
+ if (club48) {
260
+ status = await club48.waitForBundle(bundleUuid);
261
+ }
262
+ else {
263
+ // 使用 provider 等待交易上链
264
+ status = await waitForBundleWithProvider(provider, signedTxs[0], bundleUuid);
265
+ }
266
+ // 7. 解析 TokenCreate 事件获取创建的代币地址
267
+ let createdTokenAddress;
268
+ if (status.status === 'INCLUDED' || status.status === 'PENDING') {
269
+ try {
270
+ // 从创建交易中解析代币地址
271
+ const createTxHash = ethers.Transaction.from(signedCreateTx).hash;
272
+ if (createTxHash) {
273
+ const receipt = await provider.getTransactionReceipt(createTxHash);
274
+ if (receipt && receipt.logs) {
275
+ const tm2Interface = new ethers.Interface(TM2_ABI);
276
+ for (const log of receipt.logs) {
277
+ try {
278
+ const parsed = tm2Interface.parseLog({ topics: log.topics, data: log.data });
279
+ if (parsed && parsed.name === 'TokenCreate') {
280
+ createdTokenAddress = parsed.args.token;
281
+ break;
282
+ }
283
+ }
284
+ catch (_e) {
285
+ // 忽略无法解析的日志
286
+ }
287
+ }
288
+ }
289
+ }
290
+ }
291
+ catch (error) {
292
+ sdkLogger.debug?.('[TM bundle] 解析创建交易回执失败', getErrorMessageFromUnknown(error));
293
+ }
294
+ }
295
+ return {
296
+ bundleUuid,
297
+ tokenAddress: createdTokenAddress,
298
+ status,
299
+ createTx: signedCreateTx,
300
+ buyTxs,
301
+ profitTxs,
302
+ profitHopWallets, // ✅ 返回利润多跳钱包
303
+ };
304
+ }
@@ -1,8 +1,9 @@
1
1
  import { JsonRpcProvider } from 'ethers';
2
- import type { TransactionRequest } from 'ethers';
2
+ import type { InterfaceAbi, TransactionRequest } from 'ethers';
3
3
  import type { SoulPointSignatureMode, VNormalizationMode } from '../../../core/clients/club48.js';
4
4
  import { BundleStatus } from '../../../core/clients/club48.js';
5
5
  import type { GeneratedWallet } from '../../../utils/wallet.js';
6
+ export declare const TM2_ABI: InterfaceAbi;
6
7
  /**
7
8
  * four.meme Bundle 交易方法
8
9
  * 使用 48.club Bundle 服务实现原子化交易
@@ -1,5 +1,8 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { CHAINS } from '../../../core/constants/index.js';
3
+ import TM2Abi from '../../../abis/contracts/TokenManager2.json' with { type: 'json' };
4
+ // ✅ TokenManager2 ABI(create/batch/private 子文件共用)
5
+ export const TM2_ABI = TM2Abi;
3
6
  /**
4
7
  * four.meme Bundle 交易方法
5
8
  * 使用 48.club Bundle 服务实现原子化交易
@@ -0,0 +1,36 @@
1
+ export type FourPrivateBase = {
2
+ rpcUrl: string;
3
+ club48Endpoint?: string;
4
+ club48ExplorerEndpoint?: string;
5
+ };
6
+ export type FourPrivateBuyParams = FourPrivateBase & {
7
+ privateKey: string;
8
+ tokenAddress: string;
9
+ funds: string;
10
+ to?: string;
11
+ spPrivateKey?: string;
12
+ };
13
+ export type FourPrivateSellParams = FourPrivateBase & {
14
+ privateKey: string;
15
+ tokenAddress: string;
16
+ amount: string;
17
+ minFunds?: bigint;
18
+ spPrivateKey?: string;
19
+ };
20
+ export declare function fourPrivateBuy(params: FourPrivateBuyParams): Promise<string>;
21
+ export declare function fourPrivateSell(params: FourPrivateSellParams): Promise<string>;
22
+ export type FourBatchPrivateBuyParams = FourPrivateBase & {
23
+ privateKeys: string[];
24
+ fundsList: string[];
25
+ tokenAddress: string;
26
+ spPrivateKey?: string;
27
+ };
28
+ export type FourBatchPrivateSellParams = FourPrivateBase & {
29
+ privateKeys: string[];
30
+ amounts: string[];
31
+ tokenAddress: string;
32
+ spPrivateKey: string;
33
+ minFundsEach?: bigint;
34
+ };
35
+ export declare function fourBatchPrivateBuy(params: FourBatchPrivateBuyParams): Promise<boolean>;
36
+ export declare function fourBatchPrivateSell(params: FourBatchPrivateSellParams): Promise<boolean>;
@@ -0,0 +1,164 @@
1
+ /**
2
+ * tm-bundle-private - 私有交易(single/batch)
3
+ */
4
+ import { ethers, Wallet, JsonRpcProvider } from 'ethers';
5
+ import { Club48Client, sendBatchPrivateTransactions, } from '../../../core/clients/club48.js';
6
+ import { ADDRESSES, CHAINS } from '../../../core/constants/index.js';
7
+ import { TM2_ABI } from './tm-bundle-helpers.js';
8
+ export async function fourPrivateBuy(params) {
9
+ const { rpcUrl, privateKey, tokenAddress, funds, to, club48Endpoint, club48ExplorerEndpoint, spPrivateKey } = params;
10
+ const provider = new JsonRpcProvider(rpcUrl);
11
+ const wallet = new Wallet(privateKey, provider);
12
+ const club48 = new Club48Client({ endpoint: club48Endpoint, explorerEndpoint: club48ExplorerEndpoint });
13
+ const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
14
+ const gasPrice = await club48.getMinGasPrice();
15
+ const fundsWei = ethers.parseEther(funds);
16
+ const minAmount = 0n;
17
+ const tm2 = new ethers.Contract(tmAddr, TM2_ABI, wallet);
18
+ const unsigned = await tm2.buyTokenAMAP.populateTransaction(0n, tokenAddress, to ?? wallet.address, fundsWei, minAmount, { value: fundsWei });
19
+ // 估算 gas 并添加 20% 安全余量
20
+ const estimatedGas = await provider.estimateGas({ ...unsigned, from: wallet.address, value: fundsWei });
21
+ const gasLimit = (estimatedGas * 120n) / 100n;
22
+ const req = {
23
+ ...unsigned,
24
+ from: wallet.address,
25
+ nonce: await wallet.getNonce(),
26
+ gasLimit,
27
+ gasPrice,
28
+ chainId: CHAINS.BSC.chainId,
29
+ type: 0,
30
+ };
31
+ const signed = await wallet.signTransaction(req);
32
+ if (spPrivateKey)
33
+ return await club48.sendPrivateTransactionWith48SP(signed, spPrivateKey);
34
+ return await club48.sendPrivateTransaction(signed);
35
+ }
36
+ export async function fourPrivateSell(params) {
37
+ const { rpcUrl, privateKey, tokenAddress, amount, minFunds, club48Endpoint, club48ExplorerEndpoint, spPrivateKey } = params;
38
+ const provider = new JsonRpcProvider(rpcUrl);
39
+ const wallet = new Wallet(privateKey, provider);
40
+ const club48 = new Club48Client({ endpoint: club48Endpoint, explorerEndpoint: club48ExplorerEndpoint });
41
+ const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
42
+ const gasPrice = await club48.getMinGasPrice();
43
+ const amountWei = ethers.parseUnits(amount, 18);
44
+ const minOut = minFunds ?? 0n;
45
+ const tm2 = new ethers.Contract(tmAddr, TM2_ABI, wallet);
46
+ const unsigned = await tm2.sellToken.populateTransaction(0n, tokenAddress, amountWei, minOut);
47
+ // 估算 gas 并添加 20% 安全余量
48
+ const estimatedGas = await provider.estimateGas({ ...unsigned, from: wallet.address });
49
+ const gasLimit = (estimatedGas * 120n) / 100n;
50
+ const req = {
51
+ ...unsigned,
52
+ from: wallet.address,
53
+ nonce: await wallet.getNonce(),
54
+ gasLimit,
55
+ gasPrice,
56
+ chainId: CHAINS.BSC.chainId,
57
+ type: 0,
58
+ };
59
+ const signed = await wallet.signTransaction(req);
60
+ if (spPrivateKey)
61
+ return await club48.sendPrivateTransactionWith48SP(signed, spPrivateKey);
62
+ return await club48.sendPrivateTransaction(signed);
63
+ }
64
+ export async function fourBatchPrivateBuy(params) {
65
+ const { rpcUrl, privateKeys, fundsList, tokenAddress, club48Endpoint, club48ExplorerEndpoint, spPrivateKey } = params;
66
+ if (privateKeys.length !== fundsList.length)
67
+ throw new Error('privateKeys and fundsList length mismatch');
68
+ const provider = new JsonRpcProvider(rpcUrl);
69
+ const club48 = new Club48Client({ endpoint: club48Endpoint, explorerEndpoint: club48ExplorerEndpoint });
70
+ const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
71
+ // ✅ 并行处理
72
+ const wallets = privateKeys.map((pk) => new Wallet(pk, provider));
73
+ const fundsWeiList = fundsList.map((f) => ethers.parseEther(f));
74
+ // 并行获取 gasPrice 和所有 nonce
75
+ const [gasPrice, nonces] = await Promise.all([
76
+ club48.getMinGasPrice(),
77
+ Promise.all(wallets.map((w) => w.getNonce())),
78
+ ]);
79
+ // 并行构建未签名交易和估算 gas
80
+ const txDataList = await Promise.all(wallets.map(async (w, i) => {
81
+ const fundsWei = fundsWeiList[i];
82
+ const tm2 = new ethers.Contract(tmAddr, TM2_ABI, w);
83
+ const unsigned = await tm2.buyTokenAMAP.populateTransaction(0n, tokenAddress, w.address, fundsWei, 0n, {
84
+ value: fundsWei,
85
+ });
86
+ let gasLimit;
87
+ try {
88
+ const estimatedGas = await provider.estimateGas({ ...unsigned, from: w.address, value: fundsWei });
89
+ gasLimit = (estimatedGas * 120n) / 100n;
90
+ }
91
+ catch {
92
+ gasLimit = 600000n;
93
+ }
94
+ return { unsigned, gasLimit, wallet: w, fundsWei };
95
+ }));
96
+ // 并行签名所有交易
97
+ const signedTxs = await Promise.all(txDataList.map(async (data, i) => {
98
+ const req = {
99
+ ...data.unsigned,
100
+ from: data.wallet.address,
101
+ nonce: nonces[i],
102
+ gasLimit: data.gasLimit,
103
+ gasPrice,
104
+ chainId: CHAINS.BSC.chainId,
105
+ type: 0,
106
+ };
107
+ return data.wallet.signTransaction(req);
108
+ }));
109
+ if (spPrivateKey) {
110
+ return await sendBatchPrivateTransactions(signedTxs, spPrivateKey, club48Endpoint || 'https://puissant-bsc.48.club');
111
+ }
112
+ // 无 48SP:走 bundle 提交通道
113
+ const bundleUuid = await club48.sendBundle({
114
+ txs: signedTxs,
115
+ maxBlockNumber: (await provider.getBlockNumber()) + 100,
116
+ });
117
+ return !!bundleUuid;
118
+ }
119
+ export async function fourBatchPrivateSell(params) {
120
+ const { rpcUrl, privateKeys, amounts, tokenAddress, club48Endpoint, club48ExplorerEndpoint, spPrivateKey, minFundsEach, } = params;
121
+ if (privateKeys.length !== amounts.length)
122
+ throw new Error('privateKeys and amounts length mismatch');
123
+ const provider = new JsonRpcProvider(rpcUrl);
124
+ const club48 = new Club48Client({ endpoint: club48Endpoint, explorerEndpoint: club48ExplorerEndpoint });
125
+ const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
126
+ const minOut = minFundsEach ?? 0n;
127
+ // ✅ 并行处理
128
+ const wallets = privateKeys.map((pk) => new Wallet(pk, provider));
129
+ const amountsWei = amounts.map((a) => ethers.parseUnits(a, 18));
130
+ // 并行获取 gasPrice 和所有 nonce
131
+ const [gasPrice, nonces] = await Promise.all([
132
+ club48.getMinGasPrice(),
133
+ Promise.all(wallets.map((w) => w.getNonce())),
134
+ ]);
135
+ // 并行构建未签名交易和估算 gas
136
+ const txDataList = await Promise.all(wallets.map(async (w, i) => {
137
+ const amountWei = amountsWei[i];
138
+ const tm2 = new ethers.Contract(tmAddr, TM2_ABI, w);
139
+ const unsigned = await tm2.sellToken.populateTransaction(0n, tokenAddress, amountWei, minOut);
140
+ let gasLimit;
141
+ try {
142
+ const estimatedGas = await provider.estimateGas({ ...unsigned, from: w.address });
143
+ gasLimit = (estimatedGas * 120n) / 100n;
144
+ }
145
+ catch {
146
+ gasLimit = 600000n;
147
+ }
148
+ return { unsigned, gasLimit, wallet: w };
149
+ }));
150
+ // 并行签名所有交易
151
+ const signedTxs = await Promise.all(txDataList.map(async (data, i) => {
152
+ const req = {
153
+ ...data.unsigned,
154
+ from: data.wallet.address,
155
+ nonce: nonces[i],
156
+ gasLimit: data.gasLimit,
157
+ gasPrice,
158
+ chainId: CHAINS.BSC.chainId,
159
+ type: 0,
160
+ };
161
+ return data.wallet.signTransaction(req);
162
+ }));
163
+ return await sendBatchPrivateTransactions(signedTxs, spPrivateKey, club48Endpoint || 'https://puissant-bsc.48.club');
164
+ }
@@ -1,73 +1,12 @@
1
- import { BundleStatus } from '../../../core/clients/club48.js';
2
- import type { GeneratedWallet } from '../../../utils/wallet.js';
3
- import { FourBundleConfig, FourCreateWithBundleBuyParams, FourCreateWithBundleBuyResult } from './tm-bundle-helpers.js';
4
- export type { FourBundleConfig, FourCreateWithBundleBuyParams, FourCreateWithBundleBuyResult, FourProviderBundleWaitStatus, } from './tm-bundle-helpers.js';
5
- export declare function createTokenWithBundleBuy(params: FourCreateWithBundleBuyParams): Promise<FourCreateWithBundleBuyResult>;
6
- export type FourBatchBuyParams = {
7
- privateKeys: string[];
8
- buyAmounts: string[];
9
- tokenAddress: string;
10
- config: FourBundleConfig;
11
- };
12
- export type FourBatchBuyResult = {
13
- bundleUuid: string;
14
- status: BundleStatus;
15
- buyTxs: string[];
16
- profitHopWallets?: GeneratedWallet[];
17
- };
18
- /**
19
- * four.meme: 批量购买
20
- */
21
- export declare function batchBuyWithBundle(params: FourBatchBuyParams): Promise<FourBatchBuyResult>;
22
- export type FourBatchSellParams = {
23
- privateKeys: string[];
24
- sellAmounts: string[];
25
- tokenAddress: string;
26
- config: FourBundleConfig;
27
- };
28
- export type FourBatchSellResult = {
29
- bundleUuid: string;
30
- status: BundleStatus;
31
- sellTxs: string[];
32
- profitHopWallets?: GeneratedWallet[];
33
- };
34
1
  /**
35
- * four.meme: 批量卖出
2
+ * tm-bundle - 主入口(barrel re-export)
3
+ *
4
+ * 实现已按流程拆分到子文件:
5
+ * - tm-bundle-create.ts: 创建代币 + 捆绑购买 createTokenWithBundleBuy
6
+ * - tm-bundle-batch.ts: 批量购买/卖出 batchBuyWithBundle / batchSellWithBundle
7
+ * - tm-bundle-private.ts: 私有交易 fourPrivateBuy / fourPrivateSell / fourBatchPrivateBuy / fourBatchPrivateSell
36
8
  */
37
- export declare function batchSellWithBundle(params: FourBatchSellParams): Promise<FourBatchSellResult>;
38
- export type FourPrivateBase = {
39
- rpcUrl: string;
40
- club48Endpoint?: string;
41
- club48ExplorerEndpoint?: string;
42
- };
43
- export type FourPrivateBuyParams = FourPrivateBase & {
44
- privateKey: string;
45
- tokenAddress: string;
46
- funds: string;
47
- to?: string;
48
- spPrivateKey?: string;
49
- };
50
- export type FourPrivateSellParams = FourPrivateBase & {
51
- privateKey: string;
52
- tokenAddress: string;
53
- amount: string;
54
- minFunds?: bigint;
55
- spPrivateKey?: string;
56
- };
57
- export declare function fourPrivateBuy(params: FourPrivateBuyParams): Promise<string>;
58
- export declare function fourPrivateSell(params: FourPrivateSellParams): Promise<string>;
59
- export type FourBatchPrivateBuyParams = FourPrivateBase & {
60
- privateKeys: string[];
61
- fundsList: string[];
62
- tokenAddress: string;
63
- spPrivateKey?: string;
64
- };
65
- export type FourBatchPrivateSellParams = FourPrivateBase & {
66
- privateKeys: string[];
67
- amounts: string[];
68
- tokenAddress: string;
69
- spPrivateKey: string;
70
- minFundsEach?: bigint;
71
- };
72
- export declare function fourBatchPrivateBuy(params: FourBatchPrivateBuyParams): Promise<boolean>;
73
- export declare function fourBatchPrivateSell(params: FourBatchPrivateSellParams): Promise<boolean>;
9
+ export * from './tm-bundle-create.js';
10
+ export * from './tm-bundle-batch.js';
11
+ export * from './tm-bundle-private.js';
12
+ export type { FourBundleConfig, FourCreateWithBundleBuyParams, FourCreateWithBundleBuyResult, FourProviderBundleWaitStatus, } from './tm-bundle-helpers.js';