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,465 +1,7 @@
1
- import { ethers, Wallet } from 'ethers';
2
- import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../utils/bundle-helpers.js';
3
- import { ADDRESSES, BLOCKRAZOR_BUILDER_EOA, CHAINS } from '../../core/constants/index.js';
4
- import { TM2_ABI } from '../../abis/common.js';
5
- import { getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, calculateBatchProfit, getProfitRecipient, getBribeAmount, } from '../config-helpers.js';
6
- import { trySell } from '../../domains/four/contracts/tm.js';
7
- import { createSignProvider } from '../sign-context-helpers.js';
8
- const CHAIN_ID = CHAINS.BSC.chainId;
9
- const DEFAULT_GAS_LIMIT = 800000;
10
- // ✅ TM2_ABI 从公共模块导入
11
- // ✅ 本地 getGasLimit(FourAnyConfig 支持 bigint gasLimit)
12
- function getGasLimit(config, defaultGas = DEFAULT_GAS_LIMIT) {
13
- if (config.gasLimit !== undefined) {
14
- return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
15
- }
16
- const multiplier = config.gasLimitMultiplier ?? 1.0;
17
- return BigInt(Math.ceil(defaultGas * multiplier));
18
- }
19
1
  /**
20
- * 私有购买(单笔)(仅签名版本 - 不依赖 Merkle)
21
- * ✅ 精简版:只负责签名交易,不提交到 Merkle
22
- * ✅ 优化:并行获取 gasPrice 和 nonce
2
+ * 私有交易(仅签名版本 - 不依赖 Merkle)
3
+ *
4
+ * 原超长文件按职责拆分为 private/ 目录下的多个子文件,
5
+ * 对外 export 符号与路径保持不变(见 private/index.ts)。
23
6
  */
