four-flap-meme-sdk 2.2.7 → 2.2.10

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 (474) hide show
  1. package/README.en.md +6 -41
  2. package/README.md +0 -31
  3. package/README.zh-CN.md +6 -41
  4. package/dist/chains/bsc/four/approve-tokenmanager.d.ts +26 -1
  5. package/dist/chains/bsc/four/approve-tokenmanager.js +113 -1
  6. package/dist/chains/bsc/four/config.d.ts +67 -5
  7. package/dist/chains/bsc/four/config.js +114 -2
  8. package/dist/chains/bsc/four/core.d.ts +4 -1
  9. package/dist/chains/bsc/four/core.js +592 -1
  10. package/dist/chains/bsc/four/index.d.ts +6 -6
  11. package/dist/chains/bsc/four/index.js +6 -6
  12. package/dist/chains/bsc/four/internal.d.ts +46 -2
  13. package/dist/chains/bsc/four/internal.js +239 -2
  14. package/dist/chains/bsc/four/pancake-proxy.d.ts +28 -1
  15. package/dist/chains/bsc/four/pancake-proxy.js +687 -1
  16. package/dist/chains/bsc/four/private.d.ts +27 -1
  17. package/dist/chains/bsc/four/private.js +477 -1
  18. package/dist/chains/bsc/four/submit.d.ts +315 -2
  19. package/dist/chains/bsc/four/submit.js +752 -2
  20. package/dist/chains/bsc/four/swap-buy-first.d.ts +55 -2
  21. package/dist/chains/bsc/four/swap-buy-first.js +507 -2
  22. package/dist/chains/bsc/four/swap-internal.d.ts +3 -1
  23. package/dist/chains/bsc/four/swap-internal.js +18 -1
  24. package/dist/chains/bsc/four/swap.d.ts +144 -2
  25. package/dist/chains/bsc/four/swap.js +766 -2
  26. package/dist/chains/bsc/four/types.d.ts +476 -1
  27. package/dist/chains/bsc/four/utils.d.ts +18 -5
  28. package/dist/chains/bsc/four/utils.js +1552 -5
  29. package/dist/chains/bsc/pancake/bundle-buy-first.d.ts +91 -1
  30. package/dist/chains/bsc/pancake/bundle-buy-first.js +212 -97
  31. package/dist/chains/bsc/pancake/bundle-swap.d.ts +79 -1
  32. package/dist/chains/bsc/pancake/bundle-swap.js +726 -114
  33. package/dist/chains/bsc/pancake/index.d.ts +2 -4
  34. package/dist/chains/bsc/pancake/index.js +3 -1
  35. package/dist/chains/bsc/platforms/iro/factory.d.ts +2 -2
  36. package/dist/chains/bsc/platforms/iro/factory.js +1 -3
  37. package/dist/chains/bsc/platforms/iro/index.d.ts +5 -5
  38. package/dist/chains/bsc/platforms/iro/index.js +3 -3
  39. package/dist/chains/bsc/platforms/iro/pool.js +10 -31
  40. package/dist/chains/bsc/platforms/iro/token.js +1 -4
  41. package/dist/chains/eni/batch-router/bundle-approve.js +3 -4
  42. package/dist/chains/eni/batch-router/transfer.js +25 -55
  43. package/dist/chains/eni/batch-router/utils.js +6 -32
  44. package/dist/chains/eni/bundler/sign.js +6 -5
  45. package/dist/chains/eni/bundler/submit.js +4 -1
  46. package/dist/chains/eni/constants.js +1 -1
  47. package/dist/chains/eni/index.d.ts +1 -2
  48. package/dist/chains/eni/index.js +0 -1
  49. package/dist/chains/eni/platforms/daoaas/create.js +2 -2
  50. package/dist/chains/eni/platforms/daoaas/index.d.ts +3 -3
  51. package/dist/chains/eni/platforms/daoaas/index.js +3 -3
  52. package/dist/chains/eni/platforms/daoaas/meta.js +6 -9
  53. package/dist/chains/eni/platforms/daoaas/portal-direct.js +44 -28
  54. package/dist/chains/eni/platforms/daoaas/portal.js +6 -10
  55. package/dist/chains/eni/platforms/dswap/liquidity.js +26 -58
  56. package/dist/chains/eni/platforms/fair-launch/index.d.ts +2 -2
  57. package/dist/chains/eni/platforms/fair-launch/index.js +1 -1
  58. package/dist/chains/eni/platforms/fair-launch/launcher.js +46 -87
  59. package/dist/chains/eni/platforms/fair-launch/pool.js +1 -4
  60. package/dist/chains/eni/platforms/fair-launch/presets.js +2 -2
  61. package/dist/chains/eni/platforms/iro/factory.d.ts +2 -2
  62. package/dist/chains/eni/platforms/iro/factory.js +1 -3
  63. package/dist/chains/eni/platforms/iro/index.d.ts +6 -6
  64. package/dist/chains/eni/platforms/iro/index.js +4 -4
  65. package/dist/chains/eni/platforms/iro/pool.js +26 -90
  66. package/dist/chains/eni/platforms/iro/token.js +31 -107
  67. package/dist/chains/eni/platforms/iro/whitelist.js +18 -6
  68. package/dist/chains/index.d.ts +0 -13
  69. package/dist/chains/index.js +0 -13
  70. package/dist/chains/xlayer/eip7702/bundle-approve.d.ts +26 -2
  71. package/dist/chains/xlayer/eip7702/bundle-approve.js +21 -11
  72. package/dist/chains/xlayer/eip7702/bundle-buy.d.ts +6 -2
  73. package/dist/chains/xlayer/eip7702/bundle-buy.js +51 -13
  74. package/dist/chains/xlayer/eip7702/bundle-create.js +59 -93
  75. package/dist/chains/xlayer/eip7702/bundle-sell.d.ts +6 -2
  76. package/dist/chains/xlayer/eip7702/bundle-sell.js +111 -29
  77. package/dist/chains/xlayer/eip7702/bundle-swap.d.ts +65 -3
  78. package/dist/chains/xlayer/eip7702/bundle-swap.js +245 -51
  79. package/dist/chains/xlayer/eip7702/constants.d.ts +16 -1
  80. package/dist/chains/xlayer/eip7702/constants.js +21 -3
  81. package/dist/chains/xlayer/eip7702/index.d.ts +46 -28
  82. package/dist/chains/xlayer/eip7702/index.js +81 -28
  83. package/dist/chains/xlayer/eip7702/multi-hop-transfer.d.ts +203 -2
  84. package/dist/chains/xlayer/eip7702/multi-hop-transfer.js +307 -63
  85. package/dist/chains/xlayer/eip7702/types.d.ts +0 -88
  86. package/dist/chains/xlayer/eip7702/utils.d.ts +3 -0
  87. package/dist/chains/xlayer/eip7702/utils.js +28 -23
  88. package/dist/chains/xlayer/eip7702/volume.d.ts +184 -6
  89. package/dist/chains/xlayer/eip7702/volume.js +164 -89
  90. package/dist/chains/xlayer/eoa/constants.js +1 -1
  91. package/dist/chains/xlayer/eoa/dex-helpers.js +5 -5
  92. package/dist/chains/xlayer/eoa/eoa-bundle-swap.d.ts +95 -1
  93. package/dist/chains/xlayer/eoa/eoa-bundle-swap.js +299 -66
  94. package/dist/chains/xlayer/eoa/eoa-wash-volume.d.ts +1 -1
  95. package/dist/chains/xlayer/eoa/eoa-wash-volume.js +23 -18
  96. package/dist/chains/xlayer/eoa/index.d.ts +6 -10
  97. package/dist/chains/xlayer/eoa/index.js +23 -8
  98. package/dist/chains/xlayer/eoa/portal-ops.js +2 -7
  99. package/dist/chains/xlayer/eoa/router-manager.js +3 -3
  100. package/dist/chains/xlayer/eoa/types.d.ts +2 -2
  101. package/dist/chains/xlayer/eoa/types.js +3 -1
  102. package/dist/chains/xlayer/index.d.ts +2 -3
  103. package/dist/chains/xlayer/index.js +7 -4
  104. package/dist/contracts/helper3.d.ts +5 -20
  105. package/dist/contracts/helper3.js +20 -56
  106. package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.d.ts +26 -1
  107. package/dist/contracts/tm-bundle-merkle/approve-tokenmanager.js +113 -1
  108. package/dist/contracts/tm-bundle-merkle/config.d.ts +67 -5
  109. package/dist/contracts/tm-bundle-merkle/config.js +114 -2
  110. package/dist/contracts/tm-bundle-merkle/core.d.ts +4 -1
  111. package/dist/contracts/tm-bundle-merkle/core.js +591 -1
  112. package/dist/contracts/tm-bundle-merkle/index.d.ts +5 -5
  113. package/dist/contracts/tm-bundle-merkle/index.js +5 -5
  114. package/dist/contracts/tm-bundle-merkle/internal.d.ts +46 -2
  115. package/dist/contracts/tm-bundle-merkle/internal.js +238 -2
  116. package/dist/contracts/tm-bundle-merkle/pancake-proxy.d.ts +28 -1
  117. package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +686 -1
  118. package/dist/contracts/tm-bundle-merkle/private.d.ts +27 -1
  119. package/dist/contracts/tm-bundle-merkle/private.js +476 -1
  120. package/dist/contracts/tm-bundle-merkle/submit.d.ts +314 -3
  121. package/dist/contracts/tm-bundle-merkle/submit.js +928 -3
  122. package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +55 -2
  123. package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +506 -2
  124. package/dist/contracts/tm-bundle-merkle/swap-internal.d.ts +3 -1
  125. package/dist/contracts/tm-bundle-merkle/swap-internal.js +18 -1
  126. package/dist/contracts/tm-bundle-merkle/swap.d.ts +144 -2
  127. package/dist/contracts/tm-bundle-merkle/swap.js +764 -2
  128. package/dist/contracts/tm-bundle-merkle/types.d.ts +476 -1
  129. package/dist/contracts/tm-bundle-merkle/utils.d.ts +18 -6
  130. package/dist/contracts/tm-bundle-merkle/utils.js +1501 -6
  131. package/dist/contracts/tm-bundle.d.ts +51 -3
  132. package/dist/contracts/tm-bundle.js +177 -108
  133. package/dist/contracts/tm.d.ts +2 -3
  134. package/dist/contracts/tm.js +32 -37
  135. package/dist/contracts/tm1.js +4 -9
  136. package/dist/contracts/tm2.js +4 -9
  137. package/dist/dex/direct-router.d.ts +125 -3
  138. package/dist/dex/direct-router.js +666 -237
  139. package/dist/flows/create.d.ts +1 -2
  140. package/dist/flows/create.js +6 -6
  141. package/dist/index.d.ts +86 -20
  142. package/dist/index.js +216 -20
  143. package/dist/shared/abis/TaxToken.json +105 -0
  144. package/dist/shared/abis/TokenManager2.json +60 -0
  145. package/dist/shared/abis/common.d.ts +83 -2
  146. package/dist/shared/abis/common.js +253 -2
  147. package/dist/shared/abis/index.d.ts +6 -5
  148. package/dist/shared/abis/index.js +7 -5
  149. package/dist/shared/clients/blockrazor.js +25 -39
  150. package/dist/shared/clients/club48.d.ts +2 -2
  151. package/dist/shared/clients/club48.js +29 -34
  152. package/dist/shared/clients/emitservice.js +0 -2
  153. package/dist/shared/clients/four.d.ts +6 -21
  154. package/dist/shared/clients/four.js +24 -29
  155. package/dist/shared/clients/merkle.js +34 -27
  156. package/dist/shared/constants/addresses.d.ts +1 -1
  157. package/dist/shared/constants/addresses.js +2 -11
  158. package/dist/shared/constants/chains.d.ts +1 -1
  159. package/dist/shared/constants/chains.js +1 -1
  160. package/dist/shared/constants/gas.d.ts +1 -1
  161. package/dist/shared/constants/gas.js +6 -2
  162. package/dist/shared/constants/index.d.ts +0 -3
  163. package/dist/shared/constants/index.js +0 -1
  164. package/dist/shared/flap/abi.js +1 -1
  165. package/dist/shared/flap/constants.d.ts +2 -1
  166. package/dist/shared/flap/constants.js +4 -3
  167. package/dist/shared/flap/curve.js +0 -3
  168. package/dist/shared/flap/errors.d.ts +4 -1
  169. package/dist/shared/flap/errors.js +1 -20
  170. package/dist/shared/flap/index.d.ts +5 -5
  171. package/dist/shared/flap/index.js +5 -5
  172. package/dist/shared/flap/launch-v6.d.ts +117 -0
  173. package/dist/shared/flap/launch-v6.js +111 -0
  174. package/dist/shared/flap/meta.d.ts +18 -22
  175. package/dist/shared/flap/meta.js +17 -12
  176. package/dist/shared/flap/permit.js +2 -5
  177. package/dist/shared/flap/pinata.d.ts +6 -22
  178. package/dist/shared/flap/pinata.js +26 -21
  179. package/dist/shared/flap/portal-bundle-merkle/config.d.ts +72 -3
  180. package/dist/shared/flap/portal-bundle-merkle/config.js +124 -4
  181. package/dist/shared/flap/portal-bundle-merkle/core.d.ts +4 -0
  182. package/dist/shared/flap/portal-bundle-merkle/core.js +267 -164
  183. package/dist/shared/flap/portal-bundle-merkle/create-to-dex.d.ts +4 -17
  184. package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +195 -107
  185. package/dist/shared/flap/portal-bundle-merkle/curve-to-dex.js +92 -100
  186. package/dist/shared/flap/portal-bundle-merkle/index.d.ts +7 -11
  187. package/dist/shared/flap/portal-bundle-merkle/index.js +7 -4
  188. package/dist/shared/flap/portal-bundle-merkle/pancake-proxy.js +68 -71
  189. package/dist/shared/flap/portal-bundle-merkle/private.js +114 -61
  190. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.d.ts +64 -1
  191. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first.js +247 -66
  192. package/dist/shared/flap/portal-bundle-merkle/swap.d.ts +71 -2
  193. package/dist/shared/flap/portal-bundle-merkle/swap.js +410 -103
  194. package/dist/shared/flap/portal-bundle-merkle/types.d.ts +12 -88
  195. package/dist/shared/flap/portal-bundle-merkle/utils.d.ts +80 -1
  196. package/dist/shared/flap/portal-bundle-merkle/utils.js +265 -145
  197. package/dist/shared/flap/portal-bundle.js +56 -55
  198. package/dist/shared/flap/portal.d.ts +3 -14
  199. package/dist/shared/flap/portal.js +26 -49
  200. package/dist/shared/flap/vanity.d.ts +5 -4
  201. package/dist/shared/flap/vanity.js +20 -13
  202. package/dist/shared/flap/vault.d.ts +93 -25
  203. package/dist/shared/flap/vault.js +126 -75
  204. package/dist/shared/four/tax-token.d.ts +1 -1
  205. package/dist/shared/four/tax-token.js +7 -27
  206. package/dist/shared/index.d.ts +0 -6
  207. package/dist/shared/index.js +0 -4
  208. package/dist/utils/airdrop-sweep.d.ts +76 -4
  209. package/dist/utils/airdrop-sweep.js +55 -42
  210. package/dist/utils/bundle-helpers.d.ts +243 -9
  211. package/dist/utils/bundle-helpers.js +584 -10
  212. package/dist/utils/constants.d.ts +61 -5
  213. package/dist/utils/constants.js +80 -5
  214. package/dist/utils/contract-factory.d.ts +4 -2
  215. package/dist/utils/contract-factory.js +18 -25
  216. package/dist/utils/erc20.d.ts +89 -7
  217. package/dist/utils/erc20.js +125 -94
  218. package/dist/utils/errors.d.ts +1 -12
  219. package/dist/utils/errors.js +1 -60
  220. package/dist/utils/holders-maker.d.ts +138 -2
  221. package/dist/utils/holders-maker.js +661 -26
  222. package/dist/utils/lp-inspect.d.ts +112 -2
  223. package/dist/utils/lp-inspect.js +223 -73
  224. package/dist/utils/mpcExclusive.d.ts +5 -2
  225. package/dist/utils/mpcExclusive.js +3 -4
  226. package/dist/utils/private-sale.d.ts +58 -2
  227. package/dist/utils/private-sale.js +15 -4
  228. package/dist/utils/provider-factory.d.ts +0 -4
  229. package/dist/utils/provider-factory.js +0 -10
  230. package/dist/utils/quote-helpers.d.ts +45 -4
  231. package/dist/utils/quote-helpers.js +74 -17
  232. package/dist/utils/stealth-transfer.d.ts +28 -2
  233. package/dist/utils/stealth-transfer.js +15 -31
  234. package/dist/utils/swap-helpers.d.ts +15 -2
  235. package/dist/utils/swap-helpers.js +11 -6
  236. package/dist/utils/wallet.d.ts +25 -2
  237. package/dist/utils/wallet.js +10 -13
  238. package/package.json +4 -160
  239. package/dist/__tests__/subpath-exports.test.d.ts +0 -1
  240. package/dist/__tests__/subpath-exports.test.js +0 -64
  241. package/dist/abis/common.d.ts +0 -85
  242. package/dist/abis/common.js +0 -264
  243. package/dist/abis/contracts/TaxToken.json +0 -969
  244. package/dist/abis/contracts/TokenManager2.json +0 -136
  245. package/dist/abis/contracts/index.d.ts +0 -5
  246. package/dist/abis/contracts/index.js +0 -5
  247. package/dist/abis/flap/index.d.ts +0 -3
  248. package/dist/abis/flap/index.js +0 -3
  249. package/dist/abis/flap/portal-events.d.ts +0 -6
  250. package/dist/abis/flap/portal-events.js +0 -17
  251. package/dist/abis/flap/portal.d.ts +0 -6
  252. package/dist/abis/flap/portal.js +0 -37
  253. package/dist/abis/flap/vault.d.ts +0 -171
  254. package/dist/abis/flap/vault.js +0 -91
  255. package/dist/abis/index.d.ts +0 -8
  256. package/dist/abis/index.js +0 -11
  257. package/dist/bundle-core/__tests__/config-helpers.test.d.ts +0 -1
  258. package/dist/bundle-core/__tests__/config-helpers.test.js +0 -28
  259. package/dist/bundle-core/__tests__/facade-parity.test.d.ts +0 -1
  260. package/dist/bundle-core/__tests__/facade-parity.test.js +0 -33
  261. package/dist/bundle-core/__tests__/sign-context-helpers.test.d.ts +0 -1
  262. package/dist/bundle-core/__tests__/sign-context-helpers.test.js +0 -60
  263. package/dist/bundle-core/__tests__/sign-fixture.test.d.ts +0 -1
  264. package/dist/bundle-core/__tests__/sign-fixture.test.js +0 -220
  265. package/dist/bundle-core/__tests__/sign-fixtures.d.ts +0 -10
  266. package/dist/bundle-core/__tests__/sign-fixtures.js +0 -16
  267. package/dist/bundle-core/config-helpers.d.ts +0 -36
  268. package/dist/bundle-core/config-helpers.js +0 -57
  269. package/dist/bundle-core/errors.d.ts +0 -50
  270. package/dist/bundle-core/errors.js +0 -35
  271. package/dist/bundle-core/four-meme/approve-tokenmanager.d.ts +0 -7
  272. package/dist/bundle-core/four-meme/approve-tokenmanager.js +0 -99
  273. package/dist/bundle-core/four-meme/core-helpers.d.ts +0 -8
  274. package/dist/bundle-core/four-meme/core-helpers.js +0 -40
  275. package/dist/bundle-core/four-meme/core.d.ts +0 -4
  276. package/dist/bundle-core/four-meme/core.js +0 -515
  277. package/dist/bundle-core/four-meme/pancake-proxy.d.ts +0 -28
  278. package/dist/bundle-core/four-meme/pancake-proxy.js +0 -679
  279. package/dist/bundle-core/four-meme/private.d.ts +0 -27
  280. package/dist/bundle-core/four-meme/private.js +0 -465
  281. package/dist/bundle-core/four-meme/sign-context-helpers.d.ts +0 -2
  282. package/dist/bundle-core/four-meme/sign-context-helpers.js +0 -2
  283. package/dist/bundle-core/four-meme/swap-buy-first.d.ts +0 -8
  284. package/dist/bundle-core/four-meme/swap-buy-first.js +0 -493
  285. package/dist/bundle-core/four-meme/swap-hop-helpers.d.ts +0 -6
  286. package/dist/bundle-core/four-meme/swap-hop-helpers.js +0 -63
  287. package/dist/bundle-core/four-meme/swap-internal.d.ts +0 -3
  288. package/dist/bundle-core/four-meme/swap-internal.js +0 -18
  289. package/dist/bundle-core/four-meme/swap-sign-helpers.d.ts +0 -27
  290. package/dist/bundle-core/four-meme/swap-sign-helpers.js +0 -105
  291. package/dist/bundle-core/four-meme/swap.d.ts +0 -17
  292. package/dist/bundle-core/four-meme/swap.js +0 -505
  293. package/dist/bundle-core/four-meme/types/buy-first.d.ts +0 -50
  294. package/dist/bundle-core/four-meme/types/buy-first.js +0 -1
  295. package/dist/bundle-core/four-meme/types/core-flow.d.ts +0 -63
  296. package/dist/bundle-core/four-meme/types/core-flow.js +0 -1
  297. package/dist/bundle-core/four-meme/types/index.d.ts +0 -600
  298. package/dist/bundle-core/four-meme/types/index.js +0 -1
  299. package/dist/bundle-core/four-meme/types/swap-internal.d.ts +0 -19
  300. package/dist/bundle-core/four-meme/types/swap-internal.js +0 -1
  301. package/dist/bundle-core/four-meme/types.d.ts +0 -1
  302. package/dist/bundle-core/four-meme/types.js +0 -1
  303. package/dist/bundle-core/four-meme/utils-disperse.d.ts +0 -7
  304. package/dist/bundle-core/four-meme/utils-disperse.js +0 -396
  305. package/dist/bundle-core/four-meme/utils-pairwise.d.ts +0 -8
  306. package/dist/bundle-core/four-meme/utils-pairwise.js +0 -328
  307. package/dist/bundle-core/four-meme/utils-sweep.d.ts +0 -8
  308. package/dist/bundle-core/four-meme/utils-sweep.js +0 -744
  309. package/dist/bundle-core/index.d.ts +0 -8
  310. package/dist/bundle-core/index.js +0 -8
  311. package/dist/bundle-core/internal.d.ts +0 -21
  312. package/dist/bundle-core/internal.js +0 -182
  313. package/dist/bundle-core/sign-context-helpers.d.ts +0 -25
  314. package/dist/bundle-core/sign-context-helpers.js +0 -67
  315. package/dist/bundle-core/submit.d.ts +0 -293
  316. package/dist/bundle-core/submit.js +0 -727
  317. package/dist/bundle-core/types/index.d.ts +0 -8
  318. package/dist/bundle-core/types/index.js +0 -1
  319. package/dist/bundle-core/types.d.ts +0 -1
  320. package/dist/bundle-core/types.js +0 -1
  321. package/dist/chains/bsc/four/utils-disperse.d.ts +0 -1
  322. package/dist/chains/bsc/four/utils-disperse.js +0 -1
  323. package/dist/chains/bsc/four/utils-pairwise.d.ts +0 -1
  324. package/dist/chains/bsc/four/utils-pairwise.js +0 -1
  325. package/dist/chains/bsc/four/utils-sweep.d.ts +0 -1
  326. package/dist/chains/bsc/four/utils-sweep.js +0 -1
  327. package/dist/chains/bsc/iro.d.ts +0 -5
  328. package/dist/chains/bsc/iro.js +0 -4
  329. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.d.ts +0 -159
  330. package/dist/chains/bsc/pancake/bundle-buy-first-helpers.js +0 -117
  331. package/dist/chains/bsc/pancake/bundle-swap-helpers.d.ts +0 -241
  332. package/dist/chains/bsc/pancake/bundle-swap-helpers.js +0 -565
  333. package/dist/chains/eni/flat-aliases.d.ts +0 -10
  334. package/dist/chains/eni/flat-aliases.js +0 -8
  335. package/dist/chains/eni/submit.d.ts +0 -43
  336. package/dist/chains/eni/submit.js +0 -286
  337. package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +0 -13
  338. package/dist/chains/xlayer/eip7702/flat-aliases.js +0 -10
  339. package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.d.ts +0 -79
  340. package/dist/chains/xlayer/eip7702/multi-hop-transfer-helpers.js +0 -1
  341. package/dist/chains/xlayer/eip7702/transfer-context-helpers.d.ts +0 -26
  342. package/dist/chains/xlayer/eip7702/transfer-context-helpers.js +0 -57
  343. package/dist/chains/xlayer/eip7702/volume-helpers.d.ts +0 -148
  344. package/dist/chains/xlayer/eip7702/volume-helpers.js +0 -48
  345. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.d.ts +0 -126
  346. package/dist/chains/xlayer/eoa/eoa-bundle-swap-helpers.js +0 -228
  347. package/dist/contracts/tm-bundle-helpers.d.ts +0 -88
  348. package/dist/contracts/tm-bundle-helpers.js +0 -72
  349. package/dist/contracts/tm-bundle-merkle/utils-disperse.d.ts +0 -1
  350. package/dist/contracts/tm-bundle-merkle/utils-disperse.js +0 -1
  351. package/dist/contracts/tm-bundle-merkle/utils-pairwise.d.ts +0 -1
  352. package/dist/contracts/tm-bundle-merkle/utils-pairwise.js +0 -1
  353. package/dist/contracts/tm-bundle-merkle/utils-sweep.d.ts +0 -1
  354. package/dist/contracts/tm-bundle-merkle/utils-sweep.js +0 -1
  355. package/dist/dex/direct-router-helpers.d.ts +0 -264
  356. package/dist/dex/direct-router-helpers.js +0 -539
  357. package/dist/dex/types.d.ts +0 -81
  358. package/dist/dex/types.js +0 -1
  359. package/dist/exports/root-bundle-and-tooling.d.ts +0 -27
  360. package/dist/exports/root-bundle-and-tooling.js +0 -30
  361. package/dist/exports/root-eni-and-bsc-iro.d.ts +0 -26
  362. package/dist/exports/root-eni-and-bsc-iro.js +0 -66
  363. package/dist/exports/root-foundations.d.ts +0 -35
  364. package/dist/exports/root-foundations.js +0 -70
  365. package/dist/exports/root-swap-dex-and-xlayer.d.ts +0 -30
  366. package/dist/exports/root-swap-dex-and-xlayer.js +0 -78
  367. package/dist/flap/index.d.ts +0 -10
  368. package/dist/flap/index.js +0 -8
  369. package/dist/flows/index.d.ts +0 -1
  370. package/dist/flows/index.js +0 -1
  371. package/dist/merkle/index.d.ts +0 -12
  372. package/dist/merkle/index.js +0 -11
  373. package/dist/shared/clients/index.d.ts +0 -8
  374. package/dist/shared/clients/index.js +0 -8
  375. package/dist/shared/constants/quote.d.ts +0 -30
  376. package/dist/shared/constants/quote.js +0 -37
  377. package/dist/shared/flap/portal-bundle-merkle/core-helpers.d.ts +0 -32
  378. package/dist/shared/flap/portal-bundle-merkle/core-helpers.js +0 -83
  379. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.d.ts +0 -125
  380. package/dist/shared/flap/portal-bundle-merkle/swap-buy-first-helpers.js +0 -113
  381. package/dist/shared/flap/portal-bundle-merkle/swap-helpers.d.ts +0 -149
  382. package/dist/shared/flap/portal-bundle-merkle/swap-helpers.js +0 -259
  383. package/dist/shared/flap/portal-create-token.d.ts +0 -79
  384. package/dist/shared/flap/portal-create-token.js +0 -261
  385. package/dist/shared/foundation/dex/v3-path.d.ts +0 -6
  386. package/dist/shared/foundation/dex/v3-path.js +0 -35
  387. package/dist/shared/foundation/gas/bundle-gas.d.ts +0 -49
  388. package/dist/shared/foundation/gas/bundle-gas.js +0 -93
  389. package/dist/shared/foundation/gas/profit-hop.d.ts +0 -20
  390. package/dist/shared/foundation/gas/profit-hop.js +0 -72
  391. package/dist/shared/foundation/index.d.ts +0 -13
  392. package/dist/shared/foundation/index.js +0 -12
  393. package/dist/shared/foundation/nonce/nonce-manager.d.ts +0 -17
  394. package/dist/shared/foundation/nonce/nonce-manager.js +0 -183
  395. package/dist/shared/foundation/normalize-unknown.d.ts +0 -9
  396. package/dist/shared/foundation/normalize-unknown.js +0 -29
  397. package/dist/shared/foundation/sdk-logger.d.ts +0 -13
  398. package/dist/shared/foundation/sdk-logger.js +0 -12
  399. package/dist/shared/foundation/tx/build-request.d.ts +0 -17
  400. package/dist/shared/foundation/tx/build-request.js +0 -25
  401. package/dist/shared/foundation/tx/sign-batch.d.ts +0 -5
  402. package/dist/shared/foundation/tx/sign-batch.js +0 -26
  403. package/dist/shared/foundation/tx/wallet-sign-patch.d.ts +0 -1
  404. package/dist/shared/foundation/tx/wallet-sign-patch.js +0 -18
  405. package/dist/shared/foundation/types/airdrop-sweep.d.ts +0 -79
  406. package/dist/shared/foundation/types/airdrop-sweep.js +0 -1
  407. package/dist/shared/foundation/types/erc20.d.ts +0 -65
  408. package/dist/shared/foundation/types/erc20.js +0 -1
  409. package/dist/shared/foundation/types/holders-maker.d.ts +0 -64
  410. package/dist/shared/foundation/types/holders-maker.js +0 -1
  411. package/dist/shared/foundation/types/index.d.ts +0 -7
  412. package/dist/shared/foundation/types/index.js +0 -1
  413. package/dist/shared/foundation/types/lp-inspect.d.ts +0 -102
  414. package/dist/shared/foundation/types/lp-inspect.js +0 -1
  415. package/dist/shared/foundation/types/multicall.d.ts +0 -5
  416. package/dist/shared/foundation/types/multicall.js +0 -1
  417. package/dist/shared/foundation/types/private-sale.d.ts +0 -35
  418. package/dist/shared/foundation/types/private-sale.js +0 -1
  419. package/dist/shared/foundation/types/quote-helpers.d.ts +0 -17
  420. package/dist/shared/foundation/types/quote-helpers.js +0 -1
  421. package/dist/types/errors.d.ts +0 -27
  422. package/dist/types/errors.js +0 -34
  423. package/dist/utils/holders-maker/addresses.d.ts +0 -12
  424. package/dist/utils/holders-maker/addresses.js +0 -15
  425. package/dist/utils/holders-maker/buy-tx.d.ts +0 -44
  426. package/dist/utils/holders-maker/buy-tx.js +0 -278
  427. package/dist/utils/holders-maker/constants.d.ts +0 -6
  428. package/dist/utils/holders-maker/constants.js +0 -7
  429. package/dist/utils/holders-maker/disperse.d.ts +0 -18
  430. package/dist/utils/holders-maker/disperse.js +0 -90
  431. package/dist/utils/holders-maker/routing.d.ts +0 -4
  432. package/dist/utils/holders-maker/routing.js +0 -45
  433. package/dist/utils/holders-maker/transfer-tx.d.ts +0 -4
  434. package/dist/utils/holders-maker/transfer-tx.js +0 -67
  435. package/dist/utils/holders-maker-helpers.d.ts +0 -9
  436. package/dist/utils/holders-maker-helpers.js +0 -9
  437. package/dist/utils/hop-chains.d.ts +0 -35
  438. package/dist/utils/hop-chains.js +0 -215
  439. package/dist/utils/lp-inspect-helpers.d.ts +0 -9
  440. package/dist/utils/lp-inspect-helpers.js +0 -109
  441. package/dist/utils/types/airdrop-sweep.d.ts +0 -1
  442. package/dist/utils/types/airdrop-sweep.js +0 -1
  443. package/dist/utils/types/contract-factory.d.ts +0 -1
  444. package/dist/utils/types/contract-factory.js +0 -1
  445. package/dist/utils/types/erc20.d.ts +0 -1
  446. package/dist/utils/types/erc20.js +0 -1
  447. package/dist/utils/types/errors.d.ts +0 -1
  448. package/dist/utils/types/errors.js +0 -1
  449. package/dist/utils/types/holders-maker.d.ts +0 -1
  450. package/dist/utils/types/holders-maker.js +0 -1
  451. package/dist/utils/types/hop-chains.d.ts +0 -8
  452. package/dist/utils/types/hop-chains.js +0 -1
  453. package/dist/utils/types/index.d.ts +0 -13
  454. package/dist/utils/types/index.js +0 -1
  455. package/dist/utils/types/lp-inspect.d.ts +0 -1
  456. package/dist/utils/types/lp-inspect.js +0 -1
  457. package/dist/utils/types/mpc-exclusive.d.ts +0 -5
  458. package/dist/utils/types/mpc-exclusive.js +0 -1
  459. package/dist/utils/types/private-sale.d.ts +0 -1
  460. package/dist/utils/types/private-sale.js +0 -1
  461. package/dist/utils/types/quote-helpers.d.ts +0 -1
  462. package/dist/utils/types/quote-helpers.js +0 -1
  463. package/dist/utils/types/stealth-transfer.d.ts +0 -44
  464. package/dist/utils/types/stealth-transfer.js +0 -1
  465. package/dist/utils/types/wallet.d.ts +0 -25
  466. package/dist/utils/types/wallet.js +0 -1
  467. package/dist/vanity/index.d.ts +0 -5
  468. package/dist/vanity/index.js +0 -5
  469. package/src/abis/contracts/TaxToken.json +0 -969
  470. package/src/abis/contracts/TokenManager.json +0 -836
  471. package/src/abis/contracts/TokenManager2.json +0 -136
  472. package/src/abis/contracts/TokenManagerHelper3.json +0 -993
  473. /package/dist/{abis/contracts → shared/abis}/TokenManager.json +0 -0
  474. /package/dist/{abis/contracts → shared/abis}/TokenManagerHelper3.json +0 -0
