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
@@ -2,124 +2,14 @@
2
2
  * Flap Protocol 内盘捆绑换手(Merkle Bundle)- 先买后卖
3
3
  *
4
4
  * 功能:钱包B先买入代币 → 钱包A卖出相同数量 → 原子执行
5
- */
6
- import { ethers } from 'ethers';
7
- import { CommonBundleConfig } from '../../../utils/bundle-helpers.js';
8
- import { FlapSignConfig } from './config.js';
9
- import type { GeneratedWallet } from '../../../utils/wallet.js';
10
- export declare const BSC_PANCAKE_V2_ROUTER: "0x10ED43C718714eb63d5aA57B78B54704E256024E";
11
- export declare const BSC_WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
12
- export declare const MONAD_PANCAKE_V2_ROUTER = "0xb1bc24c34e88f7d43d5923034e3a14b24daacff9";
13
- export declare const MONAD_WMON: "0x3bd359c1119da7da1d913d1c4d2b7c461115433a";
14
- export declare const ROUTER_ABI: string[];
15
- /**
16
- * 获取 ERC20 代币 → 原生代币的报价
17
- * @param provider - Provider 实例
18
- * @param tokenAddress - ERC20 代币地址
19
- * @param tokenAmount - 代币数量(wei)
20
- * @param chainId - 链 ID(56=BSC, 143=Monad)
21
- * @returns 等值的原生代币数量(wei),失败返回 0n
22
- */
23
- export declare function getTokenToNativeQuote(provider: ethers.JsonRpcProvider, tokenAddress: string, tokenAmount: bigint, chainId: number): Promise<bigint>;
24
- export type FlapChain = 'bsc' | 'xlayer' | 'base';
25
- /**
26
- * 获取 Gas Limit(支持 FlapAnyConfig)
27
- */
28
- export declare function getGasLimit(config: FlapSignConfig | CommonBundleConfig, defaultGas?: number): bigint;
29
- /** 最大 Bundle 签名数 */
30
- export declare const MAX_BUNDLE_SIGNATURES = 50;
31
- /** 贿赂交易数 */
32
- export declare const BRIBE_TX_COUNT = 1;
33
- /** 利润中转交易数(支付者 1 笔 + 中转钱包 PROFIT_HOP_COUNT 笔 + 最终接收 1 笔) */
34
- export declare const PROFIT_TX_COUNT: number;
35
- /** 最大买卖交易数 */
36
- export declare const MAX_SWAP_TX_COUNT: number;
37
- export type UserType = 'v0' | 'v1';
38
- /**
39
- * 根据 userType 获取每笔交易的利润率
40
- */
41
- export declare function getProfitRatePerTxBps(userType?: UserType): number;
42
- export interface FlapBuyFirstSignConfig extends FlapSignConfig {
43
- reserveGasETH?: number;
44
- skipQuoteOnError?: boolean;
45
- userType?: UserType;
46
- }
47
- export interface FlapBuyFirstConfig extends CommonBundleConfig {
48
- apiKey: string;
49
- customRpcUrl?: string;
50
- bundleBlockOffset?: number;
51
- reserveGasETH?: number;
52
- skipQuoteOnError?: boolean;
53
- waitForConfirmation?: boolean;
54
- waitTimeoutMs?: number;
55
- }
56
- export interface FlapBundleBuyFirstSignParams {
57
- chain: FlapChain;
58
- buyerPrivateKey?: string;
59
- buyerPrivateKeys?: string[];
60
- sellerPrivateKey?: string;
61
- sellerPrivateKeys?: string[];
62
- tokenAddress: string;
63
- buyerFunds?: string;
64
- buyerFundsPercentage?: number;
65
- config: FlapBuyFirstSignConfig;
66
- quoteToken?: string;
67
- quoteTokenDecimals?: number;
68
- buyCount?: number;
69
- sellCount?: number;
70
- }
71
- export interface FlapBundleBuyFirstParams {
72
- chain: FlapChain;
73
- buyerPrivateKey: string;
74
- sellerPrivateKey: string;
75
- tokenAddress: string;
76
- buyerFunds?: string;
77
- buyerFundsPercentage?: number;
78
- config: FlapBuyFirstConfig;
79
- }
80
- /** ✅ Flap BuyFirst 结果(简化版) */
81
- export type FlapBuyFirstResult = {
82
- signedTransactions: string[];
83
- profitHopWallets?: GeneratedWallet[];
84
- metadata?: {
85
- buyerAddress: string;
86
- sellerAddress: string;
87
- buyAmount: string;
88
- sellAmount: string;
89
- profitAmount?: string;
90
- buyCount?: number;
91
- sellCount?: number;
92
- buyAmounts?: string[];
93
- sellAmounts?: string[];
94
- };
95
- };
96
- export type ChainContext = {
97
- chainId: number;
98
- nativeToken: string;
99
- portalAddress: string;
100
- provider: ethers.JsonRpcProvider;
101
- };
102
- export type BuyerFundsResult = {
103
- buyerFundsWei: bigint;
104
- buyerBalance: bigint;
105
- };
106
- export type QuoteResult = {
107
- quotedToken: bigint;
108
- sellAmountWei: bigint;
109
- };
110
- export type SellerInfo = {
111
- decimals: number;
112
- };
113
- /** ✅ 多笔买卖 nonce 规划 */
114
- export type MultiNoncePlan = {
115
- buyerNonces: number[];
116
- sellerNonces: number[];
117
- bribeNonce?: number;
118
- profitNonce?: number;
119
- };
120
- /**
121
- * 验证买卖笔数
122
- */
123
- export declare function validateSwapCounts(buyCount: number, sellCount: number): void;
124
- export declare function getChainId(chain: FlapChain): number;
125
- export declare function getNativeTokenName(chain: FlapChain): string;
5
+ *
6
+ * 拆分说明:类型/常量/链上下文/报价/规划/利润/多钱包 已拆到同名子文件,
7
+ * 本文件作为 barrel 保持对外 export 符号/路径/签名不变。
8
+ */
9
+ export * from './swap-buy-first-types.js';
10
+ export * from './swap-buy-first-constants.js';
11
+ export * from './swap-buy-first-chain.js';
12
+ export * from './swap-buy-first-quote.js';
13
+ export * from './swap-buy-first-plan.js';
14
+ export * from './swap-buy-first-profit.js';
15
+ export * from './swap-buy-first-multi-wallet.js';
@@ -2,112 +2,14 @@
2
2
  * Flap Protocol 内盘捆绑换手(Merkle Bundle)- 先买后卖
