@whetstone-research/doppler-sdk 0.0.23 → 1.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 (425) hide show
  1. package/README.md +556 -229
  2. package/dist/chunk-3LTCKCJC.js +319 -0
  3. package/dist/chunk-3LTCKCJC.js.map +1 -0
  4. package/dist/chunk-PZ5AY32C.js +9 -0
  5. package/dist/{chunk-3PNCB4W5.js.map → chunk-PZ5AY32C.js.map} +1 -1
  6. package/dist/chunk-RO6R66OM.js +974 -0
  7. package/dist/chunk-RO6R66OM.js.map +1 -0
  8. package/dist/evm/index.d.ts +8533 -0
  9. package/dist/evm/index.js +15055 -0
  10. package/dist/evm/index.js.map +1 -0
  11. package/dist/oracle-BSvZ6pxp.d.ts +820 -0
  12. package/dist/pda-RVIHNLRP.js +4 -0
  13. package/dist/pda-RVIHNLRP.js.map +1 -0
  14. package/dist/solana/index.d.ts +2495 -0
  15. package/dist/solana/index.js +2209 -0
  16. package/dist/solana/index.js.map +1 -0
  17. package/dist/solana/react/index.d.ts +1046 -0
  18. package/dist/solana/react/index.js +1436 -0
  19. package/dist/solana/react/index.js.map +1 -0
  20. package/package.json +37 -21
  21. package/dist/DopplerSDK.d.mts +0 -94
  22. package/dist/DopplerSDK.d.ts +0 -94
  23. package/dist/DopplerSDK.js +0 -51
  24. package/dist/DopplerSDK.js.map +0 -1
  25. package/dist/DopplerSDK.mjs +0 -42
  26. package/dist/DopplerSDK.mjs.map +0 -1
  27. package/dist/abis/bytecodes/derc20.d.mts +0 -3
  28. package/dist/abis/bytecodes/derc20.d.ts +0 -3
  29. package/dist/abis/bytecodes/derc20.js +0 -9
  30. package/dist/abis/bytecodes/derc20.js.map +0 -1
  31. package/dist/abis/bytecodes/derc20.mjs +0 -3
  32. package/dist/abis/bytecodes/derc20.mjs.map +0 -1
  33. package/dist/abis/bytecodes/derc2080.d.mts +0 -3
  34. package/dist/abis/bytecodes/derc2080.d.ts +0 -3
  35. package/dist/abis/bytecodes/derc2080.js +0 -9
  36. package/dist/abis/bytecodes/derc2080.js.map +0 -1
  37. package/dist/abis/bytecodes/derc2080.mjs +0 -3
  38. package/dist/abis/bytecodes/derc2080.mjs.map +0 -1
  39. package/dist/abis/bytecodes/doppler.d.mts +0 -3
  40. package/dist/abis/bytecodes/doppler.d.ts +0 -3
  41. package/dist/abis/bytecodes/doppler.js +0 -9
  42. package/dist/abis/bytecodes/doppler.js.map +0 -1
  43. package/dist/abis/bytecodes/doppler.mjs +0 -3
  44. package/dist/abis/bytecodes/doppler.mjs.map +0 -1
  45. package/dist/abis/bytecodes/dopplerDN404.d.mts +0 -3
  46. package/dist/abis/bytecodes/dopplerDN404.d.ts +0 -3
  47. package/dist/abis/bytecodes/dopplerDN404.js +0 -9
  48. package/dist/abis/bytecodes/dopplerDN404.js.map +0 -1
  49. package/dist/abis/bytecodes/dopplerDN404.mjs +0 -3
  50. package/dist/abis/bytecodes/dopplerDN404.mjs.map +0 -1
  51. package/dist/abis/bytecodes/stateView.d.mts +0 -3
  52. package/dist/abis/bytecodes/stateView.d.ts +0 -3
  53. package/dist/abis/bytecodes/stateView.js +0 -9
  54. package/dist/abis/bytecodes/stateView.js.map +0 -1
  55. package/dist/abis/bytecodes/stateView.mjs +0 -3
  56. package/dist/abis/bytecodes/stateView.mjs.map +0 -1
  57. package/dist/abis/bytecodes.d.mts +0 -5
  58. package/dist/abis/bytecodes.d.ts +0 -5
  59. package/dist/abis/bytecodes.js +0 -33
  60. package/dist/abis/bytecodes.js.map +0 -1
  61. package/dist/abis/bytecodes.mjs +0 -8
  62. package/dist/abis/bytecodes.mjs.map +0 -1
  63. package/dist/abis/index.d.mts +0 -3460
  64. package/dist/abis/index.d.ts +0 -3460
  65. package/dist/abis/index.js +0 -122
  66. package/dist/abis/index.js.map +0 -1
  67. package/dist/abis/index.mjs +0 -9
  68. package/dist/abis/index.mjs.map +0 -1
  69. package/dist/addresses.d.mts +0 -65
  70. package/dist/addresses.d.ts +0 -65
  71. package/dist/addresses.js +0 -29
  72. package/dist/addresses.js.map +0 -1
  73. package/dist/addresses.mjs +0 -4
  74. package/dist/addresses.mjs.map +0 -1
  75. package/dist/builders/DynamicAuctionBuilder.d.mts +0 -138
  76. package/dist/builders/DynamicAuctionBuilder.d.ts +0 -138
  77. package/dist/builders/DynamicAuctionBuilder.js +0 -35
  78. package/dist/builders/DynamicAuctionBuilder.js.map +0 -1
  79. package/dist/builders/DynamicAuctionBuilder.mjs +0 -26
  80. package/dist/builders/DynamicAuctionBuilder.mjs.map +0 -1
  81. package/dist/builders/MulticurveBuilder.d.mts +0 -183
  82. package/dist/builders/MulticurveBuilder.d.ts +0 -183
  83. package/dist/builders/MulticurveBuilder.js +0 -35
  84. package/dist/builders/MulticurveBuilder.js.map +0 -1
  85. package/dist/builders/MulticurveBuilder.mjs +0 -26
  86. package/dist/builders/MulticurveBuilder.mjs.map +0 -1
  87. package/dist/builders/StaticAuctionBuilder.d.mts +0 -131
  88. package/dist/builders/StaticAuctionBuilder.d.ts +0 -131
  89. package/dist/builders/StaticAuctionBuilder.js +0 -35
  90. package/dist/builders/StaticAuctionBuilder.js.map +0 -1
  91. package/dist/builders/StaticAuctionBuilder.mjs +0 -26
  92. package/dist/builders/StaticAuctionBuilder.mjs.map +0 -1
  93. package/dist/builders/index.d.mts +0 -8
  94. package/dist/builders/index.d.ts +0 -8
  95. package/dist/builders/index.js +0 -62
  96. package/dist/builders/index.js.map +0 -1
  97. package/dist/builders/index.mjs +0 -29
  98. package/dist/builders/index.mjs.map +0 -1
  99. package/dist/builders/shared.d.mts +0 -115
  100. package/dist/builders/shared.d.ts +0 -115
  101. package/dist/builders/shared.js +0 -45
  102. package/dist/builders/shared.js.map +0 -1
  103. package/dist/builders/shared.mjs +0 -24
  104. package/dist/builders/shared.mjs.map +0 -1
  105. package/dist/chunk-25GEBO3B.mjs +0 -219
  106. package/dist/chunk-25GEBO3B.mjs.map +0 -1
  107. package/dist/chunk-3MVW6UIW.js +0 -2294
  108. package/dist/chunk-3MVW6UIW.js.map +0 -1
  109. package/dist/chunk-3NMGCQJ4.mjs +0 -6
  110. package/dist/chunk-3NMGCQJ4.mjs.map +0 -1
  111. package/dist/chunk-3PNCB4W5.js +0 -4
  112. package/dist/chunk-4VWQNNNW.js +0 -233
  113. package/dist/chunk-4VWQNNNW.js.map +0 -1
  114. package/dist/chunk-4XN6DQBW.js +0 -4
  115. package/dist/chunk-4XN6DQBW.js.map +0 -1
  116. package/dist/chunk-5TQOT6CW.js +0 -8
  117. package/dist/chunk-5TQOT6CW.js.map +0 -1
  118. package/dist/chunk-6BQY5EPB.js +0 -144
  119. package/dist/chunk-6BQY5EPB.js.map +0 -1
  120. package/dist/chunk-6H6X3VTZ.js +0 -18
  121. package/dist/chunk-6H6X3VTZ.js.map +0 -1
  122. package/dist/chunk-6UHDSD42.js +0 -2585
  123. package/dist/chunk-6UHDSD42.js.map +0 -1
  124. package/dist/chunk-7CAAI5DL.js +0 -273
  125. package/dist/chunk-7CAAI5DL.js.map +0 -1
  126. package/dist/chunk-7M57PU6V.js +0 -28
  127. package/dist/chunk-7M57PU6V.js.map +0 -1
  128. package/dist/chunk-7P2SPZC7.mjs +0 -2583
  129. package/dist/chunk-7P2SPZC7.mjs.map +0 -1
  130. package/dist/chunk-7ZUV6WPX.mjs +0 -3
  131. package/dist/chunk-7ZUV6WPX.mjs.map +0 -1
  132. package/dist/chunk-ABT6AT7C.mjs +0 -16
  133. package/dist/chunk-ABT6AT7C.mjs.map +0 -1
  134. package/dist/chunk-C6MH7HYT.mjs +0 -138
  135. package/dist/chunk-C6MH7HYT.mjs.map +0 -1
  136. package/dist/chunk-CATH4QRQ.mjs +0 -141
  137. package/dist/chunk-CATH4QRQ.mjs.map +0 -1
  138. package/dist/chunk-CFAAYL5M.mjs +0 -26
  139. package/dist/chunk-CFAAYL5M.mjs.map +0 -1
  140. package/dist/chunk-CMNJZKTM.js +0 -140
  141. package/dist/chunk-CMNJZKTM.js.map +0 -1
  142. package/dist/chunk-CWTGQAOG.mjs +0 -72
  143. package/dist/chunk-CWTGQAOG.mjs.map +0 -1
  144. package/dist/chunk-DNB3T5P2.js +0 -269
  145. package/dist/chunk-DNB3T5P2.js.map +0 -1
  146. package/dist/chunk-DOUF6NON.mjs +0 -3
  147. package/dist/chunk-DOUF6NON.mjs.map +0 -1
  148. package/dist/chunk-DSYPZETD.js +0 -4
  149. package/dist/chunk-DSYPZETD.js.map +0 -1
  150. package/dist/chunk-E2NF4AQB.mjs +0 -2271
  151. package/dist/chunk-E2NF4AQB.mjs.map +0 -1
  152. package/dist/chunk-EH3V2BJF.js +0 -592
  153. package/dist/chunk-EH3V2BJF.js.map +0 -1
  154. package/dist/chunk-EIXUJANI.mjs +0 -590
  155. package/dist/chunk-EIXUJANI.mjs.map +0 -1
  156. package/dist/chunk-FFV6DMPA.mjs +0 -263
  157. package/dist/chunk-FFV6DMPA.mjs.map +0 -1
  158. package/dist/chunk-FLFYAWSS.mjs +0 -238
  159. package/dist/chunk-FLFYAWSS.mjs.map +0 -1
  160. package/dist/chunk-FNUBKONK.js +0 -291
  161. package/dist/chunk-FNUBKONK.js.map +0 -1
  162. package/dist/chunk-FOESYJP3.mjs +0 -3
  163. package/dist/chunk-FOESYJP3.mjs.map +0 -1
  164. package/dist/chunk-FTRCBE3J.js +0 -320
  165. package/dist/chunk-FTRCBE3J.js.map +0 -1
  166. package/dist/chunk-FZ4FIWCR.js +0 -240
  167. package/dist/chunk-FZ4FIWCR.js.map +0 -1
  168. package/dist/chunk-GDODJJ7D.mjs +0 -36
  169. package/dist/chunk-GDODJJ7D.mjs.map +0 -1
  170. package/dist/chunk-GSBQIVME.mjs +0 -278
  171. package/dist/chunk-GSBQIVME.mjs.map +0 -1
  172. package/dist/chunk-GSTY3GO7.mjs +0 -40
  173. package/dist/chunk-GSTY3GO7.mjs.map +0 -1
  174. package/dist/chunk-H3B54PFV.mjs +0 -17
  175. package/dist/chunk-H3B54PFV.mjs.map +0 -1
  176. package/dist/chunk-H7WPK5CR.js +0 -297
  177. package/dist/chunk-H7WPK5CR.js.map +0 -1
  178. package/dist/chunk-HJFVRV47.js +0 -120
  179. package/dist/chunk-HJFVRV47.js.map +0 -1
  180. package/dist/chunk-HL7ZAAD4.mjs +0 -375
  181. package/dist/chunk-HL7ZAAD4.mjs.map +0 -1
  182. package/dist/chunk-IWJOPXYN.mjs +0 -96
  183. package/dist/chunk-IWJOPXYN.mjs.map +0 -1
  184. package/dist/chunk-J62YDWIK.js +0 -8
  185. package/dist/chunk-J62YDWIK.js.map +0 -1
  186. package/dist/chunk-JB5XXPLL.js +0 -377
  187. package/dist/chunk-JB5XXPLL.js.map +0 -1
  188. package/dist/chunk-JIKAD4YL.js +0 -4
  189. package/dist/chunk-JIKAD4YL.js.map +0 -1
  190. package/dist/chunk-KAZQJ24E.mjs +0 -59
  191. package/dist/chunk-KAZQJ24E.mjs.map +0 -1
  192. package/dist/chunk-KHUE77HC.js +0 -81
  193. package/dist/chunk-KHUE77HC.js.map +0 -1
  194. package/dist/chunk-KOAC3BBP.mjs +0 -11
  195. package/dist/chunk-KOAC3BBP.mjs.map +0 -1
  196. package/dist/chunk-OHA5KJ2M.mjs +0 -6
  197. package/dist/chunk-OHA5KJ2M.mjs.map +0 -1
  198. package/dist/chunk-OX5CESVM.js +0 -40
  199. package/dist/chunk-OX5CESVM.js.map +0 -1
  200. package/dist/chunk-P25HBGP5.mjs +0 -3
  201. package/dist/chunk-P25HBGP5.mjs.map +0 -1
  202. package/dist/chunk-P7CHGWY7.js +0 -4
  203. package/dist/chunk-P7CHGWY7.js.map +0 -1
  204. package/dist/chunk-QAPQGDWK.js +0 -8
  205. package/dist/chunk-QAPQGDWK.js.map +0 -1
  206. package/dist/chunk-QOGBOT2M.mjs +0 -328
  207. package/dist/chunk-QOGBOT2M.mjs.map +0 -1
  208. package/dist/chunk-QRTABC4Z.js +0 -8
  209. package/dist/chunk-QRTABC4Z.js.map +0 -1
  210. package/dist/chunk-QSQGLWNY.mjs +0 -3
  211. package/dist/chunk-QSQGLWNY.mjs.map +0 -1
  212. package/dist/chunk-RI6SDMER.mjs +0 -295
  213. package/dist/chunk-RI6SDMER.mjs.map +0 -1
  214. package/dist/chunk-RIIVW6TQ.mjs +0 -267
  215. package/dist/chunk-RIIVW6TQ.mjs.map +0 -1
  216. package/dist/chunk-RV64M4Q6.mjs +0 -3
  217. package/dist/chunk-RV64M4Q6.mjs.map +0 -1
  218. package/dist/chunk-RXUJ4DUB.js +0 -330
  219. package/dist/chunk-RXUJ4DUB.js.map +0 -1
  220. package/dist/chunk-SD7BHT2F.mjs +0 -3
  221. package/dist/chunk-SD7BHT2F.mjs.map +0 -1
  222. package/dist/chunk-SWWLOD7Q.mjs +0 -6
  223. package/dist/chunk-SWWLOD7Q.mjs.map +0 -1
  224. package/dist/chunk-TIGHBA37.js +0 -143
  225. package/dist/chunk-TIGHBA37.js.map +0 -1
  226. package/dist/chunk-TLEVIIUE.mjs +0 -34
  227. package/dist/chunk-TLEVIIUE.mjs.map +0 -1
  228. package/dist/chunk-U3GOWK6J.mjs +0 -6
  229. package/dist/chunk-U3GOWK6J.mjs.map +0 -1
  230. package/dist/chunk-UPVKABAV.js +0 -19
  231. package/dist/chunk-UPVKABAV.js.map +0 -1
  232. package/dist/chunk-VCX6FG3E.mjs +0 -318
  233. package/dist/chunk-VCX6FG3E.mjs.map +0 -1
  234. package/dist/chunk-VEIVYUYF.js +0 -4
  235. package/dist/chunk-VEIVYUYF.js.map +0 -1
  236. package/dist/chunk-VYSOAGRU.mjs +0 -6
  237. package/dist/chunk-VYSOAGRU.mjs.map +0 -1
  238. package/dist/chunk-WJBJARLJ.js +0 -38
  239. package/dist/chunk-WJBJARLJ.js.map +0 -1
  240. package/dist/chunk-WNUB3UTT.js +0 -241
  241. package/dist/chunk-WNUB3UTT.js.map +0 -1
  242. package/dist/chunk-WQHTNL5L.js +0 -4
  243. package/dist/chunk-WQHTNL5L.js.map +0 -1
  244. package/dist/chunk-X3UMAHOJ.js +0 -4
  245. package/dist/chunk-X3UMAHOJ.js.map +0 -1
  246. package/dist/chunk-XMFOZYNI.js +0 -8
  247. package/dist/chunk-XMFOZYNI.js.map +0 -1
  248. package/dist/chunk-XNMXN5SZ.mjs +0 -3
  249. package/dist/chunk-XNMXN5SZ.mjs.map +0 -1
  250. package/dist/chunk-XRYLHTVV.mjs +0 -267
  251. package/dist/chunk-XRYLHTVV.mjs.map +0 -1
  252. package/dist/chunk-XSJTASPK.js +0 -13
  253. package/dist/chunk-XSJTASPK.js.map +0 -1
  254. package/dist/chunk-XT3BAM4H.js +0 -45
  255. package/dist/chunk-XT3BAM4H.js.map +0 -1
  256. package/dist/chunk-YBK6EBA5.mjs +0 -239
  257. package/dist/chunk-YBK6EBA5.mjs.map +0 -1
  258. package/dist/chunk-YFEPTSI2.js +0 -265
  259. package/dist/chunk-YFEPTSI2.js.map +0 -1
  260. package/dist/chunk-YYLD3AJ7.js +0 -61
  261. package/dist/chunk-YYLD3AJ7.js.map +0 -1
  262. package/dist/chunk-ZEDJUNC6.mjs +0 -115
  263. package/dist/chunk-ZEDJUNC6.mjs.map +0 -1
  264. package/dist/constants.d.mts +0 -91
  265. package/dist/constants.d.ts +0 -91
  266. package/dist/constants.js +0 -196
  267. package/dist/constants.js.map +0 -1
  268. package/dist/constants.mjs +0 -3
  269. package/dist/constants.mjs.map +0 -1
  270. package/dist/deployments.generated.d.mts +0 -267
  271. package/dist/deployments.generated.d.ts +0 -267
  272. package/dist/deployments.generated.js +0 -12
  273. package/dist/deployments.generated.js.map +0 -1
  274. package/dist/deployments.generated.mjs +0 -3
  275. package/dist/deployments.generated.mjs.map +0 -1
  276. package/dist/entities/DopplerFactory.d.mts +0 -266
  277. package/dist/entities/DopplerFactory.d.ts +0 -266
  278. package/dist/entities/DopplerFactory.js +0 -33
  279. package/dist/entities/DopplerFactory.js.map +0 -1
  280. package/dist/entities/DopplerFactory.mjs +0 -24
  281. package/dist/entities/DopplerFactory.mjs.map +0 -1
  282. package/dist/entities/auction/DynamicAuction.d.mts +0 -72
  283. package/dist/entities/auction/DynamicAuction.d.ts +0 -72
  284. package/dist/entities/auction/DynamicAuction.js +0 -21
  285. package/dist/entities/auction/DynamicAuction.js.map +0 -1
  286. package/dist/entities/auction/DynamicAuction.mjs +0 -12
  287. package/dist/entities/auction/DynamicAuction.mjs.map +0 -1
  288. package/dist/entities/auction/MulticurvePool.d.mts +0 -74
  289. package/dist/entities/auction/MulticurvePool.d.ts +0 -74
  290. package/dist/entities/auction/MulticurvePool.js +0 -24
  291. package/dist/entities/auction/MulticurvePool.js.map +0 -1
  292. package/dist/entities/auction/MulticurvePool.mjs +0 -15
  293. package/dist/entities/auction/MulticurvePool.mjs.map +0 -1
  294. package/dist/entities/auction/StaticAuction.d.mts +0 -44
  295. package/dist/entities/auction/StaticAuction.d.ts +0 -44
  296. package/dist/entities/auction/StaticAuction.js +0 -21
  297. package/dist/entities/auction/StaticAuction.js.map +0 -1
  298. package/dist/entities/auction/StaticAuction.mjs +0 -12
  299. package/dist/entities/auction/StaticAuction.mjs.map +0 -1
  300. package/dist/entities/auction/index.d.mts +0 -7
  301. package/dist/entities/auction/index.d.ts +0 -7
  302. package/dist/entities/auction/index.js +0 -35
  303. package/dist/entities/auction/index.js.map +0 -1
  304. package/dist/entities/auction/index.mjs +0 -18
  305. package/dist/entities/auction/index.mjs.map +0 -1
  306. package/dist/entities/quoter/Quoter.d.mts +0 -150
  307. package/dist/entities/quoter/Quoter.d.ts +0 -150
  308. package/dist/entities/quoter/Quoter.js +0 -21
  309. package/dist/entities/quoter/Quoter.js.map +0 -1
  310. package/dist/entities/quoter/Quoter.mjs +0 -12
  311. package/dist/entities/quoter/Quoter.mjs.map +0 -1
  312. package/dist/entities/quoter/index.d.mts +0 -5
  313. package/dist/entities/quoter/index.d.ts +0 -5
  314. package/dist/entities/quoter/index.js +0 -22
  315. package/dist/entities/quoter/index.js.map +0 -1
  316. package/dist/entities/quoter/index.mjs +0 -13
  317. package/dist/entities/quoter/index.mjs.map +0 -1
  318. package/dist/entities/token/derc20/Derc20.d.mts +0 -102
  319. package/dist/entities/token/derc20/Derc20.d.ts +0 -102
  320. package/dist/entities/token/derc20/Derc20.js +0 -19
  321. package/dist/entities/token/derc20/Derc20.js.map +0 -1
  322. package/dist/entities/token/derc20/Derc20.mjs +0 -10
  323. package/dist/entities/token/derc20/Derc20.mjs.map +0 -1
  324. package/dist/entities/token/derc20/index.d.mts +0 -5
  325. package/dist/entities/token/derc20/index.d.ts +0 -5
  326. package/dist/entities/token/derc20/index.js +0 -20
  327. package/dist/entities/token/derc20/index.js.map +0 -1
  328. package/dist/entities/token/derc20/index.mjs +0 -11
  329. package/dist/entities/token/derc20/index.mjs.map +0 -1
  330. package/dist/entities/token/eth/Eth.d.mts +0 -54
  331. package/dist/entities/token/eth/Eth.d.ts +0 -54
  332. package/dist/entities/token/eth/Eth.js +0 -12
  333. package/dist/entities/token/eth/Eth.js.map +0 -1
  334. package/dist/entities/token/eth/Eth.mjs +0 -3
  335. package/dist/entities/token/eth/Eth.mjs.map +0 -1
  336. package/dist/entities/token/eth/index.d.mts +0 -5
  337. package/dist/entities/token/eth/index.d.ts +0 -5
  338. package/dist/entities/token/eth/index.js +0 -13
  339. package/dist/entities/token/eth/index.js.map +0 -1
  340. package/dist/entities/token/eth/index.mjs +0 -4
  341. package/dist/entities/token/eth/index.mjs.map +0 -1
  342. package/dist/entities/token/index.d.mts +0 -6
  343. package/dist/entities/token/index.d.ts +0 -6
  344. package/dist/entities/token/index.js +0 -27
  345. package/dist/entities/token/index.js.map +0 -1
  346. package/dist/entities/token/index.mjs +0 -14
  347. package/dist/entities/token/index.mjs.map +0 -1
  348. package/dist/index.d.mts +0 -37
  349. package/dist/index.d.ts +0 -37
  350. package/dist/index.js +0 -565
  351. package/dist/index.js.map +0 -1
  352. package/dist/index.mjs +0 -47
  353. package/dist/index.mjs.map +0 -1
  354. package/dist/types.d.mts +0 -607
  355. package/dist/types.d.ts +0 -607
  356. package/dist/types.js +0 -30
  357. package/dist/types.js.map +0 -1
  358. package/dist/types.mjs +0 -5
  359. package/dist/types.mjs.map +0 -1
  360. package/dist/utils/airlock.d.mts +0 -11
  361. package/dist/utils/airlock.d.ts +0 -11
  362. package/dist/utils/airlock.js +0 -26
  363. package/dist/utils/airlock.js.map +0 -1
  364. package/dist/utils/airlock.mjs +0 -5
  365. package/dist/utils/airlock.mjs.map +0 -1
  366. package/dist/utils/balanceDelta.d.mts +0 -10
  367. package/dist/utils/balanceDelta.d.ts +0 -10
  368. package/dist/utils/balanceDelta.js +0 -12
  369. package/dist/utils/balanceDelta.js.map +0 -1
  370. package/dist/utils/balanceDelta.mjs +0 -3
  371. package/dist/utils/balanceDelta.mjs.map +0 -1
  372. package/dist/utils/computeOptimalGamma.d.mts +0 -7
  373. package/dist/utils/computeOptimalGamma.d.ts +0 -7
  374. package/dist/utils/computeOptimalGamma.js +0 -12
  375. package/dist/utils/computeOptimalGamma.js.map +0 -1
  376. package/dist/utils/computeOptimalGamma.mjs +0 -3
  377. package/dist/utils/computeOptimalGamma.mjs.map +0 -1
  378. package/dist/utils/dopplerHookMigrator.d.mts +0 -11
  379. package/dist/utils/dopplerHookMigrator.d.ts +0 -11
  380. package/dist/utils/dopplerHookMigrator.js +0 -12
  381. package/dist/utils/dopplerHookMigrator.js.map +0 -1
  382. package/dist/utils/dopplerHookMigrator.mjs +0 -3
  383. package/dist/utils/dopplerHookMigrator.mjs.map +0 -1
  384. package/dist/utils/index.d.mts +0 -14
  385. package/dist/utils/index.d.ts +0 -14
  386. package/dist/utils/index.js +0 -195
  387. package/dist/utils/index.js.map +0 -1
  388. package/dist/utils/index.mjs +0 -22
  389. package/dist/utils/index.mjs.map +0 -1
  390. package/dist/utils/isToken0Expected.d.mts +0 -13
  391. package/dist/utils/isToken0Expected.d.ts +0 -13
  392. package/dist/utils/isToken0Expected.js +0 -12
  393. package/dist/utils/isToken0Expected.js.map +0 -1
  394. package/dist/utils/isToken0Expected.mjs +0 -3
  395. package/dist/utils/isToken0Expected.mjs.map +0 -1
  396. package/dist/utils/marketCapHelpers.d.mts +0 -259
  397. package/dist/utils/marketCapHelpers.d.ts +0 -259
  398. package/dist/utils/marketCapHelpers.js +0 -58
  399. package/dist/utils/marketCapHelpers.js.map +0 -1
  400. package/dist/utils/marketCapHelpers.mjs +0 -5
  401. package/dist/utils/marketCapHelpers.mjs.map +0 -1
  402. package/dist/utils/poolKey.d.mts +0 -17
  403. package/dist/utils/poolKey.d.ts +0 -17
  404. package/dist/utils/poolKey.js +0 -12
  405. package/dist/utils/poolKey.js.map +0 -1
  406. package/dist/utils/poolKey.mjs +0 -3
  407. package/dist/utils/poolKey.mjs.map +0 -1
  408. package/dist/utils/priceHelpers.d.mts +0 -86
  409. package/dist/utils/priceHelpers.d.ts +0 -86
  410. package/dist/utils/priceHelpers.js +0 -41
  411. package/dist/utils/priceHelpers.js.map +0 -1
  412. package/dist/utils/priceHelpers.mjs +0 -4
  413. package/dist/utils/priceHelpers.mjs.map +0 -1
  414. package/dist/utils/tickMath.d.mts +0 -72
  415. package/dist/utils/tickMath.d.ts +0 -72
  416. package/dist/utils/tickMath.js +0 -60
  417. package/dist/utils/tickMath.js.map +0 -1
  418. package/dist/utils/tickMath.mjs +0 -3
  419. package/dist/utils/tickMath.mjs.map +0 -1
  420. package/dist/utils/tokenAddressMiner.d.mts +0 -37
  421. package/dist/utils/tokenAddressMiner.d.ts +0 -37
  422. package/dist/utils/tokenAddressMiner.js +0 -19
  423. package/dist/utils/tokenAddressMiner.js.map +0 -1
  424. package/dist/utils/tokenAddressMiner.mjs +0 -10
  425. package/dist/utils/tokenAddressMiner.mjs.map +0 -1