@@ -1,44 +1,93 @@
1
- /**
2
- * core - 主函数
3
- */
4
1
  import { ethers, Wallet, Contract, Interface } from 'ethers';
5
- import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
6
- import { ZERO_ADDRESS } from '../../../shared/constants/index.js';
7
- import { GAS_LIMITS } from '../../constants/index.js';
8
- import { MULTICALL3_ABI } from '../../abis/common.js';
2
+ import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
3
+ import { ADDRESSES, ZERO_ADDRESS } from '../../../utils/constants.js';
4
+ import { GAS_LIMITS, CHAINS } from '../../constants/index.js';
5
+ import { MULTICALL3_ABI, V2_ROUTER_QUOTE_ABI } from '../../abis/common.js';
9
6
  import { FLAP_PORTAL_ADDRESSES, FLAP_ORIGINAL_PORTAL_ADDRESSES } from '../constants.js';
10
- import { normalizeTaxLaunchConfig, populateCreateTokenTransaction, } from '../portal-create-token.js';
11
- import { CHAIN_ID_MAP, PORTAL_ABI, getErrorMessage, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, } from './config.js';
12
- import { MigratorType } from '../portal.js';
13
- import { MULTICALL3_ADDRESS, getGasLimit, getTokenToNativeQuote } from './core-helpers.js';
14
- function resolveCreateTokenLaunchFlags(params) {
15
- const normalizedTax = normalizeTaxLaunchConfig(params.taxV2Config, params.taxRate);
16
- const isTaxLaunch = !!normalizedTax || (params.taxRate ?? 0) > 0;
17
- const hasVault = !!normalizedTax?.vaultConfig && normalizedTax.vaultConfig.vaultType !== 'none';
18
- const useV4Portal = !isTaxLaunch &&
19
- !hasVault &&
20
- (params.lpFeeProfile !== undefined || params.dexId !== undefined);
21
- const useClInfinityLaunch = !isTaxLaunch &&
22
- !hasVault &&
23
- !useV4Portal &&
24
- params.migratorType === MigratorType.PCS_INFINITY_CL_MIGRATOR;
25
- return { normalizedTax, isTaxLaunch, hasVault, useV4Portal, useClInfinityLaunch };
26
- }
7
+ import { buildNewTokenV6WithVaultParams, VAULT_PORTAL_ADDRESSES, VAULT_PORTAL_ABI } from '../vault.js';
8
+ import { buildNewTokenV6Params } from '../launch-v6.js';
9
+ import { CHAIN_ID_MAP, PORTAL_ABI, getErrorMessage, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA } from './config.js';
10
+ // 常量
11
+ const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
12
+ // ==================== ERC20 原生代币报价 ====================
13
+ // BSC 链常量
14
+ const BSC_PANCAKE_V2_ROUTER = ADDRESSES.BSC.PancakeV2Router;
15
+ const BSC_WBNB = ADDRESSES.BSC.WBNB;
16
+ // ✅ Monad 链常量
17
+ const MONAD_PANCAKE_V2_ROUTER = '0xb1bc24c34e88f7d43d5923034e3a14b24daacff9';
18
+ const MONAD_WMON = ADDRESSES.MONAD.WMON;
19
+ // ✅ XLAYER 链常量(PotatoSwap V2)
20
+ const XLAYER_POTATOSWAP_V2_ROUTER = ADDRESSES.XLAYER.PotatoSwapV2Router;
21
+ const XLAYER_WOKB = ADDRESSES.XLAYER.WOKB;
22
+ // Base 链常量(Uniswap V3 SwapRouter02)
23
+ const BASE_WETH = ADDRESSES.BASE.WETH;
24
+ const ROUTER_ABI = V2_ROUTER_QUOTE_ABI;
27
25
  /**
28
- * 无捆绑钱包、仅 Dev 自跟买、原生报价Flap 文档方式 A(create 内 quoteAmt + msg.value)
26
+ * 获取 ERC20 代币原生代币的报价
27
+ * @param provider - Provider 实例
28
+ * @param tokenAddress - ERC20 代币地址
29
+ * @param tokenAmount - 代币数量(wei)
30
+ * @param chainId - 链 ID(56=BSC, 143=Monad)
31
+ * @returns 等值的原生代币数量(wei),失败返回 0n
29
32
  */
