four-flap-meme-sdk 3.0.0 → 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 (446) 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/index.d.ts +1 -1
  97. package/dist/chains/bsc/index.js +2 -0
  98. package/dist/chains/bsc/pancake/bundle-buy-first-build.d.ts +25 -0
  99. package/dist/chains/bsc/pancake/bundle-buy-first-build.js +177 -0
  100. package/dist/chains/bsc/pancake/bundle-buy-first-constants.d.ts +30 -0
  101. package/dist/chains/bsc/pancake/bundle-buy-first-constants.js +24 -0
  102. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +11 -149
  103. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +12 -74
  104. package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.d.ts +9 -0
  105. package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.js +225 -0
  106. package/dist/chains/bsc/pancake/bundle-buy-first-plan.d.ts +14 -0
  107. package/dist/chains/bsc/pancake/bundle-buy-first-plan.js +64 -0
  108. package/dist/chains/bsc/pancake/bundle-buy-first-profit.d.ts +12 -0
  109. package/dist/chains/bsc/pancake/bundle-buy-first-profit.js +22 -0
  110. package/dist/chains/bsc/pancake/bundle-buy-first-quote.d.ts +15 -0
  111. package/dist/chains/bsc/pancake/bundle-buy-first-quote.js +122 -0
  112. package/dist/chains/bsc/pancake/bundle-buy-first-types.d.ts +179 -0
  113. package/dist/chains/bsc/pancake/bundle-buy-first-types.js +1 -0
  114. package/dist/chains/bsc/pancake/bundle-buy-first-validate.d.ts +2 -0
  115. package/dist/chains/bsc/pancake/bundle-buy-first-validate.js +41 -0
  116. package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -1
  117. package/dist/chains/bsc/pancake/bundle-buy-first.js +8 -578
  118. package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +11 -239
  119. package/dist/chains/bsc/pancake/bundle-swap-helpers.js +12 -564
  120. package/dist/chains/bsc/pancake/bundle-swap-types.d.ts +183 -0
  121. package/dist/chains/bsc/pancake/bundle-swap-types.js +17 -0
  122. package/dist/chains/bsc/pancake/bundle-swap.d.ts +10 -132
  123. package/dist/chains/bsc/pancake/bundle-swap.js +12 -1003
  124. package/dist/chains/bsc/pancake/hop-chain.d.ts +18 -0
  125. package/dist/chains/bsc/pancake/hop-chain.js +227 -0
  126. package/dist/chains/bsc/pancake/quote.d.ts +14 -0
  127. package/dist/chains/bsc/pancake/quote.js +84 -0
  128. package/dist/chains/bsc/pancake/swap-batch.d.ts +42 -0
  129. package/dist/chains/bsc/pancake/swap-batch.js +283 -0
  130. package/dist/chains/bsc/pancake/swap-build.d.ts +19 -0
  131. package/dist/chains/bsc/pancake/swap-build.js +226 -0
  132. package/dist/chains/bsc/pancake/swap-cross.d.ts +42 -0
  133. package/dist/chains/bsc/pancake/swap-cross.js +140 -0
  134. package/dist/chains/bsc/pancake/swap-quick.d.ts +54 -0
  135. package/dist/chains/bsc/pancake/swap-quick.js +424 -0
  136. package/dist/chains/bsc/pancake/swap-single.d.ts +2 -0
  137. package/dist/chains/bsc/pancake/swap-single.js +182 -0
  138. package/dist/chains/bsc/platforms/four/index.d.ts +21 -3
  139. package/dist/chains/bsc/platforms/four/index.js +28 -3
  140. package/dist/chains/eni/batch-router/transfer-disperse.d.ts +37 -0
  141. package/dist/chains/eni/batch-router/transfer-disperse.js +302 -0
  142. package/dist/chains/eni/batch-router/transfer-shared.d.ts +9 -0
  143. package/dist/chains/eni/batch-router/transfer-shared.js +10 -0
  144. package/dist/chains/eni/batch-router/transfer-sweep.d.ts +51 -0
  145. package/dist/chains/eni/batch-router/transfer-sweep.js +364 -0
  146. package/dist/chains/eni/batch-router/transfer.d.ts +4 -74
  147. package/dist/chains/eni/batch-router/transfer.js +2 -647
  148. package/dist/chains/eni/index.d.ts +2 -0
  149. package/dist/chains/eni/index.js +4 -0
  150. package/dist/chains/eni/platforms/daoaas/portal-direct-profit.d.ts +17 -0
  151. package/dist/chains/eni/platforms/daoaas/portal-direct-profit.js +30 -0
  152. package/dist/chains/eni/platforms/daoaas/portal-direct-submit.d.ts +12 -0
  153. package/dist/chains/eni/platforms/daoaas/portal-direct-submit.js +396 -0
  154. package/dist/chains/eni/platforms/daoaas/portal-direct-tx.d.ts +20 -0
  155. package/dist/chains/eni/platforms/daoaas/portal-direct-tx.js +165 -0
  156. package/dist/chains/eni/platforms/daoaas/portal-direct.d.ts +3 -32
  157. package/dist/chains/eni/platforms/daoaas/portal-direct.js +3 -571
  158. package/dist/chains/eni/submit.js +1 -1
  159. package/dist/chains/xlayer/constants.d.ts +0 -2
  160. package/dist/chains/xlayer/constants.js +0 -2
  161. package/dist/chains/xlayer/eip7702/auth.d.ts +16 -0
  162. package/dist/chains/xlayer/eip7702/auth.js +81 -0
  163. package/dist/chains/xlayer/eip7702/bundle-create-buy.d.ts +22 -0
  164. package/dist/chains/xlayer/eip7702/bundle-create-buy.js +201 -0
  165. package/dist/chains/xlayer/eip7702/bundle-create-helpers.d.ts +114 -0
  166. package/dist/chains/xlayer/eip7702/bundle-create-helpers.js +139 -0
  167. package/dist/chains/xlayer/eip7702/bundle-create-to-dex.d.ts +24 -0
  168. package/dist/chains/xlayer/eip7702/bundle-create-to-dex.js +233 -0
  169. package/dist/chains/xlayer/eip7702/bundle-create.d.ts +3 -35
  170. package/dist/chains/xlayer/eip7702/bundle-create.js +3 -746
  171. package/dist/chains/xlayer/eip7702/bundle-graduate-buy.d.ts +22 -0
  172. package/dist/chains/xlayer/eip7702/bundle-graduate-buy.js +214 -0
  173. package/dist/chains/xlayer/eip7702/bundle-sell.js +1 -1
  174. package/dist/chains/xlayer/eip7702/bundle-swap-batch.d.ts +31 -0
  175. package/dist/chains/xlayer/eip7702/bundle-swap-batch.js +216 -0
  176. package/dist/chains/xlayer/eip7702/bundle-swap-helpers.d.ts +21 -0
  177. package/dist/chains/xlayer/eip7702/bundle-swap-helpers.js +206 -0
  178. package/dist/chains/xlayer/eip7702/bundle-swap-multi.d.ts +33 -0
  179. package/dist/chains/xlayer/eip7702/bundle-swap-multi.js +146 -0
  180. package/dist/chains/xlayer/eip7702/bundle-swap-single.d.ts +31 -0
  181. package/dist/chains/xlayer/eip7702/bundle-swap-single.js +177 -0
  182. package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +6 -61
  183. package/dist/chains/xlayer/eip7702/bundle-swap.js +3 -712
  184. package/dist/chains/xlayer/eip7702/bytes.d.ts +4 -0
  185. package/dist/chains/xlayer/eip7702/bytes.js +31 -0
  186. package/dist/chains/xlayer/eip7702/gas.d.ts +19 -0
  187. package/dist/chains/xlayer/eip7702/gas.js +152 -0
  188. package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.d.ts +5 -0
  189. package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.js +196 -0
  190. package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.d.ts +5 -0
  191. package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.js +188 -0
  192. package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.d.ts +5 -0
  193. package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.js +220 -0
  194. package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +8 -4
  195. package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +5 -591
  196. package/dist/chains/xlayer/eip7702/profit.d.ts +32 -0
  197. package/dist/chains/xlayer/eip7702/profit.js +59 -0
  198. package/dist/chains/xlayer/eip7702/provider.d.ts +3 -0
  199. package/dist/chains/xlayer/eip7702/provider.js +17 -0
  200. package/dist/chains/xlayer/eip7702/time.d.ts +2 -0
  201. package/dist/chains/xlayer/eip7702/time.js +10 -0
  202. package/dist/chains/xlayer/eip7702/tx-build.d.ts +10 -0
  203. package/dist/chains/xlayer/eip7702/tx-build.js +128 -0
  204. package/dist/chains/xlayer/eip7702/utils.d.ts +19 -85
  205. package/dist/chains/xlayer/eip7702/utils.js +19 -484
  206. package/dist/chains/xlayer/eip7702/volume-bundle.d.ts +13 -0
  207. package/dist/chains/xlayer/eip7702/volume-bundle.js +250 -0
  208. package/dist/chains/xlayer/eip7702/volume-internal.d.ts +13 -0
  209. package/dist/chains/xlayer/eip7702/volume-internal.js +169 -0
  210. package/dist/chains/xlayer/eip7702/volume-make.d.ts +8 -0
  211. package/dist/chains/xlayer/eip7702/volume-make.js +38 -0
  212. package/dist/chains/xlayer/eip7702/volume-single-round.d.ts +17 -0
  213. package/dist/chains/xlayer/eip7702/volume-single-round.js +44 -0
  214. package/dist/chains/xlayer/eip7702/volume-swap.d.ts +18 -0
  215. package/dist/chains/xlayer/eip7702/volume-swap.js +30 -0
  216. package/dist/chains/xlayer/eip7702/volume-wash.d.ts +8 -0
  217. package/dist/chains/xlayer/eip7702/volume-wash.js +191 -0
  218. package/dist/chains/xlayer/eip7702/volume.d.ts +7 -35
  219. package/dist/chains/xlayer/eip7702/volume.js +5 -697
  220. package/dist/chains/xlayer/eip7702/wallet.d.ts +6 -0
  221. package/dist/chains/xlayer/eip7702/wallet.js +17 -0
  222. package/dist/chains/xlayer/eoa/aa-types.d.ts +176 -0
  223. package/dist/chains/xlayer/eoa/aa-types.js +6 -0
  224. package/dist/chains/xlayer/eoa/constants.d.ts +0 -2
  225. package/dist/chains/xlayer/eoa/constants.js +0 -2
  226. package/dist/chains/xlayer/eoa/context.d.ts +8 -0
  227. package/dist/chains/xlayer/eoa/context.js +23 -0
  228. package/dist/chains/xlayer/eoa/encoders.d.ts +147 -0
  229. package/dist/chains/xlayer/eoa/encoders.js +147 -0
  230. package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.d.ts +5 -0
  231. package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.js +113 -0
  232. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +10 -123
  233. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +10 -225
  234. package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.d.ts +50 -0
  235. package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.js +170 -0
  236. package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.d.ts +5 -0
  237. package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.js +257 -0
  238. package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.d.ts +99 -0
  239. package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.js +11 -0
  240. package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +5 -47
  241. package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +3 -522
  242. package/dist/chains/xlayer/eoa/eoa-types.d.ts +776 -0
  243. package/dist/chains/xlayer/eoa/eoa-types.js +6 -0
  244. package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +8 -0
  245. package/dist/chains/xlayer/eoa/eoa-wash-volume.js +8 -0
  246. package/dist/chains/xlayer/eoa/format.d.ts +34 -0
  247. package/dist/chains/xlayer/eoa/format.js +56 -0
  248. package/dist/chains/xlayer/eoa/hop-chain.d.ts +4 -0
  249. package/dist/chains/xlayer/eoa/hop-chain.js +87 -0
  250. package/dist/chains/xlayer/eoa/nonce-map.d.ts +20 -0
  251. package/dist/chains/xlayer/eoa/nonce-map.js +51 -0
  252. package/dist/chains/xlayer/eoa/portal-ops.d.ts +9 -292
  253. package/dist/chains/xlayer/eoa/portal-ops.js +9 -486
  254. package/dist/chains/xlayer/eoa/query.d.ts +117 -0
  255. package/dist/chains/xlayer/eoa/query.js +285 -0
  256. package/dist/chains/xlayer/eoa/quote.d.ts +6 -0
  257. package/dist/chains/xlayer/eoa/quote.js +90 -0
  258. package/dist/chains/xlayer/eoa/types.d.ts +9 -959
  259. package/dist/chains/xlayer/eoa/types.js +9 -49
  260. package/dist/core/clients/blockrazor.js +1 -1
  261. package/dist/core/clients/merkle.js +1 -1
  262. package/dist/core/erc20/allowances.d.ts +104 -0
  263. package/dist/core/erc20/allowances.js +205 -0
  264. package/dist/core/erc20/approve.d.ts +141 -0
  265. package/dist/core/erc20/approve.js +325 -0
  266. package/dist/core/erc20/helpers.d.ts +20 -0
  267. package/dist/core/erc20/helpers.js +109 -0
  268. package/dist/core/erc20/index.d.ts +13 -0
  269. package/dist/core/erc20/index.js +12 -0
  270. package/dist/core/gas/bundle-gas.d.ts +6 -1
  271. package/dist/core/index.d.ts +1 -1
  272. package/dist/core/index.js +1 -1
  273. package/dist/core/quote/index.d.ts +1 -0
  274. package/dist/core/quote/index.js +1 -0
  275. package/dist/core/quote/quote-helpers.d.ts +78 -0
  276. package/dist/core/quote/quote-helpers.js +289 -0
  277. package/dist/core/quote/types.d.ts +1 -0
  278. package/dist/core/quote/types.js +1 -0
  279. package/dist/core/sign-context-helpers.d.ts +29 -0
  280. package/dist/core/sign-context-helpers.js +63 -0
  281. package/dist/domains/dex/direct-router-helpers.d.ts +16 -268
  282. package/dist/domains/dex/direct-router-helpers.js +16 -535
  283. package/dist/domains/dex/direct-router-types.d.ts +104 -0
  284. package/dist/domains/dex/direct-router-types.js +81 -0
  285. package/dist/domains/dex/direct-router-v2-buy.d.ts +2 -0
  286. package/dist/domains/dex/direct-router-v2-buy.js +249 -0
  287. package/dist/domains/dex/direct-router-v2-sell.d.ts +5 -0
  288. package/dist/domains/dex/direct-router-v2-sell.js +270 -0
  289. package/dist/domains/dex/direct-router-v2.d.ts +9 -0
  290. package/dist/domains/dex/direct-router-v2.js +9 -0
  291. package/dist/domains/dex/direct-router-v3.d.ts +17 -0
  292. package/dist/domains/dex/direct-router-v3.js +432 -0
  293. package/dist/domains/dex/direct-router.d.ts +11 -26
  294. package/dist/domains/dex/direct-router.js +10 -977
  295. package/dist/domains/dex/dyo-encode.d.ts +62 -0
  296. package/dist/domains/dex/dyo-encode.js +124 -0
  297. package/dist/domains/dex/profit.d.ts +24 -0
  298. package/dist/domains/dex/profit.js +86 -0
  299. package/dist/domains/dex/provider.d.ts +10 -0
  300. package/dist/domains/dex/provider.js +27 -0
  301. package/dist/domains/dex/quote.d.ts +7 -0
  302. package/dist/domains/dex/quote.js +52 -0
  303. package/dist/domains/dex/router.d.ts +56 -0
  304. package/dist/domains/dex/router.js +193 -0
  305. package/dist/domains/flap/portal-bundle/batch.d.ts +9 -0
  306. package/dist/domains/flap/portal-bundle/batch.js +193 -0
  307. package/dist/domains/flap/portal-bundle/create.d.ts +5 -0
  308. package/dist/domains/flap/portal-bundle/create.js +153 -0
  309. package/dist/domains/flap/portal-bundle/helpers.d.ts +32 -0
  310. package/dist/domains/flap/portal-bundle/helpers.js +50 -0
  311. package/dist/domains/flap/portal-bundle/index.d.ts +16 -0
  312. package/dist/domains/flap/portal-bundle/index.js +15 -0
  313. package/dist/domains/flap/portal-bundle/private.d.ts +5 -0
  314. package/dist/domains/flap/portal-bundle/private.js +198 -0
  315. package/dist/domains/flap/portal-bundle/types.d.ts +102 -0
  316. package/dist/domains/flap/portal-bundle/types.js +1 -0
  317. package/dist/domains/flap/portal-bundle-merkle/core-batch.d.ts +13 -0
  318. package/dist/domains/flap/portal-bundle-merkle/core-batch.js +376 -0
  319. package/dist/domains/flap/portal-bundle-merkle/core-helpers.d.ts +75 -7
  320. package/dist/domains/flap/portal-bundle-merkle/core-helpers.js +259 -20
  321. package/dist/domains/flap/portal-bundle-merkle/core.d.ts +2 -13
  322. package/dist/domains/flap/portal-bundle-merkle/core.js +12 -629
  323. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.d.ts +70 -0
  324. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.js +90 -0
  325. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.d.ts +12 -0
  326. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.js +11 -0
  327. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.d.ts +15 -0
  328. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.js +432 -0
  329. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.d.ts +113 -0
  330. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.js +4 -0
  331. package/dist/domains/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -127
  332. package/dist/domains/flap/portal-bundle-merkle/create-to-dex.js +4 -527
  333. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.d.ts +42 -0
  334. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.js +81 -0
  335. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.d.ts +12 -0
  336. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.js +11 -0
  337. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.d.ts +15 -0
  338. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.js +339 -0
  339. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.d.ts +72 -0
  340. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.js +4 -0
  341. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.d.ts +4 -85
  342. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.js +4 -425
  343. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.d.ts +12 -0
  344. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.js +102 -0
  345. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.d.ts +5 -0
  346. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.js +135 -0
  347. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.d.ts +52 -0
  348. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.js +267 -0
  349. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.d.ts +14 -0
  350. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.js +14 -0
  351. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.d.ts +5 -0
  352. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.js +195 -0
  353. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.d.ts +3 -24
  354. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.js +3 -700
  355. package/dist/domains/flap/portal-bundle-merkle/private/buy.d.ts +9 -0
  356. package/dist/domains/flap/portal-bundle-merkle/private/buy.js +188 -0
  357. package/dist/domains/flap/portal-bundle-merkle/private/helpers.d.ts +36 -0
  358. package/dist/domains/flap/portal-bundle-merkle/private/helpers.js +127 -0
  359. package/dist/domains/flap/portal-bundle-merkle/private/index.d.ts +12 -0
  360. package/dist/domains/flap/portal-bundle-merkle/private/index.js +12 -0
  361. package/dist/domains/flap/portal-bundle-merkle/private/sell.d.ts +9 -0
  362. package/dist/domains/flap/portal-bundle-merkle/private/sell.js +191 -0
  363. package/dist/domains/flap/portal-bundle-merkle/private.d.ts +5 -15
  364. package/dist/domains/flap/portal-bundle-merkle/private.js +5 -494
  365. package/dist/domains/flap/portal-bundle-merkle/swap-batch.js +3 -2
  366. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.d.ts +4 -0
  367. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.js +43 -0
  368. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.d.ts +13 -0
  369. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.js +21 -0
  370. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +11 -121
  371. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.js +11 -109
  372. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.d.ts +20 -0
  373. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.js +223 -0
  374. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.d.ts +32 -0
  375. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.js +66 -0
  376. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.d.ts +22 -0
  377. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.js +22 -0
  378. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.d.ts +51 -0
  379. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.js +149 -0
  380. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.d.ts +87 -0
  381. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.js +1 -0
  382. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first.js +5 -404
  383. package/dist/domains/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -1
  384. package/dist/domains/flap/portal-bundle-merkle/swap-helpers.js +0 -7
  385. package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +1 -1
  386. package/dist/domains/flap/portal-bundle-merkle/swap-quick-batch.js +3 -2
  387. package/dist/domains/flap/portal-bundle-merkle/swap-single.js +3 -2
  388. package/dist/domains/flap/portal-bundle-merkle/utils/disperse.d.ts +2 -0
  389. package/dist/domains/flap/portal-bundle-merkle/utils/disperse.js +275 -0
  390. package/dist/domains/flap/portal-bundle-merkle/utils/index.d.ts +11 -0
  391. package/dist/domains/flap/portal-bundle-merkle/utils/index.js +11 -0
  392. package/dist/domains/flap/portal-bundle-merkle/utils/sweep.d.ts +9 -0
  393. package/dist/domains/flap/portal-bundle-merkle/utils/sweep.js +570 -0
  394. package/dist/domains/flap/portal-bundle-merkle/utils.d.ts +5 -8
  395. package/dist/domains/flap/portal-bundle-merkle/utils.js +5 -841
  396. package/dist/domains/flap/portal-bundle.d.ts +5 -117
  397. package/dist/domains/flap/portal-bundle.js +5 -587
  398. package/dist/domains/flap/portal.d.ts +13 -404
  399. package/dist/domains/flap/portal.js +12 -619
  400. package/dist/domains/flap/reader.d.ts +51 -0
  401. package/dist/domains/flap/reader.js +275 -0
  402. package/dist/domains/flap/types.d.ts +246 -0
  403. package/dist/domains/flap/types.js +104 -0
  404. package/dist/domains/flap/vault/constants.d.ts +220 -0
  405. package/dist/domains/flap/vault/constants.js +173 -0
  406. package/dist/domains/flap/vault/encode.d.ts +39 -0
  407. package/dist/domains/flap/vault/encode.js +135 -0
  408. package/dist/domains/flap/vault/index.d.ts +15 -0
  409. package/dist/domains/flap/vault/index.js +14 -0
  410. package/dist/domains/flap/vault/query.d.ts +40 -0
  411. package/dist/domains/flap/vault/query.js +104 -0
  412. package/dist/domains/flap/vault/types.d.ts +147 -0
  413. package/dist/domains/flap/vault/types.js +29 -0
  414. package/dist/domains/flap/vault.d.ts +3 -413
  415. package/dist/domains/flap/vault.js +3 -467
  416. package/dist/domains/flap/writer.d.ts +124 -0
  417. package/dist/domains/flap/writer.js +255 -0
  418. package/dist/domains/four/contracts/tm-bundle-batch.d.ts +35 -0
  419. package/dist/domains/four/contracts/tm-bundle-batch.js +286 -0
  420. package/dist/domains/four/contracts/tm-bundle-create.d.ts +2 -0
  421. package/dist/domains/four/contracts/tm-bundle-create.js +304 -0
  422. package/dist/domains/four/contracts/tm-bundle-helpers.d.ts +2 -1
  423. package/dist/domains/four/contracts/tm-bundle-helpers.js +3 -0
  424. package/dist/domains/four/contracts/tm-bundle-private.d.ts +36 -0
  425. package/dist/domains/four/contracts/tm-bundle-private.js +164 -0
  426. package/dist/domains/four/contracts/tm-bundle.d.ts +10 -71
  427. package/dist/domains/four/contracts/tm-bundle.js +9 -738
  428. package/dist/domains/lp-inspect/inspect-helpers.d.ts +25 -0
  429. package/dist/domains/lp-inspect/inspect-helpers.js +343 -0
  430. package/dist/domains/lp-inspect/inspect.d.ts +8 -0
  431. package/dist/domains/lp-inspect/inspect.js +332 -0
  432. package/dist/domains/lp-inspect/lp-inspect.d.ts +9 -37
  433. package/dist/domains/lp-inspect/lp-inspect.js +9 -775
  434. package/dist/domains/lp-inspect/registry.d.ts +43 -0
  435. package/dist/domains/lp-inspect/registry.js +127 -0
  436. package/dist/domains/merkle/index.d.ts +1 -1
  437. package/dist/exports/root-bundle-and-tooling.d.ts +9 -1
  438. package/dist/exports/root-bundle-and-tooling.js +8 -1
  439. package/dist/exports/root-foundations.d.ts +1 -1
  440. package/dist/exports/root-foundations.js +1 -1
  441. package/dist/exports/root-swap-dex-and-xlayer.d.ts +4 -4
  442. package/dist/exports/root-swap-dex-and-xlayer.js +4 -4
  443. package/dist/index.d.ts +1 -1
  444. package/dist/index.js +1 -1
  445. package/dist/utils/swap-helpers.js +1 -1
  446. package/package.json +1 -81
