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,6 @@
1
+ import { Wallet } from 'ethers';
2
+ import type { JsonRpcProvider } from 'ethers';
3
+ import type { GeneratedWallet } from './types.js';
4
+ export declare function createWallet(privateKey: string, provider?: JsonRpcProvider): Wallet;
5
+ export declare function generateRandomWallet(): GeneratedWallet;
6
+ export declare function generateRandomWallets(count: number): GeneratedWallet[];
@@ -0,0 +1,17 @@
1
+ import { Wallet } from 'ethers';
2
+ // ========================================
3
+ // 钱包工具
4
+ // ========================================
5
+ export function createWallet(privateKey, provider) {
6
+ return new Wallet(privateKey, provider);
7
+ }
8
+ export function generateRandomWallet() {
9
+ const wallet = Wallet.createRandom();
10
+ return {
11
+ address: wallet.address,
12
+ privateKey: wallet.privateKey,
13
+ };
14
+ }
15
+ export function generateRandomWallets(count) {
16
+ return Array.from({ length: count }, () => generateRandomWallet());
17
+ }
@@ -0,0 +1,176 @@
1
+ /**
2
+ * XLayer SDK — ERC-4337 AA 类型定义
3
+ *
4
+ * 包含 ERC-4337 UserOperation、AA 账户、AA Gas 策略、handleOps 结果等核心类型
5
+ */
6
+ import type { HexString } from './constants.js';
7
+ /**
8
+ * UserOperation v0.6 结构
9
+ * 用于 ERC-4337 EntryPoint v0.6
10
+ */
11
+ export interface UserOperation {
12
+ sender: string;
13
+ nonce: HexString | string;
14
+ initCode: HexString | string;
15
+ callData: HexString | string;
16
+ callGasLimit: HexString | string;
17
+ verificationGasLimit: HexString | string;
18
+ preVerificationGas: HexString | string;
19
+ maxFeePerGas: HexString | string;
20
+ maxPriorityFeePerGas: HexString | string;
21
+ paymasterAndData: HexString | string;
22
+ signature: HexString | string;
23
+ }
24
+ /**
25
+ * 签名后的 UserOperation(包含额外元数据)
26
+ */
27
+ export interface SignedUserOp {
28
+ userOp: UserOperation;
29
+ userOpHash: string;
30
+ prefundWei: bigint;
31
+ sender: string;
32
+ ownerName?: string;
33
+ }
34
+ /**
35
+ * Gas 估算结果(来自 Bundler)
36
+ */
37
+ export interface GasEstimate {
38
+ callGasLimit: HexString;
39
+ verificationGasLimit: HexString;
40
+ preVerificationGas: HexString;
41
+ maxFeePerGas?: HexString;
42
+ maxPriorityFeePerGas?: HexString;
43
+ }
44
+ export type GasPolicy = 'fixed' | 'localEstimate' | 'bundlerEstimate';
45
+ export interface FixedGasConfig {
46
+ /** callGasLimit(若不提供,SDK 会使用较保守的默认值) */
47
+ callGasLimit?: bigint;
48
+ /** 已部署 sender 的 verificationGasLimit(默认用 SDK 常量) */
49
+ verificationGasLimitDeployed?: bigint;
50
+ /** 未部署 sender 的 verificationGasLimit(默认用 SDK 常量) */
51
+ verificationGasLimitUndeployed?: bigint;
52
+ /** preVerificationGas(默认用 SDK 常量) */
53
+ preVerificationGas?: bigint;
54
+ /** ✅ 固定 gasPrice(若不提供,SDK 会调用 getFeeData 获取) */
55
+ gasPrice?: bigint;
56
+ }
57
+ /**
58
+ * XLayer SDK 基础配置
59
+ */
60
+ export interface XLayerConfig {
61
+ /** RPC URL(默认使用公共节点) */
62
+ rpcUrl?: string;
63
+ /** Bundler URL(默认使用 Particle) */
64
+ bundlerUrl?: string;
65
+ /** Chain ID(默认 196) */
66
+ chainId?: number;
67
+ /** EntryPoint 地址 */
68
+ entryPoint?: string;
69
+ /** SimpleAccountFactory 地址 */
70
+ factory?: string;
71
+ /** Salt(用于 AA 账户派生) */
72
+ salt?: bigint;
73
+ /** Paymaster 地址(如果指定,不需要往 AA 转手续费) */
74
+ paymaster?: string;
75
+ /** Paymaster Data(与 paymaster 一起使用) */
76
+ paymasterData?: string;
77
+ /** 默认超时时间(毫秒) */
78
+ timeoutMs?: number;
79
+ /** Gas 估算安全余量倍数 */
80
+ gasLimitMultiplier?: number;
81
+ /** Payer handleOps 交易的 gasLimit(手动覆盖) */
82
+ gasLimit?: bigint;
83
+ /** Payer handleOps 交易的最小 gasPrice (Gwei) */
84
+ minGasPriceGwei?: number;
85
+ /** 利润尾笔原生转账 gasLimit(默认 21000n) */
86
+ profitTailGasLimit?: bigint;
87
+ /**
88
+ * AA Gas 策略(用于大规模地址时减少 RPC)
89
+ * - fixed:固定 gas(不 estimate)
90
+ * - localEstimate:eth_estimateGas(不走 bundler)
91
+ * - bundlerEstimate:eth_estimateUserOperationGas(最慢但最稳)
92
+ */
93
+ gasPolicy?: GasPolicy;
94
+ /** fixed 策略的默认 gas 配置(可被每次调用覆盖) */
95
+ fixedGas?: FixedGasConfig;
96
+ /**
97
+ * 是否提取利润(默认 true)
98
+ * - 对齐 BSC:默认会从“卖出得到的 OKB / 归集金额”中按比例刮取利润
99
+ */
100
+ extractProfit?: boolean;
101
+ /**
102
+ * 利润比例(基点 bps,1 bps = 0.01%)
103
+ * - 默认使用 `getProfitRateBps('normal')`
104
+ */
105
+ profitBps?: number;
106
+ /**
107
+ * 利润接收地址
108
+ * - 默认使用 `getProfitRecipient()`
109
+ */
110
+ profitRecipient?: string;
111
+ /**
112
+ * ✅ 安全边际百分比(默认 80)
113
+ * - 只使用报价的 X% 进行分发,防止价格下跌导致失败
114
+ * - 例如:80 表示只使用报价的 80%,允许价格下跌 20%
115
+ * - 范围:50-100,越低越安全但买入金额越少
116
+ */
117
+ safetyMarginPercent?: number;
118
+ }
119
+ /**
120
+ * AA 账户信息
121
+ */
122
+ export interface AAAccount {
123
+ /** Owner EOA 地址 */
124
+ owner: string;
125
+ /** AA Sender 地址 */
126
+ sender: string;
127
+ /** 是否已部署 */
128
+ deployed: boolean;
129
+ /** OKB 余额 */
130
+ balance: bigint;
131
+ /** Nonce */
132
+ nonce: bigint;
133
+ }
134
+ /**
135
+ * Owner 钱包信息
136
+ */
137
+ export interface OwnerInfo {
138
+ name: string;
139
+ privateKey: string;
140
+ address?: string;
141
+ sender?: string;
142
+ }
143
+ /**
144
+ * handleOps 执行结果
145
+ */
146
+ export interface HandleOpsResult {
147
+ /** 交易哈希 */
148
+ txHash: string;
149
+ /** 区块号 */
150
+ blockNumber: number;
151
+ /** 交易状态 */
152
+ status: number;
153
+ /** UserOperationEvent 列表 */
154
+ userOpEvents: UserOpEventResult[];
155
+ }
156
+ /**
157
+ * UserOperationEvent 解析结果
158
+ */
159
+ export interface UserOpEventResult {
160
+ userOpHash: string;
161
+ sender: string;
162
+ paymaster: string;
163
+ success: boolean;
164
+ actualGasCost: bigint;
165
+ actualGasUsed: bigint;
166
+ }
167
+ /**
168
+ * 深度 Partial 类型
169
+ */
170
+ export type DeepPartial<T> = {
171
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
172
+ };
173
+ /**
174
+ * 必需的配置字段
175
+ */
176
+ export type RequiredConfig = Required<Pick<XLayerConfig, 'rpcUrl' | 'bundlerUrl' | 'chainId' | 'entryPoint' | 'factory'>>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * XLayer SDK — ERC-4337 AA 类型定义
3
+ *
4
+ * 包含 ERC-4337 UserOperation、AA 账户、AA Gas 策略、handleOps 结果等核心类型
5
+ */
6
+ export {};
@@ -14,8 +14,6 @@ export declare const XLAYER_CHAIN_NAME = "xlayer";
14
14
  export declare const DEFAULT_RPC_URL: "https://xlayerrpc.okx.com";