30
- function canUseLaunchMethodA(privateKeys, buyAmounts, devAddress, useNativeToken) {
31
- if (!useNativeToken || buyAmounts.length !== 1 || privateKeys.length !== 2) {
32
- return false;
33
- }
33
+ async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chainId) {
34
+ if (tokenAmount <= 0n)
35
+ return 0n;
34
36
  try {
35
- const buyerAddr = new Wallet(privateKeys[1]).address;
36
- return buyerAddr.toLowerCase() === devAddress.toLowerCase();
37
+ if (chainId === CHAINS.BSC.chainId) {
38
+ // BSC: 使用 PancakeSwap V2 Router
39
+ const router = new Contract(BSC_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
40
+ const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, BSC_WBNB]);
41
+ return amounts[1];
42
+ }
43
+ if (chainId === CHAINS.MONAD.chainId) {
44
+ // ✅ Monad: 使用 PancakeSwap V2 Router
45
+ const router = new Contract(MONAD_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
46
+ const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, MONAD_WMON]);
47
+ return amounts[1];
48
+ }
49
+ if (chainId === CHAINS.XLAYER.chainId) {
50
+ // ✅ XLAYER: 使用 PotatoSwap V2 Router(USDT0 → WOKB)
51
+ const router = new Contract(XLAYER_POTATOSWAP_V2_ROUTER, ROUTER_ABI, provider);
52
+ const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, XLAYER_WOKB]);
53
+ return amounts[1];
54
+ }
55
+ if (chainId === CHAINS.BASE.chainId) {
56
+ // ✅ Base: 目前大部分 Flap 交易使用 ETH(原生代币),ERC20 报价暂不支持
57
+ // Base 主力 DEX 是 Uniswap V3,V2 Router 流动性有限,暂返回 0
58
+ // TODO: 后续可接入 Uniswap V3 QuoterV2 进行精确报价
59
+ return 0n;
60
+ }
61
+ // 其他链暂不支持报价,返回 0
62
+ return 0n;
37
63
  }
