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
@@ -1,5 +1,5 @@
1
- import type { ApproveFourTokenManagerBatchParams, ApproveFourTokenManagerBatchResult } from './types.js';
2
- export type { ApproveFourTokenManagerBatchParams, ApproveFourTokenManagerBatchResult } from './types.js';
1
+ import type { ApproveFourTokenManagerBatchParams, ApproveFourTokenManagerBatchResult } from './types/index.js';
2
+ export type { ApproveFourTokenManagerBatchParams, ApproveFourTokenManagerBatchResult } from './types/index.js';
3
3
  /**
4
4
  * 批量授权代币给 TokenManager(用于 Private Buy/Sell)
5
5
  * ✅ 直接通过 RPC 提交到链上并等待确认
@@ -4,8 +4,8 @@ import { ADDRESSES, CHAINS } from '../../core/constants/index.js';
4
4
  import { ERC20_ABI } from '../../abis/common.js';
5
5
  import { getErrorMessageFromUnknown } from '../../core/index.js';
6
6
  import { getTxType, getGasPriceConfig } from '../config-helpers.js';
7
- import { createSignProvider } from '../sign-context-helpers.js';
8
- import { batchCheckAllowances } from '../../core/erc20.js';
7
+ import { createSignProvider } from '../../core/sign-context-helpers.js';
8
+ import { batchCheckAllowances } from '../../core/erc20/index.js';
9
9
  const APPROVAL_THRESHOLD = ethers.MaxUint256 / 2n;
10
10
  function resolveApprovalGasLimit(config) {
11
11
  if (config.gasLimit)
@@ -38,7 +38,7 @@ export async function approveFourTokenManagerBatch(params) {
38
38
  return await tokenContract.decimals();
39
39
  }
40
40
  catch (error) {
41
- throw new Error(`查询代币 decimals 失败: ${getErrorMessageFromUnknown(error)}`);
41
+ throw new Error(`查询代币 decimals 失败: ${getErrorMessageFromUnknown(error)}`, { cause: error });
42
42
  }
43
43
  })(),
44
44
  batchCheckAllowances(provider, tokenAddress, wallets.map((w) => w.address), tmAddr),
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Four.meme Bundle 核心方法 — 批量买入流程
3
+ */
4
+ import type { FourBatchBuySignParams, FourBatchBuyMerkleResult } from '../types/index.js';
5
+ export declare function batchBuyWithBundleMerkle(params: FourBatchBuySignParams): Promise<FourBatchBuyMerkleResult>;
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Four.meme Bundle 核心方法 — 批量买入流程
3
+ */
4
+ import { ethers } from 'ethers';
5
+ import { getGasLimit } from '../../../core/gas/bundle-gas.js';
6
+ import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
7
+ import { ADDRESSES } from '../../../core/constants/index.js';
8
+ import { getBundleErrorMessage } from '../../errors.js';
9
+ import { getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount, } from '../../config-helpers.js';
10
+ import { signBribeTransaction } from '../../../core/sign-context-helpers.js';
11
+ import { createChainContext, createWallets } from '../core-helpers.js';
12
+ import { TM2_ABI } from './constants.js';
13
+ export async function batchBuyWithBundleMerkle(params) {
14
+ const { privateKeys, buyAmounts, tokenAddress, config } = params;
15
+ if (privateKeys.length === 0 || buyAmounts.length !== privateKeys.length) {
16
+ throw new Error(getBundleErrorMessage('KEY_AMOUNT_MISMATCH'));
17
+ }
18
+ const { provider, chainId } = createChainContext(config.rpcUrl);
19
+ const txType = getTxType(config);
20
+ const buyers = createWallets(privateKeys, provider);
21
+ // ✅ 优化:并行初始化 nonceManager 和获取 gasPrice
22
+ const [nonceManager, gasPrice] = await Promise.all([
23
+ Promise.resolve(new NonceManager(provider)),
24
+ getOptimizedGasPrice(provider, getGasPriceConfig(config)),
25
+ ]);
26
+ const buyFlow = await executeBuyFlow({
27
+ wallets: buyers,
28
+ buyAmounts,
29
+ tokenAddress,
30
+ config,
31
+ provider,
32
+ nonceManager,
33
+ contractAddress: ADDRESSES.BSC.TokenManagerOriginal,
34
+ gasPrice,
35
+ chainId,
36
+ profitMode: { type: 'aggregated', payer: buyers[0] },
37
+ txType,
38
+ });
39
+ nonceManager.clearTemp();
40
+ return {
41
+ signedTransactions: buyFlow.signedTxs,
42
+ profitHopWallets: buyFlow.profitHopWallets, // ✅ 返回利润多跳钱包
43
+ metadata: buyFlow.metadata,
44
+ };
45
+ }
46
+ async function executeBuyFlow(options) {
47
+ const { wallets, buyAmounts, tokenAddress, config, provider, nonceManager, contractAddress, gasPrice, chainId, profitMode, txType, } = options;
48
+ const extractProfit = shouldExtractProfit();
49
+ const analysis = analyzeBuyFunds(buyAmounts, extractProfit);
50
+ const finalGasLimit = getGasLimit(config, 800000);
51
+ // ✅ 获取贿赂金额
52
+ const bribeAmount = getBribeAmount(config);
53
+ const needBribeTx = bribeAmount > 0n;
54
+ const payer = profitMode.type === 'aggregated' ? (profitMode.payer ?? wallets[0]) : wallets[0];
55
+ // ✅ 贿赂交易放在首位
56
+ const signedTxs = [];
57
+ let bribeNonceOffset = 0;
58
+ if (needBribeTx) {
59
+ const bribeNonce = await nonceManager.getNextNonce(payer);
60
+ signedTxs.push(await signBribeTransaction(payer, bribeAmount, bribeNonce, gasPrice, chainId, txType));
61
+ bribeNonceOffset = 1; // payer 的买入交易 nonce 需要偏移
62
+ }
63
+ // ✅ 优化:并行执行 populateBuyTransactions 和批量获取 nonces(JSON-RPC 批量请求)
64
+ const [unsignedBuys, nonces] = await Promise.all([
65
+ populateBuyTransactions({
66
+ buyers: wallets,
67
+ contractAddress,
68
+ tokenAddress,
69
+ fundsList: analysis.fundsList,
70
+ }),
71
+ nonceManager.getNextNoncesForWallets(wallets), // ✅ 批量获取 nonce
72
+ ]);
73
+ // ✅ 调整 payer 的 nonce(如果有贿赂交易,需要偏移)
74
+ const payerIndex = wallets.findIndex((w) => w.address.toLowerCase() === payer.address.toLowerCase());
75
+ const adjustedNonces = nonces.map((n, i) => (i === payerIndex ? n + bribeNonceOffset : n));
76
+ // ✅ 并行签名所有买入交易
77
+ const signedBuys = await Promise.all(unsignedBuys.map((unsigned, index) => wallets[index].signTransaction({
78
+ ...unsigned,
79
+ from: wallets[index].address,
80
+ nonce: adjustedNonces[index],
81
+ gasLimit: finalGasLimit,
82
+ gasPrice,
83
+ chainId,
84
+ type: txType,
85
+ value: analysis.fundsList[index],
86
+ })));
87
+ signedTxs.push(...signedBuys);
88
+ // ✅ 利润多跳转账(强制 2 跳中转)
89
+ let profitHopWallets;
90
+ if (extractProfit && analysis.totalProfit > 0n && profitMode.type === 'aggregated') {
91
+ const profitNonce = await nonceManager.getNextNonce(payer);
92
+ const profitHopResult = await buildProfitHopTransactions({
93
+ provider,
94
+ payerWallet: payer,
95
+ profitAmount: analysis.totalProfit,
96
+ profitRecipient: getProfitRecipient(),
97
+ hopCount: PROFIT_HOP_COUNT,
98
+ gasPrice,
99
+ chainId,
100
+ txType,
101
+ startNonce: profitNonce,
102
+ });
103
+ signedTxs.push(...profitHopResult.signedTransactions);
104
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
105
+ }
106
+ const metadata = buildBuyMetadata(extractProfit, analysis.totalBuyAmount, analysis.totalProfit, wallets.length);
107
+ return { signedTxs, metadata, profitHopWallets }; // ✅ 返回利润多跳钱包
108
+ }
109
+ function analyzeBuyFunds(buyAmounts, extractProfit) {
110
+ const fundsList = [];
111
+ const profitList = [];
112
+ let totalProfit = 0n;
113
+ let totalBuyAmount = 0n;
114
+ buyAmounts.forEach((amount) => {
115
+ const originalAmount = ethers.parseEther(amount);
116
+ totalBuyAmount += originalAmount;
117
+ if (extractProfit) {
118
+ const { remaining, profit } = calculateProfit(originalAmount);
119
+ fundsList.push(remaining);
120
+ profitList.push(profit);
121
+ totalProfit += profit;
122
+ }
123
+ else {
124
+ fundsList.push(originalAmount);
125
+ profitList.push(0n);
126
+ }
127
+ });
128
+ return { fundsList, profitList, totalProfit, totalBuyAmount };
129
+ }
130
+ async function populateBuyTransactions(params) {
131
+ const { buyers, contractAddress, tokenAddress, fundsList } = params;
132
+ const contracts = buyers.map((wallet) => new ethers.Contract(contractAddress, TM2_ABI, wallet));
133
+ return Promise.all(contracts.map((contract, index) => contract.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyers[index].address, fundsList[index], 0n, {
134
+ value: fundsList[index],
135
+ })));
136
+ }
137
+ function buildBuyMetadata(extractProfit, totalBuyAmount, totalProfit, buyerCount) {
138
+ if (!extractProfit || totalBuyAmount <= 0n || totalProfit <= 0n) {
139
+ return undefined;
140
+ }
141
+ return {
142
+ totalBuyAmount: ethers.formatEther(totalBuyAmount),
143
+ profitAmount: ethers.formatEther(totalProfit),
144
+ profitRecipient: getProfitRecipient(),
145
+ buyerCount,
146
+ };
147
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Four.meme Bundle 核心方法 — 常量与扩展 ABI
3
+ */
4
+ export declare const MULTICALL3_ADDRESS: "0xcA11bde05977b3631167028862bE2a173976CA11";
5
+ export declare const TM2_ABI: string[];
6
+ export declare const PLATFORM_CREATE_FEE: bigint;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Four.meme Bundle 核心方法 — 常量与扩展 ABI
3
+ */
4
+ import { ethers } from 'ethers';
5
+ import { ADDRESSES } from '../../../core/constants/index.js';
6
+ import { TM2_ABI as _TM2_ABI } from '../../../abis/common.js';
7
+ // ✅ 常量
8
+ export const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
9
+ // ✅ TM2 扩展 ABI(包含创建代币方法和事件)
10
+ export const TM2_ABI = [
11
+ ..._TM2_ABI,
12
+ 'function createToken(bytes args, bytes signature) payable',
13
+ 'event TokenCreate(address indexed creator, address indexed token, uint256 timestamp)',
14
+ ];
15
+ export const PLATFORM_CREATE_FEE = ethers.parseEther('0.01');
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Four.meme Bundle 核心方法 — 创建代币 + 创建者买入
3
+ */
4
+ import type { FourCreateWithBundleBuySignParams, FourCreateWithBundleBuyMerkleResult } from '../types/index.js';
5
+ export declare function createTokenWithBundleBuyMerkle(params: FourCreateWithBundleBuySignParams): Promise<FourCreateWithBundleBuyMerkleResult>;
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Four.meme Bundle 核心方法 — 创建代币 + 创建者买入
3
+ */
4
+ import { ethers, Wallet } from 'ethers';
5
+ import { getGasLimit } from '../../../core/gas/bundle-gas.js';
6
+ import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
7
+ import { ADDRESSES, ZERO_ADDRESS } from '../../../core/constants/index.js';
8
+ import { FourClient } from '../../../core/clients/four.js';
9
+ import { getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount, } from '../../config-helpers.js';
10
+ import { signBribeTransaction } from '../../../core/sign-context-helpers.js';
11
+ import { createChainContext, loginFourClient, resolveTokenImage } from '../core-helpers.js';
12
+ import { TM2_ABI, PLATFORM_CREATE_FEE } from './constants.js';
13
+ export async function createTokenWithBundleBuyMerkle(params) {
14
+ const { privateKeys, buyAmounts, tokenInfo, config } = params;
15
+ // ⚠️ 限制: 只支持创建者买入,不支持其他钱包
16
+ if (privateKeys.length !== 1) {
17
+ throw new Error('只支持创建者买入,privateKeys 只能有1个元素');
18
+ }
19
+ if (buyAmounts.length !== 1) {
20
+ throw new Error('只支持买入一次,buyAmounts 只能有1个元素');
21
+ }
22
+ const creatorKey = privateKeys[0];
23
+ // ✅ 使用公共 BSC RPC 节点(支持浏览器 CORS)
24
+ // 48.club 的 RPC 不支持浏览器跨域访问,所以使用公共节点进行余额查询和 gas 估算
25
+ const rpcUrl = config.rpcUrl || 'https://bsc-dataseed.binance.org';
26
+ const { provider, chainId } = createChainContext(rpcUrl);
27
+ const devWallet = new Wallet(creatorKey, provider);
28
+ const fourClient = new FourClient({ baseUrl: config.fourApiUrl });
29
+ const accessToken = await loginFourClient(devWallet, fourClient);
30
+ const imgUrl = await resolveTokenImage(fourClient, tokenInfo, accessToken);
31
+ // ✅ 兼容:历史调用可能把 Dev 首买金额塞在 buyAmounts[0],而不是 tokenInfo.preSale
32
+ // Four 官方 API/链上 createArg 使用 preSale 表达“创建者预购金额”
33
+ const effectivePreSaleStr = tokenInfo.preSale && String(tokenInfo.preSale).trim().length > 0
34
+ ? String(tokenInfo.preSale)
35
+ : String(buyAmounts[0] ?? '0');
36
+ const createResp = await fourClient.createToken(accessToken, {
37
+ name: tokenInfo.name,
38
+ shortName: tokenInfo.symbol,
39
+ desc: tokenInfo.description,
40
+ imgUrl,
41
+ launchTime: Date.now(),
42
+ label: tokenInfo.label || 'Meme',
43
+ webUrl: tokenInfo.webUrl,
44
+ twitterUrl: tokenInfo.twitterUrl,
45
+ telegramUrl: tokenInfo.telegramUrl,
46
+ preSale: effectivePreSaleStr || '0',
47
+ onlyMPC: false,
48
+ // ✅ AntiSniperFeeMode(开盘高税模式)
49
+ ...(tokenInfo.feePlan ? { feePlan: true } : {}),
50
+ // ✅ 税币配置(Tax Token, creatorType=5)
51
+ ...(tokenInfo.tokenTaxInfo ? { tokenTaxInfo: tokenInfo.tokenTaxInfo } : {}),
52
+ lpTradingFee: 0.0025,
53
+ symbol: 'BNB',
54
+ totalSupply: 1000000000,
55
+ raisedAmount: 24,
56
+ saleRate: 0.8,
57
+ reserveRate: 0,
58
+ funGroup: false,
59
+ clickFun: false,
60
+ });
61
+ const gasPrice = await getOptimizedGasPrice(provider, getGasPriceConfig(config));
62
+ const nonceManager = new NonceManager(provider);
63
+ const txType = getTxType(config);
64
+ const signedTxs = [];
65
+ const tmCreateAddr = ADDRESSES.BSC.TokenManagerOriginal;
66
+ // ✅ 单笔交易: 和 Four.meme 官网一样
67
+ // 计算利润
68
+ const extractProfit = shouldExtractProfit();
69
+ // ✅ 对 create 流程来说,“买入金额”就是 preSale(创建者预购)
70
+ const originalBuyAmount = ethers.parseEther(effectivePreSaleStr || '0');
71
+ const profitAmount = extractProfit ? calculateProfit(originalBuyAmount).profit : 0n;
72
+ // ✅ 获取贿赂金额
73
+ const bribeAmount = getBribeAmount(config);
74
+ const needBribeTx = bribeAmount > 0n;
75
+ const b0AmountWei = ethers.parseEther(params.b0Amount ?? '0');
76
+ const preSaleWei = effectivePreSaleStr ? ethers.parseEther(effectivePreSaleStr) : 0n;
77
+ // ✅ 关键修复:
78
+ // createToken 的预购金额由 createArg.preSale 决定;因此这里只需要支付:创建费 + b0Amount + preSale
79
+ // 不要把“其它买入金额”额外塞进 msg.value,否则会被合约退回,造成“看起来没买到”的误解。
80
+ const valueWei = PLATFORM_CREATE_FEE + b0AmountWei + preSaleWei;
81
+ const tmCreate = new ethers.Contract(tmCreateAddr, TM2_ABI, devWallet);
82
+ const createTxUnsigned = await tmCreate.createToken.populateTransaction(createResp.createArg, createResp.signature, {
83
+ value: valueWei,
84
+ });
85
+ // ✅ 贿赂交易放在首位(由 devWallet 发送)
86
+ let bribeNonce;
87
+ if (needBribeTx) {
88
+ bribeNonce = await nonceManager.getNextNonce(devWallet);
89
+ signedTxs.push(await signBribeTransaction(devWallet, bribeAmount, bribeNonce, gasPrice, chainId, txType));
90
+ }
91
+ const createTxRequest = {
92
+ ...createTxUnsigned,
93
+ from: devWallet.address,
94
+ nonce: await nonceManager.getNextNonce(devWallet),
95
+ gasLimit: getGasLimit(config, 1500000),
96
+ gasPrice,
97
+ chainId,
98
+ type: getTxType(config),
99
+ value: valueWei,
100
+ };
101
+ signedTxs.push(await devWallet.signTransaction(createTxRequest));
102
+ // ✅ 利润多跳转账(强制 2 跳中转)
103
+ let profitHopWallets;
104
+ if (extractProfit && profitAmount > 0n) {
105
+ const profitNonce = await nonceManager.getNextNonce(devWallet);
106
+ const profitHopResult = await buildProfitHopTransactions({
107
+ provider,
108
+ payerWallet: devWallet,
109
+ profitAmount,
110
+ profitRecipient: getProfitRecipient(),
111
+ hopCount: PROFIT_HOP_COUNT,
112
+ gasPrice,
113
+ chainId,
114
+ txType,
115
+ startNonce: profitNonce,
116
+ });
117
+ signedTxs.push(...profitHopResult.signedTransactions);
118
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
119
+ }
120
+ nonceManager.clearTemp();
121
+ // ⚠️ 只返回签名交易,不提交
122
+ // 构建元数据
123
+ const metadata = extractProfit && profitAmount > 0n
124
+ ? {
125
+ totalBuyAmount: ethers.formatEther(originalBuyAmount),
126
+ profitAmount: ethers.formatEther(profitAmount),
127
+ profitRecipient: getProfitRecipient(),
128
+ buyerCount: 1,
129
+ }
130
+ : undefined;
131
+ return {
132
+ signedTransactions: signedTxs,
133
+ tokenAddress: ZERO_ADDRESS, // ⚠️ 占位符,实际地址需要等交易确认后从事件解析
134
+ profitHopWallets, // ✅ 返回利润多跳钱包
135
+ metadata,
136
+ };
137
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Four.meme Bundle 核心方法 barrel
3
+ *
4
+ * 原超长文件按职责拆分为:
5
+ * - constants.ts:常量与扩展 ABI
6
+ * - create-token.ts:创建代币 + 创建者买入
7
+ * - buy-flow.ts:批量买入流程
8
+ * - sell-flow.ts:批量卖出流程
9
+ *
10
+ * 对外 export 符号与路径保持不变。
11
+ */
12
+ export { createTokenWithBundleBuyMerkle } from './create-token.js';
13
+ export { batchBuyWithBundleMerkle } from './buy-flow.js';
14
+ export { batchSellWithBundleMerkle } from './sell-flow.js';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Four.meme Bundle 核心方法 barrel
3
+ *
4
+ * 原超长文件按职责拆分为:
5
+ * - constants.ts:常量与扩展 ABI
6
+ * - create-token.ts:创建代币 + 创建者买入
7
+ * - buy-flow.ts:批量买入流程
8
+ * - sell-flow.ts:批量卖出流程
9
+ *
10
+ * 对外 export 符号与路径保持不变。
11
+ */
12
+ export { createTokenWithBundleBuyMerkle } from './create-token.js';
13
+ export { batchBuyWithBundleMerkle } from './buy-flow.js';
14
+ export { batchSellWithBundleMerkle } from './sell-flow.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Four.meme Bundle 核心方法 — 批量卖出流程
3
+ */
4
+ import type { FourBatchSellSignParams, FourBatchSellMerkleResult } from '../types/index.js';
5
+ export declare function batchSellWithBundleMerkle(params: FourBatchSellSignParams): Promise<FourBatchSellMerkleResult>;
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Four.meme Bundle 核心方法 — 批量卖出流程
3
+ */
4
+ import { ethers, Contract, Interface } from 'ethers';
5
+ import { getGasLimit } from '../../../core/gas/bundle-gas.js';
6
+ import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
7
+ import { ADDRESSES } from '../../../core/constants/index.js';
8
+ import { MULTICALL3_ABI, ERC20_ABI } from '../../../abis/common.js';
9
+ import { getBundleErrorMessage } from '../../errors.js';
10
+ import { getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount, } from '../../config-helpers.js';
11
+ import { createSignProvider, signBribeTransaction } from '../../../core/sign-context-helpers.js';
12
+ import { trySell } from '../../../domains/four/contracts/tm.js';
13
+ import { createChainContext, createWallets } from '../core-helpers.js';
14
+ import { TokenManagerHelper3 as Helper3Abi } from '../../../abis/contracts/index.js';
15
+ import { TM2_ABI, MULTICALL3_ADDRESS } from './constants.js';
16
+ export async function batchSellWithBundleMerkle(params) {
17
+ const { privateKeys, sellAmounts, tokenAddress, minOutputAmounts, config } = params;
18
+ if (privateKeys.length === 0 || sellAmounts.length !== privateKeys.length) {
19
+ throw new Error(getBundleErrorMessage('SELL_KEY_AMOUNT_MISMATCH'));
20
+ }
21
+ const { provider, chainId } = createChainContext(config.rpcUrl);
22
+ const txType = getTxType(config);
23
+ const sellers = createWallets(privateKeys, provider);
24
+ // ✅ 优化:并行初始化 nonceManager 和获取 gasPrice
25
+ const [nonceManager, gasPrice] = await Promise.all([
26
+ Promise.resolve(new NonceManager(provider)),
27
+ getOptimizedGasPrice(provider, getGasPriceConfig(config)),
28
+ ]);
29
+ const sellFlow = await executeSellFlow({
30
+ wallets: sellers,
31
+ sellAmounts,
32
+ tokenAddress,
33
+ minOutputAmounts,
34
+ config,
35
+ provider,
36
+ nonceManager,
37
+ contractAddress: ADDRESSES.BSC.TokenManagerOriginal,
38
+ gasPrice,
39
+ chainId,
40
+ rpcUrl: config.rpcUrl,
41
+ txType,
42
+ });
43
+ nonceManager.clearTemp();
44
+ return {
45
+ signedTransactions: sellFlow.signedTxs,
46
+ profitHopWallets: sellFlow.profitHopWallets, // ✅ 返回利润多跳钱包
47
+ };
48
+ }
49
+ async function executeSellFlow(options) {
50
+ const { wallets, sellAmounts, tokenAddress, minOutputAmounts, config, provider, nonceManager, contractAddress, gasPrice, chainId, rpcUrl, txType, } = options;
51
+ const amountsWei = sellAmounts.map((amount) => ethers.parseUnits(amount, 18));
52
+ const finalGasLimit = getGasLimit(config, 800000);
53
+ const extractProfit = shouldExtractProfit();
54
+ // ✅ 获取贿赂金额
55
+ const bribeAmount = getBribeAmount(config);
56
+ const needBribeTx = bribeAmount > 0n;
57
+ // ✅ 优化:并行执行 resolveSellOutputs、ensureSellerBalances 和批量获取 nonces(已移除授权检查)
58
+ const [sellOutputs, , nonces] = await Promise.all([
59
+ resolveSellOutputs({
60
+ minOutputAmounts,
61
+ sellers: wallets,
62
+ amountsWei,
63
+ rpcUrl,
64
+ tokenAddress,
65
+ }),
66
+ ensureSellerBalances({ provider, tokenAddress, sellers: wallets, amountsWei }),
67
+ nonceManager.getNextNoncesForWallets(wallets), // ✅ 批量获取 nonce(JSON-RPC 批量请求)
68
+ ]);
69
+ // ✅ 找出收益最多的钱包作为 payer(贿赂和利润都由它发送)
70
+ const { totalProfit, payer } = summarizeSellProfits(sellOutputs.quotedOutputs, wallets);
71
+ const payerWallet = payer ?? wallets[0];
72
+ const payerIndex = wallets.findIndex((w) => w.address.toLowerCase() === payerWallet.address.toLowerCase());
73
+ // ✅ 贿赂交易放在首位
74
+ const signedTxs = [];
75
+ let bribeNonceOffset = 0;
76
+ if (needBribeTx) {
77
+ const bribeNonce = nonces[payerIndex];
78
+ signedTxs.push(await signBribeTransaction(payerWallet, bribeAmount, bribeNonce, gasPrice, chainId, txType));
79
+ bribeNonceOffset = 1;
80
+ }
81
+ // ✅ 调整 payer 的 nonce(如果有贿赂交易,需要偏移)
82
+ const adjustedNonces = nonces.map((n, i) => (i === payerIndex ? n + bribeNonceOffset : n));
83
+ // ✅ 构建未签名交易
84
+ const unsignedSells = await populateSellTransactions({
85
+ sellers: wallets,
86
+ contractAddress,
87
+ tokenAddress,
88
+ amountsWei,
89
+ minOuts: sellOutputs.minOuts,
90
+ });
91
+ // ✅ 并行签名所有卖出交易
92
+ const signedSells = await Promise.all(unsignedSells.map((unsigned, index) => wallets[index].signTransaction({
93
+ ...unsigned,
94
+ from: wallets[index].address,
95
+ nonce: adjustedNonces[index],
96
+ gasLimit: finalGasLimit,
97
+ gasPrice,
98
+ chainId,
99
+ type: txType,
100
+ })));
101
+ signedTxs.push(...signedSells);
102
+ // ✅ 利润多跳转账(强制 2 跳中转)
103
+ const profitHopWallets = await appendAggregatedProfitTransfer({
104
+ extractProfit,
105
+ totalProfit,
106
+ payer: payerWallet,
107
+ nonceManager,
108
+ provider,
109
+ gasPrice,
110
+ chainId,
111
+ txType,
112
+ signedTxs,
113
+ baseNonce: adjustedNonces[payerIndex] + 1, // ✅ 传入基础 nonce
114
+ });
115
+ return { signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
116
+ }
117
+ /**
118
+ * ✅ 使用 Multicall3 批量获取卖出报价(单次 RPC)
119
+ * 比 Promise.all 更高效,N 个报价只需 1 次网络请求
120
+ */
121
+ async function resolveSellOutputs(params) {
122
+ const { minOutputAmounts, sellers, amountsWei, rpcUrl, tokenAddress } = params;
123
+ // 如果已提供 minOutputAmounts,直接使用,跳过报价查询
124
+ if (minOutputAmounts && minOutputAmounts.length === sellers.length) {
125
+ const minOuts = minOutputAmounts.map((m) => (typeof m === 'string' ? ethers.parseEther(m) : m));
126
+ const quotedOutputs = minOuts.map((value) => (value * 100n) / 95n);
127
+ return { minOuts, quotedOutputs };
128
+ }
129
+ // 如果只有 1 个,直接调用(避免 multicall 开销)
130
+ if (amountsWei.length === 1) {
131
+ try {
132
+ const result = await trySell('BSC', rpcUrl, tokenAddress, amountsWei[0]);
133
+ const quotedOutputs = [result.funds];
134
+ // ✅ 已移除滑点保护:minOuts 固定为 0
135
+ const minOuts = [0n];
136
+ return { minOuts, quotedOutputs };
137
+ }
138
+ catch {
139
+ return { minOuts: [0n], quotedOutputs: [0n] };
140
+ }
141
+ }
142
+ // ✅ 使用 Multicall3 批量获取报价
143
+ const provider = createSignProvider(rpcUrl, 56, 'BSC');
144
+ const helper3Address = ADDRESSES.BSC.TokenManagerHelper3;
145
+ const helper3Iface = new Interface(Helper3Abi);
146
+ const multicall = new Contract(MULTICALL3_ADDRESS, MULTICALL3_ABI, provider);
147
+ // 构建批量调用
148
+ const calls = amountsWei.map((amount) => ({
149
+ target: helper3Address,
150
+ allowFailure: true, // 允许单个失败
151
+ callData: helper3Iface.encodeFunctionData('trySell', [tokenAddress, amount]),
152
+ }));
153
+ try {
154
+ const results = await multicall.aggregate3.staticCall(calls);
155
+ const quotedOutputs = results.map((r) => {
156
+ if (r.success && r.returnData && r.returnData !== '0x') {
157
+ try {
158
+ const decoded = helper3Iface.decodeFunctionResult('trySell', r.returnData);
159
+ // trySell 返回 (tokenManager, quote, funds, fee),我们需要 funds
160
+ return BigInt(decoded.funds);
161
+ }
162
+ catch {
163
+ return 0n;
164
+ }
165
+ }
166
+ return 0n;
167
+ });
168
+ // ✅ 已移除滑点保护:minOuts 固定为 0
169
+ const minOuts = quotedOutputs.map(() => 0n);
170
+ return { minOuts, quotedOutputs };
171
+ }
172
+ catch {
173
+ // Multicall 失败,回退到并行调用
174
+ const quotedOutputs = await Promise.all(amountsWei.map(async (amount) => {
175
+ try {
176
+ const result = await trySell('BSC', rpcUrl, tokenAddress, amount);
177
+ return result.funds;
178
+ }
179
+ catch {
180
+ return 0n;
181
+ }
182
+ }));
183
+ // ✅ 已移除滑点保护:minOuts 固定为 0
184
+ const minOuts = quotedOutputs.map(() => 0n);
185
+ return { minOuts, quotedOutputs };
186
+ }
187
+ }
188
+ async function ensureSellerBalances(params) {
189
+ const { provider, tokenAddress, sellers, amountsWei } = params;
190
+ const tokenContract = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
191
+ const balances = await Promise.all(sellers.map((wallet) => tokenContract.balanceOf(wallet.address)));
192
+ for (let i = 0; i < sellers.length; i++) {
193
+ if (balances[i] < amountsWei[i]) {
194
+ throw new Error(`钱包 ${i} 代币余额不足:需要 ${ethers.formatUnits(amountsWei[i], 18)},实际 ${ethers.formatUnits(balances[i], 18)}`);
195
+ }
196
+ }
197
+ }
198
+ async function populateSellTransactions(params) {
199
+ const { sellers, contractAddress, tokenAddress, amountsWei, minOuts } = params;
200
+ const contracts = sellers.map((wallet) => new ethers.Contract(contractAddress, TM2_ABI, wallet));
201
+ return Promise.all(contracts.map((contract, index) => contract.sellToken.populateTransaction(0n, tokenAddress, amountsWei[index], minOuts[index])));
202
+ }
203
+ function summarizeSellProfits(quotedOutputs, sellers) {
204
+ let totalProfit = 0n;
205
+ let maxRevenue = 0n;
206
+ let payer;
207
+ quotedOutputs.forEach((output, index) => {
208
+ if (output <= 0n) {
209
+ return;
210
+ }
211
+ const { profit } = calculateProfit(output);
212
+ totalProfit += profit;
213
+ if (output > maxRevenue) {
214
+ maxRevenue = output;
215
+ payer = sellers[index];
216
+ }
217
+ });
218
+ return { totalProfit, payer };
219
+ }
220
+ async function appendAggregatedProfitTransfer(params) {
221
+ const { extractProfit, totalProfit, payer, nonceManager, provider, gasPrice, chainId, txType, signedTxs, baseNonce } = params;
222
+ if (!extractProfit || totalProfit <= 0n || !payer) {
223
+ return undefined;
224
+ }
225
+ // ✅ 利润多跳转账(强制 2 跳中转)
226
+ const profitNonce = baseNonce ?? (await nonceManager.getNextNonce(payer));
227
+ const profitHopResult = await buildProfitHopTransactions({
228
+ provider,
229
+ payerWallet: payer,
230
+ profitAmount: totalProfit,
231
+ profitRecipient: getProfitRecipient(),
232
+ hopCount: PROFIT_HOP_COUNT,
233
+ gasPrice,
234
+ chainId,
235
+ txType,
236
+ startNonce: profitNonce,
237
+ });
238
+ signedTxs.push(...profitHopResult.signedTransactions);
239
+ return profitHopResult.hopWallets; // ✅ 返回利润多跳钱包
240
+ }
@@ -1,7 +1,7 @@
1
1
  import { Wallet } from 'ethers';
2
2
  import { CHAINS } from '../../core/constants/index.js';
3
3
  import { buildLoginMessage } from '../../core/clients/four.js';
4
- import { createSignProvider } from '../sign-context-helpers.js';
4
+ import { createSignProvider } from '../../core/sign-context-helpers.js';
5
5
  import { getBundleErrorMessage } from '../errors.js';
6
6
  export const CORE_CHAIN_ID = CHAINS.BSC.chainId;
7
7
  export function createChainContext(rpcUrl) {
@@ -1,4 +1,7 @@
1
- import type { FourCreateWithBundleBuySignParams, FourCreateWithBundleBuyMerkleResult, FourBatchBuySignParams, FourBatchBuyMerkleResult, FourBatchSellSignParams, FourBatchSellMerkleResult } from './types.js';
2
- export declare function createTokenWithBundleBuyMerkle(params: FourCreateWithBundleBuySignParams): Promise<FourCreateWithBundleBuyMerkleResult>;
3
- export declare function batchBuyWithBundleMerkle(params: FourBatchBuySignParams): Promise<FourBatchBuyMerkleResult>;
4
- export declare function batchSellWithBundleMerkle(params: FourBatchSellSignParams): Promise<FourBatchSellMerkleResult>;
1
+ /**
2
+ * Four.meme Bundle 核心方法
3
+ *
4
+ * 原超长文件按职责拆分为 core/ 目录下的多个子文件,
5
+ * 对外 export 符号与路径保持不变(见 core/index.ts)。
6
+ */
7
+ export * from './core/index.js';