@whetstone-research/doppler-sdk 0.0.17 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/README.md +66 -1
  2. package/dist/DopplerSDK.js +19 -19
  3. package/dist/DopplerSDK.mjs +18 -18
  4. package/dist/abis/index.d.mts +32 -1
  5. package/dist/abis/index.d.ts +32 -1
  6. package/dist/abis/index.js +26 -22
  7. package/dist/abis/index.mjs +1 -1
  8. package/dist/addresses.d.mts +1 -0
  9. package/dist/addresses.d.ts +1 -0
  10. package/dist/addresses.js +7 -7
  11. package/dist/addresses.mjs +2 -2
  12. package/dist/builders/DynamicAuctionBuilder.js +10 -10
  13. package/dist/builders/DynamicAuctionBuilder.mjs +9 -9
  14. package/dist/builders/MulticurveBuilder.d.mts +16 -0
  15. package/dist/builders/MulticurveBuilder.d.ts +16 -0
  16. package/dist/builders/MulticurveBuilder.js +10 -10
  17. package/dist/builders/MulticurveBuilder.mjs +9 -9
  18. package/dist/builders/StaticAuctionBuilder.js +10 -10
  19. package/dist/builders/StaticAuctionBuilder.mjs +9 -9
  20. package/dist/builders/index.js +18 -18
  21. package/dist/builders/index.mjs +11 -11
  22. package/dist/builders/shared.js +11 -11
  23. package/dist/builders/shared.mjs +7 -7
  24. package/dist/{chunk-LOVD3NCN.js → chunk-3MVW6UIW.js} +18 -2
  25. package/dist/chunk-3MVW6UIW.js.map +1 -0
  26. package/dist/{chunk-DVAQB7TB.mjs → chunk-3NFSMMBF.mjs} +3 -3
  27. package/dist/{chunk-DVAQB7TB.mjs.map → chunk-3NFSMMBF.mjs.map} +1 -1
  28. package/dist/{chunk-PBWOCVDZ.mjs → chunk-4TAAZ6W3.mjs} +248 -51
  29. package/dist/chunk-4TAAZ6W3.mjs.map +1 -0
  30. package/dist/{chunk-4DUE547M.js → chunk-6BQY5EPB.js} +4 -2
  31. package/dist/chunk-6BQY5EPB.js.map +1 -0
  32. package/dist/{chunk-HVM7KZJM.mjs → chunk-6HFZ6XMV.mjs} +4 -4
  33. package/dist/{chunk-HVM7KZJM.mjs.map → chunk-6HFZ6XMV.mjs.map} +1 -1
  34. package/dist/{chunk-EG6O2TUX.js → chunk-7Z2UGWE7.js} +26 -26
  35. package/dist/{chunk-EG6O2TUX.js.map → chunk-7Z2UGWE7.js.map} +1 -1
  36. package/dist/{chunk-O2DZH23A.mjs → chunk-CYY5IATT.mjs} +9 -5
  37. package/dist/chunk-CYY5IATT.mjs.map +1 -0
  38. package/dist/{chunk-BZKX3J3R.mjs → chunk-E2NF4AQB.mjs} +18 -3
  39. package/dist/chunk-E2NF4AQB.mjs.map +1 -0
  40. package/dist/{chunk-B4B7BXLI.js → chunk-E6ACC5S6.js} +24 -24
  41. package/dist/{chunk-B4B7BXLI.js.map → chunk-E6ACC5S6.js.map} +1 -1
  42. package/dist/{chunk-K5CV3MIH.mjs → chunk-FQ3PVXZU.mjs} +5 -5
  43. package/dist/{chunk-K5CV3MIH.mjs.map → chunk-FQ3PVXZU.mjs.map} +1 -1
  44. package/dist/{chunk-WQKBQRBS.mjs → chunk-GCT3IZ3E.mjs} +12 -12
  45. package/dist/{chunk-WQKBQRBS.mjs.map → chunk-GCT3IZ3E.mjs.map} +1 -1
  46. package/dist/{chunk-LDZCTC5Q.mjs → chunk-H5SUGQ2C.mjs} +45 -7
  47. package/dist/chunk-H5SUGQ2C.mjs.map +1 -0
  48. package/dist/{chunk-PE47QUJV.mjs → chunk-HH7HQ4HC.mjs} +3 -3
  49. package/dist/{chunk-PE47QUJV.mjs.map → chunk-HH7HQ4HC.mjs.map} +1 -1
  50. package/dist/{chunk-LXUF7RNX.mjs → chunk-IWJOPXYN.mjs} +4 -3
  51. package/dist/chunk-IWJOPXYN.mjs.map +1 -0
  52. package/dist/{chunk-MBOKYN2Y.js → chunk-K3TEDYUG.js} +20 -20
  53. package/dist/{chunk-MBOKYN2Y.js.map → chunk-K3TEDYUG.js.map} +1 -1
  54. package/dist/{chunk-NVVEUALG.mjs → chunk-MH74WYVZ.mjs} +5 -5
  55. package/dist/{chunk-NVVEUALG.mjs.map → chunk-MH74WYVZ.mjs.map} +1 -1
  56. package/dist/{chunk-ZVH7VBH5.mjs → chunk-N74ICDSX.mjs} +118 -20
  57. package/dist/chunk-N74ICDSX.mjs.map +1 -0
  58. package/dist/{chunk-C7GN6GPG.js → chunk-OROTK4OT.js} +51 -27
  59. package/dist/chunk-OROTK4OT.js.map +1 -0
  60. package/dist/{chunk-Z7ZGPSQF.js → chunk-P4BT5GDO.js} +76 -72
  61. package/dist/chunk-P4BT5GDO.js.map +1 -0
  62. package/dist/{chunk-YBDWQTUH.mjs → chunk-QFQXHDC7.mjs} +76 -9
  63. package/dist/chunk-QFQXHDC7.mjs.map +1 -0
  64. package/dist/{chunk-RKJ2466C.mjs → chunk-QOGBOT2M.mjs} +3 -3
  65. package/dist/{chunk-RKJ2466C.mjs.map → chunk-QOGBOT2M.mjs.map} +1 -1
  66. package/dist/{chunk-3ALNQHGL.js → chunk-RLUMYHPI.js} +76 -9
  67. package/dist/chunk-RLUMYHPI.js.map +1 -0
  68. package/dist/{chunk-5FJCRKQ6.js → chunk-RXUJ4DUB.js} +28 -28
  69. package/dist/{chunk-5FJCRKQ6.js.map → chunk-RXUJ4DUB.js.map} +1 -1
  70. package/dist/{chunk-MGLI4N4B.js → chunk-SAX7P3MH.js} +22 -22
  71. package/dist/{chunk-MGLI4N4B.js.map → chunk-SAX7P3MH.js.map} +1 -1
  72. package/dist/{chunk-3ORKVXQL.js → chunk-TJCMFITE.js} +27 -27
  73. package/dist/{chunk-3ORKVXQL.js.map → chunk-TJCMFITE.js.map} +1 -1
  74. package/dist/{chunk-TL7U67CX.js → chunk-UIPSHVT4.js} +11 -11
  75. package/dist/{chunk-TL7U67CX.js.map → chunk-UIPSHVT4.js.map} +1 -1
  76. package/dist/{chunk-5ZPBKSNS.mjs → chunk-UY4TVYEU.mjs} +3 -3
  77. package/dist/{chunk-5ZPBKSNS.mjs.map → chunk-UY4TVYEU.mjs.map} +1 -1
  78. package/dist/{chunk-PQUS2LCD.js → chunk-UZTVXZP3.js} +16 -16
  79. package/dist/{chunk-PQUS2LCD.js.map → chunk-UZTVXZP3.js.map} +1 -1
  80. package/dist/{chunk-HMZEYBFO.mjs → chunk-V32Q2S3U.mjs} +4 -4
  81. package/dist/{chunk-HMZEYBFO.mjs.map → chunk-V32Q2S3U.mjs.map} +1 -1
  82. package/dist/{chunk-7F4O7NPS.js → chunk-V5GPJ6S2.js} +26 -26
  83. package/dist/{chunk-7F4O7NPS.js.map → chunk-V5GPJ6S2.js.map} +1 -1
  84. package/dist/{chunk-DOWDXOTK.mjs → chunk-VGCXJRUV.mjs} +51 -27
  85. package/dist/chunk-VGCXJRUV.mjs.map +1 -0
  86. package/dist/{chunk-J32XSN44.js → chunk-WYRM5BAI.js} +344 -147
  87. package/dist/chunk-WYRM5BAI.js.map +1 -0
  88. package/dist/{chunk-OUUFER2X.mjs → chunk-X7FRTHUL.mjs} +4 -4
  89. package/dist/{chunk-OUUFER2X.mjs.map → chunk-X7FRTHUL.mjs.map} +1 -1
  90. package/dist/{chunk-E54BP2GN.js → chunk-Y6VZD4C6.js} +53 -15
  91. package/dist/chunk-Y6VZD4C6.js.map +1 -0
  92. package/dist/{chunk-5MP6AMPB.js → chunk-YFJUIO2A.js} +132 -34
  93. package/dist/chunk-YFJUIO2A.js.map +1 -0
  94. package/dist/{chunk-WHQHXYPB.js → chunk-YKRDFXU3.js} +5 -5
  95. package/dist/{chunk-WHQHXYPB.js.map → chunk-YKRDFXU3.js.map} +1 -1
  96. package/dist/constants.d.mts +7 -1
  97. package/dist/constants.d.ts +7 -1
  98. package/dist/constants.js +51 -47
  99. package/dist/constants.mjs +1 -1
  100. package/dist/deployments.generated.d.mts +72 -5
  101. package/dist/deployments.generated.d.ts +72 -5
  102. package/dist/deployments.generated.js +2 -2
  103. package/dist/deployments.generated.mjs +1 -1
  104. package/dist/entities/DopplerFactory.d.mts +2 -0
  105. package/dist/entities/DopplerFactory.d.ts +2 -0
  106. package/dist/entities/DopplerFactory.js +8 -8
  107. package/dist/entities/DopplerFactory.mjs +7 -7
  108. package/dist/entities/auction/DynamicAuction.js +5 -5
  109. package/dist/entities/auction/DynamicAuction.mjs +4 -4
  110. package/dist/entities/auction/MulticurvePool.d.mts +9 -3
  111. package/dist/entities/auction/MulticurvePool.d.ts +9 -3
  112. package/dist/entities/auction/MulticurvePool.js +7 -6
  113. package/dist/entities/auction/MulticurvePool.mjs +6 -5
  114. package/dist/entities/auction/StaticAuction.js +5 -5
  115. package/dist/entities/auction/StaticAuction.mjs +4 -4
  116. package/dist/entities/auction/index.js +11 -10
  117. package/dist/entities/auction/index.mjs +8 -7
  118. package/dist/entities/quoter/Quoter.js +5 -5
  119. package/dist/entities/quoter/Quoter.mjs +4 -4
  120. package/dist/entities/quoter/index.js +5 -5
  121. package/dist/entities/quoter/index.mjs +4 -4
  122. package/dist/entities/token/derc20/Derc20.js +3 -3
  123. package/dist/entities/token/derc20/Derc20.mjs +2 -2
  124. package/dist/entities/token/derc20/index.js +3 -3
  125. package/dist/entities/token/derc20/index.mjs +2 -2
  126. package/dist/entities/token/index.js +3 -3
  127. package/dist/entities/token/index.mjs +2 -2
  128. package/dist/index.d.mts +3 -3
  129. package/dist/index.d.ts +3 -3
  130. package/dist/index.js +110 -102
  131. package/dist/index.js.map +1 -1
  132. package/dist/index.mjs +18 -18
  133. package/dist/index.mjs.map +1 -1
  134. package/dist/types.d.mts +32 -1
  135. package/dist/types.d.ts +32 -1
  136. package/dist/types.js +8 -8
  137. package/dist/types.mjs +3 -3
  138. package/dist/utils/airlock.js +7 -7
  139. package/dist/utils/airlock.mjs +3 -3
  140. package/dist/utils/index.js +10 -10
  141. package/dist/utils/index.mjs +5 -5
  142. package/dist/utils/tokenAddressMiner.d.mts +7 -0
  143. package/dist/utils/tokenAddressMiner.d.ts +7 -0
  144. package/dist/utils/tokenAddressMiner.js +3 -3
  145. package/dist/utils/tokenAddressMiner.mjs +2 -2
  146. package/package.json +1 -1
  147. package/dist/chunk-3ALNQHGL.js.map +0 -1
  148. package/dist/chunk-4DUE547M.js.map +0 -1
  149. package/dist/chunk-5MP6AMPB.js.map +0 -1
  150. package/dist/chunk-BZKX3J3R.mjs.map +0 -1
  151. package/dist/chunk-C7GN6GPG.js.map +0 -1
  152. package/dist/chunk-DOWDXOTK.mjs.map +0 -1
  153. package/dist/chunk-E54BP2GN.js.map +0 -1
  154. package/dist/chunk-J32XSN44.js.map +0 -1
  155. package/dist/chunk-LDZCTC5Q.mjs.map +0 -1
  156. package/dist/chunk-LOVD3NCN.js.map +0 -1
  157. package/dist/chunk-LXUF7RNX.mjs.map +0 -1
  158. package/dist/chunk-O2DZH23A.mjs.map +0 -1
  159. package/dist/chunk-PBWOCVDZ.mjs.map +0 -1
  160. package/dist/chunk-YBDWQTUH.mjs.map +0 -1
  161. package/dist/chunk-Z7ZGPSQF.js.map +0 -1
  162. package/dist/chunk-ZVH7VBH5.mjs.map +0 -1
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk7M57PU6V_js = require('./chunk-7M57PU6V.js');
4
- var chunkZ7ZGPSQF_js = require('./chunk-Z7ZGPSQF.js');
5
- var chunkLOVD3NCN_js = require('./chunk-LOVD3NCN.js');
4
+ var chunk6BQY5EPB_js = require('./chunk-6BQY5EPB.js');
5
+ var chunkP4BT5GDO_js = require('./chunk-P4BT5GDO.js');
6
+ var chunk3MVW6UIW_js = require('./chunk-3MVW6UIW.js');
6
7
  var viem = require('viem');
