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,18 @@
1
+ import { Wallet, JsonRpcProvider } from 'ethers';
2
+ import { type DisperseHopPath } from './bundle-swap-types.js';
3
+ /**
4
+ * 生成分发多跳路径
5
+ */
6
+ export declare function generateDisperseHopPaths(targetAddresses: string[], hopCount: number, provider: JsonRpcProvider): DisperseHopPath[];
7
+ /**
8
+ * 构建原生代币多跳转账链
9
+ */
10
+ export declare function buildNativeHopChain(payer: Wallet, path: DisperseHopPath, finalAmount: bigint, gasPrice: bigint, chainId: number, txType: 0 | 2, payerNonce: number): Promise<string[]>;
11
+ /**
12
+ * 构建 ERC20 多跳转账链(需要配合 BNB 多跳使用)
13
+ */
14
+ export declare function buildERC20HopChain(payer: Wallet, path: DisperseHopPath, erc20Address: string, erc20Amount: bigint, gasPrice: bigint, chainId: number, txType: 0 | 2, payerNonce: number): Promise<string[]>;
15
+ /**
16
+ * 构建 BNB 多跳转账链(为 ERC20 中间钱包预留 gas)
17
+ */
18
+ export declare function buildBNBHopChainForERC20(payer: Wallet, path: DisperseHopPath, finalGasAmount: bigint, gasPrice: bigint, chainId: number, txType: 0 | 2, payerNonce: number): Promise<string[]>;
@@ -0,0 +1,227 @@
1
+ import { ethers, Wallet } from 'ethers';
2
+ import { ERC20_ABI } from '../../../abis/common.js';
3
+ import { generateWallets } from '../../../utils/wallet.js';
4
+ import { ERC20_TRANSFER_GAS_LIMIT_HOP, NATIVE_TRANSFER_GAS_LIMIT, } from './bundle-swap-types.js';
5
+ /**
6
+ * 生成分发多跳路径
7
+ */
8
+ export function generateDisperseHopPaths(targetAddresses, hopCount, provider) {
9
+ if (hopCount <= 0) {
10
+ return targetAddresses.map((addr) => ({
11
+ targetAddress: addr,
12
+ hopWallets: [],
13
+ hopWalletsInfo: [],
14
+ }));
15
+ }
16
+ return targetAddresses.map((targetAddress) => {
17
+ const hopWalletsInfo = generateWallets(hopCount);
18
+ const hopWallets = hopWalletsInfo.map((w) => new Wallet(w.privateKey, provider));
19
+ return { targetAddress, hopWallets, hopWalletsInfo };
20
+ });
21
+ }
22
+ /**
23
+ * 构建原生代币多跳转账链
24
+ */
25
+ export async function buildNativeHopChain(payer, path, finalAmount, gasPrice, chainId, txType, payerNonce) {
26
+ const signedTxs = [];
27
+ const hopCount = path.hopWallets.length;
28
+ if (hopCount === 0) {
29
+ const tx = {
30
+ to: path.targetAddress,
31
+ value: finalAmount,
32
+ nonce: payerNonce,
33
+ gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
34
+ chainId,
35
+ type: txType,
36
+ };
37
+ if (txType === 2) {
38
+ tx.maxFeePerGas = gasPrice;
39
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
40
+ }
41
+ else {
42
+ tx.gasPrice = gasPrice;
43
+ }
44
+ signedTxs.push(await payer.signTransaction(tx));
45
+ return signedTxs;
46
+ }
47
+ const hopGasCost = NATIVE_TRANSFER_GAS_LIMIT * gasPrice;
48
+ // 计算每跳需要的金额
49
+ const amountsPerHop = [];
50
+ for (let i = 0; i < hopCount; i++) {
51
+ const remainingHops = hopCount - i;
52
+ amountsPerHop.push(finalAmount + hopGasCost * BigInt(remainingHops));
53
+ }
54
+ // payer → hop1
55
+ const firstTx = {
56
+ to: path.hopWallets[0].address,
57
+ value: amountsPerHop[0],
58
+ nonce: payerNonce,
59
+ gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
60
+ chainId,
61
+ type: txType,
62
+ };
63
+ if (txType === 2) {
64
+ firstTx.maxFeePerGas = gasPrice;
65
+ firstTx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
66
+ }
67
+ else {
68
+ firstTx.gasPrice = gasPrice;
69
+ }
70
+ signedTxs.push(await payer.signTransaction(firstTx));
71
+ // hop1 → hop2 → ... → target
72
+ for (let i = 0; i < hopCount; i++) {
73
+ const fromWallet = path.hopWallets[i];
74
+ const toAddress = i === hopCount - 1 ? path.targetAddress : path.hopWallets[i + 1].address;
75
+ const amount = i === hopCount - 1 ? finalAmount : amountsPerHop[i + 1];
76
+ const tx = {
77
+ to: toAddress,
78
+ value: amount,
79
+ nonce: 0,
80
+ gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
81
+ chainId,
82
+ type: txType,
83
+ };
84
+ if (txType === 2) {
85
+ tx.maxFeePerGas = gasPrice;
86
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
87
+ }
88
+ else {
89
+ tx.gasPrice = gasPrice;
90
+ }
91
+ signedTxs.push(await fromWallet.signTransaction(tx));
92
+ }
93
+ return signedTxs;
94
+ }
95
+ /**
96
+ * 构建 ERC20 多跳转账链(需要配合 BNB 多跳使用)
97
+ */
98
+ export async function buildERC20HopChain(payer, path, erc20Address, erc20Amount, gasPrice, chainId, txType, payerNonce) {
99
+ const signedTxs = [];
100
+ const hopCount = path.hopWallets.length;
101
+ const erc20Interface = new ethers.Interface(ERC20_ABI);
102
+ if (hopCount === 0) {
103
+ const data = erc20Interface.encodeFunctionData('transfer', [path.targetAddress, erc20Amount]);
104
+ const tx = {
105
+ to: erc20Address,
106
+ data,
107
+ value: 0n,
108
+ nonce: payerNonce,
109
+ gasLimit: ERC20_TRANSFER_GAS_LIMIT_HOP,
110
+ chainId,
111
+ type: txType,
112
+ };
113
+ if (txType === 2) {
114
+ tx.maxFeePerGas = gasPrice;
115
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
116
+ }
117
+ else {
118
+ tx.gasPrice = gasPrice;
119
+ }
120
+ signedTxs.push(await payer.signTransaction(tx));
121
+ return signedTxs;
122
+ }
123
+ // payer → hop1
124
+ const firstData = erc20Interface.encodeFunctionData('transfer', [path.hopWallets[0].address, erc20Amount]);
125
+ const firstTx = {
126
+ to: erc20Address,
127
+ data: firstData,
128
+ value: 0n,
129
+ nonce: payerNonce,
130
+ gasLimit: ERC20_TRANSFER_GAS_LIMIT_HOP,
131
+ chainId,
132
+ type: txType,
133
+ };
134
+ if (txType === 2) {
135
+ firstTx.maxFeePerGas = gasPrice;
136
+ firstTx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
137
+ }
138
+ else {
139
+ firstTx.gasPrice = gasPrice;
140
+ }
141
+ signedTxs.push(await payer.signTransaction(firstTx));
142
+ // hop1 → hop2 → ... → target (nonce=1,nonce=0 用于 BNB 转发)
143
+ for (let i = 0; i < hopCount; i++) {
144
+ const fromWallet = path.hopWallets[i];
145
+ const toAddress = i === hopCount - 1 ? path.targetAddress : path.hopWallets[i + 1].address;
146
+ const data = erc20Interface.encodeFunctionData('transfer', [toAddress, erc20Amount]);
147
+ const tx = {
148
+ to: erc20Address,
149
+ data,
150
+ value: 0n,
151
+ nonce: 1, // nonce=0 已用于 BNB 转发
152
+ gasLimit: ERC20_TRANSFER_GAS_LIMIT_HOP,
153
+ chainId,
154
+ type: txType,
155
+ };
156
+ if (txType === 2) {
157
+ tx.maxFeePerGas = gasPrice;
158
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
159
+ }
160
+ else {
161
+ tx.gasPrice = gasPrice;
162
+ }
163
+ signedTxs.push(await fromWallet.signTransaction(tx));
164
+ }
165
+ return signedTxs;
166
+ }
167
+ /**
168
+ * 构建 BNB 多跳转账链(为 ERC20 中间钱包预留 gas)
169
+ */
170
+ export async function buildBNBHopChainForERC20(payer, path, finalGasAmount, gasPrice, chainId, txType, payerNonce) {
171
+ const signedTxs = [];
172
+ const hopCount = path.hopWallets.length;
173
+ if (hopCount === 0) {
174
+ // 无多跳时不需要转 gas
175
+ return signedTxs;
176
+ }
177
+ const hopGasCost = NATIVE_TRANSFER_GAS_LIMIT * gasPrice;
178
+ const erc20GasCost = ERC20_TRANSFER_GAS_LIMIT_HOP * gasPrice;
179
+ // 每个中间钱包需要: BNB 转发 gas + ERC20 转发 gas
180
+ const gasPerHop = hopGasCost + erc20GasCost * 2n; // 2倍安全系数
181
+ // 计算每跳需要的金额
182
+ const amountsPerHop = [];
183
+ for (let i = 0; i < hopCount; i++) {
184
+ const remainingHops = hopCount - i;
185
+ amountsPerHop.push(finalGasAmount + gasPerHop * BigInt(remainingHops));
186
+ }
187
+ // payer → hop1
188
+ const firstTx = {
189
+ to: path.hopWallets[0].address,
190
+ value: amountsPerHop[0],
191
+ nonce: payerNonce,
192
+ gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
193
+ chainId,
194
+ type: txType,
195
+ };
196
+ if (txType === 2) {
197
+ firstTx.maxFeePerGas = gasPrice;
198
+ firstTx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
199
+ }
200
+ else {
201
+ firstTx.gasPrice = gasPrice;
202
+ }
203
+ signedTxs.push(await payer.signTransaction(firstTx));
204
+ // hop1 → hop2 → ... → target (nonce=0)
205
+ for (let i = 0; i < hopCount; i++) {
206
+ const fromWallet = path.hopWallets[i];
207
+ const toAddress = i === hopCount - 1 ? path.targetAddress : path.hopWallets[i + 1].address;
208
+ const amount = i === hopCount - 1 ? finalGasAmount : amountsPerHop[i + 1];
209
+ const tx = {
210
+ to: toAddress,
211
+ value: amount,
212
+ nonce: 0,
213
+ gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
214
+ chainId,
215
+ type: txType,
216
+ };
217
+ if (txType === 2) {
218
+ tx.maxFeePerGas = gasPrice;
219
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
220
+ }
221
+ else {
222
+ tx.gasPrice = gasPrice;
223
+ }
224
+ signedTxs.push(await fromWallet.signTransaction(tx));
225
+ }
226
+ return signedTxs;
227
+ }
@@ -0,0 +1,14 @@
1
+ import { ethers } from 'ethers';
2
+ import { type QuoteBNBResult, type QuoteSellParams, type UserType } from './bundle-swap-types.js';
3
+ export declare function quoteSellOutput({ routeParams, sellAmountWei, provider, v2RouterAddress, }: QuoteSellParams): Promise<QuoteBNBResult>;
4
+ /**
5
+ * 根据 userType 计算利润率
6
+ */
7
+ export declare function getProfitRateBps(userType?: UserType): number;
8
+ export declare function calculateProfitAmount(estimatedBNBOut: bigint, userType?: UserType): bigint;
9
+ /**
10
+ * ✅ 获取 ERC20 代币 → 原生代币(BNB)的报价
11
+ * 用于将 ERC20 利润转换为 BNB
12
+ * 使用共享的报价函数
13
+ */
14
+ export declare function getERC20ToNativeQuote(provider: ethers.JsonRpcProvider, tokenAddress: string, tokenAmount: bigint, version?: 'v2' | 'v3', fee?: number): Promise<bigint>;
@@ -0,0 +1,84 @@
1
+ import { ADDRESSES } from '../../../core/constants/index.js';
2
+ import { quoteV2, quoteV3 } from '../../../core/quote/quote-helpers.js';
3
+ import { WBNB_ADDRESS, } from './bundle-swap-types.js';
4
+ export async function quoteSellOutput({ routeParams, sellAmountWei, provider, v2RouterAddress, }) {
5
+ if (routeParams.routeType === 'v2') {
6
+ const { v2Path } = routeParams;
7
+ const tokenIn = v2Path[0];
8
+ const tokenOut = v2Path[v2Path.length - 1];
9
+ const result = await quoteV2(provider, tokenIn, tokenOut, sellAmountWei, 'BSC', v2RouterAddress);
10
+ if (result.amountOut > 0n) {
11
+ return { estimatedBNBOut: result.amountOut };
12
+ }
13
+ throw new Error('V2 报价失败: 所有路径均无效');
14
+ }
15
+ // ==================== V3 单跳报价 ====================
16
+ if (routeParams.routeType === 'v3-single') {
17
+ const params = routeParams;
18
+ const result = await quoteV3(provider, params.v3TokenIn, params.v3TokenOut, sellAmountWei, 'BSC', params.v3Fee);
19
+ if (result.amountOut > 0n) {
20
+ return { estimatedBNBOut: result.amountOut };
21
+ }
22
+ // ❌ V3 报价失败时不再 fallback 到 V2,因为价格可能差异很大
23
+ throw new Error(`V3 单跳报价失败: tokenIn=${params.v3TokenIn}, tokenOut=${params.v3TokenOut}, fee=${params.v3Fee}`);
24
+ }
25
+ // ==================== V3 多跳报价 ====================
26
+ if (routeParams.routeType === 'v3-multi') {
27
+ const params = routeParams;
28
+ if (params.v3LpAddresses && params.v3LpAddresses.length > 0) {
29
+ const tokenIn = params.v3ExactTokenIn;
30
+ const WBNB = ADDRESSES.BSC.WBNB;
31
+ const result = await quoteV3(provider, tokenIn, WBNB, sellAmountWei, 'BSC');
32
+ if (result.amountOut > 0n) {
33
+ return { estimatedBNBOut: result.amountOut };
34
+ }
35
+ }
36
+ // ❌ V3 多跳报价失败时不再 fallback 到 V2,因为价格可能差异很大
37
+ throw new Error(`V3 多跳报价失败: LPs=${params.v3LpAddresses?.join(', ')}, tokenIn=${params.v3ExactTokenIn}`);
38
+ }
39
+ throw new Error(`不支持的路由类型: ${routeParams.routeType}`);
40
+ }
41
+ /**
42
+ * 根据 userType 计算利润率
43
+ */
44
+ export function getProfitRateBps(userType) {
45
+ if (userType === 'v0') {
46
+ return 4; // 0.06%
47
+ }
48
+ else if (userType === 'v1') {
49
+ return 5; // 0.05%
50
+ }
51
+ return 4; // 默认 0.06%
52
+ }
53
+ export function calculateProfitAmount(estimatedBNBOut, userType) {
54
+ if (estimatedBNBOut <= 0n) {
55
+ return 0n;
56
+ }
57
+ const rateBps = getProfitRateBps(userType);
58
+ return (estimatedBNBOut * BigInt(rateBps)) / 10000n;
59
+ }
60
+ /**
61
+ * ✅ 获取 ERC20 代币 → 原生代币(BNB)的报价
62
+ * 用于将 ERC20 利润转换为 BNB
63
+ * 使用共享的报价函数
64
+ */
65
+ export async function getERC20ToNativeQuote(provider, tokenAddress, tokenAmount, version = 'v2', fee) {
66
+ if (tokenAmount <= 0n)
67
+ return 0n;
68
+ const tokenLower = tokenAddress.toLowerCase();
69
+ const wbnbLower = WBNB_ADDRESS.toLowerCase();
70
+ // 如果代币本身就是 WBNB,直接返回
71
+ if (tokenLower === wbnbLower) {
72
+ return tokenAmount;
73
+ }
74
+ // 使用共享的报价函数
75
+ if (version === 'v3') {
76
+ const result = await quoteV3(provider, tokenAddress, WBNB_ADDRESS, tokenAmount, 'BSC', fee);
77
+ if (result.amountOut > 0n) {
78
+ return result.amountOut;
79
+ }
80
+ return 0n;
81
+ }
82
+ const result = await quoteV2(provider, tokenAddress, WBNB_ADDRESS, tokenAmount, 'BSC');
83
+ return result.amountOut > 0n ? result.amountOut : 0n;
84
+ }
@@ -0,0 +1,42 @@
1
+ import { type GeneratedWallet } from '../../../utils/wallet.js';
2
+ import { type PancakeSwapSignConfig, type RouteParams } from './bundle-swap-helpers.js';
3
+ /**
4
+ * 批量换手参数(一卖多买)
5
+ */
6
+ export interface PancakeBatchSwapSignParams {
7
+ sellerPrivateKey: string;
8
+ sellAmount?: string;
9
+ sellPercentage?: number;
10
+ buyerPrivateKeys: string[];
11
+ buyerAmounts?: string[];
12
+ buyerRatios?: number[];
13
+ tokenAddress: string;
14
+ routeParams: RouteParams;
15
+ config: PancakeSwapSignConfig;
16
+ quoteToken?: string;
17
+ quoteTokenDecimals?: number;
18
+ startNonces?: number[];
19
+ }
20
+ /**
21
+ * 批量换手结果
22
+ */
23
+ export interface PancakeBatchSwapResult {
24
+ signedTransactions: string[];
25
+ profitHopWallets?: GeneratedWallet[];
26
+ metadata?: {
27
+ sellerAddress: string;
28
+ buyerAddresses: string[];
29
+ sellAmount: string;
30
+ buyAmounts: string[];
31
+ profitAmount?: string;
32
+ };
33
+ }
34
+ /**
35
+ * PancakeSwap 批量换手(一卖多买)
36
+ *
37
+ * 功能:主钱包一次卖出 → 多个子钱包同时买入 → 在同一个区块中完成
38
+ * 限制:最多 24 个买方(服务器限制 25 笔交易,包含 1 笔利润交易)
39
+ *
40
+ * 交易顺序:[授权(可选)] → [卖出] → [买入1, 买入2, ..., 买入N] → [利润]
41
+ */
42
+ export declare function pancakeBatchSwapMerkle(params: PancakeBatchSwapSignParams): Promise<PancakeBatchSwapResult>;
@@ -0,0 +1,283 @@
1
+ /**
2
+ * swap-batch - 批量换手(一卖多买)
3
+ */
4
+ import { getProfitRecipient, BLOCKRAZOR_BUILDER_EOA } from '../../../core/constants/index.js';
5
+ import { getGasLimit } from '../../../core/gas/bundle-gas.js';
6
+ import { ethers, Contract, Wallet } from 'ethers';
7
+ import { calculateSellAmount } from '../../../utils/swap-helpers.js';
8
+ import { NonceManager, getDeadline, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
9
+ import { BRIBE_GAS_LIMIT, ERC20_BALANCE_OF_ABI, FLAT_FEE, PANCAKE_V2_ROUTER_ABI, PANCAKE_V2_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ABI, PANCAKE_V3_ROUTER_ADDRESS, ZERO_ADDRESS, calculateProfitAmount, createPancakeContext, getERC20ToNativeQuote, getGasPrice, quoteSellOutput, } from './bundle-swap-helpers.js';
10
+ /**
11
+ * PancakeSwap 批量换手(一卖多买)
12
+ *
13
+ * 功能:主钱包一次卖出 → 多个子钱包同时买入 → 在同一个区块中完成
14
+ * 限制:最多 24 个买方(服务器限制 25 笔交易,包含 1 笔利润交易)
15
+ *
16
+ * 交易顺序:[授权(可选)] → [卖出] → [买入1, 买入2, ..., 买入N] → [利润]
17
+ */
18
+ export async function pancakeBatchSwapMerkle(params) {
19
+ const { sellerPrivateKey, sellAmount, sellPercentage, buyerPrivateKeys, buyerAmounts, tokenAddress, routeParams, config, quoteToken, quoteTokenDecimals = 18, startNonces, // ✅ 可选:前端预获取的 nonces
20
+ } = params;
21
+ // ✅ 校验买方数量(最多 24 个)
22
+ const MAX_BUYERS = 24;
23
+ if (buyerPrivateKeys.length === 0) {
24
+ throw new Error('至少需要一个买方钱包');
25
+ }
26
+ if (buyerPrivateKeys.length > MAX_BUYERS) {
27
+ throw new Error(`买方钱包数量超过限制: ${buyerPrivateKeys.length} > ${MAX_BUYERS}`);
28
+ }
29
+ const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
30
+ const context = createPancakeContext(config);
31
+ const seller = new Wallet(sellerPrivateKey, context.provider);
32
+ const buyers = buyerPrivateKeys.map((pk) => new Wallet(pk, context.provider));
33
+ // ✅ 创建共享资源
34
+ const nonceManager = new NonceManager(context.provider);
35
+ const finalGasLimit = getGasLimit(config, 800000);
36
+ const txType = config.txType ?? 0;
37
+ // ✅ 并行获取 gasPrice 和卖出数量
38
+ const [gasPrice, sellAmountResult] = await Promise.all([
39
+ getGasPrice(context.provider, config),
40
+ calculateSellAmount(context.provider, tokenAddress, seller.address, sellAmount, sellPercentage),
41
+ ]);
42
+ const { amount: sellAmountWei, decimals } = sellAmountResult;
43
+ const quoteResult = await quoteSellOutput({
44
+ routeParams,
45
+ sellAmountWei,
46
+ provider: context.provider,
47
+ v2RouterAddress: config.v2RouterAddress,
48
+ });
49
+ const estimatedBNBOut = quoteResult.estimatedBNBOut;
50
+ // ✅ 计算每个买方的买入金额(已移除滑点保护:直接使用报价金额)
51
+ let buyAmountsWei;
52
+ const totalBuyAmount = estimatedBNBOut;
53
+ if (buyerAmounts && buyerAmounts.length === buyers.length) {
54
+ // 方式1:使用指定的买入金额(USDT)
55
+ buyAmountsWei = buyerAmounts.map((amt) => useNativeToken ? ethers.parseEther(amt) : ethers.parseUnits(amt, quoteTokenDecimals));
56
+ }
57
+ else if (params.buyerRatios && params.buyerRatios.length === buyers.length) {
58
+ // ✅ 方式2:按比例分配卖出所得
59
+ // buyerRatios 如 [0.3, 0.5, 0.2] 表示第一个买方分 30%,第二个 50%,第三个 20%
60
+ buyAmountsWei = params.buyerRatios.map((ratio) => {
61
+ // 按比例计算每个买方的金额
62
+ const amount = (totalBuyAmount * BigInt(Math.round(ratio * 10000))) / 10000n;
63
+ return amount;
64
+ });
65
+ }
66
+ else {
67
+ // 方式3:平均分配
68
+ const amountPerBuyer = totalBuyAmount / BigInt(buyers.length);
69
+ buyAmountsWei = buyers.map(() => amountPerBuyer);
70
+ }
71
+ // ✅ 并行验证所有买方余额
72
+ const reserveGas = ethers.parseEther((config.reserveGasBNB ?? 0.0005).toString());
73
+ const erc20Contract = useNativeToken ? null : new Contract(quoteToken, ERC20_BALANCE_OF_ABI, context.provider);
74
+ await Promise.all(buyers.map(async (buyer, i) => {
75
+ const buyAmount = buyAmountsWei[i];
76
+ if (useNativeToken) {
77
+ const buyerBalance = await buyer.provider.getBalance(buyer.address);
78
+ const required = buyAmount + FLAT_FEE + reserveGas;
79
+ if (buyerBalance < required) {
80
+ throw new Error(`买方 ${i + 1} 余额不足: 需要 ${ethers.formatEther(required)}, 实际 ${ethers.formatEther(buyerBalance)}`);
81
+ }
82
+ }
83
+ else {
84
+ const buyerBalance = await erc20Contract.balanceOf(buyer.address);
85
+ const required = buyAmount + FLAT_FEE;
86
+ if (buyerBalance < required) {
87
+ throw new Error(`买方 ${i + 1} 代币余额不足: 需要 ${ethers.formatUnits(required, quoteTokenDecimals)}, 实际 ${ethers.formatUnits(buyerBalance, quoteTokenDecimals)}`);
88
+ }
89
+ }
90
+ }));
91
+ const deadline = getDeadline();
92
+ const v3RouterIface = new ethers.Interface(PANCAKE_V3_ROUTER_ABI);
93
+ const batchV2Addr = config.v2RouterAddress || PANCAKE_V2_ROUTER_ADDRESS;
94
+ let sellUnsigned;
95
+ if (routeParams.routeType === 'v2') {
96
+ const { v2Path } = routeParams;
97
+ const v2RouterSeller = new Contract(batchV2Addr, PANCAKE_V2_ROUTER_ABI, seller);
98
+ if (useNativeToken) {
99
+ // ✅ 原生代币模式(BNB):Token → WBNB → BNB
100
+ sellUnsigned = await v2RouterSeller.swapExactTokensForETHSupportingFeeOnTransferTokens.populateTransaction(sellAmountWei, 0n, v2Path, seller.address, deadline);
101
+ }
102
+ else {
103
+ // ✅ ERC20 模式(USDT):Token → USDT
104
+ sellUnsigned = await v2RouterSeller.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(sellAmountWei, 0n, v2Path, seller.address, deadline);
105
+ }
106
+ }
107
+ else if (routeParams.routeType === 'v3-single') {
108
+ const { v3TokenIn, v3TokenOut, v3Fee } = routeParams;
109
+ const v3RouterSeller = new Contract(PANCAKE_V3_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ABI, seller);
110
+ const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
111
+ {
112
+ tokenIn: v3TokenIn,
113
+ tokenOut: v3TokenOut,
114
+ fee: v3Fee,
115
+ recipient: useNativeToken ? PANCAKE_V3_ROUTER_ADDRESS : seller.address,
116
+ amountIn: sellAmountWei,
117
+ amountOutMinimum: 0n,
118
+ sqrtPriceLimitX96: 0n,
119
+ },
120
+ ]);
121
+ if (useNativeToken) {
122
+ // 原生代币:需要 unwrap WBNB
123
+ const sellUnwrapData = v3RouterIface.encodeFunctionData('unwrapWETH9', [0n, seller.address]);
124
+ sellUnsigned = await v3RouterSeller.multicall.populateTransaction(deadline, [sellSwapData, sellUnwrapData]);
125
+ }
126
+ else {
127
+ // ERC20:直接接收代币
128
+ sellUnsigned = await v3RouterSeller.multicall.populateTransaction(deadline, [sellSwapData]);
129
+ }
130
+ }
131
+ else {
132
+ throw new Error('V3 多跳路由暂不支持官方合约,请使用 V2 路由或 V3 单跳');
133
+ }
134
+ const buyUnsignedList = await Promise.all(buyers.map(async (buyer, i) => {
135
+ const buyAmount = buyAmountsWei[i];
136
+ const buyValue = useNativeToken ? buyAmount + FLAT_FEE : 0n;
137
+ if (routeParams.routeType === 'v2') {
138
+ const { v2Path } = routeParams;
139
+ const reversePath = [...v2Path].reverse();
140
+ const v2RouterBuyer = new Contract(batchV2Addr, PANCAKE_V2_ROUTER_ABI, buyer);
141
+ if (useNativeToken) {
142
+ // ✅ 原生代币模式(BNB):BNB → WBNB → Token
143
+ return await v2RouterBuyer.swapExactETHForTokensSupportingFeeOnTransferTokens.populateTransaction(0n, reversePath, buyer.address, deadline, { value: buyValue });
144
+ }
145
+ else {
146
+ // ✅ ERC20 模式(USDT):USDT → Token
147
+ return await v2RouterBuyer.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(buyAmount, 0n, reversePath, buyer.address, deadline);
148
+ }
149
+ }
150
+ else if (routeParams.routeType === 'v3-single') {
151
+ const { v3TokenIn, v3TokenOut, v3Fee } = routeParams;
152
+ const v3RouterBuyer = new Contract(PANCAKE_V3_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ABI, buyer);
153
+ const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
154
+ {
155
+ tokenIn: v3TokenOut,
156
+ tokenOut: v3TokenIn,
157
+ fee: v3Fee,
158
+ recipient: buyer.address,
159
+ amountIn: buyAmount,
160
+ amountOutMinimum: 0n,
161
+ sqrtPriceLimitX96: 0n,
162
+ },
163
+ ]);
164
+ return await v3RouterBuyer.multicall.populateTransaction(deadline, [buySwapData], { value: buyValue });
165
+ }
166
+ else {
167
+ throw new Error('V3 多跳路由暂不支持官方合约,请使用 V2 路由或 V3 单跳');
168
+ }
169
+ }));
170
+ // ✅ 获取贿赂金额
171
+ const bribeAmount = config.bribeAmount && config.bribeAmount > 0 ? ethers.parseEther(String(config.bribeAmount)) : 0n;
172
+ // ✅ 规划 Nonce(贿赂和利润都由卖方发送)
173
+ // 卖方: [贿赂(可选)] → [卖出] → [利润(可选)]
174
+ let bribeNonce;
175
+ let sellNonce;
176
+ let buyerNonces;
177
+ // ✅ 如果前端传入了 startNonces,直接使用(性能优化)
178
+ if (startNonces && startNonces.length >= 1 + buyers.length) {
179
+ let sellerIdx = 0;
180
+ if (bribeAmount > 0n) {
181
+ bribeNonce = startNonces[0] + sellerIdx++;
182
+ }
183
+ sellNonce = startNonces[0] + sellerIdx;
184
+ buyerNonces = startNonces.slice(1);
185
+ }
186
+ else {
187
+ if (bribeAmount > 0n) {
188
+ bribeNonce = await nonceManager.getNextNonce(seller);
189
+ }
190
+ sellNonce = await nonceManager.getNextNonce(seller);
191
+ buyerNonces = await Promise.all(buyers.map((buyer) => nonceManager.getNextNonce(buyer)));
192
+ }
193
+ // ✅ 贿赂交易放在首位(由卖方发送)
194
+ let bribeTx = null;
195
+ if (bribeAmount > 0n && bribeNonce !== undefined) {
196
+ bribeTx = await seller.signTransaction({
197
+ to: BLOCKRAZOR_BUILDER_EOA,
198
+ value: bribeAmount,
199
+ nonce: bribeNonce,
200
+ gasPrice,
201
+ gasLimit: BRIBE_GAS_LIMIT,
202
+ chainId: context.chainId,
203
+ type: txType,
204
+ });
205
+ }
206
+ // ✅ 修复:利润计算应基于 BNB 数量,不是 ERC20 数量
207
+ let profitAmount;
208
+ if (useNativeToken) {
209
+ profitAmount = calculateProfitAmount(estimatedBNBOut, config.userType);
210
+ // 利润计算完成
211
+ }
212
+ else {
213
+ const version = routeParams.routeType === 'v2' ? 'v2' : 'v3';
214
+ const fee = routeParams.routeType === 'v3-single' ? routeParams.v3Fee : undefined;
215
+ const estimatedBNBValue = await getERC20ToNativeQuote(context.provider, quoteToken, estimatedBNBOut, version, fee);
216
+ profitAmount = calculateProfitAmount(estimatedBNBValue, config.userType);
217
+ // ERC20→BNB 报价完成
218
+ }
219
+ // 计算利润 nonce
220
+ const profitNonce = profitAmount > 0n
221
+ ? startNonces && startNonces.length >= 1
222
+ ? sellNonce + 1
223
+ : await nonceManager.getNextNonce(seller)
224
+ : undefined;
225
+ nonceManager.clearTemp();
226
+ // ✅ 并行签名所有交易
227
+ // 1. 签名卖出交易
228
+ const signedSellPromise = seller.signTransaction({
229
+ ...sellUnsigned,
230
+ from: seller.address,
231
+ nonce: sellNonce,
232
+ gasLimit: finalGasLimit,
233
+ gasPrice,
234
+ chainId: context.chainId,
235
+ type: txType,
236
+ });
237
+ // 2. 并行签名所有买入交易
238
+ const signedBuyPromises = buyers.map((buyer, i) => buyer.signTransaction({
239
+ ...buyUnsignedList[i],
240
+ from: buyer.address,
241
+ nonce: buyerNonces[i],
242
+ gasLimit: finalGasLimit,
243
+ gasPrice,
244
+ chainId: context.chainId,
245
+ type: txType,
246
+ }));
247
+ // 3. 等待所有签名完成
248
+ const [signedSell, ...signedBuys] = await Promise.all([signedSellPromise, ...signedBuyPromises]);
249
+ // 4. 按顺序组装交易数组:贿赂 → 卖出 → 买入
250
+ const signedTransactions = [];
251
+ if (bribeTx)
252
+ signedTransactions.push(bribeTx); // 贿赂(首位)
253
+ signedTransactions.push(signedSell); // 卖出
254
+ signedTransactions.push(...signedBuys); // 多个买入
255
+ // ✅ 利润多跳转账(强制 2 跳中转)
256
+ let profitHopWallets;
257
+ if (profitAmount > 0n && profitNonce !== undefined) {
258
+ const profitHopResult = await buildProfitHopTransactions({
259
+ provider: context.provider,
260
+ payerWallet: seller,
261
+ profitAmount,
262
+ profitRecipient: getProfitRecipient(),
263
+ hopCount: PROFIT_HOP_COUNT,
264
+ gasPrice,
265
+ chainId: context.chainId,
266
+ txType,
267
+ startNonce: profitNonce,
268
+ });
269
+ signedTransactions.push(...profitHopResult.signedTransactions);
270
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
271
+ }
272
+ return {
273
+ signedTransactions,
274
+ profitHopWallets, // ✅ 导出利润多跳钱包
275
+ metadata: {
276
+ sellerAddress: seller.address,
277
+ buyerAddresses: buyers.map((b) => b.address),
278
+ sellAmount: ethers.formatUnits(sellAmountWei, decimals),
279
+ buyAmounts: buyAmountsWei.map((amt) => useNativeToken ? ethers.formatEther(amt) : ethers.formatUnits(amt, quoteTokenDecimals)),
280
+ profitAmount: profitAmount > 0n ? ethers.formatEther(profitAmount) : undefined,
281
+ },
282
+ };
283
+ }