four-flap-meme-sdk 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/dist/bundle/four-meme/approve-tokenmanager.d.ts +2 -2
  2. package/dist/bundle/four-meme/approve-tokenmanager.js +3 -3
  3. package/dist/bundle/four-meme/core/buy-flow.d.ts +5 -0
  4. package/dist/bundle/four-meme/core/buy-flow.js +147 -0
  5. package/dist/bundle/four-meme/core/constants.d.ts +6 -0
  6. package/dist/bundle/four-meme/core/constants.js +15 -0
  7. package/dist/bundle/four-meme/core/create-token.d.ts +5 -0
  8. package/dist/bundle/four-meme/core/create-token.js +137 -0
  9. package/dist/bundle/four-meme/core/index.d.ts +14 -0
  10. package/dist/bundle/four-meme/core/index.js +14 -0
  11. package/dist/bundle/four-meme/core/sell-flow.d.ts +5 -0
  12. package/dist/bundle/four-meme/core/sell-flow.js +240 -0
  13. package/dist/bundle/four-meme/core-helpers.js +1 -1
  14. package/dist/bundle/four-meme/core.d.ts +7 -4
  15. package/dist/bundle/four-meme/core.js +5 -513
  16. package/dist/bundle/four-meme/pancake-proxy/approve.d.ts +15 -0
  17. package/dist/bundle/four-meme/pancake-proxy/approve.js +113 -0
  18. package/dist/bundle/four-meme/pancake-proxy/buy.d.ts +8 -0
  19. package/dist/bundle/four-meme/pancake-proxy/buy.js +143 -0
  20. package/dist/bundle/four-meme/pancake-proxy/constants.d.ts +25 -0
  21. package/dist/bundle/four-meme/pancake-proxy/constants.js +14 -0
  22. package/dist/bundle/four-meme/pancake-proxy/helpers.d.ts +45 -0
  23. package/dist/bundle/four-meme/pancake-proxy/helpers.js +232 -0
  24. package/dist/bundle/four-meme/pancake-proxy/index.d.ts +15 -0
  25. package/dist/bundle/four-meme/pancake-proxy/index.js +15 -0
  26. package/dist/bundle/four-meme/pancake-proxy/sell.d.ts +8 -0
  27. package/dist/bundle/four-meme/pancake-proxy/sell.js +194 -0
  28. package/dist/bundle/four-meme/pancake-proxy.d.ts +4 -20
  29. package/dist/bundle/four-meme/pancake-proxy.js +3 -670
  30. package/dist/bundle/four-meme/private/buy.d.ts +16 -0
  31. package/dist/bundle/four-meme/private/buy.js +225 -0
  32. package/dist/bundle/four-meme/private/index.d.ts +11 -0
  33. package/dist/bundle/four-meme/private/index.js +11 -0
  34. package/dist/bundle/four-meme/private/sell.d.ts +18 -0
  35. package/dist/bundle/four-meme/private/sell.js +245 -0
  36. package/dist/bundle/four-meme/private.d.ts +5 -25
  37. package/dist/bundle/four-meme/private.js +5 -463
  38. package/dist/bundle/four-meme/swap/batch.d.ts +8 -0
  39. package/dist/bundle/four-meme/swap/batch.js +170 -0
  40. package/dist/bundle/four-meme/swap/bundle.d.ts +8 -0
  41. package/dist/bundle/four-meme/swap/bundle.js +147 -0
  42. package/dist/bundle/four-meme/swap/index.d.ts +14 -0
  43. package/dist/bundle/four-meme/swap/index.js +13 -0
  44. package/dist/bundle/four-meme/swap/quick-batch.d.ts +8 -0
  45. package/dist/bundle/four-meme/swap/quick-batch.js +206 -0
  46. package/dist/bundle/four-meme/swap-buy-first/helpers.d.ts +20 -0
  47. package/dist/bundle/four-meme/swap-buy-first/helpers.js +39 -0
  48. package/dist/bundle/four-meme/swap-buy-first/index.d.ts +12 -0
  49. package/dist/bundle/four-meme/swap-buy-first/index.js +11 -0
  50. package/dist/bundle/four-meme/swap-buy-first/multi-wallet.d.ts +20 -0
  51. package/dist/bundle/four-meme/swap-buy-first/multi-wallet.js +198 -0
  52. package/dist/bundle/four-meme/swap-buy-first/single.d.ts +7 -0
  53. package/dist/bundle/four-meme/swap-buy-first/single.js +232 -0
  54. package/dist/bundle/four-meme/swap-buy-first.d.ts +4 -3
  55. package/dist/bundle/four-meme/swap-buy-first.js +4 -451
  56. package/dist/bundle/four-meme/swap-hop-helpers.d.ts +2 -2
  57. package/dist/bundle/four-meme/swap-sign-helpers.d.ts +2 -2
  58. package/dist/bundle/four-meme/swap-sign-helpers.js +1 -1
  59. package/dist/bundle/four-meme/swap.d.ts +4 -14
  60. package/dist/bundle/four-meme/swap.js +4 -502
  61. package/dist/bundle/four-meme/types/index.d.ts +1 -1
  62. package/dist/bundle/four-meme/utils-disperse.d.ts +1 -1
  63. package/dist/bundle/four-meme/utils-disperse.js +1 -1
  64. package/dist/bundle/four-meme/utils-pairwise.d.ts +1 -1
  65. package/dist/bundle/four-meme/utils-pairwise.js +1 -1
  66. package/dist/bundle/four-meme/utils-sweep/context.d.ts +39 -0
  67. package/dist/bundle/four-meme/utils-sweep/context.js +7 -0
  68. package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.d.ts +5 -0
  69. package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.js +162 -0
  70. package/dist/bundle/four-meme/utils-sweep/index.d.ts +13 -0
  71. package/dist/bundle/four-meme/utils-sweep/index.js +13 -0
  72. package/dist/bundle/four-meme/utils-sweep/main.d.ts +8 -0
  73. package/dist/bundle/four-meme/utils-sweep/main.js +114 -0
  74. package/dist/bundle/four-meme/utils-sweep/native-no-hop.d.ts +5 -0
  75. package/dist/bundle/four-meme/utils-sweep/native-no-hop.js +156 -0
  76. package/dist/bundle/four-meme/utils-sweep/with-hops.d.ts +6 -0
  77. package/dist/bundle/four-meme/utils-sweep/with-hops.js +382 -0
  78. package/dist/bundle/four-meme/utils-sweep.d.ts +3 -4
  79. package/dist/bundle/four-meme/utils-sweep.js +3 -740
  80. package/dist/bundle/internal.d.ts +2 -2
  81. package/dist/bundle/sign-context-helpers.d.ts +1 -26
  82. package/dist/bundle/sign-context-helpers.js +1 -63
  83. package/dist/bundle/submit/blockrazor.d.ts +94 -0
  84. package/dist/bundle/submit/blockrazor.js +122 -0
  85. package/dist/bundle/submit/direct.d.ts +118 -0
  86. package/dist/bundle/submit/direct.js +484 -0
  87. package/dist/bundle/submit/helpers.d.ts +7 -0
  88. package/dist/bundle/submit/helpers.js +15 -0
  89. package/dist/bundle/submit/index.d.ts +14 -0
  90. package/dist/bundle/submit/index.js +14 -0
  91. package/dist/bundle/submit/merkle.d.ts +84 -0
  92. package/dist/bundle/submit/merkle.js +121 -0
  93. package/dist/bundle/submit.d.ts +3 -286
  94. package/dist/bundle/submit.js +3 -724
  95. package/dist/chains/bsc/four/types.d.ts +1 -1
  96. package/dist/chains/bsc/index.d.ts +1 -1
  97. package/dist/chains/bsc/index.js +2 -0
  98. package/dist/chains/bsc/pancake/bundle-buy-first-build.d.ts +25 -0
  99. package/dist/chains/bsc/pancake/bundle-buy-first-build.js +177 -0
  100. package/dist/chains/bsc/pancake/bundle-buy-first-constants.d.ts +30 -0
  101. package/dist/chains/bsc/pancake/bundle-buy-first-constants.js +24 -0
  102. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +11 -149
  103. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +12 -74
  104. package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.d.ts +9 -0
  105. package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.js +225 -0
  106. package/dist/chains/bsc/pancake/bundle-buy-first-plan.d.ts +14 -0
  107. package/dist/chains/bsc/pancake/bundle-buy-first-plan.js +64 -0
  108. package/dist/chains/bsc/pancake/bundle-buy-first-profit.d.ts +12 -0
  109. package/dist/chains/bsc/pancake/bundle-buy-first-profit.js +22 -0
  110. package/dist/chains/bsc/pancake/bundle-buy-first-quote.d.ts +15 -0
  111. package/dist/chains/bsc/pancake/bundle-buy-first-quote.js +122 -0
  112. package/dist/chains/bsc/pancake/bundle-buy-first-types.d.ts +179 -0
  113. package/dist/chains/bsc/pancake/bundle-buy-first-types.js +1 -0
  114. package/dist/chains/bsc/pancake/bundle-buy-first-validate.d.ts +2 -0
  115. package/dist/chains/bsc/pancake/bundle-buy-first-validate.js +41 -0
  116. package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -1
  117. package/dist/chains/bsc/pancake/bundle-buy-first.js +8 -578
  118. package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +11 -239
  119. package/dist/chains/bsc/pancake/bundle-swap-helpers.js +12 -564
  120. package/dist/chains/bsc/pancake/bundle-swap-types.d.ts +183 -0
  121. package/dist/chains/bsc/pancake/bundle-swap-types.js +17 -0
  122. package/dist/chains/bsc/pancake/bundle-swap.d.ts +10 -132
  123. package/dist/chains/bsc/pancake/bundle-swap.js +12 -1003
  124. package/dist/chains/bsc/pancake/hop-chain.d.ts +18 -0
  125. package/dist/chains/bsc/pancake/hop-chain.js +227 -0
  126. package/dist/chains/bsc/pancake/quote.d.ts +14 -0
  127. package/dist/chains/bsc/pancake/quote.js +84 -0
  128. package/dist/chains/bsc/pancake/swap-batch.d.ts +42 -0
  129. package/dist/chains/bsc/pancake/swap-batch.js +283 -0
  130. package/dist/chains/bsc/pancake/swap-build.d.ts +19 -0
  131. package/dist/chains/bsc/pancake/swap-build.js +226 -0
  132. package/dist/chains/bsc/pancake/swap-cross.d.ts +42 -0
  133. package/dist/chains/bsc/pancake/swap-cross.js +140 -0
  134. package/dist/chains/bsc/pancake/swap-quick.d.ts +54 -0
  135. package/dist/chains/bsc/pancake/swap-quick.js +424 -0
  136. package/dist/chains/bsc/pancake/swap-single.d.ts +2 -0
  137. package/dist/chains/bsc/pancake/swap-single.js +182 -0
  138. package/dist/chains/bsc/platforms/four/index.d.ts +21 -3
  139. package/dist/chains/bsc/platforms/four/index.js +28 -3
  140. package/dist/chains/eni/batch-router/transfer-disperse.d.ts +37 -0
  141. package/dist/chains/eni/batch-router/transfer-disperse.js +302 -0
  142. package/dist/chains/eni/batch-router/transfer-shared.d.ts +9 -0
  143. package/dist/chains/eni/batch-router/transfer-shared.js +10 -0
  144. package/dist/chains/eni/batch-router/transfer-sweep.d.ts +51 -0
  145. package/dist/chains/eni/batch-router/transfer-sweep.js +364 -0
  146. package/dist/chains/eni/batch-router/transfer.d.ts +4 -74
  147. package/dist/chains/eni/batch-router/transfer.js +2 -647
  148. package/dist/chains/eni/index.d.ts +2 -0
  149. package/dist/chains/eni/index.js +4 -0
  150. package/dist/chains/eni/platforms/daoaas/portal-direct-profit.d.ts +17 -0
  151. package/dist/chains/eni/platforms/daoaas/portal-direct-profit.js +30 -0
  152. package/dist/chains/eni/platforms/daoaas/portal-direct-submit.d.ts +12 -0
  153. package/dist/chains/eni/platforms/daoaas/portal-direct-submit.js +396 -0
  154. package/dist/chains/eni/platforms/daoaas/portal-direct-tx.d.ts +20 -0
  155. package/dist/chains/eni/platforms/daoaas/portal-direct-tx.js +165 -0
  156. package/dist/chains/eni/platforms/daoaas/portal-direct.d.ts +3 -32
  157. package/dist/chains/eni/platforms/daoaas/portal-direct.js +3 -571
  158. package/dist/chains/eni/submit.js +1 -1
  159. package/dist/chains/xlayer/constants.d.ts +0 -2
  160. package/dist/chains/xlayer/constants.js +0 -2
  161. package/dist/chains/xlayer/eip7702/auth.d.ts +16 -0
  162. package/dist/chains/xlayer/eip7702/auth.js +81 -0
  163. package/dist/chains/xlayer/eip7702/bundle-create-buy.d.ts +22 -0
  164. package/dist/chains/xlayer/eip7702/bundle-create-buy.js +201 -0
  165. package/dist/chains/xlayer/eip7702/bundle-create-helpers.d.ts +114 -0
  166. package/dist/chains/xlayer/eip7702/bundle-create-helpers.js +139 -0
  167. package/dist/chains/xlayer/eip7702/bundle-create-to-dex.d.ts +24 -0
  168. package/dist/chains/xlayer/eip7702/bundle-create-to-dex.js +233 -0
  169. package/dist/chains/xlayer/eip7702/bundle-create.d.ts +3 -35
  170. package/dist/chains/xlayer/eip7702/bundle-create.js +3 -746
  171. package/dist/chains/xlayer/eip7702/bundle-graduate-buy.d.ts +22 -0
  172. package/dist/chains/xlayer/eip7702/bundle-graduate-buy.js +214 -0
  173. package/dist/chains/xlayer/eip7702/bundle-sell.js +1 -1
  174. package/dist/chains/xlayer/eip7702/bundle-swap-batch.d.ts +31 -0
  175. package/dist/chains/xlayer/eip7702/bundle-swap-batch.js +216 -0
  176. package/dist/chains/xlayer/eip7702/bundle-swap-helpers.d.ts +21 -0
  177. package/dist/chains/xlayer/eip7702/bundle-swap-helpers.js +206 -0
  178. package/dist/chains/xlayer/eip7702/bundle-swap-multi.d.ts +33 -0
  179. package/dist/chains/xlayer/eip7702/bundle-swap-multi.js +146 -0
  180. package/dist/chains/xlayer/eip7702/bundle-swap-single.d.ts +31 -0
  181. package/dist/chains/xlayer/eip7702/bundle-swap-single.js +177 -0
  182. package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +6 -61
  183. package/dist/chains/xlayer/eip7702/bundle-swap.js +3 -712
  184. package/dist/chains/xlayer/eip7702/bytes.d.ts +4 -0
  185. package/dist/chains/xlayer/eip7702/bytes.js +31 -0
  186. package/dist/chains/xlayer/eip7702/gas.d.ts +19 -0
  187. package/dist/chains/xlayer/eip7702/gas.js +152 -0
  188. package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.d.ts +5 -0
  189. package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.js +196 -0
  190. package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.d.ts +5 -0
  191. package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.js +188 -0
  192. package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.d.ts +5 -0
  193. package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.js +220 -0
  194. package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +8 -4
  195. package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +5 -591
  196. package/dist/chains/xlayer/eip7702/profit.d.ts +32 -0
  197. package/dist/chains/xlayer/eip7702/profit.js +59 -0
  198. package/dist/chains/xlayer/eip7702/provider.d.ts +3 -0
  199. package/dist/chains/xlayer/eip7702/provider.js +17 -0
  200. package/dist/chains/xlayer/eip7702/time.d.ts +2 -0
  201. package/dist/chains/xlayer/eip7702/time.js +10 -0
  202. package/dist/chains/xlayer/eip7702/tx-build.d.ts +10 -0
  203. package/dist/chains/xlayer/eip7702/tx-build.js +128 -0
  204. package/dist/chains/xlayer/eip7702/utils.d.ts +19 -85
  205. package/dist/chains/xlayer/eip7702/utils.js +19 -484
  206. package/dist/chains/xlayer/eip7702/volume-bundle.d.ts +13 -0
  207. package/dist/chains/xlayer/eip7702/volume-bundle.js +250 -0
  208. package/dist/chains/xlayer/eip7702/volume-internal.d.ts +13 -0
  209. package/dist/chains/xlayer/eip7702/volume-internal.js +169 -0
  210. package/dist/chains/xlayer/eip7702/volume-make.d.ts +8 -0
  211. package/dist/chains/xlayer/eip7702/volume-make.js +38 -0
  212. package/dist/chains/xlayer/eip7702/volume-single-round.d.ts +17 -0
  213. package/dist/chains/xlayer/eip7702/volume-single-round.js +44 -0
  214. package/dist/chains/xlayer/eip7702/volume-swap.d.ts +18 -0
  215. package/dist/chains/xlayer/eip7702/volume-swap.js +30 -0
  216. package/dist/chains/xlayer/eip7702/volume-wash.d.ts +8 -0
  217. package/dist/chains/xlayer/eip7702/volume-wash.js +191 -0
  218. package/dist/chains/xlayer/eip7702/volume.d.ts +7 -35
  219. package/dist/chains/xlayer/eip7702/volume.js +5 -697
  220. package/dist/chains/xlayer/eip7702/wallet.d.ts +6 -0
  221. package/dist/chains/xlayer/eip7702/wallet.js +17 -0
  222. package/dist/chains/xlayer/eoa/aa-types.d.ts +176 -0
  223. package/dist/chains/xlayer/eoa/aa-types.js +6 -0
  224. package/dist/chains/xlayer/eoa/constants.d.ts +0 -2
  225. package/dist/chains/xlayer/eoa/constants.js +0 -2
  226. package/dist/chains/xlayer/eoa/context.d.ts +8 -0
  227. package/dist/chains/xlayer/eoa/context.js +23 -0
  228. package/dist/chains/xlayer/eoa/encoders.d.ts +147 -0
  229. package/dist/chains/xlayer/eoa/encoders.js +147 -0
  230. package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.d.ts +5 -0
  231. package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.js +113 -0
  232. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +10 -123
  233. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +10 -225
  234. package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.d.ts +50 -0
  235. package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.js +170 -0
  236. package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.d.ts +5 -0
  237. package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.js +257 -0
  238. package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.d.ts +99 -0
  239. package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.js +11 -0
  240. package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +5 -47
  241. package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +3 -522
  242. package/dist/chains/xlayer/eoa/eoa-types.d.ts +776 -0
  243. package/dist/chains/xlayer/eoa/eoa-types.js +6 -0
  244. package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +8 -0
  245. package/dist/chains/xlayer/eoa/eoa-wash-volume.js +8 -0
  246. package/dist/chains/xlayer/eoa/format.d.ts +34 -0
  247. package/dist/chains/xlayer/eoa/format.js +56 -0
  248. package/dist/chains/xlayer/eoa/hop-chain.d.ts +4 -0
  249. package/dist/chains/xlayer/eoa/hop-chain.js +87 -0
  250. package/dist/chains/xlayer/eoa/nonce-map.d.ts +20 -0
  251. package/dist/chains/xlayer/eoa/nonce-map.js +51 -0
  252. package/dist/chains/xlayer/eoa/portal-ops.d.ts +9 -292
  253. package/dist/chains/xlayer/eoa/portal-ops.js +9 -486
  254. package/dist/chains/xlayer/eoa/query.d.ts +117 -0
  255. package/dist/chains/xlayer/eoa/query.js +285 -0
  256. package/dist/chains/xlayer/eoa/quote.d.ts +6 -0
  257. package/dist/chains/xlayer/eoa/quote.js +90 -0
  258. package/dist/chains/xlayer/eoa/types.d.ts +9 -959
  259. package/dist/chains/xlayer/eoa/types.js +9 -49
  260. package/dist/core/clients/blockrazor.js +1 -1
  261. package/dist/core/clients/merkle.js +1 -1
  262. package/dist/core/erc20/allowances.d.ts +104 -0
  263. package/dist/core/erc20/allowances.js +205 -0
  264. package/dist/core/erc20/approve.d.ts +141 -0
  265. package/dist/core/erc20/approve.js +325 -0
  266. package/dist/core/erc20/helpers.d.ts +20 -0
  267. package/dist/core/erc20/helpers.js +109 -0
  268. package/dist/core/erc20/index.d.ts +13 -0
  269. package/dist/core/erc20/index.js +12 -0
  270. package/dist/core/gas/bundle-gas.d.ts +6 -1
  271. package/dist/core/index.d.ts +1 -1
  272. package/dist/core/index.js +1 -1
  273. package/dist/core/quote/index.d.ts +1 -0
  274. package/dist/core/quote/index.js +1 -0
  275. package/dist/core/quote/quote-helpers.d.ts +78 -0
  276. package/dist/core/quote/quote-helpers.js +289 -0
  277. package/dist/core/quote/types.d.ts +1 -0
  278. package/dist/core/quote/types.js +1 -0
  279. package/dist/core/sign-context-helpers.d.ts +29 -0
  280. package/dist/core/sign-context-helpers.js +63 -0
  281. package/dist/domains/dex/direct-router-helpers.d.ts +16 -268
  282. package/dist/domains/dex/direct-router-helpers.js +16 -535
  283. package/dist/domains/dex/direct-router-types.d.ts +104 -0
  284. package/dist/domains/dex/direct-router-types.js +81 -0
  285. package/dist/domains/dex/direct-router-v2-buy.d.ts +2 -0
  286. package/dist/domains/dex/direct-router-v2-buy.js +249 -0
  287. package/dist/domains/dex/direct-router-v2-sell.d.ts +5 -0
  288. package/dist/domains/dex/direct-router-v2-sell.js +270 -0
  289. package/dist/domains/dex/direct-router-v2.d.ts +9 -0
  290. package/dist/domains/dex/direct-router-v2.js +9 -0
  291. package/dist/domains/dex/direct-router-v3.d.ts +17 -0
  292. package/dist/domains/dex/direct-router-v3.js +432 -0
  293. package/dist/domains/dex/direct-router.d.ts +11 -26
  294. package/dist/domains/dex/direct-router.js +10 -977
  295. package/dist/domains/dex/dyo-encode.d.ts +62 -0
  296. package/dist/domains/dex/dyo-encode.js +124 -0
  297. package/dist/domains/dex/profit.d.ts +24 -0
  298. package/dist/domains/dex/profit.js +86 -0
  299. package/dist/domains/dex/provider.d.ts +10 -0
  300. package/dist/domains/dex/provider.js +27 -0
  301. package/dist/domains/dex/quote.d.ts +7 -0
  302. package/dist/domains/dex/quote.js +52 -0
  303. package/dist/domains/dex/router.d.ts +56 -0
  304. package/dist/domains/dex/router.js +193 -0
  305. package/dist/domains/flap/portal-bundle/batch.d.ts +9 -0
  306. package/dist/domains/flap/portal-bundle/batch.js +193 -0
  307. package/dist/domains/flap/portal-bundle/create.d.ts +5 -0
  308. package/dist/domains/flap/portal-bundle/create.js +153 -0
  309. package/dist/domains/flap/portal-bundle/helpers.d.ts +32 -0
  310. package/dist/domains/flap/portal-bundle/helpers.js +50 -0
  311. package/dist/domains/flap/portal-bundle/index.d.ts +16 -0
  312. package/dist/domains/flap/portal-bundle/index.js +15 -0
  313. package/dist/domains/flap/portal-bundle/private.d.ts +5 -0
  314. package/dist/domains/flap/portal-bundle/private.js +198 -0
  315. package/dist/domains/flap/portal-bundle/types.d.ts +102 -0
  316. package/dist/domains/flap/portal-bundle/types.js +1 -0
  317. package/dist/domains/flap/portal-bundle-merkle/core-batch.d.ts +13 -0
  318. package/dist/domains/flap/portal-bundle-merkle/core-batch.js +376 -0
  319. package/dist/domains/flap/portal-bundle-merkle/core-helpers.d.ts +75 -7
  320. package/dist/domains/flap/portal-bundle-merkle/core-helpers.js +259 -20
  321. package/dist/domains/flap/portal-bundle-merkle/core.d.ts +2 -13
  322. package/dist/domains/flap/portal-bundle-merkle/core.js +12 -629
  323. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.d.ts +70 -0
  324. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.js +90 -0
  325. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.d.ts +12 -0
  326. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.js +11 -0
  327. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.d.ts +15 -0
  328. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.js +432 -0
  329. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.d.ts +113 -0
  330. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.js +4 -0
  331. package/dist/domains/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -127
  332. package/dist/domains/flap/portal-bundle-merkle/create-to-dex.js +4 -527
  333. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.d.ts +42 -0
  334. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.js +81 -0
  335. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.d.ts +12 -0
  336. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.js +11 -0
  337. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.d.ts +15 -0
  338. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.js +339 -0
  339. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.d.ts +72 -0
  340. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.js +4 -0
  341. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.d.ts +4 -85
  342. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.js +4 -425
  343. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.d.ts +12 -0
  344. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.js +102 -0
  345. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.d.ts +5 -0
  346. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.js +135 -0
  347. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.d.ts +52 -0
  348. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.js +267 -0
  349. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.d.ts +14 -0
  350. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.js +14 -0
  351. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.d.ts +5 -0
  352. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.js +195 -0
  353. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.d.ts +3 -24
  354. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.js +3 -700
  355. package/dist/domains/flap/portal-bundle-merkle/private/buy.d.ts +9 -0
  356. package/dist/domains/flap/portal-bundle-merkle/private/buy.js +188 -0
  357. package/dist/domains/flap/portal-bundle-merkle/private/helpers.d.ts +36 -0
  358. package/dist/domains/flap/portal-bundle-merkle/private/helpers.js +127 -0
  359. package/dist/domains/flap/portal-bundle-merkle/private/index.d.ts +12 -0
  360. package/dist/domains/flap/portal-bundle-merkle/private/index.js +12 -0
  361. package/dist/domains/flap/portal-bundle-merkle/private/sell.d.ts +9 -0
  362. package/dist/domains/flap/portal-bundle-merkle/private/sell.js +191 -0
  363. package/dist/domains/flap/portal-bundle-merkle/private.d.ts +5 -15
  364. package/dist/domains/flap/portal-bundle-merkle/private.js +5 -494
  365. package/dist/domains/flap/portal-bundle-merkle/swap-batch.js +3 -2
  366. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.d.ts +4 -0
  367. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.js +43 -0
  368. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.d.ts +13 -0
  369. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.js +21 -0
  370. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +11 -121
  371. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.js +11 -109
  372. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.d.ts +20 -0
  373. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.js +223 -0
  374. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.d.ts +32 -0
  375. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.js +66 -0
  376. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.d.ts +22 -0
  377. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.js +22 -0
  378. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.d.ts +51 -0
  379. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.js +149 -0
  380. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.d.ts +87 -0
  381. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.js +1 -0
  382. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first.js +5 -404
  383. package/dist/domains/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -1
  384. package/dist/domains/flap/portal-bundle-merkle/swap-helpers.js +0 -7
  385. package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +1 -1
  386. package/dist/domains/flap/portal-bundle-merkle/swap-quick-batch.js +3 -2
  387. package/dist/domains/flap/portal-bundle-merkle/swap-single.js +3 -2
  388. package/dist/domains/flap/portal-bundle-merkle/utils/disperse.d.ts +2 -0
  389. package/dist/domains/flap/portal-bundle-merkle/utils/disperse.js +275 -0
  390. package/dist/domains/flap/portal-bundle-merkle/utils/index.d.ts +11 -0
  391. package/dist/domains/flap/portal-bundle-merkle/utils/index.js +11 -0
  392. package/dist/domains/flap/portal-bundle-merkle/utils/sweep.d.ts +9 -0
  393. package/dist/domains/flap/portal-bundle-merkle/utils/sweep.js +570 -0
  394. package/dist/domains/flap/portal-bundle-merkle/utils.d.ts +5 -8
  395. package/dist/domains/flap/portal-bundle-merkle/utils.js +5 -841
  396. package/dist/domains/flap/portal-bundle.d.ts +5 -117
  397. package/dist/domains/flap/portal-bundle.js +5 -587
  398. package/dist/domains/flap/portal.d.ts +13 -404
  399. package/dist/domains/flap/portal.js +12 -619
  400. package/dist/domains/flap/reader.d.ts +51 -0
  401. package/dist/domains/flap/reader.js +275 -0
  402. package/dist/domains/flap/types.d.ts +246 -0
  403. package/dist/domains/flap/types.js +104 -0
  404. package/dist/domains/flap/vault/constants.d.ts +220 -0
  405. package/dist/domains/flap/vault/constants.js +173 -0
  406. package/dist/domains/flap/vault/encode.d.ts +39 -0
  407. package/dist/domains/flap/vault/encode.js +135 -0
  408. package/dist/domains/flap/vault/index.d.ts +15 -0
  409. package/dist/domains/flap/vault/index.js +14 -0
  410. package/dist/domains/flap/vault/query.d.ts +40 -0
  411. package/dist/domains/flap/vault/query.js +104 -0
  412. package/dist/domains/flap/vault/types.d.ts +147 -0
  413. package/dist/domains/flap/vault/types.js +29 -0
  414. package/dist/domains/flap/vault.d.ts +3 -413
  415. package/dist/domains/flap/vault.js +3 -467
  416. package/dist/domains/flap/writer.d.ts +124 -0
  417. package/dist/domains/flap/writer.js +255 -0
  418. package/dist/domains/four/contracts/tm-bundle-batch.d.ts +35 -0
  419. package/dist/domains/four/contracts/tm-bundle-batch.js +286 -0
  420. package/dist/domains/four/contracts/tm-bundle-create.d.ts +2 -0
  421. package/dist/domains/four/contracts/tm-bundle-create.js +304 -0
  422. package/dist/domains/four/contracts/tm-bundle-helpers.d.ts +2 -1
  423. package/dist/domains/four/contracts/tm-bundle-helpers.js +3 -0
  424. package/dist/domains/four/contracts/tm-bundle-private.d.ts +36 -0
  425. package/dist/domains/four/contracts/tm-bundle-private.js +164 -0
  426. package/dist/domains/four/contracts/tm-bundle.d.ts +10 -71
  427. package/dist/domains/four/contracts/tm-bundle.js +9 -738
  428. package/dist/domains/lp-inspect/inspect-helpers.d.ts +25 -0
  429. package/dist/domains/lp-inspect/inspect-helpers.js +343 -0
  430. package/dist/domains/lp-inspect/inspect.d.ts +8 -0
  431. package/dist/domains/lp-inspect/inspect.js +332 -0
  432. package/dist/domains/lp-inspect/lp-inspect.d.ts +9 -37
  433. package/dist/domains/lp-inspect/lp-inspect.js +9 -775
  434. package/dist/domains/lp-inspect/registry.d.ts +43 -0
  435. package/dist/domains/lp-inspect/registry.js +127 -0
  436. package/dist/domains/merkle/index.d.ts +1 -1
  437. package/dist/exports/root-bundle-and-tooling.d.ts +9 -1
  438. package/dist/exports/root-bundle-and-tooling.js +8 -1
  439. package/dist/exports/root-foundations.d.ts +1 -1
  440. package/dist/exports/root-foundations.js +1 -1
  441. package/dist/exports/root-swap-dex-and-xlayer.d.ts +4 -4
  442. package/dist/exports/root-swap-dex-and-xlayer.js +4 -4
  443. package/dist/index.d.ts +1 -1
  444. package/dist/index.js +1 -1
  445. package/dist/utils/swap-helpers.js +1 -1
  446. package/package.json +1 -81