3
3
  *
4
4
  * 功能:钱包B先买入代币 → 钱包A卖出相同数量 → 原子执行
5
- */
6
- import { Contract } from 'ethers';
7
- import { PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
8
- import { ADDRESSES } from '../../../core/constants/index.js';
9
- import { CHAINS, getProfitRateBps } from '../../../core/constants/index.js';
10
- import { V2_ROUTER_QUOTE_ABI } from '../../../core/shared-abis/common.js';
11
- // ==================== 链常量 ====================
12
- export const BSC_PANCAKE_V2_ROUTER = ADDRESSES.BSC.PancakeV2Router;
13
- export const BSC_WBNB = ADDRESSES.BSC.WBNB;
14
- export const MONAD_PANCAKE_V2_ROUTER = '0xb1bc24c34e88f7d43d5923034e3a14b24daacff9';
15
- export const MONAD_WMON = ADDRESSES.MONAD.WMON;
16
- export const ROUTER_ABI = V2_ROUTER_QUOTE_ABI;
17
- /**
18
- * 获取 ERC20 代币 → 原生代币的报价
19
- * @param provider - Provider 实例
20
- * @param tokenAddress - ERC20 代币地址
21
- * @param tokenAmount - 代币数量(wei)
22
- * @param chainId - 链 ID(56=BSC, 143=Monad)
23
- * @returns 等值的原生代币数量(wei),失败返回 0n
24
- */
25
- export async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chainId) {
26
- if (tokenAmount <= 0n)
27
- return 0n;
28
- try {
29
- if (chainId === CHAINS.BSC.chainId) {
30
- // BSC: 使用 PancakeSwap V2 Router
31
- const router = new Contract(BSC_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
32
- const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, BSC_WBNB]);
33
- return amounts[1];
34
- }
35
- if (chainId === CHAINS.MONAD.chainId) {
36
- // ✅ Monad: 使用 PancakeSwap V2 Router
37
- const router = new Contract(MONAD_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
38
- const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, MONAD_WMON]);
39
- return amounts[1];
40
- }
41
- // ✅ Base (8453) / XLayer (196) 等链暂不支持 V2 报价,返回 0
42
- return 0n;
43
- }
44
- catch {
45
- // 报价失败返回 0(可能是流动性不足或路径不存在)
46
- return 0n;
47
- }
48
- }
49
- /**
50
- * 获取 Gas Limit(支持 FlapAnyConfig)
51
- */
52
- export function getGasLimit(config, defaultGas = 800000) {
53
- if (config.gasLimit !== undefined) {
54
- return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
55
- }
56
- const multiplier = config.gasLimitMultiplier ?? 1.0;
57
- return BigInt(Math.ceil(defaultGas * multiplier));
58
- }
59
- // ==================== 多笔买卖常量 ====================
60
- /** 最大 Bundle 签名数 */
61
- export const MAX_BUNDLE_SIGNATURES = 50;
62
- /** 贿赂交易数 */
63
- export const BRIBE_TX_COUNT = 1;
64
- /** 利润中转交易数(支付者 1 笔 + 中转钱包 PROFIT_HOP_COUNT 笔 + 最终接收 1 笔) */
65
- export const PROFIT_TX_COUNT = PROFIT_HOP_COUNT + 2; // 2 + 2 = 4
66
- /** 最大买卖交易数 */
67
- export const MAX_SWAP_TX_COUNT = MAX_BUNDLE_SIGNATURES - BRIBE_TX_COUNT - PROFIT_TX_COUNT; // 50 - 1 - 4 = 45
68
- /**
69
- * 根据 userType 获取每笔交易的利润率
70
- */
71
- export function getProfitRatePerTxBps(userType) {
72
- if (userType === 'v1') {
73
- return getProfitRateBps('v1Double');
74
- }
75
- return getProfitRateBps('v0Double'); // v0 或默认
76
- }
77
- /**
78
- * 验证买卖笔数
79
- */
80
- export function validateSwapCounts(buyCount, sellCount) {
81
- if (buyCount < 1) {
82
- throw new Error(`买入笔数必须至少为 1,当前为 ${buyCount}`);
83
- }
84
- if (sellCount < 1) {
85
- throw new Error(`卖出笔数必须至少为 1,当前为 ${sellCount}`);
86
- }
87
- const totalSwaps = buyCount + sellCount;
88
- if (totalSwaps > MAX_SWAP_TX_COUNT) {
89
- throw new Error(`买卖笔数总和 (${totalSwaps}) 超出限制 (${MAX_SWAP_TX_COUNT}),` +
90
- `最大签名数为 ${MAX_BUNDLE_SIGNATURES}(${BRIBE_TX_COUNT} 贿赂 + ${PROFIT_TX_COUNT} 利润 + ${MAX_SWAP_TX_COUNT} 买卖)`);
91
- }
92
- }
93
- export function getChainId(chain) {
94
- switch (chain) {
95
- case 'bsc':
96
- return 56;
97
- case 'xlayer':
98
- return 196;
99
- case 'base':
100
- return 8453;
101
- }
102
- }
103
- export function getNativeTokenName(chain) {
104
- switch (chain) {
105
- case 'bsc':
106
- return 'BNB';
107
- case 'xlayer':
108
- return 'OKB';
109
- case 'base':
110
- return 'ETH';
111
- }
112
- }
113
- // 使用公共工具的 getGasLimit,移除本地重复实现
5
+ *
6
+ * 拆分说明:类型/常量/链上下文/报价/规划/利润/多钱包 已拆到同名子文件,
7
+ * 本文件作为 barrel 保持对外 export 符号/路径/签名不变。
8
+ */
9
+ export * from './swap-buy-first-types.js';
10
+ export * from './swap-buy-first-constants.js';
11
+ export * from './swap-buy-first-chain.js';
12
+ export * from './swap-buy-first-quote.js';
13
+ export * from './swap-buy-first-plan.js';
14
+ export * from './swap-buy-first-profit.js';
15
+ export * from './swap-buy-first-multi-wallet.js';
@@ -0,0 +1,20 @@
1
+ import type { FlapBuyFirstResult, FlapBuyFirstSignConfig, FlapChain } from './swap-buy-first-types.js';
2
+ interface FlapMultiWalletParams {
3
+ chain: FlapChain;
4
+ buyerPrivateKeys: string[];
5
+ sellerPrivateKeys: string[];
6
+ tokenAddress: string;
7
+ buyerFunds?: string;
8
+ config: FlapBuyFirstSignConfig;
9
+ quoteToken?: string;
10
+ quoteTokenDecimals?: number;
11
+ }
12
+ /**
13
+ * ✅ Flap 多钱包捆绑换手
14
+ * - 多个买方钱包执行买入(每个钱包1笔)
15
+ * - 多个卖方钱包执行卖出(每个钱包1笔)
16
+ * - 买入总价值 = 卖出总价值
17
+ * - ✅ 优化:最大化并行操作
18
+ */
19
+ export declare function flapBundleBuyFirstMultiWallet(params: FlapMultiWalletParams): Promise<FlapBuyFirstResult>;
20
+ export {};
@@ -0,0 +1,223 @@
1
+ /**
2
+ * Flap BuyFirst 多钱包捆绑换手(从 swap-buy-first-helpers.ts 抽取)
3
+ */
4
+ import { ethers, Contract, Wallet } from 'ethers';
5
+ import { getGasLimit } from '../../../core/gas/bundle-gas.js';
6
+ import { NonceManager, getOptimizedGasPrice } from '../../../utils/bundle-helpers.js';
7
+ import { ZERO_ADDRESS, GAS_LIMITS } from '../../../core/constants/index.js';
8
+ import { ERC20_BALANCE_ABI } from '../../../core/shared-abis/common.js';
9
+ import { BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI, getBribeAmount, getGasPriceConfig, getTxType, } from './config.js';
10
+ import { buildTransactionRequest } from '../../../core/tx/build-request.js';
11
+ import { splitAmountByWeight as splitAmount } from '../../../core/amount/split-by-weight.js';
12
+ import { createChainContext } from './swap-buy-first-chain.js';
13
+ import { quoteBuyerOutput, estimateSellFunds, getTokenToNativeQuote } from './swap-buy-first-quote.js';
14
+ import { getProfitRatePerTxBps, validateSwapCounts } from './swap-buy-first-plan.js';
15
+ import { buildProfitTransaction } from './swap-buy-first-profit.js';
16
+ /**
17
+ * ✅ Flap 多钱包捆绑换手
18
+ * - 多个买方钱包执行买入(每个钱包1笔)
19
+ * - 多个卖方钱包执行卖出(每个钱包1笔)
20
+ * - 买入总价值 = 卖出总价值
21
+ * - ✅ 优化:最大化并行操作
22
+ */
23
+ export async function flapBundleBuyFirstMultiWallet(params) {
24
+ const { chain, buyerPrivateKeys, sellerPrivateKeys, tokenAddress, buyerFunds, config, quoteToken, quoteTokenDecimals = 18, } = params;
25
+ const buyCount = buyerPrivateKeys.length;
26
+ const sellCount = sellerPrivateKeys.length;
27
+ if (buyCount === 0)
28
+ throw new Error('买方钱包数量不能为0');
29
+ if (sellCount === 0)
30
+ throw new Error('卖方钱包数量不能为0');
31
+ // 验证总交易数不超过限制
32
+ validateSwapCounts(buyCount, sellCount);
33
+ // ✅ 计算利润比例(根据 userType 动态调整)
34
+ const totalTxCount = buyCount + sellCount;
35
+ const profitRateBps = getProfitRatePerTxBps(config.userType) * totalTxCount;
36
+ const chainContext = createChainContext(chain, config.rpcUrl);
37
+ const nonceManager = new NonceManager(chainContext.provider);
38
+ // 创建所有钱包实例
39
+ const buyers = buyerPrivateKeys.map((pk) => new Wallet(pk, chainContext.provider));
40
+ const sellers = sellerPrivateKeys.map((pk) => new Wallet(pk, chainContext.provider));
41
+ // 使用第一个卖方作为主卖方(支付贿赂和利润)
42
+ const mainSeller = sellers[0];
43
+ // ✅ 判断是否使用原生代币
44
+ const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
45
+ const inputToken = useNativeToken ? ZERO_ADDRESS : quoteToken;
46
+ const outputToken = inputToken;
47
+ // ✅ 计算总交易金额
48
+ if (!buyerFunds) {
49
+ throw new Error('多钱包模式必须提供 buyerFunds(总交易金额)');
50
+ }
51
+ const totalFundsWei = useNativeToken
52
+ ? ethers.parseEther(String(buyerFunds))
53
+ : ethers.parseUnits(String(buyerFunds), quoteTokenDecimals);
54
+ if (totalFundsWei <= 0n) {
55
+ throw new Error('交易金额必须大于0');
56
+ }
57
+ const finalGasLimit = getGasLimit(config, 800000);
58
+ const txType = getTxType(config);
59
+ const bribeAmount = getBribeAmount(config);
60
+ const needBribeTx = bribeAmount > 0n;
61
+ // ✅ 第一批并行:报价 + Gas价格 + 代币精度 + 所有钱包 nonces
62
+ // 预先计算所有唯一钱包地址(去重)
63
+ const allWallets = [...sellers, ...buyers];
64
+ const uniqueWallets = allWallets.filter((w, i) => {
65
+ const addr = w.address.toLowerCase();
66
+ const firstIdx = allWallets.findIndex((x) => x.address.toLowerCase() === addr);
67
+ return firstIdx === i;
68
+ });
69
+ const erc20 = new Contract(tokenAddress, ERC20_BALANCE_ABI, chainContext.provider);
70
+ const [quoteResult, gasPrice, decimals, noncesArray] = await Promise.all([
71
+ quoteBuyerOutput({
72
+ portalAddress: chainContext.portalAddress,
73
+ tokenAddress,
74
+ buyerFundsWei: totalFundsWei,
75
+ provider: chainContext.provider,
76
+ skipQuoteOnError: config.skipQuoteOnError,
77
+ inputToken,
78
+ }),
79
+ getOptimizedGasPrice(chainContext.provider, getGasPriceConfig(config)),
80
+ erc20.decimals(),
81
+ nonceManager.getNextNoncesForWallets(uniqueWallets),
82
+ ]);
83
+ // 构建 nonces Map
84
+ const noncesMap = new Map();
85
+ uniqueWallets.forEach((wallet, i) => {
86
+ noncesMap.set(wallet.address.toLowerCase(), noncesArray[i]);
87
+ });
88
+ const priorityFee = gasPrice / 10n === 0n ? 1n : gasPrice / 10n;
89
+ // ✅ 将总金额平均分配给买方
90
+ const buyAmountsWei = splitAmount(totalFundsWei, buyCount);
91
+ // ✅ 将代币平均分配给卖方
92
+ const sellAmountsWei = splitAmount(quoteResult.sellAmountWei, sellCount);
93
+ // ✅ 第二批并行:估算利润 + ERC20 转原生代币报价(如需要)
94
+ const portal = new Contract(chainContext.portalAddress, PORTAL_ABI, chainContext.provider);
95
+ const estimatedSellFunds = await estimateSellFunds(portal, tokenAddress, quoteResult.sellAmountWei, outputToken);
96
+ const profitBase = estimatedSellFunds > 0n ? estimatedSellFunds : totalFundsWei;
97
+ const tokenProfitAmount = (profitBase * BigInt(profitRateBps)) / 10000n;
98
+ // ERC20 购买:获取代币利润等值的原生代币报价
99
+ let nativeProfitAmount = tokenProfitAmount;
100
+ if (!useNativeToken && tokenProfitAmount > 0n) {
101
+ nativeProfitAmount = await getTokenToNativeQuote(chainContext.provider, inputToken, tokenProfitAmount, chainContext.chainId);
102
+ }
103
+ // ✅ 第三批并行:构建并签名所有交易
104
+ const allTransactions = [];
105
+ // 1. 贿赂交易(由主卖方支付)- 先处理以确定 nonce 偏移
106
+ let bribeTxPromise = null;
107
+ if (needBribeTx) {
108
+ const mainSellerAddr = mainSeller.address.toLowerCase();
109
+ const bribeNonce = noncesMap.get(mainSellerAddr);
110
+ noncesMap.set(mainSellerAddr, bribeNonce + 1);
111
+ bribeTxPromise = mainSeller.signTransaction({
112
+ to: BLOCKRAZOR_BUILDER_EOA,
113
+ value: bribeAmount,
114
+ nonce: bribeNonce,
115
+ gasPrice,
116
+ gasLimit: GAS_LIMITS.BRIBE,
117
+ chainId: chainContext.chainId,
118
+ type: txType,
119
+ });
120
+ }
121
+ // 2. 预分配所有 nonces(同步操作,避免竞态)
122
+ const buyerNonces = [];
123
+ const sellerNonces = [];
124
+ buyers.forEach((buyer) => {
125
+ const addr = buyer.address.toLowerCase();
126
+ const nonce = noncesMap.get(addr);
127
+ buyerNonces.push(nonce);
128
+ noncesMap.set(addr, nonce + 1);
129
+ });
130
+ sellers.forEach((seller) => {
131
+ const addr = seller.address.toLowerCase();
132
+ const nonce = noncesMap.get(addr);
133
+ sellerNonces.push(nonce);
134
+ noncesMap.set(addr, nonce + 1);
135
+ });
136
+ // 3. 并行构建所有买入交易
137
+ const buyTxPromises = buyers.map(async (buyer, i) => {
138
+ const portalBuyer = new Contract(chainContext.portalAddress, PORTAL_ABI, buyer);
139
+ const unsigned = await portalBuyer.swapExactInput.populateTransaction({
140
+ inputToken,
141
+ outputToken: tokenAddress,
142
+ inputAmount: buyAmountsWei[i],
143
+ minOutputAmount: 0n,
144
+ permitData: '0x',
145
+ }, useNativeToken ? { value: buyAmountsWei[i] } : {});
146
+ return buyer.signTransaction(buildTransactionRequest(unsigned, {
147
+ from: buyer.address,
148
+ nonce: buyerNonces[i],
149
+ gasLimit: finalGasLimit,
150
+ gasPrice,
151
+ priorityFee,
152
+ chainId: chainContext.chainId,
153
+ txType,
154
+ value: useNativeToken ? buyAmountsWei[i] : 0n,
155
+ }));
156
+ });
157
+ // 4. 并行构建所有卖出交易
158
+ const sellTxPromises = sellers.map(async (seller, i) => {
159
+ const portalSeller = new Contract(chainContext.portalAddress, PORTAL_ABI, seller);
160
+ const unsigned = await portalSeller.swapExactInput.populateTransaction({
161
+ inputToken: tokenAddress,
162
+ outputToken,
163
+ inputAmount: sellAmountsWei[i],
164
+ minOutputAmount: 0n,
165
+ permitData: '0x',
166
+ });
167
+ return seller.signTransaction(buildTransactionRequest(unsigned, {
168
+ from: seller.address,
169
+ nonce: sellerNonces[i],
170
+ gasLimit: finalGasLimit,
171
+ gasPrice,
172
+ priorityFee,
173
+ chainId: chainContext.chainId,
174
+ txType,
175
+ value: 0n,
176
+ }));
177
+ });
178
+ // ✅ 并行签名所有交易(贿赂 + 买入 + 卖出)
179
+ const [bribeTx, signedBuys, signedSells] = await Promise.all([
180
+ bribeTxPromise,
181
+ Promise.all(buyTxPromises),
182
+ Promise.all(sellTxPromises),
183
+ ]);
184
+ // 组装交易顺序:贿赂 → 买入 → 卖出
185
+ if (bribeTx)
186
+ allTransactions.push(bribeTx);
187
+ allTransactions.push(...signedBuys, ...signedSells);
188
+ // 5. 利润多跳转账(由主卖方支付)
189
+ let profitHopWallets;
190
+ if (nativeProfitAmount > 0n) {
191
+ const mainSellerAddr = mainSeller.address.toLowerCase();
192
+ const profitNonce = noncesMap.get(mainSellerAddr);
193
+ const profitResult = await buildProfitTransaction({
194
+ provider: chainContext.provider,
195
+ seller: mainSeller,
196
+ profitAmount: nativeProfitAmount,
197
+ profitNonce,
198
+ gasPrice,
199
+ chainId: chainContext.chainId,
200
+ txType,
201
+ });
202
+ if (profitResult) {
203
+ allTransactions.push(...profitResult.signedTransactions);
204
+ profitHopWallets = profitResult.hopWallets;
205
+ }
206
+ }
207
+ nonceManager.clearTemp();
208
+ return {
209
+ signedTransactions: allTransactions,
210
+ profitHopWallets,
211
+ metadata: {
212
+ buyerAddress: buyers.map((b) => b.address).join(','),
213
+ sellerAddress: sellers.map((s) => s.address).join(','),
214
+ buyAmount: ethers.formatEther(totalFundsWei),
215
+ sellAmount: ethers.formatUnits(quoteResult.sellAmountWei, decimals),
216
+ profitAmount: nativeProfitAmount > 0n ? ethers.formatEther(nativeProfitAmount) : undefined,
217
+ buyCount,
218
+ sellCount,
219
+ buyAmounts: buyAmountsWei.map((amt) => ethers.formatEther(amt)),
220
+ sellAmounts: sellAmountsWei.map((amt) => ethers.formatUnits(amt, decimals)),
221
+ },
222
+ };
223
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Flap BuyFirst nonce 规划与笔数校验(从 swap-buy-first-helpers.ts 抽取)
3
+ */
4
+ import type { Wallet } from 'ethers';
5
+ import type { NonceManager } from '../../../utils/bundle-helpers.js';
6
+ import type { MultiNoncePlan, UserType } from './swap-buy-first-types.js';
7
+ /**
8
+ * 根据 userType 获取每笔交易的利润率
9
+ */
10
+ export declare function getProfitRatePerTxBps(userType?: UserType): number;
11
+ /**
12
+ * 验证买卖笔数
13
+ */
14
+ export declare function validateSwapCounts(buyCount: number, sellCount: number): void;
15
+ type PlanMultiNonceParams = {
16
+ buyer: Wallet;
17
+ seller: Wallet;
18
+ buyCount: number;
19
+ sellCount: number;
20
+ extractProfit: boolean;
21
+ needBribeTx: boolean;
22
+ sameAddress: boolean;
23
+ nonceManager: NonceManager;
24
+ };
25
+ /**
26
+ * ✅ 规划多笔交易 nonce
27
+ * 交易顺序:贿赂 → 买入(多笔) → 卖出(多笔) → 利润
28
+ *
29
+ * 利润中转需要 PROFIT_HOP_COUNT + 1 个 nonce(支付者→跳1→跳2→利润地址)
30
+ */
31
+ export declare function planMultiNonces({ buyer, seller, buyCount, sellCount, extractProfit, needBribeTx, sameAddress, nonceManager, }: PlanMultiNonceParams): Promise<MultiNoncePlan>;
32
+ export {};
@@ -0,0 +1,66 @@
1
+ import { getProfitRateBps } from '../../../core/constants/index.js';
2
+ import { BRIBE_TX_COUNT, MAX_BUNDLE_SIGNATURES, MAX_SWAP_TX_COUNT, PROFIT_TX_COUNT, } from './swap-buy-first-constants.js';
3
+ /**
4
+ * 根据 userType 获取每笔交易的利润率
5
+ */
6
+ export function getProfitRatePerTxBps(userType) {
7
+ if (userType === 'v1') {
8
+ return getProfitRateBps('v1Double');
9
+ }
10
+ return getProfitRateBps('v0Double'); // v0 或默认
11
+ }
12
+ /**
13
+ * 验证买卖笔数
14
+ */
15
+ export function validateSwapCounts(buyCount, sellCount) {
16
+ if (buyCount < 1) {
17
+ throw new Error(`买入笔数必须至少为 1,当前为 ${buyCount}`);
18
+ }
19
+ if (sellCount < 1) {
20
+ throw new Error(`卖出笔数必须至少为 1,当前为 ${sellCount}`);
21
+ }
22
+ const totalSwaps = buyCount + sellCount;
23
+ if (totalSwaps > MAX_SWAP_TX_COUNT) {
24
+ throw new Error(`买卖笔数总和 (${totalSwaps}) 超出限制 (${MAX_SWAP_TX_COUNT}),` +
25
+ `最大签名数为 ${MAX_BUNDLE_SIGNATURES}(${BRIBE_TX_COUNT} 贿赂 + ${PROFIT_TX_COUNT} 利润 + ${MAX_SWAP_TX_COUNT} 买卖)`);
26
+ }
27
+ }
28
+ /**
29
+ * ✅ 规划多笔交易 nonce
30
+ * 交易顺序:贿赂 → 买入(多笔) → 卖出(多笔) → 利润
31
+ *
32
+ * 利润中转需要 PROFIT_HOP_COUNT + 1 个 nonce(支付者→跳1→跳2→利润地址)
33
+ */
34
+ export async function planMultiNonces({ buyer, seller, buyCount, sellCount, extractProfit, needBribeTx, sameAddress, nonceManager, }) {
35
+ // 利润中转交易数(支付者只需要 1 个 nonce,中转钱包的 nonce 由 buildProfitHopTransactions 内部处理)
36
+ const profitNonceCount = extractProfit ? 1 : 0;
37
+ if (sameAddress) {
38
+ // 同一地址:贿赂(可选) + 买入(多笔) + 卖出(多笔) + 利润(可选)
39
+ const bribeTxCount = needBribeTx ? 1 : 0;
40
+ const totalTxCount = bribeTxCount + buyCount + sellCount + profitNonceCount;
41
+ const nonces = await nonceManager.getNextNonceBatch(buyer, totalTxCount);
42
+ let idx = 0;
43
+ const bribeNonce = needBribeTx ? nonces[idx++] : undefined;
44
+ const buyerNonces = nonces.slice(idx, idx + buyCount);
45
+ idx += buyCount;
46
+ const sellerNonces = nonces.slice(idx, idx + sellCount);
47
+ idx += sellCount;
48
+ const profitNonce = extractProfit ? nonces[idx] : undefined;
49
+ return { buyerNonces, sellerNonces, bribeNonce, profitNonce };
50
+ }
51
+ // 不同地址
52
+ // 买方:buyCount 个 nonce
53
+ // 卖方:贿赂(可选) + sellCount + 利润(可选) 个 nonce
54
+ const bribeTxCount = needBribeTx ? 1 : 0;
55
+ const sellerTxCount = bribeTxCount + sellCount + profitNonceCount;
56
+ const [buyerNonces, sellerNoncesAll] = await Promise.all([
57
+ nonceManager.getNextNonceBatch(buyer, buyCount),
58
+ nonceManager.getNextNonceBatch(seller, sellerTxCount),
59
+ ]);
60
+ let idx = 0;
61
+ const bribeNonce = needBribeTx ? sellerNoncesAll[idx++] : undefined;
62
+ const sellerNonces = sellerNoncesAll.slice(idx, idx + sellCount);
63
+ idx += sellCount;
64
+ const profitNonce = extractProfit ? sellerNoncesAll[idx] : undefined;
65
+ return { buyerNonces, sellerNonces, bribeNonce, profitNonce };
66
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Flap BuyFirst 利润多跳转账 helper(从 swap-buy-first-helpers.ts 抽取)
3
+ */
4
+ import type { ethers, Wallet } from 'ethers';
5
+ import type { GeneratedWallet } from '../../../utils/wallet.js';
6
+ type ProfitTxParams = {
7
+ provider: ethers.JsonRpcProvider;
8
+ seller: Wallet;
9
+ profitAmount: bigint;
10
+ profitNonce?: number;
11
+ gasPrice: bigint;
12
+ chainId: number;
13
+ txType: number;
14
+ };
15
+ /**
16
+ * 构建利润多跳转账交易(强制 2 跳中转)
17
+ */
18
+ export declare function buildProfitTransaction({ provider, seller, profitAmount, profitNonce, gasPrice, chainId, txType, }: ProfitTxParams): Promise<{
19
+ signedTransactions: string[];
20
+ hopWallets?: GeneratedWallet[];
21
+ } | null>;
22
+ export {};
@@ -0,0 +1,22 @@
1
+ import { buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
2
+ import { getProfitRecipient } from './config.js';
3
+ /**
4
+ * 构建利润多跳转账交易(强制 2 跳中转)
5
+ */
6
+ export async function buildProfitTransaction({ provider, seller, profitAmount, profitNonce, gasPrice, chainId, txType, }) {
7
+ if (profitNonce === undefined || profitAmount === 0n) {
8
+ return null;
9
+ }
10
+ const profitHopResult = await buildProfitHopTransactions({
11
+ provider,
12
+ payerWallet: seller,
13
+ profitAmount,
14
+ profitRecipient: getProfitRecipient(),
15
+ hopCount: PROFIT_HOP_COUNT,
16
+ gasPrice,
17
+ chainId,
18
+ txType,
19
+ startNonce: profitNonce,
20
+ });
21
+ return { signedTransactions: profitHopResult.signedTransactions, hopWallets: profitHopResult.hopWallets };
22
+ }