38
64
  catch {
39
- return false;
65
+ // 报价失败返回 0(可能是流动性不足或路径不存在)
66
+ return 0n;
40
67
  }
41
68
  }
69
+ /**
70
+ * 获取 Gas Limit
71
+ * 优先使用 config.gasLimit,否则使用默认值 * multiplier
72
+ *
73
+ * ✅ ethers v6 最佳实践:直接使用 bigint 类型
74
+ */
75
+ function getGasLimit(config, defaultGas = 800000) {
76
+ // 优先使用前端传入的 gasLimit
77
+ if (config.gasLimit !== undefined) {
78
+ // 如果已经是 bigint,直接返回;否则转换
79
+ return typeof config.gasLimit === 'bigint' ? config.gasLimit : BigInt(config.gasLimit);
80
+ }
81
+ // 使用默认值 * multiplier
82
+ const multiplier = config.gasLimitMultiplier ?? 1.0;
83
+ const calculatedGas = Math.ceil(defaultGas * multiplier);
84
+ // JavaScript 原生 BigInt 转换(ethers v6 兼容)
85
+ return BigInt(calculatedGas);
86
+ }
87
+ /**
88
+ * Flap Protocol: 创建代币 + 捆绑购买(仅签名版本 - 不依赖 Merkle)
89
+ * ✅ 精简版:只负责签名交易,不提交到 Merkle
90
+ */
42
91
  export async function createTokenWithBundleBuyMerkle(params) {
43
92
  const { chain, privateKeys, buyAmounts, tokenInfo, tokenAddress, config } = params;
44
93
  if (privateKeys.length === 0) {
@@ -54,41 +103,128 @@ export async function createTokenWithBundleBuyMerkle(params) {
54
103
  const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
55
104
  const originalPortalAddr = FLAP_ORIGINAL_PORTAL_ADDRESSES[chain];
56
105
  const portal = new ethers.Contract(originalPortalAddr, PORTAL_ABI, devWallet);
57
- const { normalizedTax, useV4Portal, useClInfinityLaunch } = resolveCreateTokenLaunchFlags(params);
58
- const inputToken = params.quoteToken && params.quoteToken !== ZERO_ADDRESS ? params.quoteToken : ZERO_ADDRESS;
59
- const useNativeToken = inputToken === ZERO_ADDRESS;
60
- const extractProfit = config.extractProfitOnLaunch === false ? false : shouldExtractProfit(config);
61
- const useMethodA = canUseLaunchMethodA(privateKeys, buyAmounts, devWallet.address, useNativeToken);
62
- let methodAQuoteAmt = 0n;
63
- let methodABuyMeta;
64
- if (useMethodA) {
65
- methodABuyMeta = analyzeBuyFunds(buyAmounts, config, extractProfit);
66
- methodAQuoteAmt = methodABuyMeta.fundsList[0] ?? 0n;
67
- }
68
- const createTxPromise = populateCreateTokenTransaction({
69
- chain,
70
- devWallet,
71
- originalPortal: portal,
72
- tokenInfo,
73
- quoteToken: params.quoteToken || ZERO_ADDRESS,
74
- beneficiary: devWallet.address,
75
- dexThresh: params.dexThresh,
76
- salt: params.salt,
77
- migratorType: params.migratorType,
78
- taxRate: params.taxRate,
79
- dexId: params.dexId,
80
- lpFeeProfile: params.lpFeeProfile,
81
- extensionID: params.extensionID,
82
- extensionData: params.extensionData,
83
- useV4Portal,
84
- useClInfinityLaunch,
85
- taxConfig: normalizedTax,
86
- initialQuoteAmt: useMethodA ? methodAQuoteAmt : 0n,
87
- });
106
+ // 判断使用哪个版本的 newToken
107
+ // V5: 提供了 taxV2Config taxRate > 0(Tax Token V2 高级税收分配)
108
+ // V4: 提供了 dexId lpFeeProfile(支持 DEX 选择和 LP 费率配置)
109
+ // V3: 提供了 extensionID(支持扩展数据)
110
+ // V2: 默认
111
+ const useV5 = params.taxV2Config !== undefined && (params.taxRate ?? 0) > 0;
112
+ const useV4 = !useV5 && (params.dexId !== undefined || params.lpFeeProfile !== undefined);
113
+ const useV3 = !useV5 && !useV4 && !!params.extensionID;
114
+ // 优化:并行获取 gasPrice、devWallet nonce 和 createTx
115
+ let createTxPromise;
116
+ if (useV5) {
117
+ // V5: Tax Token V2 高级税收分配
118
+ const tv2 = params.taxV2Config;
119
+ const dist = tv2.distribution;
120
+ const total = dist.mktBps + dist.deflationBps + dist.dividendBps + dist.lpBps;
121
+ if (total !== 10000) {
122
+ throw new Error(`Tax distribution must sum to 10000 (100%), got ${total}`);
123
+ }
124
+ // ✅ 金库:VaultPortal.newTokenV6WithVault;无金库:Portal.newTokenV6 + TOKEN_TAXED_V3
125
+ const hasVault = tv2.vaultConfig && tv2.vaultConfig.vaultType !== 'none';
126
+ if (hasVault) {
127
+ const vaultPortalAddr = VAULT_PORTAL_ADDRESSES[chain];
128
+ if (!vaultPortalAddr) {
129
+ throw new Error(`链 "${chain}" 不支持 Tax Vault 金库功能`);
130
+ }
131
+ const vaultPortal = new ethers.Contract(vaultPortalAddr, VAULT_PORTAL_ABI, devWallet);
132
+ const v6VaultParams = buildNewTokenV6WithVaultParams({
133
+ tokenInfo,
134
+ taxV2: tv2,
135
+ chain,
136
+ salt: params.salt,
137
+ taxRate: params.taxRate,
138
+ buyTaxRate: params.buyTaxRate,
139
+ sellTaxRate: params.sellTaxRate,
140
+ dexThresh: params.dexThresh,
141
+ migratorType: params.migratorType,
142
+ quoteToken: params.quoteToken,
143
+ quoteAmt: 0n,
144
+ dexId: params.dexId,
145
+ lpFeeProfile: params.lpFeeProfile,
146
+ });
147
+ createTxPromise = vaultPortal.newTokenV6WithVault.populateTransaction(v6VaultParams);
148
+ }
149
+ else {
150
+ const v6Params = buildNewTokenV6Params({
151
+ tokenInfo,
152
+ taxV2: tv2,
153
+ beneficiary: devWallet.address,
154
+ salt: params.salt,
155
+ taxRate: params.taxRate,
156
+ buyTaxRate: params.buyTaxRate,
157
+ sellTaxRate: params.sellTaxRate,
158
+ dexThresh: params.dexThresh,
159
+ migratorType: params.migratorType,
160
+ quoteToken: params.quoteToken,
161
+ quoteAmt: 0n,
162
+ dexId: params.dexId,
163
+ lpFeeProfile: params.lpFeeProfile,
164
+ extensionID: params.extensionID,
165
+ extensionData: params.extensionData,
166
+ });
167
+ createTxPromise = portal.newTokenV6.populateTransaction(v6Params);
168
+ }
169
+ }
170
+ else if (useV4) {
171
+ // V4: 支持 DEX ID 和 LP 费率配置
172
+ createTxPromise = portal.newTokenV4.populateTransaction({
173
+ name: tokenInfo.name,
174
+ symbol: tokenInfo.symbol,
175
+ meta: tokenInfo.meta,
176
+ dexThresh: (params.dexThresh ?? 1) & 0xff,
177
+ salt: params.salt ?? '0x' + '00'.repeat(32),
178
+ taxRate: (params.taxRate ?? 0) & 0xffff,
179
+ migratorType: (params.migratorType ?? 0) & 0xff,
180
+ quoteToken: params.quoteToken || ZERO_ADDRESS,
181
+ quoteAmt: 0n,
182
+ beneficiary: devWallet.address,
183
+ permitData: '0x',
184
+ extensionID: params.extensionID ?? '0x' + '00'.repeat(32),
185
+ extensionData: params.extensionData ?? '0x',
186
+ dexId: (params.dexId ?? 0) & 0xff,
187
+ lpFeeProfile: (params.lpFeeProfile ?? 0) & 0xff
188
+ });
189
+ }
190
+ else if (useV3) {
191
+ // V3: 支持扩展数据
192
+ createTxPromise = portal.newTokenV3.populateTransaction({
193
+ name: tokenInfo.name,
194
+ symbol: tokenInfo.symbol,
195
+ meta: tokenInfo.meta,
196
+ dexThresh: (params.dexThresh ?? 1) & 0xff,
197
+ salt: params.salt ?? '0x' + '00'.repeat(32),
198
+ taxRate: (params.taxRate ?? 0) & 0xffff,
199
+ migratorType: (params.migratorType ?? 0) & 0xff,
200
+ quoteToken: params.quoteToken || ZERO_ADDRESS,
201
+ quoteAmt: 0n,
202
+ beneficiary: devWallet.address,
203
+ permitData: '0x',
204
+ extensionID: params.extensionID,
205
+ extensionData: params.extensionData ?? '0x'
206
+ });
207
+ }
208
+ else {
209
+ // V2: 基础版本
210
+ createTxPromise = portal.newTokenV2.populateTransaction({
211
+ name: tokenInfo.name,
212
+ symbol: tokenInfo.symbol,
213
+ meta: tokenInfo.meta,
214
+ dexThresh: (params.dexThresh ?? 1) & 0xff,
215
+ salt: params.salt ?? '0x' + '00'.repeat(32),
216
+ taxRate: (params.taxRate ?? 0) & 0xffff,
217
+ migratorType: (params.migratorType ?? 0) & 0xff,
218
+ quoteToken: params.quoteToken || ZERO_ADDRESS,
219
+ quoteAmt: 0n,
220
+ beneficiary: devWallet.address,
221
+ permitData: '0x'
222
+ });
223
+ }
88
224
  const [gasPrice, createTxUnsigned, devNonce] = await Promise.all([
89
225
  resolveGasPrice(provider, config),
90
226
  createTxPromise,
91
- nonceManager.getNextNonce(devWallet),
227
+ nonceManager.getNextNonce(devWallet)
92
228
  ]);
93
229
  const createTxRequest = {
94
230
  ...createTxUnsigned,
@@ -97,74 +233,31 @@ export async function createTokenWithBundleBuyMerkle(params) {
97
233
  gasLimit: getGasLimit(config),
98
234
  gasPrice,
99
235
  chainId,
100
- type: getTxType(config),
101
- value: useMethodA ? methodAQuoteAmt : 0n,
236
+ type: getTxType(config)
102
237
  };
103
238
  const signedCreateTx = await devWallet.signTransaction(createTxRequest);
104
239
  signedTxs.push(signedCreateTx);
105
- if (useMethodA && methodABuyMeta) {
106
- const { totalBuyAmount, totalProfit } = methodABuyMeta;
107
- const bribeAmount = getBribeAmount(config);
108
- const bribeTxs = [];
109
- let nextDevNonce = devNonce + 1;
110
- if (bribeAmount > 0n) {
111
- const bribeTx = await devWallet.signTransaction({
112
- to: BLOCKRAZOR_BUILDER_EOA,
113
- value: bribeAmount,
114
- nonce: nextDevNonce,
115
- gasPrice,
116
- gasLimit: GAS_LIMITS.BRIBE,
117
- chainId,
118
- type: getTxType(config),
119
- });
120
- bribeTxs.push(bribeTx);
121
- nextDevNonce += 1;
122
- }
123
- const profitTxs = [];
124
- let profitHopWallets;
125
- if (extractProfit && totalProfit > 0n) {
126
- const profitHopResult = await buildProfitHopTransactions({
127
- provider,
128
- payerWallet: devWallet,
129
- profitAmount: totalProfit,
130
- profitRecipient: getProfitRecipient(),
131
- hopCount: PROFIT_HOP_COUNT,
132
- gasPrice,
133
- chainId,
134
- txType: getTxType(config),
135
- startNonce: nextDevNonce,
136
- });
137
- profitTxs.push(...profitHopResult.signedTransactions);
138
- profitHopWallets = profitHopResult.hopWallets;
139
- }
140
- nonceManager.clearTemp();
141
- return {
142
- signedTransactions: [...bribeTxs, ...signedTxs, ...profitTxs],
143
- tokenAddress,
144
- profitHopWallets,
145
- metadata: {
146
- ...buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, 0),
147
- launchMethod: 'quoteAmt',
148
- },
149
- };
150
- }
151
240
  const buyers = createWallets(privateKeys.slice(1), provider);
241
+ const extractProfit = shouldExtractProfit(config);
152
242
  const { fundsList, originalAmounts, totalBuyAmount, totalProfit } = analyzeBuyFunds(buyAmounts, config, extractProfit);
153
243
  const maxFundsIndex = findMaxIndex(originalAmounts);
154
244
  const gasLimits = buildGasLimitList(buyers.length, config);
245
+ // ✅ 支持 quoteToken:如果传入了 quoteToken 且非零地址,则使用它
246
+ const inputToken = params.quoteToken && params.quoteToken !== ZERO_ADDRESS ? params.quoteToken : ZERO_ADDRESS;
247
+ const useNativeToken = inputToken === ZERO_ADDRESS;
155
248
  // ✅ 如果使用非原生代币(如 USDC),需要根据精度转换金额
156
249
  let adjustedFundsList = fundsList;
157
250
  let profitTokenAmount = totalProfit;
158
251
  if (!useNativeToken && params.quoteTokenDecimals !== undefined && params.quoteTokenDecimals !== 18) {
159
252
  const decimalsDiff = 18 - params.quoteTokenDecimals;
160
253
  const divisor = BigInt(10 ** decimalsDiff);
161
- adjustedFundsList = fundsList.map((amount) => amount / divisor);
254
+ adjustedFundsList = fundsList.map(amount => amount / divisor);
162
255
  profitTokenAmount = totalProfit / divisor;
163
256
  }
164
257
  // ✅ 优化:并行获取 unsignedBuys 和 buyerNonces
165
258
  const [unsignedBuys, buyerNonces] = await Promise.all([
166
259
  populateBuyTransactionsWithQuote(buyers, portalAddr, tokenAddress, adjustedFundsList, inputToken, useNativeToken),
167
- allocateBuyerNonces(buyers, extractProfit, maxFundsIndex, useNativeToken ? totalProfit : profitTokenAmount, nonceManager),
260
+ allocateBuyerNonces(buyers, extractProfit, maxFundsIndex, useNativeToken ? totalProfit : profitTokenAmount, nonceManager)
168
261
  ]);
169
262
  // ✅ 贿赂交易放在首位(提高 BlockRazor 打包优先级)
170
263
  const bribeAmount = getBribeAmount(config);
@@ -179,7 +272,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
179
272
  gasPrice,
180
273
  gasLimit: GAS_LIMITS.BRIBE,
181
274
  chainId,
182
- type: getTxType(config),
275
+ type: getTxType(config)
183
276
  });
184
277
  bribeTxs.push(bribeTx);
185
278
  // 调整 maxFundsIndex 钱包的 nonce(买入交易 +1)
@@ -194,7 +287,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
194
287
  chainId,
195
288
  config,
196
289
  fundsList: adjustedFundsList, // ✅ 使用调整后的金额
197
- useNativeToken, // ✅ 传递是否使用原生代币
290
+ useNativeToken // ✅ 传递是否使用原生代币
198
291
  });