@@ -1,126 +1,13 @@
1
- import { ethers, Wallet, JsonRpcProvider } from 'ethers';
2
- import { type GeneratedWallet } from '../../../utils/wallet.js';
3
1
  /**
4
-
5
- * XLayer EOA 模式批量换手
6
-
2
+ * XLayer EOA 模式批量换手 helpers(barrel re-export)
7
3
  *
8
-
9
- * 专门为 XLayer 链设计,不影响 BSC 链的逻辑
10
-
11
- * - 使用 PotatoSwap V3 Quoter
12
-
13
- * - 使用 WOKB 作为 Wrapped Native Token
14
-
15
- * - 支持多跳转账和利润刮取
16
-
4
+ * 本文件为兼容性入口,实现已按职责拆分到子文件:
5
+ * - eoa-bundle-swap-types.ts: 类型 + 常量
6
+ * - quote.ts: 报价 + 利润
7
+ * - hop-chain.ts: 多跳转账链
8
+ * - context.ts: 上下文 + Gas
17
9
  */
18
- export declare const XLAYER_CHAIN_ID: 196;
19
- export declare const WOKB_ADDRESS: string;
20
- export declare const POTATO_V2_ROUTER: string;
21
- export declare const POTATO_V3_ROUTER: string;
22
- export declare const NATIVE_TRANSFER_GAS_LIMIT: 21055n;
23
- export { ZERO_ADDRESS } from '../../../core/constants/index.js';
24
- export type UserType = 'v0' | 'v1';
25
- export type SwapRouteType = 'v2' | 'v3-single' | 'v3-multi';
26
- export interface V2RouteParams {
27
- routeType: 'v2';
28
- v2Path: string[];
29
- }
30
- export interface V3SingleRouteParams {
31
- routeType: 'v3-single';
32
- v3TokenIn: string;
33
- v3TokenOut: string;
34
- v3Fee: number;
35
- v2Path?: string[];
36
- }
37
- export interface V3MultiRouteParams {
38
- routeType: 'v3-multi';
39
- v3LpAddresses: string[];
40
- v3ExactTokenIn: string;
41
- v2Path?: string[];
42
- }
43
- export type RouteParams = V2RouteParams | V3SingleRouteParams | V3MultiRouteParams;
44
- export interface XLayerEoaSwapConfig {
45
- rpcUrl: string;
46
- gasLimit?: number | bigint;
47
- gasLimitMultiplier?: number;
48
- minGasPriceGwei?: number;
49
- maxGasPriceGwei?: number;
50
- txType?: 0 | 2;
51
- reserveGasBNB?: number;
52
- userType?: UserType;
53
- bribeAmount?: number;
54
- }
55
- export interface XLayerQuickBatchSwapParams {
56
- sellerPrivateKey: string;
57
- sellAmount?: string;
58
- sellPercentage?: number;
59
- buyerPrivateKeys: string[];
60
- buyerRatios?: number[];
61
- buyerAmounts?: string[];
62
- tokenAddress: string;
63
- routeParams: RouteParams;
64
- config: XLayerEoaSwapConfig;
65
- quoteToken?: string;
66
- quoteTokenDecimals?: number;
67
- disperseHopCount?: number;
68
- startNonces?: number[];
69
- }
70
- export interface XLayerQuickBatchSwapResult {
71
- signedTransactions: string[];
72
- disperseHopWallets?: GeneratedWallet[];
73
- profitHopWallets?: GeneratedWallet[];
74
- metadata?: {
75
- sellerAddress: string;
76
- buyerAddresses: string[];
77
- sellAmount: string;
78
- estimatedOutput: string;
79
- transferAmounts: string[];
80
- profitAmount?: string;
81
- useNativeToken: boolean;
82
- disperseHopCount?: number;
83
- };
84
- }
85
- export interface XLayerCrossSwapParams {
86
- sellerPrivateKeys: string[];
87
- sellAmounts: string[];
88
- buyerPrivateKeys: string[];
89
- tokenAddress: string;
90
- routeParams: RouteParams;
91
- config: XLayerEoaSwapConfig;
92
- quoteToken?: string;
93
- quoteTokenDecimals?: number;
94
- buyersPerSell?: number;
95
- disperseHopCount?: number;
96
- /** ✅ 预获取的 nonce(地址 -> nonce),避免 nonce 不同步 */
97
- startNonces?: Map<string, number>;
98
- }
99
- export interface XLayerCrossSwapResult {
100
- signedTransactions: string[];
101
- rounds: Array<{
102
- sellerAddress: string;
103
- buyerAddresses: string[];
104
- sellAmount: string;
105
- bundleHash?: string;
106
- }>;
107
- disperseHopWallets?: GeneratedWallet[];
108
- profitHopWallets?: GeneratedWallet[];
109
- }
110
- export declare function createXLayerContext(config: XLayerEoaSwapConfig): {
111
- chainId: 196;
112
- provider: ethers.JsonRpcProvider;
113
- };
114
- export declare function getGasLimit(config: XLayerEoaSwapConfig, defaultGas?: number): bigint;
115
- export declare function getGasPrice(provider: JsonRpcProvider, config: XLayerEoaSwapConfig): Promise<bigint>;
116
- export declare function getProfitRateBps(userType?: UserType): number;
117
- export declare function calculateProfitAmount(estimatedOutput: bigint, userType?: UserType): bigint;
118
- export declare function quoteSellOutput(provider: JsonRpcProvider, routeParams: RouteParams, sellAmountWei: bigint): Promise<bigint>;
119
- export declare function getERC20ToOkbQuote(provider: JsonRpcProvider, tokenAddress: string, tokenAmount: bigint, version?: 'v2' | 'v3', fee?: number): Promise<bigint>;
120
- export type DisperseHopPath = {
121
- targetAddress: string;
122
- hopWallets: Wallet[];
123
- hopWalletsInfo: GeneratedWallet[];
124
- };
125
- export declare function generateDisperseHopPaths(targetAddresses: string[], hopCount: number, provider: JsonRpcProvider): DisperseHopPath[];
126
- export declare function buildNativeHopChain(payer: Wallet, path: DisperseHopPath, finalAmount: bigint, gasPrice: bigint, txType: 0 | 2, payerNonce: number): Promise<string[]>;
10
+ export * from './eoa-bundle-swap-types.js';
11
+ export * from './quote.js';
12
+ export * from './hop-chain.js';
13
+ export * from './context.js';
@@ -1,228 +1,13 @@
1
- import { ethers, Wallet } from 'ethers';
2
- import { createXLayerProvider } from '../../../utils/provider-factory.js';
3
- import { GAS_LIMITS, CHAINS, getProfitRateBps as getSharedProfitRateBps } from '../../../core/constants/index.js';
4
- import { quoteV2, quoteV3 } from '../../../domains/quote/quote-helpers.js';
5
- import { generateWallets } from '../../../utils/wallet.js';
6
- import { WOKB, POTATOSWAP_V2_ROUTER, POTATOSWAP_SWAP_ROUTER02 } from './constants.js';
7
1
  /**
8
-
9
- * XLayer EOA 模式批量换手
10
-
2
+ * XLayer EOA 模式批量换手 helpers(barrel re-export)
11
3
  *
12
-
13
- * 专门为 XLayer 链设计,不影响 BSC 链的逻辑
14
-
15
- * - 使用 PotatoSwap V3 Quoter
16
-
17
- * - 使用 WOKB 作为 Wrapped Native Token
18
-
19
- * - 支持多跳转账和利润刮取
20
-
4
+ * 本文件为兼容性入口,实现已按职责拆分到子文件:
5
+ * - eoa-bundle-swap-types.ts: 类型 + 常量
6
+ * - quote.ts: 报价 + 利润
7
+ * - hop-chain.ts: 多跳转账链
8
+ * - context.ts: 上下文 + Gas
21
9
  */
