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
+ /**
2
+ * XLayer SDK — EOA/交易参数与结果类型
3
+ *
4
+ * 包含买入/卖出/换手/刷量/DEX 交易/预授权/买到毕业等交易参数与结果类型
5
+ */
6
+ export {};
@@ -9,6 +9,14 @@
9
9
  * - 与普通买卖使用相同的代码路径
10
10
  *
11
11
  * 支持池子类型:V2, V3
12
+ *
13
+ * 跨层依赖说明(chains → domains/dex):
14
+ * - 依赖 `../../../domains/dex/direct-router.js`(directV2BatchBuy / directV2BatchSell /
15
+ * directV3BatchBuy / directV3BatchSell)与 `../../../domains/dex/types.js`
16
+ * (DirectRouterSignConfig)。
17
+ * - 原因:EOA 刷量的本质是「直接调用 DEX Router 做批量买卖」,其路由识别、报价、签名、
18
+ * 利润刮取全部复用 DEX 层 direct-router 的实现,属于真实业务依赖(非纯函数/常量),
19
+ * 不宜抽到 core 或 chains 内部,否则会复制一份 DEX 路由逻辑导致双实现漂移。
12
20
  */
13
21
  import { Wallet } from 'ethers';
14
22
  import type { DirectRouterSignConfig } from '../../../domains/dex/types.js';
@@ -9,6 +9,14 @@
9
9
  * - 与普通买卖使用相同的代码路径
10
10
  *
11
11
  * 支持池子类型:V2, V3
12
+ *
13
+ * 跨层依赖说明(chains → domains/dex):
14
+ * - 依赖 `../../../domains/dex/direct-router.js`(directV2BatchBuy / directV2BatchSell /
15
+ * directV3BatchBuy / directV3BatchSell)与 `../../../domains/dex/types.js`
16
+ * (DirectRouterSignConfig)。
17
+ * - 原因:EOA 刷量的本质是「直接调用 DEX Router 做批量买卖」,其路由识别、报价、签名、
18
+ * 利润刮取全部复用 DEX 层 direct-router 的实现,属于真实业务依赖(非纯函数/常量),
19
+ * 不宜抽到 core 或 chains 内部,否则会复制一份 DEX 路由逻辑导致双实现漂移。
12
20
  */
13
21
  import { ethers, Wallet, Contract } from 'ethers';
14
22
  import { createXLayerProvider } from '../../../utils/provider-factory.js';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * XLayer Portal 操作 — 格式化 / 工具函数(format)
