@whetstone-research/doppler-sdk 0.0.23 → 1.0.0

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