22
- // ✅ 从 XLayer 常量导入正确的路由地址
23
- // ==================== XLayer 专用常量 ====================
24
- export const XLAYER_CHAIN_ID = CHAINS.XLAYER.chainId;
25
- const XLAYER_CHAIN_NAME = CHAINS.XLAYER.name;
26
- export const WOKB_ADDRESS = ethers.getAddress(WOKB);
27
- // ✅ 强制校验和,避免大小写错误导致的 bad address checksum
28
- export const POTATO_V2_ROUTER = ethers.getAddress(POTATOSWAP_V2_ROUTER);
29
- export const POTATO_V3_ROUTER = ethers.getAddress(POTATOSWAP_SWAP_ROUTER02); // ✅ SwapRouter02 用于 V3 交易
30
- export const NATIVE_TRANSFER_GAS_LIMIT = GAS_LIMITS.NATIVE_TRANSFER;
31
- export { ZERO_ADDRESS } from '../../../core/constants/index.js';
32
- // ==================== 工具函数 ====================
33
- export function createXLayerContext(config) {
34
- const provider = createXLayerProvider(config.rpcUrl);
35
- return { chainId: XLAYER_CHAIN_ID, provider };
36
- }
37
- export function getGasLimit(config, defaultGas = 800000) {
38
- if (config.gasLimit !== undefined) {
39
- return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
40
- }
41
- const multiplier = config.gasLimitMultiplier ?? 1.0;
42
- return BigInt(Math.ceil(defaultGas * multiplier));
43
- }
44
- export async function getGasPrice(provider, config) {
45
- const feeData = await provider.getFeeData();
46
- let gasPrice = feeData.gasPrice || ethers.parseUnits('0.1', 'gwei');
47
- if (config.minGasPriceGwei) {
48
- const minGas = ethers.parseUnits(config.minGasPriceGwei.toString(), 'gwei');
49
- if (gasPrice < minGas)
50
- gasPrice = minGas;
51
- }
52
- if (config.maxGasPriceGwei) {
53
- const maxGas = ethers.parseUnits(config.maxGasPriceGwei.toString(), 'gwei');
54
- if (gasPrice > maxGas)
55
- gasPrice = maxGas;
56
- }
57
- return gasPrice;
58
- }
59
- export function getProfitRateBps(userType) {
60
- if (userType === 'v0')
61
- return getSharedProfitRateBps('v0Single');
62
- if (userType === 'v1')
63
- return getSharedProfitRateBps('v1Single');
64
- return getSharedProfitRateBps('v0Single');
65
- }
66
- export function calculateProfitAmount(estimatedOutput, userType) {
67
- if (estimatedOutput <= 0n)
68
- return 0n;
69
- const rateBps = getProfitRateBps(userType);
70
- return (estimatedOutput * BigInt(rateBps)) / 10000n;
71
- }
72
- // ==================== 报价函数 ====================
73
- export async function quoteSellOutput(provider, routeParams, sellAmountWei) {
74
- if (routeParams.routeType === 'v2') {
75
- const { v2Path } = routeParams;
76
- const tokenIn = v2Path[0];
77
- const tokenOut = v2Path[v2Path.length - 1];
78
- const result = await quoteV2(provider, tokenIn, tokenOut, sellAmountWei, XLAYER_CHAIN_NAME);
79
- if (result.amountOut > 0n) {
80
- return result.amountOut;
81
- }
82
- throw new Error('V2 报价失败');
83
- }
84
- if (routeParams.routeType === 'v3-single') {
85
- const params = routeParams;
86
- const result = await quoteV3(provider, params.v3TokenIn, params.v3TokenOut, sellAmountWei, XLAYER_CHAIN_NAME, params.v3Fee);
87
- if (result.amountOut > 0n) {
88
- return result.amountOut;
89
- }
90
- // ❗️兜底:如果 V3 报价失败且提供了 v2Path,则尝试 V2 报价(避免因为无对应费率池导致失败)
91
- if (params.v2Path && params.v2Path.length >= 2) {
92
- const tokenIn = params.v2Path[0];
93
- const tokenOut = params.v2Path[params.v2Path.length - 1];
94
- const v2Result = await quoteV2(provider, tokenIn, tokenOut, sellAmountWei, XLAYER_CHAIN_NAME);
95
- if (v2Result.amountOut > 0n) {
96
- return v2Result.amountOut;
97
- }
98
- }
99
- throw new Error(`V3 单跳报价失败: tokenIn=${params.v3TokenIn}, tokenOut=${params.v3TokenOut}, fee=${params.v3Fee}`);
100
- }
101
- if (routeParams.routeType === 'v3-multi') {
102
- const params = routeParams;
103
- const tokenIn = params.v3ExactTokenIn;
104
- const result = await quoteV3(provider, tokenIn, WOKB_ADDRESS, sellAmountWei, XLAYER_CHAIN_NAME);
105
- if (result.amountOut > 0n) {
106
- return result.amountOut;
107
- }
108
- // ❗️兜底:如果 V3 多跳失败且提供 v2Path,则尝试 V2 报价
109
- if (params.v2Path && params.v2Path.length >= 2) {
110
- const tokenInV2 = params.v2Path[0];
111
- const tokenOutV2 = params.v2Path[params.v2Path.length - 1];
112
- const v2Result = await quoteV2(provider, tokenInV2, tokenOutV2, sellAmountWei, XLAYER_CHAIN_NAME);
113
- if (v2Result.amountOut > 0n) {
114
- return v2Result.amountOut;
115
- }
116
- }
117
- throw new Error(`V3 多跳报价失败`);
118
- }
119
- // ✅ 用类型判断收窄 RouteParams 联合类型
120
- const routeType = routeParams.routeType ??
121
- routeParams.routeType ??
122
- routeParams.routeType;
123
- throw new Error(`不支持的路由类型: ${routeType}`);
124
- }
125
- export async function getERC20ToOkbQuote(provider, tokenAddress, tokenAmount, version = 'v2', fee) {
126
- if (tokenAmount <= 0n)
127
- return 0n;
128
- const tokenLower = tokenAddress.toLowerCase();
129
- const wokbLower = WOKB_ADDRESS.toLowerCase();
130
- if (tokenLower === wokbLower)
131
- return tokenAmount;
132
- if (version === 'v3') {
133
- const result = await quoteV3(provider, tokenAddress, WOKB_ADDRESS, tokenAmount, XLAYER_CHAIN_NAME, fee);
134
- if (result.amountOut > 0n) {
135
- return result.amountOut;
136
- }
137
- return 0n;
138
- }
139
- const result = await quoteV2(provider, tokenAddress, WOKB_ADDRESS, tokenAmount, XLAYER_CHAIN_NAME);
140
- if (result.amountOut > 0n) {
141
- return result.amountOut;
142
- }
143
- return 0n;
144
- }
145
- export function generateDisperseHopPaths(targetAddresses, hopCount, provider) {
146
- if (hopCount <= 0) {
147
- return targetAddresses.map((addr) => ({
148
- targetAddress: addr,
149
- hopWallets: [],
150
- hopWalletsInfo: [],
151
- }));
152
- }
153
- return targetAddresses.map((targetAddress) => {
154
- const hopWalletsInfo = generateWallets(hopCount);
155
- const hopWallets = hopWalletsInfo.map((w) => new Wallet(w.privateKey, provider));
156
- return { targetAddress, hopWallets, hopWalletsInfo };
157
- });
158
- }
159
- export async function buildNativeHopChain(payer, path, finalAmount, gasPrice, txType, payerNonce) {
160
- const signedTxs = [];
161
- const hopCount = path.hopWallets.length;
162
- if (hopCount === 0) {
163
- const tx = {
164
- to: path.targetAddress,
165
- value: finalAmount,
166
- nonce: payerNonce,
167
- gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
168
- chainId: XLAYER_CHAIN_ID,
169
- type: txType,
170
- };
171
- if (txType === 2) {
172
- tx.maxFeePerGas = gasPrice;
173
- tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
174
- }
175
- else {
176
- tx.gasPrice = gasPrice;
177
- }
178
- signedTxs.push(await payer.signTransaction(tx));
179
- return signedTxs;
180
- }
181
- const hopGasCost = NATIVE_TRANSFER_GAS_LIMIT * gasPrice;
182
- const amountsPerHop = [];
183
- for (let i = 0; i < hopCount; i++) {
184
- const remainingHops = hopCount - i;
185
- amountsPerHop.push(finalAmount + hopGasCost * 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: XLAYER_CHAIN_ID,
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
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 ? finalAmount : amountsPerHop[i + 1];
209
- const tx = {
210
- to: toAddress,
211
- value: amount,
212
- nonce: 0,
213
- gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
214
- chainId: XLAYER_CHAIN_ID,
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
- }
228
- // ==================== XLayer 快捷批量换手 ====================
10
+ export * from './eoa-bundle-swap-types.js';
11
+ export * from './quote.js';
12
+ export * from './hop-chain.js';
13
+ export * from './context.js';
@@ -0,0 +1,50 @@
1
+ /**
2
+ * XLayer EOA 真正的交叉换手(卖方保留 OKB,买方用自己 OKB)
3
+ */
4
+ import { type RouteParams, type XLayerEoaSwapConfig } from './eoa-bundle-swap-helpers.js';
5
+ /**
6
+ * 真正的交叉换手参数
7
+ */
8
+ export interface XLayerPureCrossSwapParams {
9
+ /** 卖方私钥列表 */
10
+ sellerPrivateKeys: string[];
11
+ /** 每个卖方的卖出数量 */
12
+ sellAmounts: string[];
13
+ /** 买方私钥列表 */
14
+ buyerPrivateKeys: string[];
15
+ /** 每个买方的买入 OKB 数量 */
16
+ buyAmounts: string[];
17
+ /** 代币地址 */
18
+ tokenAddress: string;
19
+ /** 路由参数 */
20
+ routeParams: RouteParams;
21
+ /** 配置 */
22
+ config: XLayerEoaSwapConfig;
23
+ /** 报价代币(默认 OKB) */
24
+ quoteToken?: string;
25
+ /** 预获取的 nonce(地址 -> nonce) */
26
+ startNonces?: Map<string, number>;
27
+ }
28
+ /**
29
+ * 真正的交叉换手结果
30
+ */
31
+ export interface XLayerPureCrossSwapResult {
32
+ signedTransactions: string[];
33
+ metadata: {
34
+ sellerAddresses: string[];
35
+ buyerAddresses: string[];
36
+ sellAmounts: string[];
37
+ buyAmounts: string[];
38
+ };
39
+ }
40
+ /**
41
+ * ✅ 真正的交叉换手
42
+ *
43
+ * 与资金利用率模式不同:
44
+ * - 卖方卖出代币 → OKB 留在卖方钱包
45
+ * - 买方用自己的 OKB 买入代币
46
+ * - 无资金转移
47
+ *
48
+ * 交易顺序:卖1 → 买1 → 卖2 → 买2 → ... (交替执行)
49
+ */
50
+ export declare function xlayerPureCrossSwapMerkle(params: XLayerPureCrossSwapParams): Promise<XLayerPureCrossSwapResult>;
@@ -0,0 +1,170 @@
1
+ /**
2
+ * XLayer EOA 真正的交叉换手(卖方保留 OKB,买方用自己 OKB)
3
+ */
4
+ import { ethers, Contract, Wallet } from 'ethers';
5
+ import { getGasLimit } from '../../../core/gas/bundle-gas.js';
6
+ import { calculateSellAmount } from '../../../utils/swap-helpers.js';
7
+ import { NonceManager, getDeadline } from '../../../utils/bundle-helpers.js';
8
+ import { V2_ROUTER_ABI, V3_ROUTER02_ABI } from '../../../abis/common.js';
9
+ import { POTATO_V2_ROUTER, POTATO_V3_ROUTER, XLAYER_CHAIN_ID, ZERO_ADDRESS, createXLayerContext, getGasPrice, } from './eoa-bundle-swap-helpers.js';
10
+ /**
11
+ * ✅ 真正的交叉换手
12
+ *
13
+ * 与资金利用率模式不同:
14
+ * - 卖方卖出代币 → OKB 留在卖方钱包
15
+ * - 买方用自己的 OKB 买入代币
16
+ * - 无资金转移
17
+ *
18
+ * 交易顺序:卖1 → 买1 → 卖2 → 买2 → ... (交替执行)
19
+ */
20
+ export async function xlayerPureCrossSwapMerkle(params) {
21
+ const { sellerPrivateKeys, sellAmounts, buyerPrivateKeys, buyAmounts, tokenAddress, routeParams, config, quoteToken, startNonces: inputNonces, } = params;
22
+ if (sellerPrivateKeys.length === 0)
23
+ throw new Error('至少需要一个卖方');
24
+ if (sellerPrivateKeys.length !== sellAmounts.length)
25
+ throw new Error('sellAmounts 长度必须与卖方数量一致');
26
+ if (buyerPrivateKeys.length === 0)
27
+ throw new Error('至少需要一个买方');
28
+ if (buyerPrivateKeys.length !== buyAmounts.length)
29
+ throw new Error('buyAmounts 长度必须与买方数量一致');
30
+ const context = createXLayerContext(config);
31
+ const nonceManager = new NonceManager(context.provider);
32
+ const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
33
+ const sellers = sellerPrivateKeys.map((pk) => new Wallet(pk, context.provider));
34
+ const buyers = buyerPrivateKeys.map((pk) => new Wallet(pk, context.provider));
35
+ // 获取 nonce
36
+ const addressToNonce = new Map();
37
+ for (const wallet of [...sellers, ...buyers]) {
38
+ if (!addressToNonce.has(wallet.address)) {
39
+ const inputNonce = inputNonces?.get(wallet.address.toLowerCase()) ?? inputNonces?.get(wallet.address);
40
+ if (inputNonce !== undefined) {
41
+ addressToNonce.set(wallet.address, inputNonce);
42
+ }
43
+ else {
44
+ addressToNonce.set(wallet.address, await nonceManager.getNextNonce(wallet));
45
+ }
46
+ }
47
+ }
48
+ const [gasPrice, finalGasLimit] = await Promise.all([
49
+ getGasPrice(context.provider, config),
50
+ Promise.resolve(getGasLimit(config, 800000)),
51
+ ]);
52
+ const txType = config.txType ?? 0;
53
+ const deadline = getDeadline();
54
+ const v3RouterIface = new ethers.Interface(V3_ROUTER02_ABI);
55
+ const signedTransactions = [];
56
+ // ==================== 卖出交易 ====================
57
+ for (let i = 0; i < sellers.length; i++) {
58
+ const seller = sellers[i];
59
+ const sellAmount = sellAmounts[i];
60
+ const nonce = addressToNonce.get(seller.address);
61
+ addressToNonce.set(seller.address, nonce + 1);
62
+ // 计算卖出数量
63
+ const { amount: sellAmountWei } = await calculateSellAmount(context.provider, tokenAddress, seller.address, sellAmount);
64
+ let sellUnsigned;
65
+ if (routeParams.routeType === 'v2') {
66
+ const { v2Path } = routeParams;
67
+ const v2Router = new Contract(POTATO_V2_ROUTER, V2_ROUTER_ABI, seller);
68
+ if (useNativeToken) {
69
+ sellUnsigned = await v2Router.swapExactTokensForETHSupportingFeeOnTransferTokens.populateTransaction(sellAmountWei, 0n, v2Path, seller.address, deadline);
70
+ }
71
+ else {
72
+ sellUnsigned = await v2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(sellAmountWei, 0n, v2Path, seller.address, deadline);
73
+ }
74
+ }
75
+ else if (routeParams.routeType === 'v3-single') {
76
+ const { v3TokenIn, v3TokenOut, v3Fee } = routeParams;
77
+ const v3Router = new Contract(POTATO_V3_ROUTER, V3_ROUTER02_ABI, seller);
78
+ const sellSwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
79
+ {
80
+ tokenIn: v3TokenIn,
81
+ tokenOut: v3TokenOut,
82
+ fee: v3Fee,
83
+ recipient: useNativeToken ? POTATO_V3_ROUTER : seller.address,
84
+ amountIn: sellAmountWei,
85
+ amountOutMinimum: 0n,
86
+ sqrtPriceLimitX96: 0n,
87
+ },
88
+ ]);
89
+ if (useNativeToken) {
90
+ const sellUnwrapData = v3RouterIface.encodeFunctionData('unwrapWETH9', [0n, seller.address]);
91
+ sellUnsigned = await v3Router.multicall.populateTransaction(deadline, [sellSwapData, sellUnwrapData]);
92
+ }
93
+ else {
94
+ sellUnsigned = await v3Router.multicall.populateTransaction(deadline, [sellSwapData]);
95
+ }
96
+ }
97
+ else {
98
+ throw new Error('V3 多跳路由暂不支持');
99
+ }
100
+ const signedSell = await seller.signTransaction({
101
+ ...sellUnsigned,
102
+ from: seller.address,
103
+ nonce,
104
+ gasLimit: finalGasLimit,
105
+ gasPrice,
106
+ chainId: XLAYER_CHAIN_ID,
107
+ type: txType,
108
+ });
109
+ signedTransactions.push(signedSell);
110
+ }
111
+ // ==================== 买入交易 ====================
112
+ for (let i = 0; i < buyers.length; i++) {
113
+ const buyer = buyers[i];
114
+ const buyAmount = buyAmounts[i];
115
+ const nonce = addressToNonce.get(buyer.address);
116
+ addressToNonce.set(buyer.address, nonce + 1);
117
+ const buyAmountWei = ethers.parseEther(buyAmount);
118
+ const buyValue = useNativeToken ? buyAmountWei : 0n;
119
+ let buyUnsigned;
120
+ if (routeParams.routeType === 'v2') {
121
+ const { v2Path } = routeParams;
122
+ const reversePath = [...v2Path].reverse();
123
+ const v2Router = new Contract(POTATO_V2_ROUTER, V2_ROUTER_ABI, buyer);
124
+ if (useNativeToken) {
125
+ buyUnsigned = await v2Router.swapExactETHForTokensSupportingFeeOnTransferTokens.populateTransaction(0n, reversePath, buyer.address, deadline, { value: buyValue });
126
+ }
127
+ else {
128
+ buyUnsigned = await v2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(buyAmountWei, 0n, reversePath, buyer.address, deadline);
129
+ }
130
+ }
131
+ else if (routeParams.routeType === 'v3-single') {
132
+ const { v3TokenIn, v3TokenOut, v3Fee } = routeParams;
133
+ const v3Router = new Contract(POTATO_V3_ROUTER, V3_ROUTER02_ABI, buyer);
134
+ const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [
135
+ {
136
+ tokenIn: v3TokenOut, // 买入时反过来
137
+ tokenOut: v3TokenIn,
138
+ fee: v3Fee,
139
+ recipient: buyer.address,
140
+ amountIn: buyAmountWei,
141
+ amountOutMinimum: 0n,
142
+ sqrtPriceLimitX96: 0n,
143
+ },
144
+ ]);
145
+ buyUnsigned = await v3Router.multicall.populateTransaction(deadline, [buySwapData], { value: buyValue });
146
+ }
147
+ else {
148
+ throw new Error('V3 多跳路由暂不支持');
149
+ }
150
+ const signedBuy = await buyer.signTransaction({
151
+ ...buyUnsigned,
152
+ from: buyer.address,
153
+ nonce,
154
+ gasLimit: finalGasLimit,
155
+ gasPrice,
156
+ chainId: XLAYER_CHAIN_ID,
157
+ type: txType,
158
+ });
159
+ signedTransactions.push(signedBuy);
160
+ }
161
+ return {
162
+ signedTransactions,
163
+ metadata: {
164
+ sellerAddresses: sellers.map((s) => s.address),
165
+ buyerAddresses: buyers.map((b) => b.address),
166
+ sellAmounts,
167
+ buyAmounts,
168
+ },
169
+ };
170
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * XLayer EOA 快速批量换手(单卖多买)
3
+ */
4
+ import { type XLayerQuickBatchSwapParams, type XLayerQuickBatchSwapResult } from './eoa-bundle-swap-helpers.js';
5
+ export declare function xlayerQuickBatchSwapMerkle(params: XLayerQuickBatchSwapParams): Promise<XLayerQuickBatchSwapResult>;