3
+ */
4
+ /**
5
+ * 计算带滑点的最小输出
6
+ *
7
+ * @param expectedOutput 预期输出
8
+ * @param slippageBps 滑点基点(如 100 = 1%)
9
+ */
10
+ export declare function applySlippage(expectedOutput: bigint, slippageBps: number): bigint;
11
+ /**
12
+ * 将 Portal 的 lpFeeProfile 转换为 V3 Router 所需的 fee (100万分比)
13
+ *
14
+ * STANDARD = 0.25% (2500)
15
+ * LOW = 0.01% (100)
16
+ * HIGH = 1% (10000)
17
+ */
18
+ export declare function lpFeeProfileToV3Fee(profile: number): number;
19
+ /**
20
+ * 格式化 OKB 金额(wei -> OKB 字符串)
21
+ */
22
+ export declare function formatOkb(wei: bigint): string;
23
+ /**
24
+ * 解析 OKB 金额(OKB 字符串 -> wei)
25
+ */
26
+ export declare function parseOkb(okb: string): bigint;
27
+ /**
28
+ * 格式化代币金额(考虑精度)
29
+ */
30
+ export declare function formatTokenAmount(amount: bigint, decimals?: number): string;
31
+ /**
32
+ * 解析代币金额(考虑精度)
33
+ */
34
+ export declare function parseTokenAmount(amount: string, decimals?: number): bigint;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * XLayer Portal 操作 — 格式化 / 工具函数(format)
3
+ */
4
+ import { ethers } from 'ethers';
5
+ /**
6
+ * 计算带滑点的最小输出
7
+ *
8
+ * @param expectedOutput 预期输出
9
+ * @param slippageBps 滑点基点(如 100 = 1%)
10
+ */
11
+ export function applySlippage(expectedOutput, slippageBps) {
12
+ const keep = BigInt(10000 - Math.max(0, Math.min(5000, slippageBps)));
13
+ return (expectedOutput * keep) / 10000n;
14
+ }
15
+ /**
16
+ * 将 Portal 的 lpFeeProfile 转换为 V3 Router 所需的 fee (100万分比)
17
+ *
18
+ * STANDARD = 0.25% (2500)
19
+ * LOW = 0.01% (100)
20
+ * HIGH = 1% (10000)
21
+ */
22
+ export function lpFeeProfileToV3Fee(profile) {
23
+ switch (profile) {
24
+ case 1:
25
+ return 100; // 0.01%
26
+ case 2:
27
+ return 10000; // 1%
28
+ case 0:
29
+ default:
30
+ return 2500; // 0.25%
31
+ }
32
+ }
33
+ /**
34
+ * 格式化 OKB 金额(wei -> OKB 字符串)
35
+ */
36
+ export function formatOkb(wei) {
37
+ return ethers.formatEther(wei);
38
+ }
39
+ /**
40
+ * 解析 OKB 金额(OKB 字符串 -> wei)
41
+ */
42
+ export function parseOkb(okb) {
43
+ return ethers.parseEther(okb);
44
+ }
45
+ /**
46
+ * 格式化代币金额(考虑精度)
47
+ */
48
+ export function formatTokenAmount(amount, decimals = 18) {
49
+ return ethers.formatUnits(amount, decimals);
50
+ }
51
+ /**
52
+ * 解析代币金额(考虑精度)
53
+ */
54
+ export function parseTokenAmount(amount, decimals = 18) {
55
+ return ethers.parseUnits(amount, decimals);
56
+ }
@@ -0,0 +1,4 @@
1
+ import { Wallet, JsonRpcProvider } from 'ethers';
2
+ import { type DisperseHopPath } from './eoa-bundle-swap-types.js';
3
+ export declare function generateDisperseHopPaths(targetAddresses: string[], hopCount: number, provider: JsonRpcProvider): DisperseHopPath[];
4
+ export declare function buildNativeHopChain(payer: Wallet, path: DisperseHopPath, finalAmount: bigint, gasPrice: bigint, txType: 0 | 2, payerNonce: number): Promise<string[]>;
@@ -0,0 +1,87 @@
1
+ import { Wallet } from 'ethers';
2
+ import { generateWallets } from '../../../utils/wallet.js';
3
+ import { NATIVE_TRANSFER_GAS_LIMIT, XLAYER_CHAIN_ID } from './eoa-bundle-swap-types.js';
4
+ // ==================== 多跳转账辅助函数 ====================
5
+ export function generateDisperseHopPaths(targetAddresses, hopCount, provider) {
6
+ if (hopCount <= 0) {
7
+ return targetAddresses.map((addr) => ({
8
+ targetAddress: addr,
9
+ hopWallets: [],
10
+ hopWalletsInfo: [],
11
+ }));
12
+ }
13
+ return targetAddresses.map((targetAddress) => {
14
+ const hopWalletsInfo = generateWallets(hopCount);
15
+ const hopWallets = hopWalletsInfo.map((w) => new Wallet(w.privateKey, provider));
16
+ return { targetAddress, hopWallets, hopWalletsInfo };
17
+ });
18
+ }
19
+ export async function buildNativeHopChain(payer, path, finalAmount, gasPrice, txType, payerNonce) {
20
+ const signedTxs = [];
21
+ const hopCount = path.hopWallets.length;
22
+ if (hopCount === 0) {
23
+ const tx = {
24
+ to: path.targetAddress,
25
+ value: finalAmount,
26
+ nonce: payerNonce,
27
+ gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
28
+ chainId: XLAYER_CHAIN_ID,
29
+ type: txType,
30
+ };
31
+ if (txType === 2) {
32
+ tx.maxFeePerGas = gasPrice;
33
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
34
+ }
35
+ else {
36
+ tx.gasPrice = gasPrice;
37
+ }
38
+ signedTxs.push(await payer.signTransaction(tx));
39
+ return signedTxs;
40
+ }
41
+ const hopGasCost = NATIVE_TRANSFER_GAS_LIMIT * gasPrice;
42
+ const amountsPerHop = [];
43
+ for (let i = 0; i < hopCount; i++) {
44
+ const remainingHops = hopCount - i;
45
+ amountsPerHop.push(finalAmount + hopGasCost * BigInt(remainingHops));
46
+ }
47
+ // payer → hop1
48
+ const firstTx = {
49
+ to: path.hopWallets[0].address,
50
+ value: amountsPerHop[0],
51
+ nonce: payerNonce,
52
+ gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
53
+ chainId: XLAYER_CHAIN_ID,
54
+ type: txType,
55
+ };
56
+ if (txType === 2) {
57
+ firstTx.maxFeePerGas = gasPrice;
58
+ firstTx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
59
+ }
60
+ else {
61
+ firstTx.gasPrice = gasPrice;
62
+ }
63
+ signedTxs.push(await payer.signTransaction(firstTx));
64
+ // hop1 → hop2 → ... → target
65
+ for (let i = 0; i < hopCount; i++) {
66
+ const fromWallet = path.hopWallets[i];
67
+ const toAddress = i === hopCount - 1 ? path.targetAddress : path.hopWallets[i + 1].address;
68
+ const amount = i === hopCount - 1 ? finalAmount : amountsPerHop[i + 1];
69
+ const tx = {
70
+ to: toAddress,
71
+ value: amount,
72
+ nonce: 0,
73
+ gasLimit: NATIVE_TRANSFER_GAS_LIMIT,
74
+ chainId: XLAYER_CHAIN_ID,
75
+ type: txType,
76
+ };
77
+ if (txType === 2) {
78
+ tx.maxFeePerGas = gasPrice;
79
+ tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
80
+ }
81
+ else {
82
+ tx.gasPrice = gasPrice;
83
+ }
84
+ signedTxs.push(await fromWallet.signTransaction(tx));
85
+ }
86
+ return signedTxs;
87
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * XLayer SDK — AA Nonce(EntryPoint nonce)本地分配器
3
+ */
4
+ /**
5
+ * ✅ 仅用于 ERC-4337 AA(EntryPoint.getNonce(sender, 0))
6
+ *
7
+ * 目标:不要在业务代码里手写 `+1/+2` 推导,而是像 BSC bundle 一样用本地 Map
8
+ * 对“同一 sender 多步流程”连续分配 nonce。
9
+ *
10
+ * 注意:
11
+ * - 这是**同一次 SDK 调用/同一条流程**内的 nonce 分配;不解决多进程/多并发任务同时使用同一 sender 的问题。
12
+ * - 对“可能不生成 op”的分支(例如 withdraw 返回 null),使用 peek + commit,避免提前消耗 nonce。
13
+ */
14
+ export declare class AANonceMap {
15
+ private nextBySenderLower;
16
+ init(sender: string, startNonce: bigint): void;
17
+ peek(sender: string): bigint;
18
+ commit(sender: string, usedNonce: bigint): void;
19
+ next(sender: string): bigint;
20
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * XLayer SDK — AA Nonce(EntryPoint nonce)本地分配器
3
+ */
4
+ // ==================== AA Nonce(EntryPoint nonce)本地分配器 ====================
5
+ /**
6
+ * ✅ 仅用于 ERC-4337 AA(EntryPoint.getNonce(sender, 0))
7
+ *
8
+ * 目标:不要在业务代码里手写 `+1/+2` 推导,而是像 BSC bundle 一样用本地 Map
9
+ * 对“同一 sender 多步流程”连续分配 nonce。
10
+ *
11
+ * 注意:
12
+ * - 这是**同一次 SDK 调用/同一条流程**内的 nonce 分配;不解决多进程/多并发任务同时使用同一 sender 的问题。
13
+ * - 对“可能不生成 op”的分支(例如 withdraw 返回 null),使用 peek + commit,避免提前消耗 nonce。
14
+ */
15
+ export class AANonceMap {
16
+ nextBySenderLower = new Map();
17
+ init(sender, startNonce) {
18
+ const k = sender.toLowerCase();
19
+ const cur = this.nextBySenderLower.get(k);
20
+ if (cur === undefined || startNonce > cur) {
21
+ this.nextBySenderLower.set(k, startNonce);
22
+ }
23
+ }
24
+ peek(sender) {
25
+ const k = sender.toLowerCase();
26
+ const cur = this.nextBySenderLower.get(k);
27
+ if (cur === undefined) {
28
+ throw new Error(`AANonceMap: sender not initialized: ${sender}`);
29
+ }
30
+ return cur;
31
+ }
32
+ commit(sender, usedNonce) {
33
+ const k = sender.toLowerCase();
34
+ const cur = this.nextBySenderLower.get(k);
35
+ if (cur === undefined) {
36
+ throw new Error(`AANonceMap: sender not initialized: ${sender}`);
37
+ }
38
+ // 只允许“使用当前 nonce”或“重复 commit”(幂等)
39
+ if (usedNonce !== cur && usedNonce !== cur - 1n) {
40
+ throw new Error(`AANonceMap: nonce mismatch for ${sender}: used=${usedNonce.toString()} cur=${cur.toString()}`);
41
+ }
42
+ if (usedNonce === cur) {
43
+ this.nextBySenderLower.set(k, cur + 1n);
44
+ }
45
+ }
46
+ next(sender) {
47
+ const n = this.peek(sender);
48
+ this.commit(sender, n);
49
+ return n;
50
+ }
51
+ }
@@ -1,296 +1,13 @@
1
1
  /**
2
- * XLayer Portal 操作核心
2
+ * XLayer Portal 操作核心 barrel
3
3
  *
4
- * Flap Portal 内盘交易的核心逻辑:
5
- * - 买入(swapExactInput: native -> token)
6
- * - 卖出(swapExactInput: token -> native)
7
- * - 授权(approve)
8
- * - 代币转账
9
- */
10
- import { JsonRpcProvider } from 'ethers';
11
- /**
12
- * 编码买入调用(swapExactInput: native -> token)
13
- *
14
- * @param tokenAddress 目标代币地址
15
- * @param inputAmount 输入 OKB 数量(wei)
16
- * @param minOutputAmount 最小输出代币数量(默认 0)
17
- */
18
- export declare function encodeBuyCall(tokenAddress: string, inputAmount: bigint, minOutputAmount?: bigint): string;
19
- /**
20
- * 编码买入调用 V3(swapExactInputV3: native -> token,支持 extensionData)
21
- *
22
- * 与 BSC 版本的 create-to-dex.ts 保持一致:
23
- * - 统一优先使用 swapExactInputV3(支持 extensionData;无扩展时传 0x 即可)
24
- * - 这里的 V3 指"交易接口版本(扩展支持)",不是"外盘 V3 池子"
25
- *
26
- * @param tokenAddress 目标代币地址
27
- * @param inputAmount 输入 OKB 数量(wei)
28
- * @param minOutputAmount 最小输出代币数量(默认 0)
29
- * @param extensionData 扩展数据(默认 0x)
30
- */
31
- export declare function encodeBuyCallV3(tokenAddress: string, inputAmount: bigint, minOutputAmount?: bigint, extensionData?: string): string;
32
- /**
33
- * 编码卖出调用(swapExactInput: token -> native)
34
- *
35
- * @param tokenAddress 目标代币地址
36
- * @param inputAmount 输入代币数量
37
- * @param minOutputAmount 最小输出 OKB 数量(默认 0)
38
- */
39
- export declare function encodeSellCall(tokenAddress: string, inputAmount: bigint, minOutputAmount?: bigint): string;
40
- /**
41
- * ✅ 编码卖出调用(支持 ERC20 输出):swapExactInput: token -> quoteToken
42
- *
43
- * @param tokenAddress 输入代币地址
44
- * @param quoteToken 输出代币地址(如 USDT/USDC)
45
- * @param inputAmount 输入代币数量
46
- * @param minOutputAmount 最小输出数量(默认 0)
47
- */
48
- export declare function encodeSellCallWithQuote(tokenAddress: string, quoteToken: string, inputAmount: bigint, minOutputAmount?: bigint): string;
49
- /**
50
- * ✅ 编码买入调用(支持 ERC20 输入):swapExactInput: quoteToken -> token
51
- *
52
- * @param tokenAddress 输出代币地址
53
- * @param quoteToken 输入代币地址(如 USDT/USDC)
54
- * @param inputAmount 输入数量
55
- * @param minOutputAmount 最小输出代币数量(默认 0)
56
- */
57
- export declare function encodeBuyCallWithQuote(tokenAddress: string, quoteToken: string, inputAmount: bigint, minOutputAmount?: bigint): string;
58
- /**
59
- * 编码授权调用
60
- *
61
- * @param spender 授权对象地址
62
- * @param amount 授权数量(默认无限)
63
- */
64
- export declare function encodeApproveCall(spender: string, amount?: bigint): string;
65
- /**
66
- * 编码代币转账调用
67
- *
68
- * @param to 接收地址
69
- * @param amount 转账数量
70
- */
71
- export declare function encodeTransferCall(to: string, amount: bigint): string;
72
- /**
73
- * 编码创建代币调用 V2
74
- */
75
- export declare function encodeCreateCallV2(params: {
76
- name: string;
77
- symbol: string;
78
- meta: string;
79
- dexThresh: number;
80
- salt: string;
81
- taxRate: number;
82
- migratorType: number;
83
- quoteToken: string;
84
- quoteAmt: bigint;
85
- beneficiary: string;
86
- permitData: string;
87
- }): string;
88
- /**
89
- * 编码创建代币调用 V3
90
- */
91
- export declare function encodeCreateCallV3(params: {
92
- name: string;
93
- symbol: string;
94
- meta: string;
95
- dexThresh: number;
96
- salt: string;
97
- taxRate: number;
98
- migratorType: number;
99
- quoteToken: string;
100
- quoteAmt: bigint;
101
- beneficiary: string;
102
- permitData: string;
103
- extensionID: string;
104
- extensionData: string;
105
- }): string;
106
- /**
107
- * 编码创建代币调用 V4
108
- */
109
- export declare function encodeCreateCallV4(params: {
110
- name: string;
111
- symbol: string;
112
- meta: string;
113
- dexThresh: number;
114
- salt: string;
115
- taxRate: number;
116
- migratorType: number;
117
- quoteToken: string;
118
- quoteAmt: bigint;
119
- beneficiary: string;
120
- permitData: string;
121
- extensionID: string;
122
- extensionData: string;
123
- dexId: number;
124
- lpFeeProfile: number;
125
- }): string;
126
- /**
127
- * 编码创建代币调用 V5(Tax Token V2 高级税收分配)
128
- */
129
- export declare function encodeCreateCallV5(params: {
130
- name: string;
131
- symbol: string;
132
- meta: string;
133
- dexThresh: number;
134
- salt: string;
135
- taxRate: number;
136
- migratorType: number;
137
- quoteToken: string;
138
- quoteAmt: bigint;
139
- beneficiary: string;
140
- permitData: string;
141
- extensionID: string;
142
- extensionData: string;
143
- dexId: number;
144
- lpFeeProfile: number;
145
- taxDuration: bigint;
146
- antiFarmerDuration: bigint;
147
- mktBps: number;
148
- deflationBps: number;
149
- dividendBps: number;
150
- lpBps: number;
151
- minimumShareBalance: bigint;
152
- }): string;
153
- export interface PortalQueryConfig {
154
- rpcUrl?: string;
155
- chainId?: number;
156
- portalAddress?: string;
157
- }
158
- /**
159
- * Portal 查询器
160
- *
161
- * 提供只读查询方法:
162
- * - 代币余额
163
- * - 授权额度
164
- * - 预览买入/卖出
165
- * - 代币状态
166
- */
167
- export declare class PortalQuery {
168
- private provider;
169
- private portal;
170
- private portalAddress;
171
- constructor(config?: PortalQueryConfig);
172
- private multicallAggregate3;
173
- /**
174
- * 获取 Provider
175
- */
176
- getProvider(): JsonRpcProvider;
177
- /**
178
- * 获取 Portal 地址
179
- */
180
- getPortalAddress(): string;
181
- /**
182
- * 获取代币余额
183
- */
184
- getTokenBalance(tokenAddress: string, account: string): Promise<bigint>;
185
- /**
186
- * 获取 OKB 余额
187
- */
188
- getOkbBalance(account: string): Promise<bigint>;
189
- /**
190
- * 获取授权额度
191
- */
192
- getAllowance(tokenAddress: string, owner: string, spender?: string): Promise<bigint>;
193
- /**
194
- * 检查是否需要授权
195
- */
196
- needsApproval(tokenAddress: string, owner: string, amount: bigint, spender?: string): Promise<boolean>;
197
- /**
198
- * 预览买入输出
199
- */
200
- previewBuy(tokenAddress: string, okbAmount: bigint): Promise<bigint>;
201
- /**
202
- * 预览卖出输出
203
- */
204
- previewSell(tokenAddress: string, tokenAmount: bigint): Promise<bigint>;
205
- /**
206
- * 使用 quoteExactInput 查询报价
207
- */
208
- quoteExactInput(inputToken: string, outputToken: string, inputAmount: bigint): Promise<bigint>;
209
- /**
210
- * 获取代币状态 V5
211
- */
212
- getTokenV5(tokenAddress: string): Promise<{
213
- status: number;
214
- reserve: bigint;
215
- circulatingSupply: bigint;
216
- price: bigint;
217
- tokenVersion: number;
218
- r: bigint;
219
- h: bigint;
220
- k: bigint;
221
- dexSupplyThresh: bigint;
222
- quoteTokenAddress: string;
223
- nativeToQuoteSwapEnabled: boolean;
224
- extensionID: string;
225
- }>;
226
- /**
227
- * 获取代币状态 V7 (包含 lpFeeProfile)
228
- *
229
- * ✅ 修复:与 BSC portal.ts 对齐,使用 16 字段结构
230
- */
231
- getTokenV7(tokenAddress: string): Promise<{
232
- status: number;
233
- reserve: bigint;
234
- circulatingSupply: bigint;
235
- price: bigint;
236
- tokenVersion: number;
237
- r: bigint;
238
- h: bigint;
239
- k: bigint;
240
- dexSupplyThresh: bigint;
241
- quoteTokenAddress: string;
242
- nativeToQuoteSwapEnabled: boolean;
243
- extensionID: string;
244
- taxRate: number;
245
- pool: string;
246
- progress: bigint;
247
- lpFeeProfile: number;
248
- }>;
249
- /**
250
- * 批量获取多个账户的代币余额
251
- */
252
- getMultipleTokenBalances(tokenAddress: string, accounts: string[]): Promise<Map<string, bigint>>;
253
- /**
254
- * 批量获取多个账户的 OKB 余额
255
- */
256
- getMultipleOkbBalances(accounts: string[]): Promise<Map<string, bigint>>;
257
- /**
258
- * 批量获取授权额度
259
- */
260
- getMultipleAllowances(tokenAddress: string, owners: string[], spender?: string): Promise<Map<string, bigint>>;
261
- }
262
- /**
263
- * 计算带滑点的最小输出
264
- *
265
- * @param expectedOutput 预期输出
266
- * @param slippageBps 滑点基点(如 100 = 1%)
267
- */
268
- export declare function applySlippage(expectedOutput: bigint, slippageBps: number): bigint;
269
- /**
270
- * 将 Portal 的 lpFeeProfile 转换为 V3 Router 所需的 fee (100万分比)
4
+ * 原超长文件按职责拆分为:
5
+ * - encoders.ts:Portal 操作编码器(买入/卖出/授权/转账/创建代币)
6
+ * - query.ts:PortalQuery 查询器 + createPortalQuery
7
+ * - format.ts:格式化 / 工具函数(applySlippage / lpFeeProfileToV3Fee / format / parse)
271
8
  *
272
- * STANDARD = 0.25% (2500)
273
- * LOW = 0.01% (100)
274
- * HIGH = 1% (10000)
275
- */
276
- export declare function lpFeeProfileToV3Fee(profile: number): number;
277
- /**
278
- * 创建 Portal 查询器
279
- */
280
- export declare function createPortalQuery(config?: PortalQueryConfig): PortalQuery;
281
- /**
282
- * 格式化 OKB 金额(wei -> OKB 字符串)
283
- */
284
- export declare function formatOkb(wei: bigint): string;
285
- /**
286
- * 解析 OKB 金额(OKB 字符串 -> wei)
287
- */
288
- export declare function parseOkb(okb: string): bigint;
289
- /**
290
- * 格式化代币金额(考虑精度)
291
- */
292
- export declare function formatTokenAmount(amount: bigint, decimals?: number): string;
293
- /**
294
- * 解析代币金额(考虑精度)
9
+ * 对外 export 符号与路径保持不变。
295
10
  */
296
- export declare function parseTokenAmount(amount: string, decimals?: number): bigint;
11
+ export { encodeBuyCall, encodeBuyCallV3, encodeSellCall, encodeSellCallWithQuote, encodeBuyCallWithQuote, encodeApproveCall, encodeTransferCall, encodeCreateCallV2, encodeCreateCallV3, encodeCreateCallV4, encodeCreateCallV5, } from './encoders.js';
12
+ export { PortalQuery, createPortalQuery, type PortalQueryConfig } from './query.js';
13
+ export { applySlippage, lpFeeProfileToV3Fee, formatOkb, parseOkb, formatTokenAmount, parseTokenAmount, } from './format.js';