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,9 @@
1
+ import type { FlapPrivateBuyMerkleParams, FlapPrivateTransactionResult, FlapBatchPrivateBuyMerkleParams, FlapBatchPrivateMerkleResult } from '../types.js';
2
+ /**
3
+ * 私有购买(单笔)(Merkle 版本)
4
+ */
5
+ export declare function flapPrivateBuyMerkle(params: FlapPrivateBuyMerkleParams): Promise<FlapPrivateTransactionResult>;
6
+ /**
7
+ * 批量私有购买(Merkle 版本)
8
+ */
9
+ export declare function flapBatchPrivateBuyMerkle(params: FlapBatchPrivateBuyMerkleParams): Promise<FlapBatchPrivateMerkleResult>;
@@ -0,0 +1,188 @@
1
+ import { ethers, Wallet } from 'ethers';
2
+ import { getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../../utils/bundle-helpers.js';
3
+ import { FLAP_PORTAL_ADDRESSES } from '../../constants.js';
4
+ import { ZERO_ADDRESS } from '../../../../core/constants/index.js';
5
+ import { GAS_LIMITS } from '../../../../core/constants/index.js';
6
+ import { PORTAL_ABI, getTxType, getGasPriceConfig, shouldExtractProfit, calculateBatchProfit, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, } from '../config.js';
7
+ import { createMerkleContext, splitBuyAmount, parseMinOutput, resolveGasLimit, resolveBatchMinOutputs, findMaxIndex, signBatchTransactions, } from './helpers.js';
8
+ /**
9
+ * 私有购买(单笔)(Merkle 版本)
10
+ */
11
+ export async function flapPrivateBuyMerkle(params) {
12
+ const { chain, privateKey, tokenAddress, amountIn, minOutputAmount, config } = params;
13
+ const { chainId, provider } = createMerkleContext(chain, config);
14
+ const wallet = new Wallet(privateKey, provider);
15
+ const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
16
+ const originalAmountWei = ethers.parseEther(amountIn);
17
+ // ✅ 利润提取配置
18
+ const extractProfit = shouldExtractProfit();
19
+ const { actualAmountWei, profitWei } = splitBuyAmount(originalAmountWei, extractProfit);
20
+ const minAmountOut = parseMinOutput(minOutputAmount);
21
+ const portal = new ethers.Contract(portalAddr, PORTAL_ABI, wallet);
22
+ // ✅ 并行获取 gasPrice、nonce 和构建未签名交易
23
+ const [gasPrice, currentNonce, unsigned] = await Promise.all([
24
+ getOptimizedGasPrice(provider, getGasPriceConfig(config)),
25
+ // ✅ 使用 pending nonce,避免 xLayer 等链上“已有 pending 交易”导致 nonce too low
26
+ provider.getTransactionCount(wallet.address, 'pending'),
27
+ portal.swapExactInput.populateTransaction({
28
+ inputToken: ZERO_ADDRESS,
29
+ outputToken: tokenAddress,
30
+ inputAmount: actualAmountWei,
31
+ minOutputAmount: minAmountOut,
32
+ permitData: '0x',
33
+ }, { value: actualAmountWei }),
34
+ ]);
35
+ const gasLimit = resolveGasLimit(config.gasLimitMultiplier);
36
+ // ✅ 获取贿赂金额
37
+ const bribeAmount = getBribeAmount(config);
38
+ const needBribeTx = bribeAmount > 0n;
39
+ const needProfitTx = extractProfit && profitWei > 0n;
40
+ // ✅ 分配 nonces:贿赂 → 买入 → 利润
41
+ let nonceIdx = 0;
42
+ const bribeNonce = needBribeTx ? currentNonce + nonceIdx++ : undefined;
43
+ const buyNonce = currentNonce + nonceIdx++;
44
+ const profitNonce = needProfitTx ? currentNonce + nonceIdx : undefined;
45
+ // ✅ 并行签名所有交易(贿赂、买入、利润)
46
+ const signPromises = [];
47
+ const txType = getTxType(config);
48
+ // 贿赂交易
49
+ if (needBribeTx && bribeNonce !== undefined) {
50
+ signPromises.push(wallet.signTransaction({
51
+ to: BLOCKRAZOR_BUILDER_EOA,
52
+ value: bribeAmount,
53
+ nonce: bribeNonce,
54
+ gasPrice,
55
+ gasLimit: GAS_LIMITS.BRIBE,
56
+ chainId,
57
+ type: txType,
58
+ }));
59
+ }
60
+ // 买入交易
61
+ signPromises.push(wallet.signTransaction({
62
+ ...unsigned,
63
+ from: wallet.address,
64
+ nonce: buyNonce,
65
+ gasLimit,
66
+ gasPrice,
67
+ chainId,
68
+ type: txType,
69
+ value: actualAmountWei,
70
+ }));
71
+ // ✅ 并行签名完成后按顺序返回
72
+ const signedTxs = await Promise.all(signPromises);
73
+ // ✅ 利润多跳转账(强制 2 跳中转)
74
+ let profitHopWallets;
75
+ if (needProfitTx && profitNonce !== undefined) {
76
+ const profitHopResult = await buildProfitHopTransactions({
77
+ provider,
78
+ payerWallet: wallet,
79
+ profitAmount: profitWei,
80
+ profitRecipient: getProfitRecipient(),
81
+ hopCount: PROFIT_HOP_COUNT,
82
+ gasPrice,
83
+ chainId,
84
+ txType,
85
+ startNonce: profitNonce,
86
+ });
87
+ signedTxs.push(...profitHopResult.signedTransactions);
88
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
89
+ }
90
+ return { signedTransactions: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
91
+ }
92
+ /**
93
+ * 批量私有购买(Merkle 版本)
94
+ */
95
+ export async function flapBatchPrivateBuyMerkle(params) {
96
+ const { chain, privateKeys, amountsIn, tokenAddress, minOutputAmounts, config } = params;
97
+ if (privateKeys.length !== amountsIn.length) {
98
+ throw new Error('privateKeys and amountsIn length mismatch');
99
+ }
100
+ const { chainId, provider } = createMerkleContext(chain, config);
101
+ const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
102
+ const wallets = privateKeys.map((k) => new Wallet(k, provider));
103
+ const originalAmountsWei = amountsIn.map((a) => ethers.parseEther(a));
104
+ // ✅ 利润提取配置
105
+ const extractProfit = shouldExtractProfit();
106
+ const { totalProfit, remainingAmounts } = calculateBatchProfit(originalAmountsWei);
107
+ const actualAmountsWei = remainingAmounts;
108
+ const maxFundsIndex = findMaxIndex(originalAmountsWei);
109
+ const minOuts = resolveBatchMinOutputs(minOutputAmounts, wallets.length);
110
+ const portals = wallets.map((w) => new ethers.Contract(portalAddr, PORTAL_ABI, w));
111
+ // ✅ 获取贿赂金额
112
+ const bribeAmount = getBribeAmount(config);
113
+ const needBribeTx = bribeAmount > 0n;
114
+ const needProfitTx = extractProfit && totalProfit > 0n;
115
+ // ✅ 并行获取 gasPrice、所有 nonces 和构建未签名交易
116
+ const [gasPrice, initialNonces, unsignedList] = await Promise.all([
117
+ getOptimizedGasPrice(provider, getGasPriceConfig(config)),
118
+ // ✅ 使用 pending nonce,避免 xLayer 等链上“已有 pending 交易”导致 nonce too low
119
+ Promise.all(wallets.map((w) => provider.getTransactionCount(w.address, 'pending'))),
120
+ Promise.all(portals.map((portal, i) => portal.swapExactInput.populateTransaction({
121
+ inputToken: ZERO_ADDRESS,
122
+ outputToken: tokenAddress,
123
+ inputAmount: actualAmountsWei[i],
124
+ minOutputAmount: minOuts[i],
125
+ permitData: '0x',
126
+ }, { value: actualAmountsWei[i] }))),
127
+ ]);
128
+ // ✅ 分配 nonces:贿赂(可选) → 买入 → 利润(可选)
129
+ let payerNonceOffset = 0;
130
+ let bribeNonce;
131
+ if (needBribeTx && maxFundsIndex >= 0) {
132
+ bribeNonce = initialNonces[maxFundsIndex];
133
+ payerNonceOffset++;
134
+ }
135
+ const nonces = initialNonces.map((n, i) => {
136
+ if (i === maxFundsIndex) {
137
+ return n + payerNonceOffset; // payer 的买入 nonce 需要偏移
138
+ }
139
+ return n;
140
+ });
141
+ const profitNonce = needProfitTx && maxFundsIndex >= 0 ? initialNonces[maxFundsIndex] + payerNonceOffset + 1 : undefined;
142
+ const gasLimit = resolveGasLimit(config.gasLimitMultiplier);
143
+ const gasLimits = new Array(wallets.length).fill(gasLimit);
144
+ const signedTxs = [];
145
+ // ✅ 贿赂交易放在首位
146
+ if (needBribeTx && bribeNonce !== undefined && maxFundsIndex >= 0) {
147
+ const bribeTx = await wallets[maxFundsIndex].signTransaction({
148
+ to: BLOCKRAZOR_BUILDER_EOA,
149
+ value: bribeAmount,
150
+ nonce: bribeNonce,
151
+ gasPrice,
152
+ gasLimit: GAS_LIMITS.BRIBE,
153
+ chainId,
154
+ type: getTxType(config),
155
+ });
156
+ signedTxs.push(bribeTx);
157
+ }
158
+ // ✅ 并行签名所有买入交易
159
+ const signedList = await signBatchTransactions({
160
+ unsignedList,
161
+ wallets,
162
+ nonces,
163
+ gasLimits,
164
+ gasPrice,
165
+ chainId,
166
+ config,
167
+ values: actualAmountsWei,
168
+ });
169
+ signedTxs.push(...signedList);
170
+ // ✅ 利润多跳转账(强制 2 跳中转)
171
+ let profitHopWallets;
172
+ if (needProfitTx && profitNonce !== undefined && maxFundsIndex >= 0) {
173
+ const profitHopResult = await buildProfitHopTransactions({
174
+ provider,
175
+ payerWallet: wallets[maxFundsIndex],
176
+ profitAmount: totalProfit,
177
+ profitRecipient: getProfitRecipient(),
178
+ hopCount: PROFIT_HOP_COUNT,
179
+ gasPrice,
180
+ chainId,
181
+ txType: getTxType(config),
182
+ startNonce: profitNonce,
183
+ });
184
+ signedTxs.push(...profitHopResult.signedTransactions);
185
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
186
+ }
187
+ return { signedTransactions: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
188
+ }
@@ -0,0 +1,36 @@
1
+ import { ethers, Wallet } from 'ethers';
2
+ import type { FlapPrivateBuyMerkleParams } from '../types.js';
3
+ type FlapChain = FlapPrivateBuyMerkleParams['chain'];
4
+ type FlapConfig = FlapPrivateBuyMerkleParams['config'];
5
+ export declare function createMerkleContext(chain: FlapChain, config: FlapConfig): {
6
+ chainId: number;
7
+ provider: ethers.JsonRpcProvider;
8
+ };
9
+ export declare function splitBuyAmount(amount: bigint, extractProfit: boolean): {
10
+ actualAmountWei: bigint;
11
+ profitWei: bigint;
12
+ };
13
+ export declare function parseMinOutput(value?: string | bigint): bigint;
14
+ export declare function resolveGasLimit(multiplier?: number, defaultGas?: number): bigint;
15
+ export declare function resolveSingleSellOutputs(portal: ethers.Contract, tokenAddress: string, amountWei: bigint, minOutputAmount?: string | bigint): Promise<{
16
+ quotedOutput: any;
17
+ minOut: bigint;
18
+ }>;
19
+ export declare function resolveBatchMinOutputs(minOutputAmounts: (string | bigint)[] | undefined, walletCount: number): any[];
20
+ export declare function findMaxIndex(values: bigint[]): number;
21
+ type SignBatchParams = {
22
+ unsignedList: ethers.TransactionLike[];
23
+ wallets: Wallet[];
24
+ nonces: number[];
25
+ gasLimits: bigint[];
26
+ gasPrice: bigint;
27
+ chainId: number;
28
+ config: FlapConfig;
29
+ values?: bigint[];
30
+ };
31
+ export declare function signBatchTransactions({ unsignedList, wallets, nonces, gasLimits, gasPrice, chainId, config, values, }: SignBatchParams): Promise<string[]>;
32
+ export declare function summarizeSellProfits(quotedOutputs: bigint[], extractProfit: boolean): {
33
+ totalProfit: bigint;
34
+ maxRevenueIndex: number;
35
+ };
36
+ export {};
@@ -0,0 +1,127 @@
1
+ import { ethers, JsonRpcProvider } from 'ethers';
2
+ import { MerkleClient } from '../../../../core/clients/merkle.js';
3
+ import { ZERO_ADDRESS, CHAINS } from '../../../../core/constants/index.js';
4
+ import { CHAIN_ID_MAP, getTxType, calculateProfit, } from '../config.js';
5
+ const DEFAULT_GAS_LIMIT = 800000;
6
+ export function createMerkleContext(chain, config) {
7
+ const chainId = CHAIN_ID_MAP[chain];
8
+ // ✅ 检查是否为 Merkle 支持的链(BSC, ETH)
9
+ // Monad 不支持 Merkle 捆绑服务,使用普通 RPC
10
+ if (chainId !== CHAINS.BSC.chainId && chainId !== CHAINS.ETHEREUM.chainId) {
11
+ // 对于不支持 Merkle 的链(如 Monad),必须提供自定义 RPC
12
+ if (!config.customRpcUrl) {
13
+ throw new Error(`Chain ${chain} (chainId: ${chainId}) does not support Merkle bundle service. Please provide customRpcUrl.`);
14
+ }
15
+ return {
16
+ chainId,
17
+ // ✅ 禁用 ENS: 避免 "network does not support ENS" 错误
18
+ provider: new JsonRpcProvider(config.customRpcUrl, { chainId, name: chain.toLowerCase(), ensAddress: undefined }),
19
+ };
20
+ }
21
+ const merkle = new MerkleClient({
22
+ apiKey: config.apiKey,
23
+ chainId: chainId, // 类型断言为 Merkle 支持的 chainId
24
+ customRpcUrl: config.customRpcUrl,
25
+ });
26
+ return {
27
+ chainId,
28
+ provider: merkle.getProvider(),
29
+ };
30
+ }
31
+ export function splitBuyAmount(amount, extractProfit) {
32
+ if (!extractProfit) {
33
+ return { actualAmountWei: amount, profitWei: 0n };
34
+ }
35
+ const { remaining, profit } = calculateProfit(amount);
36
+ return { actualAmountWei: remaining, profitWei: profit };
37
+ }
38
+ export function parseMinOutput(value) {
39
+ if (value === undefined) {
40
+ return 0n;
41
+ }
42
+ return typeof value === 'string' ? ethers.parseUnits(value, 18) : value;
43
+ }
44
+ export function resolveGasLimit(multiplier, defaultGas = DEFAULT_GAS_LIMIT) {
45
+ const factor = multiplier ?? 1.0;
46
+ return BigInt(Math.ceil(defaultGas * factor));
47
+ }
48
+ export async function resolveSingleSellOutputs(portal, tokenAddress, amountWei, minOutputAmount) {
49
+ if (minOutputAmount !== undefined) {
50
+ const minOut = typeof minOutputAmount === 'string' ? ethers.parseEther(minOutputAmount) : minOutputAmount;
51
+ return {
52
+ quotedOutput: minOut,
53
+ minOut,
54
+ };
55
+ }
56
+ try {
57
+ const quotedOutput = await portal.quoteExactInput.staticCall({
58
+ inputToken: tokenAddress,
59
+ outputToken: ZERO_ADDRESS,
60
+ inputAmount: amountWei,
61
+ });
62
+ return {
63
+ quotedOutput,
64
+ minOut: 0n, // ✅ 已移除滑点保护:minOut 固定为 0
65
+ };
66
+ }
67
+ catch {
68
+ return {
69
+ quotedOutput: 0n,
70
+ minOut: 0n,
71
+ };
72
+ }
73
+ }
74
+ export function resolveBatchMinOutputs(minOutputAmounts, walletCount) {
75
+ if (minOutputAmounts && minOutputAmounts.length === walletCount) {
76
+ return minOutputAmounts.map((m) => (typeof m === 'string' ? ethers.parseUnits(m, 18) : m));
77
+ }
78
+ return new Array(walletCount).fill(0n);
79
+ }
80
+ export function findMaxIndex(values) {
81
+ if (values.length === 0) {
82
+ return -1;
83
+ }
84
+ let maxIndex = 0;
85
+ let maxValue = values[0];
86
+ for (let i = 1; i < values.length; i++) {
87
+ if (values[i] > maxValue) {
88
+ maxValue = values[i];
89
+ maxIndex = i;
90
+ }
91
+ }
92
+ return maxIndex;
93
+ }
94
+ export async function signBatchTransactions({ unsignedList, wallets, nonces, gasLimits, gasPrice, chainId, config, values, }) {
95
+ return await Promise.all(unsignedList.map((unsigned, i) => {
96
+ const value = values ? values[i] : (unsigned.value ?? 0n);
97
+ return wallets[i].signTransaction({
98
+ ...unsigned,
99
+ from: wallets[i].address,
100
+ nonce: nonces[i],
101
+ gasLimit: gasLimits[i],
102
+ gasPrice,
103
+ chainId,
104
+ type: getTxType(config),
105
+ value,
106
+ });
107
+ }));
108
+ }
109
+ export function summarizeSellProfits(quotedOutputs, extractProfit) {
110
+ let totalProfit = 0n;
111
+ let maxRevenueIndex = -1;
112
+ let maxRevenue = 0n;
113
+ if (extractProfit) {
114
+ for (let i = 0; i < quotedOutputs.length; i++) {
115
+ const quoted = quotedOutputs[i];
116
+ if (quoted > 0n) {
117
+ const { profit } = calculateProfit(quoted);
118
+ totalProfit += profit;
119
+ if (quoted > maxRevenue) {
120
+ maxRevenue = quoted;
121
+ maxRevenueIndex = i;
122
+ }
123
+ }
124
+ }
125
+ }
126
+ return { totalProfit, maxRevenueIndex: maxRevenueIndex < 0 ? 0 : maxRevenueIndex };
127
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 私有交易(Merkle 版本)barrel
3
+ *
4
+ * 原超长文件按职责拆分为:
5
+ * - helpers.ts:Merkle 上下文 / 金额解析 / nonce 分配 / 批量签名 / 利润汇总
6
+ * - buy.ts:flapPrivateBuyMerkle / flapBatchPrivateBuyMerkle
7
+ * - sell.ts:flapPrivateSellMerkle / flapBatchPrivateSellMerkle
8
+ *
9
+ * 对外 export 符号与路径保持不变。
10
+ */
11
+ export { flapPrivateBuyMerkle, flapBatchPrivateBuyMerkle } from './buy.js';
12
+ export { flapPrivateSellMerkle, flapBatchPrivateSellMerkle } from './sell.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 私有交易(Merkle 版本)barrel
3
+ *
4
+ * 原超长文件按职责拆分为:
5
+ * - helpers.ts:Merkle 上下文 / 金额解析 / nonce 分配 / 批量签名 / 利润汇总
6
+ * - buy.ts:flapPrivateBuyMerkle / flapBatchPrivateBuyMerkle
7
+ * - sell.ts:flapPrivateSellMerkle / flapBatchPrivateSellMerkle
8
+ *
9
+ * 对外 export 符号与路径保持不变。
10
+ */
11
+ export { flapPrivateBuyMerkle, flapBatchPrivateBuyMerkle } from './buy.js';
12
+ export { flapPrivateSellMerkle, flapBatchPrivateSellMerkle } from './sell.js';
@@ -0,0 +1,9 @@
1
+ import type { FlapPrivateSellMerkleParams, FlapPrivateTransactionResult, FlapBatchPrivateSellMerkleParams, FlapBatchPrivateMerkleResult } from '../types.js';
2
+ /**
3
+ * 私有卖出(单笔)(Merkle 版本)
4
+ */
5
+ export declare function flapPrivateSellMerkle(params: FlapPrivateSellMerkleParams): Promise<FlapPrivateTransactionResult>;
6
+ /**
7
+ * 批量私有卖出(Merkle 版本)
8
+ */
9
+ export declare function flapBatchPrivateSellMerkle(params: FlapBatchPrivateSellMerkleParams): Promise<FlapBatchPrivateMerkleResult>;
@@ -0,0 +1,191 @@
1
+ import { ethers, Wallet } from 'ethers';
2
+ import { getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../../utils/bundle-helpers.js';
3
+ import { FLAP_PORTAL_ADDRESSES } from '../../constants.js';
4
+ import { ZERO_ADDRESS } from '../../../../core/constants/index.js';
5
+ import { GAS_LIMITS } from '../../../../core/constants/index.js';
6
+ import { PORTAL_ABI, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, } from '../config.js';
7
+ import { createMerkleContext, resolveGasLimit, resolveSingleSellOutputs, signBatchTransactions, summarizeSellProfits, } from './helpers.js';
8
+ /**
9
+ * 私有卖出(单笔)(Merkle 版本)
10
+ */
11
+ export async function flapPrivateSellMerkle(params) {
12
+ const { chain, privateKey, tokenAddress, amount, minOutputAmount, config } = params;
13
+ const { chainId, provider } = createMerkleContext(chain, config);
14
+ const wallet = new Wallet(privateKey, provider);
15
+ const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
16
+ const amountWei = ethers.parseUnits(amount, 18);
17
+ const portal = new ethers.Contract(portalAddr, PORTAL_ABI, wallet);
18
+ // ✅ 并行获取 gasPrice、nonce、报价和构建未签名交易
19
+ const [gasPrice, currentNonce, { quotedOutput }, unsigned] = await Promise.all([
20
+ getOptimizedGasPrice(provider, getGasPriceConfig(config)),
21
+ // ✅ 使用 pending nonce,避免 xLayer 等链上“已有 pending 交易”导致 nonce too low
22
+ provider.getTransactionCount(wallet.address, 'pending'),
23
+ resolveSingleSellOutputs(portal, tokenAddress, amountWei, minOutputAmount),
24
+ portal.swapExactInput.populateTransaction({
25
+ inputToken: tokenAddress,
26
+ outputToken: ZERO_ADDRESS,
27
+ inputAmount: amountWei,
28
+ minOutputAmount: 0n, // ✅ 已移除滑点保护
29
+ permitData: '0x',
30
+ }),
31
+ ]);
32
+ const gasLimit = resolveGasLimit(config.gasLimitMultiplier);
33
+ const txType = getTxType(config);
34
+ // ✅ 获取贿赂金额
35
+ const bribeAmount = getBribeAmount(config);
36
+ const needBribeTx = bribeAmount > 0n;
37
+ // ✅ 利润计算
38
+ const extractProfit = shouldExtractProfit();
39
+ const { profit: profitWei } = extractProfit && quotedOutput > 0n ? calculateProfit(quotedOutput) : { profit: 0n };
40
+ const needProfitTx = extractProfit && profitWei > 0n;
41
+ // ✅ 分配 nonces:贿赂 → 卖出 → 利润
42
+ let nonceIdx = 0;
43
+ const bribeNonce = needBribeTx ? currentNonce + nonceIdx++ : undefined;
44
+ const sellNonce = currentNonce + nonceIdx++;
45
+ const profitNonce = needProfitTx ? currentNonce + nonceIdx : undefined;
46
+ // ✅ 并行签名所有交易(贿赂、卖出、利润)
47
+ const signPromises = [];
48
+ // 贿赂交易
49
+ if (needBribeTx && bribeNonce !== undefined) {
50
+ signPromises.push(wallet.signTransaction({
51
+ to: BLOCKRAZOR_BUILDER_EOA,
52
+ value: bribeAmount,
53
+ nonce: bribeNonce,
54
+ gasPrice,
55
+ gasLimit: GAS_LIMITS.BRIBE,
56
+ chainId,
57
+ type: txType,
58
+ }));
59
+ }
60
+ // 卖出交易
61
+ signPromises.push(wallet.signTransaction({
62
+ ...unsigned,
63
+ from: wallet.address,
64
+ nonce: sellNonce,
65
+ gasLimit,
66
+ gasPrice,
67
+ chainId,
68
+ type: txType,
69
+ }));
70
+ // ✅ 并行签名完成后按顺序返回
71
+ const signedTxs = await Promise.all(signPromises);
72
+ // ✅ 利润多跳转账(强制 2 跳中转)
73
+ let profitHopWallets;
74
+ if (needProfitTx && profitNonce !== undefined) {
75
+ const profitHopResult = await buildProfitHopTransactions({
76
+ provider,
77
+ payerWallet: wallet,
78
+ profitAmount: profitWei,
79
+ profitRecipient: getProfitRecipient(),
80
+ hopCount: PROFIT_HOP_COUNT,
81
+ gasPrice,
82
+ chainId,
83
+ txType,
84
+ startNonce: profitNonce,
85
+ });
86
+ signedTxs.push(...profitHopResult.signedTransactions);
87
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
88
+ }
89
+ return { signedTransactions: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
90
+ }
91
+ /**
92
+ * 批量私有卖出(Merkle 版本)
93
+ */
94
+ export async function flapBatchPrivateSellMerkle(params) {
95
+ const { chain, privateKeys, amounts, tokenAddress, config } = params;
96
+ if (privateKeys.length !== amounts.length) {
97
+ throw new Error('privateKeys and amounts length mismatch');
98
+ }
99
+ const { chainId, provider } = createMerkleContext(chain, config);
100
+ const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
101
+ const wallets = privateKeys.map((k) => new Wallet(k, provider));
102
+ const amountsWei = amounts.map((a) => ethers.parseUnits(a, 18));
103
+ const portal = new ethers.Contract(portalAddr, PORTAL_ABI, provider);
104
+ const portals = wallets.map((w) => new ethers.Contract(portalAddr, PORTAL_ABI, w));
105
+ // ✅ 并行获取 gasPrice、所有 nonces、所有报价和构建未签名交易
106
+ const [gasPrice, initialNonces, quotedOutputs, unsignedList] = await Promise.all([
107
+ getOptimizedGasPrice(provider, getGasPriceConfig(config)),
108
+ // ✅ 使用 pending nonce,避免 xLayer 等链上“已有 pending 交易”导致 nonce too low
109
+ Promise.all(wallets.map((w) => provider.getTransactionCount(w.address, 'pending'))),
110
+ Promise.all(amountsWei.map((amount) => portal.quoteExactInput
111
+ .staticCall({
112
+ inputToken: tokenAddress,
113
+ outputToken: ZERO_ADDRESS,
114
+ inputAmount: amount,
115
+ })
116
+ .catch(() => 0n))),
117
+ // ✅ 并行构建未签名交易(已移除滑点保护:minOuts 固定为 0)
118
+ Promise.all(portals.map((p, i) => p.swapExactInput.populateTransaction({
119
+ inputToken: tokenAddress,
120
+ outputToken: ZERO_ADDRESS,
121
+ inputAmount: amountsWei[i],
122
+ minOutputAmount: 0n,
123
+ permitData: '0x',
124
+ }))),
125
+ ]);
126
+ const extractProfit = shouldExtractProfit();
127
+ const { totalProfit, maxRevenueIndex } = summarizeSellProfits(quotedOutputs, extractProfit);
128
+ // ✅ 获取贿赂金额
129
+ const bribeAmount = getBribeAmount(config);
130
+ const needBribeTx = bribeAmount > 0n;
131
+ const needProfitTx = extractProfit && totalProfit > 0n;
132
+ // ✅ 分配 nonces:贿赂(可选) → 卖出 → 利润(可选)
133
+ let payerNonceOffset = 0;
134
+ let bribeNonce;
135
+ if (needBribeTx && maxRevenueIndex >= 0) {
136
+ bribeNonce = initialNonces[maxRevenueIndex];
137
+ payerNonceOffset++;
138
+ }
139
+ const nonces = initialNonces.map((n, i) => {
140
+ if (i === maxRevenueIndex) {
141
+ return n + payerNonceOffset; // payer 的卖出 nonce 需要偏移
142
+ }
143
+ return n;
144
+ });
145
+ const profitNonce = needProfitTx && maxRevenueIndex >= 0 ? initialNonces[maxRevenueIndex] + payerNonceOffset + 1 : undefined;
146
+ const gasLimit = resolveGasLimit(config.gasLimitMultiplier);
147
+ const gasLimits = new Array(wallets.length).fill(gasLimit);
148
+ const signedTxs = [];
149
+ // ✅ 贿赂交易放在首位
150
+ if (needBribeTx && bribeNonce !== undefined && maxRevenueIndex >= 0) {
151
+ const bribeTx = await wallets[maxRevenueIndex].signTransaction({
152
+ to: BLOCKRAZOR_BUILDER_EOA,
153
+ value: bribeAmount,
154
+ nonce: bribeNonce,
155
+ gasPrice,
156
+ gasLimit: GAS_LIMITS.BRIBE,
157
+ chainId,
158
+ type: getTxType(config),
159
+ });
160
+ signedTxs.push(bribeTx);
161
+ }
162
+ // ✅ 并行签名所有卖出交易
163
+ const signedList = await signBatchTransactions({
164
+ unsignedList,
165
+ wallets,
166
+ nonces,
167
+ gasLimits,
168
+ gasPrice,
169
+ chainId,
170
+ config,
171
+ });
172
+ signedTxs.push(...signedList);
173
+ // ✅ 利润多跳转账(强制 2 跳中转)
174
+ let profitHopWallets;
175
+ if (needProfitTx && profitNonce !== undefined && maxRevenueIndex >= 0) {
176
+ const profitHopResult = await buildProfitHopTransactions({
177
+ provider,
178
+ payerWallet: wallets[maxRevenueIndex],
179
+ profitAmount: totalProfit,
180
+ profitRecipient: getProfitRecipient(),
181
+ hopCount: PROFIT_HOP_COUNT,
182
+ gasPrice,
183
+ chainId,
184
+ txType: getTxType(config),
185
+ startNonce: profitNonce,
186
+ });
187
+ signedTxs.push(...profitHopResult.signedTransactions);
188
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
189
+ }
190
+ return { signedTransactions: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
191
+ }
@@ -1,17 +1,7 @@
1
- import { FlapPrivateBuyMerkleParams, FlapPrivateSellMerkleParams, FlapPrivateTransactionResult, FlapBatchPrivateBuyMerkleParams, FlapBatchPrivateSellMerkleParams, FlapBatchPrivateMerkleResult } from './types.js';
2
1
  /**
3
- * 私有购买(单笔)(Merkle 版本)
2
+ * 私有交易(Merkle 版本)
3
+ *
4
+ * 原超长文件按职责拆分为 private/ 目录下的多个子文件,
5
+ * 对外 export 符号与路径保持不变(见 private/index.ts)。
4
6
  */
5
- export declare function flapPrivateBuyMerkle(params: FlapPrivateBuyMerkleParams): Promise<FlapPrivateTransactionResult>;
6
- /**
7
- * 私有卖出(单笔)(Merkle 版本)
8
- */
9
- export declare function flapPrivateSellMerkle(params: FlapPrivateSellMerkleParams): Promise<FlapPrivateTransactionResult>;
10
- /**
11
- * 批量私有购买(Merkle 版本)
12
- */
13
- export declare function flapBatchPrivateBuyMerkle(params: FlapBatchPrivateBuyMerkleParams): Promise<FlapBatchPrivateMerkleResult>;
14
- /**
15
- * 批量私有卖出(Merkle 版本)
16
- */
17
- export declare function flapBatchPrivateSellMerkle(params: FlapBatchPrivateSellMerkleParams): Promise<FlapBatchPrivateMerkleResult>;
7
+ export * from './private/index.js';