7
8
 
8
9
  var MulticurvePool = class {
@@ -25,7 +26,7 @@ var MulticurvePool = class {
25
26
  /**
26
27
  * Get current pool state from the multicurve initializer
27
28
  *
28
- * Automatically discovers which initializer (standard or scheduled) contains the pool.
29
+ * Automatically discovers which initializer (standard, scheduled, or decay) contains the pool.
29
30
  */
30
31
  async getState() {
31
32
  const { state } = await this.findInitializerForPool();
@@ -35,14 +36,15 @@ var MulticurvePool = class {
35
36
  * Find which initializer contains this pool and return both the address and state.
36
37
  *
37
38
  * Tries v4MulticurveInitializer first (more common), then falls back to
38
- * v4ScheduledMulticurveInitializer if the pool isn't found.
39
+ * v4ScheduledMulticurveInitializer and v4DecayMulticurveInitializer if needed.
39
40
  */
40
41
  async findInitializerForPool() {
41
42
  const chainId = await this.rpc.getChainId();
42
- const addresses = chunkZ7ZGPSQF_js.getAddresses(chainId);
43
+ const addresses = chunkP4BT5GDO_js.getAddresses(chainId);
43
44
  const initializersToTry = [
44
45
  addresses.v4MulticurveInitializer,
45
- addresses.v4ScheduledMulticurveInitializer
46
+ addresses.v4ScheduledMulticurveInitializer,
47
+ addresses.v4DecayMulticurveInitializer
46
48
  ].filter(
47
49
  (addr) => addr !== void 0 && addr !== viem.zeroAddress
48
50
  );
@@ -56,7 +58,7 @@ var MulticurvePool = class {
56
58
  triedInitializers.push(initializerAddress);
57
59
  const stateData = await this.rpc.readContract({
58
60
  address: initializerAddress,
59
- abi: chunkLOVD3NCN_js.v4MulticurveInitializerAbi,
61
+ abi: chunk3MVW6UIW_js.v4MulticurveInitializerAbi,
60
62
  functionName: "getState",
61
63
  args: [this.tokenAddress]
62
64
  });
@@ -93,13 +95,13 @@ var MulticurvePool = class {
93
95
  throw new Error("Wallet client required to collect fees");
94
96
  }
95
97
  const chainId = await this.rpc.getChainId();
96
- const addresses = chunkZ7ZGPSQF_js.getAddresses(chainId);
98
+ const addresses = chunkP4BT5GDO_js.getAddresses(chainId);
97
99
  const { initializerAddress, state } = await this.findInitializerForPool();
98
100
  if (state.status === 2 /* Locked */) {
99
101
  const poolId = chunk7M57PU6V_js.computePoolId(state.poolKey);
100
102
  return this.collectFeesFromContract(
101
103
  initializerAddress,
102
- chunkLOVD3NCN_js.v4MulticurveInitializerAbi,
104
+ chunk3MVW6UIW_js.v4MulticurveInitializerAbi,
103
105
  poolId
104
106
  );
105
107
  }
@@ -111,7 +113,7 @@ var MulticurvePool = class {
111
113
  }
112
114
  const assetData = await this.rpc.readContract({
113
115
  address: addresses.v4Migrator,
114
- abi: chunkLOVD3NCN_js.v4MulticurveMigratorAbi,
116
+ abi: chunk3MVW6UIW_js.v4MulticurveMigratorAbi,
115
117
  functionName: "getAssetData",
116
118
  args: [state.poolKey.currency0, state.poolKey.currency1]
117
119
  });
@@ -131,7 +133,7 @@ var MulticurvePool = class {
131
133
  );
132
134
  const streamData = await this.rpc.readContract({
133
135
  address: lockerAddress,
134
- abi: chunkLOVD3NCN_js.streamableFeesLockerAbi,
136
+ abi: chunk3MVW6UIW_js.streamableFeesLockerAbi,
135
137
  functionName: "streams",
136
138
  args: [poolId]
137
139
  });
@@ -143,7 +145,7 @@ var MulticurvePool = class {
143
145
  }
144
146
  return this.collectFeesFromContract(
145
147
  lockerAddress,
146
- chunkLOVD3NCN_js.streamableFeesLockerAbi,
148
+ chunk3MVW6UIW_js.streamableFeesLockerAbi,
147
149
  poolId
148
150
  );
149
151
  }
@@ -156,6 +158,42 @@ var MulticurvePool = class {
156
158
  const state = await this.getState();
157
159
  return state.numeraire;
158
160
  }
161
+ /**
162
+ * Get the decay fee schedule for dynamic-fee multicurve pools.
163
+ *
164
+ * Returns `null` when the pool is not using dynamic fees.
165
+ */
166
+ async getFeeSchedule() {
167
+ const { state } = await this.findInitializerForPool();
168
+ if (state.poolKey.fee !== chunk6BQY5EPB_js.DYNAMIC_FEE_FLAG) {
169
+ return null;
170
+ }
171
+ const poolId = chunk7M57PU6V_js.computePoolId(state.poolKey);
172
+ try {
173
+ const scheduleData = await this.rpc.readContract({
174
+ address: state.poolKey.hooks,
175
+ abi: chunk3MVW6UIW_js.decayMulticurveInitializerHookAbi,
176
+ functionName: "getFeeScheduleOf",
177
+ args: [poolId]
178
+ });
179
+ const scheduleStruct = scheduleData;
180
+ return {
181
+ startingTime: Number(
182
+ scheduleStruct.startingTime ?? scheduleStruct[0] ?? 0
183
+ ),
184
+ startFee: Number(scheduleStruct.startFee ?? scheduleStruct[1] ?? 0),
185
+ endFee: Number(scheduleStruct.endFee ?? scheduleStruct[2] ?? 0),
186
+ lastFee: Number(scheduleStruct.lastFee ?? scheduleStruct[3] ?? 0),
187
+ durationSeconds: Number(
188
+ scheduleStruct.durationSeconds ?? scheduleStruct[4] ?? 0
189
+ )
190
+ };
191
+ } catch {
192
+ throw new Error(
193
+ `Dynamic multicurve hook at ${state.poolKey.hooks} does not expose getFeeScheduleOf(poolId)`
194
+ );
195
+ }
196
+ }
159
197
  parsePoolKey(rawPoolKey) {
160
198
  const poolKeyStruct = rawPoolKey;
161
199
  return {
@@ -172,7 +210,7 @@ var MulticurvePool = class {
172
210
  }
173
211
  const lockerAddress = await this.rpc.readContract({
174
212
  address: migratorAddress,
175
- abi: chunkLOVD3NCN_js.v4MulticurveMigratorAbi,
213
+ abi: chunk3MVW6UIW_js.v4MulticurveMigratorAbi,
176
214
  functionName: "locker",
177
215
  args: []
178
216
  });
@@ -198,5 +236,5 @@ var MulticurvePool = class {
198
236
  };
199
237
 
200
238
  exports.MulticurvePool = MulticurvePool;
201
- //# sourceMappingURL=chunk-E54BP2GN.js.map
202
- //# sourceMappingURL=chunk-E54BP2GN.js.map
239
+ //# sourceMappingURL=chunk-Y6VZD4C6.js.map
240
+ //# sourceMappingURL=chunk-Y6VZD4C6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/entities/auction/MulticurvePool.ts"],"names":["getAddresses","zeroAddress","v4MulticurveInitializerAbi","computePoolId","v4MulticurveMigratorAbi","streamableFeesLockerAbi","DYNAMIC_FEE_FLAG","decayMulticurveInitializerHookAbi"],"mappings":";;;;;;;;AA8CO,IAAM,iBAAN,MAAqB;AAAA,EAI1B,IAAY,GAAA,GAAoB;AAC9B,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA,EAEA,WAAA,CACE,MAAA,EACA,YAAA,EACA,YAAA,EACA;AACA,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,YAAA,GAAe,YAAA;AACpB,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AAAA,MAChD,OAAA,EAAS,eAAA;AAAA,MACT,GAAA,EAAKH,wCAAA;AAAA,MACL,YAAA,EAAc,QAAA;AAAA,MACd,MAAM;AAAC,KACR,CAAA;AAED,IAAA,OAAO,aAAA;AAAA,EACT;AAAA,EAEA,MAAc,uBAAA,CACZ,eAAA,EACA,GAAA,EACA,MAAA,EACkE;AAClE,IAAA,MAAM,EAAE,OAAA,EAAS,MAAA,KAAW,MAAM,IAAA,CAAK,IAAI,gBAAA,CAAiB;AAAA,MAC1D,OAAA,EAAS,eAAA;AAAA,MACT,GAAA;AAAA,MACA,YAAA,EAAc,aAAA;AAAA,MACd,IAAA,EAAM,CAAC,MAAM,CAAA;AAAA,MACb,OAAA,EAAS,KAAK,YAAA,CAAc;AAAA,KAC7B,CAAA;AAED,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,YAAA,CAAc,cAAc,OAAO,CAAA;AAE3D,IAAA,MAAM,KAAK,GAAA,CAAI,yBAAA,CAA0B,EAAE,IAAA,EAAM,aAAA,EAAe,GAAG,CAAA;AAEnE,IAAA,MAAM,CAAC,KAAA,EAAO,KAAK,CAAA,GAAI,MAAA;AAEvB,IAAA,OAAO;AAAA,MACL,KAAA;AAAA,MACA,KAAA;AAAA,MACA,eAAA,EAAiB;AAAA,KACnB;AAAA,EACF;AACF","file":"chunk-Y6VZD4C6.js","sourcesContent":["import {\n type Address,\n type PublicClient,\n type WalletClient,\n type Hash,\n type Hex,\n zeroAddress,\n} from 'viem';\nimport {\n LockablePoolStatus,\n type MulticurveDecayFeeSchedule,\n type MulticurvePoolState,\n type SupportedPublicClient,\n type V4PoolKey,\n} from '../../types';\nimport {\n decayMulticurveInitializerHookAbi,\n v4MulticurveInitializerAbi,\n v4MulticurveMigratorAbi,\n streamableFeesLockerAbi,\n} from '../../abis';\nimport { getAddresses } from '../../addresses';\nimport type { SupportedChainId } from '../../addresses';\nimport { DYNAMIC_FEE_FLAG } from '../../constants';\nimport { computePoolId } from '../../utils/poolKey';\n\n/** Result from finding which initializer contains the pool */\ninterface InitializerDiscoveryResult {\n initializerAddress: Address;\n state: MulticurvePoolState;\n}\n\n/**\n * MulticurvePool class for interacting with V4 multicurve pools\n *\n * Multicurve pools use the V4 multicurve initializer which supports:\n * - Multiple bonding curves with different price ranges\n * - Fee collection for configured beneficiaries\n * - No-migration lockable liquidity\n *\n * Note: V4 pools don't have their own contract addresses. The token address\n * is used as the lookup key to retrieve pool state from the initializer contract.\n *\n * Terminology: The contracts call the created token \"asset\" (paired against \"numeraire\", e.g., WETH).\n * We use \"tokenAddress\" in the SDK for consistency.\n */\nexport class MulticurvePool {\n private client: SupportedPublicClient;\n private walletClient?: WalletClient;\n private tokenAddress: Address;\n private get rpc(): PublicClient {\n return this.client as PublicClient;\n }\n\n constructor(\n client: SupportedPublicClient,\n walletClient: WalletClient | undefined,\n tokenAddress: Address,\n ) {\n this.client = client;\n this.walletClient = walletClient;\n this.tokenAddress = tokenAddress;\n }\n\n /**\n * Get the token address for this pool\n * This is also the lookup key used to retrieve pool state from the initializer\n * (Called \"asset\" in the contracts, but we use \"tokenAddress\" for SDK consistency)\n */\n getTokenAddress(): Address {\n return this.tokenAddress;\n }\n\n /**\n * Get current pool state from the multicurve initializer\n *\n * Automatically discovers which initializer (standard, scheduled, or decay) contains the pool.\n */\n async getState(): Promise<MulticurvePoolState> {\n const { state } = await this.findInitializerForPool();\n return state;\n }\n\n /**\n * Find which initializer contains this pool and return both the address and state.\n *\n * Tries v4MulticurveInitializer first (more common), then falls back to\n * v4ScheduledMulticurveInitializer and v4DecayMulticurveInitializer if needed.\n */\n private async findInitializerForPool(): Promise<InitializerDiscoveryResult> {\n const chainId = await this.rpc.getChainId();\n const addresses = getAddresses(chainId as SupportedChainId);\n\n // Build list of initializers to try, preferring non-scheduled (more common)\n const initializersToTry: Address[] = [\n addresses.v4MulticurveInitializer,\n addresses.v4ScheduledMulticurveInitializer,\n addresses.v4DecayMulticurveInitializer,\n ].filter(\n (addr): addr is Address => addr !== undefined && addr !== zeroAddress,\n );\n\n if (initializersToTry.length === 0) {\n throw new Error(\n 'No V4 multicurve initializer addresses configured for this chain',\n );\n }\n\n const triedInitializers: Address[] = [];\n\n for (const initializerAddress of initializersToTry) {\n triedInitializers.push(initializerAddress);\n\n const stateData = await this.rpc.readContract({\n address: initializerAddress,\n abi: v4MulticurveInitializerAbi,\n functionName: 'getState',\n args: [this.tokenAddress],\n });\n\n // Parse the returned tuple into a strongly typed PoolKey\n const [numeraire, status, rawPoolKey, farTick] = stateData as readonly [\n Address,\n number,\n {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n } & readonly [Address, Address, number, number, Address],\n number,\n ];\n\n const poolKey = this.parsePoolKey(rawPoolKey);\n\n // Check if pool exists in this initializer\n // A non-existent pool will have zeroed hooks and tickSpacing\n if (poolKey.hooks !== zeroAddress && poolKey.tickSpacing !== 0) {\n const state: MulticurvePoolState = {\n asset: this.tokenAddress,\n numeraire,\n fee: poolKey.fee,\n tickSpacing: poolKey.tickSpacing,\n status,\n poolKey,\n farTick: Number(farTick),\n };\n return { initializerAddress, state };\n }\n }\n\n // Pool not found in any initializer\n throw new Error(\n `Pool not found for token ${this.tokenAddress}. ` +\n `Tried initializers: ${triedInitializers.join(', ')}`,\n );\n }\n\n /**\n * Collect fees from the pool and distribute to beneficiaries\n *\n * This function can be called by any beneficiary to trigger fee collection\n * and distribution. Fees are automatically distributed according to the\n * configured beneficiary shares.\n *\n * @returns Object containing the amounts of fees0 and fees1 distributed, and the transaction hash\n */\n async collectFees(): Promise<{\n fees0: bigint;\n fees1: bigint;\n transactionHash: Hash;\n }> {\n if (!this.walletClient) {\n throw new Error('Wallet client required to collect fees');\n }\n\n const chainId = await this.rpc.getChainId();\n const addresses = getAddresses(chainId as SupportedChainId);\n\n // Discover which initializer has this pool and get state in one call\n const { initializerAddress, state } = await this.findInitializerForPool();\n\n if (state.status === LockablePoolStatus.Locked) {\n const poolId = computePoolId(state.poolKey);\n return this.collectFeesFromContract(\n initializerAddress,\n v4MulticurveInitializerAbi,\n poolId,\n );\n }\n\n if (state.status === LockablePoolStatus.Exited) {\n if (!addresses.v4Migrator) {\n throw new Error(\n 'V4 multicurve migrator address not configured for this chain',\n );\n }\n\n const assetData = await this.rpc.readContract({\n address: addresses.v4Migrator,\n abi: v4MulticurveMigratorAbi,\n functionName: 'getAssetData',\n args: [state.poolKey.currency0, state.poolKey.currency1],\n });\n\n const migratorPoolKey = this.parsePoolKey(\n (assetData as any).poolKey ?? (assetData as any)[1],\n );\n const poolId = computePoolId(migratorPoolKey);\n\n const beneficiaries =\n (assetData as any).beneficiaries ?? (assetData as any)[4] ?? [];\n if (!Array.isArray(beneficiaries) || beneficiaries.length === 0) {\n throw new Error(\n 'Migrated multicurve pool has no beneficiaries configured',\n );\n }\n\n const lockerAddress = await this.resolveLockerAddress(\n addresses.v4Migrator,\n addresses.streamableFeesLocker,\n );\n\n const streamData = await this.rpc.readContract({\n address: lockerAddress,\n abi: streamableFeesLockerAbi,\n functionName: 'streams',\n args: [poolId],\n });\n\n const startDate = Number(\n (streamData as any).startDate ?? (streamData as any)[2] ?? 0,\n );\n if (startDate === 0) {\n throw new Error('Migrated multicurve stream not initialized');\n }\n\n return this.collectFeesFromContract(\n lockerAddress,\n streamableFeesLockerAbi,\n poolId,\n );\n }\n\n throw new Error('Multicurve pool is not locked or migrated');\n }\n\n /**\n * Get the numeraire address for this pool\n */\n async getNumeraireAddress(): Promise<Address> {\n const state = await this.getState();\n return state.numeraire;\n }\n\n /**\n * Get the decay fee schedule for dynamic-fee multicurve pools.\n *\n * Returns `null` when the pool is not using dynamic fees.\n */\n async getFeeSchedule(): Promise<MulticurveDecayFeeSchedule | null> {\n const { state } = await this.findInitializerForPool();\n if (state.poolKey.fee !== DYNAMIC_FEE_FLAG) {\n return null;\n }\n\n const poolId = computePoolId(state.poolKey);\n try {\n const scheduleData = await this.rpc.readContract({\n address: state.poolKey.hooks,\n abi: decayMulticurveInitializerHookAbi,\n functionName: 'getFeeScheduleOf',\n args: [poolId],\n });\n\n const scheduleStruct = scheduleData as any;\n return {\n startingTime: Number(\n scheduleStruct.startingTime ?? scheduleStruct[0] ?? 0,\n ),\n startFee: Number(scheduleStruct.startFee ?? scheduleStruct[1] ?? 0),\n endFee: Number(scheduleStruct.endFee ?? scheduleStruct[2] ?? 0),\n lastFee: Number(scheduleStruct.lastFee ?? scheduleStruct[3] ?? 0),\n durationSeconds: Number(\n scheduleStruct.durationSeconds ?? scheduleStruct[4] ?? 0,\n ),\n };\n } catch {\n throw new Error(\n `Dynamic multicurve hook at ${state.poolKey.hooks} does not expose getFeeScheduleOf(poolId)`,\n );\n }\n }\n\n private parsePoolKey(rawPoolKey: unknown): V4PoolKey {\n const poolKeyStruct = rawPoolKey as any;\n return {\n currency0: (poolKeyStruct.currency0 ?? poolKeyStruct[0]) as Address,\n currency1: (poolKeyStruct.currency1 ?? poolKeyStruct[1]) as Address,\n fee: Number(poolKeyStruct.fee ?? poolKeyStruct[2]),\n tickSpacing: Number(poolKeyStruct.tickSpacing ?? poolKeyStruct[3]),\n hooks: (poolKeyStruct.hooks ?? poolKeyStruct[4]) as Address,\n };\n }\n\n private async resolveLockerAddress(\n migratorAddress: Address,\n configuredLocker?: Address,\n ): Promise<Address> {\n if (configuredLocker) {\n return configuredLocker;\n }\n\n const lockerAddress = await this.rpc.readContract({\n address: migratorAddress,\n abi: v4MulticurveMigratorAbi,\n functionName: 'locker',\n args: [],\n });\n\n return lockerAddress as Address;\n }\n\n private async collectFeesFromContract(\n contractAddress: Address,\n abi: typeof v4MulticurveInitializerAbi | typeof streamableFeesLockerAbi,\n poolId: Hex,\n ): Promise<{ fees0: bigint; fees1: bigint; transactionHash: Hash }> {\n const { request, result } = await this.rpc.simulateContract({\n address: contractAddress,\n abi,\n functionName: 'collectFees',\n args: [poolId],\n account: this.walletClient!.account,\n });\n\n const hash = await this.walletClient!.writeContract(request);\n\n await this.rpc.waitForTransactionReceipt({ hash, confirmations: 1 });\n\n const [fees0, fees1] = result as readonly [bigint, bigint];\n\n return {\n fees0,\n fees1,\n transactionHash: hash,\n };\n }\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkMGLI4N4B_js = require('./chunk-MGLI4N4B.js');
3
+ var chunkSAX7P3MH_js = require('./chunk-SAX7P3MH.js');
4
4
  var chunkN33R22A2_js = require('./chunk-N33R22A2.js');
5
- var chunk4DUE547M_js = require('./chunk-4DUE547M.js');
6
- var chunkTL7U67CX_js = require('./chunk-TL7U67CX.js');
5
+ var chunk6BQY5EPB_js = require('./chunk-6BQY5EPB.js');
6
+ var chunkUIPSHVT4_js = require('./chunk-UIPSHVT4.js');
7
7
 
8
8
  // src/builders/MulticurveBuilder.ts
9
9
  var MulticurveBuilder = class _MulticurveBuilder {
@@ -28,7 +28,7 @@ var MulticurveBuilder = class _MulticurveBuilder {
28
28
  name: params.name,
29
29
  symbol: params.symbol,
30
30
  tokenURI: params.tokenURI,
31
- yearlyMintRate: params.yearlyMintRate ?? chunk4DUE547M_js.DEFAULT_V3_YEARLY_MINT_RATE
31
+ yearlyMintRate: params.yearlyMintRate ?? chunk6BQY5EPB_js.DEFAULT_V3_YEARLY_MINT_RATE
32
32
  };
33
33
  }
34
34
  return this;
@@ -66,7 +66,7 @@ var MulticurveBuilder = class _MulticurveBuilder {
66
66
  "Cannot use withMarketCapPresets() after withCurves(). Use withCurves() for market cap-based configuration, or withMarketCapPresets() for preset-based configuration."
67
67
  );
68
68
  }
69
- const { fee, tickSpacing, curves } = chunkMGLI4N4B_js.buildCurvesFromPresets({
69
+ const { fee, tickSpacing, curves } = chunkSAX7P3MH_js.buildCurvesFromPresets({
70
70
  fee: params?.fee,
71
71
  tickSpacing: params?.tickSpacing,
72
72
  presets: params?.presets,
@@ -143,14 +143,14 @@ var MulticurveBuilder = class _MulticurveBuilder {
143
143
  const sortedCurves = this.sortCurvesByMarketCap(params.curves);
144
144
  this.validateCurveContiguity(sortedCurves);
145
145
  const totalShares = sortedCurves.reduce((sum, c) => sum + c.shares, 0n);
146
- if (totalShares !== chunk4DUE547M_js.WAD) {
146
+ if (totalShares !== chunk6BQY5EPB_js.WAD) {
147
147
  throw new Error(
148
- `Total curve shares must equal 100% (${chunk4DUE547M_js.WAD}). Got ${totalShares} (${Number(totalShares * 10000n / chunk4DUE547M_js.WAD) / 100}%)`
148
+ `Total curve shares must equal 100% (${chunk6BQY5EPB_js.WAD}). Got ${totalShares} (${Number(totalShares * 10000n / chunk6BQY5EPB_js.WAD) / 100}%)`
149
149
  );
150
150
  }
151
- if (params.fee !== void 0 && params.fee > chunk4DUE547M_js.V4_MAX_FEE) {
151
+ if (params.fee !== void 0 && params.fee > chunk6BQY5EPB_js.V4_MAX_FEE) {
152
152
  throw new Error(
153
- `Fee ${params.fee} exceeds maximum allowed for V4 pools (${chunk4DUE547M_js.V4_MAX_FEE} = 10%). Use a fee between 0 and ${chunk4DUE547M_js.V4_MAX_FEE}.`
153
+ `Fee ${params.fee} exceeds maximum allowed for V4 pools (${chunk6BQY5EPB_js.V4_MAX_FEE} = 10%). Use a fee between 0 and ${chunk6BQY5EPB_js.V4_MAX_FEE}.`
154
154
  );
155
155
  }
156
156
  this.numerairePrice = params.numerairePrice;
@@ -241,10 +241,11 @@ var MulticurveBuilder = class _MulticurveBuilder {
241
241
  * ```
242
242
  */
243
243
  withRehypeDopplerHook(params) {
244
+ this.assertCanSetInitializer("rehype");
244
245
  const totalDistribution = params.assetBuybackPercentWad + params.numeraireBuybackPercentWad + params.beneficiaryPercentWad + params.lpPercentWad;
245
- if (totalDistribution !== chunk4DUE547M_js.WAD) {
246
+ if (totalDistribution !== chunk6BQY5EPB_js.WAD) {
246
247
  throw new Error(
247
- `DopplerHook fee distribution must sum to ${chunk4DUE547M_js.WAD} (100%), but got ${totalDistribution}`
248
+ `DopplerHook fee distribution must sum to ${chunk6BQY5EPB_js.WAD} (100%), but got ${totalDistribution}`
248
249
  );
249
250
  }
250
251
  if (params.graduationMarketCap !== void 0 && params.farTick !== void 0) {
@@ -253,6 +254,7 @@ var MulticurveBuilder = class _MulticurveBuilder {
253
254
  );
254
255
  }
255
256
  this.dopplerHook = params;
257
+ this.initializer = { type: "rehype", config: params };
256
258
  return this;
257
259
  }
258
260
  withVesting(params) {
@@ -268,35 +270,100 @@ var MulticurveBuilder = class _MulticurveBuilder {
268
270
  };
269
271
  return this;
270
272
  }
271
- withSchedule(params) {
272
- if (!params) {
273
- this.schedule = void 0;
274
- return this;
275
- }
273
+ parseStartTimeSeconds(value, label) {
276
274
  let startTimeSeconds;
277
- const { startTime } = params;
278
- if (startTime instanceof Date) {
279
- startTimeSeconds = Math.floor(startTime.getTime() / 1e3);
280
- } else if (typeof startTime === "bigint") {
281
- startTimeSeconds = Number(startTime);
275
+ if (value instanceof Date) {
276
+ startTimeSeconds = Math.floor(value.getTime() / 1e3);
277
+ } else if (typeof value === "bigint") {
278
+ startTimeSeconds = Number(value);
282
279
  } else {
283
- startTimeSeconds = Number(startTime);
280
+ startTimeSeconds = Number(value);
284
281
  }
285
282
  if (!Number.isFinite(startTimeSeconds) || !Number.isInteger(startTimeSeconds)) {
286
283
  throw new Error(
287
- "Schedule startTime must be an integer number of seconds since Unix epoch"
284
+ `${label} must be an integer number of seconds since Unix epoch`
288
285
  );
289
286
  }
290
287
  if (startTimeSeconds < 0) {
291
- throw new Error("Schedule startTime cannot be negative");
288
+ throw new Error(`${label} cannot be negative`);
292
289
  }
293
290
  const UINT32_MAX = 4294967295;
294
291
  if (startTimeSeconds > UINT32_MAX) {
295
292
  throw new Error(
296
- "Schedule startTime must fit within uint32 (seconds since Unix epoch up to year 2106)"
293
+ `${label} must fit within uint32 (seconds since Unix epoch up to year 2106)`
294
+ );
295
+ }
296
+ return startTimeSeconds;
297
+ }
298
+ assertCanSetInitializer(nextType) {
299
+ const currentType = this.initializer?.type;
300
+ if (currentType === void 0 || currentType === "standard" || currentType === nextType) {
301
+ return;
302
+ }
303
+ throw new Error(
304
+ `Cannot set multicurve initializer to '${nextType}' because it is already configured as '${currentType}'`
305
+ );
306
+ }
307
+ /**
308
+ * Configure decay multicurve initializer settings.
309
+ *
310
+ * The pool's terminal fee is always taken from `poolConfig().fee`.
311
+ * `startFee` must be greater than or equal to that terminal fee.
312
+ * `startTime` is optional and defaults to `0` when omitted.
313
+ */
314
+ withDecay(params) {
315
+ if (!params) {
316
+ if (this.initializer?.type === "decay") {
317
+ this.initializer = { type: "standard" };
318
+ }
319
+ return this;
320
+ }
321
+ this.assertCanSetInitializer("decay");
322
+ const startTime = params.startTime === void 0 ? 0 : this.parseStartTimeSeconds(params.startTime, "Decay startTime");
323
+ const startFee = Number(params.startFee);
324
+ const durationSeconds = Number(params.durationSeconds);
325
+ if (!Number.isFinite(startFee) || !Number.isInteger(startFee)) {
326
+ throw new Error("Decay startFee must be an integer");
327
+ }
328
+ if (startFee < 0 || startFee > chunk6BQY5EPB_js.DECAY_MAX_START_FEE) {
329
+ throw new Error(
330
+ `Decay startFee must be between 0 and ${chunk6BQY5EPB_js.DECAY_MAX_START_FEE} (80%)`
297
331
  );
298
332
  }
333
+ if (!Number.isFinite(durationSeconds) || !Number.isInteger(durationSeconds)) {
334
+ throw new Error("Decay durationSeconds must be an integer");
335
+ }
336
+ if (durationSeconds < 0) {
337
+ throw new Error("Decay durationSeconds cannot be negative");
338
+ }
339
+ const UINT32_MAX = 4294967295;
340
+ if (durationSeconds > UINT32_MAX) {
341
+ throw new Error("Decay durationSeconds must fit within uint32");
342
+ }
343
+ this.schedule = void 0;
344
+ this.initializer = {
345
+ type: "decay",
346
+ startTime,
347
+ startFee,
348
+ durationSeconds
349
+ };
350
+ return this;
351
+ }
352
+ withSchedule(params) {
353
+ if (!params) {
354
+ if (this.initializer?.type === "scheduled") {
355
+ this.initializer = { type: "standard" };
356
+ }
357
+ this.schedule = void 0;
358
+ return this;
359
+ }
360
+ this.assertCanSetInitializer("scheduled");
361
+ const startTimeSeconds = this.parseStartTimeSeconds(
362
+ params.startTime,
363
+ "Schedule startTime"
364
+ );
299
365
  this.schedule = { startTime: startTimeSeconds };
366
+ this.initializer = { type: "scheduled", startTime: startTimeSeconds };
300
367
  return this;
301
368
  }
302
369
  withGovernance(params) {
@@ -312,7 +379,7 @@ var MulticurveBuilder = class _MulticurveBuilder {
312
379
  return this;
313
380
  }
314
381
  withIntegrator(address) {
315
- this.integrator = address ?? chunk4DUE547M_js.ZERO_ADDRESS;
382
+ this.integrator = address ?? chunk6BQY5EPB_js.ZERO_ADDRESS;
316
383
  return this;
317
384
  }
318
385
  withGasLimit(gas) {
@@ -338,6 +405,9 @@ var MulticurveBuilder = class _MulticurveBuilder {
338
405
  withV4ScheduledMulticurveInitializer(address) {
339
406
  return this.overrideModule("v4ScheduledMulticurveInitializer", address);
340
407
  }
408
+ withV4DecayMulticurveInitializer(address) {
409
+ return this.overrideModule("v4DecayMulticurveInitializer", address);
410
+ }
341
411
  withGovernanceFactory(address) {
342
412
  return this.overrideModule("governanceFactory", address);
343
413
  }
@@ -366,8 +436,8 @@ var MulticurveBuilder = class _MulticurveBuilder {
366
436
  "tokenSupply must be provided (either via saleConfig() or withCurves() params)"
367
437
  );
368
438
  }
369
- const fee = config.fee ?? chunk4DUE547M_js.FEE_TIERS.MEDIUM;
370
- const tickSpacing = config.tickSpacing ?? chunk4DUE547M_js.TICK_SPACINGS[fee];
439
+ const fee = config.fee ?? chunk6BQY5EPB_js.FEE_TIERS.MEDIUM;
440
+ const tickSpacing = config.tickSpacing ?? chunk6BQY5EPB_js.TICK_SPACINGS[fee];
371
441
  if (tickSpacing === void 0) {
372
442
  throw new Error(
373
443
  `Custom fee ${fee} requires explicit tickSpacing. Standard fees (100, 500, 3000, 10000) auto-derive tickSpacing.`
@@ -466,8 +536,35 @@ var MulticurveBuilder = class _MulticurveBuilder {
466
536
  }
467
537
  dopplerHook = { ...dopplerHook, farTick };
468
538
  }
469
- const governance = this.governance ?? (chunkTL7U67CX_js.isNoOpEnabledChain(this.chainId) ? { type: "noOp" } : { type: "default" });
470
- if (governance.type === "launchpad" && !chunkTL7U67CX_js.isLaunchpadEnabledChain(this.chainId)) {
539
+ const initializer = this.initializer ?? (dopplerHook ? { type: "rehype", config: dopplerHook } : this.schedule ? { type: "scheduled", startTime: this.schedule.startTime } : { type: "standard" });
540
+ if (initializer.type === "scheduled" && dopplerHook) {
541
+ throw new Error(
542
+ "Cannot combine scheduled multicurve with rehype initializer. Use exactly one initializer mode."
543
+ );
544
+ }
545
+ if (initializer.type === "decay" && dopplerHook) {
546
+ throw new Error(
547
+ "Cannot combine decay multicurve with rehype initializer. Use exactly one initializer mode."
548
+ );
549
+ }
550
+ if (initializer.type === "decay") {
551
+ const startFee = Number(initializer.startFee);
552
+ const terminalFee = Number(this.pool.fee);
553
+ if (startFee < terminalFee) {
554
+ throw new Error(
555
+ `Decay startFee (${startFee}) must be greater than or equal to terminal pool fee (${terminalFee})`
556
+ );
557
+ }
558
+ if (startFee > terminalFee && initializer.durationSeconds <= 0) {
559
+ throw new Error(
560
+ "Decay durationSeconds must be greater than 0 when startFee is greater than pool.fee"
561
+ );
562
+ }
563
+ }
564
+ const schedule = initializer.type === "scheduled" ? { startTime: initializer.startTime } : void 0;
565
+ dopplerHook = initializer.type === "rehype" ? initializer.config : void 0;
566
+ const governance = this.governance ?? (chunkUIPSHVT4_js.isNoOpEnabledChain(this.chainId) ? { type: "noOp" } : { type: "default" });
567
+ if (governance.type === "launchpad" && !chunkUIPSHVT4_js.isLaunchpadEnabledChain(this.chainId)) {
471
568
  throw new Error(
472
569
  `Launchpad governance is not supported on chain ${this.chainId}. Use a supported chain or a different governance type.`
473
570
  );
@@ -476,12 +573,13 @@ var MulticurveBuilder = class _MulticurveBuilder {
476
573
  token: this.token,
477
574
  sale: this.sale,
478
575
  pool: this.pool,
479
- schedule: this.schedule,
576
+ initializer,
577
+ schedule,
480
578
  dopplerHook,
481
579
  vesting: this.vesting,
482
580
  governance,
483
581
  migration: this.migration,
484
- integrator: this.integrator ?? chunk4DUE547M_js.ZERO_ADDRESS,
582
+ integrator: this.integrator ?? chunk6BQY5EPB_js.ZERO_ADDRESS,
485
583
  userAddress: this.userAddress,
486
584
  modules: this.moduleAddresses,
487
585
  gas: this.gasLimit
@@ -490,5 +588,5 @@ var MulticurveBuilder = class _MulticurveBuilder {
490
588
  };
491
589
 
492
590
  exports.MulticurveBuilder = MulticurveBuilder;
493
- //# sourceMappingURL=chunk-5MP6AMPB.js.map
494
- //# sourceMappingURL=chunk-5MP6AMPB.js.map
591
+ //# sourceMappingURL=chunk-YFJUIO2A.js.map
592
+ //# sourceMappingURL=chunk-YFJUIO2A.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/builders/MulticurveBuilder.ts"],"names":["DEFAULT_V3_YEARLY_MINT_RATE","buildCurvesFromPresets","WAD","V4_MAX_FEE","DECAY_MAX_START_FEE","ZERO_ADDRESS","FEE_TIERS","TICK_SPACINGS","validateMarketCapParameters","marketCapToTicksForMulticurve","marketCapToTickForMulticurve","isNoOpEnabledChain","isLaunchpadEnabledChain"],"mappings":";;;;;;;;AAqCO,IAAM,iBAAA,GAAN,MAAM,kBAAA,CAEsB;AAAA,EAmCjC,YAAY,OAAA,EAAY;AACtB,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AAAA,EAEA,OAAO,SACL,OAAA,EACsB;AACtB,IAAA,OAAO,IAAI,mBAAkB,OAAO,CAAA;AAAA,EACtC;AAAA,EAEA,YACE,MAAA,EAeM;AACN,IAAA,IAAI,MAAA,IAAU,MAAA,IAAU,MAAA,IAAU,MAAA,CAAO,SAAS,YAAA,EAAc;AAC9D,MAAA,IAAA,CAAK,KAAA,GAAQ;AAAA,QACX,IAAA,EAAM,YAAA;AAAA,QACN,MAAM,MAAA,CAAO,IAAA;AAAA,QACb,QAAQ,MAAA,CAAO,MAAA;AAAA,QACf,SAAS,MAAA,CAAO,OAAA;AAAA,QAChB,MAAM,MAAA,CAAO;AAAA,OACf;AAAA,IACF,C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\nimport {\n DEFAULT_V3_YEARLY_MINT_RATE,\n DECAY_MAX_START_FEE,\n FEE_TIERS,\n TICK_SPACINGS,\n V4_MAX_FEE,\n WAD,\n ZERO_ADDRESS,\n} from '../constants';\n\nimport {\n marketCapToTicksForMulticurve,\n marketCapToTickForMulticurve,\n validateMarketCapParameters,\n} from '../utils';\nimport {\n isNoOpEnabledChain,\n isLaunchpadEnabledChain,\n type CreateMulticurveParams,\n type GovernanceOption,\n type MigrationConfig,\n type VestingConfig,\n type TokenConfig,\n type MulticurveMarketCapCurvesConfig,\n type MulticurveMarketCapPreset,\n type ModuleAddressOverrides,\n type RehypeDopplerHookConfig,\n type MulticurveInitializerConfig,\n} from '../types';\nimport { type SupportedChainId } from '../addresses';\nimport {\n type BaseAuctionBuilder,\n type MarketCapPresetOverrides,\n buildCurvesFromPresets,\n} from './shared';\n\nexport class MulticurveBuilder<\n C extends SupportedChainId,\n> implements BaseAuctionBuilder<C> {\n private token?: TokenConfig;\n private sale?: CreateMulticurveParams<C>['sale'];\n private pool?: CreateMulticurveParams<C>['pool'];\n private initializer?: CreateMulticurveParams<C>['initializer'];\n private schedule?: CreateMulticurveParams<C>['schedule'];\n private dopplerHook?: RehypeDopplerHookConfig;\n private vesting?: VestingConfig;\n private governance?: GovernanceOption<C>;\n private migration?: MigrationConfig;\n private integrator?: Address;\n private userAddress?: Address;\n private moduleAddresses?: ModuleAddressOverrides;\n private gasLimit?: bigint;\n // Stored from withCurves() for graduationMarketCap conversion in build()\n private numerairePrice?: number;\n private tokenDecimals?: number;\n private numeraireDecimals?: number;\n // Deferred curves config - converted to pool in build()\n private curvesConfig?: {\n numerairePrice: number;\n curves: Array<{\n marketCap: { start: number; end: number | 'max' };\n numPositions: number;\n shares: bigint;\n }>;\n tokenSupply?: bigint;\n tokenDecimals?: number;\n numeraireDecimals?: number;\n fee?: number;\n tickSpacing?: number;\n beneficiaries?: { beneficiary: Address; shares: bigint }[];\n };\n public chainId: C;\n\n constructor(chainId: C) {\n this.chainId = chainId;\n }\n\n static forChain<C extends SupportedChainId>(\n chainId: C,\n ): MulticurveBuilder<C> {\n return new MulticurveBuilder(chainId);\n }\n\n tokenConfig(\n params:\n | {\n type?: 'standard';\n name: string;\n symbol: string;\n tokenURI: string;\n yearlyMintRate?: bigint;\n }\n | {\n type: 'doppler404';\n name: string;\n symbol: string;\n baseURI: string;\n unit?: bigint;\n },\n ): this {\n if (params && 'type' in params && params.type === 'doppler404') {\n this.token = {\n type: 'doppler404',\n name: params.name,\n symbol: params.symbol,\n baseURI: params.baseURI,\n unit: params.unit,\n };\n } else {\n this.token = {\n type: 'standard',\n name: params.name,\n symbol: params.symbol,\n tokenURI: params.tokenURI,\n yearlyMintRate: params.yearlyMintRate ?? DEFAULT_V3_YEARLY_MINT_RATE,\n };\n }\n return this;\n }\n\n saleConfig(params: {\n initialSupply: bigint;\n numTokensToSell: bigint;\n numeraire: Address;\n }): this {\n this.sale = {\n initialSupply: params.initialSupply,\n numTokensToSell: params.numTokensToSell,\n numeraire: params.numeraire,\n };\n return this;\n }\n\n poolConfig(params: {\n fee: number;\n tickSpacing: number;\n curves: {\n tickLower: number;\n tickUpper: number;\n numPositions: number;\n shares: bigint;\n }[];\n beneficiaries?: { beneficiary: Address; shares: bigint }[];\n }): this {\n // Mutual exclusion: cannot use poolConfig() after withCurves()\n if (this.curvesConfig) {\n throw new Error(\n 'Cannot use poolConfig() after withCurves(). ' +\n 'Use withCurves() for market cap-based configuration, ' +\n 'or poolConfig() for manual tick configuration.',\n );\n }\n\n const sortedBeneficiaries = params.beneficiaries\n ? [...params.beneficiaries].sort((a, b) => {\n const aAddr = a.beneficiary.toLowerCase();\n const bAddr = b.beneficiary.toLowerCase();\n return aAddr < bAddr ? -1 : aAddr > bAddr ? 1 : 0;\n })\n : undefined;\n\n this.pool = {\n fee: params.fee,\n tickSpacing: params.tickSpacing,\n curves: params.curves,\n beneficiaries: sortedBeneficiaries,\n };\n return this;\n }\n\n withMarketCapPresets(params?: {\n fee?: number;\n tickSpacing?: number;\n presets?: MulticurveMarketCapPreset[];\n overrides?: MarketCapPresetOverrides;\n beneficiaries?: { beneficiary: Address; shares: bigint }[];\n }): this {\n // Mutual exclusion: cannot use withMarketCapPresets() after withCurves()\n if (this.curvesConfig) {\n throw new Error(\n 'Cannot use withMarketCapPresets() after withCurves(). ' +\n 'Use withCurves() for market cap-based configuration, ' +\n 'or withMarketCapPresets() for preset-based configuration.',\n );\n }\n\n const { fee, tickSpacing, curves } = buildCurvesFromPresets({\n fee: params?.fee,\n tickSpacing: params?.tickSpacing,\n presets: params?.presets,\n overrides: params?.overrides,\n });\n\n return this.poolConfig({\n fee,\n tickSpacing,\n curves,\n beneficiaries: params?.beneficiaries,\n });\n }\n\n /**\n * Configure multicurve using market cap ranges (no tick math required).\n *\n * This is the recommended way to configure multicurve pools. Simply specify\n * market cap ranges in USD for each curve.\n *\n * Curves can be provided in any order - they will be automatically sorted\n * by market cap (ascending) before validation and processing. Curves must\n * be contiguous or overlapping (no gaps allowed).\n *\n * V4 pools support custom fees (0-100,000). Standard fee tiers auto-derive\n * tickSpacing; custom fees require explicit tickSpacing parameter.\n *\n * @param params - Market cap configuration with curves defined by market cap ranges\n * @returns Builder instance for chaining\n *\n * @example Standard fee tier\n * ```ts\n * builder\n * .saleConfig({ initialSupply, numTokensToSell, numeraire: WETH })\n * .withCurves({\n * numerairePrice: 3000,\n * curves: [...],\n * fee: 500, // Standard tier, tickSpacing auto-derived\n * })\n * ```\n *\n * @example Custom fee\n * ```ts\n * builder\n * .saleConfig({ initialSupply, numTokensToSell, numeraire: WETH })\n * .withCurves({\n * numerairePrice: 3000,\n * curves: [...],\n * fee: 2500, // Custom 0.25% fee\n * tickSpacing: 10, // Required for custom fees\n * })\n * ```\n */\n withCurves(params: MulticurveMarketCapCurvesConfig): this {\n // Mutual exclusion: cannot use withCurves() after poolConfig()/withMarketCapPresets()\n if (this.pool) {\n throw new Error(\n 'Cannot use withCurves() after poolConfig()/withMarketCapPresets(). ' +\n 'Use withCurves() for market cap-based configuration, ' +\n 'or poolConfig() for manual tick configuration.',\n );\n }\n\n // Validate numerairePrice\n if (params.numerairePrice <= 0) {\n throw new Error('numerairePrice must be greater than 0');\n }\n\n // Validate curves array\n if (!params.curves || params.curves.length === 0) {\n throw new Error('curves array must contain at least one curve');\n }\n\n // Validate each curve (basic validation that doesn't require saleConfig)\n for (let i = 0; i < params.curves.length; i++) {\n const curve = params.curves[i];\n this.validateCurveRange(\n curve.marketCap.start,\n curve.marketCap.end,\n curve.numPositions,\n curve.shares,\n `curves[${i}]`,\n );\n }\n\n // Sort curves by market cap (start, then end) for deterministic ordering\n const sortedCurves = this.sortCurvesByMarketCap(params.curves);\n\n // Validate curve contiguity (no gaps allowed, overlaps OK)\n this.validateCurveContiguity(sortedCurves);\n\n // Validate total shares sum to exactly WAD\n const totalShares = sortedCurves.reduce((sum, c) => sum + c.shares, 0n);\n if (totalShares !== WAD) {\n throw new Error(\n `Total curve shares must equal 100% (${WAD}). Got ${totalShares} (${Number((totalShares * 10000n) / WAD) / 100}%)`,\n );\n }\n\n // Validate fee if provided\n if (params.fee !== undefined && params.fee > V4_MAX_FEE) {\n throw new Error(\n `Fee ${params.fee} exceeds maximum allowed for V4 pools (${V4_MAX_FEE} = 10%). ` +\n `Use a fee between 0 and ${V4_MAX_FEE}.`,\n );\n }\n\n // Store for later use in build() (graduationMarketCap conversion)\n this.numerairePrice = params.numerairePrice;\n this.tokenDecimals = params.tokenDecimals;\n this.numeraireDecimals = params.numeraireDecimals;\n\n // Store config for deferred conversion in build()\n this.curvesConfig = {\n numerairePrice: params.numerairePrice,\n curves: sortedCurves,\n tokenSupply: params.tokenSupply,\n tokenDecimals: params.tokenDecimals,\n numeraireDecimals: params.numeraireDecimals,\n fee: params.fee,\n tickSpacing: params.tickSpacing,\n beneficiaries: params.beneficiaries,\n };\n\n return this;\n }\n\n /**\n * Sort curves by market cap (start, then end) for deterministic ordering\n */\n private sortCurvesByMarketCap<\n T extends { marketCap: { start: number; end: number | 'max' } },\n >(curves: T[]): T[] {\n return [...curves].sort((a, b) => {\n const startDiff = a.marketCap.start - b.marketCap.start;\n if (startDiff !== 0) return startDiff;\n const aEnd = a.marketCap.end === 'max' ? Infinity : a.marketCap.end;\n const bEnd = b.marketCap.end === 'max' ? Infinity : b.marketCap.end;\n return aEnd - bEnd;\n });\n }\n\n private validateCurveRange(\n startMarketCap: number,\n endMarketCap: number | 'max',\n numPositions: number,\n shares: bigint,\n label: string,\n ): void {\n if (startMarketCap <= 0) {\n throw new Error(`${label}: marketCap.start must be greater than 0`);\n }\n if (endMarketCap !== 'max' && endMarketCap <= 0) {\n throw new Error(`${label}: marketCap.end must be greater than 0`);\n }\n if (endMarketCap !== 'max' && startMarketCap >= endMarketCap) {\n throw new Error(\n `${label}: startMarketCap ($${startMarketCap.toLocaleString()}) must be less than endMarketCap ($${endMarketCap.toLocaleString()})`,\n );\n }\n if (numPositions <= 0) {\n throw new Error(`${label}: numPositions must be greater than 0`);\n }\n if (shares <= 0n) {\n throw new Error(`${label}: shares must be greater than 0`);\n }\n }\n\n private validateCurveContiguity(\n sortedCurves: { marketCap: { start: number; end: number | 'max' } }[],\n ): void {\n if (sortedCurves.length <= 1) {\n return;\n }\n\n for (let i = 1; i < sortedCurves.length; i++) {\n const prevCurve = sortedCurves[i - 1];\n const currCurve = sortedCurves[i];\n const prevEnd =\n prevCurve.marketCap.end === 'max'\n ? Infinity\n : prevCurve.marketCap.end;\n const prevEndLabel =\n prevCurve.marketCap.end === 'max'\n ? 'max'\n : `$${prevCurve.marketCap.end.toLocaleString()}`;\n const currEndLabel =\n currCurve.marketCap.end === 'max'\n ? 'max'\n : `$${currCurve.marketCap.end.toLocaleString()}`;\n\n if (currCurve.marketCap.start > prevEnd) {\n throw new Error(\n `Gap detected between market cap ranges: ` +\n `$${prevCurve.marketCap.start.toLocaleString()}-${prevEndLabel} ` +\n `and $${currCurve.marketCap.start.toLocaleString()}-${currEndLabel}. ` +\n `Curves must be contiguous or overlapping.`,\n );\n }\n }\n }\n\n /**\n * Configure a RehypeDopplerHook for the pool.\n *\n * When configured, the hook will be initialized with the pool and will handle:\n * - Custom swap fees\n * - Fee distribution to beneficiaries, LPs, and buyback destinations\n *\n * IMPORTANT:\n * - The hook address must be whitelisted in the DopplerHookInitializer\n * - Fee distribution percentages must sum to exactly WAD (1e18 = 100%)\n *\n * @example\n * ```typescript\n * builder.withRehypeDopplerHook({\n * hookAddress: '0x...',\n * buybackDestination: '0x...',\n * customFee: 3000, // 0.3%\n * assetBuybackPercentWad: parseEther('0.2'), // 20%\n * numeraireBuybackPercentWad: parseEther('0.2'), // 20%\n * beneficiaryPercentWad: parseEther('0.3'), // 30%\n * lpPercentWad: parseEther('0.3'), // 30%\n * })\n * ```\n */\n withRehypeDopplerHook(params: RehypeDopplerHookConfig): this {\n this.assertCanSetInitializer('rehype');\n\n const totalDistribution =\n params.assetBuybackPercentWad +\n params.numeraireBuybackPercentWad +\n params.beneficiaryPercentWad +\n params.lpPercentWad;\n if (totalDistribution !== WAD) {\n throw new Error(\n `DopplerHook fee distribution must sum to ${WAD} (100%), but got ${totalDistribution}`,\n );\n }\n\n // Validate mutual exclusivity of graduation threshold options\n if (params.graduationMarketCap !== undefined && params.farTick !== undefined) {\n throw new Error(\n 'Cannot specify both graduationMarketCap and farTick. Use one or the other.',\n );\n }\n\n this.dopplerHook = params;\n this.initializer = { type: 'rehype', config: params };\n return this;\n }\n\n withVesting(params?: {\n duration?: bigint;\n cliffDuration?: number;\n recipients?: Address[];\n amounts?: bigint[];\n }): this {\n if (!params) {\n this.vesting = undefined;\n return this;\n }\n this.vesting = {\n duration: Number(params.duration ?? 0n),\n cliffDuration: params.cliffDuration ?? 0,\n recipients: params.recipients,\n amounts: params.amounts,\n };\n return this;\n }\n\n private parseStartTimeSeconds(\n value: number | bigint | Date,\n label: string,\n ): number {\n let startTimeSeconds: number;\n if (value instanceof Date) {\n startTimeSeconds = Math.floor(value.getTime() / 1000);\n } else if (typeof value === 'bigint') {\n startTimeSeconds = Number(value);\n } else {\n startTimeSeconds = Number(value);\n }\n\n if (\n !Number.isFinite(startTimeSeconds) ||\n !Number.isInteger(startTimeSeconds)\n ) {\n throw new Error(\n `${label} must be an integer number of seconds since Unix epoch`,\n );\n }\n\n if (startTimeSeconds < 0) {\n throw new Error(`${label} cannot be negative`);\n }\n\n const UINT32_MAX = 0xffffffff;\n if (startTimeSeconds > UINT32_MAX) {\n throw new Error(\n `${label} must fit within uint32 (seconds since Unix epoch up to year 2106)`,\n );\n }\n\n return startTimeSeconds;\n }\n\n private assertCanSetInitializer(\n nextType: MulticurveInitializerConfig['type'],\n ): void {\n const currentType = this.initializer?.type;\n if (\n currentType === undefined ||\n currentType === 'standard' ||\n currentType === nextType\n ) {\n return;\n }\n throw new Error(\n `Cannot set multicurve initializer to '${nextType}' because it is already configured as '${currentType}'`,\n );\n }\n\n /**\n * Configure decay multicurve initializer settings.\n *\n * The pool's terminal fee is always taken from `poolConfig().fee`.\n * `startFee` must be greater than or equal to that terminal fee.\n * `startTime` is optional and defaults to `0` when omitted.\n */\n withDecay(params?: {\n startTime?: number | bigint | Date;\n startFee: number;\n durationSeconds: number | bigint;\n }): this {\n if (!params) {\n if (this.initializer?.type === 'decay') {\n this.initializer = { type: 'standard' };\n }\n return this;\n }\n\n this.assertCanSetInitializer('decay');\n\n const startTime =\n params.startTime === undefined\n ? 0\n : this.parseStartTimeSeconds(params.startTime, 'Decay startTime');\n const startFee = Number(params.startFee);\n const durationSeconds = Number(params.durationSeconds);\n\n if (!Number.isFinite(startFee) || !Number.isInteger(startFee)) {\n throw new Error('Decay startFee must be an integer');\n }\n if (startFee < 0 || startFee > DECAY_MAX_START_FEE) {\n throw new Error(\n `Decay startFee must be between 0 and ${DECAY_MAX_START_FEE} (80%)`,\n );\n }\n if (!Number.isFinite(durationSeconds) || !Number.isInteger(durationSeconds)) {\n throw new Error('Decay durationSeconds must be an integer');\n }\n if (durationSeconds < 0) {\n throw new Error('Decay durationSeconds cannot be negative');\n }\n const UINT32_MAX = 0xffffffff;\n if (durationSeconds > UINT32_MAX) {\n throw new Error('Decay durationSeconds must fit within uint32');\n }\n\n this.schedule = undefined;\n this.initializer = {\n type: 'decay',\n startTime,\n startFee,\n durationSeconds,\n };\n return this;\n }\n\n withSchedule(params?: { startTime: number | bigint | Date }): this {\n if (!params) {\n if (this.initializer?.type === 'scheduled') {\n this.initializer = { type: 'standard' };\n }\n this.schedule = undefined;\n return this;\n }\n\n this.assertCanSetInitializer('scheduled');\n const startTimeSeconds = this.parseStartTimeSeconds(\n params.startTime,\n 'Schedule startTime',\n );\n this.schedule = { startTime: startTimeSeconds };\n this.initializer = { type: 'scheduled', startTime: startTimeSeconds };\n return this;\n }\n\n withGovernance(params: GovernanceOption<C>): this {\n this.governance = params;\n return this;\n }\n\n withMigration(migration: MigrationConfig): this {\n this.migration = migration;\n return this;\n }\n\n withUserAddress(address: Address): this {\n this.userAddress = address;\n return this;\n }\n\n withIntegrator(address?: Address): this {\n this.integrator = address ?? ZERO_ADDRESS;\n return this;\n }\n\n withGasLimit(gas?: bigint): this {\n this.gasLimit = gas;\n return this;\n }\n\n private overrideModule<K extends keyof ModuleAddressOverrides>(\n key: K,\n address: NonNullable<ModuleAddressOverrides[K]>,\n ): this {\n this.moduleAddresses = {\n ...this.moduleAddresses,\n [key]: address,\n } as ModuleAddressOverrides;\n return this;\n }\n\n withTokenFactory(address: Address): this {\n return this.overrideModule('tokenFactory', address);\n }\n withAirlock(address: Address): this {\n return this.overrideModule('airlock', address);\n }\n withV4MulticurveInitializer(address: Address): this {\n return this.overrideModule('v4MulticurveInitializer', address);\n }\n withV4ScheduledMulticurveInitializer(address: Address): this {\n return this.overrideModule('v4ScheduledMulticurveInitializer', address);\n }\n withV4DecayMulticurveInitializer(address: Address): this {\n return this.overrideModule('v4DecayMulticurveInitializer', address);\n }\n withGovernanceFactory(address: Address): this {\n return this.overrideModule('governanceFactory', address);\n }\n withV2Migrator(address: Address): this {\n return this.overrideModule('v2Migrator', address);\n }\n\n withV4Migrator(address: Address): this {\n return this.overrideModule('v4Migrator', address);\n }\n withNoOpMigrator(address: Address): this {\n return this.overrideModule('noOpMigrator', address);\n }\n withDopplerHookInitializer(address: Address): this {\n return this.overrideModule('dopplerHookInitializer', address);\n }\n\n build(): CreateMulticurveParams<C> {\n if (!this.token) throw new Error('tokenConfig is required');\n if (!this.sale) throw new Error('saleConfig is required');\n if (!this.migration) throw new Error('migration configuration is required');\n if (!this.userAddress) throw new Error('userAddress is required');\n\n // Convert deferred curves config to pool if set\n if (this.curvesConfig && !this.pool) {\n const config = this.curvesConfig;\n\n // Get token supply from config or saleConfig\n const tokenSupply = config.tokenSupply ?? this.sale.initialSupply;\n if (!tokenSupply) {\n throw new Error(\n 'tokenSupply must be provided (either via saleConfig() or withCurves() params)',\n );\n }\n\n // Get fee and tick spacing\n const fee = config.fee ?? FEE_TIERS.MEDIUM;\n const tickSpacing =\n config.tickSpacing ?? (TICK_SPACINGS as Record<number, number>)[fee];\n\n if (tickSpacing === undefined) {\n throw new Error(\n `Custom fee ${fee} requires explicit tickSpacing. ` +\n `Standard fees (100, 500, 3000, 10000) auto-derive tickSpacing.`,\n );\n }\n\n // Validate first curve market caps (the launch price)\n const firstCurve = config.curves[0];\n const startValidation = validateMarketCapParameters(\n firstCurve.marketCap.start,\n tokenSupply,\n config.tokenDecimals,\n );\n const endValidation =\n firstCurve.marketCap.end === 'max'\n ? { valid: true, warnings: [] }\n : validateMarketCapParameters(\n firstCurve.marketCap.end,\n tokenSupply,\n config.tokenDecimals,\n );\n const allWarnings = [\n ...startValidation.warnings,\n ...endValidation.warnings,\n ];\n if (allWarnings.length > 0) {\n console.warn('First curve market cap validation warnings:');\n allWarnings.forEach((w) => console.warn(` - ${w}`));\n }\n\n // Convert all curves to ticks\n const curves: {\n tickLower: number;\n tickUpper: number;\n numPositions: number;\n shares: bigint;\n }[] = [];\n\n for (const curve of config.curves) {\n const curveTicks = marketCapToTicksForMulticurve({\n marketCapLower: curve.marketCap.start,\n marketCapUpper: curve.marketCap.end,\n tokenSupply,\n numerairePriceUSD: config.numerairePrice,\n tickSpacing,\n tokenDecimals: config.tokenDecimals ?? 18,\n numeraireDecimals: config.numeraireDecimals ?? 18,\n });\n\n curves.push({\n tickLower: curveTicks.tickLower,\n tickUpper: curveTicks.tickUpper,\n numPositions: curve.numPositions,\n shares: curve.shares,\n });\n }\n\n // Sort beneficiaries by address if provided\n const sortedBeneficiaries = config.beneficiaries\n ? [...config.beneficiaries].sort((a, b) => {\n const aAddr = a.beneficiary.toLowerCase();\n const bAddr = b.beneficiary.toLowerCase();\n return aAddr < bAddr ? -1 : aAddr > bAddr ? 1 : 0;\n })\n : undefined;\n\n // Set pool config\n this.pool = {\n fee,\n tickSpacing,\n curves,\n beneficiaries: sortedBeneficiaries,\n };\n }\n\n if (!this.pool) throw new Error('poolConfig is required');\n\n // Validate noOp migration requires beneficiaries\n // NoOpMigrator is designed for locked pools with beneficiaries. Without beneficiaries,\n // the pool status is \"Initialized\" (not \"Locked\"), meaning exitLiquidity() can be called.\n // But NoOpMigrator.migrate() always reverts, so the entire graduation transaction fails\n // and liquidity becomes trapped.\n if (this.migration.type === 'noOp') {\n const hasBeneficiaries =\n this.pool.beneficiaries && this.pool.beneficiaries.length > 0;\n if (!hasBeneficiaries) {\n throw new Error(\n 'noOp migration requires beneficiaries. Without beneficiaries, the pool would be stuck after reaching ' +\n 'graduation - exitLiquidity() succeeds but NoOpMigrator.migrate() always reverts, causing the entire ' +\n 'transaction to fail. Either add beneficiaries or use a different migration type (uniswapV2, uniswapV4).',\n );\n }\n }\n\n // Convert graduationMarketCap to farTick if using rehype\n let dopplerHook = this.dopplerHook;\n if (dopplerHook?.graduationMarketCap !== undefined) {\n // Use numerairePrice from: 1) explicit in dopplerHook, 2) stored from withCurves()\n const numerairePrice = dopplerHook.numerairePrice ?? this.numerairePrice;\n\n if (!numerairePrice) {\n throw new Error(\n 'graduationMarketCap requires numerairePrice. ' +\n 'Either use withCurves() (which provides numerairePrice), ' +\n 'or pass numerairePrice explicitly in withRehypeDopplerHook().',\n );\n }\n\n if (dopplerHook.graduationMarketCap <= 0) {\n throw new Error('graduationMarketCap must be greater than 0');\n }\n\n const farTick = marketCapToTickForMulticurve({\n marketCapUSD: dopplerHook.graduationMarketCap,\n tokenSupply: this.sale.initialSupply,\n numerairePriceUSD: numerairePrice,\n tickSpacing: this.pool.tickSpacing,\n tokenDecimals: this.tokenDecimals ?? 18,\n numeraireDecimals: this.numeraireDecimals ?? 18,\n });\n\n // Validate farTick is within curve boundaries\n const allTickUppers = this.pool.curves.map((c) => c.tickUpper);\n const allTickLowers = this.pool.curves.map((c) => c.tickLower);\n const maxTickUpper = Math.max(...allTickUppers);\n const minTickLower = Math.min(...allTickLowers);\n\n if (farTick < minTickLower) {\n throw new Error(\n `graduationMarketCap converts to tick ${farTick}, which is below the lowest curve tick (${minTickLower})`,\n );\n }\n if (farTick > maxTickUpper) {\n throw new Error(\n `graduationMarketCap converts to tick ${farTick}, which is above the highest curve tick (${maxTickUpper})`,\n );\n }\n\n // Store computed farTick on dopplerHook for encoding\n dopplerHook = { ...dopplerHook, farTick };\n }\n\n const initializer =\n this.initializer ??\n (dopplerHook\n ? { type: 'rehype', config: dopplerHook }\n : this.schedule\n ? { type: 'scheduled', startTime: this.schedule.startTime }\n : { type: 'standard' });\n\n if (initializer.type === 'scheduled' && dopplerHook) {\n throw new Error(\n \"Cannot combine scheduled multicurve with rehype initializer. Use exactly one initializer mode.\",\n );\n }\n if (initializer.type === 'decay' && dopplerHook) {\n throw new Error(\n \"Cannot combine decay multicurve with rehype initializer. Use exactly one initializer mode.\",\n );\n }\n if (initializer.type === 'decay') {\n const startFee = Number(initializer.startFee);\n const terminalFee = Number(this.pool.fee);\n\n if (startFee < terminalFee) {\n throw new Error(\n `Decay startFee (${startFee}) must be greater than or equal to terminal pool fee (${terminalFee})`,\n );\n }\n\n if (startFee > terminalFee && initializer.durationSeconds <= 0) {\n throw new Error(\n 'Decay durationSeconds must be greater than 0 when startFee is greater than pool.fee',\n );\n }\n }\n\n const schedule =\n initializer.type === 'scheduled'\n ? { startTime: initializer.startTime }\n : undefined;\n dopplerHook =\n initializer.type === 'rehype' ? initializer.config : undefined;\n\n // Default governance: noOp on supported chains, default on others (e.g., Ink)\n const governance =\n this.governance ??\n (isNoOpEnabledChain(this.chainId)\n ? { type: 'noOp' as const }\n : { type: 'default' as const });\n\n if (\n governance.type === 'launchpad' &&\n !isLaunchpadEnabledChain(this.chainId)\n ) {\n throw new Error(\n `Launchpad governance is not supported on chain ${this.chainId}. Use a supported chain or a different governance type.`,\n );\n }\n\n return {\n token: this.token,\n sale: this.sale,\n pool: this.pool,\n initializer,\n schedule,\n dopplerHook,\n vesting: this.vesting,\n governance: governance as GovernanceOption<C>,\n migration: this.migration,\n integrator: this.integrator ?? ZERO_ADDRESS,\n userAddress: this.userAddress,\n modules: this.moduleAddresses,\n gas: this.gasLimit,\n };\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkZ7ZGPSQF_js = require('./chunk-Z7ZGPSQF.js');
3
+ var chunkP4BT5GDO_js = require('./chunk-P4BT5GDO.js');
4
4
 
5
5
  // src/utils/airlock.ts
6
6
  var airlockAbi = [
@@ -15,10 +15,10 @@ var airlockAbi = [
15
15
  var getAirlockOwner = async (publicClient) => {
16
16
  const client = publicClient;
17
17
  const chainId = client.chain?.id;
18
- if (!chainId || !chunkZ7ZGPSQF_js.ADDRESSES[chainId]) {
18
+ if (!chainId || !chunkP4BT5GDO_js.ADDRESSES[chainId]) {
19
19
  throw new Error("Unsupported chain ID for airlock owner lookup");
20
20
  }
21
- const airlockAddress = chunkZ7ZGPSQF_js.ADDRESSES[chainId].airlock;
21
+ const airlockAddress = chunkP4BT5GDO_js.ADDRESSES[chainId].airlock;
22
22
  const owner = await client.readContract({
23
23
  address: airlockAddress,
24
24
  abi: airlockAbi,
@@ -41,5 +41,5 @@ exports.DEFAULT_AIRLOCK_BENEFICIARY_SHARES = DEFAULT_AIRLOCK_BENEFICIARY_SHARES;
41
41
  exports.createAirlockBeneficiary = createAirlockBeneficiary;
42
42
  exports.getAirlockBeneficiary = getAirlockBeneficiary;
43
43
  exports.getAirlockOwner = getAirlockOwner;
44
- //# sourceMappingURL=chunk-WHQHXYPB.js.map
45
- //# sourceMappingURL=chunk-WHQHXYPB.js.map
44
+ //# sourceMappingURL=chunk-YKRDFXU3.js.map
45
+ //# sourceMappingURL=chunk-YKRDFXU3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/airlock.ts"],"names":["ADDRESSES"],"mappings":";;;;;AAIA,IAAM,UAAA,GAAa;AAAA,EACjB;AAAA,IACE,IAAA,EAAM,UAAA;AAAA,IACN,IAAA,EAAM,OAAA;AAAA,IACN,QAAQ,EAAC;AAAA,IACT,OAAA,EAAS,CAAC,EAAE,IAAA,EAAM,IAAI,IAAA,EAAM,SAAA,EAAW,YAAA,EAAc,SAAA,EAAW,CAAA;AAAA,IAChE,eAAA,EAAiB;AAAA;AAErB,CAAA;AAEO,IAAM,eAAA,GAAkB,OAC7B,YAAA,KACqB;AACrB,EAAA,MAAM,MAAA,GAAS,YAAA;AACf,EAAA,MAAM,OAAA,GAAU,OAAO,KAAA,EAAO,EAAA;AAC9B,EAAA,IAAI,CAAC,OAAA,IAAW,CAACA,0BAAA,CAAU,OAAO,CAAA,EAAG;AACnC,IAAA,MAAM,IAAI,MAAM,+CAA+C,CAAA;AAAA,EACjE;AAEA,EAAA,MAAM,cAAA,GAAiBA,0BAAA,CAAU,OAAO,CAAA,CAAE,OAAA;AAE1C,EAAA,MAAM,KAAA,GAAQ,MAAM,MAAA,CAAO,YAAA,CAAa;AAAA,IACtC,OAAA,EAAS,cAAA;AAAA,IACT,GAAA,EAAK,UAAA;AAAA,IACL,YAAA,EAAc;AAAA,GACf,CAAA;AAED,EAAA,IAAI,CAAC,KAAA,EAAO,MAAM,IAAI,MAAM,yBAAyB,CAAA;AACrD,EAAA,OAAO,KAAA;AACT;AAGO,IAAM,kCAAA,GAAqC,OAAO,IAAI;AAEtD,IAAM,wBAAA,GAA2B,CACtC,KAAA,EACA,MAAA,GAAiB,kCAAA,MACI;AAAA,EACrB,WAAA,EAAa,KAAA;AAAA,EACb;AACF,CAAA;AAEO,IAAM,qBAAA,GAAwB,OACnC,YAAA,EACA,MAAA,GAAiB,kCAAA,KACY;AAC7B,EAAA,MAAM,KAAA,GAAQ,MAAM,eAAA,CAAgB,YAAY,CAAA;AAChD,EAAA,OAAO,wBAAA,CAAyB,OAAO,MAAM,CAAA;AAC/C","file":"chunk-WHQHXYPB.js","sourcesContent":["import type { PublicClient, Address } from 'viem';\nimport { ADDRESSES, type SupportedChainId } from '../addresses';\nimport type { BeneficiaryData } from '../types';\n\nconst airlockAbi = [\n {\n type: 'function',\n name: 'owner',\n inputs: [],\n outputs: [{ name: '', type: 'address', internalType: 'address' }],\n stateMutability: 'view',\n },\n] as const;\n\nexport const getAirlockOwner = async (\n publicClient: unknown,\n): Promise<Address> => {\n const client = publicClient as PublicClient;\n const chainId = client.chain?.id as SupportedChainId | undefined;\n if (!chainId || !ADDRESSES[chainId]) {\n throw new Error('Unsupported chain ID for airlock owner lookup');\n }\n\n const airlockAddress = ADDRESSES[chainId].airlock;\n\n const owner = await client.readContract({\n address: airlockAddress,\n abi: airlockAbi,\n functionName: 'owner',\n });\n\n if (!owner) throw new Error('Airlock owner not found');\n return owner as Address;\n};\n\n// Default airlock beneficiary shares (5% = 0.05e18 WAD)\nexport const DEFAULT_AIRLOCK_BENEFICIARY_SHARES = BigInt(5e16); // 5% in WAD\n\nexport const createAirlockBeneficiary = (\n owner: Address,\n shares: bigint = DEFAULT_AIRLOCK_BENEFICIARY_SHARES,\n): BeneficiaryData => ({\n beneficiary: owner,\n shares,\n});\n\nexport const getAirlockBeneficiary = async (\n publicClient: unknown,\n shares: bigint = DEFAULT_AIRLOCK_BENEFICIARY_SHARES,\n): Promise<BeneficiaryData> => {\n const owner = await getAirlockOwner(publicClient);\n return createAirlockBeneficiary(owner, shares);\n};\n"]}
1
+ {"version":3,"sources":["../src/utils/airlock.ts"],"names":["ADDRESSES"],"mappings":";;;;;AAIA,IAAM,UAAA,GAAa;AAAA,EACjB;AAAA,IACE,IAAA,EAAM,UAAA;AAAA,IACN,IAAA,EAAM,OAAA;AAAA,IACN,QAAQ,EAAC;AAAA,IACT,OAAA,EAAS,CAAC,EAAE,IAAA,EAAM,IAAI,IAAA,EAAM,SAAA,EAAW,YAAA,EAAc,SAAA,EAAW,CAAA;AAAA,IAChE,eAAA,EAAiB;AAAA;AAErB,CAAA;AAEO,IAAM,eAAA,GAAkB,OAC7B,YAAA,KACqB;AACrB,EAAA,MAAM,MAAA,GAAS,YAAA;AACf,EAAA,MAAM,OAAA,GAAU,OAAO,KAAA,EAAO,EAAA;AAC9B,EAAA,IAAI,CAAC,OAAA,IAAW,CAACA,0BAAA,CAAU,OAAO,CAAA,EAAG;AACnC,IAAA,MAAM,IAAI,MAAM,+CAA+C,CAAA;AAAA,EACjE;AAEA,EAAA,MAAM,cAAA,GAAiBA,0BAAA,CAAU,OAAO,CAAA,CAAE,OAAA;AAE1C,EAAA,MAAM,KAAA,GAAQ,MAAM,MAAA,CAAO,YAAA,CAAa;AAAA,IACtC,OAAA,EAAS,cAAA;AAAA,IACT,GAAA,EAAK,UAAA;AAAA,IACL,YAAA,EAAc;AAAA,GACf,CAAA;AAED,EAAA,IAAI,CAAC,KAAA,EAAO,MAAM,IAAI,MAAM,yBAAyB,CAAA;AACrD,EAAA,OAAO,KAAA;AACT;AAGO,IAAM,kCAAA,GAAqC,OAAO,IAAI;AAEtD,IAAM,wBAAA,GAA2B,CACtC,KAAA,EACA,MAAA,GAAiB,kCAAA,MACI;AAAA,EACrB,WAAA,EAAa,KAAA;AAAA,EACb;AACF,CAAA;AAEO,IAAM,qBAAA,GAAwB,OACnC,YAAA,EACA,MAAA,GAAiB,kCAAA,KACY;AAC7B,EAAA,MAAM,KAAA,GAAQ,MAAM,eAAA,CAAgB,YAAY,CAAA;AAChD,EAAA,OAAO,wBAAA,CAAyB,OAAO,MAAM,CAAA;AAC/C","file":"chunk-YKRDFXU3.js","sourcesContent":["import type { PublicClient, Address } from 'viem';\nimport { ADDRESSES, type SupportedChainId } from '../addresses';\nimport type { BeneficiaryData } from '../types';\n\nconst airlockAbi = [\n {\n type: 'function',\n name: 'owner',\n inputs: [],\n outputs: [{ name: '', type: 'address', internalType: 'address' }],\n stateMutability: 'view',\n },\n] as const;\n\nexport const getAirlockOwner = async (\n publicClient: unknown,\n): Promise<Address> => {\n const client = publicClient as PublicClient;\n const chainId = client.chain?.id as SupportedChainId | undefined;\n if (!chainId || !ADDRESSES[chainId]) {\n throw new Error('Unsupported chain ID for airlock owner lookup');\n }\n\n const airlockAddress = ADDRESSES[chainId].airlock;\n\n const owner = await client.readContract({\n address: airlockAddress,\n abi: airlockAbi,\n functionName: 'owner',\n });\n\n if (!owner) throw new Error('Airlock owner not found');\n return owner as Address;\n};\n\n// Default airlock beneficiary shares (5% = 0.05e18 WAD)\nexport const DEFAULT_AIRLOCK_BENEFICIARY_SHARES = BigInt(5e16); // 5% in WAD\n\nexport const createAirlockBeneficiary = (\n owner: Address,\n shares: bigint = DEFAULT_AIRLOCK_BENEFICIARY_SHARES,\n): BeneficiaryData => ({\n beneficiary: owner,\n shares,\n});\n\nexport const getAirlockBeneficiary = async (\n publicClient: unknown,\n shares: bigint = DEFAULT_AIRLOCK_BENEFICIARY_SHARES,\n): Promise<BeneficiaryData> => {\n const owner = await getAirlockOwner(publicClient);\n return createAirlockBeneficiary(owner, shares);\n};\n"]}