199
292
  // ✅ 利润多跳转账(强制 2 跳中转)
200
293
  const profitTxs = [];
@@ -215,7 +308,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
215
308
  gasPrice,
216
309
  chainId,
217
310
  txType: getTxType(config),
218
- startNonce: profitNonce,
311
+ startNonce: profitNonce
219
312
  });
220
313
  profitTxs.push(...profitHopResult.signedTransactions);
221
314
  profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
@@ -227,10 +320,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
227
320
  signedTransactions: [...bribeTxs, ...signedTxs, ...signedBuys, ...profitTxs],
228
321
  tokenAddress,
229
322
  profitHopWallets, // ✅ 返回利润多跳钱包
230
- metadata: {
231
- ...buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, buyers.length),
232
- launchMethod: 'swapExactInput',
233
- },
323
+ metadata: buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, buyers.length)
234
324
  };
235
325
  }
236
326
  /**
@@ -245,8 +335,9 @@ export async function batchBuyWithBundleMerkle(params) {
245
335
  }
246
336
  const { provider, chainId } = createChainContext(chain, config.rpcUrl);
247
337
  const nonceManager = new NonceManager(provider);
338
+ const signedTxs = [];
248
339
  const buyers = createWallets(privateKeys, provider);
249
- const extractProfit = shouldExtractProfit();
340
+ const extractProfit = shouldExtractProfit(config);
250
341
  const { fundsList, originalAmounts, totalBuyAmount, totalProfit } = analyzeBuyFunds(buyAmounts, config, extractProfit);
251
342
  const maxFundsIndex = findMaxIndex(originalAmounts);
252
343
  const gasLimits = buildGasLimitList(buyers.length, config);
@@ -264,7 +355,7 @@ export async function batchBuyWithBundleMerkle(params) {
264
355
  // 转为 USDC (6位) = 100000 (0.1 USDC)
265
356
  const decimalsDiff = 18 - quoteTokenDecimals;
266
357
  const divisor = BigInt(10 ** decimalsDiff);
267
- adjustedFundsList = fundsList.map((amount) => amount / divisor);
358
+ adjustedFundsList = fundsList.map(amount => amount / divisor);
268
359
  profitTokenAmount = totalProfit / divisor;
269
360
  }
270
361
  // ✅ ERC20 购买:获取代币利润等值的原生代币(BNB)报价
@@ -281,8 +372,10 @@ export async function batchBuyWithBundleMerkle(params) {
281
372
  populateBuyTransactionsWithQuote(buyers, FLAP_PORTAL_ADDRESSES[chain], tokenAddress, adjustedFundsList, inputToken, useNativeToken),
282
373
  presetNonces && presetNonces.length === buyers.length
283
374
  ? adjustNoncesForProfit(presetNonces) // ✅ 调整 nonces 避免冲突
284
- : allocateBuyerNonces(buyers, extractProfit, maxFundsIndex, nativeProfitAmount, nonceManager),
375
+ : allocateBuyerNonces(buyers, extractProfit, maxFundsIndex, nativeProfitAmount, nonceManager)
285
376
  ]);
377
+ if (presetNonces) {
378
+ }
286
379
  // ✅ 贿赂交易放在首位(提高 BlockRazor 打包优先级)
287
380
  const bribeAmount = getBribeAmount(config);
288
381
  const bribeTxs = [];
@@ -295,7 +388,7 @@ export async function batchBuyWithBundleMerkle(params) {
295
388
  gasPrice,
296
389
  gasLimit: GAS_LIMITS.BRIBE,
297
390
  chainId,
298
- type: getTxType(config),
391
+ type: getTxType(config)
299
392
  });
300
393
  bribeTxs.push(bribeTx);
301
394
  // 调整 maxFundsIndex 钱包的 nonce(买入交易 +1)
@@ -310,18 +403,20 @@ export async function batchBuyWithBundleMerkle(params) {
310
403
  chainId,
311
404
  config,
312
405
  fundsList: adjustedFundsList, // ✅ 使用调整后的金额
313
- useNativeToken, // ✅ USDT 购买时 value=0,BNB 购买时 value=金额
406
+ useNativeToken // ✅ USDT 购买时 value=0,BNB 购买时 value=金额
314
407
  });
315
408
  // ✅ 利润多跳转账
316
409
  const profitTxs = [];
317
410
  let profitHopWallets;
318
411
  // ✅ 检查是否使用分布式利润模式
319
- const profitMode = config.profitMode ?? 'single';
412
+ const profitMode = config.profitMode || 'single';
413
+ console.log('🔧 [SDK batchBuyWithBundleMerkle] config.profitMode:', config.profitMode, '-> resolved:', profitMode, 'wallets:', buyers.length);
320
414
  if (extractProfit && nativeProfitAmount > 0n) {
321
415
  if (profitMode === 'distributed') {
322
416
  // ✅ 分布式模式:每个钱包独立扣除自己的利润,每个都有独立的多跳
323
417
  // 最多支持 12 个钱包(12 交易 + 36 多跳 + 1 贿赂 = 49 笔)
324
418
  const MAX_DISTRIBUTED_WALLETS = 12;
419
+ console.log('🔧 [SDK] 使用分布式利润模式,钱包数:', buyers.length);
325
420
  if (buyers.length > MAX_DISTRIBUTED_WALLETS) {
326
421
  throw new Error(`分布式利润模式最多支持 ${MAX_DISTRIBUTED_WALLETS} 个钱包,当前 ${buyers.length} 个`);
327
422
  }
@@ -331,7 +426,9 @@ export async function batchBuyWithBundleMerkle(params) {
331
426
  for (let i = 0; i < buyers.length; i++) {
332
427
  const walletOriginalAmount = originalAmounts[i];
333
428
  // 按比例计算该钱包应承担的利润
334
- const walletProfit = totalBuyAmount > 0n ? (nativeProfitAmount * walletOriginalAmount) / totalBuyAmount : 0n;
429
+ const walletProfit = totalBuyAmount > 0n
430
+ ? (nativeProfitAmount * walletOriginalAmount) / totalBuyAmount
431
+ : 0n;
335
432
  perWalletProfits.push(walletProfit);
336
433
  }
337
434
  // 为每个钱包生成独立的利润多跳交易
@@ -348,7 +445,7 @@ export async function batchBuyWithBundleMerkle(params) {
348
445
  gasPrice,
349
446
  chainId,
350
447
  txType: getTxType(config),
351
- startNonce: profitNonce,
448
+ startNonce: profitNonce
352
449
  });
353
450
  profitTxs.push(...profitHopResult.signedTransactions);
354
451
  if (profitHopResult.hopWallets) {
@@ -370,7 +467,7 @@ export async function batchBuyWithBundleMerkle(params) {
370
467
  gasPrice,
371
468
  chainId,
372
469
  txType: getTxType(config),
373
- startNonce: profitNonce,
470
+ startNonce: profitNonce
374
471
  });
375
472
  profitTxs.push(...profitHopResult.signedTransactions);
376
473
  profitHopWallets = profitHopResult.hopWallets;
@@ -385,7 +482,7 @@ export async function batchBuyWithBundleMerkle(params) {
385
482
  metadata: {
386
483
  ...buildProfitMetadata(extractProfit, totalBuyAmount, nativeProfitAmount, buyers.length),
387
484
  profitMode, // ✅ 返回使用的利润模式
388
- },
485
+ }
389
486
  };
390
487
  }
391
488
  /**
@@ -400,22 +497,23 @@ export async function batchSellWithBundleMerkle(params) {
400
497
  }
401
498
  const { provider, chainId } = createChainContext(chain, config.rpcUrl);
402
499
  const nonceManager = new NonceManager(provider);
500
+ const signedTxs = [];
403
501
  const wallets = createWallets(privateKeys, provider);
404
- const amountsWei = sellAmounts.map((a) => ethers.parseUnits(a, 18));
502
+ const amountsWei = sellAmounts.map(a => ethers.parseUnits(a, 18));
405
503
  const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
406
504
  const readOnlyPortal = new ethers.Contract(portalAddr, PORTAL_ABI, provider);
407
505
  const gasLimits = buildGasLimitList(wallets.length, config);
408
- const portals = wallets.map((w) => new ethers.Contract(portalAddr, PORTAL_ABI, w));
506
+ const portals = wallets.map(w => new ethers.Contract(portalAddr, PORTAL_ABI, w));
409
507
  // ✅ 确定 outputToken:如果传入了 quoteToken 且非零地址,则使用它;否则使用零地址(原生代币)
410
508
  const outputToken = quoteToken && quoteToken !== ZERO_ADDRESS ? quoteToken : ZERO_ADDRESS;
411
509
  const useNativeOutput = outputToken === ZERO_ADDRESS;
412
510
  // ✅ 优化:如果前端传入了 nonces,直接使用(跳过 RPC 调用)
413
511
  const presetNonces = config.nonces;
414
- const extractProfit = shouldExtractProfit();
512
+ const extractProfit = shouldExtractProfit(config);
415
513
  // ✅ 并行执行 gasPrice 和 quoteSellOutputs(Multicall3)
416
514
  const [gasPrice, quotedOutputs] = await Promise.all([
417
515
  resolveGasPrice(provider, config),
418
- quoteSellOutputsWithQuote(readOnlyPortal, tokenAddress, amountsWei, outputToken),
516
+ quoteSellOutputsWithQuote(readOnlyPortal, tokenAddress, amountsWei, outputToken)
419
517
  ]);
420
518
  // ✅ 计算利润和 maxRevenueIndex(用于 nonce 分配)
421
519
  let totalTokenProfit = 0n;
@@ -425,7 +523,7 @@ export async function batchSellWithBundleMerkle(params) {
425
523
  for (let i = 0; i < wallets.length; i++) {
426
524
  const quoted = quotedOutputs[i];
427
525
  if (quoted > 0n) {
428
- const { profit } = calculateProfit(quoted);
526
+ const { profit } = calculateProfit(quoted, config);
429
527
  totalTokenProfit += profit;
430
528
  if (quoted > maxRevenue) {
431
529
  maxRevenue = quoted;
@@ -457,7 +555,9 @@ export async function batchSellWithBundleMerkle(params) {
457
555
  const maxRevenueNonces = await nonceManager.getNextNonceBatch(wallets[maxRevenueIndex], maxRevenueNonceCount);
458
556
  // 其他钱包各需要 1 个 nonce
459
557
  const otherWallets = wallets.filter((_, i) => i !== maxRevenueIndex);
460
- const otherNonces = otherWallets.length > 0 ? await nonceManager.getNextNoncesForWallets(otherWallets) : [];
558
+ const otherNonces = otherWallets.length > 0
559
+ ? await nonceManager.getNextNoncesForWallets(otherWallets)
560
+ : [];
461
561
  // 组装最终的 nonces 数组(保持原顺序)
462
562
  nonces = [];
463
563
  let otherIdx = 0;
@@ -488,7 +588,7 @@ export async function batchSellWithBundleMerkle(params) {
488
588
  outputToken, // ✅ 使用动态 outputToken
489
589
  inputAmount: amountsWei[i],
490
590
  minOutputAmount: minOuts[i],
491
- permitData: '0x',
591
+ permitData: '0x'
492
592
  })));
493
593
  // ✅ 贿赂交易放在首位
494
594
  const bribeTxs = [];
@@ -500,7 +600,7 @@ export async function batchSellWithBundleMerkle(params) {
500
600
  gasPrice,
501
601
  gasLimit: GAS_LIMITS.BRIBE,
502
602
  chainId,
503
- type: getTxType(config),
603
+ type: getTxType(config)
504
604
  });
505
605
  bribeTxs.push(bribeTx);
506
606
  }
@@ -514,13 +614,14 @@ export async function batchSellWithBundleMerkle(params) {
514
614
  gasPrice,
515
615
  chainId,
516
616
  type: getTxType(config),
517
- value: 0n, // ✅ 卖出交易不发送原生代币
617
+ value: 0n // ✅ 卖出交易不发送原生代币
518
618
  })));
519
619
  // ✅ 利润多跳转账
520
620
  const profitTxs = [];
521
621
  let profitHopWallets;
522
622
  // ✅ 检查是否使用分布式利润模式
523
- const profitMode = config.profitMode ?? 'single';
623
+ const profitMode = config.profitMode || 'single';
624
+ console.log('🔧 [SDK batchSellWithBundleMerkle] config.profitMode:', config.profitMode, '-> resolved:', profitMode, 'wallets:', wallets.length);
524
625
  if (needProfitTx) {
525
626
  // ERC20 输出时:获取代币利润等值的原生代币(BNB)报价
526
627
  let totalNativeProfitAmount = totalTokenProfit;
@@ -554,7 +655,7 @@ export async function batchSellWithBundleMerkle(params) {
554
655
  gasPrice,
555
656
  chainId,
556
657
  txType: getTxType(config),
557
- startNonce: walletProfitNonce,
658
+ startNonce: walletProfitNonce
558
659
  });
559
660
  profitTxs.push(...profitHopResult.signedTransactions);
560
661
  if (profitHopResult.hopWallets) {
@@ -576,7 +677,7 @@ export async function batchSellWithBundleMerkle(params) {
576
677
  gasPrice,
577
678
  chainId,
578
679
  txType: getTxType(config),
579
- startNonce: profitNonce,
680
+ startNonce: profitNonce
580
681
  });
581
682
  profitTxs.push(...profitHopResult.signedTransactions);
582
683
  profitHopWallets = profitHopResult.hopWallets;
@@ -592,7 +693,7 @@ export async function batchSellWithBundleMerkle(params) {
592
693
  metadata: {
593
694
  profitMode, // ✅ 返回使用的利润模式
594
695
  totalProfit: totalTokenProfit.toString(),
595
- },
696
+ }
596
697
  };
597
698
  }
598
699
  // ✅ Provider 缓存(复用连接,减少初始化开销)
@@ -613,27 +714,29 @@ function createChainContext(chain, rpcUrl) {
613
714
  return { chainId, provider };
614
715
  }
615
716
  async function resolveGasPrice(provider, config) {
616
- if ('gasPrice' in config && config.gasPrice !== undefined) {
617
- return config.gasPrice;
717
+ // 优化:如果前端传入了 gasPrice,直接使用(跳过 RPC 调用)
718
+ if (config.gasPrice !== undefined) {
719
+ const gasPrice = config.gasPrice;
720
+ return gasPrice;
618
721
  }
619
722
  return await getOptimizedGasPrice(provider, getGasPriceConfig(config));
620
723
  }
621
724
  function createWallets(privateKeys, provider) {
622
- return privateKeys.map((key) => new Wallet(key, provider));
725
+ return privateKeys.map(key => new Wallet(key, provider));
623
726
  }
624
727
  function analyzeBuyFunds(buyAmounts, config, extractProfit) {
625
728
  const result = {
626
729
  fundsList: [],
627
730
  originalAmounts: [],
628
731
  totalBuyAmount: 0n,
629
- totalProfit: 0n,
732
+ totalProfit: 0n
630
733
  };
631
- buyAmounts.forEach((amount) => {
734
+ buyAmounts.forEach(amount => {
632
735
  const originalAmount = ethers.parseEther(amount);
633
736
  result.originalAmounts.push(originalAmount);
634
737
  result.totalBuyAmount += originalAmount;
635
738
  if (extractProfit) {
636
- const { remaining, profit } = calculateProfit(originalAmount);
739
+ const { remaining, profit } = calculateProfit(originalAmount, config);
637
740
  result.totalProfit += profit;
638
741
  result.fundsList.push(remaining);
639
742
  }
@@ -662,13 +765,13 @@ function findMaxIndex(values) {
662
765
  * 当 inputToken 为非零地址(如 USDC)时,value 为 0
663
766
  */