15
15
  /** 零地址(表示原生代币) */
16
16
  export declare const ZERO_ADDRESS: "0x0000000000000000000000000000000000000000";
17
- /** 高级 RPC URL(QuikNode) */
18
- export declare const QUIKNODE_RPC_URL = "https://stylish-practical-valley.xlayer-mainnet.quiknode.pro/84bb5dedac404fa486f57ab6387e32254dee1f83";
19
17
  /** Particle Bundler URL */
20
18
  export declare const PARTICLE_BUNDLER_URL = "https://bundler.particle.network";
21
19
  /** EntryPoint v0.6 合约地址 */
@@ -21,8 +21,6 @@ export const ZERO_ADDRESS = SHARED_ZERO_ADDRESS;
21
21
  // ============================================================================
22
22
  // XLayer 特有配置
23
23
  // ============================================================================
24
- /** 高级 RPC URL(QuikNode) */
25
- export const QUIKNODE_RPC_URL = 'https://stylish-practical-valley.xlayer-mainnet.quiknode.pro/84bb5dedac404fa486f57ab6387e32254dee1f83';
26
24
  /** Particle Bundler URL */
27
25
  export const PARTICLE_BUNDLER_URL = 'https://bundler.particle.network';
28
26
  // ============================================================================
@@ -0,0 +1,8 @@
1
+ import { ethers } from 'ethers';
2
+ import type { JsonRpcProvider } from 'ethers';
3
+ import { type XLayerEoaSwapConfig } from './eoa-bundle-swap-types.js';
4
+ export declare function createXLayerContext(config: XLayerEoaSwapConfig): {
5
+ chainId: 196;
6
+ provider: ethers.JsonRpcProvider;
7
+ };
8
+ export declare function getGasPrice(provider: JsonRpcProvider, config: XLayerEoaSwapConfig): Promise<bigint>;
@@ -0,0 +1,23 @@
1
+ import { ethers } from 'ethers';
2
+ import { createXLayerProvider } from '../../../utils/provider-factory.js';
3
+ import { XLAYER_CHAIN_ID } from './eoa-bundle-swap-types.js';
4
+ // ==================== 工具函数 ====================
5
+ export function createXLayerContext(config) {
6
+ const provider = createXLayerProvider(config.rpcUrl);
7
+ return { chainId: XLAYER_CHAIN_ID, provider };
8
+ }
9
+ export async function getGasPrice(provider, config) {
10
+ const feeData = await provider.getFeeData();
11
+ let gasPrice = feeData.gasPrice || ethers.parseUnits('0.1', 'gwei');
12
+ if (config.minGasPriceGwei) {
13
+ const minGas = ethers.parseUnits(config.minGasPriceGwei.toString(), 'gwei');
14
+ if (gasPrice < minGas)
15
+ gasPrice = minGas;
16
+ }
17
+ if (config.maxGasPriceGwei) {
18
+ const maxGas = ethers.parseUnits(config.maxGasPriceGwei.toString(), 'gwei');
19
+ if (gasPrice > maxGas)
20
+ gasPrice = maxGas;
21
+ }
22
+ return gasPrice;
23
+ }
@@ -0,0 +1,147 @@
1
+ /**
2
+ * XLayer Portal 操作 — 编码器(encoders)
3
+ */
4
+ import { ethers } from 'ethers';
5
+ export declare const erc20Iface: ethers.Interface;
6
+ /**
7
+ * 编码买入调用(swapExactInput: native -> token)
8
+ *
9
+ * @param tokenAddress 目标代币地址
10
+ * @param inputAmount 输入 OKB 数量(wei)
11
+ * @param minOutputAmount 最小输出代币数量(默认 0)
12
+ */
13
+ export declare function encodeBuyCall(tokenAddress: string, inputAmount: bigint, minOutputAmount?: bigint): string;
14
+ /**
15
+ * 编码买入调用 V3(swapExactInputV3: native -> token,支持 extensionData)
16
+ *
17
+ * 与 BSC 版本的 create-to-dex.ts 保持一致:
18
+ * - 统一优先使用 swapExactInputV3(支持 extensionData;无扩展时传 0x 即可)
19
+ * - 这里的 V3 指"交易接口版本(扩展支持)",不是"外盘 V3 池子"
20
+ *
21
+ * @param tokenAddress 目标代币地址
22
+ * @param inputAmount 输入 OKB 数量(wei)
23
+ * @param minOutputAmount 最小输出代币数量(默认 0)
24
+ * @param extensionData 扩展数据(默认 0x)
25
+ */
26
+ export declare function encodeBuyCallV3(tokenAddress: string, inputAmount: bigint, minOutputAmount?: bigint, extensionData?: string): string;
27
+ /**
28
+ * 编码卖出调用(swapExactInput: token -> native)
29
+ *
30
+ * @param tokenAddress 目标代币地址
31
+ * @param inputAmount 输入代币数量
32
+ * @param minOutputAmount 最小输出 OKB 数量(默认 0)
33
+ */
34
+ export declare function encodeSellCall(tokenAddress: string, inputAmount: bigint, minOutputAmount?: bigint): string;
35
+ /**
36
+ * ✅ 编码卖出调用(支持 ERC20 输出):swapExactInput: token -> quoteToken
37
+ *
38
+ * @param tokenAddress 输入代币地址
39
+ * @param quoteToken 输出代币地址(如 USDT/USDC)
40
+ * @param inputAmount 输入代币数量
41
+ * @param minOutputAmount 最小输出数量(默认 0)
42
+ */
43
+ export declare function encodeSellCallWithQuote(tokenAddress: string, quoteToken: string, inputAmount: bigint, minOutputAmount?: bigint): string;
44
+ /**
45
+ * ✅ 编码买入调用(支持 ERC20 输入):swapExactInput: quoteToken -> token
46
+ *
47
+ * @param tokenAddress 输出代币地址
48
+ * @param quoteToken 输入代币地址(如 USDT/USDC)
49
+ * @param inputAmount 输入数量
50
+ * @param minOutputAmount 最小输出代币数量(默认 0)
51
+ */
52
+ export declare function encodeBuyCallWithQuote(tokenAddress: string, quoteToken: string, inputAmount: bigint, minOutputAmount?: bigint): string;
53
+ /**
54
+ * 编码授权调用
55
+ *
56
+ * @param spender 授权对象地址
57
+ * @param amount 授权数量(默认无限)
58
+ */
59
+ export declare function encodeApproveCall(spender: string, amount?: bigint): string;
60
+ /**
61
+ * 编码代币转账调用
62
+ *
63
+ * @param to 接收地址
64
+ * @param amount 转账数量
65
+ */
66
+ export declare function encodeTransferCall(to: string, amount: bigint): string;
67
+ /**
68
+ * 编码创建代币调用 V2
69
+ */
70
+ export declare function encodeCreateCallV2(params: {
71
+ name: string;
72
+ symbol: string;
73
+ meta: string;
74
+ dexThresh: number;
75
+ salt: string;
76
+ taxRate: number;
77
+ migratorType: number;
78
+ quoteToken: string;
79
+ quoteAmt: bigint;
80
+ beneficiary: string;
81
+ permitData: string;
82
+ }): string;
83
+ /**
84
+ * 编码创建代币调用 V3
85
+ */
86
+ export declare function encodeCreateCallV3(params: {
87
+ name: string;
88
+ symbol: string;
89
+ meta: string;
90
+ dexThresh: number;
91
+ salt: string;
92
+ taxRate: number;
93
+ migratorType: number;
94
+ quoteToken: string;
95
+ quoteAmt: bigint;
96
+ beneficiary: string;
97
+ permitData: string;
98
+ extensionID: string;
99
+ extensionData: string;
100
+ }): string;
101
+ /**
102
+ * 编码创建代币调用 V4
103
+ */
104
+ export declare function encodeCreateCallV4(params: {
105
+ name: string;
106
+ symbol: string;
107
+ meta: string;
108
+ dexThresh: number;
109
+ salt: string;
110
+ taxRate: number;
111
+ migratorType: number;
112
+ quoteToken: string;
113
+ quoteAmt: bigint;
114
+ beneficiary: string;
115
+ permitData: string;
116
+ extensionID: string;
117
+ extensionData: string;
118
+ dexId: number;
119
+ lpFeeProfile: number;
120
+ }): string;
121
+ /**
122
+ * 编码创建代币调用 V5(Tax Token V2 高级税收分配)
123
+ */
124
+ export declare function encodeCreateCallV5(params: {
125
+ name: string;
126
+ symbol: string;
127
+ meta: string;
128
+ dexThresh: number;
129
+ salt: string;
130
+ taxRate: number;
131
+ migratorType: number;
132
+ quoteToken: string;
133
+ quoteAmt: bigint;
134
+ beneficiary: string;
135
+ permitData: string;
136
+ extensionID: string;
137
+ extensionData: string;
138
+ dexId: number;
139
+ lpFeeProfile: number;
140
+ taxDuration: bigint;
141
+ antiFarmerDuration: bigint;
142
+ mktBps: number;
143
+ deflationBps: number;
144
+ dividendBps: number;
145
+ lpBps: number;
146
+ minimumShareBalance: bigint;
147
+ }): string;
@@ -0,0 +1,147 @@
1
+ /**
2
+ * XLayer Portal 操作 — 编码器(encoders)
3
+ */
4
+ import { ethers, Interface } from 'ethers';
5
+ import { ZERO_ADDRESS, PORTAL_ABI, ERC20_ABI } from './constants.js';
6
+ const portalIface = new Interface(PORTAL_ABI);
7
+ export const erc20Iface = new Interface(ERC20_ABI);
8
+ /**
9
+ * 编码买入调用(swapExactInput: native -> token)
10
+ *
11
+ * @param tokenAddress 目标代币地址
12
+ * @param inputAmount 输入 OKB 数量(wei)
13
+ * @param minOutputAmount 最小输出代币数量(默认 0)
14
+ */
15
+ export function encodeBuyCall(tokenAddress, inputAmount, minOutputAmount = 0n) {
16
+ return portalIface.encodeFunctionData('swapExactInput', [
17
+ {
18
+ inputToken: ZERO_ADDRESS,
19
+ outputToken: tokenAddress,
20
+ inputAmount,
21
+ minOutputAmount,
22
+ permitData: '0x',
23
+ },
24
+ ]);
25
+ }
26
+ /**
27
+ * 编码买入调用 V3(swapExactInputV3: native -> token,支持 extensionData)
28
+ *
29
+ * 与 BSC 版本的 create-to-dex.ts 保持一致:
30
+ * - 统一优先使用 swapExactInputV3(支持 extensionData;无扩展时传 0x 即可)
31
+ * - 这里的 V3 指"交易接口版本(扩展支持)",不是"外盘 V3 池子"
32
+ *
33
+ * @param tokenAddress 目标代币地址
34
+ * @param inputAmount 输入 OKB 数量(wei)
35
+ * @param minOutputAmount 最小输出代币数量(默认 0)
36
+ * @param extensionData 扩展数据(默认 0x)
37
+ */
38
+ export function encodeBuyCallV3(tokenAddress, inputAmount, minOutputAmount = 0n, extensionData = '0x') {
39
+ return portalIface.encodeFunctionData('swapExactInputV3', [
40
+ {
41
+ inputToken: ZERO_ADDRESS,
42
+ outputToken: tokenAddress,
43
+ inputAmount,
44
+ minOutputAmount,
45
+ permitData: '0x',
46
+ extensionData,
47
+ },
48
+ ]);
49
+ }
50
+ /**
51
+ * 编码卖出调用(swapExactInput: token -> native)
52
+ *
53
+ * @param tokenAddress 目标代币地址
54
+ * @param inputAmount 输入代币数量
55
+ * @param minOutputAmount 最小输出 OKB 数量(默认 0)
56
+ */
57
+ export function encodeSellCall(tokenAddress, inputAmount, minOutputAmount = 0n) {
58
+ return portalIface.encodeFunctionData('swapExactInput', [
59
+ {
60
+ inputToken: tokenAddress,
61
+ outputToken: ZERO_ADDRESS,
62
+ inputAmount,
63
+ minOutputAmount,
64
+ permitData: '0x',
65
+ },
66
+ ]);
67
+ }
68
+ /**
69
+ * ✅ 编码卖出调用(支持 ERC20 输出):swapExactInput: token -> quoteToken
70
+ *
71
+ * @param tokenAddress 输入代币地址
72
+ * @param quoteToken 输出代币地址(如 USDT/USDC)
73
+ * @param inputAmount 输入代币数量
74
+ * @param minOutputAmount 最小输出数量(默认 0)
75
+ */
76
+ export function encodeSellCallWithQuote(tokenAddress, quoteToken, inputAmount, minOutputAmount = 0n) {
77
+ return portalIface.encodeFunctionData('swapExactInput', [
78
+ {
79
+ inputToken: tokenAddress,
80
+ outputToken: quoteToken,
81
+ inputAmount,
82
+ minOutputAmount,
83
+ permitData: '0x',
84
+ },
85
+ ]);
86
+ }
87
+ /**
88
+ * ✅ 编码买入调用(支持 ERC20 输入):swapExactInput: quoteToken -> token
89
+ *
90
+ * @param tokenAddress 输出代币地址
91
+ * @param quoteToken 输入代币地址(如 USDT/USDC)
92
+ * @param inputAmount 输入数量
93
+ * @param minOutputAmount 最小输出代币数量(默认 0)
94
+ */
95
+ export function encodeBuyCallWithQuote(tokenAddress, quoteToken, inputAmount, minOutputAmount = 0n) {
96
+ return portalIface.encodeFunctionData('swapExactInput', [
97
+ {
98
+ inputToken: quoteToken,
99
+ outputToken: tokenAddress,
100
+ inputAmount,
101
+ minOutputAmount,
102
+ permitData: '0x',
103
+ },
104
+ ]);
105
+ }
106
+ /**
107
+ * 编码授权调用
108
+ *
109
+ * @param spender 授权对象地址
110
+ * @param amount 授权数量(默认无限)
111
+ */
112
+ export function encodeApproveCall(spender, amount = ethers.MaxUint256) {
113
+ return erc20Iface.encodeFunctionData('approve', [spender, amount]);
114
+ }
115
+ /**
116
+ * 编码代币转账调用
117
+ *
118
+ * @param to 接收地址
119
+ * @param amount 转账数量
120
+ */
121
+ export function encodeTransferCall(to, amount) {
122
+ return erc20Iface.encodeFunctionData('transfer', [to, amount]);
123
+ }
124
+ /**
125
+ * 编码创建代币调用 V2
126
+ */
127
+ export function encodeCreateCallV2(params) {
128
+ return portalIface.encodeFunctionData('newTokenV2', [params]);
129
+ }
130
+ /**
131
+ * 编码创建代币调用 V3
132
+ */
133
+ export function encodeCreateCallV3(params) {
134
+ return portalIface.encodeFunctionData('newTokenV3', [params]);
135
+ }
136
+ /**
137
+ * 编码创建代币调用 V4
138
+ */
139
+ export function encodeCreateCallV4(params) {
140
+ return portalIface.encodeFunctionData('newTokenV4', [params]);
141
+ }
142
+ /**
143
+ * 编码创建代币调用 V5(Tax Token V2 高级税收分配)
144
+ */
145
+ export function encodeCreateCallV5(params) {
146
+ return portalIface.encodeFunctionData('newTokenV5', [params]);
147
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * XLayer EOA 交叉换手(多卖多买,委托给 quick batch swap)
3
+ */
4
+ import { type XLayerCrossSwapParams, type XLayerCrossSwapResult } from './eoa-bundle-swap-helpers.js';
5
+ export declare function xlayerCrossSwapMerkle(params: XLayerCrossSwapParams): Promise<XLayerCrossSwapResult>;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * XLayer EOA 交叉换手(多卖多买,委托给 quick batch swap)
3
+ */
4
+ import { ethers, Wallet } from 'ethers';
5
+ import { NonceManager } from '../../../utils/bundle-helpers.js';
6
+ import { createXLayerContext, } from './eoa-bundle-swap-helpers.js';
7
+ import { xlayerQuickBatchSwapMerkle } from './eoa-bundle-swap-quick.js';
8
+ export async function xlayerCrossSwapMerkle(params) {
9
+ const { sellerPrivateKeys, sellAmounts, buyerPrivateKeys, tokenAddress, routeParams, config, quoteToken, quoteTokenDecimals = 18, buyersPerSell, disperseHopCount = 0, startNonces: inputNonces, } = params;
10
+ if (sellerPrivateKeys.length === 0)
11
+ throw new Error('至少需要一个卖方');
12
+ if (sellerPrivateKeys.length !== sellAmounts.length)
13
+ throw new Error('sellAmounts 长度必须与卖方数量一致');
14
+ if (buyerPrivateKeys.length === 0)
15
+ throw new Error('至少需要一个买方');
16
+ const context = createXLayerContext(config);
17
+ const nonceManager = new NonceManager(context.provider);
18
+ const allSellerWallets = sellerPrivateKeys.map((pk) => new Wallet(pk, context.provider));
19
+ const allBuyerWallets = buyerPrivateKeys.map((pk) => new Wallet(pk, context.provider));
20
+ // ✅ 优先使用前端传入的 nonce,避免 nonce 不同步
21
+ const addressToNonce = new Map();
22
+ for (const wallet of allSellerWallets) {
23
+ if (!addressToNonce.has(wallet.address)) {
24
+ const inputNonce = inputNonces?.get(wallet.address.toLowerCase()) ?? inputNonces?.get(wallet.address);
25
+ if (inputNonce !== undefined) {
26
+ addressToNonce.set(wallet.address, inputNonce);
27
+ }
28
+ else {
29
+ addressToNonce.set(wallet.address, await nonceManager.getNextNonce(wallet));
30
+ }
31
+ }
32
+ }
33
+ for (const wallet of allBuyerWallets) {
34
+ if (!addressToNonce.has(wallet.address)) {
35
+ const inputNonce = inputNonces?.get(wallet.address.toLowerCase()) ?? inputNonces?.get(wallet.address);
36
+ if (inputNonce !== undefined) {
37
+ addressToNonce.set(wallet.address, inputNonce);
38
+ }
39
+ else {
40
+ addressToNonce.set(wallet.address, await nonceManager.getNextNonce(wallet));
41
+ }
42
+ }
43
+ }
44
+ const allSigned = [];
45
+ const allDisperse = [];
46
+ const allProfit = [];
47
+ const rounds = [];
48
+ let buyerCursor = 0;
49
+ const buyerBatchSize = Math.max(1, buyersPerSell ?? buyerPrivateKeys.length);
50
+ const bribeAmount = config.bribeAmount && config.bribeAmount > 0 ? ethers.parseEther(String(config.bribeAmount)) : 0n;
51
+ const hasBribe = bribeAmount > 0n;
52
+ for (let i = 0; i < sellerPrivateKeys.length; i++) {
53
+ const sellerPk = sellerPrivateKeys[i];
54
+ const sellAmount = sellAmounts[i];
55
+ const sellerWallet = allSellerWallets[i];
56
+ const roundBuyerPks = [];
57
+ const roundBuyerWallets = [];
58
+ for (let k = 0; k < buyerBatchSize; k++) {
59
+ const idx = buyerCursor % buyerPrivateKeys.length;
60
+ roundBuyerPks.push(buyerPrivateKeys[idx]);
61
+ roundBuyerWallets.push(allBuyerWallets[idx]);
62
+ buyerCursor++;
63
+ }
64
+ const sellerNonce = addressToNonce.get(sellerWallet.address);
65
+ const roundBuyerNonces = roundBuyerWallets.map((w) => {
66
+ const nonce = addressToNonce.get(w.address);
67
+ addressToNonce.set(w.address, nonce + 1);
68
+ return nonce;
69
+ });
70
+ const ratio = 1 / roundBuyerPks.length;
71
+ const buyerRatios = roundBuyerPks.map(() => ratio);
72
+ const startNonces = [sellerNonce, ...roundBuyerNonces];
73
+ // 预先计算卖方 nonce 消耗
74
+ let sellerNonceConsumed = 0;
75
+ if (hasBribe)
76
+ sellerNonceConsumed += 1;
77
+ sellerNonceConsumed += 1; // 卖出
78
+ sellerNonceConsumed += roundBuyerPks.length; // 转账
79
+ sellerNonceConsumed += 1; // 利润
80
+ const res = await xlayerQuickBatchSwapMerkle({
81
+ sellerPrivateKey: sellerPk,
82
+ sellAmount,
83
+ buyerPrivateKeys: roundBuyerPks,
84
+ buyerRatios,
85
+ tokenAddress,
86
+ routeParams,
87
+ config,
88
+ quoteToken,
89
+ quoteTokenDecimals,
90
+ disperseHopCount,
91
+ startNonces,
92
+ });
93
+ addressToNonce.set(sellerWallet.address, sellerNonce + sellerNonceConsumed);
94
+ allSigned.push(...res.signedTransactions);
95
+ if (res.disperseHopWallets)
96
+ allDisperse.push(...res.disperseHopWallets);
97
+ if (res.profitHopWallets)
98
+ allProfit.push(...res.profitHopWallets);
99
+ rounds.push({
100
+ sellerAddress: res.metadata?.sellerAddress || '',
101
+ buyerAddresses: res.metadata?.buyerAddresses || [],
102
+ sellAmount,
103
+ bundleHash: undefined,
104
+ });
105
+ }
106
+ nonceManager.clearTemp();
107
+ return {
108
+ signedTransactions: allSigned,
109
+ rounds,
110
+ disperseHopWallets: allDisperse.length > 0 ? allDisperse : undefined,
111
+ profitHopWallets: allProfit.length > 0 ? allProfit : undefined,
112
+ };
113
+ }