@@ -1,2585 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkUPVKABAV_js = require('./chunk-UPVKABAV.js');
4
- var chunkWJBJARLJ_js = require('./chunk-WJBJARLJ.js');
5
- var chunk6H6X3VTZ_js = require('./chunk-6H6X3VTZ.js');
6
- var chunk4VWQNNNW_js = require('./chunk-4VWQNNNW.js');
7
- var chunk6BQY5EPB_js = require('./chunk-6BQY5EPB.js');
8
- var chunk7CAAI5DL_js = require('./chunk-7CAAI5DL.js');
9
- var chunk3MVW6UIW_js = require('./chunk-3MVW6UIW.js');
10
- var chunkQRTABC4Z_js = require('./chunk-QRTABC4Z.js');
11
- var chunkJ62YDWIK_js = require('./chunk-J62YDWIK.js');
12
- var chunkXMFOZYNI_js = require('./chunk-XMFOZYNI.js');
13
- var chunkQAPQGDWK_js = require('./chunk-QAPQGDWK.js');
14
- var viem = require('viem');
15
-
16
- var MAX_UINT128 = (1n << 128n) - 1n;
17
- var MAX_PROCEEDS_SPLIT_SHARE = chunk6BQY5EPB_js.WAD / 2n;
18
- var TOKEN_FACTORY_80_ADDRESS = "0xf0b5141dd9096254b2ca624dff26024f46087229";
19
- var DopplerFactory = class {
20
- constructor(publicClient, walletClient, chainId) {
21
- this.multicurveBundlerSupport = /* @__PURE__ */ new Map();
22
- this.publicClient = publicClient;
23
- this.walletClient = walletClient;
24
- this.chainId = chainId;
25
- }
26
- /**
27
- * Set a custom migration data encoder function
28
- * @param encoder Custom function to encode migration data
29
- * @returns The factory instance for method chaining
30
- */
31
- withCustomMigrationEncoder(encoder) {
32
- this.customMigrationEncoder = encoder;
33
- return this;
34
- }
35
- async encodeCreateStaticAuctionParams(params) {
36
- this.validateStaticAuctionParams(params);
37
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
38
- const hasBeneficiaries = params.pool.beneficiaries && params.pool.beneficiaries.length > 0;
39
- let poolInitializerData;
40
- if (hasBeneficiaries) {
41
- const sortedBeneficiaries = params.pool.beneficiaries.slice().sort((a, b) => {
42
- const aAddr = a.beneficiary.toLowerCase();
43
- const bAddr = b.beneficiary.toLowerCase();
44
- return aAddr < bAddr ? -1 : aAddr > bAddr ? 1 : 0;
45
- });
46
- poolInitializerData = viem.encodeAbiParameters(
47
- [
48
- {
49
- type: "tuple",
50
- components: [
51
- { type: "uint24", name: "fee" },
52
- { type: "int24", name: "tickLower" },
53
- { type: "int24", name: "tickUpper" },
54
- { type: "uint16", name: "numPositions" },
55
- { type: "uint256", name: "maxShareToBeSold" },
56
- {
57
- type: "tuple[]",
58
- name: "beneficiaries",
59
- components: [
60
- { type: "address", name: "beneficiary" },
61
- { type: "uint96", name: "shares" }
62
- ]
63
- }
64
- ]
65
- }
66
- ],
67
- [
68
- {
69
- fee: params.pool.fee,
70
- tickLower: params.pool.startTick,
71
- tickUpper: params.pool.endTick,
72
- numPositions: params.pool.numPositions ?? chunk6BQY5EPB_js.DEFAULT_V3_NUM_POSITIONS,
73
- maxShareToBeSold: params.pool.maxShareToBeSold ?? chunk6BQY5EPB_js.DEFAULT_V3_MAX_SHARE_TO_BE_SOLD,
74
- beneficiaries: sortedBeneficiaries.map((b) => ({
75
- beneficiary: b.beneficiary,
76
- shares: b.shares
77
- }))
78
- }
79
- ]
80
- );
81
- } else {
82
- poolInitializerData = viem.encodeAbiParameters(
83
- [
84
- {
85
- type: "tuple",
86
- components: [
87
- { type: "uint24", name: "fee" },
88
- { type: "int24", name: "tickLower" },
89
- { type: "int24", name: "tickUpper" },
90
- { type: "uint16", name: "numPositions" },
91
- { type: "uint256", name: "maxShareToBeSold" }
92
- ]
93
- }
94
- ],
95
- [
96
- {
97
- fee: params.pool.fee,
98
- tickLower: params.pool.startTick,
99
- tickUpper: params.pool.endTick,
100
- numPositions: params.pool.numPositions ?? chunk6BQY5EPB_js.DEFAULT_V3_NUM_POSITIONS,
101
- maxShareToBeSold: params.pool.maxShareToBeSold ?? chunk6BQY5EPB_js.DEFAULT_V3_MAX_SHARE_TO_BE_SOLD
102
- }
103
- ]
104
- );
105
- }
106
- const liquidityMigratorData = this.encodeMigrationData(params.migration, {
107
- numeraire: params.sale.numeraire,
108
- overrides: params.modules
109
- });
110
- let tokenFactoryData;
111
- if (this.isDoppler404Token(params.token)) {
112
- const token404 = params.token;
113
- const baseURI = token404.baseURI;
114
- const unit = token404.unit !== void 0 ? BigInt(token404.unit) : 1000n;
115
- tokenFactoryData = viem.encodeAbiParameters(
116
- [
117
- { type: "string" },
118
- { type: "string" },
119
- { type: "string" },
120
- { type: "uint256" }
121
- ],
122
- [params.token.name, params.token.symbol, baseURI, unit]
123
- );
124
- } else {
125
- const tokenStd = params.token;
126
- const vestingDuration = params.vesting?.duration ?? BigInt(0);
127
- const yearlyMintRate = tokenStd.yearlyMintRate ?? chunk6BQY5EPB_js.DEFAULT_V4_YEARLY_MINT_RATE;
128
- let vestingRecipients = [];
129
- let vestingAmounts = [];
130
- if (params.vesting) {
131
- if (params.vesting.recipients && params.vesting.amounts) {
132
- vestingRecipients = params.vesting.recipients;
133
- vestingAmounts = params.vesting.amounts;
134
- } else {
135
- vestingRecipients = [params.userAddress];
136
- vestingAmounts = [
137
- params.sale.initialSupply - params.sale.numTokensToSell
138
- ];
139
- }
140
- }
141
- tokenFactoryData = viem.encodeAbiParameters(
142
- [
143
- { type: "string" },
144
- { type: "string" },
145
- { type: "uint256" },
146
- { type: "uint256" },
147
- { type: "address[]" },
148
- { type: "uint256[]" },
149
- { type: "string" }
150
- ],
151
- [
152
- tokenStd.name,
153
- tokenStd.symbol,
154
- yearlyMintRate,
155
- BigInt(vestingDuration),
156
- vestingRecipients,
157
- vestingAmounts,
158
- tokenStd.tokenURI
159
- ]
160
- );
161
- }
162
- const governanceFactoryData = (() => {
163
- if (params.governance.type === "noOp") {
164
- return "0x";
165
- }
166
- if (params.governance.type === "launchpad") {
167
- return viem.encodeAbiParameters(
168
- [{ type: "address" }],
169
- [params.governance.multisig]
170
- );
171
- }
172
- return viem.encodeAbiParameters(
173
- [
174
- { type: "string" },
175
- { type: "uint48" },
176
- { type: "uint32" },
177
- { type: "uint256" }
178
- ],
179
- [
180
- params.token.name,
181
- params.governance.type === "custom" ? params.governance.initialVotingDelay : chunk6BQY5EPB_js.DEFAULT_V3_INITIAL_VOTING_DELAY,
182
- params.governance.type === "custom" ? params.governance.initialVotingPeriod : chunk6BQY5EPB_js.DEFAULT_V3_INITIAL_VOTING_PERIOD,
183
- params.governance.type === "custom" ? params.governance.initialProposalThreshold : chunk6BQY5EPB_js.DEFAULT_V3_INITIAL_PROPOSAL_THRESHOLD
184
- ]
185
- );
186
- })();
187
- const governanceFactoryAddress = (() => {
188
- if (params.governance.type === "noOp") {
189
- const resolved2 = params.modules?.governanceFactory ?? addresses.noOpGovernanceFactory ?? chunk6BQY5EPB_js.ZERO_ADDRESS;
190
- if (!resolved2 || resolved2 === chunk6BQY5EPB_js.ZERO_ADDRESS) {
191
- throw new Error(
192
- "No-op governance requested, but no-op governanceFactory is not configured on this chain. Provide a governanceFactory override or use a supported chain."
193
- );
194
- }
195
- return resolved2;
196
- }
197
- if (params.governance.type === "launchpad") {
198
- const resolved2 = params.modules?.governanceFactory ?? addresses.launchpadGovernanceFactory ?? chunk6BQY5EPB_js.ZERO_ADDRESS;
199
- if (!resolved2 || resolved2 === chunk6BQY5EPB_js.ZERO_ADDRESS) {
200
- throw new Error(
201
- "Launchpad governance requested, but launchpadGovernanceFactory is not configured on this chain. Provide a governanceFactory override or use a supported chain."
202
- );
203
- }
204
- return resolved2;
205
- }
206
- const resolved = params.modules?.governanceFactory ?? addresses.governanceFactory;
207
- if (!resolved || resolved === chunk6BQY5EPB_js.ZERO_ADDRESS) {
208
- throw new Error(
209
- "Standard governance requested but governanceFactory is not deployed on this chain."
210
- );
211
- }
212
- return resolved;
213
- })();
214
- const resolvedTokenFactory = params.modules?.tokenFactory ?? (this.isDoppler404Token(params.token) ? addresses.doppler404Factory : addresses.tokenFactory);
215
- if (!resolvedTokenFactory || resolvedTokenFactory === chunk6BQY5EPB_js.ZERO_ADDRESS) {
216
- throw new Error(
217
- "Token factory address not configured. Provide an explicit address via builder.withTokenFactory(...) or ensure chain config includes a valid factory."
218
- );
219
- }
220
- const baseCreateParams = {
221
- initialSupply: params.sale.initialSupply,
222
- numTokensToSell: params.sale.numTokensToSell,
223
- numeraire: params.sale.numeraire,
224
- tokenFactory: resolvedTokenFactory,
225
- tokenFactoryData,
226
- governanceFactory: governanceFactoryAddress,
227
- governanceFactoryData,
228
- poolInitializer: (() => {
229
- if (hasBeneficiaries) {
230
- const lockableInitializer = params.modules?.lockableV3Initializer ?? addresses.lockableV3Initializer;
231
- if (!lockableInitializer) {
232
- throw new Error(
233
- "Lockable V3 initializer address not configured on this chain. Required when using beneficiaries."
234
- );
235
- }
236
- return lockableInitializer;
237
- }
238
- return params.modules?.v3Initializer ?? addresses.v3Initializer;
239
- })(),
240
- poolInitializerData,
241
- liquidityMigrator: this.getMigratorAddress(
242
- params.migration,
243
- params.modules
244
- ),
245
- liquidityMigratorData,
246
- integrator: params.integrator ?? chunk6BQY5EPB_js.ZERO_ADDRESS
247
- };
248
- const minedCreateParams = await this.mineTokenOrder({
249
- params,
250
- baseCreateParams,
251
- addresses
252
- });
253
- return minedCreateParams;
254
- }
255
- /**
256
- * Simulate a static auction creation and return predicted addresses.
257
- * Useful for pre-buy flows (bundle) to know the token/pool before sending.
258
- */
259
- async simulateCreateStaticAuction(params) {
260
- const createParams = await this.encodeCreateStaticAuctionParams(params);
261
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
262
- const airlockAddress = params.modules?.airlock ?? addresses.airlock;
263
- const { request, result } = await this.publicClient.simulateContract({
264
- address: airlockAddress,
265
- abi: chunk3MVW6UIW_js.airlockAbi,
266
- functionName: "create",
267
- args: [{ ...createParams }],
268
- account: this.walletClient?.account
269
- });
270
- const simResult = result;
271
- const gasEstimate = await this.resolveCreateGasEstimate({
272
- request,
273
- address: airlockAddress,
274
- createParams,
275
- account: this.walletClient?.account ?? params.userAddress
276
- });
277
- if (!simResult || !Array.isArray(simResult) || simResult.length < 2) {
278
- throw new Error("Failed to simulate static auction create");
279
- }
280
- return {
281
- createParams,
282
- asset: simResult[0],
283
- pool: simResult[1],
284
- gasEstimate,
285
- execute: () => this.createStaticAuction(params, { _createParams: createParams })
286
- };
287
- }
288
- /**
289
- * Create a new static auction (using Uniswap V3 for initial liquidity)
290
- * @param params Configuration for the static auction
291
- * @returns The address of the created pool and token
292
- */
293
- async createStaticAuction(params, options) {
294
- const createParams = options?._createParams ?? (await this.simulateCreateStaticAuction(params)).createParams;
295
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
296
- if (!this.walletClient) {
297
- throw new Error("Wallet client required for write operations");
298
- }
299
- const airlockAddress = params.modules?.airlock ?? addresses.airlock;
300
- const { request, result } = await this.publicClient.simulateContract({
301
- address: airlockAddress,
302
- abi: chunk3MVW6UIW_js.airlockAbi,
303
- functionName: "create",
304
- args: [{ ...createParams }],
305
- account: this.walletClient.account
306
- });
307
- const simResult = result;
308
- const gasEstimate = await this.resolveCreateGasEstimate({
309
- request,
310
- address: airlockAddress,
311
- createParams,
312
- account: this.walletClient.account
313
- });
314
- const gasOverride = params.gas ?? gasEstimate ?? chunk6BQY5EPB_js.DEFAULT_CREATE_GAS_LIMIT;
315
- const hash = await this.walletClient.writeContract({
316
- ...request,
317
- gas: gasOverride
318
- });
319
- const receipt = await this.publicClient.waitForTransactionReceipt({ hash, confirmations: 2 });
320
- const actualAddresses = this.extractAddressesFromCreateEvent(receipt);
321
- if (!actualAddresses) {
322
- throw new Error(
323
- "Failed to extract addresses from Create event in transaction logs"
324
- );
325
- }
326
- if (simResult && Array.isArray(simResult) && simResult.length >= 2) {
327
- const simulatedToken = simResult[0];
328
- const simulatedPool = simResult[1];
329
- if (simulatedToken.toLowerCase() !== actualAddresses.tokenAddress.toLowerCase()) {
330
- console.warn(
331
- `[DopplerSDK] Simulation predicted token ${simulatedToken} but actual is ${actualAddresses.tokenAddress}. This may indicate state divergence between simulation and execution.`
332
- );
333
- }
334
- if (simulatedPool.toLowerCase() !== actualAddresses.poolOrHookAddress.toLowerCase()) {
335
- console.warn(
336
- `[DopplerSDK] Simulation predicted pool ${simulatedPool} but actual is ${actualAddresses.poolOrHookAddress}. This may indicate state divergence between simulation and execution.`
337
- );
338
- }
339
- }
340
- return {
341
- tokenAddress: actualAddresses.tokenAddress,
342
- poolAddress: actualAddresses.poolOrHookAddress,
343
- transactionHash: hash
344
- };
345
- }
346
- /**
347
- * Generate a random salt based on user address
348
- */
349
- generateRandomSalt(account) {
350
- const array = new Uint8Array(32);
351
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
352
- crypto.getRandomValues(array);
353
- } else {
354
- const timestamp = Date.now();
355
- const timestampBytes = new Uint8Array(8);
356
- for (let i = 0; i < 8; i++) {
357
- timestampBytes[i] = timestamp >> i * 8 & 255;
358
- }
359
- for (let i = 0; i < 32; i++) {
360
- if (i < 8) {
361
- array[i] = timestampBytes[i];
362
- } else {
363
- array[i] = i;
364
- }
365
- }
366
- }
367
- if (account) {
368
- const addressBytes = account.slice(2).padStart(40, "0");
369
- for (let i = 0; i < 20; i++) {
370
- const addressByte = parseInt(
371
- addressBytes.slice(i * 2, (i + 1) * 2),
372
- 16
373
- );
374
- array[i] ^= addressByte;
375
- }
376
- }
377
- return `0x${Array.from(array).map((b) => b.toString(16).padStart(2, "0")).join("")}`;
378
- }
379
- /**
380
- * Extract actual deployed addresses from Create event logs.
381
- * This is the source of truth - what actually deployed on-chain.
382
- * @param receipt Transaction receipt containing logs
383
- * @returns Token and pool/hook addresses from the Create event, or null if not found
384
- */
385
- extractAddressesFromCreateEvent(receipt) {
386
- const createEvent = receipt.logs.find((log) => {
387
- try {
388
- const decoded2 = viem.decodeEventLog({
389
- abi: chunk3MVW6UIW_js.airlockAbi,
390
- data: log.data,
391
- topics: log.topics
392
- });
393
- return decoded2.eventName === "Create";
394
- } catch {
395
- return false;
396
- }
397
- });
398
- if (!createEvent) return null;
399
- const decoded = viem.decodeEventLog({
400
- abi: chunk3MVW6UIW_js.airlockAbi,
401
- data: createEvent.data,
402
- topics: createEvent.topics
403
- });
404
- if (decoded.eventName === "Create") {
405
- const args = decoded.args;
406
- return { tokenAddress: args.asset, poolOrHookAddress: args.poolOrHook };
407
- }
408
- return null;
409
- }
410
- /**
411
- * Iteratively mine a salt that ensures the newly created token sorts after the numeraire.
412
- * This mirrors the legacy SDK behaviour so tick configuration can assume the numeraire is token0.
413
- */
414
- async mineTokenOrder(args) {
415
- const { params, baseCreateParams, addresses } = args;
416
- const airlockAddress = params.modules?.airlock ?? addresses.airlock;
417
- if (!airlockAddress || airlockAddress === chunk6BQY5EPB_js.ZERO_ADDRESS) {
418
- throw new Error(
419
- "Airlock address not configured. Provide an explicit address via modules.airlock or ensure chain config includes a valid airlock."
420
- );
421
- }
422
- const accountForSimulation = this.walletClient?.account ?? params.userAddress;
423
- const numeraireBigInt = BigInt(params.sale.numeraire);
424
- let attempt = 0n;
425
- const maxAttempts = 256n;
426
- let salt = this.generateRandomSalt(params.userAddress);
427
- while (attempt < maxAttempts) {
428
- const createParams = { ...baseCreateParams, salt };
429
- const { result } = await this.publicClient.simulateContract({
430
- address: airlockAddress,
431
- abi: chunk3MVW6UIW_js.airlockAbi,
432
- functionName: "create",
433
- args: [{ ...createParams }],
434
- account: accountForSimulation
435
- });
436
- const simResult = result;
437
- if (!simResult || !Array.isArray(simResult) || simResult.length < 2) {
438
- throw new Error(
439
- "Failed to simulate static auction create while mining token ordering"
440
- );
441
- }
442
- const tokenAddress = simResult[0];
443
- if (BigInt(tokenAddress) > numeraireBigInt) {
444
- return createParams;
445
- }
446
- attempt += 1n;
447
- const incrementedAccount = viem.toHex(
448
- BigInt(params.userAddress) + attempt
449
- );
450
- salt = this.generateRandomSalt(incrementedAccount);
451
- }
452
- throw new Error(
453
- "Token mining exceeded iteration limit while trying to force token order. Try again or provide a different user address."
454
- );
455
- }
456
- async encodeCreateDynamicAuctionParams(params) {
457
- this.validateDynamicAuctionParams(params);
458
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
459
- const gamma = params.auction.gamma ?? chunkUPVKABAV_js.computeOptimalGamma(
460
- params.auction.startTick,
461
- params.auction.endTick,
462
- params.auction.duration,
463
- params.auction.epochLength,
464
- params.pool.tickSpacing
465
- );
466
- let blockTimestamp;
467
- if (params.blockTimestamp !== void 0) {
468
- blockTimestamp = params.blockTimestamp;
469
- } else {
470
- const latestBlock = await this.publicClient.getBlock({
471
- blockTag: "latest"
472
- });
473
- blockTimestamp = Number(
474
- latestBlock.timestamp
475
- );
476
- }
477
- const startTimeOffset = params.startTimeOffset ?? 30;
478
- const startTime = blockTimestamp + startTimeOffset;
479
- const endTime = blockTimestamp + params.auction.duration + startTimeOffset;
480
- const dopplerData = {
481
- minimumProceeds: params.auction.minProceeds,
482
- maximumProceeds: params.auction.maxProceeds,
483
- startingTime: BigInt(startTime),
484
- endingTime: BigInt(endTime),
485
- startingTick: params.auction.startTick,
486
- endingTick: params.auction.endTick,
487
- epochLength: BigInt(params.auction.epochLength),
488
- gamma,
489
- isToken0: false,
490
- // Will be determined during mining
491
- numPDSlugs: BigInt(params.auction.numPdSlugs ?? chunk6BQY5EPB_js.DEFAULT_PD_SLUGS),
492
- fee: params.pool.fee,
493
- tickSpacing: params.pool.tickSpacing
494
- };
495
- if (this.isDoppler404Token(params.token)) {
496
- if (!addresses.doppler404Factory || addresses.doppler404Factory === chunk6BQY5EPB_js.ZERO_ADDRESS) {
497
- throw new Error(
498
- "Doppler404 factory address not configured for this chain"
499
- );
500
- }
501
- }
502
- const vestingDuration = params.vesting?.duration ?? BigInt(0);
503
- const tokenFactoryData = this.isDoppler404Token(params.token) ? (() => {
504
- const t = params.token;
505
- return {
506
- name: t.name,
507
- symbol: t.symbol,
508
- baseURI: t.baseURI,
509
- unit: t.unit !== void 0 ? BigInt(t.unit) : 1000n
510
- };
511
- })() : (() => {
512
- const t = params.token;
513
- let vestingRecipients = [];
514
- let vestingAmounts = [];
515
- if (params.vesting) {
516
- if (params.vesting.recipients && params.vesting.amounts) {
517
- vestingRecipients = params.vesting.recipients;
518
- vestingAmounts = params.vesting.amounts;
519
- } else {
520
- vestingRecipients = [params.userAddress];
521
- vestingAmounts = [
522
- params.sale.initialSupply - params.sale.numTokensToSell
523
- ];
524
- }
525
- }
526
- return {
527
- name: t.name,
528
- symbol: t.symbol,
529
- initialSupply: params.sale.initialSupply,
530
- airlock: addresses.airlock,
531
- yearlyMintRate: t.yearlyMintRate ?? chunk6BQY5EPB_js.DEFAULT_V4_YEARLY_MINT_RATE,
532
- vestingDuration: BigInt(vestingDuration),
533
- recipients: vestingRecipients,
534
- amounts: vestingAmounts,
535
- tokenURI: t.tokenURI
536
- };
537
- })();
538
- const resolvedTokenFactoryDyn = params.modules?.tokenFactory ?? (this.isDoppler404Token(params.token) ? addresses.doppler404Factory : addresses.tokenFactory);
539
- if (!resolvedTokenFactoryDyn || resolvedTokenFactoryDyn === chunk6BQY5EPB_js.ZERO_ADDRESS) {
540
- throw new Error(
541
- "Token factory address not configured. Provide an explicit address via builder.withTokenFactory(...) or ensure chain config includes a valid factory."
542
- );
543
- }
544
- const [
545
- salt,
546
- hookAddress,
547
- tokenAddress,
548
- poolInitializerData,
549
- encodedTokenFactoryData
550
- ] = this.mineHookAddress({
551
- airlock: params.modules?.airlock ?? addresses.airlock,
552
- poolManager: params.modules?.poolManager ?? addresses.poolManager,
553
- deployer: params.modules?.dopplerDeployer ?? addresses.dopplerDeployer,
554
- initialSupply: params.sale.initialSupply,
555
- numTokensToSell: params.sale.numTokensToSell,
556
- numeraire: params.sale.numeraire,
557
- tokenFactory: resolvedTokenFactoryDyn,
558
- tokenFactoryData,
559
- poolInitializer: params.modules?.v4Initializer ?? addresses.v4Initializer,
560
- poolInitializerData: dopplerData,
561
- tokenVariant: this.isDoppler404Token(params.token) ? "doppler404" : "standard"
562
- });
563
- const liquidityMigratorData = this.encodeMigrationData(params.migration, {
564
- numeraire: params.sale.numeraire,
565
- overrides: params.modules
566
- });
567
- const governanceFactoryData = (() => {
568
- if (params.governance.type === "noOp") {
569
- return "0x";
570
- }
571
- if (params.governance.type === "launchpad") {
572
- return viem.encodeAbiParameters(
573
- [{ type: "address" }],
574
- [params.governance.multisig]
575
- );
576
- }
577
- return viem.encodeAbiParameters(
578
- [
579
- { type: "string" },
580
- { type: "uint48" },
581
- { type: "uint32" },
582
- { type: "uint256" }
583
- ],
584
- [
585
- params.token.name,
586
- params.governance.type === "custom" ? params.governance.initialVotingDelay : chunk6BQY5EPB_js.DEFAULT_V4_INITIAL_VOTING_DELAY,
587
- params.governance.type === "custom" ? params.governance.initialVotingPeriod : chunk6BQY5EPB_js.DEFAULT_V4_INITIAL_VOTING_PERIOD,
588
- params.governance.type === "custom" ? params.governance.initialProposalThreshold : chunk6BQY5EPB_js.DEFAULT_V4_INITIAL_PROPOSAL_THRESHOLD
589
- ]
590
- );
591
- })();
592
- const governanceFactoryAddress = (() => {
593
- if (params.governance.type === "noOp") {
594
- const resolved2 = params.modules?.governanceFactory ?? addresses.noOpGovernanceFactory ?? chunk6BQY5EPB_js.ZERO_ADDRESS;
595
- if (!resolved2 || resolved2 === chunk6BQY5EPB_js.ZERO_ADDRESS) {
596
- throw new Error(
597
- "No-op governance requested, but no-op governanceFactory is not configured on this chain. Provide a governanceFactory override or use a supported chain."
598
- );
599
- }
600
- return resolved2;
601
- }
602
- if (params.governance.type === "launchpad") {
603
- const resolved2 = params.modules?.governanceFactory ?? addresses.launchpadGovernanceFactory ?? chunk6BQY5EPB_js.ZERO_ADDRESS;
604
- if (!resolved2 || resolved2 === chunk6BQY5EPB_js.ZERO_ADDRESS) {
605
- throw new Error(
606
- "Launchpad governance requested, but launchpadGovernanceFactory is not configured on this chain. Provide a governanceFactory override or use a supported chain."
607
- );
608
- }
609
- return resolved2;
610
- }
611
- const resolved = params.modules?.governanceFactory ?? addresses.governanceFactory;
612
- if (!resolved || resolved === chunk6BQY5EPB_js.ZERO_ADDRESS) {
613
- throw new Error(
614
- "Standard governance requested but governanceFactory is not deployed on this chain."
615
- );
616
- }
617
- return resolved;
618
- })();
619
- const createParams = {
620
- initialSupply: params.sale.initialSupply,
621
- numTokensToSell: params.sale.numTokensToSell,
622
- numeraire: params.sale.numeraire,
623
- tokenFactory: resolvedTokenFactoryDyn,
624
- tokenFactoryData: encodedTokenFactoryData,
625
- governanceFactory: governanceFactoryAddress,
626
- governanceFactoryData,
627
- poolInitializer: params.modules?.v4Initializer ?? addresses.v4Initializer,
628
- poolInitializerData,
629
- liquidityMigrator: this.getMigratorAddress(
630
- params.migration,
631
- params.modules
632
- ),
633
- liquidityMigratorData,
634
- integrator: params.integrator ?? chunk6BQY5EPB_js.ZERO_ADDRESS,
635
- salt
636
- };
637
- return { createParams, hookAddress, tokenAddress };
638
- }
639
- /**
640
- * Create a new dynamic auction (using Uniswap V4 hook for gradual Dutch auction)
641
- * @param params Configuration for the dynamic auction
642
- * @returns The address of the created hook and token
643
- */
644
- async createDynamicAuction(params, options) {
645
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
646
- let createParams;
647
- if (options?._createParams) {
648
- createParams = options._createParams;
649
- } else {
650
- const simulation = await this.simulateCreateDynamicAuction(params);
651
- createParams = simulation.createParams;
652
- }
653
- if (!this.walletClient) {
654
- throw new Error("Wallet client required for write operations");
655
- }
656
- const airlockAddress = params.modules?.airlock ?? addresses.airlock;
657
- const { request, result } = await this.publicClient.simulateContract({
658
- address: airlockAddress,
659
- abi: chunk3MVW6UIW_js.airlockAbi,
660
- functionName: "create",
661
- args: [{ ...createParams }],
662
- account: this.walletClient.account
663
- });
664
- const simResult = result;
665
- const gasEstimate = await this.resolveCreateGasEstimate({
666
- request,
667
- address: airlockAddress,
668
- createParams,
669
- account: this.walletClient.account
670
- });
671
- const gasOverride = params.gas ?? gasEstimate ?? chunk6BQY5EPB_js.DEFAULT_CREATE_GAS_LIMIT;
672
- const hash = await this.walletClient.writeContract({
673
- ...request,
674
- gas: gasOverride
675
- });
676
- const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
677
- const actualAddresses = this.extractAddressesFromCreateEvent(receipt);
678
- if (!actualAddresses) {
679
- throw new Error(
680
- "Failed to extract addresses from Create event in transaction logs"
681
- );
682
- }
683
- const actualTokenAddress = actualAddresses.tokenAddress;
684
- const actualHookAddress = actualAddresses.poolOrHookAddress;
685
- if (simResult && Array.isArray(simResult) && simResult.length >= 2) {
686
- const simulatedToken = simResult[0];
687
- const simulatedHook = simResult[1];
688
- if (simulatedToken.toLowerCase() !== actualTokenAddress.toLowerCase()) {
689
- console.warn(
690
- `[DopplerSDK] Simulation predicted token ${simulatedToken} but actual is ${actualTokenAddress}. This may indicate state divergence between simulation and execution.`
691
- );
692
- }
693
- if (simulatedHook.toLowerCase() !== actualHookAddress.toLowerCase()) {
694
- console.warn(
695
- `[DopplerSDK] Simulation predicted hook ${simulatedHook} but actual is ${actualHookAddress}. This may indicate state divergence between simulation and execution.`
696
- );
697
- }
698
- }
699
- const poolId = this.computePoolId({
700
- currency0: actualTokenAddress < params.sale.numeraire ? actualTokenAddress : params.sale.numeraire,
701
- currency1: actualTokenAddress < params.sale.numeraire ? params.sale.numeraire : actualTokenAddress,
702
- fee: params.pool.fee,
703
- tickSpacing: params.pool.tickSpacing,
704
- hooks: actualHookAddress
705
- });
706
- return {
707
- hookAddress: actualHookAddress,
708
- tokenAddress: actualTokenAddress,
709
- poolId,
710
- transactionHash: hash
711
- };
712
- }
713
- /**
714
- * Simulate a dynamic auction creation and return predicted addresses and poolId.
715
- * Useful for clients that need the hook/token/poolId before submitting the tx.
716
- */
717
- async simulateCreateDynamicAuction(params) {
718
- const { createParams } = await this.encodeCreateDynamicAuctionParams(params);
719
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
720
- const airlockAddress = params.modules?.airlock ?? addresses.airlock;
721
- const { request, result } = await this.publicClient.simulateContract({
722
- address: airlockAddress,
723
- abi: chunk3MVW6UIW_js.airlockAbi,
724
- functionName: "create",
725
- args: [{ ...createParams }],
726
- account: this.walletClient?.account
727
- });
728
- const simResult = result;
729
- const gasEstimate = await this.resolveCreateGasEstimate({
730
- request,
731
- address: airlockAddress,
732
- createParams,
733
- account: this.walletClient?.account ?? params.userAddress
734
- });
735
- if (!simResult || !Array.isArray(simResult) || simResult.length < 2) {
736
- throw new Error("Failed to simulate dynamic auction create");
737
- }
738
- const tokenAddress = simResult[0];
739
- const hookAddress = simResult[1];
740
- const poolId = this.computePoolId({
741
- currency0: tokenAddress < params.sale.numeraire ? tokenAddress : params.sale.numeraire,
742
- currency1: tokenAddress < params.sale.numeraire ? params.sale.numeraire : tokenAddress,
743
- fee: params.pool.fee,
744
- tickSpacing: params.pool.tickSpacing,
745
- hooks: hookAddress
746
- });
747
- return {
748
- createParams,
749
- hookAddress,
750
- tokenAddress,
751
- poolId,
752
- gasEstimate,
753
- execute: () => this.createDynamicAuction(params, { _createParams: createParams })
754
- };
755
- }
756
- async resolveCreateGasEstimate(args) {
757
- const { request, address, createParams, account } = args;
758
- const gasFromRequest = request && typeof request === "object" && "gas" in request ? request.gas : void 0;
759
- if (gasFromRequest) {
760
- return gasFromRequest;
761
- }
762
- try {
763
- const estimated = await this.publicClient.estimateContractGas({
764
- address,
765
- abi: chunk3MVW6UIW_js.airlockAbi,
766
- functionName: "create",
767
- args: [{ ...createParams }],
768
- account
769
- });
770
- return estimated;
771
- } catch {
772
- return void 0;
773
- }
774
- }
775
- isDoppler404Token(token) {
776
- return token.type === "doppler404";
777
- }
778
- /**
779
- * Encode migration data based on the MigrationConfig
780
- * This replaces the manual encoding methods from the old SDKs
781
- */
782
- encodeMigrationData(config, options) {
783
- if (this.customMigrationEncoder) {
784
- return this.customMigrationEncoder(config);
785
- }
786
- switch (config.type) {
787
- case "uniswapV2":
788
- return "0x";
789
- case "noOp":
790
- return "0x";
791
- case "uniswapV4":
792
- const streamableFees = config.streamableFees;
793
- if (!streamableFees) {
794
- return "0x";
795
- }
796
- const beneficiaryData = [...streamableFees.beneficiaries].sort(
797
- (a, b) => {
798
- const addrA = a.beneficiary.toLowerCase();
799
- const addrB = b.beneficiary.toLowerCase();
800
- return addrA < addrB ? -1 : addrA > addrB ? 1 : 0;
801
- }
802
- );
803
- return viem.encodeAbiParameters(
804
- [
805
- { type: "uint24" },
806
- // fee
807
- { type: "int24" },
808
- // tickSpacing
809
- { type: "uint32" },
810
- // lockDuration (0 if no streamableFees)
811
- {
812
- type: "tuple[]",
813
- components: [
814
- { type: "address", name: "beneficiary" },
815
- { type: "uint96", name: "shares" }
816
- ]
817
- }
818
- ],
819
- [
820
- config.fee,
821
- config.tickSpacing,
822
- streamableFees.lockDuration,
823
- beneficiaryData
824
- ]
825
- );
826
- case "dopplerHook": {
827
- const dopplerHookConfig = config;
828
- if (dopplerHookConfig.hook && dopplerHookConfig.rehype) {
829
- throw new Error(
830
- "dopplerHook migration cannot set both hook and rehype config. Use exactly one hook mode."
831
- );
832
- }
833
- const beneficiaries = [...dopplerHookConfig.beneficiaries].sort(
834
- (a, b) => {
835
- const addrA = a.beneficiary.toLowerCase();
836
- const addrB = b.beneficiary.toLowerCase();
837
- return addrA < addrB ? -1 : addrA > addrB ? 1 : 0;
838
- }
839
- );
840
- let dopplerHookAddress = chunk6BQY5EPB_js.ZERO_ADDRESS;
841
- let onInitializationCalldata = "0x";
842
- if (dopplerHookConfig.hook) {
843
- dopplerHookAddress = dopplerHookConfig.hook.hookAddress;
844
- onInitializationCalldata = dopplerHookConfig.hook.onInitializationCalldata ?? "0x";
845
- } else if (dopplerHookConfig.rehype) {
846
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
847
- const resolvedRehypeHookAddress = dopplerHookConfig.rehype.hookAddress ?? options?.overrides?.rehypeDopplerHookMigrator ?? addresses.rehypeDopplerHookMigrator;
848
- if (!resolvedRehypeHookAddress) {
849
- throw new Error(
850
- "RehypeDopplerHookMigrator address not configured on this chain. Provide migration.rehype.hookAddress or override modules.rehypeDopplerHookMigrator."
851
- );
852
- }
853
- if (!options?.numeraire) {
854
- throw new Error(
855
- "numeraire is required to encode rehype dopplerHook migration data"
856
- );
857
- }
858
- dopplerHookAddress = resolvedRehypeHookAddress;
859
- onInitializationCalldata = chunkWJBJARLJ_js.encodeRehypeDopplerHookMigratorCalldata({
860
- numeraire: options.numeraire,
861
- config: dopplerHookConfig.rehype
862
- });
863
- }
864
- const proceedsRecipient = dopplerHookConfig.proceedsSplit?.recipient ?? chunk6BQY5EPB_js.ZERO_ADDRESS;
865
- const proceedsShare = dopplerHookConfig.proceedsSplit?.share ?? 0n;
866
- return viem.encodeAbiParameters(
867
- [
868
- { type: "uint24" },
869
- { type: "bool" },
870
- { type: "int24" },
871
- { type: "uint32" },
872
- {
873
- type: "tuple[]",
874
- components: [
875
- { type: "address", name: "beneficiary" },
876
- { type: "uint96", name: "shares" }
877
- ]
878
- },
879
- { type: "address" },
880
- { type: "bytes" },
881
- { type: "address" },
882
- { type: "uint256" }
883
- ],
884
- [
885
- dopplerHookConfig.fee,
886
- dopplerHookConfig.useDynamicFee ?? false,
887
- dopplerHookConfig.tickSpacing,
888
- dopplerHookConfig.lockDuration,
889
- beneficiaries,
890
- dopplerHookAddress,
891
- onInitializationCalldata,
892
- proceedsRecipient,
893
- proceedsShare
894
- ]
895
- );
896
- }
897
- default:
898
- throw new Error("Unknown migration type");
899
- }
900
- }
901
- /**
902
- * Encode create params for Uniswap V4 Multicurve initializer/migrator flow
903
- */
904
- normalizeUint32(value, label) {
905
- const normalized = typeof value === "bigint" ? Number(value) : Number(value);
906
- if (!Number.isFinite(normalized) || !Number.isInteger(normalized)) {
907
- throw new Error(
908
- `${label} must be an integer number of seconds since Unix epoch`
909
- );
910
- }
911
- if (normalized < 0) {
912
- throw new Error(`${label} cannot be negative`);
913
- }
914
- const UINT32_MAX = 4294967295;
915
- if (normalized > UINT32_MAX) {
916
- throw new Error(
917
- `${label} must fit within uint32 (seconds since Unix epoch up to year 2106)`
918
- );
919
- }
920
- return normalized;
921
- }
922
- resolveMulticurveInitializerMode(params) {
923
- const legacySchedule = params.schedule;
924
- const legacyHook = params.dopplerHook;
925
- const hasLegacySchedule = legacySchedule !== void 0;
926
- const hasLegacyHook = legacyHook !== void 0;
927
- if (hasLegacySchedule && hasLegacyHook) {
928
- throw new Error(
929
- "Cannot combine schedule and dopplerHook legacy multicurve options. Use exactly one initializer mode."
930
- );
931
- }
932
- const initializer = params.initializer;
933
- let mode;
934
- if (!initializer) {
935
- if (hasLegacySchedule) {
936
- mode = {
937
- type: "scheduled",
938
- startTime: this.normalizeUint32(
939
- legacySchedule.startTime,
940
- "Scheduled multicurve startTime"
941
- )
942
- };
943
- } else if (hasLegacyHook) {
944
- mode = {
945
- type: "rehype",
946
- hookConfig: legacyHook
947
- };
948
- } else {
949
- mode = { type: "standard" };
950
- }
951
- } else {
952
- switch (initializer.type) {
953
- case "standard": {
954
- if (hasLegacySchedule || hasLegacyHook) {
955
- throw new Error(
956
- "Initializer type 'standard' cannot be combined with legacy schedule/dopplerHook fields"
957
- );
958
- }
959
- mode = { type: "standard" };
960
- break;
961
- }
962
- case "scheduled": {
963
- if (hasLegacyHook) {
964
- throw new Error(
965
- "Initializer type 'scheduled' cannot be combined with dopplerHook"
966
- );
967
- }
968
- const normalizedStart = this.normalizeUint32(
969
- initializer.startTime,
970
- "Scheduled multicurve startTime"
971
- );
972
- if (hasLegacySchedule) {
973
- const legacyStart = this.normalizeUint32(
974
- legacySchedule.startTime,
975
- "Scheduled multicurve startTime"
976
- );
977
- if (legacyStart !== normalizedStart) {
978
- throw new Error(
979
- "Conflicting scheduled start times provided via initializer and schedule"
980
- );
981
- }
982
- }
983
- mode = { type: "scheduled", startTime: normalizedStart };
984
- break;
985
- }
986
- case "decay": {
987
- if (hasLegacySchedule || hasLegacyHook) {
988
- throw new Error(
989
- "Initializer type 'decay' cannot be combined with legacy schedule/dopplerHook fields"
990
- );
991
- }
992
- const startTime = this.normalizeUint32(
993
- initializer.startTime,
994
- "Decay multicurve startTime"
995
- );
996
- const startFee = Number(initializer.startFee);
997
- const durationSeconds = this.normalizeUint32(
998
- initializer.durationSeconds,
999
- "Decay multicurve durationSeconds"
1000
- );
1001
- const endFee = Number(params.pool.fee);
1002
- if (!Number.isInteger(startFee)) {
1003
- throw new Error("Decay multicurve startFee must be an integer");
1004
- }
1005
- if (startFee < 0 || startFee > chunk6BQY5EPB_js.DECAY_MAX_START_FEE) {
1006
- throw new Error(
1007
- `Decay multicurve startFee must be between 0 and ${chunk6BQY5EPB_js.DECAY_MAX_START_FEE}`
1008
- );
1009
- }
1010
- if (!Number.isInteger(endFee) || endFee < 0 || endFee > chunk6BQY5EPB_js.V4_MAX_FEE) {
1011
- throw new Error(
1012
- `Multicurve pool fee must be between 0 and ${chunk6BQY5EPB_js.V4_MAX_FEE}`
1013
- );
1014
- }
1015
- if (startFee < endFee) {
1016
- throw new Error(
1017
- `Decay multicurve startFee (${startFee}) must be greater than or equal to terminal pool fee (${endFee})`
1018
- );
1019
- }
1020
- if (startFee > endFee && durationSeconds <= 0) {
1021
- throw new Error(
1022
- "Decay multicurve durationSeconds must be greater than 0 when startFee is greater than terminal pool fee"
1023
- );
1024
- }
1025
- mode = {
1026
- type: "decay",
1027
- startTime,
1028
- startFee,
1029
- durationSeconds
1030
- };
1031
- break;
1032
- }
1033
- case "rehype": {
1034
- if (hasLegacySchedule) {
1035
- throw new Error(
1036
- "Initializer type 'rehype' cannot be combined with schedule"
1037
- );
1038
- }
1039
- mode = { type: "rehype", hookConfig: initializer.config };
1040
- break;
1041
- }
1042
- default: {
1043
- const exhaustive = initializer;
1044
- throw new Error(
1045
- `Unsupported multicurve initializer type: ${exhaustive?.type ?? "unknown"}`
1046
- );
1047
- }
1048
- }
1049
- }
1050
- if (params.modules?.dopplerHookInitializer !== void 0) {
1051
- if (mode.type === "standard") {
1052
- mode = { type: "rehype" };
1053
- } else if (mode.type !== "rehype") {
1054
- throw new Error(
1055
- "modules.dopplerHookInitializer can only be used with the rehype or standard multicurve initializer mode"
1056
- );
1057
- }
1058
- }
1059
- return mode;
1060
- }
1061
- encodeCreateMulticurveParams(params) {
1062
- this.validateMulticurveParams(params);
1063
- if (!params.pool || params.pool.curves.length === 0) {
1064
- throw new Error("Multicurve pool must include at least one curve");
1065
- }
1066
- const normalizedCurves = this.normalizeMulticurveCurves(
1067
- params.pool.curves,
1068
- params.pool.tickSpacing
1069
- );
1070
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
1071
- const sortedBeneficiaries = (params.pool.beneficiaries ?? []).slice().sort(
1072
- (a, b) => {
1073
- const aAddr = a.beneficiary.toLowerCase();
1074
- const bAddr = b.beneficiary.toLowerCase();
1075
- return aAddr < bAddr ? -1 : aAddr > bAddr ? 1 : 0;
1076
- }
1077
- );
1078
- const initializerMode = this.resolveMulticurveInitializerMode(params);
1079
- const useScheduledInitializer = initializerMode.type === "scheduled";
1080
- const useDecayInitializer = initializerMode.type === "decay";
1081
- const useDopplerHookInitializer = initializerMode.type === "rehype";
1082
- if (initializerMode.type === "rehype" && initializerMode.hookConfig) {
1083
- const hook = initializerMode.hookConfig;
1084
- const totalDistribution = hook.assetBuybackPercentWad + hook.numeraireBuybackPercentWad + hook.beneficiaryPercentWad + hook.lpPercentWad;
1085
- if (totalDistribution !== chunk6BQY5EPB_js.WAD) {
1086
- throw new Error(
1087
- `DopplerHook fee distribution must sum to ${chunk6BQY5EPB_js.WAD} (100%), but got ${totalDistribution}`
1088
- );
1089
- }
1090
- }
1091
- const curveComponents = [
1092
- { type: "int24", name: "tickLower" },
1093
- { type: "int24", name: "tickUpper" },
1094
- { type: "uint16", name: "numPositions" },
1095
- { type: "uint256", name: "shares" }
1096
- ];
1097
- const beneficiaryComponents = [
1098
- { type: "address", name: "beneficiary" },
1099
- { type: "uint96", name: "shares" }
1100
- ];
1101
- const curvesData = normalizedCurves.map(
1102
- (c) => ({
1103
- tickLower: c.tickLower,
1104
- tickUpper: c.tickUpper,
1105
- numPositions: c.numPositions,
1106
- shares: c.shares
1107
- })
1108
- );
1109
- const beneficiariesData = sortedBeneficiaries.map(
1110
- (b) => ({
1111
- beneficiary: b.beneficiary,
1112
- shares: b.shares
1113
- })
1114
- );
1115
- let poolInitializerData;
1116
- if (useDopplerHookInitializer) {
1117
- const hookConfig = initializerMode.type === "rehype" ? initializerMode.hookConfig : void 0;
1118
- let farTick;
1119
- if (hookConfig?.farTick !== void 0) {
1120
- farTick = hookConfig.farTick;
1121
- } else {
1122
- const allTickUppers = params.pool.curves.map((c) => c.tickUpper);
1123
- farTick = Math.max(...allTickUppers);
1124
- }
1125
- let onInitializationDopplerHookCalldata = "0x";
1126
- let graduationDopplerHookCalldata = "0x";
1127
- let dopplerHookAddress = chunk6BQY5EPB_js.ZERO_ADDRESS;
1128
- if (hookConfig) {
1129
- dopplerHookAddress = hookConfig.hookAddress;
1130
- onInitializationDopplerHookCalldata = viem.encodeAbiParameters(
1131
- [
1132
- { type: "address" },
1133
- // numeraire
1134
- { type: "address" },
1135
- // buybackDst
1136
- { type: "uint24" },
1137
- // customFee
1138
- { type: "uint256" },
1139
- // assetBuybackPercentWad
1140
- { type: "uint256" },
1141
- // numeraireBuybackPercentWad
1142
- { type: "uint256" },
1143
- // beneficiaryPercentWad
1144
- { type: "uint256" }
1145
- // lpPercentWad
1146
- ],
1147
- [
1148
- params.sale.numeraire,
1149
- hookConfig.buybackDestination,
1150
- hookConfig.customFee,
1151
- hookConfig.assetBuybackPercentWad,
1152
- hookConfig.numeraireBuybackPercentWad,
1153
- hookConfig.beneficiaryPercentWad,
1154
- hookConfig.lpPercentWad
1155
- ]
1156
- );
1157
- graduationDopplerHookCalldata = hookConfig.graduationCalldata ?? "0x";
1158
- }
1159
- const dopplerHookTupleComponents = [
1160
- { name: "fee", type: "uint24" },
1161
- { name: "tickSpacing", type: "int24" },
1162
- { name: "farTick", type: "int24" },
1163
- { name: "curves", type: "tuple[]", components: curveComponents },
1164
- {
1165
- name: "beneficiaries",
1166
- type: "tuple[]",
1167
- components: beneficiaryComponents
1168
- },
1169
- { name: "dopplerHook", type: "address" },
1170
- { name: "onInitializationDopplerHookCalldata", type: "bytes" },
1171
- { name: "graduationDopplerHookCalldata", type: "bytes" }
1172
- ];
1173
- poolInitializerData = viem.encodeAbiParameters(
1174
- [{ type: "tuple", components: dopplerHookTupleComponents }],
1175
- [
1176
- {
1177
- fee: params.pool.fee,
1178
- tickSpacing: params.pool.tickSpacing,
1179
- farTick,
1180
- curves: curvesData,
1181
- beneficiaries: beneficiariesData,
1182
- dopplerHook: dopplerHookAddress,
1183
- onInitializationDopplerHookCalldata,
1184
- graduationDopplerHookCalldata
1185
- }
1186
- ]
1187
- );
1188
- } else if (useDecayInitializer) {
1189
- const decayTupleComponents = [
1190
- { name: "startFee", type: "uint24" },
1191
- { name: "fee", type: "uint24" },
1192
- { name: "durationSeconds", type: "uint32" },
1193
- { name: "tickSpacing", type: "int24" },
1194
- { name: "curves", type: "tuple[]", components: curveComponents },
1195
- {
1196
- name: "beneficiaries",
1197
- type: "tuple[]",
1198
- components: beneficiaryComponents
1199
- },
1200
- { name: "startingTime", type: "uint32" }
1201
- ];
1202
- if (initializerMode.type !== "decay") {
1203
- throw new Error("Invalid multicurve initializer state for decay mode");
1204
- }
1205
- poolInitializerData = viem.encodeAbiParameters(
1206
- [{ type: "tuple", components: decayTupleComponents }],
1207
- [
1208
- {
1209
- startFee: initializerMode.startFee,
1210
- fee: params.pool.fee,
1211
- durationSeconds: initializerMode.durationSeconds,
1212
- tickSpacing: params.pool.tickSpacing,
1213
- curves: curvesData,
1214
- beneficiaries: beneficiariesData,
1215
- startingTime: initializerMode.startTime
1216
- }
1217
- ]
1218
- );
1219
- } else if (useScheduledInitializer) {
1220
- if (initializerMode.type !== "scheduled") {
1221
- throw new Error(
1222
- "Invalid multicurve initializer state for scheduled mode"
1223
- );
1224
- }
1225
- const scheduledTupleComponents = [
1226
- { name: "fee", type: "uint24" },
1227
- { name: "tickSpacing", type: "int24" },
1228
- { name: "curves", type: "tuple[]", components: curveComponents },
1229
- {
1230
- name: "beneficiaries",
1231
- type: "tuple[]",
1232
- components: beneficiaryComponents
1233
- },
1234
- { name: "startingTime", type: "uint32" }
1235
- ];
1236
- poolInitializerData = viem.encodeAbiParameters(
1237
- [{ type: "tuple", components: scheduledTupleComponents }],
1238
- [
1239
- {
1240
- fee: params.pool.fee,
1241
- tickSpacing: params.pool.tickSpacing,
1242
- curves: curvesData,
1243
- beneficiaries: beneficiariesData,
1244
- startingTime: initializerMode.startTime
1245
- }
1246
- ]
1247
- );
1248
- } else {
1249
- const basicTupleComponents = [
1250
- { name: "fee", type: "uint24" },
1251
- { name: "tickSpacing", type: "int24" },
1252
- { name: "curves", type: "tuple[]", components: curveComponents },
1253
- {
1254
- name: "beneficiaries",
1255
- type: "tuple[]",
1256
- components: beneficiaryComponents
1257
- }
1258
- ];
1259
- poolInitializerData = viem.encodeAbiParameters(
1260
- [{ type: "tuple", components: basicTupleComponents }],
1261
- [
1262
- {
1263
- fee: params.pool.fee,
1264
- tickSpacing: params.pool.tickSpacing,
1265
- curves: curvesData,
1266
- beneficiaries: beneficiariesData
1267
- }
1268
- ]
1269
- );
1270
- }
1271
- let tokenFactoryData;
1272
- if (this.isDoppler404Token(params.token)) {
1273
- const token404 = params.token;
1274
- const unit = token404.unit !== void 0 ? BigInt(token404.unit) : 1000n;
1275
- tokenFactoryData = viem.encodeAbiParameters(
1276
- [
1277
- { type: "string" },
1278
- { type: "string" },
1279
- { type: "string" },
1280
- { type: "uint256" }
1281
- ],
1282
- [token404.name, token404.symbol, token404.baseURI, unit]
1283
- );
1284
- } else {
1285
- const tokenStd = params.token;
1286
- const vestingDuration = params.vesting?.duration ?? BigInt(0);
1287
- const yearlyMintRate = tokenStd.yearlyMintRate ?? chunk6BQY5EPB_js.DEFAULT_V3_YEARLY_MINT_RATE;
1288
- let vestingRecipients = [];
1289
- let vestingAmounts = [];
1290
- if (params.vesting) {
1291
- if (params.vesting.recipients && params.vesting.amounts) {
1292
- vestingRecipients = params.vesting.recipients;
1293
- vestingAmounts = params.vesting.amounts;
1294
- } else {
1295
- vestingRecipients = [params.userAddress];
1296
- vestingAmounts = [
1297
- params.sale.initialSupply - params.sale.numTokensToSell
1298
- ];
1299
- }
1300
- }
1301
- tokenFactoryData = viem.encodeAbiParameters(
1302
- [
1303
- { type: "string" },
1304
- { type: "string" },
1305
- { type: "uint256" },
1306
- { type: "uint256" },
1307
- { type: "address[]" },
1308
- { type: "uint256[]" },
1309
- { type: "string" }
1310
- ],
1311
- [
1312
- tokenStd.name,
1313
- tokenStd.symbol,
1314
- yearlyMintRate,
1315
- BigInt(vestingDuration),
1316
- vestingRecipients,
1317
- vestingAmounts,
1318
- tokenStd.tokenURI
1319
- ]
1320
- );
1321
- }
1322
- const governanceFactoryData = (() => {
1323
- if (params.governance.type === "noOp") {
1324
- return "0x";
1325
- }
1326
- if (params.governance.type === "launchpad") {
1327
- return viem.encodeAbiParameters(
1328
- [{ type: "address" }],
1329
- [params.governance.multisig]
1330
- );
1331
- }
1332
- return viem.encodeAbiParameters(
1333
- [
1334
- { type: "string" },
1335
- { type: "uint48" },
1336
- { type: "uint32" },
1337
- { type: "uint256" }
1338
- ],
1339
- [
1340
- params.token.name,
1341
- params.governance.type === "custom" ? params.governance.initialVotingDelay : chunk6BQY5EPB_js.DEFAULT_V4_INITIAL_VOTING_DELAY,
1342
- params.governance.type === "custom" ? params.governance.initialVotingPeriod : chunk6BQY5EPB_js.DEFAULT_V4_INITIAL_VOTING_PERIOD,
1343
- params.governance.type === "custom" ? params.governance.initialProposalThreshold : chunk6BQY5EPB_js.DEFAULT_V4_INITIAL_PROPOSAL_THRESHOLD
1344
- ]
1345
- );
1346
- })();
1347
- const salt = this.generateRandomSalt(params.userAddress);
1348
- const resolvedTokenFactory = params.modules?.tokenFactory ?? (this.isDoppler404Token(params.token) ? addresses.doppler404Factory : addresses.tokenFactory);
1349
- if (!resolvedTokenFactory || resolvedTokenFactory === chunk6BQY5EPB_js.ZERO_ADDRESS) {
1350
- throw new Error(
1351
- "Token factory address not configured. Provide an explicit address or ensure chain config includes a valid factory."
1352
- );
1353
- }
1354
- const resolvedInitializer = (() => {
1355
- if (useDopplerHookInitializer) {
1356
- return params.modules?.dopplerHookInitializer ?? addresses.dopplerHookInitializer;
1357
- }
1358
- if (useDecayInitializer) {
1359
- return params.modules?.v4DecayMulticurveInitializer ?? addresses.v4DecayMulticurveInitializer;
1360
- }
1361
- if (useScheduledInitializer) {
1362
- return params.modules?.v4ScheduledMulticurveInitializer ?? addresses.v4ScheduledMulticurveInitializer;
1363
- }
1364
- return params.modules?.v4MulticurveInitializer ?? addresses.v4MulticurveInitializer;
1365
- })();
1366
- if (!resolvedInitializer || resolvedInitializer === chunk6BQY5EPB_js.ZERO_ADDRESS) {
1367
- if (useDopplerHookInitializer) {
1368
- throw new Error(
1369
- "DopplerHookInitializer address not configured on this chain. Override via builder.withDopplerHookInitializer() or update chain config."
1370
- );
1371
- }
1372
- if (useDecayInitializer) {
1373
- throw new Error(
1374
- "Decay multicurve initializer address not configured on this chain. Override via builder.withV4DecayMulticurveInitializer() or update chain config."
1375
- );
1376
- }
1377
- throw new Error(
1378
- useScheduledInitializer ? "Scheduled multicurve initializer address not configured on this chain. Override via builder or update chain config." : "Multicurve initializer address not configured on this chain. Override via builder or update chain config."
1379
- );
1380
- }
1381
- const hasBeneficiaries = params.pool.beneficiaries && params.pool.beneficiaries.length > 0;
1382
- let liquidityMigratorData;
1383
- let resolvedMigrator;
1384
- if (hasBeneficiaries) {
1385
- liquidityMigratorData = "0x";
1386
- resolvedMigrator = params.modules?.noOpMigrator ?? addresses.noOpMigrator;
1387
- if (!resolvedMigrator || resolvedMigrator === chunk6BQY5EPB_js.ZERO_ADDRESS) {
1388
- throw new Error(
1389
- "NoOpMigrator address not configured on this chain. Override via modules.noOpMigrator or update chain config."
1390
- );
1391
- }
1392
- } else {
1393
- liquidityMigratorData = this.encodeMigrationData(params.migration, {
1394
- numeraire: params.sale.numeraire,
1395
- overrides: params.modules
1396
- });
1397
- resolvedMigrator = this.getMigratorAddress(
1398
- params.migration,
1399
- params.modules
1400
- );
1401
- if (!resolvedMigrator || resolvedMigrator === chunk6BQY5EPB_js.ZERO_ADDRESS) {
1402
- throw new Error(
1403
- "Migrator address not configured on this chain. Override via builder or update chain config."
1404
- );
1405
- }
1406
- }
1407
- const governanceFactoryAddress = (() => {
1408
- if (params.governance.type === "noOp") {
1409
- const resolved2 = params.modules?.governanceFactory ?? addresses.noOpGovernanceFactory ?? chunk6BQY5EPB_js.ZERO_ADDRESS;
1410
- if (!resolved2 || resolved2 === chunk6BQY5EPB_js.ZERO_ADDRESS) {
1411
- throw new Error(
1412
- "No-op governance requested, but no-op governanceFactory is not configured on this chain."
1413
- );
1414
- }
1415
- return resolved2;
1416
- }
1417
- if (params.governance.type === "launchpad") {
1418
- const resolved2 = params.modules?.governanceFactory ?? addresses.launchpadGovernanceFactory ?? chunk6BQY5EPB_js.ZERO_ADDRESS;
1419
- if (!resolved2 || resolved2 === chunk6BQY5EPB_js.ZERO_ADDRESS) {
1420
- throw new Error(
1421
- "Launchpad governance requested, but launchpadGovernanceFactory is not configured on this chain."
1422
- );
1423
- }
1424
- return resolved2;
1425
- }
1426
- const resolved = params.modules?.governanceFactory ?? addresses.governanceFactory;
1427
- if (!resolved || resolved === chunk6BQY5EPB_js.ZERO_ADDRESS) {
1428
- throw new Error(
1429
- "Standard governance requested but governanceFactory is not deployed on this chain."
1430
- );
1431
- }
1432
- return resolved;
1433
- })();
1434
- const createParams = {
1435
- initialSupply: params.sale.initialSupply,
1436
- numTokensToSell: params.sale.numTokensToSell,
1437
- numeraire: params.sale.numeraire,
1438
- tokenFactory: resolvedTokenFactory,
1439
- tokenFactoryData,
1440
- governanceFactory: governanceFactoryAddress,
1441
- governanceFactoryData,
1442
- poolInitializer: resolvedInitializer,
1443
- poolInitializerData,
1444
- liquidityMigrator: resolvedMigrator,
1445
- liquidityMigratorData,
1446
- integrator: params.integrator ?? chunk6BQY5EPB_js.ZERO_ADDRESS,
1447
- salt
1448
- };
1449
- return createParams;
1450
- }
1451
- async simulateCreateMulticurve(params) {
1452
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
1453
- const createParams = this.encodeCreateMulticurveParams(params);
1454
- const airlockAddress = params.modules?.airlock ?? addresses.airlock;
1455
- const { request, result } = await this.publicClient.simulateContract({
1456
- address: airlockAddress,
1457
- abi: chunk3MVW6UIW_js.airlockAbi,
1458
- functionName: "create",
1459
- args: [{ ...createParams }],
1460
- account: this.walletClient?.account
1461
- });
1462
- const simResult = result;
1463
- const gasEstimate = await this.resolveCreateGasEstimate({
1464
- request,
1465
- address: airlockAddress,
1466
- createParams,
1467
- account: this.walletClient?.account ?? params.userAddress
1468
- });
1469
- if (!simResult || !Array.isArray(simResult) || simResult.length < 2) {
1470
- throw new Error("Failed to simulate multicurve create");
1471
- }
1472
- const tokenAddress = simResult[0];
1473
- const poolId = await this.computeMulticurvePoolId(params, tokenAddress);
1474
- return {
1475
- createParams,
1476
- tokenAddress,
1477
- poolId,
1478
- gasEstimate,
1479
- execute: () => this.createMulticurve(params, { _createParams: createParams })
1480
- };
1481
- }
1482
- async createMulticurve(params, options) {
1483
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
1484
- if (!this.walletClient)
1485
- throw new Error("Wallet client required for write operations");
1486
- const createParams = options?._createParams ?? (await this.simulateCreateMulticurve(params)).createParams;
1487
- const airlockAddress = params.modules?.airlock ?? addresses.airlock;
1488
- const { request, result } = await this.publicClient.simulateContract({
1489
- address: airlockAddress,
1490
- abi: chunk3MVW6UIW_js.airlockAbi,
1491
- functionName: "create",
1492
- args: [{ ...createParams }],
1493
- account: this.walletClient.account
1494
- });
1495
- const simResult = result;
1496
- const gasEstimate = await this.resolveCreateGasEstimate({
1497
- request,
1498
- address: airlockAddress,
1499
- createParams,
1500
- account: this.walletClient.account
1501
- });
1502
- const gas = params.gas ?? gasEstimate ?? chunk6BQY5EPB_js.DEFAULT_CREATE_GAS_LIMIT;
1503
- const hash = await this.walletClient.writeContract({ ...request, gas });
1504
- const receipt = await this.publicClient.waitForTransactionReceipt({ hash, confirmations: 2 });
1505
- const actualAddresses = this.extractAddressesFromCreateEvent(receipt);
1506
- if (!actualAddresses) {
1507
- throw new Error(
1508
- "Failed to extract token address from Create event in transaction logs"
1509
- );
1510
- }
1511
- const actualTokenAddress = actualAddresses.tokenAddress;
1512
- if (simResult && Array.isArray(simResult) && simResult.length >= 1) {
1513
- const simulatedToken = simResult[0];
1514
- if (simulatedToken.toLowerCase() !== actualTokenAddress.toLowerCase()) {
1515
- console.warn(
1516
- `[DopplerSDK] Simulation predicted token ${simulatedToken} but actual is ${actualTokenAddress}. This may indicate state divergence between simulation and execution.`
1517
- );
1518
- }
1519
- }
1520
- const poolId = await this.computeMulticurvePoolId(
1521
- params,
1522
- actualTokenAddress
1523
- );
1524
- return { tokenAddress: actualTokenAddress, poolId, transactionHash: hash };
1525
- }
1526
- /**
1527
- * Normalize user-provided multicurve positions and ensure they satisfy SDK constraints
1528
- */
1529
- normalizeMulticurveCurves(curves, tickSpacing) {
1530
- if (tickSpacing <= 0) {
1531
- throw new Error("Tick spacing must be positive");
1532
- }
1533
- if (!curves.length) {
1534
- throw new Error("Multicurve pool must include at least one curve");
1535
- }
1536
- let totalShares = 0n;
1537
- let mostPositiveTickUpper;
1538
- const sanitizedCurves = curves.map((curve) => {
1539
- const sanitized = { ...curve };
1540
- if (!Number.isFinite(sanitized.tickLower) || !Number.isFinite(sanitized.tickUpper)) {
1541
- throw new Error("Multicurve ticks must be finite numbers");
1542
- }
1543
- if (sanitized.tickLower >= sanitized.tickUpper) {
1544
- throw new Error(
1545
- "Multicurve curve tickLower must be less than tickUpper"
1546
- );
1547
- }
1548
- if (!Number.isInteger(sanitized.numPositions) || sanitized.numPositions <= 0) {
1549
- throw new Error(
1550
- "Multicurve curve numPositions must be a positive integer"
1551
- );
1552
- }
1553
- if (sanitized.shares <= 0n) {
1554
- throw new Error("Multicurve curve shares must be positive");
1555
- }
1556
- totalShares += sanitized.shares;
1557
- if (totalShares > chunk6BQY5EPB_js.WAD) {
1558
- throw new Error("Total multicurve shares cannot exceed 100% (1e18)");
1559
- }
1560
- if (mostPositiveTickUpper === void 0 || sanitized.tickUpper > mostPositiveTickUpper) {
1561
- mostPositiveTickUpper = sanitized.tickUpper;
1562
- }
1563
- return sanitized;
1564
- });
1565
- if (totalShares === chunk6BQY5EPB_js.WAD) {
1566
- return sanitizedCurves;
1567
- }
1568
- const missingShare = chunk6BQY5EPB_js.WAD - totalShares;
1569
- if (missingShare <= 0n) {
1570
- return sanitizedCurves;
1571
- }
1572
- const fallbackTickLower = mostPositiveTickUpper;
1573
- if (fallbackTickLower === void 0) {
1574
- throw new Error("Unable to determine fallback multicurve tick range");
1575
- }
1576
- const fallbackTickUpper = this.roundMaxTickDown(tickSpacing);
1577
- const fallbackCurve = {
1578
- // Extend from the most positive user tick out to the maximum supported tick bucket
1579
- tickLower: fallbackTickLower,
1580
- tickUpper: fallbackTickUpper,
1581
- numPositions: sanitizedCurves[sanitizedCurves.length - 1]?.numPositions ?? 1,
1582
- shares: missingShare
1583
- };
1584
- return [...sanitizedCurves, fallbackCurve];
1585
- }
1586
- roundMaxTickDown(tickSpacing) {
1587
- if (tickSpacing <= 0) {
1588
- throw new Error("Tick spacing must be positive");
1589
- }
1590
- const rounded = Math.floor(chunk4VWQNNNW_js.MAX_TICK / tickSpacing) * tickSpacing;
1591
- return rounded;
1592
- }
1593
- validateStaticAuctionParams(params) {
1594
- if (!params.token.name || params.token.name.trim().length === 0) {
1595
- throw new Error("Token name is required");
1596
- }
1597
- if (!params.token.symbol || params.token.symbol.trim().length === 0) {
1598
- throw new Error("Token symbol is required");
1599
- }
1600
- if (params.pool.startTick >= params.pool.endTick) {
1601
- throw new Error("Start tick must be less than end tick");
1602
- }
1603
- const tickSpacing = chunk6BQY5EPB_js.TICK_SPACINGS[params.pool.fee];
1604
- if (tickSpacing === void 0) {
1605
- throw new Error(
1606
- `Unsupported fee tier ${params.pool.fee} for static auctions`
1607
- );
1608
- }
1609
- if (params.pool.startTick < chunk4VWQNNNW_js.MIN_TICK || params.pool.endTick > chunk4VWQNNNW_js.MAX_TICK) {
1610
- throw new Error(
1611
- `Ticks must be within the allowed range (${chunk4VWQNNNW_js.MIN_TICK} to ${chunk4VWQNNNW_js.MAX_TICK})`
1612
- );
1613
- }
1614
- const startTickAligned = params.pool.startTick % tickSpacing === 0;
1615
- const endTickAligned = params.pool.endTick % tickSpacing === 0;
1616
- if (!startTickAligned || !endTickAligned) {
1617
- throw new Error(
1618
- `Pool ticks must be multiples of tick spacing ${tickSpacing} for fee tier ${params.pool.fee}`
1619
- );
1620
- }
1621
- if (params.sale.initialSupply <= BigInt(0)) {
1622
- throw new Error("Initial supply must be positive");
1623
- }
1624
- if (params.sale.numTokensToSell <= BigInt(0)) {
1625
- throw new Error("Number of tokens to sell must be positive");
1626
- }
1627
- if (params.sale.numTokensToSell > params.sale.initialSupply) {
1628
- throw new Error("Cannot sell more tokens than initial supply");
1629
- }
1630
- if (params.vesting) {
1631
- if (params.vesting.recipients && params.vesting.amounts) {
1632
- if (params.vesting.recipients.length !== params.vesting.amounts.length) {
1633
- throw new Error(
1634
- "Vesting recipients and amounts arrays must have the same length"
1635
- );
1636
- }
1637
- if (params.vesting.recipients.length === 0) {
1638
- throw new Error("Vesting recipients array cannot be empty");
1639
- }
1640
- const totalVested = params.vesting.amounts.reduce(
1641
- (sum, amt) => sum + amt,
1642
- BigInt(0)
1643
- );
1644
- const availableForVesting = params.sale.initialSupply - params.sale.numTokensToSell;
1645
- if (totalVested > availableForVesting) {
1646
- throw new Error(
1647
- `Total vesting amount (${totalVested}) exceeds available tokens (${availableForVesting})`
1648
- );
1649
- }
1650
- } else {
1651
- const vestedAmount = params.sale.initialSupply - params.sale.numTokensToSell;
1652
- if (vestedAmount <= BigInt(0)) {
1653
- throw new Error("No tokens available for vesting");
1654
- }
1655
- }
1656
- }
1657
- if (params.migration.type === "dopplerHook") {
1658
- throw new Error(
1659
- "dopplerHook migration is only supported for dynamic auctions"
1660
- );
1661
- }
1662
- if (params.migration.type === "uniswapV4" && params.migration.streamableFees) {
1663
- const beneficiaries = params.migration.streamableFees.beneficiaries;
1664
- if (beneficiaries.length === 0) {
1665
- throw new Error(
1666
- "At least one beneficiary is required for V4 migration"
1667
- );
1668
- }
1669
- const totalShares = beneficiaries.reduce((sum, b) => sum + b.shares, 0n);
1670
- if (totalShares !== chunk6BQY5EPB_js.WAD) {
1671
- throw new Error(
1672
- `Beneficiary shares must sum to ${chunk6BQY5EPB_js.WAD} (100%), but got ${totalShares}`
1673
- );
1674
- }
1675
- }
1676
- if (params.pool.beneficiaries && params.pool.beneficiaries.length > 0) {
1677
- const beneficiaries = params.pool.beneficiaries;
1678
- const totalShares = beneficiaries.reduce((sum, b) => sum + b.shares, 0n);
1679
- if (totalShares !== chunk6BQY5EPB_js.WAD) {
1680
- throw new Error(
1681
- `Pool beneficiary shares must sum to ${chunk6BQY5EPB_js.WAD} (100%), but got ${totalShares}`
1682
- );
1683
- }
1684
- for (const b of beneficiaries) {
1685
- if (b.shares <= 0n) {
1686
- throw new Error("Each beneficiary must have positive shares");
1687
- }
1688
- }
1689
- }
1690
- }
1691
- /**
1692
- * Validate dynamic auction parameters
1693
- */
1694
- validateDynamicAuctionParams(params) {
1695
- if (!params.token.name || params.token.name.trim().length === 0) {
1696
- throw new Error("Token name is required");
1697
- }
1698
- if (!params.token.symbol || params.token.symbol.trim().length === 0) {
1699
- throw new Error("Token symbol is required");
1700
- }
1701
- const isToken0 = chunk6H6X3VTZ_js.isToken0Expected(params.sale.numeraire);
1702
- if (isToken0 && params.auction.startTick <= params.auction.endTick) {
1703
- throw new Error(
1704
- "Start tick must be greater than end tick if base token is currency0"
1705
- );
1706
- }
1707
- if (!isToken0 && params.auction.startTick >= params.auction.endTick) {
1708
- throw new Error(
1709
- "Start tick must be less than end tick if base token is currency1"
1710
- );
1711
- }
1712
- if (params.sale.initialSupply <= BigInt(0)) {
1713
- throw new Error("Initial supply must be positive");
1714
- }
1715
- if (params.sale.numTokensToSell <= BigInt(0)) {
1716
- throw new Error("Number of tokens to sell must be positive");
1717
- }
1718
- if (params.sale.numTokensToSell > params.sale.initialSupply) {
1719
- throw new Error("Cannot sell more tokens than initial supply");
1720
- }
1721
- if (params.auction.duration <= 0) {
1722
- throw new Error("Auction duration must be positive");
1723
- }
1724
- if (params.auction.epochLength <= 0) {
1725
- throw new Error("Epoch length must be positive");
1726
- }
1727
- if (params.pool.tickSpacing <= 0) {
1728
- throw new Error("Tick spacing must be positive");
1729
- }
1730
- if (params.pool.tickSpacing > chunk6BQY5EPB_js.DOPPLER_MAX_TICK_SPACING) {
1731
- throw new Error(
1732
- `Dynamic auctions require tickSpacing <= ${chunk6BQY5EPB_js.DOPPLER_MAX_TICK_SPACING} (Doppler.sol MAX_TICK_SPACING). Got tickSpacing=${params.pool.tickSpacing}. Use withMarketCapRange() which handles this automatically, or use a smaller tickSpacing with poolConfig().`
1733
- );
1734
- }
1735
- if (params.auction.duration % params.auction.epochLength !== 0) {
1736
- throw new Error("Epoch length must divide total duration evenly");
1737
- }
1738
- if (params.auction.gamma !== void 0) {
1739
- if (params.auction.gamma % params.pool.tickSpacing !== 0) {
1740
- throw new Error("Gamma must be divisible by tick spacing");
1741
- }
1742
- }
1743
- if (params.migration.type === "uniswapV4" && params.migration.streamableFees) {
1744
- const beneficiaries = params.migration.streamableFees.beneficiaries;
1745
- if (beneficiaries.length === 0) {
1746
- throw new Error(
1747
- "At least one beneficiary is required for V4 migration"
1748
- );
1749
- }
1750
- const totalShares = beneficiaries.reduce((sum, b) => sum + b.shares, 0n);
1751
- if (totalShares !== chunk6BQY5EPB_js.WAD) {
1752
- throw new Error(
1753
- `Beneficiary shares must sum to ${chunk6BQY5EPB_js.WAD} (100%), but got ${totalShares}`
1754
- );
1755
- }
1756
- }
1757
- if (params.migration.type === "dopplerHook") {
1758
- const migration = params.migration;
1759
- if (!Number.isInteger(migration.fee) || migration.fee < 0) {
1760
- throw new Error(
1761
- "DopplerHook migration fee must be a non-negative integer"
1762
- );
1763
- }
1764
- if (migration.fee > 15e4) {
1765
- throw new Error("DopplerHook migration fee must be <= 150000 (15%)");
1766
- }
1767
- if (!Number.isInteger(migration.tickSpacing) || migration.tickSpacing <= 0) {
1768
- throw new Error(
1769
- "DopplerHook migration tickSpacing must be a positive integer"
1770
- );
1771
- }
1772
- if (migration.beneficiaries.length === 0) {
1773
- throw new Error(
1774
- "At least one beneficiary is required for dopplerHook migration"
1775
- );
1776
- }
1777
- const totalShares = migration.beneficiaries.reduce(
1778
- (sum, b) => sum + b.shares,
1779
- 0n
1780
- );
1781
- if (totalShares !== chunk6BQY5EPB_js.WAD) {
1782
- throw new Error(
1783
- `Beneficiary shares must sum to ${chunk6BQY5EPB_js.WAD} (100%), but got ${totalShares}`
1784
- );
1785
- }
1786
- const lockDuration = Number(migration.lockDuration);
1787
- if (!Number.isInteger(lockDuration) || lockDuration < 0) {
1788
- throw new Error(
1789
- "DopplerHook migration lockDuration must be a non-negative integer number of seconds"
1790
- );
1791
- }
1792
- if (lockDuration > 4294967295) {
1793
- throw new Error(
1794
- "DopplerHook migration lockDuration must fit within uint32"
1795
- );
1796
- }
1797
- if (migration.hook && migration.rehype) {
1798
- throw new Error(
1799
- "dopplerHook migration cannot set both hook and rehype config. Use exactly one hook mode."
1800
- );
1801
- }
1802
- if (migration.rehype) {
1803
- if (!Number.isInteger(migration.rehype.customFee) || migration.rehype.customFee < 0) {
1804
- throw new Error("Rehype customFee must be a non-negative integer");
1805
- }
1806
- if (migration.rehype.customFee > 1e6) {
1807
- throw new Error("Rehype customFee must be <= 1000000 (100%)");
1808
- }
1809
- const rehypeDistributionTotal = migration.rehype.assetBuybackPercentWad + migration.rehype.numeraireBuybackPercentWad + migration.rehype.beneficiaryPercentWad + migration.rehype.lpPercentWad;
1810
- if (rehypeDistributionTotal !== chunk6BQY5EPB_js.WAD) {
1811
- throw new Error(
1812
- `DopplerHook fee distribution must sum to ${chunk6BQY5EPB_js.WAD} (100%), but got ${rehypeDistributionTotal}`
1813
- );
1814
- }
1815
- }
1816
- if (migration.proceedsSplit) {
1817
- if (migration.proceedsSplit.recipient === chunk6BQY5EPB_js.ZERO_ADDRESS) {
1818
- throw new Error(
1819
- "DopplerHook proceeds split recipient cannot be zero address"
1820
- );
1821
- }
1822
- if (migration.proceedsSplit.share < 0n) {
1823
- throw new Error(
1824
- "DopplerHook proceeds split share cannot be negative"
1825
- );
1826
- }
1827
- if (migration.proceedsSplit.share > MAX_PROCEEDS_SPLIT_SHARE) {
1828
- throw new Error(
1829
- `DopplerHook proceeds split share cannot exceed ${MAX_PROCEEDS_SPLIT_SHARE}`
1830
- );
1831
- }
1832
- }
1833
- }
1834
- }
1835
- /**
1836
- * Validate multicurve auction parameters
1837
- */
1838
- validateMulticurveParams(params) {
1839
- if (!params.token.name || params.token.name.trim().length === 0) {
1840
- throw new Error("Token name is required");
1841
- }
1842
- if (!params.token.symbol || params.token.symbol.trim().length === 0) {
1843
- throw new Error("Token symbol is required");
1844
- }
1845
- if (params.sale.initialSupply <= BigInt(0)) {
1846
- throw new Error("Initial supply must be positive");
1847
- }
1848
- if (params.sale.numTokensToSell <= BigInt(0)) {
1849
- throw new Error("Number of tokens to sell must be positive");
1850
- }
1851
- if (params.sale.numTokensToSell > params.sale.initialSupply) {
1852
- throw new Error("Cannot sell more tokens than initial supply");
1853
- }
1854
- this.resolveMulticurveInitializerMode(params);
1855
- if (params.vesting) {
1856
- if (params.vesting.recipients && params.vesting.amounts) {
1857
- if (params.vesting.recipients.length !== params.vesting.amounts.length) {
1858
- throw new Error(
1859
- "Vesting recipients and amounts arrays must have the same length"
1860
- );
1861
- }
1862
- if (params.vesting.recipients.length === 0) {
1863
- throw new Error("Vesting recipients array cannot be empty");
1864
- }
1865
- const totalVested = params.vesting.amounts.reduce(
1866
- (sum, amt) => sum + amt,
1867
- BigInt(0)
1868
- );
1869
- const availableForVesting = params.sale.initialSupply - params.sale.numTokensToSell;
1870
- if (totalVested > availableForVesting) {
1871
- throw new Error(
1872
- `Total vesting amount (${totalVested}) exceeds available tokens (${availableForVesting})`
1873
- );
1874
- }
1875
- }
1876
- }
1877
- if (params.pool.beneficiaries && params.pool.beneficiaries.length > 0) {
1878
- const beneficiaries = params.pool.beneficiaries;
1879
- const totalShares = beneficiaries.reduce((sum, b) => sum + b.shares, 0n);
1880
- if (totalShares !== chunk6BQY5EPB_js.WAD) {
1881
- throw new Error(
1882
- `Pool beneficiary shares must sum to ${chunk6BQY5EPB_js.WAD} (100%), but got ${totalShares}`
1883
- );
1884
- }
1885
- for (const b of beneficiaries) {
1886
- if (b.shares <= 0n) {
1887
- throw new Error("Each beneficiary must have positive shares");
1888
- }
1889
- }
1890
- }
1891
- if (params.migration.type === "dopplerHook") {
1892
- throw new Error(
1893
- "dopplerHook migration is only supported for dynamic auctions"
1894
- );
1895
- }
1896
- if (params.migration.type === "uniswapV4" && params.migration.streamableFees) {
1897
- const beneficiaries = params.migration.streamableFees.beneficiaries;
1898
- if (beneficiaries.length === 0) {
1899
- throw new Error(
1900
- "At least one beneficiary is required for V4 migration"
1901
- );
1902
- }
1903
- const totalShares = beneficiaries.reduce((sum, b) => sum + b.shares, 0n);
1904
- if (totalShares !== chunk6BQY5EPB_js.WAD) {
1905
- throw new Error(
1906
- `Beneficiary shares must sum to ${chunk6BQY5EPB_js.WAD} (100%), but got ${totalShares}`
1907
- );
1908
- }
1909
- }
1910
- }
1911
- /**
1912
- * Get the airlock contract address for the current chain
1913
- */
1914
- getAirlockAddress() {
1915
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
1916
- return addresses.airlock;
1917
- }
1918
- /**
1919
- * Get the appropriate initializer address based on auction type
1920
- */
1921
- getInitializerAddress(isStatic) {
1922
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
1923
- return isStatic ? addresses.v3Initializer : addresses.v4Initializer;
1924
- }
1925
- /**
1926
- * Get the Bundler contract address for the current chain
1927
- * Used to perform atomic create + swap ("bundle") flows for static auctions
1928
- */
1929
- getBundlerAddress() {
1930
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
1931
- const addr = addresses.bundler;
1932
- if (!addr || addr === viem.zeroAddress) {
1933
- throw new Error("Bundler address not configured for this chain");
1934
- }
1935
- return addr;
1936
- }
1937
- /**
1938
- * Get the appropriate migrator address based on migration config
1939
- * Allows override via ModuleAddressOverrides when provided in params.
1940
- */
1941
- getMigratorAddress(config, overrides) {
1942
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
1943
- switch (config.type) {
1944
- case "uniswapV2":
1945
- return overrides?.v2Migrator ?? addresses.v2Migrator;
1946
- case "uniswapV4": {
1947
- const v4Address = overrides?.v4Migrator ?? addresses.v4Migrator;
1948
- if (v4Address === "0x0000000000000000000000000000000000000000") {
1949
- throw new Error(
1950
- "UniswapV4Migrator not deployed on this chain. Use uniswapV2 migration or provide override via modules.v4Migrator."
1951
- );
1952
- }
1953
- return v4Address;
1954
- }
1955
- case "dopplerHook": {
1956
- const dopplerHookMigratorAddress = overrides?.dopplerHookMigrator ?? addresses.dopplerHookMigrator;
1957
- if (!dopplerHookMigratorAddress || dopplerHookMigratorAddress === chunk6BQY5EPB_js.ZERO_ADDRESS) {
1958
- throw new Error(
1959
- "DopplerHookMigrator not configured on this chain. Provide override via modules.dopplerHookMigrator or use a different migration type."
1960
- );
1961
- }
1962
- return dopplerHookMigratorAddress;
1963
- }
1964
- case "noOp": {
1965
- const noOpAddress = overrides?.noOpMigrator ?? addresses.noOpMigrator;
1966
- if (!noOpAddress) {
1967
- throw new Error(
1968
- "NoOpMigrator not configured on this chain. Provide override via modules.noOpMigrator or update chain config."
1969
- );
1970
- }
1971
- return noOpAddress;
1972
- }
1973
- default:
1974
- throw new Error("Unknown migration type");
1975
- }
1976
- }
1977
- // computeTicks moved to builders. No longer needed here.
1978
- // computeOptimalGamma moved to utils.
1979
- // -----------------------------
1980
- // Bundler helpers (Static/V3)
1981
- // -----------------------------
1982
- /**
1983
- * Simulate a bundle with exact input on Uniswap V3 as part of create
1984
- * Returns the expected output amount for the provided exact input.
1985
- */
1986
- async simulateBundleExactInput(createParams, params) {
1987
- const bundler = this.getBundlerAddress();
1988
- const { result } = await this.publicClient.simulateContract({
1989
- address: bundler,
1990
- abi: chunk3MVW6UIW_js.bundlerAbi,
1991
- functionName: "simulateBundleExactIn",
1992
- args: [
1993
- { ...createParams },
1994
- {
1995
- tokenIn: params.tokenIn,
1996
- tokenOut: params.tokenOut,
1997
- amountIn: params.amountIn,
1998
- fee: params.fee,
1999
- sqrtPriceLimitX96: params.sqrtPriceLimitX96
2000
- }
2001
- ]
2002
- });
2003
- return result;
2004
- }
2005
- /**
2006
- * Simulate a bundle with exact output on Uniswap V3 as part of create
2007
- * Returns the required input amount for the provided exact output.
2008
- */
2009
- async simulateBundleExactOutput(createParams, params) {
2010
- const bundler = this.getBundlerAddress();
2011
- const { result } = await this.publicClient.simulateContract({
2012
- address: bundler,
2013
- abi: chunk3MVW6UIW_js.bundlerAbi,
2014
- functionName: "simulateBundleExactOut",
2015
- args: [
2016
- { ...createParams },
2017
- {
2018
- tokenIn: params.tokenIn,
2019
- tokenOut: params.tokenOut,
2020
- amount: params.amount,
2021
- fee: params.fee,
2022
- sqrtPriceLimitX96: params.sqrtPriceLimitX96
2023
- }
2024
- ]
2025
- });
2026
- return result;
2027
- }
2028
- // Bundler helpers (Multicurve/V4)
2029
- async simulateMulticurveBundleExactOut(createParams, params) {
2030
- const bundler = this.getBundlerAddress();
2031
- await this.ensureMulticurveBundlerSupport(bundler);
2032
- const exactAmountOut = params?.exactAmountOut ?? 0n;
2033
- this.ensureUint128(exactAmountOut, "exactAmountOut", { allowZero: true });
2034
- const hookData = "0x";
2035
- const { result } = await this.publicClient.simulateContract({
2036
- address: bundler,
2037
- abi: chunk3MVW6UIW_js.bundlerAbi,
2038
- functionName: "simulateMulticurveBundleExactOut",
2039
- args: [{ ...createParams }, exactAmountOut, hookData]
2040
- });
2041
- const { asset, poolKey, amount, gasEstimate } = this.parseMulticurveBundleResult(result);
2042
- return {
2043
- asset,
2044
- poolKey,
2045
- amountIn: amount,
2046
- gasEstimate
2047
- };
2048
- }
2049
- async simulateMulticurveBundleExactIn(createParams, params) {
2050
- const bundler = this.getBundlerAddress();
2051
- await this.ensureMulticurveBundlerSupport(bundler);
2052
- if (params.exactAmountIn === void 0) {
2053
- throw new Error(
2054
- "exactAmountIn is required for multicurve bundle simulations"
2055
- );
2056
- }
2057
- const exactAmountIn = params.exactAmountIn;
2058
- this.ensureUint128(exactAmountIn, "exactAmountIn");
2059
- const hookData = "0x";
2060
- const { result } = await this.publicClient.simulateContract({
2061
- address: bundler,
2062
- abi: chunk3MVW6UIW_js.bundlerAbi,
2063
- functionName: "simulateMulticurveBundleExactIn",
2064
- args: [{ ...createParams }, exactAmountIn, hookData]
2065
- });
2066
- const { asset, poolKey, amount, gasEstimate } = this.parseMulticurveBundleResult(result);
2067
- return {
2068
- asset,
2069
- poolKey,
2070
- amountOut: amount,
2071
- gasEstimate
2072
- };
2073
- }
2074
- /**
2075
- * Execute an atomic create + swap bundle through the Bundler
2076
- * commands/inputs are Universal Router encoded values (e.g., from doppler-router)
2077
- */
2078
- async bundle(createParams, commands, inputs, options) {
2079
- if (!this.walletClient) {
2080
- throw new Error("Wallet client required for write operations");
2081
- }
2082
- const bundler = this.getBundlerAddress();
2083
- const { request } = await this.publicClient.simulateContract({
2084
- address: bundler,
2085
- abi: chunk3MVW6UIW_js.bundlerAbi,
2086
- functionName: "bundle",
2087
- args: [{ ...createParams }, commands, inputs],
2088
- account: this.walletClient.account,
2089
- value: options?.value ?? 0n
2090
- });
2091
- const gas = options?.gas ?? void 0;
2092
- const tx = await this.walletClient.writeContract(
2093
- gas ? { ...request, gas } : request
2094
- );
2095
- return tx;
2096
- }
2097
- ensureUint128(value, paramName, options = {}) {
2098
- const { allowZero = false } = options;
2099
- if (value < 0n) {
2100
- throw new Error(`${paramName} cannot be negative`);
2101
- }
2102
- if (!allowZero && value === 0n) {
2103
- throw new Error(`${paramName} must be greater than zero`);
2104
- }
2105
- if (value > MAX_UINT128) {
2106
- throw new Error(`${paramName} exceeds uint128 range`);
2107
- }
2108
- }
2109
- parseMulticurveBundleResult(result) {
2110
- let asset;
2111
- let poolKeyRaw;
2112
- let amount;
2113
- let gasEstimate;
2114
- if (Array.isArray(result)) {
2115
- if (result.length < 4) {
2116
- throw new Error("Unexpected multicurve bundle simulation result shape");
2117
- }
2118
- asset = result[0];
2119
- poolKeyRaw = result[1];
2120
- amount = result[2];
2121
- gasEstimate = result[3];
2122
- } else if (result && typeof result === "object") {
2123
- const obj = result;
2124
- asset = obj.asset;
2125
- poolKeyRaw = obj.poolKey;
2126
- amount = obj.amountIn ?? obj.amountOut ?? obj.amount;
2127
- gasEstimate = obj.gasEstimate;
2128
- } else {
2129
- throw new Error("Unexpected multicurve bundle simulation result format");
2130
- }
2131
- if (asset === void 0 || poolKeyRaw === void 0 || amount === void 0 || gasEstimate === void 0) {
2132
- throw new Error("Incomplete multicurve bundle simulation result");
2133
- }
2134
- return {
2135
- asset,
2136
- poolKey: this.normalizePoolKey(poolKeyRaw),
2137
- amount,
2138
- gasEstimate
2139
- };
2140
- }
2141
- normalizePoolKey(value) {
2142
- if (Array.isArray(value)) {
2143
- const [currency0, currency1, feeRaw, tickSpacingRaw, hooks] = value;
2144
- const feeValue = Number(feeRaw);
2145
- const tickSpacingValue = Number(tickSpacingRaw);
2146
- if (!Number.isFinite(feeValue) || !Number.isFinite(tickSpacingValue)) {
2147
- throw new Error(
2148
- "Invalid pool key numeric fields in multicurve bundle simulation result"
2149
- );
2150
- }
2151
- return {
2152
- currency0,
2153
- currency1,
2154
- fee: feeValue,
2155
- tickSpacing: tickSpacingValue,
2156
- hooks
2157
- };
2158
- }
2159
- if (value && typeof value === "object") {
2160
- const { currency0, currency1, fee, tickSpacing, hooks } = value;
2161
- const feeValue = Number(fee);
2162
- const tickSpacingValue = Number(tickSpacing);
2163
- if (!Number.isFinite(feeValue) || !Number.isFinite(tickSpacingValue)) {
2164
- throw new Error(
2165
- "Invalid pool key numeric fields in multicurve bundle simulation result"
2166
- );
2167
- }
2168
- return {
2169
- currency0,
2170
- currency1,
2171
- fee: feeValue,
2172
- tickSpacing: tickSpacingValue,
2173
- hooks
2174
- };
2175
- }
2176
- throw new Error(
2177
- "Unable to normalize PoolKey from multicurve bundle simulation result"
2178
- );
2179
- }
2180
- /**
2181
- * Mines a salt and hook address with the appropriate flags
2182
- *
2183
- * This method iterates through possible salt values to find a combination that:
2184
- * - Produces a hook address with required Doppler flags
2185
- * - Maintains proper token ordering relative to numeraire
2186
- * - Ensures deterministic deployment addresses
2187
- *
2188
- * @param params - Parameters for hook address mining
2189
- * @returns Tuple of [salt, hook address, token address, pool data, token data]
2190
- * @throws {Error} If no valid salt can be found within the search limit
2191
- * @private
2192
- */
2193
- mineHookAddress(params) {
2194
- const isToken0 = chunk6H6X3VTZ_js.isToken0Expected(params.numeraire);
2195
- const {
2196
- minimumProceeds,
2197
- maximumProceeds,
2198
- startingTime,
2199
- endingTime,
2200
- startingTick,
2201
- endingTick,
2202
- epochLength,
2203
- gamma,
2204
- numPDSlugs,
2205
- fee,
2206
- tickSpacing
2207
- } = params.poolInitializerData;
2208
- const poolInitializerData = viem.encodeAbiParameters(
2209
- [
2210
- { type: "uint256" },
2211
- { type: "uint256" },
2212
- { type: "uint256" },
2213
- { type: "uint256" },
2214
- { type: "int24" },
2215
- { type: "int24" },
2216
- { type: "uint256" },
2217
- { type: "int24" },
2218
- { type: "bool" },
2219
- { type: "uint256" },
2220
- { type: "uint24" },
2221
- { type: "int24" }
2222
- ],
2223
- [
2224
- minimumProceeds,
2225
- maximumProceeds,
2226
- startingTime,
2227
- endingTime,
2228
- startingTick,
2229
- endingTick,
2230
- epochLength,
2231
- gamma,
2232
- isToken0,
2233
- numPDSlugs,
2234
- fee,
2235
- tickSpacing
2236
- ]
2237
- );
2238
- const { poolManager, numTokensToSell, poolInitializer } = params;
2239
- const hookInitHashData = viem.encodeAbiParameters(
2240
- [
2241
- { type: "address" },
2242
- { type: "uint256" },
2243
- { type: "uint256" },
2244
- { type: "uint256" },
2245
- { type: "uint256" },
2246
- { type: "uint256" },
2247
- { type: "int24" },
2248
- { type: "int24" },
2249
- { type: "uint256" },
2250
- { type: "int24" },
2251
- { type: "bool" },
2252
- { type: "uint256" },
2253
- { type: "address" },
2254
- { type: "uint24" }
2255
- ],
2256
- [
2257
- poolManager,
2258
- numTokensToSell,
2259
- minimumProceeds,
2260
- maximumProceeds,
2261
- startingTime,
2262
- endingTime,
2263
- startingTick,
2264
- endingTick,
2265
- epochLength,
2266
- gamma,
2267
- isToken0,
2268
- numPDSlugs,
2269
- poolInitializer,
2270
- fee
2271
- ]
2272
- );
2273
- const hookInitHash = viem.keccak256(
2274
- viem.encodePacked(
2275
- ["bytes", "bytes"],
2276
- [chunkXMFOZYNI_js.doppler_default, hookInitHashData]
2277
- )
2278
- );
2279
- const tokenFactoryData = params.tokenVariant === "doppler404" ? (() => {
2280
- const t = params.tokenFactoryData;
2281
- return viem.encodeAbiParameters(
2282
- [
2283
- { type: "string" },
2284
- { type: "string" },
2285
- { type: "string" },
2286
- { type: "uint256" }
2287
- ],
2288
- [t.name, t.symbol, t.baseURI, t.unit ?? 1000n]
2289
- );
2290
- })() : (() => {
2291
- const {
2292
- name,
2293
- symbol,
2294
- yearlyMintRate,
2295
- vestingDuration,
2296
- recipients,
2297
- amounts,
2298
- tokenURI
2299
- } = params.tokenFactoryData;
2300
- return viem.encodeAbiParameters(
2301
- [
2302
- { type: "string" },
2303
- { type: "string" },
2304
- { type: "uint256" },
2305
- { type: "uint256" },
2306
- { type: "address[]" },
2307
- { type: "uint256[]" },
2308
- { type: "string" }
2309
- ],
2310
- [
2311
- name,
2312
- symbol,
2313
- yearlyMintRate,
2314
- vestingDuration,
2315
- recipients,
2316
- amounts,
2317
- tokenURI
2318
- ]
2319
- );
2320
- })();
2321
- let tokenInitHash;
2322
- if (params.tokenVariant === "doppler404") {
2323
- const { name, symbol, baseURI } = params.tokenFactoryData;
2324
- const { airlock, initialSupply } = params;
2325
- const initHashData = viem.encodeAbiParameters(
2326
- [
2327
- { type: "string" },
2328
- { type: "string" },
2329
- { type: "uint256" },
2330
- { type: "address" },
2331
- { type: "address" },
2332
- { type: "string" }
2333
- ],
2334
- [name, symbol, initialSupply, airlock, airlock, baseURI]
2335
- );
2336
- tokenInitHash = viem.keccak256(
2337
- viem.encodePacked(
2338
- ["bytes", "bytes"],
2339
- [chunkQAPQGDWK_js.dopplerDN404_default, initHashData]
2340
- )
2341
- );
2342
- } else {
2343
- const {
2344
- name,
2345
- symbol,
2346
- yearlyMintRate,
2347
- vestingDuration,
2348
- recipients,
2349
- amounts,
2350
- tokenURI
2351
- } = params.tokenFactoryData;
2352
- const { airlock, initialSupply } = params;
2353
- const initHashData = viem.encodeAbiParameters(
2354
- [
2355
- { type: "string" },
2356
- { type: "string" },
2357
- { type: "uint256" },
2358
- { type: "address" },
2359
- { type: "address" },
2360
- { type: "uint256" },
2361
- { type: "uint256" },
2362
- { type: "address[]" },
2363
- { type: "uint256[]" },
2364
- { type: "string" }
2365
- ],
2366
- [
2367
- name,
2368
- symbol,
2369
- initialSupply,
2370
- airlock,
2371
- airlock,
2372
- yearlyMintRate,
2373
- vestingDuration,
2374
- recipients,
2375
- amounts,
2376
- tokenURI
2377
- ]
2378
- );
2379
- const isTokenFactory80 = params.tokenFactory.toLowerCase() === TOKEN_FACTORY_80_ADDRESS;
2380
- const bytecode = isTokenFactory80 ? chunkJ62YDWIK_js.derc2080_default : params.customDerc20Bytecode ?? chunkQRTABC4Z_js.derc20_default;
2381
- tokenInitHash = viem.keccak256(
2382
- viem.encodePacked(["bytes", "bytes"], [bytecode, initHashData])
2383
- );
2384
- }
2385
- const flags = BigInt(
2386
- 1 << 13 | // BEFORE_INITIALIZE_FLAG
2387
- 1 << 12 | // AFTER_INITIALIZE_FLAG
2388
- 1 << 11 | // BEFORE_ADD_LIQUIDITY_FLAG
2389
- 1 << 7 | // BEFORE_SWAP_FLAG
2390
- 1 << 6 | // AFTER_SWAP_FLAG
2391
- 1 << 5
2392
- // BEFORE_DONATE_FLAG
2393
- );
2394
- const numeraireBigInt = BigInt(params.numeraire);
2395
- const hookBuffer = this.prepareCreate2Buffer(params.deployer, hookInitHash);
2396
- const tokenBuffer = tokenInitHash ? this.prepareCreate2Buffer(params.tokenFactory, tokenInitHash) : null;
2397
- for (let salt = 0n; salt < 1000000n; salt++) {
2398
- this.updateSaltInBuffer(hookBuffer, salt);
2399
- const hookRaw = this.computeCreate2AddressFast(hookBuffer);
2400
- const hookBigInt = BigInt(hookRaw);
2401
- if ((hookBigInt & chunk6BQY5EPB_js.FLAG_MASK) !== flags) {
2402
- continue;
2403
- }
2404
- if (tokenBuffer) {
2405
- this.updateSaltInBuffer(tokenBuffer, salt);
2406
- const tokenRaw = this.computeCreate2AddressFast(tokenBuffer);
2407
- const tokenBigInt = BigInt(tokenRaw);
2408
- if (isToken0 && tokenBigInt < numeraireBigInt || !isToken0 && tokenBigInt > numeraireBigInt) {
2409
- const saltBytes = `0x${salt.toString(16).padStart(64, "0")}`;
2410
- const hook = viem.getAddress(hookRaw);
2411
- const token = viem.getAddress(tokenRaw);
2412
- return [
2413
- saltBytes,
2414
- hook,
2415
- token,
2416
- poolInitializerData,
2417
- tokenFactoryData
2418
- ];
2419
- }
2420
- }
2421
- }
2422
- throw new Error("AirlockMiner: could not find salt");
2423
- }
2424
- /**
2425
- * Computes the CREATE2 address for a contract deployment
2426
- * @param salt - The salt used for deployment
2427
- * @param initCodeHash - Hash of the initialization code
2428
- * @param deployer - Address of the deploying contract
2429
- * @returns The computed contract address
2430
- * @private
2431
- */
2432
- computeCreate2Address(salt, initCodeHash, deployer) {
2433
- const encoded = viem.encodePacked(
2434
- ["bytes1", "address", "bytes32", "bytes32"],
2435
- ["0xff", deployer, salt, initCodeHash]
2436
- );
2437
- return viem.getAddress(`0x${viem.keccak256(encoded).slice(-40)}`);
2438
- }
2439
- /**
2440
- * Helper to convert hex string to Uint8Array
2441
- * @private
2442
- */
2443
- hexToBytes(hex) {
2444
- const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
2445
- const bytes = new Uint8Array(cleanHex.length / 2);
2446
- for (let i = 0; i < bytes.length; i++) {
2447
- bytes[i] = parseInt(cleanHex.substr(i * 2, 2), 16);
2448
- }
2449
- return bytes;
2450
- }
2451
- /**
2452
- * Helper to convert Uint8Array to hex string
2453
- * @private
2454
- */
2455
- bytesToHex(bytes) {
2456
- return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
2457
- }
2458
- /**
2459
- * Pre-compute CREATE2 buffer with constant prefix for fast mining
2460
- * Buffer layout: 0xff (1 byte) + deployer (20 bytes) + salt (32 bytes) + initCodeHash (32 bytes) = 85 bytes
2461
- * @private
2462
- */
2463
- prepareCreate2Buffer(deployer, initCodeHash) {
2464
- const buffer = new Uint8Array(85);
2465
- buffer[0] = 255;
2466
- const deployerBytes = this.hexToBytes(deployer);
2467
- buffer.set(deployerBytes, 1);
2468
- const initCodeHashBytes = this.hexToBytes(initCodeHash);
2469
- buffer.set(initCodeHashBytes, 53);
2470
- return buffer;
2471
- }
2472
- /**
2473
- * Update salt in pre-computed CREATE2 buffer (bytes 21-52)
2474
- * Uses direct byte manipulation instead of string conversion
2475
- * @private
2476
- */
2477
- updateSaltInBuffer(buffer, salt) {
2478
- for (let i = 21; i < 53; i++) {
2479
- buffer[i] = 0;
2480
- }
2481
- let remaining = salt;
2482
- for (let i = 52; remaining > 0n && i >= 21; i--) {
2483
- buffer[i] = Number(remaining & 0xffn);
2484
- remaining >>= 8n;
2485
- }
2486
- }
2487
- /**
2488
- * Compute CREATE2 address from pre-computed buffer (fast version for mining)
2489
- * Returns raw lowercase address without checksum for comparison
2490
- * @private
2491
- */
2492
- computeCreate2AddressFast(buffer) {
2493
- const hash = viem.keccak256(this.bytesToHex(buffer));
2494
- return "0x" + hash.slice(-40).toLowerCase();
2495
- }
2496
- /**
2497
- * Compute V4 pool ID from pool key components
2498
- */
2499
- computePoolId(poolKey) {
2500
- const encoded = viem.encodeAbiParameters(
2501
- [
2502
- { type: "address" },
2503
- { type: "address" },
2504
- { type: "uint24" },
2505
- { type: "int24" },
2506
- { type: "address" }
2507
- ],
2508
- [
2509
- poolKey.currency0,
2510
- poolKey.currency1,
2511
- poolKey.fee,
2512
- poolKey.tickSpacing,
2513
- poolKey.hooks
2514
- ]
2515
- );
2516
- return viem.keccak256(encoded);
2517
- }
2518
- /**
2519
- * Compute the V4 poolId for a multicurve pool by reading the hook address from the initializer
2520
- */
2521
- async computeMulticurvePoolId(params, tokenAddress) {
2522
- const addresses = chunk7CAAI5DL_js.getAddresses(this.chainId);
2523
- const initializerMode = this.resolveMulticurveInitializerMode(params);
2524
- let hookAddress;
2525
- if (initializerMode.type === "rehype") {
2526
- hookAddress = initializerMode.hookConfig?.hookAddress ?? chunk6BQY5EPB_js.ZERO_ADDRESS;
2527
- } else {
2528
- const initializerAddress = (() => {
2529
- if (initializerMode.type === "decay") {
2530
- return params.modules?.v4DecayMulticurveInitializer ?? addresses.v4DecayMulticurveInitializer;
2531
- }
2532
- if (initializerMode.type === "scheduled") {
2533
- return params.modules?.v4ScheduledMulticurveInitializer ?? addresses.v4ScheduledMulticurveInitializer;
2534
- }
2535
- return params.modules?.v4MulticurveInitializer ?? addresses.v4MulticurveInitializer;
2536
- })();
2537
- if (!initializerAddress) {
2538
- throw new Error("Multicurve initializer address not configured");
2539
- }
2540
- hookAddress = await this.publicClient.readContract({
2541
- address: initializerAddress,
2542
- abi: chunk3MVW6UIW_js.v4MulticurveInitializerAbi,
2543
- functionName: "HOOK"
2544
- });
2545
- }
2546
- const numeraire = params.sale.numeraire;
2547
- const currency0 = tokenAddress < numeraire ? tokenAddress : numeraire;
2548
- const currency1 = tokenAddress < numeraire ? numeraire : tokenAddress;
2549
- const fee = initializerMode.type === "decay" ? chunk6BQY5EPB_js.DYNAMIC_FEE_FLAG : params.pool.fee;
2550
- return this.computePoolId({
2551
- currency0,
2552
- currency1,
2553
- fee,
2554
- tickSpacing: params.pool.tickSpacing,
2555
- hooks: hookAddress
2556
- });
2557
- }
2558
- async ensureMulticurveBundlerSupport(bundler) {
2559
- if (this.multicurveBundlerSupport.get(bundler)) {
2560
- return;
2561
- }
2562
- const client = this.publicClient;
2563
- if (!client || typeof client.getBytecode !== "function") {
2564
- this.multicurveBundlerSupport.set(bundler, true);
2565
- return;
2566
- }
2567
- const bytecode = await client.getBytecode({ address: bundler });
2568
- const supports = Boolean(
2569
- bytecode && MULTICURVE_BUNDLER_SELECTORS.every(
2570
- (selector) => bytecode.includes(selector.slice(2))
2571
- )
2572
- );
2573
- if (!supports) {
2574
- throw new Error(
2575
- `Bundler at ${bundler} does not support multicurve bundling. Ensure the Doppler Bundler has been upgraded and update chain addresses.`
2576
- );
2577
- }
2578
- this.multicurveBundlerSupport.set(bundler, true);
2579
- }
2580
- };
2581
- var MULTICURVE_BUNDLER_SELECTORS = ["0xe2e9faa1", "0x07087b06"];
2582
-
2583
- exports.DopplerFactory = DopplerFactory;
2584
- //# sourceMappingURL=chunk-6UHDSD42.js.map
2585
- //# sourceMappingURL=chunk-6UHDSD42.js.map