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