664
767
  async function populateBuyTransactionsWithQuote(buyers, portalAddr, tokenAddress, fundsList, inputToken, useNativeToken) {
665
- const portals = buyers.map((wallet) => new ethers.Contract(portalAddr, PORTAL_ABI, wallet));
768
+ const portals = buyers.map(wallet => new ethers.Contract(portalAddr, PORTAL_ABI, wallet));
666
769
  return await Promise.all(portals.map((portal, i) => portal.swapExactInput.populateTransaction({
667
770
  inputToken,
668
771
  outputToken: tokenAddress,
669
772
  inputAmount: fundsList[i],
670
773
  minOutputAmount: 0n,
671
- permitData: '0x',
774
+ permitData: '0x'
672
775
  },
673
776
  // ✅ 如果使用原生代币,value 为购买金额;否则为 0
674
777
  useNativeToken ? { value: fundsList[i] } : {})));
@@ -705,7 +808,9 @@ async function allocateBuyerNonces(buyers, extractProfit, maxIndex, totalProfit,
705
808
  const maxIndexNonces = await nonceManager.getNextNonceBatch(buyers[maxIndex], 2);
706
809
  // 其他钱包各需要 1 个 nonce
707
810
  const otherBuyers = buyers.filter((_, i) => i !== maxIndex);
708
- const otherNonces = otherBuyers.length > 0 ? await nonceManager.getNextNoncesForWallets(otherBuyers) : [];
811
+ const otherNonces = otherBuyers.length > 0
812
+ ? await nonceManager.getNextNoncesForWallets(otherBuyers)
813
+ : [];
709
814
  // 组装最终的 nonces 数组(保持原顺序)
710
815
  const nonces = [];
711
816
  let otherIdx = 0;
@@ -719,7 +824,7 @@ async function allocateBuyerNonces(buyers, extractProfit, maxIndex, totalProfit,
719
824
  }
720
825
  return nonces;
721
826
  }
722
- async function signBuyTransactions({ unsignedBuys, buyers, nonces, gasLimits, gasPrice, chainId, config, fundsList, useNativeToken = true, // ✅ 默认使用原生代币
827
+ async function signBuyTransactions({ unsignedBuys, buyers, nonces, gasLimits, gasPrice, chainId, config, fundsList, useNativeToken = true // ✅ 默认使用原生代币
723
828
  }) {
724
829
  return await Promise.all(unsignedBuys.map((unsigned, i) => buyers[i].signTransaction({
725
830
  ...unsigned,
@@ -729,7 +834,7 @@ async function signBuyTransactions({ unsignedBuys, buyers, nonces, gasLimits, ga
729
834
  gasPrice,
730
835
  chainId,
731
836
  type: getTxType(config),
732
- value: useNativeToken ? fundsList[i] : 0n, // ✅ 非原生代币时 value 为 0
837
+ value: useNativeToken ? fundsList[i] : 0n // ✅ 非原生代币时 value 为 0
733
838
  })));
734
839
  }
735
840
  function buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, buyerCount) {
@@ -740,7 +845,7 @@ function buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, buyerCo
740
845
  totalBuyAmount: ethers.formatEther(totalBuyAmount),
741
846
  profitAmount: ethers.formatEther(totalProfit),
742
847
  profitRecipient: getProfitRecipient(),
743
- buyerCount,
848
+ buyerCount
744
849
  };
745
850
  }
746
851
  /**
@@ -756,7 +861,7 @@ async function quoteSellOutputsWithQuote(portal, tokenAddress, amountsWei, outpu
756
861
  const result = await portal.quoteExactInput.staticCall({
757
862
  inputToken: tokenAddress,
758
863
  outputToken,
759
- inputAmount: amountsWei[0],
864
+ inputAmount: amountsWei[0]
760
865
  });
761
866
  return [result];
762
867
  }
@@ -769,16 +874,14 @@ async function quoteSellOutputsWithQuote(portal, tokenAddress, amountsWei, outpu
769
874
  const portalIface = new Interface(PORTAL_ABI);
770
875
  const multicall = new Contract(MULTICALL3_ADDRESS, MULTICALL3_ABI, provider);
771
876
  // 构建批量调用
772
- const calls = amountsWei.map((amount) => ({
877
+ const calls = amountsWei.map(amount => ({
773
878
  target: portalAddress,
774
879
  allowFailure: true, // 允许单个失败
775
- callData: portalIface.encodeFunctionData('quoteExactInput', [
776
- {
880
+ callData: portalIface.encodeFunctionData('quoteExactInput', [{
777
881
  inputToken: tokenAddress,
778
882
  outputToken,
779
- inputAmount: amount,
780
- },
781
- ]),
883
+ inputAmount: amount
884
+ }])
782
885
  }));
783
886
  try {
784
887
  const results = await multicall.aggregate3.staticCall(calls);
@@ -802,7 +905,7 @@ async function quoteSellOutputsWithQuote(portal, tokenAddress, amountsWei, outpu
802
905
  return await portal.quoteExactInput.staticCall({
803
906
  inputToken: tokenAddress,
804
907
  outputToken,
805
- inputAmount: amount,
908
+ inputAmount: amount
806
909
  });
807
910
  }
808
911
  catch {