@@ -1,740 +1,11 @@
1
1
  /**
2
- * tm-bundle - 主函数
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
3
8
  */
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 TM2Abi from '../../../abis/contracts/TokenManager2.json' with { type: 'json' };
10
- import { FourClient, buildLoginMessage } from '../../../core/clients/four.js';
11
- import { trySell } from './tm.js';
12
- import { consoleSdkLogger, getErrorMessageFromUnknown } from '../../../core/index.js';
13
- import { getErrorMessage, waitForBundleWithProvider, } from './tm-bundle-helpers.js';
14
- const TM2_ABI = TM2Abi;
15
- const sdkLogger = consoleSdkLogger;
16
- export async function createTokenWithBundleBuy(params) {
17
- const { privateKeys, buyAmounts, tokenInfo, config } = params;
18
- if (privateKeys.length === 0) {
19
- throw new Error(getErrorMessage('NO_PRIVATE_KEY'));
20
- }
21
- if (buyAmounts.length !== privateKeys.length - 1) {
22
- throw new Error(getErrorMessage('AMOUNT_MISMATCH', buyAmounts.length, privateKeys.length - 1));
23
- }
24
- const provider = new JsonRpcProvider(config.rpcUrl);
25
- const devWallet = new Wallet(privateKeys[0], provider);
26
- // ✅ 只在没有 customSubmitFn 时创建 club48 客户端
27
- let club48 = null;
28
- if (!config.customSubmitFn) {
29
- club48 = new Club48Client({
30
- endpoint: 'https://puissant-bsc.48.club',
31
- explorerEndpoint: config.club48ExplorerEndpoint,
32
- });
33
- }
34
- const fourClient = new FourClient({ baseUrl: config.fourApiUrl });
35
- // 1. 登录 four.meme
36
- const nonce = await fourClient.generateNonce({
37
- accountAddress: devWallet.address,
38
- verifyType: 'LOGIN',
39
- networkCode: 'BSC',
40
- });
41
- const loginSignature = await devWallet.signMessage(buildLoginMessage(nonce));
42
- const accessToken = await fourClient.loginDex({
43
- region: 'WEB',
44
- langType: 'EN',
45
- verifyInfo: {
46
- address: devWallet.address,
47
- networkCode: 'BSC',
48
- signature: loginSignature,
49
- verifyType: 'LOGIN',
50
- },
51
- walletName: 'MetaMask',
52
- });
53
- // 2. 上传图片(如果需要)
54
- let imgUrl = tokenInfo.imageUrl || '';
55
- if (!imgUrl && tokenInfo.imageFile) {
56
- imgUrl = await fourClient.uploadImage(accessToken, tokenInfo.imageFile);
57
- }
58
- if (!imgUrl) {
59
- throw new Error(getErrorMessage('IMAGE_REQUIRED'));
60
- }
61
- // 3. 获取创建参数
62
- const createResp = await fourClient.createToken(accessToken, {
63
- // 可自定义参数
64
- name: tokenInfo.name,
65
- shortName: tokenInfo.symbol,
66
- desc: tokenInfo.description,
67
- imgUrl,
68
- launchTime: Date.now(),
69
- label: tokenInfo.label || 'Meme',
70
- webUrl: tokenInfo.webUrl,
71
- twitterUrl: tokenInfo.twitterUrl,
72
- telegramUrl: tokenInfo.telegramUrl,
73
- preSale: tokenInfo.preSale || '0',
74
- onlyMPC: false,
75
- // 固定参数
76
- lpTradingFee: 0.0025,
77
- symbol: 'BNB',
78
- totalSupply: 1000000000,
79
- raisedAmount: 24,
80
- saleRate: 0.8,
81
- reserveRate: 0,
82
- funGroup: false,
83
- clickFun: false,
84
- });
85
- // 4. 构建交易
86
- const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
87
- // ✅ 获取 gas price
88
- let gasPrice;
89
- if (club48) {
90
- gasPrice = await club48.getMinGasPrice();
91
- }
92
- else {
93
- // 使用 provider 获取 gas price 并增加 20%
94
- const currentGasPrice = (await provider.getFeeData()).gasPrice || 3000000000n;
95
- gasPrice = (currentGasPrice * 120n) / 100n;
96
- }
97
- const signedTxs = [];
98
- const nextNonceMap = new Map();
99
- const getNextNonce = async (w) => {
100
- const key = w.address.toLowerCase();
101
- const cached = nextNonceMap.get(key);
102
- if (cached !== undefined) {
103
- const n = cached;
104
- nextNonceMap.set(key, cached + 1);
105
- return n;
106
- }
107
- const onchain = await w.getNonce();
108
- nextNonceMap.set(key, onchain + 1);
109
- return onchain;
110
- };
111
- // four.meme 只支持 BNB,固定使用 0 地址
112
- const tokenAddress = ZERO_ADDRESS;
113
- // 4.1 创建交易
114
- // 根据文档:b0Amount(初始金额,默认 8 BNB)+ preSale(预购金额)
115
- const b0AmountStr = params.b0Amount ?? '8';
116
- const b0AmountWei = ethers.parseEther(b0AmountStr);
117
- const preSaleWei = tokenInfo.preSale ? ethers.parseEther(tokenInfo.preSale) : 0n;
118
- const valueWei = b0AmountWei + preSaleWei;
119
- const tm2 = new ethers.Contract(tmAddr, TM2_ABI, devWallet);
120
- const createTxUnsigned = await tm2.createToken.populateTransaction(createResp.createArg, createResp.signature, {
121
- value: valueWei,
122
- });
123
- // 估算 gas 并添加 20% 安全余量
124
- const estimatedCreateGas = await provider.estimateGas({
125
- ...createTxUnsigned,
126
- from: devWallet.address,
127
- value: valueWei,
128
- });
129
- const createGasLimit = (estimatedCreateGas * 120n) / 100n;
130
- const createTxRequest = {
131
- ...createTxUnsigned,
132
- from: devWallet.address,
133
- nonce: await getNextNonce(devWallet),
134
- gasLimit: createGasLimit,
135
- gasPrice: gasPrice,
136
- chainId: CHAINS.BSC.chainId,
137
- type: 0, // Legacy transaction (required for BSC on 48.club)
138
- };
139
- const signedCreateTx = await devWallet.signTransaction(createTxRequest);
140
- signedTxs.push(signedCreateTx);
141
- // 4.2 购买交易
142
- const buyTxs = [];
143
- const profitTxs = [];
144
- const buyAmountsWei = buyAmounts.map((a) => ethers.parseEther(a));
145
- // 🔍 找出买入金额最多的买家(由他支付所有利润)
146
- let maxBuyerIndex = 0;
147
- let maxAmount = buyAmountsWei[0];
148
- for (let i = 1; i < buyAmountsWei.length; i++) {
149
- if (buyAmountsWei[i] > maxAmount) {
150
- maxAmount = buyAmountsWei[i];
151
- maxBuyerIndex = i;
152
- }
153
- }
154
- // ✅ 并行构建所有购买交易
155
- const buyerWallets = privateKeys.slice(1).map((pk) => new Wallet(pk, provider));
156
- // 并行获取所有买家的 nonce
157
- const buyerNonces = await Promise.all(buyerWallets.map((w) => getNextNonce(w)));
158
- // 并行构建未签名交易和估算 gas
159
- const buyTxDataList = await Promise.all(buyAmountsWei.map(async (fundsWei, i) => {
160
- const buyerWallet = buyerWallets[i];
161
- const buyTm2 = new ethers.Contract(tmAddr, TM2_ABI, buyerWallet);
162
- const buyTxUnsigned = await buyTm2.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyerWallet.address, fundsWei, 0n, { value: fundsWei });
163
- // 估算 gas 并添加 20% 安全余量
164
- let buyGasLimit;
165
- try {
166
- const estimatedBuyGas = await provider.estimateGas({
167
- ...buyTxUnsigned,
168
- from: buyerWallet.address,
169
- value: fundsWei,
170
- });
171
- buyGasLimit = (estimatedBuyGas * 120n) / 100n;
172
- }
173
- catch {
174
- buyGasLimit = 600000n; // 兜底值
175
- }
176
- return { buyTxUnsigned, buyGasLimit, buyerWallet, fundsWei };
177
- }));
178
- // 并行签名所有购买交易
179
- const signedBuyTxList = await Promise.all(buyTxDataList.map(async (data, i) => {
180
- const buyTxRequest = {
181
- ...data.buyTxUnsigned,
182
- from: data.buyerWallet.address,
183
- nonce: buyerNonces[i],
184
- gasLimit: data.buyGasLimit,
185
- gasPrice: gasPrice,
186
- chainId: CHAINS.BSC.chainId,
187
- };
188
- return data.buyerWallet.signTransaction(buyTxRequest);
189
- }));
190
- signedTxs.push(...signedBuyTxList);
191
- buyTxs.push(...signedBuyTxList);
192
- // ✅ 聚合利润:由买入最多的人支付总利润(强制 2 跳中转)
193
- const totalBuyAmount = buyAmountsWei.reduce((sum, amount) => sum + amount, 0n);
194
- const totalProfitAmount = (totalBuyAmount * BigInt(getProfitRateBps('normal'))) / 10000n;
195
- let profitHopWallets;
196
- if (totalProfitAmount > 0n) {
197
- const payerWallet = new Wallet(privateKeys[maxBuyerIndex + 1], provider);
198
- const profitNonce = await getNextNonce(payerWallet);
199
- const profitHopResult = await buildProfitHopTransactions({
200
- provider,
201
- payerWallet,
202
- profitAmount: totalProfitAmount,
203
- profitRecipient: getProfitRecipient(),
204
- hopCount: PROFIT_HOP_COUNT,
205
- gasPrice,
206
- chainId: CHAINS.BSC.chainId,
207
- txType: 0,
208
- startNonce: profitNonce,
209
- });
210
- signedTxs.push(...profitHopResult.signedTransactions);
211
- profitTxs.push(...profitHopResult.signedTransactions);
212
- profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
213
- }
214
- // 可选 tipTx
215
- if (config.tipAmountWei && config.tipAmountWei > 0n) {
216
- const tipTx = await devWallet.signTransaction({
217
- to: BUILDER_CONTROL_EOA,
218
- value: config.tipAmountWei,
219
- gasPrice,
220
- gasLimit: GAS_LIMITS.BRIBE,
221
- chainId: CHAINS.BSC.chainId,
222
- type: 0, // Legacy transaction
223
- nonce: await getNextNonce(devWallet),
224
- });
225
- signedTxs.push(tipTx);
226
- }
227
- // 5. 提交 Bundle
228
- let bundleUuid;
229
- if (config.customSubmitFn) {
230
- // ✅ 使用自定义提交函数(通过服务器代理)
231
- bundleUuid = await config.customSubmitFn(signedTxs);
232
- }
233
- else if (config.spPrivateKey) {
234
- await sendBatchPrivateTransactions(signedTxs, config.spPrivateKey, config.club48Endpoint || 'https://puissant-bsc.48.club', {
235
- spMode: config.spMode ?? 'timestampPersonalSign',
236
- spVMode: config.spVMode,
237
- });
238
- // 批量提交不返回 bundleUuid,使用第一笔交易的 hash 作为标识
239
- const firstHash = ethers.Transaction.from(signedTxs[0]).hash;
240
- if (!firstHash) {
241
- throw new Error('无法解析首笔已签名交易的 hash(48SP 批量提交)');
242
- }
243
- bundleUuid = firstHash;
244
- }
245
- else {
246
- // ✅ 直接提交到 48.club Bundle(仅服务器端可用)
247
- if (!club48) {
248
- throw new Error('❌ 浏览器环境必须提供 customSubmitFn 或 spPrivateKey 来提交 Bundle(避免 CORS 限制)');
249
- }
250
- bundleUuid = await club48.sendBundle({
251
- txs: signedTxs,
252
- maxBlockNumber: (await provider.getBlockNumber()) + (config.bundleBlockOffset ?? 100),
253
- noMerge: config.noMerge,
254
- }, {
255
- spMode: config.spMode ?? 'timestampPersonalSign',
256
- spPrivateKey: config.spPrivateKey || privateKeys[0],
257
- spVMode: config.spVMode,
258
- });
259
- }
260
- // 6. 等待完成
261
- let status;
262
- if (club48) {
263
- status = await club48.waitForBundle(bundleUuid);
264
- }
265
- else {
266
- // 使用 provider 等待交易上链
267
- status = await waitForBundleWithProvider(provider, signedTxs[0], bundleUuid);
268
- }
269
- // 7. 解析 TokenCreate 事件获取创建的代币地址
270
- let createdTokenAddress;
271
- if (status.status === 'INCLUDED' || status.status === 'PENDING') {
272
- try {
273
- // 从创建交易中解析代币地址
274
- const createTxHash = ethers.Transaction.from(signedCreateTx).hash;
275
- if (createTxHash) {
276
- const receipt = await provider.getTransactionReceipt(createTxHash);
277
- if (receipt && receipt.logs) {
278
- const tm2Interface = new ethers.Interface(TM2_ABI);
279
- for (const log of receipt.logs) {
280
- try {
281
- const parsed = tm2Interface.parseLog({ topics: log.topics, data: log.data });
282
- if (parsed && parsed.name === 'TokenCreate') {
283
- createdTokenAddress = parsed.args.token;
284
- break;
285
- }
286
- }
287
- catch (_e) {
288
- // 忽略无法解析的日志
289
- }
290
- }
291
- }
292
- }
293
- }
294
- catch (error) {
295
- sdkLogger.debug?.('[TM bundle] 解析创建交易回执失败', getErrorMessageFromUnknown(error));
296
- }
297
- }
298
- return {
299
- bundleUuid,
300
- tokenAddress: createdTokenAddress,
301
- status,
302
- createTx: signedCreateTx,
303
- buyTxs,
304
- profitTxs,
305
- profitHopWallets, // ✅ 返回利润多跳钱包
306
- };
307
- }
308
- /**
309
- * four.meme: 批量购买
310
- */
311
- export async function batchBuyWithBundle(params) {
312
- const { privateKeys, buyAmounts, tokenAddress, config } = params;
313
- if (privateKeys.length === 0 || buyAmounts.length !== privateKeys.length) {
314
- throw new Error(getErrorMessage('KEY_AMOUNT_MISMATCH'));
315
- }
316
- const provider = new JsonRpcProvider(config.rpcUrl);
317
- const club48 = new Club48Client({
318
- endpoint: config.club48Endpoint,
319
- explorerEndpoint: config.club48ExplorerEndpoint,
320
- });
321
- const blockOffset = config.bundleBlockOffset ?? 100;
322
- const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
323
- const gasPrice = await club48.getMinGasPrice();
324
- const signedTxs = [];
325
- const nextNonceMap = new Map();
326
- const getNextNonce = async (w) => {
327
- const key = w.address.toLowerCase();
328
- const cached = nextNonceMap.get(key);
329
- if (cached !== undefined) {
330
- const n = cached;
331
- nextNonceMap.set(key, cached + 1);
332
- return n;
333
- }
334
- const onchain = await w.getNonce();
335
- nextNonceMap.set(key, onchain + 1);
336
- return onchain;
337
- };
338
- // ✅ 并行处理所有买家
339
- const wallets = privateKeys.map((pk) => new Wallet(pk, provider));
340
- const fundsWeiList = buyAmounts.map((a) => ethers.parseEther(a));
341
- // 找出买入最多的买家(由他支付所有利润)
342
- let maxBuyerIndex = 0;
343
- let maxFunds = fundsWeiList[0];
344
- for (let i = 1; i < fundsWeiList.length; i++) {
345
- if (fundsWeiList[i] > maxFunds) {
346
- maxFunds = fundsWeiList[i];
347
- maxBuyerIndex = i;
348
- }
349
- }
350
- // 并行获取所有钱包的初始 nonce
351
- const initialNonces = await Promise.all(wallets.map((w) => w.getNonce()));
352
- // 为每个钱包分配 nonce(普通钱包1个,利润支付者2个)
353
- const nonceMap = new Map();
354
- wallets.forEach((w, i) => {
355
- nonceMap.set(w.address.toLowerCase(), initialNonces[i]);
356
- });
357
- const getNextNonceLocal = (w) => {
358
- const key = w.address.toLowerCase();
359
- const n = nonceMap.get(key);
360
- nonceMap.set(key, n + 1);
361
- return n;
362
- };
363
- // 并行构建未签名交易和估算 gas
364
- const txDataList = await Promise.all(wallets.map(async (buyerWallet, i) => {
365
- const fundsWei = fundsWeiList[i];
366
- const tm2 = new ethers.Contract(tmAddr, TM2_ABI, buyerWallet);
367
- const buyTxUnsigned = await tm2.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyerWallet.address, fundsWei, 0n, { value: fundsWei });
368
- let gasLimit;
369
- try {
370
- const estimatedGas = await provider.estimateGas({
371
- ...buyTxUnsigned,
372
- from: buyerWallet.address,
373
- value: fundsWei,
374
- });
375
- gasLimit = (estimatedGas * 120n) / 100n;
376
- }
377
- catch {
378
- gasLimit = 600000n;
379
- }
380
- return { buyTxUnsigned, gasLimit, buyerWallet, fundsWei };
381
- }));
382
- // 并行签名所有买入交易
383
- const signedBuyTxList = await Promise.all(txDataList.map(async (data) => {
384
- const buyTxRequest = {
385
- ...data.buyTxUnsigned,
386
- from: data.buyerWallet.address,
387
- nonce: getNextNonceLocal(data.buyerWallet),
388
- gasLimit: data.gasLimit,
389
- gasPrice: gasPrice,
390
- chainId: CHAINS.BSC.chainId,
391
- };
392
- return data.buyerWallet.signTransaction(buyTxRequest);
393
- }));
394
- signedTxs.push(...signedBuyTxList);
395
- // ✅ 聚合利润:由买入最多的人支付总利润(强制 2 跳中转)
396
- const totalFunds = fundsWeiList.reduce((sum, f) => sum + f, 0n);
397
- const totalProfit = (totalFunds * BigInt(getProfitRateBps('normal'))) / 10000n;
398
- let profitHopWallets;
399
- if (totalProfit > 0n) {
400
- const payerWallet = wallets[maxBuyerIndex];
401
- const profitNonce = getNextNonceLocal(payerWallet);
402
- const profitHopResult = await buildProfitHopTransactions({
403
- provider,
404
- payerWallet,
405
- profitAmount: totalProfit,
406
- profitRecipient: getProfitRecipient(),
407
- hopCount: PROFIT_HOP_COUNT,
408
- gasPrice,
409
- chainId: CHAINS.BSC.chainId,
410
- txType: 0,
411
- startNonce: profitNonce,
412
- });
413
- signedTxs.push(...profitHopResult.signedTransactions);
414
- profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
415
- }
416
- // 可选 tipTx(置前)
417
- if (config.tipAmountWei && config.tipAmountWei > 0n) {
418
- const tipWallet = new Wallet(privateKeys[0], provider);
419
- const tipTx = await tipWallet.signTransaction({
420
- to: BUILDER_CONTROL_EOA,
421
- value: config.tipAmountWei,
422
- gasPrice,
423
- gasLimit: GAS_LIMITS.BRIBE,
424
- chainId: CHAINS.BSC.chainId,
425
- type: 0, // Legacy transaction
426
- nonce: await getNextNonce(tipWallet),
427
- });
428
- signedTxs.unshift(tipTx);
429
- }
430
- const bundleUuid = await club48.sendBundle({
431
- txs: signedTxs,
432
- maxBlockNumber: (await provider.getBlockNumber()) + blockOffset,
433
- noMerge: config.noMerge,
434
- }, {
435
- spMode: config.spMode ?? 'timestampPersonalSign',
436
- spPrivateKey: config.spPrivateKey || privateKeys[0],
437
- spVMode: config.spVMode,
438
- });
439
- const status = await club48.waitForBundle(bundleUuid);
440
- return { bundleUuid, status, buyTxs: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
441
- }
442
- /**
443
- * four.meme: 批量卖出
444
- */
445
- export async function batchSellWithBundle(params) {
446
- const { privateKeys, sellAmounts, tokenAddress, config } = params;
447
- if (privateKeys.length === 0 || sellAmounts.length !== privateKeys.length) {
448
- throw new Error(getErrorMessage('SELL_KEY_AMOUNT_MISMATCH'));
449
- }
450
- const provider = new JsonRpcProvider(config.rpcUrl);
451
- const club48 = new Club48Client({
452
- endpoint: config.club48Endpoint,
453
- explorerEndpoint: config.club48ExplorerEndpoint,
454
- });
455
- const blockOffset = config.bundleBlockOffset ?? 100;
456
- const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
457
- const gasPrice = await club48.getMinGasPrice();
458
- const signedTxs = [];
459
- const nextNonceMap = new Map();
460
- const getNextNonce = async (w) => {
461
- const key = w.address.toLowerCase();
462
- const cached = nextNonceMap.get(key);
463
- if (cached !== undefined) {
464
- const n = cached;
465
- nextNonceMap.set(key, cached + 1);
466
- return n;
467
- }
468
- const onchain = await w.getNonce();
469
- nextNonceMap.set(key, onchain + 1);
470
- return onchain;
471
- };
472
- // ✅ 并行处理所有卖家
473
- const wallets = privateKeys.map((pk) => new Wallet(pk, provider));
474
- const amountsWei = sellAmounts.map((a) => ethers.parseUnits(a, 18));
475
- // 并行预估所有卖出能获得的 BNB
476
- const estimatedBnbOuts = await Promise.all(amountsWei.map(async (amountWei) => {
477
- try {
478
- const result = await trySell('BSC', config.rpcUrl, tokenAddress, amountWei);
479
- return result.funds;
480
- }
481
- catch {
482
- return 0n;
483
- }
484
- }));
485
- // 找出收益最高的卖家(由他支付所有利润)
486
- let maxSellerIndex = 0;
487
- let maxBnbOut = estimatedBnbOuts[0];
488
- for (let i = 1; i < estimatedBnbOuts.length; i++) {
489
- if (estimatedBnbOuts[i] > maxBnbOut) {
490
- maxBnbOut = estimatedBnbOuts[i];
491
- maxSellerIndex = i;
492
- }
493
- }
494
- // 并行获取所有钱包的初始 nonce
495
- const initialNonces = await Promise.all(wallets.map((w) => w.getNonce()));
496
- const nonceMap = new Map();
497
- wallets.forEach((w, i) => {
498
- nonceMap.set(w.address.toLowerCase(), initialNonces[i]);
499
- });
500
- const getNextNonceLocal = (w) => {
501
- const key = w.address.toLowerCase();
502
- const n = nonceMap.get(key);
503
- nonceMap.set(key, n + 1);
504
- return n;
505
- };
506
- // 并行构建未签名交易和估算 gas
507
- const txDataList = await Promise.all(wallets.map(async (sellerWallet, i) => {
508
- const amountWei = amountsWei[i];
509
- const tm2 = new ethers.Contract(tmAddr, TM2_ABI, sellerWallet);
510
- const sellTxUnsigned = await tm2.sellToken.populateTransaction(0n, tokenAddress, amountWei, 0n);
511
- let gasLimit;
512
- try {
513
- const estimatedGas = await provider.estimateGas({
514
- ...sellTxUnsigned,
515
- from: sellerWallet.address,
516
- });
517
- gasLimit = (estimatedGas * 120n) / 100n;
518
- }
519
- catch {
520
- gasLimit = 600000n;
521
- }
522
- return { sellTxUnsigned, gasLimit, sellerWallet };
523
- }));
524
- // 并行签名所有卖出交易
525
- const signedSellTxList = await Promise.all(txDataList.map(async (data) => {
526
- const sellTxRequest = {
527
- ...data.sellTxUnsigned,
528
- from: data.sellerWallet.address,
529
- nonce: getNextNonceLocal(data.sellerWallet),
530
- gasLimit: data.gasLimit,
531
- gasPrice: gasPrice,
532
- chainId: CHAINS.BSC.chainId,
533
- };
534
- return data.sellerWallet.signTransaction(sellTxRequest);
535
- }));
536
- signedTxs.push(...signedSellTxList);
537
- // ✅ 聚合利润:由收益最高的人支付总利润(强制 2 跳中转)
538
- const totalBnbOut = estimatedBnbOuts.reduce((sum, b) => sum + b, 0n);
539
- const totalProfit = (totalBnbOut * BigInt(getProfitRateBps('normal'))) / 10000n;
540
- let profitHopWallets;
541
- if (totalProfit > 0n) {
542
- const payerWallet = wallets[maxSellerIndex];
543
- const profitNonce = getNextNonceLocal(payerWallet);
544
- const profitHopResult = await buildProfitHopTransactions({
545
- provider,
546
- payerWallet,
547
- profitAmount: totalProfit,
548
- profitRecipient: getProfitRecipient(),
549
- hopCount: PROFIT_HOP_COUNT,
550
- gasPrice,
551
- chainId: CHAINS.BSC.chainId,
552
- txType: 0,
553
- startNonce: profitNonce,
554
- });
555
- signedTxs.push(...profitHopResult.signedTransactions);
556
- profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
557
- }
558
- // 可选 tipTx(置前)
559
- if (config.tipAmountWei && config.tipAmountWei > 0n) {
560
- const tipWallet = new Wallet(privateKeys[0], provider);
561
- const tipTx = await tipWallet.signTransaction({
562
- to: BUILDER_CONTROL_EOA,
563
- value: config.tipAmountWei,
564
- gasPrice,
565
- gasLimit: GAS_LIMITS.BRIBE,
566
- chainId: CHAINS.BSC.chainId,
567
- type: 0, // Legacy transaction
568
- nonce: await getNextNonce(tipWallet),
569
- });
570
- signedTxs.unshift(tipTx);
571
- }
572
- const bundleUuid = await club48.sendBundle({
573
- txs: signedTxs,
574
- maxBlockNumber: (await provider.getBlockNumber()) + blockOffset,
575
- noMerge: config.noMerge,
576
- }, {
577
- spMode: config.spMode ?? 'timestampPersonalSign',
578
- spPrivateKey: config.spPrivateKey || privateKeys[0],
579
- spVMode: config.spVMode,
580
- });
581
- const status = await club48.waitForBundle(bundleUuid);
582
- return { bundleUuid, status, sellTxs: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
583
- }
584
- export async function fourPrivateBuy(params) {
585
- const { rpcUrl, privateKey, tokenAddress, funds, to, club48Endpoint, club48ExplorerEndpoint, spPrivateKey } = params;
586
- const provider = new JsonRpcProvider(rpcUrl);
587
- const wallet = new Wallet(privateKey, provider);
588
- const club48 = new Club48Client({ endpoint: club48Endpoint, explorerEndpoint: club48ExplorerEndpoint });
589
- const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
590
- const gasPrice = await club48.getMinGasPrice();
591
- const fundsWei = ethers.parseEther(funds);
592
- const minAmount = 0n;
593
- const tm2 = new ethers.Contract(tmAddr, TM2_ABI, wallet);
594
- const unsigned = await tm2.buyTokenAMAP.populateTransaction(0n, tokenAddress, to ?? wallet.address, fundsWei, minAmount, { value: fundsWei });
595
- // 估算 gas 并添加 20% 安全余量
596
- const estimatedGas = await provider.estimateGas({ ...unsigned, from: wallet.address, value: fundsWei });
597
- const gasLimit = (estimatedGas * 120n) / 100n;
598
- const req = {
599
- ...unsigned,
600
- from: wallet.address,
601
- nonce: await wallet.getNonce(),
602
- gasLimit,
603
- gasPrice,
604
- chainId: CHAINS.BSC.chainId,
605
- type: 0,
606
- };
607
- const signed = await wallet.signTransaction(req);
608
- if (spPrivateKey)
609
- return await club48.sendPrivateTransactionWith48SP(signed, spPrivateKey);
610
- return await club48.sendPrivateTransaction(signed);
611
- }
612
- export async function fourPrivateSell(params) {
613
- const { rpcUrl, privateKey, tokenAddress, amount, minFunds, club48Endpoint, club48ExplorerEndpoint, spPrivateKey } = params;
614
- const provider = new JsonRpcProvider(rpcUrl);
615
- const wallet = new Wallet(privateKey, provider);
616
- const club48 = new Club48Client({ endpoint: club48Endpoint, explorerEndpoint: club48ExplorerEndpoint });
617
- const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
618
- const gasPrice = await club48.getMinGasPrice();
619
- const amountWei = ethers.parseUnits(amount, 18);
620
- const minOut = minFunds ?? 0n;
621
- const tm2 = new ethers.Contract(tmAddr, TM2_ABI, wallet);
622
- const unsigned = await tm2.sellToken.populateTransaction(0n, tokenAddress, amountWei, minOut);
623
- // 估算 gas 并添加 20% 安全余量
624
- const estimatedGas = await provider.estimateGas({ ...unsigned, from: wallet.address });
625
- const gasLimit = (estimatedGas * 120n) / 100n;
626
- const req = {
627
- ...unsigned,
628
- from: wallet.address,
629
- nonce: await wallet.getNonce(),
630
- gasLimit,
631
- gasPrice,
632
- chainId: CHAINS.BSC.chainId,
633
- type: 0,
634
- };
635
- const signed = await wallet.signTransaction(req);
636
- if (spPrivateKey)
637
- return await club48.sendPrivateTransactionWith48SP(signed, spPrivateKey);
638
- return await club48.sendPrivateTransaction(signed);
639
- }
640
- export async function fourBatchPrivateBuy(params) {
641
- const { rpcUrl, privateKeys, fundsList, tokenAddress, club48Endpoint, club48ExplorerEndpoint, spPrivateKey } = params;
642
- if (privateKeys.length !== fundsList.length)
643
- throw new Error('privateKeys and fundsList length mismatch');
644
- const provider = new JsonRpcProvider(rpcUrl);
645
- const club48 = new Club48Client({ endpoint: club48Endpoint, explorerEndpoint: club48ExplorerEndpoint });
646
- const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
647
- // ✅ 并行处理
648
- const wallets = privateKeys.map((pk) => new Wallet(pk, provider));
649
- const fundsWeiList = fundsList.map((f) => ethers.parseEther(f));
650
- // 并行获取 gasPrice 和所有 nonce
651
- const [gasPrice, nonces] = await Promise.all([
652
- club48.getMinGasPrice(),
653
- Promise.all(wallets.map((w) => w.getNonce())),
654
- ]);
655
- // 并行构建未签名交易和估算 gas
656
- const txDataList = await Promise.all(wallets.map(async (w, i) => {
657
- const fundsWei = fundsWeiList[i];
658
- const tm2 = new ethers.Contract(tmAddr, TM2_ABI, w);
659
- const unsigned = await tm2.buyTokenAMAP.populateTransaction(0n, tokenAddress, w.address, fundsWei, 0n, {
660
- value: fundsWei,
661
- });
662
- let gasLimit;
663
- try {
664
- const estimatedGas = await provider.estimateGas({ ...unsigned, from: w.address, value: fundsWei });
665
- gasLimit = (estimatedGas * 120n) / 100n;
666
- }
667
- catch {
668
- gasLimit = 600000n;
669
- }
670
- return { unsigned, gasLimit, wallet: w, fundsWei };
671
- }));
672
- // 并行签名所有交易
673
- const signedTxs = await Promise.all(txDataList.map(async (data, i) => {
674
- const req = {
675
- ...data.unsigned,
676
- from: data.wallet.address,
677
- nonce: nonces[i],
678
- gasLimit: data.gasLimit,
679
- gasPrice,
680
- chainId: CHAINS.BSC.chainId,
681
- type: 0,
682
- };
683
- return data.wallet.signTransaction(req);
684
- }));
685
- if (spPrivateKey) {
686
- return await sendBatchPrivateTransactions(signedTxs, spPrivateKey, club48Endpoint || 'https://puissant-bsc.48.club');
687
- }
688
- // 无 48SP:走 bundle 提交通道
689
- const bundleUuid = await club48.sendBundle({
690
- txs: signedTxs,
691
- maxBlockNumber: (await provider.getBlockNumber()) + 100,
692
- });
693
- return !!bundleUuid;
694
- }
695
- export async function fourBatchPrivateSell(params) {
696
- const { rpcUrl, privateKeys, amounts, tokenAddress, club48Endpoint, club48ExplorerEndpoint, spPrivateKey, minFundsEach, } = params;
697
- if (privateKeys.length !== amounts.length)
698
- throw new Error('privateKeys and amounts length mismatch');
699
- const provider = new JsonRpcProvider(rpcUrl);
700
- const club48 = new Club48Client({ endpoint: club48Endpoint, explorerEndpoint: club48ExplorerEndpoint });
701
- const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
702
- const minOut = minFundsEach ?? 0n;
703
- // ✅ 并行处理
704
- const wallets = privateKeys.map((pk) => new Wallet(pk, provider));
705
- const amountsWei = amounts.map((a) => ethers.parseUnits(a, 18));
706
- // 并行获取 gasPrice 和所有 nonce
707
- const [gasPrice, nonces] = await Promise.all([
708
- club48.getMinGasPrice(),
709
- Promise.all(wallets.map((w) => w.getNonce())),
710
- ]);
711
- // 并行构建未签名交易和估算 gas
712
- const txDataList = await Promise.all(wallets.map(async (w, i) => {
713
- const amountWei = amountsWei[i];
714
- const tm2 = new ethers.Contract(tmAddr, TM2_ABI, w);
715
- const unsigned = await tm2.sellToken.populateTransaction(0n, tokenAddress, amountWei, minOut);
716
- let gasLimit;
717
- try {
718
- const estimatedGas = await provider.estimateGas({ ...unsigned, from: w.address });
719
- gasLimit = (estimatedGas * 120n) / 100n;
720
- }
721
- catch {
722
- gasLimit = 600000n;
723
- }
724
- return { unsigned, gasLimit, wallet: w };
725
- }));
726
- // 并行签名所有交易
727
- const signedTxs = await Promise.all(txDataList.map(async (data, i) => {
728
- const req = {
729
- ...data.unsigned,
730
- from: data.wallet.address,
731
- nonce: nonces[i],
732
- gasLimit: data.gasLimit,
733
- gasPrice,
734
- chainId: CHAINS.BSC.chainId,
735
- type: 0,
736
- };
737
- return data.wallet.signTransaction(req);
738
- }));
739
- return await sendBatchPrivateTransactions(signedTxs, spPrivateKey, club48Endpoint || 'https://puissant-bsc.48.club');
740
- }
9
+ export * from './tm-bundle-create.js';
10
+ export * from './tm-bundle-batch.js';
11
+ export * from './tm-bundle-private.js';