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