four-flap-meme-sdk 3.0.1 → 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 (442) 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/pancake/bundle-buy-first-build.d.ts +25 -0
  97. package/dist/chains/bsc/pancake/bundle-buy-first-build.js +177 -0
  98. package/dist/chains/bsc/pancake/bundle-buy-first-constants.d.ts +30 -0
  99. package/dist/chains/bsc/pancake/bundle-buy-first-constants.js +24 -0
  100. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +11 -149
  101. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +12 -74
  102. package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.d.ts +9 -0
  103. package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.js +225 -0
  104. package/dist/chains/bsc/pancake/bundle-buy-first-plan.d.ts +14 -0
  105. package/dist/chains/bsc/pancake/bundle-buy-first-plan.js +64 -0
  106. package/dist/chains/bsc/pancake/bundle-buy-first-profit.d.ts +12 -0
  107. package/dist/chains/bsc/pancake/bundle-buy-first-profit.js +22 -0
  108. package/dist/chains/bsc/pancake/bundle-buy-first-quote.d.ts +15 -0
  109. package/dist/chains/bsc/pancake/bundle-buy-first-quote.js +122 -0
  110. package/dist/chains/bsc/pancake/bundle-buy-first-types.d.ts +179 -0
  111. package/dist/chains/bsc/pancake/bundle-buy-first-types.js +1 -0
  112. package/dist/chains/bsc/pancake/bundle-buy-first-validate.d.ts +2 -0
  113. package/dist/chains/bsc/pancake/bundle-buy-first-validate.js +41 -0
  114. package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +1 -1
  115. package/dist/chains/bsc/pancake/bundle-buy-first.js +8 -578
  116. package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +11 -239
  117. package/dist/chains/bsc/pancake/bundle-swap-helpers.js +12 -564
  118. package/dist/chains/bsc/pancake/bundle-swap-types.d.ts +183 -0
  119. package/dist/chains/bsc/pancake/bundle-swap-types.js +17 -0
  120. package/dist/chains/bsc/pancake/bundle-swap.d.ts +10 -132
  121. package/dist/chains/bsc/pancake/bundle-swap.js +12 -1003
  122. package/dist/chains/bsc/pancake/hop-chain.d.ts +18 -0
  123. package/dist/chains/bsc/pancake/hop-chain.js +227 -0
  124. package/dist/chains/bsc/pancake/quote.d.ts +14 -0
  125. package/dist/chains/bsc/pancake/quote.js +84 -0
  126. package/dist/chains/bsc/pancake/swap-batch.d.ts +42 -0
  127. package/dist/chains/bsc/pancake/swap-batch.js +283 -0
  128. package/dist/chains/bsc/pancake/swap-build.d.ts +19 -0
  129. package/dist/chains/bsc/pancake/swap-build.js +226 -0
  130. package/dist/chains/bsc/pancake/swap-cross.d.ts +42 -0
  131. package/dist/chains/bsc/pancake/swap-cross.js +140 -0
  132. package/dist/chains/bsc/pancake/swap-quick.d.ts +54 -0
  133. package/dist/chains/bsc/pancake/swap-quick.js +424 -0
  134. package/dist/chains/bsc/pancake/swap-single.d.ts +2 -0
  135. package/dist/chains/bsc/pancake/swap-single.js +182 -0
  136. package/dist/chains/bsc/platforms/four/index.d.ts +21 -3
  137. package/dist/chains/bsc/platforms/four/index.js +28 -3
  138. package/dist/chains/eni/batch-router/transfer-disperse.d.ts +37 -0
  139. package/dist/chains/eni/batch-router/transfer-disperse.js +302 -0
  140. package/dist/chains/eni/batch-router/transfer-shared.d.ts +9 -0
  141. package/dist/chains/eni/batch-router/transfer-shared.js +10 -0
  142. package/dist/chains/eni/batch-router/transfer-sweep.d.ts +51 -0
  143. package/dist/chains/eni/batch-router/transfer-sweep.js +364 -0
  144. package/dist/chains/eni/batch-router/transfer.d.ts +4 -74
  145. package/dist/chains/eni/batch-router/transfer.js +2 -647
  146. package/dist/chains/eni/platforms/daoaas/portal-direct-profit.d.ts +17 -0
  147. package/dist/chains/eni/platforms/daoaas/portal-direct-profit.js +30 -0
  148. package/dist/chains/eni/platforms/daoaas/portal-direct-submit.d.ts +12 -0
  149. package/dist/chains/eni/platforms/daoaas/portal-direct-submit.js +396 -0
  150. package/dist/chains/eni/platforms/daoaas/portal-direct-tx.d.ts +20 -0
  151. package/dist/chains/eni/platforms/daoaas/portal-direct-tx.js +165 -0
  152. package/dist/chains/eni/platforms/daoaas/portal-direct.d.ts +3 -32
  153. package/dist/chains/eni/platforms/daoaas/portal-direct.js +3 -571
  154. package/dist/chains/eni/submit.js +1 -1
  155. package/dist/chains/xlayer/constants.d.ts +0 -2
  156. package/dist/chains/xlayer/constants.js +0 -2
  157. package/dist/chains/xlayer/eip7702/auth.d.ts +16 -0
  158. package/dist/chains/xlayer/eip7702/auth.js +81 -0
  159. package/dist/chains/xlayer/eip7702/bundle-create-buy.d.ts +22 -0
  160. package/dist/chains/xlayer/eip7702/bundle-create-buy.js +201 -0
  161. package/dist/chains/xlayer/eip7702/bundle-create-helpers.d.ts +114 -0
  162. package/dist/chains/xlayer/eip7702/bundle-create-helpers.js +139 -0
  163. package/dist/chains/xlayer/eip7702/bundle-create-to-dex.d.ts +24 -0
  164. package/dist/chains/xlayer/eip7702/bundle-create-to-dex.js +233 -0
  165. package/dist/chains/xlayer/eip7702/bundle-create.d.ts +3 -35
  166. package/dist/chains/xlayer/eip7702/bundle-create.js +3 -746
  167. package/dist/chains/xlayer/eip7702/bundle-graduate-buy.d.ts +22 -0
  168. package/dist/chains/xlayer/eip7702/bundle-graduate-buy.js +214 -0
  169. package/dist/chains/xlayer/eip7702/bundle-sell.js +1 -1
  170. package/dist/chains/xlayer/eip7702/bundle-swap-batch.d.ts +31 -0
  171. package/dist/chains/xlayer/eip7702/bundle-swap-batch.js +216 -0
  172. package/dist/chains/xlayer/eip7702/bundle-swap-helpers.d.ts +21 -0
  173. package/dist/chains/xlayer/eip7702/bundle-swap-helpers.js +206 -0
  174. package/dist/chains/xlayer/eip7702/bundle-swap-multi.d.ts +33 -0
  175. package/dist/chains/xlayer/eip7702/bundle-swap-multi.js +146 -0
  176. package/dist/chains/xlayer/eip7702/bundle-swap-single.d.ts +31 -0
  177. package/dist/chains/xlayer/eip7702/bundle-swap-single.js +177 -0
  178. package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +6 -61
  179. package/dist/chains/xlayer/eip7702/bundle-swap.js +3 -712
  180. package/dist/chains/xlayer/eip7702/bytes.d.ts +4 -0
  181. package/dist/chains/xlayer/eip7702/bytes.js +31 -0
  182. package/dist/chains/xlayer/eip7702/gas.d.ts +19 -0
  183. package/dist/chains/xlayer/eip7702/gas.js +152 -0
  184. package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.d.ts +5 -0
  185. package/dist/chains/xlayer/eip7702/multi-hop-transfer-disperse.js +196 -0
  186. package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.d.ts +5 -0
  187. package/dist/chains/xlayer/eip7702/multi-hop-transfer-pairwise.js +188 -0
  188. package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.d.ts +5 -0
  189. package/dist/chains/xlayer/eip7702/multi-hop-transfer-sweep.js +220 -0
  190. package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +8 -4
  191. package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +5 -591
  192. package/dist/chains/xlayer/eip7702/profit.d.ts +32 -0
  193. package/dist/chains/xlayer/eip7702/profit.js +59 -0
  194. package/dist/chains/xlayer/eip7702/provider.d.ts +3 -0
  195. package/dist/chains/xlayer/eip7702/provider.js +17 -0
  196. package/dist/chains/xlayer/eip7702/time.d.ts +2 -0
  197. package/dist/chains/xlayer/eip7702/time.js +10 -0
  198. package/dist/chains/xlayer/eip7702/tx-build.d.ts +10 -0
  199. package/dist/chains/xlayer/eip7702/tx-build.js +128 -0
  200. package/dist/chains/xlayer/eip7702/utils.d.ts +19 -85
  201. package/dist/chains/xlayer/eip7702/utils.js +19 -484
  202. package/dist/chains/xlayer/eip7702/volume-bundle.d.ts +13 -0
  203. package/dist/chains/xlayer/eip7702/volume-bundle.js +250 -0
  204. package/dist/chains/xlayer/eip7702/volume-internal.d.ts +13 -0
  205. package/dist/chains/xlayer/eip7702/volume-internal.js +169 -0
  206. package/dist/chains/xlayer/eip7702/volume-make.d.ts +8 -0
  207. package/dist/chains/xlayer/eip7702/volume-make.js +38 -0
  208. package/dist/chains/xlayer/eip7702/volume-single-round.d.ts +17 -0
  209. package/dist/chains/xlayer/eip7702/volume-single-round.js +44 -0
  210. package/dist/chains/xlayer/eip7702/volume-swap.d.ts +18 -0
  211. package/dist/chains/xlayer/eip7702/volume-swap.js +30 -0
  212. package/dist/chains/xlayer/eip7702/volume-wash.d.ts +8 -0
  213. package/dist/chains/xlayer/eip7702/volume-wash.js +191 -0
  214. package/dist/chains/xlayer/eip7702/volume.d.ts +7 -35
  215. package/dist/chains/xlayer/eip7702/volume.js +5 -697
  216. package/dist/chains/xlayer/eip7702/wallet.d.ts +6 -0
  217. package/dist/chains/xlayer/eip7702/wallet.js +17 -0
  218. package/dist/chains/xlayer/eoa/aa-types.d.ts +176 -0
  219. package/dist/chains/xlayer/eoa/aa-types.js +6 -0
  220. package/dist/chains/xlayer/eoa/constants.d.ts +0 -2
  221. package/dist/chains/xlayer/eoa/constants.js +0 -2
  222. package/dist/chains/xlayer/eoa/context.d.ts +8 -0
  223. package/dist/chains/xlayer/eoa/context.js +23 -0
  224. package/dist/chains/xlayer/eoa/encoders.d.ts +147 -0
  225. package/dist/chains/xlayer/eoa/encoders.js +147 -0
  226. package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.d.ts +5 -0
  227. package/dist/chains/xlayer/eoa/eoa-bundle-swap-cross.js +113 -0
  228. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +10 -123
  229. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +10 -225
  230. package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.d.ts +50 -0
  231. package/dist/chains/xlayer/eoa/eoa-bundle-swap-pure.js +170 -0
  232. package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.d.ts +5 -0
  233. package/dist/chains/xlayer/eoa/eoa-bundle-swap-quick.js +257 -0
  234. package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.d.ts +99 -0
  235. package/dist/chains/xlayer/eoa/eoa-bundle-swap-types.js +11 -0
  236. package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +5 -47
  237. package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +3 -522
  238. package/dist/chains/xlayer/eoa/eoa-types.d.ts +776 -0
  239. package/dist/chains/xlayer/eoa/eoa-types.js +6 -0
  240. package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +8 -0
  241. package/dist/chains/xlayer/eoa/eoa-wash-volume.js +8 -0
  242. package/dist/chains/xlayer/eoa/format.d.ts +34 -0
  243. package/dist/chains/xlayer/eoa/format.js +56 -0
  244. package/dist/chains/xlayer/eoa/hop-chain.d.ts +4 -0
  245. package/dist/chains/xlayer/eoa/hop-chain.js +87 -0
  246. package/dist/chains/xlayer/eoa/nonce-map.d.ts +20 -0
  247. package/dist/chains/xlayer/eoa/nonce-map.js +51 -0
  248. package/dist/chains/xlayer/eoa/portal-ops.d.ts +9 -292
  249. package/dist/chains/xlayer/eoa/portal-ops.js +9 -486
  250. package/dist/chains/xlayer/eoa/query.d.ts +117 -0
  251. package/dist/chains/xlayer/eoa/query.js +285 -0
  252. package/dist/chains/xlayer/eoa/quote.d.ts +6 -0
  253. package/dist/chains/xlayer/eoa/quote.js +90 -0
  254. package/dist/chains/xlayer/eoa/types.d.ts +9 -959
  255. package/dist/chains/xlayer/eoa/types.js +9 -49
  256. package/dist/core/clients/blockrazor.js +1 -1
  257. package/dist/core/clients/merkle.js +1 -1
  258. package/dist/core/erc20/allowances.d.ts +104 -0
  259. package/dist/core/erc20/allowances.js +205 -0
  260. package/dist/core/erc20/approve.d.ts +141 -0
  261. package/dist/core/erc20/approve.js +325 -0
  262. package/dist/core/erc20/helpers.d.ts +20 -0
  263. package/dist/core/erc20/helpers.js +109 -0
  264. package/dist/core/erc20/index.d.ts +13 -0
  265. package/dist/core/erc20/index.js +12 -0
  266. package/dist/core/gas/bundle-gas.d.ts +6 -1
  267. package/dist/core/index.d.ts +1 -1
  268. package/dist/core/index.js +1 -1
  269. package/dist/core/quote/index.d.ts +1 -0
  270. package/dist/core/quote/index.js +1 -0
  271. package/dist/core/quote/quote-helpers.d.ts +78 -0
  272. package/dist/core/quote/quote-helpers.js +289 -0
  273. package/dist/core/quote/types.d.ts +1 -0
  274. package/dist/core/quote/types.js +1 -0
  275. package/dist/core/sign-context-helpers.d.ts +29 -0
  276. package/dist/core/sign-context-helpers.js +63 -0
  277. package/dist/domains/dex/direct-router-helpers.d.ts +16 -268
  278. package/dist/domains/dex/direct-router-helpers.js +16 -535
  279. package/dist/domains/dex/direct-router-types.d.ts +104 -0
  280. package/dist/domains/dex/direct-router-types.js +81 -0
  281. package/dist/domains/dex/direct-router-v2-buy.d.ts +2 -0
  282. package/dist/domains/dex/direct-router-v2-buy.js +249 -0
  283. package/dist/domains/dex/direct-router-v2-sell.d.ts +5 -0
  284. package/dist/domains/dex/direct-router-v2-sell.js +270 -0
  285. package/dist/domains/dex/direct-router-v2.d.ts +9 -0
  286. package/dist/domains/dex/direct-router-v2.js +9 -0
  287. package/dist/domains/dex/direct-router-v3.d.ts +17 -0
  288. package/dist/domains/dex/direct-router-v3.js +432 -0
  289. package/dist/domains/dex/direct-router.d.ts +11 -26
  290. package/dist/domains/dex/direct-router.js +10 -977
  291. package/dist/domains/dex/dyo-encode.d.ts +62 -0
  292. package/dist/domains/dex/dyo-encode.js +124 -0
  293. package/dist/domains/dex/profit.d.ts +24 -0
  294. package/dist/domains/dex/profit.js +86 -0
  295. package/dist/domains/dex/provider.d.ts +10 -0
  296. package/dist/domains/dex/provider.js +27 -0
  297. package/dist/domains/dex/quote.d.ts +7 -0
  298. package/dist/domains/dex/quote.js +52 -0
  299. package/dist/domains/dex/router.d.ts +56 -0
  300. package/dist/domains/dex/router.js +193 -0
  301. package/dist/domains/flap/portal-bundle/batch.d.ts +9 -0
  302. package/dist/domains/flap/portal-bundle/batch.js +193 -0
  303. package/dist/domains/flap/portal-bundle/create.d.ts +5 -0
  304. package/dist/domains/flap/portal-bundle/create.js +153 -0
  305. package/dist/domains/flap/portal-bundle/helpers.d.ts +32 -0
  306. package/dist/domains/flap/portal-bundle/helpers.js +50 -0
  307. package/dist/domains/flap/portal-bundle/index.d.ts +16 -0
  308. package/dist/domains/flap/portal-bundle/index.js +15 -0
  309. package/dist/domains/flap/portal-bundle/private.d.ts +5 -0
  310. package/dist/domains/flap/portal-bundle/private.js +198 -0
  311. package/dist/domains/flap/portal-bundle/types.d.ts +102 -0
  312. package/dist/domains/flap/portal-bundle/types.js +1 -0
  313. package/dist/domains/flap/portal-bundle-merkle/core-batch.d.ts +13 -0
  314. package/dist/domains/flap/portal-bundle-merkle/core-batch.js +376 -0
  315. package/dist/domains/flap/portal-bundle-merkle/core-helpers.d.ts +75 -7
  316. package/dist/domains/flap/portal-bundle-merkle/core-helpers.js +259 -20
  317. package/dist/domains/flap/portal-bundle-merkle/core.d.ts +2 -13
  318. package/dist/domains/flap/portal-bundle-merkle/core.js +12 -629
  319. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.d.ts +70 -0
  320. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/constants.js +90 -0
  321. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.d.ts +12 -0
  322. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/index.js +11 -0
  323. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.d.ts +15 -0
  324. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/main.js +432 -0
  325. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.d.ts +113 -0
  326. package/dist/domains/flap/portal-bundle-merkle/create-to-dex/types.js +4 -0
  327. package/dist/domains/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -127
  328. package/dist/domains/flap/portal-bundle-merkle/create-to-dex.js +4 -527
  329. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.d.ts +42 -0
  330. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/constants.js +81 -0
  331. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.d.ts +12 -0
  332. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/index.js +11 -0
  333. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.d.ts +15 -0
  334. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/main.js +339 -0
  335. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.d.ts +72 -0
  336. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex/types.js +4 -0
  337. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.d.ts +4 -85
  338. package/dist/domains/flap/portal-bundle-merkle/curve-to-dex.js +4 -425
  339. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.d.ts +12 -0
  340. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/approve.js +102 -0
  341. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.d.ts +5 -0
  342. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/buy.js +135 -0
  343. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.d.ts +52 -0
  344. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/helpers.js +267 -0
  345. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.d.ts +14 -0
  346. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/index.js +14 -0
  347. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.d.ts +5 -0
  348. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy/sell.js +195 -0
  349. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.d.ts +3 -24
  350. package/dist/domains/flap/portal-bundle-merkle/pancake-proxy.js +3 -700
  351. package/dist/domains/flap/portal-bundle-merkle/private/buy.d.ts +9 -0
  352. package/dist/domains/flap/portal-bundle-merkle/private/buy.js +188 -0
  353. package/dist/domains/flap/portal-bundle-merkle/private/helpers.d.ts +36 -0
  354. package/dist/domains/flap/portal-bundle-merkle/private/helpers.js +127 -0
  355. package/dist/domains/flap/portal-bundle-merkle/private/index.d.ts +12 -0
  356. package/dist/domains/flap/portal-bundle-merkle/private/index.js +12 -0
  357. package/dist/domains/flap/portal-bundle-merkle/private/sell.d.ts +9 -0
  358. package/dist/domains/flap/portal-bundle-merkle/private/sell.js +191 -0
  359. package/dist/domains/flap/portal-bundle-merkle/private.d.ts +5 -15
  360. package/dist/domains/flap/portal-bundle-merkle/private.js +5 -494
  361. package/dist/domains/flap/portal-bundle-merkle/swap-batch.js +3 -2
  362. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.d.ts +4 -0
  363. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-chain.js +43 -0
  364. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.d.ts +13 -0
  365. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-constants.js +21 -0
  366. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +11 -121
  367. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-helpers.js +11 -109
  368. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.d.ts +20 -0
  369. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.js +223 -0
  370. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.d.ts +32 -0
  371. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.js +66 -0
  372. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.d.ts +22 -0
  373. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-profit.js +22 -0
  374. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.d.ts +51 -0
  375. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.js +149 -0
  376. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.d.ts +87 -0
  377. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-types.js +1 -0
  378. package/dist/domains/flap/portal-bundle-merkle/swap-buy-first.js +5 -404
  379. package/dist/domains/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -1
  380. package/dist/domains/flap/portal-bundle-merkle/swap-helpers.js +0 -7
  381. package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +1 -1
  382. package/dist/domains/flap/portal-bundle-merkle/swap-quick-batch.js +3 -2
  383. package/dist/domains/flap/portal-bundle-merkle/swap-single.js +3 -2
  384. package/dist/domains/flap/portal-bundle-merkle/utils/disperse.d.ts +2 -0
  385. package/dist/domains/flap/portal-bundle-merkle/utils/disperse.js +275 -0
  386. package/dist/domains/flap/portal-bundle-merkle/utils/index.d.ts +11 -0
  387. package/dist/domains/flap/portal-bundle-merkle/utils/index.js +11 -0
  388. package/dist/domains/flap/portal-bundle-merkle/utils/sweep.d.ts +9 -0
  389. package/dist/domains/flap/portal-bundle-merkle/utils/sweep.js +570 -0
  390. package/dist/domains/flap/portal-bundle-merkle/utils.d.ts +5 -8
  391. package/dist/domains/flap/portal-bundle-merkle/utils.js +5 -841
  392. package/dist/domains/flap/portal-bundle.d.ts +5 -117
  393. package/dist/domains/flap/portal-bundle.js +5 -587
  394. package/dist/domains/flap/portal.d.ts +13 -404
  395. package/dist/domains/flap/portal.js +12 -619
  396. package/dist/domains/flap/reader.d.ts +51 -0
  397. package/dist/domains/flap/reader.js +275 -0
  398. package/dist/domains/flap/types.d.ts +246 -0
  399. package/dist/domains/flap/types.js +104 -0
  400. package/dist/domains/flap/vault/constants.d.ts +220 -0
  401. package/dist/domains/flap/vault/constants.js +173 -0
  402. package/dist/domains/flap/vault/encode.d.ts +39 -0
  403. package/dist/domains/flap/vault/encode.js +135 -0
  404. package/dist/domains/flap/vault/index.d.ts +15 -0
  405. package/dist/domains/flap/vault/index.js +14 -0
  406. package/dist/domains/flap/vault/query.d.ts +40 -0
  407. package/dist/domains/flap/vault/query.js +104 -0
  408. package/dist/domains/flap/vault/types.d.ts +147 -0
  409. package/dist/domains/flap/vault/types.js +29 -0
  410. package/dist/domains/flap/vault.d.ts +3 -413
  411. package/dist/domains/flap/vault.js +3 -467
  412. package/dist/domains/flap/writer.d.ts +124 -0
  413. package/dist/domains/flap/writer.js +255 -0
  414. package/dist/domains/four/contracts/tm-bundle-batch.d.ts +35 -0
  415. package/dist/domains/four/contracts/tm-bundle-batch.js +286 -0
  416. package/dist/domains/four/contracts/tm-bundle-create.d.ts +2 -0
  417. package/dist/domains/four/contracts/tm-bundle-create.js +304 -0
  418. package/dist/domains/four/contracts/tm-bundle-helpers.d.ts +2 -1
  419. package/dist/domains/four/contracts/tm-bundle-helpers.js +3 -0
  420. package/dist/domains/four/contracts/tm-bundle-private.d.ts +36 -0
  421. package/dist/domains/four/contracts/tm-bundle-private.js +164 -0
  422. package/dist/domains/four/contracts/tm-bundle.d.ts +10 -71
  423. package/dist/domains/four/contracts/tm-bundle.js +9 -738
  424. package/dist/domains/lp-inspect/inspect-helpers.d.ts +25 -0
  425. package/dist/domains/lp-inspect/inspect-helpers.js +343 -0
  426. package/dist/domains/lp-inspect/inspect.d.ts +8 -0
  427. package/dist/domains/lp-inspect/inspect.js +332 -0
  428. package/dist/domains/lp-inspect/lp-inspect.d.ts +9 -37
  429. package/dist/domains/lp-inspect/lp-inspect.js +9 -775
  430. package/dist/domains/lp-inspect/registry.d.ts +43 -0
  431. package/dist/domains/lp-inspect/registry.js +127 -0
  432. package/dist/domains/merkle/index.d.ts +1 -1
  433. package/dist/exports/root-bundle-and-tooling.d.ts +9 -1
  434. package/dist/exports/root-bundle-and-tooling.js +8 -1
  435. package/dist/exports/root-foundations.d.ts +1 -1
  436. package/dist/exports/root-foundations.js +1 -1
  437. package/dist/exports/root-swap-dex-and-xlayer.d.ts +4 -4
  438. package/dist/exports/root-swap-dex-and-xlayer.js +4 -4
  439. package/dist/index.d.ts +1 -1
  440. package/dist/index.js +1 -1
  441. package/dist/utils/swap-helpers.js +1 -1
  442. package/package.json +1 -85
