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
@@ -0,0 +1,102 @@
1
+ import type { BundleStatus, SoulPointSignatureMode, VNormalizationMode } from '../../../core/clients/club48.js';
2
+ export type FlapBundleConfig = {
3
+ rpcUrl: string;
4
+ club48Endpoint?: string;
5
+ club48ExplorerEndpoint?: string;
6
+ spMode?: SoulPointSignatureMode;
7
+ spVMode?: VNormalizationMode;
8
+ spPrivateKey?: string;
9
+ bundleBlockOffset?: number;
10
+ noMerge?: boolean;
11
+ tipAmountWei?: bigint;
12
+ txType?: 0 | 2;
13
+ gasLimitMultiplier?: number;
14
+ waitTimeoutMs?: number;
15
+ slippageBps?: number;
16
+ };
17
+ export type FlapChainForBundle = 'BSC';
18
+ export type FlapCreateWithBundleBuyParams = {
19
+ chain: FlapChainForBundle;
20
+ privateKeys: string[];
21
+ buyAmounts: string[];
22
+ tokenInfo: {
23
+ name: string;
24
+ symbol: string;
25
+ meta: string;
26
+ };
27
+ quoteToken?: string;
28
+ tokenAddress: string;
29
+ config: FlapBundleConfig;
30
+ dexThresh?: number;
31
+ migratorType?: number;
32
+ taxRate?: number;
33
+ salt?: string;
34
+ };
35
+ export type FlapCreateWithBundleBuyResult = {
36
+ bundleUuid: string;
37
+ tokenAddress?: string;
38
+ status: BundleStatus;
39
+ createTx: string;
40
+ buyTxs: string[];
41
+ };
42
+ export type FlapBatchBuyParams = {
43
+ chain: FlapChainForBundle;
44
+ privateKeys: string[];
45
+ buyAmounts: string[];
46
+ tokenAddress: string;
47
+ config: FlapBundleConfig;
48
+ };
49
+ export type FlapBatchBuyResult = {
50
+ bundleUuid: string;
51
+ status: BundleStatus;
52
+ buyTxs: string[];
53
+ };
54
+ export type FlapBatchSellParams = {
55
+ chain: FlapChainForBundle;
56
+ privateKeys: string[];
57
+ sellAmounts: string[];
58
+ tokenAddress: string;
59
+ config: FlapBundleConfig;
60
+ };
61
+ export type FlapBatchSellResult = {
62
+ bundleUuid: string;
63
+ status: BundleStatus;
64
+ sellTxs: string[];
65
+ };
66
+ export type FlapPrivateBase = {
67
+ chain: FlapChainForBundle;
68
+ config: FlapBundleConfig;
69
+ };
70
+ export type FlapPrivateBuyParams = FlapPrivateBase & {
71
+ privateKey: string;
72
+ tokenAddress: string;
73
+ amountIn: string;
74
+ to?: string;
75
+ spPrivateKey?: string;
76
+ };
77
+ export type FlapPrivateSellParams = FlapPrivateBase & {
78
+ privateKey: string;
79
+ tokenAddress: string;
80
+ amount: string;
81
+ minEth?: bigint;
82
+ spPrivateKey?: string;
83
+ };
84
+ export type FlapBatchPrivateBuyParams = FlapPrivateBase & {
85
+ privateKeys: string[];
86
+ amountsIn: string[];
87
+ tokenAddress: string;
88
+ spPrivateKey: string;
89
+ };
90
+ export type FlapBatchPrivateSellParams = FlapPrivateBase & {
91
+ privateKeys: string[];
92
+ amounts: string[];
93
+ tokenAddress: string;
94
+ spPrivateKey?: string;
95
+ minEthEach?: bigint;
96
+ };
97
+ export type FlapBatchPrivateSellResult = {
98
+ submitted: boolean;
99
+ sellTxs: string[];
100
+ bundleUuid?: string;
101
+ status?: BundleStatus;
102
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { FlapBatchBuySignParams, FlapBatchBuyMerkleResult, FlapBatchSellSignParams, FlapBatchSellMerkleResult } from './types.js';
2
+ /**
3
+ * Flap Protocol: 批量购买(仅签名版本 - 不依赖 Merkle)
4
+ * ✅ 精简版:只负责签名交易,不提交到 Merkle
5
+ * ✅ 支持 quoteToken:传入 USDC 等地址时使用该代币购买,否则使用原生代币
6
+ */
7
+ export declare function batchBuyWithBundleMerkle(params: FlapBatchBuySignParams): Promise<FlapBatchBuyMerkleResult>;
8
+ /**
9
+ * Flap Protocol: 批量卖出(仅签名版本 - 不依赖 Merkle)
10
+ * ✅ 精简版:只负责签名交易,不提交到 Merkle
11
+ * ✅ 支持 quoteToken:传入 USDC 等地址时卖出为该代币,否则卖出为原生代币
12
+ */
13
+ export declare function batchSellWithBundleMerkle(params: FlapBatchSellSignParams): Promise<FlapBatchSellMerkleResult>;
@@ -0,0 +1,376 @@
1
+ /**
2
+ * core-batch — 批量买入/卖出主函数(从 core.ts 抽取)
3
+ *
4
+ * 拆分说明:batchBuyWithBundleMerkle / batchSellWithBundleMerkle 从 core.ts
5
+ * 抽到本文件,core.ts 通过 re-export 保持对外符号/路径/签名不变。
6
+ */
7
+ import { ethers } from 'ethers';
8
+ import { NonceManager, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
9
+ import { ZERO_ADDRESS } from '../../../core/constants/index.js';
10
+ import { GAS_LIMITS } from '../../../core/constants/index.js';
11
+ import { FLAP_PORTAL_ADDRESSES } from '../constants.js';
12
+ import { PORTAL_ABI, getErrorMessage, getTxType, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, } from './config.js';
13
+ import { getTokenToNativeQuote, validateQuoteTokenDecimals, createChainContext, resolveGasPrice, createWallets, analyzeBuyFunds, findMaxIndex, buildGasLimitList, populateBuyTransactionsWithQuote, allocateBuyerNonces, adjustNoncesForProfit, signBuyTransactions, buildProfitMetadata, quoteSellOutputsWithQuote, resolveMinOutputs, } from './core-helpers.js';
14
+ /**
15
+ * Flap Protocol: 批量购买(仅签名版本 - 不依赖 Merkle)
16
+ * ✅ 精简版:只负责签名交易,不提交到 Merkle
17
+ * ✅ 支持 quoteToken:传入 USDC 等地址时使用该代币购买,否则使用原生代币
18
+ */
19
+ export async function batchBuyWithBundleMerkle(params) {
20
+ const { chain, privateKeys, buyAmounts, tokenAddress, quoteToken, quoteTokenDecimals, config } = params;
21
+ if (privateKeys.length === 0 || buyAmounts.length !== privateKeys.length) {
22
+ throw new Error(getErrorMessage('KEY_AMOUNT_MISMATCH'));
23
+ }
24
+ const { provider, chainId } = createChainContext(chain, config.rpcUrl);
25
+ const nonceManager = new NonceManager(provider);
26
+ const buyers = createWallets(privateKeys, provider);
27
+ const extractProfit = shouldExtractProfit();
28
+ const { fundsList, originalAmounts, totalBuyAmount, totalProfit } = analyzeBuyFunds(buyAmounts, config, extractProfit);
29
+ const maxFundsIndex = findMaxIndex(originalAmounts);
30
+ const gasLimits = buildGasLimitList(buyers.length, config);
31
+ // ✅ 确定 inputToken:如果传入了 quoteToken 且非零地址,则使用它;否则使用零地址(原生代币)
32
+ const inputToken = quoteToken && quoteToken !== ZERO_ADDRESS ? quoteToken : ZERO_ADDRESS;
33
+ // ✅ 如果使用非原生代币,则 value 应为 0(不发送原生代币)
34
+ const useNativeToken = inputToken === ZERO_ADDRESS;
35
+ const validatedBatchQuoteDecimals = validateQuoteTokenDecimals(quoteTokenDecimals, 'batchBuyWithBundleMerkle');
36
+ // ✅ 如果使用非原生代币(如 USDC),需要根据精度转换金额
37
+ // buyAmounts 是按 18 位精度传入的,需要转换为目标代币精度
38
+ let adjustedFundsList = fundsList;
39
+ let profitTokenAmount = totalProfit;
40
+ if (!useNativeToken && validatedBatchQuoteDecimals !== undefined && validatedBatchQuoteDecimals !== 18) {
41
+ // 从 18 位精度转换为目标精度
42
+ // 例如:0.1 ETH (18位) = 100000000000000000 wei
43
+ // 转为 USDC (6位) = 100000 (0.1 USDC)
44
+ const decimalsDiff = 18 - validatedBatchQuoteDecimals;
45
+ const divisor = BigInt(10 ** decimalsDiff);
46
+ adjustedFundsList = fundsList.map((amount) => amount / divisor);
47
+ profitTokenAmount = totalProfit / divisor;
48
+ }
49
+ // ✅ ERC20 购买:获取代币利润等值的原生代币(BNB)报价
50
+ let nativeProfitAmount = totalProfit; // 原生代币购买时直接使用
51
+ if (!useNativeToken && extractProfit && totalProfit > 0n) {
52
+ // 将代币利润转换为等值原生代币(BNB/OKB/MON)
53
+ nativeProfitAmount = await getTokenToNativeQuote(provider, inputToken, profitTokenAmount, chainId);
54
+ }
55
+ // ✅ 优化:如果前端传入了 nonces,需要调整以避免利润交易 nonce 冲突
56
+ const presetNonces = config.nonces;
57
+ // ✅ 并行执行需要的 RPC 操作
58
+ const [gasPrice, unsignedBuys, buyerNonces] = await Promise.all([
59
+ resolveGasPrice(provider, config),
60
+ populateBuyTransactionsWithQuote(buyers, FLAP_PORTAL_ADDRESSES[chain], tokenAddress, adjustedFundsList, inputToken, useNativeToken),
61
+ presetNonces && presetNonces.length === buyers.length
62
+ ? adjustNoncesForProfit(presetNonces) // ✅ 调整 nonces 避免冲突
63
+ : allocateBuyerNonces(buyers, extractProfit, maxFundsIndex, nativeProfitAmount, nonceManager),
64
+ ]);
65
+ // ✅ 贿赂交易放在首位(提高 BlockRazor 打包优先级)
66
+ const bribeAmount = getBribeAmount(config);
67
+ const bribeTxs = [];
68
+ if (bribeAmount > 0n && maxFundsIndex >= 0 && buyers.length > 0) {
69
+ const bribeNonce = buyerNonces[maxFundsIndex];
70
+ const bribeTx = await buyers[maxFundsIndex].signTransaction({
71
+ to: BLOCKRAZOR_BUILDER_EOA,
72
+ value: bribeAmount,
73
+ nonce: bribeNonce,
74
+ gasPrice,
75
+ gasLimit: GAS_LIMITS.BRIBE,
76
+ chainId,
77
+ type: getTxType(config),
78
+ });
79
+ bribeTxs.push(bribeTx);
80
+ // 调整 maxFundsIndex 钱包的 nonce(买入交易 +1)
81
+ buyerNonces[maxFundsIndex] = bribeNonce + 1;
82
+ }
83
+ const signedBuys = await signBuyTransactions({
84
+ unsignedBuys,
85
+ buyers,
86
+ nonces: buyerNonces,
87
+ gasLimits,
88
+ gasPrice,
89
+ chainId,
90
+ config,
91
+ fundsList: adjustedFundsList, // ✅ 使用调整后的金额
92
+ useNativeToken, // ✅ USDT 购买时 value=0,BNB 购买时 value=金额
93
+ });
94
+ // ✅ 利润多跳转账
95
+ const profitTxs = [];
96
+ let profitHopWallets;
97
+ // ✅ 检查是否使用分布式利润模式
98
+ const profitMode = config.profitMode ?? 'single';
99
+ if (extractProfit && nativeProfitAmount > 0n) {
100
+ if (profitMode === 'distributed') {
101
+ // ✅ 分布式模式:每个钱包独立扣除自己的利润,每个都有独立的多跳
102
+ // 最多支持 12 个钱包(12 交易 + 36 多跳 + 1 贿赂 = 49 笔)
103
+ const MAX_DISTRIBUTED_WALLETS = 12;
104
+ if (buyers.length > MAX_DISTRIBUTED_WALLETS) {
105
+ throw new Error(`分布式利润模式最多支持 ${MAX_DISTRIBUTED_WALLETS} 个钱包,当前 ${buyers.length} 个`);
106
+ }
107
+ profitHopWallets = [];
108
+ // 计算每个钱包的利润(按比例分配)
109
+ const perWalletProfits = [];
110
+ for (let i = 0; i < buyers.length; i++) {
111
+ const walletOriginalAmount = originalAmounts[i];
112
+ // 按比例计算该钱包应承担的利润
113
+ const walletProfit = totalBuyAmount > 0n ? (nativeProfitAmount * walletOriginalAmount) / totalBuyAmount : 0n;
114
+ perWalletProfits.push(walletProfit);
115
+ }
116
+ // 为每个钱包生成独立的利润多跳交易
117
+ for (let i = 0; i < buyers.length; i++) {
118
+ const walletProfit = perWalletProfits[i];
119
+ if (walletProfit > 0n) {
120
+ const profitNonce = buyerNonces[i] + 1; // 每个钱包买入后 +1
121
+ const profitHopResult = await buildProfitHopTransactions({
122
+ provider,
123
+ payerWallet: buyers[i],
124
+ profitAmount: walletProfit,
125
+ profitRecipient: getProfitRecipient(),
126
+ hopCount: PROFIT_HOP_COUNT,
127
+ gasPrice,
128
+ chainId,
129
+ txType: getTxType(config),
130
+ startNonce: profitNonce,
131
+ });
132
+ profitTxs.push(...profitHopResult.signedTransactions);
133
+ if (profitHopResult.hopWallets) {
134
+ profitHopWallets.push(...profitHopResult.hopWallets);
135
+ }
136
+ }
137
+ }
138
+ }
139
+ else {
140
+ // ✅ 单一模式(默认):从金额最大的钱包统一扣除所有利润
141
+ if (maxFundsIndex >= 0) {
142
+ const profitNonce = buyerNonces[maxFundsIndex] + 1;
143
+ const profitHopResult = await buildProfitHopTransactions({
144
+ provider,
145
+ payerWallet: buyers[maxFundsIndex],
146
+ profitAmount: nativeProfitAmount,
147
+ profitRecipient: getProfitRecipient(),
148
+ hopCount: PROFIT_HOP_COUNT,
149
+ gasPrice,
150
+ chainId,
151
+ txType: getTxType(config),
152
+ startNonce: profitNonce,
153
+ });
154
+ profitTxs.push(...profitHopResult.signedTransactions);
155
+ profitHopWallets = profitHopResult.hopWallets;
156
+ }
157
+ }
158
+ }
159
+ nonceManager.clearTemp();
160
+ // ✅ 组装顺序:贿赂 → 买入 → 利润多跳
161
+ return {
162
+ signedTransactions: [...bribeTxs, ...signedBuys, ...profitTxs],
163
+ profitHopWallets, // ✅ 返回利润多跳钱包
164
+ metadata: {
165
+ ...buildProfitMetadata(extractProfit, totalBuyAmount, nativeProfitAmount, buyers.length),
166
+ profitMode, // ✅ 返回使用的利润模式
167
+ },
168
+ };
169
+ }
170
+ /**
171
+ * Flap Protocol: 批量卖出(仅签名版本 - 不依赖 Merkle)
172
+ * ✅ 精简版:只负责签名交易,不提交到 Merkle
173
+ * ✅ 支持 quoteToken:传入 USDC 等地址时卖出为该代币,否则卖出为原生代币
174
+ */
175
+ export async function batchSellWithBundleMerkle(params) {
176
+ const { chain, privateKeys, sellAmounts, tokenAddress, quoteToken, minOutputAmounts, config } = params;
177
+ if (privateKeys.length === 0 || sellAmounts.length !== privateKeys.length) {
178
+ throw new Error(getErrorMessage('SELL_KEY_AMOUNT_MISMATCH'));
179
+ }
180
+ const { provider, chainId } = createChainContext(chain, config.rpcUrl);
181
+ const nonceManager = new NonceManager(provider);
182
+ const wallets = createWallets(privateKeys, provider);
183
+ const amountsWei = sellAmounts.map((a) => ethers.parseUnits(a, 18));
184
+ const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
185
+ const readOnlyPortal = new ethers.Contract(portalAddr, PORTAL_ABI, provider);
186
+ const gasLimits = buildGasLimitList(wallets.length, config);
187
+ const portals = wallets.map((w) => new ethers.Contract(portalAddr, PORTAL_ABI, w));
188
+ // ✅ 确定 outputToken:如果传入了 quoteToken 且非零地址,则使用它;否则使用零地址(原生代币)
189
+ const outputToken = quoteToken && quoteToken !== ZERO_ADDRESS ? quoteToken : ZERO_ADDRESS;
190
+ const useNativeOutput = outputToken === ZERO_ADDRESS;
191
+ // ✅ 优化:如果前端传入了 nonces,直接使用(跳过 RPC 调用)
192
+ const presetNonces = config.nonces;
193
+ const extractProfit = shouldExtractProfit();
194
+ // ✅ 并行执行 gasPrice 和 quoteSellOutputs(Multicall3)
195
+ const [gasPrice, quotedOutputs] = await Promise.all([
196
+ resolveGasPrice(provider, config),
197
+ quoteSellOutputsWithQuote(readOnlyPortal, tokenAddress, amountsWei, outputToken),
198
+ ]);
199
+ // ✅ 计算利润和 maxRevenueIndex(用于 nonce 分配)
200
+ let totalTokenProfit = 0n;
201
+ let maxRevenueIndex = -1;
202
+ let maxRevenue = 0n;
203
+ if (extractProfit && quotedOutputs.length > 0) {
204
+ for (let i = 0; i < wallets.length; i++) {
205
+ const quoted = quotedOutputs[i];
206
+ if (quoted > 0n) {
207
+ const { profit } = calculateProfit(quoted);
208
+ totalTokenProfit += profit;
209
+ if (quoted > maxRevenue) {
210
+ maxRevenue = quoted;
211
+ maxRevenueIndex = i;
212
+ }
213
+ }
214
+ }
215
+ }
216
+ // ✅ 修复:根据是否需要贿赂/利润交易,统一分配 nonces
217
+ const bribeAmount = getBribeAmount(config);
218
+ const needBribeTx = bribeAmount > 0n && maxRevenueIndex >= 0;
219
+ const needProfitTx = extractProfit && totalTokenProfit > 0n && maxRevenueIndex >= 0;
220
+ // 计算 maxRevenueIndex 钱包需要的 nonce 数量:贿赂(可选) + 卖出 + 利润(可选)
221
+ const maxRevenueNonceCount = 1 + (needBribeTx ? 1 : 0) + (needProfitTx ? 1 : 0);
222
+ let nonces;
223
+ let bribeNonce;
224
+ let profitNonce;
225
+ if (presetNonces && presetNonces.length === wallets.length) {
226
+ // ✅ 使用前端传入的 nonces
227
+ nonces = [...presetNonces];
228
+ if (needBribeTx) {
229
+ bribeNonce = nonces[maxRevenueIndex];
230
+ nonces[maxRevenueIndex] = bribeNonce + 1; // 卖出交易 nonce +1
231
+ }
232
+ profitNonce = needProfitTx ? nonces[maxRevenueIndex] + 1 : undefined;
233
+ }
234
+ else if (maxRevenueNonceCount > 1 && maxRevenueIndex >= 0) {
235
+ // maxRevenueIndex 钱包需要多个连续 nonce
236
+ const maxRevenueNonces = await nonceManager.getNextNonceBatch(wallets[maxRevenueIndex], maxRevenueNonceCount);
237
+ // 其他钱包各需要 1 个 nonce
238
+ const otherWallets = wallets.filter((_, i) => i !== maxRevenueIndex);
239
+ const otherNonces = otherWallets.length > 0 ? await nonceManager.getNextNoncesForWallets(otherWallets) : [];
240
+ // 组装最终的 nonces 数组(保持原顺序)
241
+ nonces = [];
242
+ let otherIdx = 0;
243
+ let nonceIdx = 0;
244
+ if (needBribeTx) {
245
+ bribeNonce = maxRevenueNonces[nonceIdx++]; // 贿赂交易用第一个 nonce
246
+ }
247
+ for (let i = 0; i < wallets.length; i++) {
248
+ if (i === maxRevenueIndex) {
249
+ nonces.push(maxRevenueNonces[nonceIdx++]); // 卖出交易
250
+ }
251
+ else {
252
+ nonces.push(otherNonces[otherIdx++]);
253
+ }
254
+ }
255
+ if (needProfitTx) {
256
+ profitNonce = maxRevenueNonces[nonceIdx]; // 利润交易用最后一个 nonce
257
+ }
258
+ }
259
+ else {
260
+ // 不需要额外交易,所有钱包各 1 个 nonce
261
+ nonces = await nonceManager.getNextNoncesForWallets(wallets);
262
+ }
263
+ const minOuts = resolveMinOutputs(minOutputAmounts, wallets.length, quotedOutputs);
264
+ // ✅ 优化:构建未签名交易(这里是本地操作,但仍然并行执行以提高效率)
265
+ const unsignedList = await Promise.all(portals.map((portal, i) => portal.swapExactInput.populateTransaction({
266
+ inputToken: tokenAddress,
267
+ outputToken, // ✅ 使用动态 outputToken
268
+ inputAmount: amountsWei[i],
269
+ minOutputAmount: minOuts[i],
270
+ permitData: '0x',
271
+ })));
272
+ // ✅ 贿赂交易放在首位
273
+ const bribeTxs = [];
274
+ if (needBribeTx && bribeNonce !== undefined) {
275
+ const bribeTx = await wallets[maxRevenueIndex].signTransaction({
276
+ to: BLOCKRAZOR_BUILDER_EOA,
277
+ value: bribeAmount,
278
+ nonce: bribeNonce,
279
+ gasPrice,
280
+ gasLimit: GAS_LIMITS.BRIBE,
281
+ chainId,
282
+ type: getTxType(config),
283
+ });
284
+ bribeTxs.push(bribeTx);
285
+ }
286
+ // ✅ 签名所有卖出交易(并行)
287
+ // ✅ 卖出交易 value 必须为 0,不能发送原生代币
288
+ const signedList = await Promise.all(unsignedList.map((unsigned, i) => wallets[i].signTransaction({
289
+ ...unsigned,
290
+ from: wallets[i].address,
291
+ nonce: nonces[i],
292
+ gasLimit: gasLimits[i],
293
+ gasPrice,
294
+ chainId,
295
+ type: getTxType(config),
296
+ value: 0n, // ✅ 卖出交易不发送原生代币
297
+ })));
298
+ // ✅ 利润多跳转账
299
+ const profitTxs = [];
300
+ let profitHopWallets;
301
+ // ✅ 检查是否使用分布式利润模式
302
+ const profitMode = config.profitMode ?? 'single';
303
+ if (needProfitTx) {
304
+ // ERC20 输出时:获取代币利润等值的原生代币(BNB)报价
305
+ let totalNativeProfitAmount = totalTokenProfit;
306
+ if (!useNativeOutput && outputToken) {
307
+ totalNativeProfitAmount = await getTokenToNativeQuote(provider, outputToken, totalTokenProfit, chainId);
308
+ }
309
+ if (totalNativeProfitAmount > 0n) {
310
+ if (profitMode === 'distributed') {
311
+ // ✅ 分布式模式:每个钱包独立扣除自己的利润,每个都有独立的多跳
312
+ // 最多支持 12 个钱包(12 交易 + 36 多跳 + 1 贿赂 = 49 笔)
313
+ const MAX_DISTRIBUTED_WALLETS = 12;
314
+ if (wallets.length > MAX_DISTRIBUTED_WALLETS) {
315
+ throw new Error(`分布式利润模式最多支持 ${MAX_DISTRIBUTED_WALLETS} 个钱包,当前 ${wallets.length} 个`);
316
+ }
317
+ profitHopWallets = [];
318
+ // 计算每个钱包的利润(按卖出收益比例分配)
319
+ const totalQuoted = quotedOutputs.reduce((sum, q) => sum + q, 0n);
320
+ for (let i = 0; i < wallets.length; i++) {
321
+ const quoted = quotedOutputs[i];
322
+ if (quoted > 0n && totalQuoted > 0n) {
323
+ // 按比例计算该钱包应承担的利润
324
+ const walletProfit = (totalNativeProfitAmount * quoted) / totalQuoted;
325
+ if (walletProfit > 0n) {
326
+ const walletProfitNonce = nonces[i] + 1; // 每个钱包卖出后 +1
327
+ const profitHopResult = await buildProfitHopTransactions({
328
+ provider,
329
+ payerWallet: wallets[i],
330
+ profitAmount: walletProfit,
331
+ profitRecipient: getProfitRecipient(),
332
+ hopCount: PROFIT_HOP_COUNT,
333
+ gasPrice,
334
+ chainId,
335
+ txType: getTxType(config),
336
+ startNonce: walletProfitNonce,
337
+ });
338
+ profitTxs.push(...profitHopResult.signedTransactions);
339
+ if (profitHopResult.hopWallets) {
340
+ profitHopWallets.push(...profitHopResult.hopWallets);
341
+ }
342
+ }
343
+ }
344
+ }
345
+ }
346
+ else {
347
+ // ✅ 单一模式(默认):从收益最大的钱包统一扣除所有利润
348
+ if (profitNonce !== undefined) {
349
+ const profitHopResult = await buildProfitHopTransactions({
350
+ provider,
351
+ payerWallet: wallets[maxRevenueIndex],
352
+ profitAmount: totalNativeProfitAmount,
353
+ profitRecipient: getProfitRecipient(),
354
+ hopCount: PROFIT_HOP_COUNT,
355
+ gasPrice,
356
+ chainId,
357
+ txType: getTxType(config),
358
+ startNonce: profitNonce,
359
+ });
360
+ profitTxs.push(...profitHopResult.signedTransactions);
361
+ profitHopWallets = profitHopResult.hopWallets;
362
+ }
363
+ }
364
+ }
365
+ }
366
+ nonceManager.clearTemp();
367
+ // ✅ 组装顺序:贿赂 → 卖出 → 利润多跳
368
+ return {
369
+ signedTransactions: [...bribeTxs, ...signedList, ...profitTxs],
370
+ profitHopWallets, // ✅ 返回利润多跳钱包
371
+ metadata: {
372
+ profitMode, // ✅ 返回使用的利润模式
373
+ totalProfit: totalTokenProfit.toString(),
374
+ },
375
+ };
376
+ }
@@ -1,4 +1,5 @@
1
- import { JsonRpcProvider } from 'ethers';
1
+ import { ethers, JsonRpcProvider, Wallet } from 'ethers';
2
+ import { NonceManager } from '../../../utils/bundle-helpers.js';
2
3
  import { FlapAnyConfig } from './config.js';
3
4
  import { FlapCreateWithBundleBuySignParams } from './types.js';
4
5
  export declare const MULTICALL3_ADDRESS: "0xcA11bde05977b3631167028862bE2a173976CA11";
@@ -19,14 +20,81 @@ export declare const ROUTER_ABI: string[];
19
20
  */
20
21
  export declare function getTokenToNativeQuote(provider: JsonRpcProvider, tokenAddress: string, tokenAmount: bigint, chainId: number): Promise<bigint>;
21
22
  export type FlapChain = FlapCreateWithBundleBuySignParams['chain'];
23
+ export declare function validateQuoteTokenDecimals(decimals: number | undefined, source: string): number | undefined;
24
+ export declare function resolveCreateTokenLaunchFlags(params: {
25
+ taxRate?: number;
26
+ taxV2Config?: FlapCreateWithBundleBuySignParams['taxV2Config'];
27
+ lpFeeProfile?: number;
28
+ dexId?: number;
29
+ migratorType?: number;
30
+ extensionID?: string;
31
+ }): {
32
+ normalizedTax: import("../portal-create-token.js").NormalizedTaxLaunchConfig | undefined;
33
+ isTaxLaunch: boolean;
34
+ hasVault: boolean;
35
+ useV7Portal: boolean;
36
+ };
22
37
  /**
23
- * 获取 Gas Limit
24
- * 优先使用 config.gasLimit,否则使用默认值 * multiplier
38
+ * 无捆绑钱包、仅 Dev 自跟买、原生报价 → Flap 文档方式 A(create 内 quoteAmt + msg.value)
39
+ */
40
+ export declare function canUseLaunchMethodA(privateKeys: string[], buyAmounts: string[], devAddress: string, useNativeToken: boolean): boolean;
41
+ export declare function createChainContext(chain: FlapChain, rpcUrl: string): {
42
+ chainId: number;
43
+ provider: ethers.JsonRpcProvider;
44
+ };
45
+ export declare function resolveGasPrice(provider: ethers.JsonRpcProvider, config: FlapAnyConfig): Promise<bigint>;
46
+ export declare function createWallets(privateKeys: string[], provider: ethers.JsonRpcProvider): ethers.Wallet[];
47
+ export type BuyAnalysis = {
48
+ fundsList: bigint[];
49
+ originalAmounts: bigint[];
50
+ totalBuyAmount: bigint;
51
+ totalProfit: bigint;
52
+ };
53
+ export declare function analyzeBuyFunds(buyAmounts: string[], config: FlapAnyConfig, extractProfit: boolean): BuyAnalysis;
54
+ export declare function findMaxIndex(values: bigint[]): number;
55
+ /**
56
+ * ✅ 支持 quoteToken 的买入交易构建
57
+ * 当 inputToken 为非零地址(如 USDC)时,value 为 0
58
+ */
59
+ export declare function populateBuyTransactionsWithQuote(buyers: Wallet[], portalAddr: string, tokenAddress: string, fundsList: bigint[], inputToken: string, useNativeToken: boolean): Promise<ethers.ContractTransaction[]>;
60
+ export declare function buildGasLimitList(length: number, config: FlapAnyConfig): any[];
61
+ /**
62
+ * ✅ 修复:不再调整其他钱包的 nonce
25
63
  *
26
- * ✅ ethers v6 最佳实践:直接使用 bigint 类型
64
+ * 之前的错误逻辑:如果钱包 B 的 nonce 与利润交易的 nonce 数值相同,就 +1
65
+ * 这是错误的!因为不同钱包的 nonce 是独立的,即使数值相同也不会冲突!
66
+ *
67
+ * 正确逻辑:直接返回原始 nonces,不做任何调整
68
+ * - 每个钱包使用自己的 nonce 发送买入交易
69
+ * - 利润交易使用 maxIndex 钱包的 nonce + 1(在构建利润交易时处理)
70
+ */
71
+ export declare function adjustNoncesForProfit(presetNonces: number[]): number[];
72
+ /**
73
+ * ✅ 修复:明确分配 nonces,避免隐式状态依赖
27
74
  */
28
- export declare function getGasLimit(config: FlapAnyConfig, defaultGas?: number): bigint;
75
+ export declare function allocateBuyerNonces(buyers: Wallet[], extractProfit: boolean, maxIndex: number, totalProfit: bigint, nonceManager: NonceManager): Promise<number[]>;
76
+ type SignBuyTxParams = {
77
+ unsignedBuys: ethers.TransactionLike[];
78
+ buyers: Wallet[];
79
+ nonces: number[];
80
+ gasLimits: bigint[];
81
+ gasPrice: bigint;
82
+ chainId: number;
83
+ config: FlapAnyConfig;
84
+ fundsList: bigint[];
85
+ useNativeToken?: boolean;
86
+ };
87
+ export declare function signBuyTransactions({ unsignedBuys, buyers, nonces, gasLimits, gasPrice, chainId, config, fundsList, useNativeToken, }: SignBuyTxParams): Promise<string[]>;
88
+ export declare function buildProfitMetadata(extractProfit: boolean, totalBuyAmount: bigint, totalProfit: bigint, buyerCount: number): {
89
+ totalBuyAmount: string;
90
+ profitAmount: string;
91
+ profitRecipient: string;
92
+ buyerCount: number;
93
+ } | undefined;
29
94
  /**
30
- * Flap Protocol: 创建代币 + 捆绑购买(仅签名版本 - 不依赖 Merkle)
31
- * ✅ 精简版:只负责签名交易,不提交到 Merkle
95
+ * ✅ 使用 Multicall3 批量获取卖出报价(单次 RPC)
96
+ * 比 Promise.all 更高效,N 个报价只需 1 次网络请求
32
97
  */
98
+ export declare function quoteSellOutputsWithQuote(portal: ethers.Contract, tokenAddress: string, amountsWei: bigint[], outputToken: string): Promise<bigint[]>;
99
+ export declare function resolveMinOutputs(_provided: (string | bigint)[] | undefined, walletCount: number, _quotedOutputs: bigint[]): any[];
100
+ export {};