24
- export async function fourPrivateBuyMerkle(params) {
25
- const { privateKey, tokenAddress, funds, to, config } = params;
26
- // ✅ 直接使用传入的 RPC URL 创建 provider(不依赖 Merkle)
27
- const provider = createSignProvider(config.rpcUrl, CHAIN_ID, 'BSC');
28
- const wallet = new Wallet(privateKey, provider);
29
- const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
30
- const txType = getTxType(config);
31
- const gasLimit = getGasLimit(config);
32
- const originalFundsWei = ethers.parseEther(funds);
33
- // ✅ 利润提取配置(同步计算)
34
- const extractProfit = shouldExtractProfit();
35
- let profitWei = 0n;
36
- let actualFundsWei = originalFundsWei;
37
- if (extractProfit) {
38
- const { profit, remaining } = calculateProfit(originalFundsWei);
39
- profitWei = profit;
40
- actualFundsWei = remaining;
41
- }
42
- const tm2 = new ethers.Contract(tmAddr, TM2_ABI, wallet);
43
- // ✅ 获取贿赂金额
44
- const bribeAmount = getBribeAmount(config);
45
- const needBribeTx = bribeAmount > 0n;
46
- const needProfitTx = extractProfit && profitWei > 0n;
47
- // ✅ 优化:并行获取 gasPrice、nonce 和构建未签名交易
48
- const [gasPrice, baseNonce, unsigned] = await Promise.all([
49
- getOptimizedGasPrice(provider, getGasPriceConfig(config)),
50
- wallet.getNonce(),
51
- tm2.buyTokenAMAP.populateTransaction(0n, tokenAddress, to ?? wallet.address, actualFundsWei, 0n, {
52
- value: actualFundsWei,
53
- }),
54
- ]);
55
- // ✅ 分配 nonces:贿赂 → 买入 → 利润
56
- let nonceIdx = 0;
57
- const bribeNonce = needBribeTx ? baseNonce + nonceIdx++ : undefined;
58
- const buyNonce = baseNonce + nonceIdx++;
59
- const profitNonce = needProfitTx ? baseNonce + nonceIdx : undefined;
60
- // ✅ 并行签名所有交易(贿赂、买入、利润)
61
- const signPromises = [];
62
- // 贿赂交易
63
- if (needBribeTx && bribeNonce !== undefined) {
64
- signPromises.push(wallet.signTransaction({
65
- to: BLOCKRAZOR_BUILDER_EOA,
66
- value: bribeAmount,
67
- nonce: bribeNonce,
68
- gasPrice,
69
- gasLimit: 21000n,
70
- chainId: CHAIN_ID,
71
- type: txType,
72
- }));
73
- }
74
- // 买入交易
75
- signPromises.push(wallet.signTransaction({
76
- ...unsigned,
77
- from: wallet.address,
78
- nonce: buyNonce,
79
- gasLimit,
80
- gasPrice,
81
- chainId: CHAIN_ID,
82
- type: txType,
83
- value: actualFundsWei,
84
- }));
85
- // ✅ 并行签名完成后按顺序返回
86
- const signedTxs = await Promise.all(signPromises);
87
- // ✅ 利润多跳转账(强制 2 跳中转)
88
- let profitHopWallets;
89
- if (needProfitTx && profitNonce !== undefined) {
90
- const profitHopResult = await buildProfitHopTransactions({
91
- provider,
92
- payerWallet: wallet,
93
- profitAmount: profitWei,
94
- profitRecipient: getProfitRecipient(),
95
- hopCount: PROFIT_HOP_COUNT,
96
- gasPrice,
97
- chainId: CHAIN_ID,
98
- txType,
99
- startNonce: profitNonce,
100
- });
101
- signedTxs.push(...profitHopResult.signedTransactions);
102
- profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
103
- }
104
- return {
105
- signedTransactions: signedTxs,
106
- profitHopWallets, // ✅ 返回利润多跳钱包
107
- };
108
- }
109
- /**
110
- * 私有卖出(单笔)(仅签名版本 - 不依赖 Merkle)
111
- * ✅ 精简版:只负责签名交易,不提交到 Merkle
112
- * ✅ 自动检查授权,智能处理授权+卖出
113
- * ✅ 优化:并行获取 gasPrice、allowance、nonce
114
- */
115
- export async function fourPrivateSellMerkle(params) {
116
- const { privateKey, tokenAddress, amount, minFunds, config } = params;
117
- // ✅ 直接使用传入的 RPC URL 创建 provider(不依赖 Merkle)
118
- const provider = createSignProvider(config.rpcUrl, CHAIN_ID, 'BSC');
119
- const wallet = new Wallet(privateKey, provider);
120
- const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
121
- const txType = getTxType(config);
122
- const sellGasLimit = getGasLimit(config);
123
- const amountWei = ethers.parseUnits(amount, 18);
124
- const minOut = minFunds ?? 0n;
125
- const tm2 = new ethers.Contract(tmAddr, TM2_ABI, wallet);
126
- // ✅ 优化:并行获取 gasPrice、nonce 和构建未签名交易(已移除授权检查)
127
- const [gasPrice, sellNonce, sellUnsigned] = await Promise.all([
128
- getOptimizedGasPrice(provider, getGasPriceConfig(config)),
129
- wallet.getNonce(),
130
- tm2.sellToken.populateTransaction(0n, tokenAddress, amountWei, 0n), // ✅ 已移除滑点保护:minOut 固定为 0
131
- ]);
132
- // ✅ 已移除授权检查(前端负责确保授权)
133
- // ✅ 利润计算(同步)
134
- const extractProfit = shouldExtractProfit();
135
- const { profit } = extractProfit ? calculateProfit(minOut) : { profit: 0n };
136
- // ✅ 获取贿赂金额
137
- const bribeAmount = getBribeAmount(config);
138
- const needBribeTx = bribeAmount > 0n;
139
- const needProfitTx = extractProfit && profit > 0n;
140
- // ✅ 分配 nonces:贿赂 → 卖出 → 利润
141
- let nonceIdx = 0;
142
- const bribeNonce = needBribeTx ? sellNonce + nonceIdx++ : undefined;
143
- const actualSellNonce = sellNonce + nonceIdx++;
144
- const profitNonce = needProfitTx ? sellNonce + nonceIdx : undefined;
145
- // ✅ 并行签名所有交易(贿赂、卖出、利润)
146
- const signPromises = [];
147
- // 贿赂交易
148
- if (needBribeTx && bribeNonce !== undefined) {
149
- signPromises.push(wallet.signTransaction({
150
- to: BLOCKRAZOR_BUILDER_EOA,
151
- value: bribeAmount,
152
- nonce: bribeNonce,
153
- gasPrice,
154
- gasLimit: 21000n,
155
- chainId: CHAIN_ID,
156
- type: txType,
157
- }));
158
- }
159
- // 卖出交易
160
- signPromises.push(wallet.signTransaction({
161
- ...sellUnsigned,
162
- from: wallet.address,
163
- nonce: actualSellNonce,
164
- gasLimit: sellGasLimit,
165
- gasPrice,
166
- chainId: CHAIN_ID,
167
- type: txType,
168
- value: 0n,
169
- }));
170
- // ✅ 并行签名完成后按顺序返回
171
- const signedTxs = await Promise.all(signPromises);
172
- // ✅ 利润多跳转账(强制 2 跳中转)
173
- let profitHopWallets;
174
- if (needProfitTx && profitNonce !== undefined) {
175
- const profitHopResult = await buildProfitHopTransactions({
176
- provider,
177
- payerWallet: wallet,
178
- profitAmount: profit,
179
- profitRecipient: getProfitRecipient(),
180
- hopCount: PROFIT_HOP_COUNT,
181
- gasPrice,
182
- chainId: CHAIN_ID,
183
- txType,
184
- startNonce: profitNonce,
185
- });
186
- signedTxs.push(...profitHopResult.signedTransactions);
187
- profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
188
- }
189
- return {
190
- signedTransactions: signedTxs,
191
- profitHopWallets, // ✅ 返回利润多跳钱包
192
- };
193
- }
194
- /**
195
- * 批量私有购买(仅签名版本 - 不依赖 Merkle)
196
- * ✅ 精简版:只负责签名交易,不提交到 Merkle
197
- * ✅ 优化:并行获取 gasPrice 和 nonces,批量构建交易
198
- */
199
- export async function fourBatchPrivateBuyMerkle(params) {
200
- const { privateKeys, fundsList, tokenAddress, config } = params;
201
- if (privateKeys.length !== fundsList.length) {
202
- throw new Error('privateKeys and fundsList length mismatch');
203
- }
204
- // ✅ 直接使用传入的 RPC URL 创建 provider(不依赖 Merkle)
205
- const provider = createSignProvider(config.rpcUrl, CHAIN_ID, 'BSC');
206
- const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
207
- const txType = getTxType(config);
208
- const finalGasLimit = getGasLimit(config);
209
- const wallets = privateKeys.map((k) => new Wallet(k, provider));
210
- const originalAmountsWei = fundsList.map((a) => ethers.parseEther(a));
211
- // ✅ 利润提取配置(同步计算)
212
- const extractProfit = shouldExtractProfit();
213
- const { totalProfit, remainingAmounts } = calculateBatchProfit(originalAmountsWei);
214
- const actualAmountsWei = remainingAmounts;
215
- // ✅ 获取贿赂金额
216
- const bribeAmount = getBribeAmount(config);
217
- const needBribeTx = bribeAmount > 0n;
218
- // ✅ 找出投入金额最多的钱包(作为贿赂和利润支付者)- 同步计算
219
- let maxFundsIndex = 0;
220
- let maxFunds = originalAmountsWei[0];
221
- for (let i = 1; i < originalAmountsWei.length; i++) {
222
- if (originalAmountsWei[i] > maxFunds) {
223
- maxFunds = originalAmountsWei[i];
224
- maxFundsIndex = i;
225
- }
226
- }
227
- const tm2Contracts = wallets.map((w) => new ethers.Contract(tmAddr, TM2_ABI, w));
228
- const nonceManager = new NonceManager(provider);
229
- const needProfitTx = extractProfit && totalProfit > 0n;
230
- // ✅ 计算 payer 需要的 nonce 数量:贿赂(可选) + 买入 + 利润(可选)
231
- const payerNonceCount = 1 + (needBribeTx ? 1 : 0) + (needProfitTx ? 1 : 0);
232
- // ✅ 优化:并行获取 gasPrice、nonces 和构建未签名交易
233
- const [gasPrice, unsignedList, noncesResult] = await Promise.all([
234
- getOptimizedGasPrice(provider, getGasPriceConfig(config)),
235
- Promise.all(tm2Contracts.map((c, i) => c.buyTokenAMAP.populateTransaction(0n, tokenAddress, wallets[i].address, actualAmountsWei[i], 0n, {
236
- value: actualAmountsWei[i],
237
- }))),
238
- (async () => {
239
- if (payerNonceCount > 1) {
240
- // payer 需要多个连续 nonce
241
- const payerNonces = await nonceManager.getNextNonceBatch(wallets[maxFundsIndex], payerNonceCount);
242
- // 其他钱包各需要 1 个 nonce
243
- const otherWallets = wallets.filter((_, i) => i !== maxFundsIndex);
244
- const otherNonces = otherWallets.length > 0 ? await nonceManager.getNextNoncesForWallets(otherWallets) : [];
245
- // 组装最终的 nonces 数组(保持原顺序)
246
- const nonces = [];
247
- let otherIdx = 0;
248
- let nonceIdx = 0;
249
- const bribeNonce = needBribeTx ? payerNonces[nonceIdx++] : undefined;
250
- for (let i = 0; i < wallets.length; i++) {
251
- if (i === maxFundsIndex) {
252
- nonces.push(payerNonces[nonceIdx++]); // 买入交易
253
- }
254
- else {
255
- nonces.push(otherNonces[otherIdx++]);
256
- }
257
- }
258
- const profitNonce = needProfitTx ? payerNonces[nonceIdx] : undefined;
259
- return { nonces, bribeNonce, profitNonce };
260
- }
261
- else {
262
- // 所有钱包各 1 个 nonce
263
- const nonces = await nonceManager.getNextNoncesForWallets(wallets);
264
- return { nonces, bribeNonce: undefined, profitNonce: undefined };
265
- }
266
- })(),
267
- ]);
268
- const { nonces, bribeNonce, profitNonce } = noncesResult;
269
- // ✅ 贿赂交易放在首位(提高 BlockRazor 打包优先级)
270
- const signedTxs = [];
271
- if (needBribeTx && bribeNonce !== undefined) {
272
- const bribeTx = await wallets[maxFundsIndex].signTransaction({
273
- to: BLOCKRAZOR_BUILDER_EOA,
274
- value: bribeAmount,
275
- nonce: bribeNonce,
276
- gasPrice,
277
- gasLimit: 21000n,
278
- chainId: CHAIN_ID,
279
- type: txType,
280
- });
281
- signedTxs.push(bribeTx);
282
- }
283
- // ✅ 并行签名所有买入交易
284
- const signedList = await Promise.all(unsignedList.map((unsigned, i) => wallets[i].signTransaction({
285
- ...unsigned,
286
- from: wallets[i].address,
287
- nonce: nonces[i],
288
- gasLimit: finalGasLimit,
289
- gasPrice,
290
- chainId: CHAIN_ID,
291
- type: txType,
292
- value: actualAmountsWei[i],
293
- })));
294
- signedTxs.push(...signedList);
295
- // ✅ 利润多跳转账(强制 2 跳中转)
296
- let profitHopWallets;
297
- if (needProfitTx && profitNonce !== undefined) {
298
- const profitHopResult = await buildProfitHopTransactions({
299
- provider,
300
- payerWallet: wallets[maxFundsIndex],
301
- profitAmount: totalProfit,
302
- profitRecipient: getProfitRecipient(),
303
- hopCount: PROFIT_HOP_COUNT,
304
- gasPrice,
305
- chainId: CHAIN_ID,
306
- txType,
307
- startNonce: profitNonce,
308
- });
309
- signedTxs.push(...profitHopResult.signedTransactions);
310
- profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
311
- }
312
- nonceManager.clearTemp();
313
- return {
314
- signedTransactions: signedTxs,
315
- profitHopWallets, // ✅ 返回利润多跳钱包
316
- };
317
- }
318
- /**
319
- * 批量私有卖出(仅签名版本 - 不依赖 Merkle)
320
- * ✅ 精简版:只负责签名交易,不提交到 Merkle
321
- * ✅ 自动包含授权交易,无需前端单独调用
322
- * ✅ 优化:并行获取所有查询数据,批量获取 nonces
323
- */
324
- export async function fourBatchPrivateSellMerkle(params) {
325
- const { privateKeys, amounts, tokenAddress, config, minFundsEach } = params;
326
- if (privateKeys.length !== amounts.length) {
327
- throw new Error('privateKeys and amounts length mismatch');
328
- }
329
- // ✅ 直接使用传入的 RPC URL 创建 provider(不依赖 Merkle)
330
- const provider = createSignProvider(config.rpcUrl, CHAIN_ID, 'BSC');
331
- const tmAddr = ADDRESSES.BSC.TokenManagerOriginal;
332
- const txType = getTxType(config);
333
- const sellGasLimit = getGasLimit(config);
334
- const wallets = privateKeys.map((k) => new Wallet(k, provider));
335
- const amountsWei = amounts.map((a) => ethers.parseUnits(a, 18));
336
- const rpcUrl = config.rpcUrl;
337
- // ✅ 优化:并行获取 gasPrice 和 quotedOutputs(已移除授权和余额检查)
338
- const [gasPrice, quotedOutputs] = await Promise.all([
339
- getOptimizedGasPrice(provider, getGasPriceConfig(config)),
340
- // 获取预期收益(用于计算利润)
341
- minFundsEach !== undefined
342
- ? Promise.resolve((() => {
343
- const minOutWei = typeof minFundsEach === 'string' ? ethers.parseEther(minFundsEach) : minFundsEach;
344
- return new Array(wallets.length).fill((minOutWei * 100n) / 95n);
345
- })())
346
- : Promise.all(amountsWei.map(async (amount) => {
347
- try {
348
- const result = await trySell('BSC', rpcUrl, tokenAddress, amount);
349
- return result.funds;
350
- }
351
- catch {
352
- return 0n;
353
- }
354
- })),
355
- ]);
356
- // ✅ 已移除滑点保护:minOuts 固定为 0
357
- const minOuts = new Array(wallets.length).fill(0n);
358
- // ✅ 计算总利润和找出收益最高的钱包(同步计算)
359
- const extractProfit = shouldExtractProfit();
360
- let totalProfit = 0n;
361
- let maxRevenueIndex = 0;
362
- let maxRevenue = 0n;
363
- if (extractProfit) {
364
- for (let i = 0; i < wallets.length; i++) {
365
- if (quotedOutputs[i] > 0n) {
366
- const { profit } = calculateProfit(quotedOutputs[i]);
367
- totalProfit += profit;
368
- if (quotedOutputs[i] > maxRevenue) {
369
- maxRevenue = quotedOutputs[i];
370
- maxRevenueIndex = i;
371
- }
372
- }
373
- }
374
- }
375
- // ✅ 获取贿赂金额
376
- const bribeAmount = getBribeAmount(config);
377
- const needBribeTx = bribeAmount > 0n;
378
- const tm2Contracts = wallets.map((w) => new ethers.Contract(tmAddr, TM2_ABI, w));
379
- const nonceManager = new NonceManager(provider);
380
- const needProfitTx = extractProfit && totalProfit > 0n;
381
- // ✅ 计算 payer 需要的 nonce 数量:贿赂(可选) + 卖出 + 利润(可选)
382
- const payerNonceCount = 1 + (needBribeTx ? 1 : 0) + (needProfitTx ? 1 : 0);
383
- // ✅ 优化:第二批并行获取 - nonces 和构建未签名交易
384
- const [sellUnsigned, noncesResult] = await Promise.all([
385
- Promise.all(tm2Contracts.map((c, i) => c.sellToken.populateTransaction(0n, tokenAddress, amountsWei[i], minOuts[i]))),
386
- (async () => {
387
- if (payerNonceCount > 1) {
388
- // payer 需要多个连续 nonce
389
- const payerNonces = await nonceManager.getNextNonceBatch(wallets[maxRevenueIndex], payerNonceCount);
390
- // 其他钱包各需要 1 个 nonce
391
- const otherWallets = wallets.filter((_, i) => i !== maxRevenueIndex);
392
- const otherNonces = otherWallets.length > 0 ? await nonceManager.getNextNoncesForWallets(otherWallets) : [];
393
- // 组装最终的 nonces 数组(保持原顺序)
394
- const nonces = [];
395
- let otherIdx = 0;
396
- let nonceIdx = 0;
397
- const bribeNonce = needBribeTx ? payerNonces[nonceIdx++] : undefined;
398
- for (let i = 0; i < wallets.length; i++) {
399
- if (i === maxRevenueIndex) {
400
- nonces.push(payerNonces[nonceIdx++]); // 卖出交易
401
- }
402
- else {
403
- nonces.push(otherNonces[otherIdx++]);
404
- }
405
- }
406
- const profitNonce = needProfitTx ? payerNonces[nonceIdx] : undefined;
407
- return { nonces, bribeNonce, profitNonce };
408
- }
409
- else {
410
- // 所有钱包各 1 个 nonce
411
- const nonces = await nonceManager.getNextNoncesForWallets(wallets);
412
- return { nonces, bribeNonce: undefined, profitNonce: undefined };
413
- }
414
- })(),
415
- ]);
416
- const { nonces, bribeNonce, profitNonce } = noncesResult;
417
- // ✅ 贿赂交易放在首位(提高 BlockRazor 打包优先级)
418
- const signedTxs = [];
419
- if (needBribeTx && bribeNonce !== undefined) {
420
- const bribeTx = await wallets[maxRevenueIndex].signTransaction({
421
- to: BLOCKRAZOR_BUILDER_EOA,
422
- value: bribeAmount,
423
- nonce: bribeNonce,
424
- gasPrice,
425
- gasLimit: 21000n,
426
- chainId: CHAIN_ID,
427
- type: txType,
428
- });
429
- signedTxs.push(bribeTx);
430
- }
431
- // ✅ 并行签名所有卖出交易
432
- const signedSells = await Promise.all(sellUnsigned.map((unsigned, i) => wallets[i].signTransaction({
433
- ...unsigned,
434
- from: wallets[i].address,
435
- nonce: nonces[i],
436
- gasLimit: sellGasLimit,
437
- gasPrice,
438
- chainId: CHAIN_ID,
439
- type: txType,
440
- value: 0n,
441
- })));
442
- signedTxs.push(...signedSells);
443
- // ✅ 利润多跳转账(强制 2 跳中转)
444
- let profitHopWallets;
445
- if (needProfitTx && profitNonce !== undefined) {
446
- const profitHopResult = await buildProfitHopTransactions({
447
- provider,
448
- payerWallet: wallets[maxRevenueIndex],
449
- profitAmount: totalProfit,
450
- profitRecipient: getProfitRecipient(),
451
- hopCount: PROFIT_HOP_COUNT,
452
- gasPrice,
453
- chainId: CHAIN_ID,
454
- txType,
455
- startNonce: profitNonce,
456
- });
457
- signedTxs.push(...profitHopResult.signedTransactions);
458
- profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
459
- }
460
- nonceManager.clearTemp();
461
- return {
462
- signedTransactions: signedTxs,
463
- profitHopWallets, // ✅ 返回利润多跳钱包
464
- };
465
- }
7
+ export * from './private/index.js';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Four.meme 内盘批量换手(Merkle Bundle)— 一卖多买流程
3
+ */
4
+ import type { FourBatchSwapResult, FourBatchSwapSignParams } from '../types/index.js';
5
+ /**
6
+ * Four 内盘批量换手(一卖多买)
7
+ */
8
+ export declare function fourBatchSwapMerkle(params: FourBatchSwapSignParams): Promise<FourBatchSwapResult>;
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Four.meme 内盘批量换手(Merkle Bundle)— 一卖多买流程
3
+ */
4
+ import { ethers, Contract, Wallet } from 'ethers';
5
+ import { countSellerNonceSlots, createFourSwapGasContext, fetchFourSwapSellQuoteAllowanceAndBalances, getFourSwapProfitRateBps, needsTmTokenApproval, planSellerNonces, signTmMaxApprovalTx, } from '../swap-sign-helpers.js';
6
+ import { signBribeTransaction } from '../../../core/sign-context-helpers.js';
7
+ import { calculateSellAmount } from '../../../utils/swap-helpers.js';
8
+ import { NonceManager, getOptimizedGasPrice, getGasPriceConfig, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
9
+ import { getBribeAmount, getProfitRecipient } from '../../config-helpers.js';
10
+ import { TM_ABI, TM_ADDRESS } from '../swap-internal.js';
11
+ /**
12
+ * Four 内盘批量换手(一卖多买)
13
+ */
14
+ export async function fourBatchSwapMerkle(params) {
15
+ const { sellerPrivateKey, sellAmount, sellPercentage, buyerPrivateKeys, tokenAddress, config, startNonces, // ✅ 可选:前端预获取的 nonces
16
+ } = params;
17
+ // ✅ 校验买方数量(最多 24 个)
18
+ const MAX_BUYERS = 24;
19
+ if (buyerPrivateKeys.length === 0) {
20
+ throw new Error('至少需要一个买方钱包');
21
+ }
22
+ if (buyerPrivateKeys.length > MAX_BUYERS) {
23
+ throw new Error(`买方钱包数量超过限制: ${buyerPrivateKeys.length} > ${MAX_BUYERS}`);
24
+ }
25
+ const { chainIdNum, provider, bundleConfig, finalGasLimit, txType } = createFourSwapGasContext(config);
26
+ const seller = new Wallet(sellerPrivateKey, provider);
27
+ const buyers = buyerPrivateKeys.map((pk) => new Wallet(pk, provider));
28
+ const nonceManager = new NonceManager(provider);
29
+ // ✅ 并行获取:卖出数量、gasPrice
30
+ const [sellAmountResult, gasPrice] = await Promise.all([
31
+ calculateSellAmount(provider, tokenAddress, seller.address, sellAmount, sellPercentage),
32
+ getOptimizedGasPrice(provider, getGasPriceConfig(bundleConfig)),
33
+ ]);
34
+ const { amount: sellAmountWei, decimals } = sellAmountResult;
35
+ const { sellFunds: totalBuyerFunds, allowance: currentAllowance, buyerBalances, } = await fetchFourSwapSellQuoteAllowanceAndBalances(provider, tokenAddress, seller.address, sellAmountWei, buyers.map((b) => b.address));
36
+ // ✅ 计算每个买方的买入金额(按比例分配)
37
+ let buyAmountsWei;
38
+ if (params.buyerRatios && params.buyerRatios.length === buyers.length) {
39
+ // 按比例分配
40
+ buyAmountsWei = params.buyerRatios.map((ratio) => {
41
+ const amount = (totalBuyerFunds * BigInt(Math.round(ratio * 10000))) / 10000n;
42
+ return amount;
43
+ });
44
+ }
45
+ else {
46
+ // 平均分配
47
+ const amountPerBuyer = totalBuyerFunds / BigInt(buyers.length);
48
+ buyAmountsWei = buyers.map(() => amountPerBuyer);
49
+ }
50
+ // ✅ 验证所有买方余额
51
+ const reserveGas = ethers.parseEther((config.reserveGasBNB || 0.0005).toString());
52
+ buyers.forEach((buyer, i) => {
53
+ const required = buyAmountsWei[i] + reserveGas;
54
+ if (buyerBalances[i] < required) {
55
+ throw new Error(`买方 ${i + 1} 余额不足: 需要 ${ethers.formatEther(required)} BNB, 实际 ${ethers.formatEther(buyerBalances[i])} BNB`);
56
+ }
57
+ });
58
+ // 检查是否需要授权
59
+ const needApproval = needsTmTokenApproval(currentAllowance, decimals);
60
+ // 利润配置
61
+ const profitRateBps = getFourSwapProfitRateBps(config.userType);
62
+ const profitAmount = totalBuyerFunds > 0n ? (totalBuyerFunds * BigInt(profitRateBps)) / 10000n : 0n;
63
+ // ✅ 获取贿赂金额
64
+ const bribeAmount = getBribeAmount(config);
65
+ const needBribeTx = bribeAmount > 0n;
66
+ // ✅ 并行构建所有交易
67
+ const tmSeller = new Contract(TM_ADDRESS, TM_ABI, seller);
68
+ const [sellUnsigned, ...buyUnsignedList] = await Promise.all([
69
+ // 卖出交易
70
+ tmSeller.sellToken.populateTransaction(0n, tokenAddress, sellAmountWei, 0n),
71
+ // 所有买入交易
72
+ ...buyers.map((buyer, i) => {
73
+ const tmBuyer = new Contract(TM_ADDRESS, TM_ABI, buyer);
74
+ const buyAmount = buyAmountsWei[i];
75
+ return tmBuyer.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyer.address, buyAmount, 0n, {
76
+ value: buyAmount,
77
+ });
78
+ }),
79
+ ]);
80
+ const sellerNonceCount = countSellerNonceSlots(needBribeTx, needApproval, true);
81
+ // ✅ 如果前端传入了 startNonces,直接使用(性能优化)
82
+ // 否则从链上获取
83
+ const allWallets = [seller, ...buyers];
84
+ const initialNonces = startNonces && startNonces.length >= allWallets.length
85
+ ? startNonces
86
+ : await nonceManager.getNextNoncesForWallets(allWallets);
87
+ // 分配 seller nonces
88
+ const sellerNonces = Array.from({ length: sellerNonceCount }, (_, i) => initialNonces[0] + i);
89
+ const noncePlan = planSellerNonces(sellerNonces, needBribeTx, needApproval, true);
90
+ const profitNonce = noncePlan.profitNonce;
91
+ const buyerNonces = initialNonces.slice(1);
92
+ const signPromises = [];
93
+ if (needBribeTx && noncePlan.bribeNonce !== undefined) {
94
+ signPromises.push(signBribeTransaction(seller, bribeAmount, noncePlan.bribeNonce, gasPrice, chainIdNum, txType));
95
+ }
96
+ if (needApproval && noncePlan.approvalNonce !== undefined) {
97
+ signPromises.push(signTmMaxApprovalTx(seller, tokenAddress, noncePlan.approvalNonce, gasPrice, chainIdNum, txType));
98
+ }
99
+ signPromises.push(seller.signTransaction({
100
+ ...sellUnsigned,
101
+ from: seller.address,
102
+ nonce: noncePlan.sellerNonce,
103
+ gasLimit: finalGasLimit,
104
+ gasPrice,
105
+ chainId: chainIdNum,
106
+ type: txType,
107
+ }));
108
+ // 所有买入交易
109
+ buyers.forEach((buyer, i) => {
110
+ signPromises.push(buyer.signTransaction({
111
+ ...buyUnsignedList[i],
112
+ from: buyer.address,
113
+ nonce: buyerNonces[i],
114
+ gasLimit: finalGasLimit,
115
+ gasPrice,
116
+ chainId: chainIdNum,
117
+ type: txType,
118
+ value: buyAmountsWei[i],
119
+ }));
120
+ });
121
+ const signedTxs = await Promise.all(signPromises);
122
+ // 解析签名结果
123
+ let signIdx = 0;
124
+ let bribeTx = null;
125
+ let approvalTx = null;
126
+ if (needBribeTx)
127
+ bribeTx = signedTxs[signIdx++];
128
+ if (needApproval)
129
+ approvalTx = signedTxs[signIdx++];
130
+ const signedSell = signedTxs[signIdx++];
131
+ const signedBuys = signedTxs.slice(signIdx, signIdx + buyers.length);
132
+ nonceManager.clearTemp();
133
+ // ✅ 按顺序组装交易数组:贿赂 → 授权 → 卖出 → 买入
134
+ const signedTransactions = [];
135
+ if (bribeTx)
136
+ signedTransactions.push(bribeTx);
137
+ if (approvalTx)
138
+ signedTransactions.push(approvalTx);
139
+ signedTransactions.push(signedSell);
140
+ signedTransactions.push(...signedBuys);
141
+ // ✅ 利润多跳转账(强制 2 跳中转)
142
+ let profitHopWallets;
143
+ if (profitAmount > 0n) {
144
+ const profitHopResult = await buildProfitHopTransactions({
145
+ provider,
146
+ payerWallet: seller,
147
+ profitAmount: profitAmount,
148
+ profitRecipient: getProfitRecipient(),
149
+ hopCount: PROFIT_HOP_COUNT,
150
+ gasPrice,
151
+ chainId: chainIdNum,
152
+ txType,
153
+ startNonce: profitNonce,
154
+ });
155
+ signedTransactions.push(...profitHopResult.signedTransactions);
156
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
157
+ }
158
+ return {
159
+ signedTransactions,
160
+ profitHopWallets, // ✅ 导出利润多跳钱包
161
+ metadata: {
162
+ sellerAddress: seller.address,
163
+ buyerAddresses: buyers.map((b) => b.address),
164
+ sellAmount: ethers.formatUnits(sellAmountWei, decimals),
165
+ buyAmounts: buyAmountsWei.map((amt) => ethers.formatEther(amt)),
166
+ hasApproval: !!approvalTx,
167
+ profitAmount: ethers.formatEther(profitAmount),
168
+ },
169
+ };
170
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Four.meme 内盘捆绑换手(Merkle Bundle)— 单卖单买流程
3
+ */
4
+ import type { FourBundleSwapSignParams, FourSwapResult } from '../types/index.js';
5
+ /**
6
+ * Four内盘捆绑换手
7
+ */
8
+ export declare function fourBundleSwapMerkle(params: FourBundleSwapSignParams): Promise<FourSwapResult>;