@@ -0,0 +1,81 @@
1
+ import { ethers } from 'ethers';
2
+ import * as rlp from '@ethereumjs/rlp';
3
+ import { EIP7702_AUTH_PREFIX, XLAYER_CHAIN_ID } from './constants.js';
4
+ import { addressToBytes, bigintToBytes } from './bytes.js';
5
+ // ========================================
6
+ // EIP-7702 授权签名
7
+ // ========================================
8
+ export async function signAuthorization(wallet, delegateAddress, nonce, chainId = XLAYER_CHAIN_ID) {
9
+ const authData = [bigintToBytes(BigInt(chainId)), addressToBytes(delegateAddress), bigintToBytes(nonce)];
10
+ const rlpEncoded = rlp.encode(authData);
11
+ const toSign = new Uint8Array(1 + rlpEncoded.length);
12
+ toSign[0] = EIP7702_AUTH_PREFIX;
13
+ toSign.set(rlpEncoded, 1);
14
+ const msgHash = ethers.keccak256(toSign);
15
+ const signingKey = new ethers.SigningKey(wallet.privateKey);
16
+ const sig = signingKey.sign(msgHash);
17
+ return {
18
+ chainId: BigInt(chainId),
19
+ address: delegateAddress,
20
+ nonce: nonce,
21
+ yParity: sig.yParity,
22
+ r: ethers.getBytes(sig.r),
23
+ s: ethers.getBytes(sig.s),
24
+ };
25
+ }
26
+ export async function signAuthorizationWithNonce(wallet, delegateAddress, provider, isTransactionSender = false) {
27
+ let nonce = await provider.getTransactionCount(wallet.address, 'pending');
28
+ if (isTransactionSender) {
29
+ nonce += 1;
30
+ }
31
+ return signAuthorization(wallet, delegateAddress, BigInt(nonce));
32
+ }
33
+ /**
34
+ * 批量签署授权 - 并行获取 nonce,并行签名
35
+ */
36
+ export async function signAuthorizationsBatch(wallets, delegateAddress, provider, mainWalletIndex) {
37
+ // 并行获取所有钱包的 nonce
38
+ const nonces = await Promise.all(wallets.map((w) => provider.getTransactionCount(w.address, 'pending')));
39
+ // 并行签署所有授权(签名是同步 CPU 操作,但包装成 Promise 以保持一致性)
40
+ return Promise.all(wallets.map((wallet, i) => {
41
+ const isMainWallet = mainWalletIndex !== undefined && i === mainWalletIndex;
42
+ const nonce = isMainWallet ? nonces[i] + 1 : nonces[i];
43
+ return signAuthorization(wallet, delegateAddress, BigInt(nonce));
44
+ }));
45
+ }
46
+ /**
47
+ * 批量签署授权(带预取 nonce)- 用于与其他操作并行
48
+ */
49
+ export function signAuthorizationsWithNonces(wallets, nonces, delegateAddress, mainWalletIndex) {
50
+ return wallets.map((wallet, i) => {
51
+ const isMainWallet = mainWalletIndex !== undefined && i === mainWalletIndex;
52
+ const nonce = isMainWallet ? nonces[i] + 1 : nonces[i];
53
+ // signAuthorization 内部实际是同步的,直接调用
54
+ const authData = [
55
+ bigintToBytes(BigInt(XLAYER_CHAIN_ID)),
56
+ addressToBytes(delegateAddress),
57
+ bigintToBytes(BigInt(nonce)),
58
+ ];
59
+ const rlpEncoded = rlp.encode(authData);
60
+ const toSign = new Uint8Array(1 + rlpEncoded.length);
61
+ toSign[0] = EIP7702_AUTH_PREFIX;
62
+ toSign.set(rlpEncoded, 1);
63
+ const msgHash = ethers.keccak256(toSign);
64
+ const signingKey = new ethers.SigningKey(wallet.privateKey);
65
+ const sig = signingKey.sign(msgHash);
66
+ return {
67
+ chainId: BigInt(XLAYER_CHAIN_ID),
68
+ address: delegateAddress,
69
+ nonce: BigInt(nonce),
70
+ yParity: sig.yParity,
71
+ r: ethers.getBytes(sig.r),
72
+ s: ethers.getBytes(sig.s),
73
+ };
74
+ });
75
+ }
76
+ /**
77
+ * 批量获取多个地址的 nonce - 并行
78
+ */
79
+ export async function batchGetNonces(addresses, provider) {
80
+ return Promise.all(addresses.map((addr) => provider.getTransactionCount(addr, 'pending')));
81
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * EIP-7702 捆绑创建代币 + 买入
3
+ *
4
+ * 在一笔交易中完成:
5
+ * 1. 开发者创建代币
6
+ * 2. 多个买家买入
7
+ * 3. 利润提取
8
+ *
9
+ * 只生成签名,由调用方决定如何提交
10
+ */
11
+ import type { BundleCreateBuyParams, BundleCreateBuyResult } from './types.js';
12
+ /**
13
+ * 捆绑创建代币 + 买入(EIP-7702 版本)
14
+ *
15
+ * 在一笔交易中完成:
16
+ * 1. 开发者创建代币
17
+ * 2. 多个买家买入
18
+ * 3. 利润提取
19
+ *
20
+ * @returns 只返回签名后的交易,不发送
21
+ */
22
+ export declare function bundleCreateBuy(params: BundleCreateBuyParams): Promise<BundleCreateBuyResult>;
@@ -0,0 +1,201 @@
1
+ /**
2
+ * EIP-7702 捆绑创建代币 + 买入
3
+ *
4
+ * 在一笔交易中完成:
5
+ * 1. 开发者创建代币
6
+ * 2. 多个买家买入
7
+ * 3. 利润提取
8
+ *
9
+ * 只生成签名,由调用方决定如何提交
10
+ */
11
+ import { ethers, Interface } from 'ethers';
12
+ import { ZERO_ADDRESS, ZERO_BYTES32 } from '../../../core/constants/index.js';
13
+ import { FLAP_PORTAL_ADDRESS, UNIFIED_DELEGATE_ADDRESS, UNIFIED_DELEGATE_ABI } from './constants.js';
14
+ import { getCachedProvider, createWallet, signAuthorizationsWithNonces, batchGetNonces, buildEIP7702TransactionSync, calculateProfitAmountByUserType, getProfitRecipient, } from './utils.js';
15
+ import { buildProfitCall, encodeCreateCallV2, encodeCreateCallV3, encodeCreateCallV4, encodeCreateCallV5, encodeFlapBuyCall, } from './bundle-create-helpers.js';
16
+ /**
17
+ * 捆绑创建代币 + 买入(EIP-7702 版本)
18
+ *
19
+ * 在一笔交易中完成:
20
+ * 1. 开发者创建代币
21
+ * 2. 多个买家买入
22
+ * 3. 利润提取
23
+ *
24
+ * @returns 只返回签名后的交易,不发送
25
+ */
26
+ export async function bundleCreateBuy(params) {
27
+ const { tokenInfo, tokenAddress = ZERO_ADDRESS, devPrivateKey, buyerPrivateKeys, buyAmounts, userType = 'v0', // ✅ 用户类型(影响利润率)
28
+ config, } = params;
29
+ if (buyerPrivateKeys.length !== buyAmounts.length) {
30
+ throw new Error('buyerPrivateKeys 和 buyAmounts 长度必须相同');
31
+ }
32
+ const provider = getCachedProvider(config?.rpcUrl);
33
+ const delegateAddress = (config?.delegateAddress && config.delegateAddress.trim()) || UNIFIED_DELEGATE_ADDRESS;
34
+ const delegateInterface = new Interface(UNIFIED_DELEGATE_ABI);
35
+ // 创建钱包
36
+ const devWallet = createWallet(devPrivateKey, provider);
37
+ const buyerWallets = buyerPrivateKeys.map((pk) => createWallet(pk, provider));
38
+ const allWallets = [devWallet, ...buyerWallets];
39
+ const mainWallet = devWallet;
40
+ // 计算买入金额和利润(单边模式:只有买入)
41
+ const buyAmountsWei = buyAmounts.map((amt) => ethers.parseEther(amt));
42
+ const totalBuyAmount = buyAmountsWei.reduce((sum, amt) => sum + amt, 0n);
43
+ const profitAmount = calculateProfitAmountByUserType(totalBuyAmount, userType, false); // ✅ 支持 userType
44
+ const profitRecipient = getProfitRecipient(config);
45
+ // 并行获取 nonce 和 fee data
46
+ const [nonces, feeData] = await Promise.all([
47
+ batchGetNonces(allWallets.map((w) => w.address), provider),
48
+ provider.getFeeData(),
49
+ ]);
50
+ // 签名授权
51
+ const authorizations = signAuthorizationsWithNonces(allWallets, nonces, delegateAddress, 0);
52
+ // 构建调用
53
+ const calls = [];
54
+ // 1. 利润转账(从开发者钱包)
55
+ if (profitAmount > 0n) {
56
+ calls.push(buildProfitCall(devWallet.address, profitAmount, profitRecipient, delegateInterface));
57
+ }
58
+ // 2. 创建代币
59
+ const useV5 = params.taxV2Config !== undefined && (params.taxRate ?? 0) > 0;
60
+ const useV4 = !useV5 && (params.dexId !== undefined || params.lpFeeProfile !== undefined);
61
+ const useV3 = !useV5 && !useV4 && !!params.extensionID;
62
+ let createData;
63
+ if (useV5) {
64
+ // V5: Tax Token V2 高级税收分配
65
+ const tv2 = params.taxV2Config;
66
+ const total = tv2.mktBps + tv2.deflationBps + tv2.dividendBps + tv2.lpBps;
67
+ if (total !== 10000) {
68
+ throw new Error(`Tax distribution must sum to 10000 (100%), got ${total}`);
69
+ }
70
+ createData = encodeCreateCallV5({
71
+ name: tokenInfo.name,
72
+ symbol: tokenInfo.symbol,
73
+ meta: tokenInfo.meta,
74
+ dexThresh: params.dexThresh ?? 1,
75
+ salt: params.salt ?? ZERO_BYTES32,
76
+ taxRate: params.taxRate ?? 0,
77
+ migratorType: params.migratorType ?? 0,
78
+ quoteToken: params.quoteToken ?? ZERO_ADDRESS,
79
+ quoteAmt: params.quoteAmt ?? 0n,
80
+ beneficiary: params.beneficiary ?? devWallet.address,
81
+ permitData: params.permitData ?? '0x',
82
+ extensionID: params.extensionID ?? ZERO_BYTES32,
83
+ extensionData: params.extensionData ?? '0x',
84
+ dexId: params.dexId ?? 0,
85
+ lpFeeProfile: params.lpFeeProfile ?? 0,
86
+ taxDuration: BigInt(tv2.taxDuration),
87
+ antiFarmerDuration: BigInt(tv2.antiFarmerDuration),
88
+ mktBps: tv2.mktBps,
89
+ deflationBps: tv2.deflationBps,
90
+ dividendBps: tv2.dividendBps,
91
+ lpBps: tv2.lpBps,
92
+ minimumShareBalance: BigInt(tv2.minimumShareBalance ?? 10000) * 10n ** 18n,
93
+ });
94
+ }
95
+ else if (useV4) {
96
+ createData = encodeCreateCallV4({
97
+ name: tokenInfo.name,
98
+ symbol: tokenInfo.symbol,
99
+ meta: tokenInfo.meta,
100
+ dexThresh: params.dexThresh ?? 1,
101
+ salt: params.salt ?? ZERO_BYTES32,
102
+ taxRate: params.taxRate ?? 0,
103
+ migratorType: params.migratorType ?? 0,
104
+ quoteToken: params.quoteToken ?? ZERO_ADDRESS,
105
+ quoteAmt: params.quoteAmt ?? 0n,
106
+ beneficiary: params.beneficiary ?? devWallet.address,
107
+ permitData: params.permitData ?? '0x',
108
+ extensionID: params.extensionID ?? ZERO_BYTES32,
109
+ extensionData: params.extensionData ?? '0x',
110
+ dexId: params.dexId ?? 0,
111
+ lpFeeProfile: params.lpFeeProfile ?? 0,
112
+ });
113
+ }
114
+ else if (useV3) {
115
+ createData = encodeCreateCallV3({
116
+ name: tokenInfo.name,
117
+ symbol: tokenInfo.symbol,
118
+ meta: tokenInfo.meta,
119
+ dexThresh: params.dexThresh ?? 1,
120
+ salt: params.salt ?? ZERO_BYTES32,
121
+ taxRate: params.taxRate ?? 0,
122
+ migratorType: params.migratorType ?? 0,
123
+ quoteToken: params.quoteToken ?? ZERO_ADDRESS,
124
+ quoteAmt: params.quoteAmt ?? 0n,
125
+ beneficiary: params.beneficiary ?? devWallet.address,
126
+ permitData: params.permitData ?? '0x',
127
+ extensionID: params.extensionID,
128
+ extensionData: params.extensionData ?? '0x',
129
+ });
130
+ }
131
+ else {
132
+ createData = encodeCreateCallV2({
133
+ name: tokenInfo.name,
134
+ symbol: tokenInfo.symbol,
135
+ meta: tokenInfo.meta,
136
+ dexThresh: params.dexThresh ?? 1,
137
+ salt: params.salt ?? ZERO_BYTES32,
138
+ taxRate: params.taxRate ?? 0,
139
+ migratorType: params.migratorType ?? 0,
140
+ quoteToken: params.quoteToken ?? ZERO_ADDRESS,
141
+ quoteAmt: params.quoteAmt ?? 0n,
142
+ beneficiary: params.beneficiary ?? devWallet.address,
143
+ permitData: params.permitData ?? '0x',
144
+ });
145
+ }
146
+ // 使用 executeBatch 从 devWallet 调用 Portal.newToken
147
+ const createBatchCall = delegateInterface.encodeFunctionData('executeBatch', [
148
+ [
149
+ {
150
+ target: FLAP_PORTAL_ADDRESS,
151
+ value: params.quoteAmt ?? 0n,
152
+ data: createData,
153
+ },
154
+ ],
155
+ ]);
156
+ calls.push({
157
+ target: devWallet.address,
158
+ allowFailure: false,
159
+ value: params.quoteAmt ?? 0n,
160
+ callData: createBatchCall,
161
+ });
162
+ // 3. 买家买入
163
+ const extensionData = params.extensionData ?? '0x';
164
+ const useV3OrV4 = useV4 || useV3; // 根据代币版本选择买入函数
165
+ for (let i = 0; i < buyerWallets.length; i++) {
166
+ const buyerWallet = buyerWallets[i];
167
+ const buyAmount = buyAmountsWei[i];
168
+ // 使用 executeBatch 从 buyerWallet 调用 Portal
169
+ const buyData = encodeFlapBuyCall(tokenAddress, buyAmount, useV3OrV4, extensionData);
170
+ const buyBatchCall = delegateInterface.encodeFunctionData('executeBatch', [
171
+ [
172
+ {
173
+ target: FLAP_PORTAL_ADDRESS,
174
+ value: buyAmount,
175
+ data: buyData,
176
+ },
177
+ ],
178
+ ]);
179
+ // ✅ 修复:value 设为 0n,让钱包使用自己余额买入
180
+ calls.push({
181
+ target: buyerWallet.address,
182
+ allowFailure: false,
183
+ value: 0n,
184
+ callData: buyBatchCall,
185
+ });
186
+ }
187
+ // ✅ 利润从开发者钱包余额转出,主交易只支付创建费用
188
+ const totalValue = params.quoteAmt ?? 0n;
189
+ // 构建签名交易
190
+ const signedTransaction = buildEIP7702TransactionSync(mainWallet, authorizations, calls, totalValue, nonces[0], feeData, config);
191
+ return {
192
+ signedTransaction,
193
+ tokenAddress,
194
+ metadata: {
195
+ devAddress: devWallet.address,
196
+ buyerCount: buyerWallets.length,
197
+ totalBuyAmount: ethers.formatEther(totalBuyAmount),
198
+ profitAmount: ethers.formatEther(profitAmount),
199
+ },
200
+ };
201
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * bundle-create 内部工具函数
3
+ *
4
+ * 供 bundle-create-buy / bundle-create-to-dex / bundle-graduate-buy 共享使用,
5
+ * 不作为公共 API 导出。
6
+ */
7
+ import { Interface } from 'ethers';
8
+ import type { Call3Value } from './types.js';
9
+ /**
10
+ * 将 lpFeeProfile 转换为 V3 fee
11
+ */
12
+ export declare function lpFeeProfileToV3Fee(lpFeeProfile: number | undefined): number;
13
+ /**
14
+ * 编码创建代币调用 V2
15
+ */
16
+ export declare function encodeCreateCallV2(params: {
17
+ name: string;
18
+ symbol: string;
19
+ meta: string;
20
+ dexThresh: number;
21
+ salt: string;
22
+ taxRate: number;
23
+ migratorType: number;
24
+ quoteToken: string;
25
+ quoteAmt: bigint;
26
+ beneficiary: string;
27
+ permitData: string;
28
+ }): string;
29
+ /**
30
+ * 编码创建代币调用 V3
31
+ */
32
+ export declare function encodeCreateCallV3(params: {
33
+ name: string;
34
+ symbol: string;
35
+ meta: string;
36
+ dexThresh: number;
37
+ salt: string;
38
+ taxRate: number;
39
+ migratorType: number;
40
+ quoteToken: string;
41
+ quoteAmt: bigint;
42
+ beneficiary: string;
43
+ permitData: string;
44
+ extensionID: string;
45
+ extensionData: string;
46
+ }): string;
47
+ /**
48
+ * 编码创建代币调用 V4
49
+ */
50
+ export declare function encodeCreateCallV4(params: {
51
+ name: string;
52
+ symbol: string;
53
+ meta: string;
54
+ dexThresh: number;
55
+ salt: string;
56
+ taxRate: number;
57
+ migratorType: number;
58
+ quoteToken: string;
59
+ quoteAmt: bigint;
60
+ beneficiary: string;
61
+ permitData: string;
62
+ extensionID: string;
63
+ extensionData: string;
64
+ dexId: number;
65
+ lpFeeProfile: number;
66
+ }): string;
67
+ /**
68
+ * 编码创建代币调用 V5(Tax Token V2 高级税收分配)
69
+ */
70
+ export declare function encodeCreateCallV5(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
+ extensionID: string;
83
+ extensionData: string;
84
+ dexId: number;
85
+ lpFeeProfile: number;
86
+ taxDuration: bigint;
87
+ antiFarmerDuration: bigint;
88
+ mktBps: number;
89
+ deflationBps: number;
90
+ dividendBps: number;
91
+ lpBps: number;
92
+ minimumShareBalance: bigint;
93
+ }): string;
94
+ /**
95
+ * 编码内盘买入调用
96
+ *
97
+ * 根据是否需要 extensionData 选择使用 swapExactInput 或 swapExactInputV3
98
+ * - V2 代币:使用 swapExactInput(无 extensionData)
99
+ * - V3/V4 代币:使用 swapExactInputV3(支持 extensionData)
100
+ */
101
+ export declare function encodeFlapBuyCall(tokenAddress: string, inputAmount: bigint, useV3OrV4?: boolean, extensionData?: string): string;
102
+ /**
103
+ * 编码外盘 V3 买入调用
104
+ */
105
+ export declare function encodeV3BuyCall(tokenAddress: string, fee: number, recipient: string, deadline: number, amountIn: bigint): string;
106
+ /**
107
+ * 编码外盘 V2 买入调用
108
+ */
109
+ export declare function encodeV2BuyCall(tokenAddress: string, recipient: string, deadline: number): string;
110
+ /**
111
+ * 构建利润转账调用
112
+ * ✅ 使用 transferAmount 从钱包余额转出,而不是 msg.value
113
+ */
114
+ export declare function buildProfitCall(walletAddress: string, profitAmount: bigint, profitRecipient: string, delegateInterface: Interface): Call3Value;
@@ -0,0 +1,139 @@
1
+ /**
2
+ * bundle-create 内部工具函数
3
+ *
4
+ * 供 bundle-create-buy / bundle-create-to-dex / bundle-graduate-buy 共享使用,
5
+ * 不作为公共 API 导出。
6
+ */
7
+ import { Interface } from 'ethers';
8
+ import { ZERO_ADDRESS } from '../../../core/constants/index.js';
9
+ import { FLAP_PORTAL_ABI, WOKB_ADDRESS, V3_FEE_TIERS } from './constants.js';
10
+ // ========================================
11
+ // 辅助函数
12
+ // ========================================
13
+ /**
14
+ * 将 lpFeeProfile 转换为 V3 fee
15
+ */
16
+ export function lpFeeProfileToV3Fee(lpFeeProfile) {
17
+ switch (lpFeeProfile) {
18
+ case 0:
19
+ return V3_FEE_TIERS.MEDIUM; // 0.25%
20
+ case 1:
21
+ return V3_FEE_TIERS.LOWEST; // 0.01%
22
+ case 2:
23
+ return V3_FEE_TIERS.HIGH; // 1%
24
+ default:
25
+ return V3_FEE_TIERS.MEDIUM;
26
+ }
27
+ }
28
+ /**
29
+ * 编码创建代币调用 V2
30
+ */
31
+ export function encodeCreateCallV2(params) {
32
+ const portalIface = new Interface(FLAP_PORTAL_ABI);
33
+ return portalIface.encodeFunctionData('newTokenV2', [params]);
34
+ }
35
+ /**
36
+ * 编码创建代币调用 V3
37
+ */
38
+ export function encodeCreateCallV3(params) {
39
+ const portalIface = new Interface(FLAP_PORTAL_ABI);
40
+ return portalIface.encodeFunctionData('newTokenV3', [params]);
41
+ }
42
+ /**
43
+ * 编码创建代币调用 V4
44
+ */
45
+ export function encodeCreateCallV4(params) {
46
+ const portalIface = new Interface(FLAP_PORTAL_ABI);
47
+ return portalIface.encodeFunctionData('newTokenV4', [params]);
48
+ }
49
+ /**
50
+ * 编码创建代币调用 V5(Tax Token V2 高级税收分配)
51
+ */
52
+ export function encodeCreateCallV5(params) {
53
+ const portalIface = new Interface(FLAP_PORTAL_ABI);
54
+ return portalIface.encodeFunctionData('newTokenV5', [params]);
55
+ }
56
+ /**
57
+ * 编码内盘买入调用
58
+ *
59
+ * 根据是否需要 extensionData 选择使用 swapExactInput 或 swapExactInputV3
60
+ * - V2 代币:使用 swapExactInput(无 extensionData)
61
+ * - V3/V4 代币:使用 swapExactInputV3(支持 extensionData)
62
+ */
63
+ export function encodeFlapBuyCall(tokenAddress, inputAmount, useV3OrV4 = false, extensionData = '0x') {
64
+ const portalIface = new Interface(FLAP_PORTAL_ABI);
65
+ if (useV3OrV4) {
66
+ // V3/V4 代币使用 swapExactInputV3(支持 extensionData)
67
+ return portalIface.encodeFunctionData('swapExactInputV3', [
68
+ {
69
+ inputToken: ZERO_ADDRESS,
70
+ outputToken: tokenAddress,
71
+ inputAmount,
72
+ minOutputAmount: 0n,
73
+ permitData: '0x',
74
+ extensionData,
75
+ },
76
+ ]);
77
+ }
78
+ else {
79
+ // V2 代币使用 swapExactInput
80
+ return portalIface.encodeFunctionData('swapExactInput', [
81
+ {
82
+ inputToken: ZERO_ADDRESS,
83
+ outputToken: tokenAddress,
84
+ inputAmount,
85
+ minOutputAmount: 0n,
86
+ permitData: '0x',
87
+ },
88
+ ]);
89
+ }
90
+ }
91
+ /**
92
+ * 编码外盘 V3 买入调用
93
+ */
94
+ export function encodeV3BuyCall(tokenAddress, fee, recipient, deadline, amountIn) {
95
+ const routerIface = new Interface([
96
+ 'function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96)) external payable returns (uint256)',
97
+ 'function multicall(uint256 deadline, bytes[] data) external payable returns (bytes[])',
98
+ 'function refundETH() external payable',
99
+ ]);
100
+ const exactInputData = routerIface.encodeFunctionData('exactInputSingle', [
101
+ {
102
+ tokenIn: WOKB_ADDRESS,
103
+ tokenOut: tokenAddress,
104
+ fee,
105
+ recipient,
106
+ amountIn,
107
+ amountOutMinimum: 0n,
108
+ sqrtPriceLimitX96: 0n,
109
+ },
110
+ ]);
111
+ const refundEthData = routerIface.encodeFunctionData('refundETH', []);
112
+ return routerIface.encodeFunctionData('multicall', [deadline, [exactInputData, refundEthData]]);
113
+ }
114
+ /**
115
+ * 编码外盘 V2 买入调用
116
+ */
117
+ export function encodeV2BuyCall(tokenAddress, recipient, deadline) {
118
+ const routerIface = new Interface([
119
+ 'function swapExactETHForTokensSupportingFeeOnTransferTokens(uint256 amountOutMin, address[] path, address to, uint256 deadline) external payable',
120
+ ]);
121
+ return routerIface.encodeFunctionData('swapExactETHForTokensSupportingFeeOnTransferTokens', [
122
+ 0n,
123
+ [WOKB_ADDRESS, tokenAddress],
124
+ recipient,
125
+ deadline,
126
+ ]);
127
+ }
128
+ /**
129
+ * 构建利润转账调用
130
+ * ✅ 使用 transferAmount 从钱包余额转出,而不是 msg.value
131
+ */
132
+ export function buildProfitCall(walletAddress, profitAmount, profitRecipient, delegateInterface) {
133
+ return {
134
+ target: walletAddress,
135
+ allowFailure: false,
136
+ value: 0n, // ✅ 不需要 msg.value,从钱包余额转出
137
+ callData: delegateInterface.encodeFunctionData('transferAmount', [profitRecipient, profitAmount]),
138
+ };
139
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * EIP-7702 一键发射到外盘 (Create-to-DEX)
3
+ *
4
+ * 在一笔交易中完成:
5
+ * 1. Payer 创建代币
6
+ * 2. 内盘买家买入(最后一笔触发毕业)
7
+ * 3. 外盘买家买入(可选)
8
+ * 4. 利润提取
9
+ *
10
+ * 只生成签名,由调用方决定如何提交
11
+ */
12
+ import type { BundleCreateToDexParams, BundleCreateToDexResult } from './types.js';
13
+ /**
14
+ * 一键发射到外盘(EIP-7702 版本)
15
+ *
16
+ * 在一笔交易中完成:
17
+ * 1. Payer 创建代币
18
+ * 2. 内盘买家买入(最后一笔触发毕业)
19
+ * 3. 外盘买家买入(可选)
20
+ * 4. 利润提取
21
+ *
22
+ * @returns 只返回签名后的交易,不发送
23
+ */
24
+ export declare function bundleCreateToDex(params: BundleCreateToDexParams): Promise<BundleCreateToDexResult>;