@whetstone-research/doppler-sdk 0.0.18 → 0.0.20
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 +46 -1
- package/dist/DopplerSDK.js +18 -18
- package/dist/DopplerSDK.mjs +17 -17
- package/dist/abis/index.d.mts +32 -1
- package/dist/abis/index.d.ts +32 -1
- package/dist/abis/index.js +26 -22
- package/dist/abis/index.mjs +1 -1
- package/dist/addresses.d.mts +1 -0
- package/dist/addresses.d.ts +1 -0
- package/dist/addresses.js +7 -7
- package/dist/addresses.mjs +2 -2
- package/dist/builders/DynamicAuctionBuilder.js +9 -9
- package/dist/builders/DynamicAuctionBuilder.mjs +8 -8
- package/dist/builders/MulticurveBuilder.d.mts +16 -0
- package/dist/builders/MulticurveBuilder.d.ts +16 -0
- package/dist/builders/MulticurveBuilder.js +9 -9
- package/dist/builders/MulticurveBuilder.mjs +8 -8
- package/dist/builders/StaticAuctionBuilder.js +9 -9
- package/dist/builders/StaticAuctionBuilder.mjs +8 -8
- package/dist/builders/index.js +17 -17
- package/dist/builders/index.mjs +10 -10
- package/dist/builders/shared.js +10 -10
- package/dist/builders/shared.mjs +6 -6
- package/dist/{chunk-ZQA3VG53.mjs → chunk-36Y3N257.mjs} +118 -20
- package/dist/chunk-36Y3N257.mjs.map +1 -0
- package/dist/{chunk-LOVD3NCN.js → chunk-3MVW6UIW.js} +18 -2
- package/dist/chunk-3MVW6UIW.js.map +1 -0
- package/dist/{chunk-WGP4RHM7.js → chunk-3SCK4LGS.js} +26 -26
- package/dist/{chunk-WGP4RHM7.js.map → chunk-3SCK4LGS.js.map} +1 -1
- package/dist/{chunk-UGBCLUOX.js → chunk-4CJS5XLY.js} +26 -26
- package/dist/{chunk-UGBCLUOX.js.map → chunk-4CJS5XLY.js.map} +1 -1
- package/dist/{chunk-IJEMEVGS.mjs → chunk-4LNXE5DF.mjs} +4 -4
- package/dist/{chunk-IJEMEVGS.mjs.map → chunk-4LNXE5DF.mjs.map} +1 -1
- package/dist/{chunk-4DUE547M.js → chunk-6BQY5EPB.js} +4 -2
- package/dist/chunk-6BQY5EPB.js.map +1 -0
- package/dist/{chunk-27TY7K5D.js → chunk-AS5UUJRI.js} +11 -11
- package/dist/{chunk-27TY7K5D.js.map → chunk-AS5UUJRI.js.map} +1 -1
- package/dist/{chunk-Y4IZVDJE.mjs → chunk-BFJGY436.mjs} +3 -3
- package/dist/{chunk-Y4IZVDJE.mjs.map → chunk-BFJGY436.mjs.map} +1 -1
- package/dist/{chunk-NVJNZ7XO.js → chunk-COUZYFEE.js} +27 -27
- package/dist/{chunk-NVJNZ7XO.js.map → chunk-COUZYFEE.js.map} +1 -1
- package/dist/{chunk-JCJVX42H.mjs → chunk-CXE33IZN.mjs} +5 -5
- package/dist/{chunk-JCJVX42H.mjs.map → chunk-CXE33IZN.mjs.map} +1 -1
- package/dist/{chunk-BZKX3J3R.mjs → chunk-E2NF4AQB.mjs} +18 -3
- package/dist/chunk-E2NF4AQB.mjs.map +1 -0
- package/dist/{chunk-3Q2BALCB.js → chunk-GFOBDFVW.js} +344 -147
- package/dist/chunk-GFOBDFVW.js.map +1 -0
- package/dist/{chunk-CXYA7OX6.js → chunk-GLMPU7VL.js} +132 -34
- package/dist/chunk-GLMPU7VL.js.map +1 -0
- package/dist/{chunk-PE47QUJV.mjs → chunk-HH7HQ4HC.mjs} +3 -3
- package/dist/{chunk-PE47QUJV.mjs.map → chunk-HH7HQ4HC.mjs.map} +1 -1
- package/dist/{chunk-IUXOT6OY.js → chunk-HHHCRTC7.js} +53 -15
- package/dist/chunk-HHHCRTC7.js.map +1 -0
- package/dist/{chunk-LXUF7RNX.mjs → chunk-IWJOPXYN.mjs} +4 -3
- package/dist/chunk-IWJOPXYN.mjs.map +1 -0
- package/dist/{chunk-4BPFHO6W.js → chunk-J2E2GILK.js} +20 -20
- package/dist/{chunk-4BPFHO6W.js.map → chunk-J2E2GILK.js.map} +1 -1
- package/dist/{chunk-2UUVAFXS.js → chunk-JHPDKSC4.js} +78 -72
- package/dist/chunk-JHPDKSC4.js.map +1 -0
- package/dist/{chunk-AQKQRG7M.js → chunk-K27G7LLT.js} +5 -5
- package/dist/{chunk-AQKQRG7M.js.map → chunk-K27G7LLT.js.map} +1 -1
- package/dist/{chunk-FM5ASWDQ.mjs → chunk-NJYBKWCD.mjs} +45 -7
- package/dist/chunk-NJYBKWCD.mjs.map +1 -0
- package/dist/{chunk-RAII4DRI.mjs → chunk-NWZGO2CH.mjs} +10 -4
- package/dist/chunk-NWZGO2CH.mjs.map +1 -0
- package/dist/{chunk-WM2YFSKT.mjs → chunk-QFQXHDC7.mjs} +11 -2
- package/dist/chunk-QFQXHDC7.mjs.map +1 -0
- package/dist/{chunk-RKJ2466C.mjs → chunk-QOGBOT2M.mjs} +3 -3
- package/dist/{chunk-RKJ2466C.mjs.map → chunk-QOGBOT2M.mjs.map} +1 -1
- package/dist/{chunk-AG3E3XYB.mjs → chunk-RJE6LWWF.mjs} +4 -4
- package/dist/{chunk-AG3E3XYB.mjs.map → chunk-RJE6LWWF.mjs.map} +1 -1
- package/dist/{chunk-EKQKHXJN.mjs → chunk-RKPAL3SU.mjs} +3 -3
- package/dist/{chunk-EKQKHXJN.mjs.map → chunk-RKPAL3SU.mjs.map} +1 -1
- package/dist/{chunk-JXNAHW6C.js → chunk-RLUMYHPI.js} +11 -2
- package/dist/chunk-RLUMYHPI.js.map +1 -0
- package/dist/{chunk-5FJCRKQ6.js → chunk-RXUJ4DUB.js} +28 -28
- package/dist/{chunk-5FJCRKQ6.js.map → chunk-RXUJ4DUB.js.map} +1 -1
- package/dist/{chunk-MGLI4N4B.js → chunk-SAX7P3MH.js} +22 -22
- package/dist/{chunk-MGLI4N4B.js.map → chunk-SAX7P3MH.js.map} +1 -1
- package/dist/{chunk-226TXYRB.mjs → chunk-SKU6VE6L.mjs} +12 -12
- package/dist/{chunk-226TXYRB.mjs.map → chunk-SKU6VE6L.mjs.map} +1 -1
- package/dist/{chunk-DVQWWF23.js → chunk-TYJZL2XZ.js} +24 -24
- package/dist/{chunk-DVQWWF23.js.map → chunk-TYJZL2XZ.js.map} +1 -1
- package/dist/{chunk-IJRI5LNK.mjs → chunk-U7CHPFU6.mjs} +248 -51
- package/dist/chunk-U7CHPFU6.mjs.map +1 -0
- package/dist/{chunk-WMOJQ6MS.mjs → chunk-V7YRKFYK.mjs} +5 -5
- package/dist/{chunk-WMOJQ6MS.mjs.map → chunk-V7YRKFYK.mjs.map} +1 -1
- package/dist/{chunk-IEEK2PMP.mjs → chunk-XEWKLVOD.mjs} +4 -4
- package/dist/{chunk-IEEK2PMP.mjs.map → chunk-XEWKLVOD.mjs.map} +1 -1
- package/dist/{chunk-HVYUDMHH.js → chunk-Y5RAENN5.js} +16 -16
- package/dist/{chunk-HVYUDMHH.js.map → chunk-Y5RAENN5.js.map} +1 -1
- package/dist/constants.d.mts +7 -1
- package/dist/constants.d.ts +7 -1
- package/dist/constants.js +51 -47
- package/dist/constants.mjs +1 -1
- package/dist/deployments.generated.d.mts +9 -0
- package/dist/deployments.generated.d.ts +9 -0
- package/dist/deployments.generated.js +2 -2
- package/dist/deployments.generated.mjs +1 -1
- package/dist/entities/DopplerFactory.d.mts +2 -0
- package/dist/entities/DopplerFactory.d.ts +2 -0
- package/dist/entities/DopplerFactory.js +7 -7
- package/dist/entities/DopplerFactory.mjs +6 -6
- package/dist/entities/auction/DynamicAuction.js +5 -5
- package/dist/entities/auction/DynamicAuction.mjs +4 -4
- package/dist/entities/auction/MulticurvePool.d.mts +9 -3
- package/dist/entities/auction/MulticurvePool.d.ts +9 -3
- package/dist/entities/auction/MulticurvePool.js +7 -6
- package/dist/entities/auction/MulticurvePool.mjs +6 -5
- package/dist/entities/auction/StaticAuction.js +5 -5
- package/dist/entities/auction/StaticAuction.mjs +4 -4
- package/dist/entities/auction/index.js +11 -10
- package/dist/entities/auction/index.mjs +8 -7
- package/dist/entities/quoter/Quoter.js +5 -5
- package/dist/entities/quoter/Quoter.mjs +4 -4
- package/dist/entities/quoter/index.js +5 -5
- package/dist/entities/quoter/index.mjs +4 -4
- package/dist/entities/token/derc20/Derc20.js +3 -3
- package/dist/entities/token/derc20/Derc20.mjs +2 -2
- package/dist/entities/token/derc20/index.js +3 -3
- package/dist/entities/token/derc20/index.mjs +2 -2
- package/dist/entities/token/index.js +3 -3
- package/dist/entities/token/index.mjs +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +108 -100
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -17
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.mts +32 -1
- package/dist/types.d.ts +32 -1
- package/dist/types.js +8 -8
- package/dist/types.mjs +3 -3
- package/dist/utils/airlock.js +7 -7
- package/dist/utils/airlock.mjs +3 -3
- package/dist/utils/index.js +8 -8
- package/dist/utils/index.mjs +4 -4
- package/dist/utils/tokenAddressMiner.js +1 -1
- package/dist/utils/tokenAddressMiner.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-2UUVAFXS.js.map +0 -1
- package/dist/chunk-3Q2BALCB.js.map +0 -1
- package/dist/chunk-4DUE547M.js.map +0 -1
- package/dist/chunk-BZKX3J3R.mjs.map +0 -1
- package/dist/chunk-CXYA7OX6.js.map +0 -1
- package/dist/chunk-FM5ASWDQ.mjs.map +0 -1
- package/dist/chunk-IJRI5LNK.mjs.map +0 -1
- package/dist/chunk-IUXOT6OY.js.map +0 -1
- package/dist/chunk-JXNAHW6C.js.map +0 -1
- package/dist/chunk-LOVD3NCN.js.map +0 -1
- package/dist/chunk-LXUF7RNX.mjs.map +0 -1
- package/dist/chunk-RAII4DRI.mjs.map +0 -1
- package/dist/chunk-WM2YFSKT.mjs.map +0 -1
- package/dist/chunk-ZQA3VG53.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkJHPDKSC4_js = require('./chunk-JHPDKSC4.js');
|
|
4
|
+
var chunk3MVW6UIW_js = require('./chunk-3MVW6UIW.js');
|
|
5
5
|
var viem = require('viem');
|
|
6
6
|
|
|
7
7
|
var DynamicAuction = class {
|
|
@@ -44,42 +44,42 @@ var DynamicAuction = class {
|
|
|
44
44
|
this.readHookState(),
|
|
45
45
|
this.rpc.readContract({
|
|
46
46
|
address: this.hookAddress,
|
|
47
|
-
abi:
|
|
47
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
48
48
|
functionName: "earlyExit"
|
|
49
49
|
}),
|
|
50
50
|
this.rpc.readContract({
|
|
51
51
|
address: this.hookAddress,
|
|
52
|
-
abi:
|
|
52
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
53
53
|
functionName: "insufficientProceeds"
|
|
54
54
|
}),
|
|
55
55
|
this.rpc.readContract({
|
|
56
56
|
address: this.hookAddress,
|
|
57
|
-
abi:
|
|
57
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
58
58
|
functionName: "poolKey"
|
|
59
59
|
}),
|
|
60
60
|
this.rpc.readContract({
|
|
61
61
|
address: this.hookAddress,
|
|
62
|
-
abi:
|
|
62
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
63
63
|
functionName: "startingTime"
|
|
64
64
|
}),
|
|
65
65
|
this.rpc.readContract({
|
|
66
66
|
address: this.hookAddress,
|
|
67
|
-
abi:
|
|
67
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
68
68
|
functionName: "endingTime"
|
|
69
69
|
}),
|
|
70
70
|
this.rpc.readContract({
|
|
71
71
|
address: this.hookAddress,
|
|
72
|
-
abi:
|
|
72
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
73
73
|
functionName: "epochLength"
|
|
74
74
|
}),
|
|
75
75
|
this.rpc.readContract({
|
|
76
76
|
address: this.hookAddress,
|
|
77
|
-
abi:
|
|
77
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
78
78
|
functionName: "minimumProceeds"
|
|
79
79
|
}),
|
|
80
80
|
this.rpc.readContract({
|
|
81
81
|
address: this.hookAddress,
|
|
82
|
-
abi:
|
|
82
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
83
83
|
functionName: "maximumProceeds"
|
|
84
84
|
})
|
|
85
85
|
]);
|
|
@@ -114,13 +114,13 @@ var DynamicAuction = class {
|
|
|
114
114
|
async getTokenAddress() {
|
|
115
115
|
const poolKeyRaw = await this.rpc.readContract({
|
|
116
116
|
address: this.hookAddress,
|
|
117
|
-
abi:
|
|
117
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
118
118
|
functionName: "poolKey"
|
|
119
119
|
});
|
|
120
120
|
const poolKey = this.normalizePoolKey(poolKeyRaw);
|
|
121
121
|
const isToken0 = await this.rpc.readContract({
|
|
122
122
|
address: this.hookAddress,
|
|
123
|
-
abi:
|
|
123
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
124
124
|
functionName: "isToken0"
|
|
125
125
|
});
|
|
126
126
|
return isToken0 ? poolKey.currency0 : poolKey.currency1;
|
|
@@ -131,7 +131,7 @@ var DynamicAuction = class {
|
|
|
131
131
|
async getPoolId() {
|
|
132
132
|
const poolKeyRaw = await this.rpc.readContract({
|
|
133
133
|
address: this.hookAddress,
|
|
134
|
-
abi:
|
|
134
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
135
135
|
functionName: "poolKey"
|
|
136
136
|
});
|
|
137
137
|
const poolKey = this.normalizePoolKey(poolKeyRaw);
|
|
@@ -143,10 +143,10 @@ var DynamicAuction = class {
|
|
|
143
143
|
async hasGraduated() {
|
|
144
144
|
const tokenAddress = await this.getTokenAddress();
|
|
145
145
|
const chainId = await this.rpc.getChainId();
|
|
146
|
-
const addresses =
|
|
146
|
+
const addresses = chunkJHPDKSC4_js.getAddresses(chainId);
|
|
147
147
|
const assetData = await this.rpc.readContract({
|
|
148
148
|
address: addresses.airlock,
|
|
149
|
-
abi:
|
|
149
|
+
abi: chunk3MVW6UIW_js.airlockAbi,
|
|
150
150
|
functionName: "getAssetData",
|
|
151
151
|
args: [tokenAddress]
|
|
152
152
|
});
|
|
@@ -160,12 +160,12 @@ var DynamicAuction = class {
|
|
|
160
160
|
const [startingTime, epochLength] = await Promise.all([
|
|
161
161
|
this.rpc.readContract({
|
|
162
162
|
address: this.hookAddress,
|
|
163
|
-
abi:
|
|
163
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
164
164
|
functionName: "startingTime"
|
|
165
165
|
}),
|
|
166
166
|
this.rpc.readContract({
|
|
167
167
|
address: this.hookAddress,
|
|
168
|
-
abi:
|
|
168
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
169
169
|
functionName: "epochLength"
|
|
170
170
|
})
|
|
171
171
|
]);
|
|
@@ -182,27 +182,27 @@ var DynamicAuction = class {
|
|
|
182
182
|
this.readHookState(),
|
|
183
183
|
this.rpc.readContract({
|
|
184
184
|
address: this.hookAddress,
|
|
185
|
-
abi:
|
|
185
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
186
186
|
functionName: "startingTick"
|
|
187
187
|
}),
|
|
188
188
|
this.rpc.readContract({
|
|
189
189
|
address: this.hookAddress,
|
|
190
|
-
abi:
|
|
190
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
191
191
|
functionName: "endingTick"
|
|
192
192
|
}),
|
|
193
193
|
this.rpc.readContract({
|
|
194
194
|
address: this.hookAddress,
|
|
195
|
-
abi:
|
|
195
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
196
196
|
functionName: "gamma"
|
|
197
197
|
}),
|
|
198
198
|
this.rpc.readContract({
|
|
199
199
|
address: this.hookAddress,
|
|
200
|
-
abi:
|
|
200
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
201
201
|
functionName: "startingTime"
|
|
202
202
|
}),
|
|
203
203
|
this.rpc.readContract({
|
|
204
204
|
address: this.hookAddress,
|
|
205
|
-
abi:
|
|
205
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
206
206
|
functionName: "epochLength"
|
|
207
207
|
})
|
|
208
208
|
]);
|
|
@@ -227,7 +227,7 @@ var DynamicAuction = class {
|
|
|
227
227
|
async hasEndedEarly() {
|
|
228
228
|
return await this.rpc.readContract({
|
|
229
229
|
address: this.hookAddress,
|
|
230
|
-
abi:
|
|
230
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
231
231
|
functionName: "earlyExit"
|
|
232
232
|
});
|
|
233
233
|
}
|
|
@@ -260,7 +260,7 @@ var DynamicAuction = class {
|
|
|
260
260
|
async readHookState() {
|
|
261
261
|
const result = await this.rpc.readContract({
|
|
262
262
|
address: this.hookAddress,
|
|
263
|
-
abi:
|
|
263
|
+
abi: chunk3MVW6UIW_js.dopplerHookAbi,
|
|
264
264
|
functionName: "state"
|
|
265
265
|
});
|
|
266
266
|
if (Array.isArray(result)) {
|
|
@@ -293,5 +293,5 @@ var DynamicAuction = class {
|
|
|
293
293
|
};
|
|
294
294
|
|
|
295
295
|
exports.DynamicAuction = DynamicAuction;
|
|
296
|
-
//# sourceMappingURL=chunk-
|
|
297
|
-
//# sourceMappingURL=chunk-
|
|
296
|
+
//# sourceMappingURL=chunk-4CJS5XLY.js.map
|
|
297
|
+
//# sourceMappingURL=chunk-4CJS5XLY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/entities/auction/DynamicAuction.ts"],"names":["dopplerHookAbi","zeroAddress","getAddresses","airlockAbi","encodeAbiParameters","keccak256"],"mappings":";;;;;;AAkBO,IAAM,iBAAN,MAAqB;AAAA,EAG1B,IAAY,GAAA,GAAoB;AAC9B,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA,EAEA,WAAA,CAAY,QAA+B,WAAA,EAAsB;AAC/D,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA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AAA,CAAQ,WAAA;AAAA,QACR,OAAA,CAAQ;AAAA;AACV,KACF;AACA,IAAA,OAAOC,eAAU,OAAO,CAAA;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAc,aAAA,GAA8B;AAC1C,IAAA,MAAM,MAAA,GAAc,MAAM,IAAA,CAAK,GAAA,CAAI,YAAA,CAAa;AAAA,MAC9C,SAAS,IAAA,CAAK,WAAA;AAAA,MACd,GAAA,EAAKL,+BAAA;AAAA,MACL,YAAA,EAAc;AAAA,KACf,CAAA;AACD,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,EAAG;AACzB,MAAA,MAAM;AAAA,QACJ,SAAA;AAAA,QACA,eAAA;AAAA,QACA,eAAA;AAAA,QACA,aAAA;AAAA,QACA,wBAAA;AAAA,QACA;AAAA,OACF,GAAI,MAAA;AACJ,MAAA,OAAO;AAAA,QACL,SAAA;AAAA,QACA,eAAA;AAAA,QACA,eAAA;AAAA,QACA,aAAA;AAAA,QACA,wBAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEQ,iBAAiB,KAAA,EAMvB;AACA,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,MAAA,MAAM,CAAC,SAAA,EAAW,SAAA,EAAW,GAAA,EAAK,WAAA,EAAa,KAAK,CAAA,GAAI,KAAA;AAOxD,MAAA,OAAO,EAAE,SAAA,EAAW,SAAA,EAAW,GAAA,EAAK,aAAa,KAAA,EAAM;AAAA,IACzD;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACF","file":"chunk-UGBCLUOX.js","sourcesContent":["import {\n type Address,\n type PublicClient,\n type Hex,\n keccak256,\n encodeAbiParameters,\n zeroAddress,\n} from 'viem';\nimport type { HookInfo, SupportedPublicClient } from '../../types';\nimport { dopplerHookAbi, airlockAbi } from '../../abis';\nimport { getAddresses } from '../../addresses';\n\n/**\n * DynamicAuction class for interacting with dynamic auctions (Uniswap V4 hook based)\n *\n * Dynamic auctions use a Uniswap V4 hook to create a gradual Dutch auction\n * where the price moves dynamically over time according to set parameters.\n */\nexport class DynamicAuction {\n private client: SupportedPublicClient;\n private hookAddress: Address;\n private get rpc(): PublicClient {\n return this.client as PublicClient;\n }\n\n constructor(client: SupportedPublicClient, hookAddress: Address) {\n this.client = client;\n this.hookAddress = hookAddress;\n }\n\n /**\n * Wait for a transaction to be confirmed and the contract to be ready for reads\n * @param hash - Transaction hash to wait for\n * @param confirmations - Number of block confirmations to wait for (default: 2)\n */\n async waitForDeployment(hash: Hex, confirmations: number = 2): Promise<void> {\n await this.rpc.waitForTransactionReceipt({ hash, confirmations });\n }\n\n /**\n * Get the hook address\n */\n getAddress(): Address {\n return this.hookAddress;\n }\n\n /**\n * Get current hook information\n */\n async getHookInfo(): Promise<HookInfo> {\n // Fetch all hook data in parallel\n const [\n state,\n earlyExit,\n insufficientProceeds,\n poolKeyRaw,\n startingTime,\n endingTime,\n epochLength,\n minimumProceeds,\n maximumProceeds,\n ] = await Promise.all([\n this.readHookState(),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'earlyExit',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'insufficientProceeds',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'poolKey',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'startingTime',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'endingTime',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'epochLength',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'minimumProceeds',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'maximumProceeds',\n }),\n ]);\n\n // Calculate current epoch\n const currentTime = BigInt(Math.floor(Date.now() / 1000));\n const elapsedTime =\n currentTime > startingTime ? currentTime - startingTime : BigInt(0);\n const currentEpoch =\n epochLength > 0n ? Number(elapsedTime / epochLength) : 0;\n\n // Determine token addresses from poolKey\n const poolKey = this.normalizePoolKey(poolKeyRaw as any);\n const isToken0 = poolKey.currency0 !== zeroAddress;\n const tokenAddress = isToken0 ? poolKey.currency0 : poolKey.currency1;\n const numeraireAddress = isToken0 ? poolKey.currency1 : poolKey.currency0;\n\n // Compute pool ID\n const poolId = this.computePoolId(poolKey);\n\n return {\n hookAddress: this.hookAddress,\n tokenAddress,\n numeraireAddress,\n poolId,\n currentEpoch,\n totalProceeds: (state as any).totalProceeds,\n totalTokensSold: (state as any).totalTokensSold,\n earlyExit,\n insufficientProceeds,\n startingTime,\n endingTime,\n epochLength,\n minimumProceeds,\n maximumProceeds,\n };\n }\n\n /**\n * Get the token address for this auction\n */\n async getTokenAddress(): Promise<Address> {\n const poolKeyRaw = await this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'poolKey',\n });\n const poolKey = this.normalizePoolKey(poolKeyRaw as any);\n\n const isToken0 = await this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'isToken0',\n });\n\n return isToken0 ? poolKey.currency0 : poolKey.currency1;\n }\n\n /**\n * Get the pool ID for this auction\n */\n async getPoolId(): Promise<string> {\n const poolKeyRaw = await this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'poolKey',\n });\n const poolKey = this.normalizePoolKey(poolKeyRaw as any);\n return this.computePoolId(poolKey);\n }\n\n /**\n * Check if the auction has graduated (ready for migration)\n */\n async hasGraduated(): Promise<boolean> {\n const tokenAddress = await this.getTokenAddress();\n const chainId = await this.rpc.getChainId();\n const addresses = getAddresses(chainId);\n\n const assetData = await this.rpc.readContract({\n address: addresses.airlock,\n abi: airlockAbi,\n functionName: 'getAssetData',\n args: [tokenAddress],\n });\n // Check if the asset is graduated (liquidityMigrator is zero)\n const liquidityMigrator = Array.isArray(assetData)\n ? (assetData as any)[3]\n : (assetData as any)?.liquidityMigrator;\n return liquidityMigrator === zeroAddress;\n }\n\n /**\n * Get the current epoch\n */\n async getCurrentEpoch(): Promise<number> {\n const [startingTime, epochLength] = await Promise.all([\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'startingTime',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'epochLength',\n }),\n ]);\n\n const currentTime = BigInt(Math.floor(Date.now() / 1000));\n const elapsedTime =\n currentTime > startingTime ? currentTime - startingTime : BigInt(0);\n\n return Number(elapsedTime / epochLength);\n }\n\n /**\n * Get the current price in the auction\n * Returns the current tick based on the epoch and gamma parameters\n */\n async getCurrentPrice(): Promise<bigint> {\n const [_state, startingTick, endingTick, gamma, startingTime, epochLength] =\n await Promise.all([\n this.readHookState(),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'startingTick',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'endingTick',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'gamma',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'startingTime',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'epochLength',\n }),\n ]);\n\n // Calculate current epoch\n const currentTime = BigInt(Math.floor(Date.now() / 1000));\n const elapsedTime =\n currentTime > startingTime ? currentTime - startingTime : BigInt(0);\n const currentEpoch =\n epochLength > 0n ? Number(elapsedTime / epochLength) : 0;\n\n // Calculate current tick based on the auction progression\n // The tick moves from startingTick towards endingTick based on epochs and gamma\n const direction = endingTick > startingTick ? 1 : -1;\n const tickMovement = Math.floor(currentEpoch * gamma * direction);\n const currentTick = Math.floor(startingTick + tickMovement);\n\n // Convert tick to price\n // price = 1.0001^tick\n // For simplicity, returning the tick as bigint for now\n // In production, you'd convert this to actual price using TickMath\n return BigInt(currentTick);\n }\n\n /**\n * Get total proceeds collected so far\n */\n async getTotalProceeds(): Promise<bigint> {\n const state = await this.readHookState();\n\n return (state as any).totalProceeds;\n }\n\n /**\n * Check if the auction ended early due to max proceeds\n */\n async hasEndedEarly(): Promise<boolean> {\n return await this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'earlyExit',\n });\n }\n\n /**\n * Compute V4 pool ID from pool key components\n */\n private computePoolId(poolKey: {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n }): string {\n // V4 pools are identified by the hash of their PoolKey\n const encoded = encodeAbiParameters(\n [\n { type: 'address' },\n { type: 'address' },\n { type: 'uint24' },\n { type: 'int24' },\n { type: 'address' },\n ],\n [\n poolKey.currency0,\n poolKey.currency1,\n poolKey.fee,\n poolKey.tickSpacing,\n poolKey.hooks,\n ],\n );\n return keccak256(encoded);\n }\n\n /**\n * Read hook state with backward-compatible decoding.\n * Falls back to legacy state() ABI if the latest ABI fails to decode.\n */\n private async readHookState(): Promise<any> {\n const result: any = await this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'state',\n });\n if (Array.isArray(result)) {\n const [\n lastEpoch,\n tickAccumulator,\n totalTokensSold,\n totalProceeds,\n totalTokensSoldLastEpoch,\n feesAccrued,\n ] = result as any[];\n return {\n lastEpoch,\n tickAccumulator,\n totalTokensSold,\n totalProceeds,\n totalTokensSoldLastEpoch,\n feesAccrued,\n };\n }\n return result;\n }\n\n private normalizePoolKey(value: any): {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n } {\n if (Array.isArray(value)) {\n const [currency0, currency1, fee, tickSpacing, hooks] = value as [\n Address,\n Address,\n number,\n number,\n Address,\n ];\n return { currency0, currency1, fee, tickSpacing, hooks };\n }\n return value as any;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/entities/auction/DynamicAuction.ts"],"names":["dopplerHookAbi","zeroAddress","getAddresses","airlockAbi","encodeAbiParameters","keccak256"],"mappings":";;;;;;AAkBO,IAAM,iBAAN,MAAqB;AAAA,EAG1B,IAAY,GAAA,GAAoB;AAC9B,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA,EAEA,WAAA,CAAY,QAA+B,WAAA,EAAsB;AAC/D,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,WAAA,GAAc,WAAA;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,iBAAA,CAAkB,IAAA,EAAW,aAAA,GAAwB,CAAA,EAAkB;AAC3E,IAAA,MAAM,KAAK,GAAA,CAAI,yBAAA,CAA0B,EAAE,IAAA,EAAM,eAAe,CAAA;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA,GAAsB;AACpB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAA,GAAiC;AAErC,IAAA,MAAM;AAAA,MACJ,KAAA;AAAA,MACA,SAAA;AAAA,MACA,oBAAA;AAAA,MACA,UAAA;AAAA,MACA,YAAA;AAAA,MACA,UAAA;AAAA,MACA,WAAA;AAAA,MACA,eAAA;AAAA,MACA;AAAA,KACF,GAAI,MAAM,OAAA,CAAQ,GAAA,CAAI;AAAA,MACpB,KAAK,aAAA,EAAc;AAAA,MACnB,IAAA,CAAK,IAAI,YAAA,CAAa;AAAA,QACpB,SAAS,IAAA,CAAK,WAAA;AAAA,QACd,GAAA,EAAKA,+BAAA;AAAA,QACL,YAAA,EAAc;AAAA,OACf,CAAA;AAAA,MACD,IAAA,CAAK,IAAI,YAAA,CAAa;AAAA,QACpB,SAAS,IAAA,C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,EAAW,GAAA,EAAK,WAAA,EAAa,KAAK,CAAA,GAAI,KAAA;AAOxD,MAAA,OAAO,EAAE,SAAA,EAAW,SAAA,EAAW,GAAA,EAAK,aAAa,KAAA,EAAM;AAAA,IACzD;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACF","file":"chunk-4CJS5XLY.js","sourcesContent":["import {\n type Address,\n type PublicClient,\n type Hex,\n keccak256,\n encodeAbiParameters,\n zeroAddress,\n} from 'viem';\nimport type { HookInfo, SupportedPublicClient } from '../../types';\nimport { dopplerHookAbi, airlockAbi } from '../../abis';\nimport { getAddresses } from '../../addresses';\n\n/**\n * DynamicAuction class for interacting with dynamic auctions (Uniswap V4 hook based)\n *\n * Dynamic auctions use a Uniswap V4 hook to create a gradual Dutch auction\n * where the price moves dynamically over time according to set parameters.\n */\nexport class DynamicAuction {\n private client: SupportedPublicClient;\n private hookAddress: Address;\n private get rpc(): PublicClient {\n return this.client as PublicClient;\n }\n\n constructor(client: SupportedPublicClient, hookAddress: Address) {\n this.client = client;\n this.hookAddress = hookAddress;\n }\n\n /**\n * Wait for a transaction to be confirmed and the contract to be ready for reads\n * @param hash - Transaction hash to wait for\n * @param confirmations - Number of block confirmations to wait for (default: 2)\n */\n async waitForDeployment(hash: Hex, confirmations: number = 2): Promise<void> {\n await this.rpc.waitForTransactionReceipt({ hash, confirmations });\n }\n\n /**\n * Get the hook address\n */\n getAddress(): Address {\n return this.hookAddress;\n }\n\n /**\n * Get current hook information\n */\n async getHookInfo(): Promise<HookInfo> {\n // Fetch all hook data in parallel\n const [\n state,\n earlyExit,\n insufficientProceeds,\n poolKeyRaw,\n startingTime,\n endingTime,\n epochLength,\n minimumProceeds,\n maximumProceeds,\n ] = await Promise.all([\n this.readHookState(),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'earlyExit',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'insufficientProceeds',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'poolKey',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'startingTime',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'endingTime',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'epochLength',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'minimumProceeds',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'maximumProceeds',\n }),\n ]);\n\n // Calculate current epoch\n const currentTime = BigInt(Math.floor(Date.now() / 1000));\n const elapsedTime =\n currentTime > startingTime ? currentTime - startingTime : BigInt(0);\n const currentEpoch =\n epochLength > 0n ? Number(elapsedTime / epochLength) : 0;\n\n // Determine token addresses from poolKey\n const poolKey = this.normalizePoolKey(poolKeyRaw as any);\n const isToken0 = poolKey.currency0 !== zeroAddress;\n const tokenAddress = isToken0 ? poolKey.currency0 : poolKey.currency1;\n const numeraireAddress = isToken0 ? poolKey.currency1 : poolKey.currency0;\n\n // Compute pool ID\n const poolId = this.computePoolId(poolKey);\n\n return {\n hookAddress: this.hookAddress,\n tokenAddress,\n numeraireAddress,\n poolId,\n currentEpoch,\n totalProceeds: (state as any).totalProceeds,\n totalTokensSold: (state as any).totalTokensSold,\n earlyExit,\n insufficientProceeds,\n startingTime,\n endingTime,\n epochLength,\n minimumProceeds,\n maximumProceeds,\n };\n }\n\n /**\n * Get the token address for this auction\n */\n async getTokenAddress(): Promise<Address> {\n const poolKeyRaw = await this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'poolKey',\n });\n const poolKey = this.normalizePoolKey(poolKeyRaw as any);\n\n const isToken0 = await this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'isToken0',\n });\n\n return isToken0 ? poolKey.currency0 : poolKey.currency1;\n }\n\n /**\n * Get the pool ID for this auction\n */\n async getPoolId(): Promise<string> {\n const poolKeyRaw = await this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'poolKey',\n });\n const poolKey = this.normalizePoolKey(poolKeyRaw as any);\n return this.computePoolId(poolKey);\n }\n\n /**\n * Check if the auction has graduated (ready for migration)\n */\n async hasGraduated(): Promise<boolean> {\n const tokenAddress = await this.getTokenAddress();\n const chainId = await this.rpc.getChainId();\n const addresses = getAddresses(chainId);\n\n const assetData = await this.rpc.readContract({\n address: addresses.airlock,\n abi: airlockAbi,\n functionName: 'getAssetData',\n args: [tokenAddress],\n });\n // Check if the asset is graduated (liquidityMigrator is zero)\n const liquidityMigrator = Array.isArray(assetData)\n ? (assetData as any)[3]\n : (assetData as any)?.liquidityMigrator;\n return liquidityMigrator === zeroAddress;\n }\n\n /**\n * Get the current epoch\n */\n async getCurrentEpoch(): Promise<number> {\n const [startingTime, epochLength] = await Promise.all([\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'startingTime',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'epochLength',\n }),\n ]);\n\n const currentTime = BigInt(Math.floor(Date.now() / 1000));\n const elapsedTime =\n currentTime > startingTime ? currentTime - startingTime : BigInt(0);\n\n return Number(elapsedTime / epochLength);\n }\n\n /**\n * Get the current price in the auction\n * Returns the current tick based on the epoch and gamma parameters\n */\n async getCurrentPrice(): Promise<bigint> {\n const [_state, startingTick, endingTick, gamma, startingTime, epochLength] =\n await Promise.all([\n this.readHookState(),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'startingTick',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'endingTick',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'gamma',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'startingTime',\n }),\n this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'epochLength',\n }),\n ]);\n\n // Calculate current epoch\n const currentTime = BigInt(Math.floor(Date.now() / 1000));\n const elapsedTime =\n currentTime > startingTime ? currentTime - startingTime : BigInt(0);\n const currentEpoch =\n epochLength > 0n ? Number(elapsedTime / epochLength) : 0;\n\n // Calculate current tick based on the auction progression\n // The tick moves from startingTick towards endingTick based on epochs and gamma\n const direction = endingTick > startingTick ? 1 : -1;\n const tickMovement = Math.floor(currentEpoch * gamma * direction);\n const currentTick = Math.floor(startingTick + tickMovement);\n\n // Convert tick to price\n // price = 1.0001^tick\n // For simplicity, returning the tick as bigint for now\n // In production, you'd convert this to actual price using TickMath\n return BigInt(currentTick);\n }\n\n /**\n * Get total proceeds collected so far\n */\n async getTotalProceeds(): Promise<bigint> {\n const state = await this.readHookState();\n\n return (state as any).totalProceeds;\n }\n\n /**\n * Check if the auction ended early due to max proceeds\n */\n async hasEndedEarly(): Promise<boolean> {\n return await this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'earlyExit',\n });\n }\n\n /**\n * Compute V4 pool ID from pool key components\n */\n private computePoolId(poolKey: {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n }): string {\n // V4 pools are identified by the hash of their PoolKey\n const encoded = encodeAbiParameters(\n [\n { type: 'address' },\n { type: 'address' },\n { type: 'uint24' },\n { type: 'int24' },\n { type: 'address' },\n ],\n [\n poolKey.currency0,\n poolKey.currency1,\n poolKey.fee,\n poolKey.tickSpacing,\n poolKey.hooks,\n ],\n );\n return keccak256(encoded);\n }\n\n /**\n * Read hook state with backward-compatible decoding.\n * Falls back to legacy state() ABI if the latest ABI fails to decode.\n */\n private async readHookState(): Promise<any> {\n const result: any = await this.rpc.readContract({\n address: this.hookAddress,\n abi: dopplerHookAbi,\n functionName: 'state',\n });\n if (Array.isArray(result)) {\n const [\n lastEpoch,\n tickAccumulator,\n totalTokensSold,\n totalProceeds,\n totalTokensSoldLastEpoch,\n feesAccrued,\n ] = result as any[];\n return {\n lastEpoch,\n tickAccumulator,\n totalTokensSold,\n totalProceeds,\n totalTokensSoldLastEpoch,\n feesAccrued,\n };\n }\n return result;\n }\n\n private normalizePoolKey(value: any): {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n } {\n if (Array.isArray(value)) {\n const [currency0, currency1, fee, tickSpacing, hooks] = value as [\n Address,\n Address,\n number,\n number,\n Address,\n ];\n return { currency0, currency1, fee, tickSpacing, hooks };\n }\n return value as any;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getAddresses } from './chunk-
|
|
2
|
-
import { quoterV2Abi, uniswapV2Router02Abi, v4QuoterAbi } from './chunk-
|
|
1
|
+
import { getAddresses } from './chunk-NWZGO2CH.mjs';
|
|
2
|
+
import { quoterV2Abi, uniswapV2Router02Abi, v4QuoterAbi } from './chunk-E2NF4AQB.mjs';
|
|
3
3
|
import { decodeAbiParameters } from 'viem';
|
|
4
4
|
|
|
5
5
|
var Quoter = class {
|
|
@@ -259,5 +259,5 @@ var Quoter = class {
|
|
|
259
259
|
};
|
|
260
260
|
|
|
261
261
|
export { Quoter };
|
|
262
|
-
//# sourceMappingURL=chunk-
|
|
263
|
-
//# sourceMappingURL=chunk-
|
|
262
|
+
//# sourceMappingURL=chunk-4LNXE5DF.mjs.map
|
|
263
|
+
//# sourceMappingURL=chunk-4LNXE5DF.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/entities/quoter/Quoter.ts"],"names":[],"mappings":";;;;AAiBO,IAAM,SAAN,MAAa;AAAA,EAGlB,IAAY,GAAA,GAAoB;AAC9B,IAAA,OAAO,IAAA,CAAK,YAAA;AAAA,EACd;AAAA,EAEA,WAAA,CAAY,cAAqC,OAAA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O,OAAA;AAAA,UAChB,YAAY,MAAA,CAAO,UAAA;AAAA,UACnB,aAAa,MAAA,CAAO,WAAA;AAAA,UACpB,QAAA,EAAW,OAAO,QAAA,IAAY;AAAA;AAChC;AACF,KACD,CAAA;AAED,IAAA,OAAO;AAAA,MACL,SAAA,EAAW,OAAO,CAAC,CAAA;AAAA,MACnB,WAAA,EAAa,OAAO,CAAC;AAAA,KACvB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,yBAAyB,MAAA,EAc5B;AACD,IAAA,MAAM,SAAA,GAAY,YAAA,CAAa,IAAA,CAAK,OAAO,CAAA;AAC3C,IAAA,MAAM,gBAAgB,SAAA,CAAU,eAAA;AAEhC,IAAA,IAAI,CAAC,aAAA,EAAe;AAClB,MAAA,MAAM,IAAI,MAAM,uDAAuD,CAAA;AAAA,IACzE;AAEA,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,MAAM,IAAA,CAAK,IAAI,gBAAA,CAAiB;AAAA,MACjD,OAAA,EAAS,aAAA;AAAA,MACT,GAAA,EAAK,WAAA;AAAA,MACL,YAAA,EAAc,wBAAA;AAAA,MACd,IAAA,EAAM;AAAA,QACJ;AAAA,UACE,SAAS,MAAA,CAAO,OAAA;AAAA,UAChB,YAAY,MAAA,CAAO,UAAA;AAAA,UACnB,aAAa,MAAA,CAAO,WAAA;AAAA,UACpB,QAAA,EAAW,OAAO,QAAA,IAAY;AAAA;AAChC;AACF,KACD,CAAA;AAED,IAAA,OAAO;AAAA,MACL,QAAA,EAAU,OAAO,CAAC,CAAA;AAAA,MAClB,WAAA,EAAa,OAAO,CAAC;AAAA,KACvB;AAAA,EACF;AACF","file":"chunk-IJEMEVGS.mjs","sourcesContent":["import {\n type Address,\n decodeAbiParameters,\n type Hex,\n type PublicClient,\n} from 'viem';\nimport { quoterV2Abi, uniswapV2Router02Abi, v4QuoterAbi } from '../../abis';\nimport { getAddresses } from '../../addresses';\nimport type { SupportedPublicClient } from '../../types';\n\n/**\n * Unified Quoter for getting price quotes across Uniswap V2, V3, and V4\n *\n * This class provides a unified interface for price discovery across all\n * supported Uniswap versions, abstracting away the differences between\n * V2 router, V3 quoter, and V4 quoter contracts.\n */\nexport class Quoter {\n private publicClient: SupportedPublicClient;\n private chainId: number;\n private get rpc(): PublicClient {\n return this.publicClient as PublicClient;\n }\n\n constructor(publicClient: SupportedPublicClient, chainId: number) {\n this.publicClient = publicClient;\n this.chainId = chainId;\n }\n\n /**\n * Get a price quote for swapping an exact amount of input tokens on Uniswap V3\n * @param params Parameters for the quote\n * @returns Quote result including output amount and price impact\n */\n async quoteExactInputV3(params: {\n tokenIn: Address;\n tokenOut: Address;\n amountIn: bigint;\n fee: number;\n sqrtPriceLimitX96?: bigint;\n }): Promise<{\n amountOut: bigint;\n sqrtPriceX96After: bigint;\n initializedTicksCrossed: number;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n\n try {\n const { result } = await this.rpc.simulateContract({\n address: addresses.v3Quoter,\n abi: quoterV2Abi,\n functionName: 'quoteExactInputSingle',\n args: [\n {\n tokenIn: params.tokenIn,\n tokenOut: params.tokenOut,\n amountIn: params.amountIn,\n fee: params.fee,\n sqrtPriceLimitX96: params.sqrtPriceLimitX96 ?? BigInt(0),\n },\n ],\n });\n return {\n amountOut: result[0],\n sqrtPriceX96After: result[1],\n initializedTicksCrossed: result[2],\n gasEstimate: result[3],\n };\n } catch (err: unknown) {\n const revertData: Hex | undefined =\n (err as { cause?: { data?: Hex }; data?: Hex })?.cause?.data ||\n (err as { data?: Hex }).data;\n if (\n revertData &&\n typeof revertData === 'string' &&\n revertData.startsWith('0x')\n ) {\n try {\n // Uniswap V3 QuoterV2 encodes (uint256 amount, uint160 sqrtPriceX96After, int24 tickAfter)\n const [amount, sqrtPriceX96After] = decodeAbiParameters(\n [{ type: 'uint256' }, { type: 'uint160' }, { type: 'int24' }],\n revertData as Hex,\n ) as unknown as [bigint, bigint, number];\n return {\n amountOut: amount,\n sqrtPriceX96After,\n initializedTicksCrossed: 0,\n gasEstimate: 0n,\n };\n } catch (_) {\n // fall through\n }\n }\n throw err;\n }\n }\n\n /**\n * Get a price quote for receiving an exact amount of output tokens on Uniswap V3\n * @param params Parameters for the quote\n * @returns Quote result including required input amount\n */\n async quoteExactOutputV3(params: {\n tokenIn: Address;\n tokenOut: Address;\n amountOut: bigint;\n fee: number;\n sqrtPriceLimitX96?: bigint;\n }): Promise<{\n amountIn: bigint;\n sqrtPriceX96After: bigint;\n initializedTicksCrossed: number;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n\n try {\n const { result } = await this.rpc.simulateContract({\n address: addresses.v3Quoter,\n abi: quoterV2Abi,\n functionName: 'quoteExactOutputSingle',\n args: [\n {\n tokenIn: params.tokenIn,\n tokenOut: params.tokenOut,\n amount: params.amountOut,\n fee: params.fee,\n sqrtPriceLimitX96: params.sqrtPriceLimitX96 ?? BigInt(0),\n },\n ],\n });\n return {\n amountIn: result[0],\n sqrtPriceX96After: result[1],\n initializedTicksCrossed: result[2],\n gasEstimate: result[3],\n };\n } catch (err: unknown) {\n const revertData: Hex | undefined =\n (err as { cause?: { data?: Hex }; data?: Hex })?.cause?.data ||\n (err as { data?: Hex }).data;\n if (\n revertData &&\n typeof revertData === 'string' &&\n revertData.startsWith('0x')\n ) {\n try {\n // Uniswap V3 QuoterV2 encodes (uint256 amount, uint160 sqrtPriceX96After, int24 tickAfter)\n const [amount, sqrtPriceX96After] = decodeAbiParameters(\n [{ type: 'uint256' }, { type: 'uint160' }, { type: 'int24' }],\n revertData as Hex,\n ) as unknown as [bigint, bigint, number];\n return {\n amountIn: amount,\n sqrtPriceX96After,\n initializedTicksCrossed: 0,\n gasEstimate: 0n,\n };\n } catch (_) {\n // fall through\n }\n }\n throw err;\n }\n }\n\n /**\n * Get a price quote for swapping an exact amount of input tokens on Uniswap V2\n * @param params Parameters for the quote\n * @returns Array of amounts for each step in the path\n */\n async quoteExactInputV2(params: {\n amountIn: bigint;\n path: Address[];\n }): Promise<bigint[]> {\n const addresses = getAddresses(this.chainId);\n\n if (!addresses.univ2Router02) {\n throw new Error('Uniswap V2 Router not available on this chain');\n }\n\n const result = await this.rpc.readContract({\n address: addresses.univ2Router02,\n abi: uniswapV2Router02Abi,\n functionName: 'getAmountsOut',\n args: [params.amountIn, params.path],\n });\n\n return [...result]; // Convert readonly array to mutable array\n }\n\n /**\n * Get a price quote for receiving an exact amount of output tokens on Uniswap V2\n * @param params Parameters for the quote\n * @returns Array of amounts for each step in the path\n */\n async quoteExactOutputV2(params: {\n amountOut: bigint;\n path: Address[];\n }): Promise<bigint[]> {\n const addresses = getAddresses(this.chainId);\n\n if (!addresses.univ2Router02) {\n throw new Error('Uniswap V2 Router not available on this chain');\n }\n\n const result = await this.rpc.readContract({\n address: addresses.univ2Router02,\n abi: uniswapV2Router02Abi,\n functionName: 'getAmountsIn',\n args: [params.amountOut, params.path],\n });\n\n return [...result]; // Convert readonly array to mutable array\n }\n\n /**\n * Get a price quote for swapping an exact amount of input tokens on Uniswap V4\n * @param params Parameters for the quote\n * @returns Quote result for V4 pools\n */\n async quoteExactInputV4(params: {\n poolKey: {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n };\n zeroForOne: boolean;\n exactAmount: bigint;\n hookData?: string;\n }): Promise<{\n amountOut: bigint;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n\n const quoterAddress = addresses.uniswapV4Quoter;\n\n if (!quoterAddress) {\n throw new Error('No V4 quoter available on this chain');\n }\n\n const { result } = await this.rpc.simulateContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: 'quoteExactInputSingle',\n args: [\n {\n poolKey: params.poolKey,\n zeroForOne: params.zeroForOne,\n exactAmount: params.exactAmount,\n hookData: (params.hookData ?? '0x') as `0x${string}`,\n },\n ],\n });\n\n return {\n amountOut: result[0],\n gasEstimate: result[1],\n };\n }\n\n /**\n * Get a price quote for receiving an exact amount of output tokens on Uniswap V4\n * @param params Parameters for the quote\n * @returns Quote result for V4 pools\n */\n async quoteExactOutputV4(params: {\n poolKey: {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n };\n zeroForOne: boolean;\n exactAmount: bigint;\n hookData?: string;\n }): Promise<{\n amountIn: bigint;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n\n // Use v4Quoter if available, otherwise use dopplerLens (they're the same contract)\n const quoterAddress = addresses.dopplerLens;\n\n if (!quoterAddress) {\n throw new Error('No V4 quoter available on this chain');\n }\n\n const { result } = await this.rpc.simulateContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: 'quoteExactOutputSingle',\n args: [\n {\n poolKey: params.poolKey,\n zeroForOne: params.zeroForOne,\n exactAmount: params.exactAmount,\n hookData: (params.hookData ?? '0x') as `0x${string}`,\n },\n ],\n });\n\n return {\n amountIn: result[0],\n gasEstimate: result[1],\n };\n }\n\n /**\n * Quote a single exact-input trade using the Uniswap V4 Quoter (not Lens)\n * @param params Parameters for the quote\n */\n async quoteExactInputV4Quoter(params: {\n poolKey: {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n };\n zeroForOne: boolean;\n exactAmount: bigint;\n hookData?: string;\n }): Promise<{\n amountOut: bigint;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n const quoterAddress = addresses.uniswapV4Quoter;\n\n if (!quoterAddress) {\n throw new Error('Uniswap V4 Quoter address not available on this chain');\n }\n\n const { result } = await this.rpc.simulateContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: 'quoteExactInputSingle',\n args: [\n {\n poolKey: params.poolKey,\n zeroForOne: params.zeroForOne,\n exactAmount: params.exactAmount,\n hookData: (params.hookData ?? '0x') as `0x${string}`,\n },\n ],\n });\n\n return {\n amountOut: result[0],\n gasEstimate: result[1],\n };\n }\n\n /**\n * Quote a single exact-output trade using the Uniswap V4 Quoter (not Lens)\n * @param params Parameters for the quote\n */\n async quoteExactOutputV4Quoter(params: {\n poolKey: {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n };\n zeroForOne: boolean;\n exactAmount: bigint;\n hookData?: string;\n }): Promise<{\n amountIn: bigint;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n const quoterAddress = addresses.uniswapV4Quoter;\n\n if (!quoterAddress) {\n throw new Error('Uniswap V4 Quoter address not available on this chain');\n }\n\n const { result } = await this.rpc.simulateContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: 'quoteExactOutputSingle',\n args: [\n {\n poolKey: params.poolKey,\n zeroForOne: params.zeroForOne,\n exactAmount: params.exactAmount,\n hookData: (params.hookData ?? '0x') as `0x${string}`,\n },\n ],\n });\n\n return {\n amountIn: result[0],\n gasEstimate: result[1],\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/entities/quoter/Quoter.ts"],"names":[],"mappings":";;;;AAiBO,IAAM,SAAN,MAAa;AAAA,EAGlB,IAAY,GAAA,GAAoB;AAC9B,IAAA,OAAO,IAAA,CAAK,YAAA;AAAA,EACd;AAAA,EAEA,WAAA,CAAY,cAAqC,OAAA,EAAiB;AAChE,IAAA,IAAA,CAAK,YAAA,GAAe,YAAA;AACpB,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,kBAAkB,MAAA,EAWrB;AACD,IAAA,MAAM,SAAA,GAAY,YAAA,CAAa,IAAA,CAAK,OAAO,CAAA;AAE3C,IAAA,IAAI;AACF,MAAA,MAAM,EAAE,MAAA,EAAO,GAAI,MAAM,IAAA,CAAK,IAAI,gBAAA,CAAiB;AAAA,QACjD,SAAS,SAAA,CAAU,QAAA;AAAA,QACnB,GAAA,EAAK,WAAA;AAAA,QACL,YAAA,EAAc,uBAAA;AAAA,QACd,IAAA,EAA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IAAI,CAAC,aAAA,EAAe;AAClB,MAAA,MAAM,IAAI,MAAM,uDAAuD,CAAA;AAAA,IACzE;AAEA,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,MAAM,IAAA,CAAK,IAAI,gBAAA,CAAiB;AAAA,MACjD,OAAA,EAAS,aAAA;AAAA,MACT,GAAA,EAAK,WAAA;AAAA,MACL,YAAA,EAAc,wBAAA;AAAA,MACd,IAAA,EAAM;AAAA,QACJ;AAAA,UACE,SAAS,MAAA,CAAO,OAAA;AAAA,UAChB,YAAY,MAAA,CAAO,UAAA;AAAA,UACnB,aAAa,MAAA,CAAO,WAAA;AAAA,UACpB,QAAA,EAAW,OAAO,QAAA,IAAY;AAAA;AAChC;AACF,KACD,CAAA;AAED,IAAA,OAAO;AAAA,MACL,QAAA,EAAU,OAAO,CAAC,CAAA;AAAA,MAClB,WAAA,EAAa,OAAO,CAAC;AAAA,KACvB;AAAA,EACF;AACF","file":"chunk-4LNXE5DF.mjs","sourcesContent":["import {\n type Address,\n decodeAbiParameters,\n type Hex,\n type PublicClient,\n} from 'viem';\nimport { quoterV2Abi, uniswapV2Router02Abi, v4QuoterAbi } from '../../abis';\nimport { getAddresses } from '../../addresses';\nimport type { SupportedPublicClient } from '../../types';\n\n/**\n * Unified Quoter for getting price quotes across Uniswap V2, V3, and V4\n *\n * This class provides a unified interface for price discovery across all\n * supported Uniswap versions, abstracting away the differences between\n * V2 router, V3 quoter, and V4 quoter contracts.\n */\nexport class Quoter {\n private publicClient: SupportedPublicClient;\n private chainId: number;\n private get rpc(): PublicClient {\n return this.publicClient as PublicClient;\n }\n\n constructor(publicClient: SupportedPublicClient, chainId: number) {\n this.publicClient = publicClient;\n this.chainId = chainId;\n }\n\n /**\n * Get a price quote for swapping an exact amount of input tokens on Uniswap V3\n * @param params Parameters for the quote\n * @returns Quote result including output amount and price impact\n */\n async quoteExactInputV3(params: {\n tokenIn: Address;\n tokenOut: Address;\n amountIn: bigint;\n fee: number;\n sqrtPriceLimitX96?: bigint;\n }): Promise<{\n amountOut: bigint;\n sqrtPriceX96After: bigint;\n initializedTicksCrossed: number;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n\n try {\n const { result } = await this.rpc.simulateContract({\n address: addresses.v3Quoter,\n abi: quoterV2Abi,\n functionName: 'quoteExactInputSingle',\n args: [\n {\n tokenIn: params.tokenIn,\n tokenOut: params.tokenOut,\n amountIn: params.amountIn,\n fee: params.fee,\n sqrtPriceLimitX96: params.sqrtPriceLimitX96 ?? BigInt(0),\n },\n ],\n });\n return {\n amountOut: result[0],\n sqrtPriceX96After: result[1],\n initializedTicksCrossed: result[2],\n gasEstimate: result[3],\n };\n } catch (err: unknown) {\n const revertData: Hex | undefined =\n (err as { cause?: { data?: Hex }; data?: Hex })?.cause?.data ||\n (err as { data?: Hex }).data;\n if (\n revertData &&\n typeof revertData === 'string' &&\n revertData.startsWith('0x')\n ) {\n try {\n // Uniswap V3 QuoterV2 encodes (uint256 amount, uint160 sqrtPriceX96After, int24 tickAfter)\n const [amount, sqrtPriceX96After] = decodeAbiParameters(\n [{ type: 'uint256' }, { type: 'uint160' }, { type: 'int24' }],\n revertData as Hex,\n ) as unknown as [bigint, bigint, number];\n return {\n amountOut: amount,\n sqrtPriceX96After,\n initializedTicksCrossed: 0,\n gasEstimate: 0n,\n };\n } catch (_) {\n // fall through\n }\n }\n throw err;\n }\n }\n\n /**\n * Get a price quote for receiving an exact amount of output tokens on Uniswap V3\n * @param params Parameters for the quote\n * @returns Quote result including required input amount\n */\n async quoteExactOutputV3(params: {\n tokenIn: Address;\n tokenOut: Address;\n amountOut: bigint;\n fee: number;\n sqrtPriceLimitX96?: bigint;\n }): Promise<{\n amountIn: bigint;\n sqrtPriceX96After: bigint;\n initializedTicksCrossed: number;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n\n try {\n const { result } = await this.rpc.simulateContract({\n address: addresses.v3Quoter,\n abi: quoterV2Abi,\n functionName: 'quoteExactOutputSingle',\n args: [\n {\n tokenIn: params.tokenIn,\n tokenOut: params.tokenOut,\n amount: params.amountOut,\n fee: params.fee,\n sqrtPriceLimitX96: params.sqrtPriceLimitX96 ?? BigInt(0),\n },\n ],\n });\n return {\n amountIn: result[0],\n sqrtPriceX96After: result[1],\n initializedTicksCrossed: result[2],\n gasEstimate: result[3],\n };\n } catch (err: unknown) {\n const revertData: Hex | undefined =\n (err as { cause?: { data?: Hex }; data?: Hex })?.cause?.data ||\n (err as { data?: Hex }).data;\n if (\n revertData &&\n typeof revertData === 'string' &&\n revertData.startsWith('0x')\n ) {\n try {\n // Uniswap V3 QuoterV2 encodes (uint256 amount, uint160 sqrtPriceX96After, int24 tickAfter)\n const [amount, sqrtPriceX96After] = decodeAbiParameters(\n [{ type: 'uint256' }, { type: 'uint160' }, { type: 'int24' }],\n revertData as Hex,\n ) as unknown as [bigint, bigint, number];\n return {\n amountIn: amount,\n sqrtPriceX96After,\n initializedTicksCrossed: 0,\n gasEstimate: 0n,\n };\n } catch (_) {\n // fall through\n }\n }\n throw err;\n }\n }\n\n /**\n * Get a price quote for swapping an exact amount of input tokens on Uniswap V2\n * @param params Parameters for the quote\n * @returns Array of amounts for each step in the path\n */\n async quoteExactInputV2(params: {\n amountIn: bigint;\n path: Address[];\n }): Promise<bigint[]> {\n const addresses = getAddresses(this.chainId);\n\n if (!addresses.univ2Router02) {\n throw new Error('Uniswap V2 Router not available on this chain');\n }\n\n const result = await this.rpc.readContract({\n address: addresses.univ2Router02,\n abi: uniswapV2Router02Abi,\n functionName: 'getAmountsOut',\n args: [params.amountIn, params.path],\n });\n\n return [...result]; // Convert readonly array to mutable array\n }\n\n /**\n * Get a price quote for receiving an exact amount of output tokens on Uniswap V2\n * @param params Parameters for the quote\n * @returns Array of amounts for each step in the path\n */\n async quoteExactOutputV2(params: {\n amountOut: bigint;\n path: Address[];\n }): Promise<bigint[]> {\n const addresses = getAddresses(this.chainId);\n\n if (!addresses.univ2Router02) {\n throw new Error('Uniswap V2 Router not available on this chain');\n }\n\n const result = await this.rpc.readContract({\n address: addresses.univ2Router02,\n abi: uniswapV2Router02Abi,\n functionName: 'getAmountsIn',\n args: [params.amountOut, params.path],\n });\n\n return [...result]; // Convert readonly array to mutable array\n }\n\n /**\n * Get a price quote for swapping an exact amount of input tokens on Uniswap V4\n * @param params Parameters for the quote\n * @returns Quote result for V4 pools\n */\n async quoteExactInputV4(params: {\n poolKey: {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n };\n zeroForOne: boolean;\n exactAmount: bigint;\n hookData?: string;\n }): Promise<{\n amountOut: bigint;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n\n const quoterAddress = addresses.uniswapV4Quoter;\n\n if (!quoterAddress) {\n throw new Error('No V4 quoter available on this chain');\n }\n\n const { result } = await this.rpc.simulateContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: 'quoteExactInputSingle',\n args: [\n {\n poolKey: params.poolKey,\n zeroForOne: params.zeroForOne,\n exactAmount: params.exactAmount,\n hookData: (params.hookData ?? '0x') as `0x${string}`,\n },\n ],\n });\n\n return {\n amountOut: result[0],\n gasEstimate: result[1],\n };\n }\n\n /**\n * Get a price quote for receiving an exact amount of output tokens on Uniswap V4\n * @param params Parameters for the quote\n * @returns Quote result for V4 pools\n */\n async quoteExactOutputV4(params: {\n poolKey: {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n };\n zeroForOne: boolean;\n exactAmount: bigint;\n hookData?: string;\n }): Promise<{\n amountIn: bigint;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n\n // Use v4Quoter if available, otherwise use dopplerLens (they're the same contract)\n const quoterAddress = addresses.dopplerLens;\n\n if (!quoterAddress) {\n throw new Error('No V4 quoter available on this chain');\n }\n\n const { result } = await this.rpc.simulateContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: 'quoteExactOutputSingle',\n args: [\n {\n poolKey: params.poolKey,\n zeroForOne: params.zeroForOne,\n exactAmount: params.exactAmount,\n hookData: (params.hookData ?? '0x') as `0x${string}`,\n },\n ],\n });\n\n return {\n amountIn: result[0],\n gasEstimate: result[1],\n };\n }\n\n /**\n * Quote a single exact-input trade using the Uniswap V4 Quoter (not Lens)\n * @param params Parameters for the quote\n */\n async quoteExactInputV4Quoter(params: {\n poolKey: {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n };\n zeroForOne: boolean;\n exactAmount: bigint;\n hookData?: string;\n }): Promise<{\n amountOut: bigint;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n const quoterAddress = addresses.uniswapV4Quoter;\n\n if (!quoterAddress) {\n throw new Error('Uniswap V4 Quoter address not available on this chain');\n }\n\n const { result } = await this.rpc.simulateContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: 'quoteExactInputSingle',\n args: [\n {\n poolKey: params.poolKey,\n zeroForOne: params.zeroForOne,\n exactAmount: params.exactAmount,\n hookData: (params.hookData ?? '0x') as `0x${string}`,\n },\n ],\n });\n\n return {\n amountOut: result[0],\n gasEstimate: result[1],\n };\n }\n\n /**\n * Quote a single exact-output trade using the Uniswap V4 Quoter (not Lens)\n * @param params Parameters for the quote\n */\n async quoteExactOutputV4Quoter(params: {\n poolKey: {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n };\n zeroForOne: boolean;\n exactAmount: bigint;\n hookData?: string;\n }): Promise<{\n amountIn: bigint;\n gasEstimate: bigint;\n }> {\n const addresses = getAddresses(this.chainId);\n const quoterAddress = addresses.uniswapV4Quoter;\n\n if (!quoterAddress) {\n throw new Error('Uniswap V4 Quoter address not available on this chain');\n }\n\n const { result } = await this.rpc.simulateContract({\n address: quoterAddress,\n abi: v4QuoterAbi,\n functionName: 'quoteExactOutputSingle',\n args: [\n {\n poolKey: params.poolKey,\n zeroForOne: params.zeroForOne,\n exactAmount: params.exactAmount,\n hookData: (params.hookData ?? '0x') as `0x${string}`,\n },\n ],\n });\n\n return {\n amountIn: result[0],\n gasEstimate: result[1],\n };\n }\n}\n"]}
|
|
@@ -24,6 +24,7 @@ var VALID_FEE_TIERS = [
|
|
|
24
24
|
];
|
|
25
25
|
var V3_FEE_TIERS = VALID_FEE_TIERS;
|
|
26
26
|
var V4_MAX_FEE = 1e5;
|
|
27
|
+
var DECAY_MAX_START_FEE = 8e5;
|
|
27
28
|
var TICK_SPACINGS = {
|
|
28
29
|
100: 1,
|
|
29
30
|
500: 10,
|
|
@@ -95,6 +96,7 @@ var DYNAMIC_AUCTION_VALID_FEES = [100, 500, 3e3, 1e4];
|
|
|
95
96
|
exports.BASIS_POINTS = BASIS_POINTS;
|
|
96
97
|
exports.DAY_SECONDS = DAY_SECONDS;
|
|
97
98
|
exports.DEAD_ADDRESS = DEAD_ADDRESS;
|
|
99
|
+
exports.DECAY_MAX_START_FEE = DECAY_MAX_START_FEE;
|
|
98
100
|
exports.DEFAULT_AUCTION_DURATION = DEFAULT_AUCTION_DURATION;
|
|
99
101
|
exports.DEFAULT_CREATE_GAS_LIMIT = DEFAULT_CREATE_GAS_LIMIT;
|
|
100
102
|
exports.DEFAULT_EPOCH_LENGTH = DEFAULT_EPOCH_LENGTH;
|
|
@@ -138,5 +140,5 @@ exports.V4_MAX_FEE = V4_MAX_FEE;
|
|
|
138
140
|
exports.VALID_FEE_TIERS = VALID_FEE_TIERS;
|
|
139
141
|
exports.WAD = WAD;
|
|
140
142
|
exports.ZERO_ADDRESS = ZERO_ADDRESS;
|
|
141
|
-
//# sourceMappingURL=chunk-
|
|
142
|
-
//# sourceMappingURL=chunk-
|
|
143
|
+
//# sourceMappingURL=chunk-6BQY5EPB.js.map
|
|
144
|
+
//# sourceMappingURL=chunk-6BQY5EPB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"names":["parseEther"],"mappings":";;;;;AAGO,I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,MAAM;AAGzD,IAAM,+BAAA,GAAkC;AACxC,IAAM,gCAAA,GAAmC;AACzC,IAAM,qCAAA,GAAwC;AAC9C,IAAM,2BAAA,GAA8BA,gBAAW,MAAM;AAKrD,IAAM,8BAAA,GAAiC;AAAA,EAC5C,OAAA;AAAA,EAAU,OAAA;AAAA,EAAU;AACtB;AACO,IAAM,8BAAA,GAAiC;AAAA,EAC5C,OAAA;AAAA,EAAU,OAAA;AAAA,EAAU;AACtB;AACO,IAAM,gCAAA,GAAmC,CAAC,EAAA,EAAI,EAAA,EAAI,EAAE;AACpD,IAAM,oCAAA,GAAuC;AAAA,EAClDA,gBAAW,MAAM,CAAA;AAAA;AAAA,EACjBA,gBAAW,OAAO,CAAA;AAAA;AAAA,EAClBA,gBAAW,KAAK;AAAA;AAClB;AAGO,IAAM,cAAA,GAAiB;AACvB,IAAM,cAAA,GACX;AAGK,IAAM,YAAA,GAAe;AAGrB,IAAM,SAAA,GAAY,OAAO,KAAM;AAC/B,IAAM,aAAA,GAAgB,MAAA;AAAA,EAC1B,CAAA,IAAK,EAAA;AAAA,EACH,CAAA,IAAK,EAAA;AAAA,EACL,CAAA,IAAK,EAAA;AAAA,EACL,CAAA,IAAK,CAAA;AAAA,EACL,CAAA,IAAK,CAAA;AAAA,EACL,CAAA,IAAK;AAAA;AACV;AAGO,IAAM,gBAAA,GAAmB;AACzB,IAAM,eAAA,GAAkB;AAOxB,IAAM,0BAAA,GAA6B,CAAC,GAAA,EAAK,GAAA,EAAK,KAAM,GAAK","file":"chunk-6BQY5EPB.js","sourcesContent":["import { Address, parseEther } from 'viem';\n\n// Common constants\nexport const WAD = 10n ** 18n;\nexport const DEAD_ADDRESS =\n '0x000000000000000000000000000000000000dEaD' as Address;\nexport const ZERO_ADDRESS =\n '0x0000000000000000000000000000000000000000' as Address;\n\n// =============================================================================\n// Fee Tiers - V3 vs V4 Distinction\n// =============================================================================\n//\n// Uniswap V3 (Static Auctions): Fees are COUPLED to tick spacings. Only 4 tiers allowed.\n// Uniswap V4 (Dynamic/Multicurve): Fees are DECOUPLED. Any fee 0-100,000 is valid.\n//\n// The standard fee tiers below are recognized by both V3 and V4, but V4 pools\n// can use ANY fee value as long as you provide an explicit tickSpacing.\n\n/** Standard fee tiers recognized by both Uniswap V3 and V4 */\nexport const FEE_TIERS = {\n LOWEST: 100, // 0.01%\n LOW: 500, // 0.05%\n MEDIUM: 3000, // 0.30%\n HIGH: 10000, // 1.00%\n} as const;\n\n/** Valid fee tier values (100, 500, 3000, 10000) */\nexport type FeeTier = (typeof FEE_TIERS)[keyof typeof FEE_TIERS];\n\n/**\n * Standard fee tiers - REQUIRED for V3 (Static Auctions).\n * V4 pools can use custom fees but these are the recommended defaults.\n */\nexport const VALID_FEE_TIERS: readonly FeeTier[] = [\n 100, 500, 3000, 10000,\n] as const;\n\n/**\n * V3 fee tiers - These are the ONLY valid fees for Uniswap V3 pools.\n * Static Auctions use V3 and must use one of these tiers.\n */\nexport const V3_FEE_TIERS = VALID_FEE_TIERS;\n\n/**\n * Maximum LP fee for V4 pools (from DopplerHookInitializer.sol).\n * V4 pools can use any fee from 0 to this value.\n * @see DopplerHookInitializer.sol line 171: `uint24 constant MAX_LP_FEE = 100_000`\n */\nexport const V4_MAX_FEE = 100_000; // 10%\n\n/**\n * Maximum allowed start fee for decay multicurve schedules.\n * This is intentionally higher than V4_MAX_FEE to support anti-sniping launches.\n * 800_000 = 80%\n */\nexport const DECAY_MAX_START_FEE = 800_000; // 80%\n\n// Tick spacings for different fee tiers (standard Uniswap V3 mapping)\n// In V4, tickSpacing is independent of fee - you can use any combination\nexport const TICK_SPACINGS = {\n 100: 1,\n 500: 10,\n 3000: 60,\n 10000: 200,\n} as const;\n\n/**\n * Maximum tick spacing allowed by Doppler.sol for dynamic (Dutch) auctions.\n * @see Doppler.sol line 159: `int24 constant MAX_TICK_SPACING = 30`\n */\nexport const DOPPLER_MAX_TICK_SPACING = 30;\n\n// Time constants\nexport const SECONDS_PER_DAY = 86400;\nexport const SECONDS_PER_YEAR = 365 * SECONDS_PER_DAY;\n\n// Default values\nexport const DEFAULT_EPOCH_LENGTH = 43200; // 12 hours in seconds (matching V4 SDK)\nexport const DEFAULT_AUCTION_DURATION = 7 * SECONDS_PER_DAY; // 7 days\nexport const DEFAULT_LOCK_DURATION = SECONDS_PER_YEAR; // 1 year\nexport const DEFAULT_PD_SLUGS = 5; // Default price discovery slugs\nexport const DAY_SECONDS = SECONDS_PER_DAY; // Alias for consistency\n\n// Default gas limit to fall back on when create() simulations do not return a value\nexport const DEFAULT_CREATE_GAS_LIMIT = 13_500_000n;\n\n// V3 Default parameters\nexport const DEFAULT_V3_START_TICK = 175000;\nexport const DEFAULT_V3_END_TICK = 225000;\nexport const DEFAULT_V3_NUM_POSITIONS = 15;\nexport const DEFAULT_V3_FEE = 10000; // 1% fee tier\nexport const DEFAULT_V3_INITIAL_VOTING_DELAY = 172800; // 2 days\nexport const DEFAULT_V3_INITIAL_VOTING_PERIOD = 1209600; // 14 days\nexport const DEFAULT_V3_INITIAL_PROPOSAL_THRESHOLD = 0n;\nexport const DEFAULT_V3_VESTING_DURATION = BigInt(SECONDS_PER_YEAR);\nexport const DEFAULT_V3_INITIAL_SUPPLY = parseEther('1000000000'); // 1 billion tokens\nexport const DEFAULT_V3_NUM_TOKENS_TO_SELL = parseEther('900000000'); // 900 million tokens\nexport const DEFAULT_V3_YEARLY_MINT_RATE = parseEther('0.02'); // 2% yearly mint rate\nexport const DEFAULT_V3_PRE_MINT = parseEther('9000000'); // 9 million tokens (0.9%)\nexport const DEFAULT_V3_MAX_SHARE_TO_BE_SOLD = parseEther('0.35'); // 35%\n\n// V4 Default parameters\nexport const DEFAULT_V4_INITIAL_VOTING_DELAY = 7200; // 2 hours\nexport const DEFAULT_V4_INITIAL_VOTING_PERIOD = 50400; // 14 hours\nexport const DEFAULT_V4_INITIAL_PROPOSAL_THRESHOLD = 0n;\nexport const DEFAULT_V4_YEARLY_MINT_RATE = parseEther('0.02'); // 2% yearly mint rate\n\n// V4 Multicurve Default Tick Ranges\n// Based on market cap tiers: LOW ($7.5k -> $30k), MEDIUM ($50k -> $150k), HIGH ($250k -> $750k)\n// Calculated for 1B token supply, $4500 numeraire (e.g., WETH on Base)\nexport const DEFAULT_MULTICURVE_LOWER_TICKS = [\n -202_100, -183_100, -167_000,\n] as const;\nexport const DEFAULT_MULTICURVE_UPPER_TICKS = [\n -188_200, -172_100, -156_000,\n] as const;\nexport const DEFAULT_MULTICURVE_NUM_POSITIONS = [11, 11, 11] as const;\nexport const DEFAULT_MULTICURVE_MAX_SUPPLY_SHARES = [\n parseEther('0.05'), // 5% for LOW tier\n parseEther('0.125'), // 12.5% for MEDIUM tier\n parseEther('0.2'), // 20% for HIGH tier\n] as const;\n\n// Price bounds\nexport const MIN_SQRT_RATIO = 4295128739n;\nexport const MAX_SQRT_RATIO =\n 1461446703485210103287273052203988822378723970342n;\n\n// Basis points\nexport const BASIS_POINTS = 10000;\n\n// V4 Hook Flags for Doppler\nexport const FLAG_MASK = BigInt(0x3fff);\nexport const DOPPLER_FLAGS = BigInt(\n (1 << 13) | // BEFORE_INITIALIZE_FLAG\n (1 << 12) | // AFTER_INITIALIZE_FLAG\n (1 << 11) | // BEFORE_ADD_LIQUIDITY_FLAG\n (1 << 7) | // BEFORE_SWAP_FLAG\n (1 << 6) | // AFTER_SWAP_FLAG\n (1 << 5), // BEFORE_DONATE_FLAG\n);\n\n// V4 Dynamic Fee Flag\nexport const DYNAMIC_FEE_FLAG = 0x800000; // 8388608 in decimal\nexport const FEE_AMOUNT_MASK = 0xffffff; // Mask to extract actual fee from dynamic fee\n\n/**\n * @deprecated Dynamic auctions (V4) support ANY fee 0-100,000 with explicit tickSpacing.\n * This constant is kept for backwards compatibility but is no longer enforced.\n * Standard fee tiers still auto-derive tickSpacing; custom fees require explicit tickSpacing.\n */\nexport const DYNAMIC_AUCTION_VALID_FEES = [100, 500, 3000, 10000] as const;\n"]}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkJHPDKSC4_js = require('./chunk-JHPDKSC4.js');
|
|
4
4
|
|
|
5
5
|
// src/types.ts
|
|
6
6
|
var NO_OP_ENABLED_CHAIN_IDS = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
chunkJHPDKSC4_js.CHAIN_IDS.BASE,
|
|
8
|
+
chunkJHPDKSC4_js.CHAIN_IDS.BASE_SEPOLIA,
|
|
9
|
+
chunkJHPDKSC4_js.CHAIN_IDS.UNICHAIN,
|
|
10
|
+
chunkJHPDKSC4_js.CHAIN_IDS.UNICHAIN_SEPOLIA,
|
|
11
|
+
chunkJHPDKSC4_js.CHAIN_IDS.MONAD_TESTNET,
|
|
12
|
+
chunkJHPDKSC4_js.CHAIN_IDS.MONAD_MAINNET
|
|
13
13
|
];
|
|
14
14
|
function isNoOpEnabledChain(chainId) {
|
|
15
15
|
return NO_OP_ENABLED_CHAIN_IDS.includes(chainId);
|
|
16
16
|
}
|
|
17
17
|
var LAUNCHPAD_ENABLED_CHAIN_IDS = [
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
chunkJHPDKSC4_js.CHAIN_IDS.BASE,
|
|
19
|
+
chunkJHPDKSC4_js.CHAIN_IDS.MONAD_MAINNET
|
|
20
20
|
];
|
|
21
21
|
function isLaunchpadEnabledChain(chainId) {
|
|
22
22
|
return LAUNCHPAD_ENABLED_CHAIN_IDS.includes(chainId);
|
|
@@ -34,5 +34,5 @@ exports.LockablePoolStatus = LockablePoolStatus;
|
|
|
34
34
|
exports.NO_OP_ENABLED_CHAIN_IDS = NO_OP_ENABLED_CHAIN_IDS;
|
|
35
35
|
exports.isLaunchpadEnabledChain = isLaunchpadEnabledChain;
|
|
36
36
|
exports.isNoOpEnabledChain = isNoOpEnabledChain;
|
|
37
|
-
//# sourceMappingURL=chunk-
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
37
|
+
//# sourceMappingURL=chunk-AS5UUJRI.js.map
|
|
38
|
+
//# sourceMappingURL=chunk-AS5UUJRI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"names":["CHAIN_IDS","LockablePoolStatus"],"mappings":";;;;;AA0EO,IAAM,uBAAA,GAA0B;AAAA,EACrCA,0BAAA,CAAU,IAAA;AAAA,EACVA,0BAAA,CAAU,YAAA;AAAA,EACVA,0BAAA,CAAU,QAAA;AAAA,EACVA,0BAAA,CAAU,gBAAA;AAAA,EACVA,0BAAA,CAAU,aAAA;AAAA,EACVA,0BAAA,CAAU;AACZ;AAOO,SAAS,mBACd,OAAA,EAC+B;AAC/B,EAAA,OAAQ,uBAAA,CAA8C,SAAS,OAAO,CAAA;AACxE;AAGO,IAAM,2BAAA,GAA8B;AAAA,EACzCA,0BAAA,CAAU,IAAA;AAAA,EACVA,0BAAA,CAAU;AACZ;AAQO,SAAS,wBACd,OAAA,EACoC;AACpC,EAAA,OAAQ,2BAAA,CAAkD,SAAS,OAAO,CAAA;AAC5E;AA8BO,IAAK,kBAAA,qBAAAC,mBAAAA,KAAL;AACL,EAAAA,mBAAAA,CAAAA,mBAAAA,CAAA,mBAAgB,CAAA,CAAA,GAAhB,eAAA;AACA,EAAAA,mBAAAA,CAAAA,mBAAAA,CAAA,iBAAc,CAAA,CAAA,GAAd,aAAA;AACA,EAAAA,mBAAAA,CAAAA,mBAAAA,CAAA,YAAS,CAAA,CAAA,GAAT,QAAA;AACA,EAAAA,mBAAAA,CAAAA,mBAAAA,CAAA,YAAS,CAAA,CAAA,GAAT,QAAA;AAJU,EAAA,OAAAA,mBAAAA;AAAA,CAAA,EAAA,kBAAA,IAAA,EAAA","file":"chunk-27TY7K5D.js","sourcesContent":["import { base, baseSepolia, ink, unichain } from 'viem/chains';\nimport { CHAIN_IDS, type SupportedChainId } from './addresses';\n// Re-export SupportedChainId so consumers can import from this module\nexport { type SupportedChainId } from './addresses';\nimport type { Address, WalletClient } from 'viem';\n\nexport type SupportedChain =\n | typeof base\n | typeof baseSepolia\n | typeof ink\n | typeof unichain\n | typeof baseSepolia;\n// Use a wide type to avoid cross-package viem type identity issues when linking packages locally.\nexport type SupportedPublicClient = unknown;\n\n// Core configuration types\n// Token configuration (discriminated union)\nexport interface StandardTokenConfig {\n type?: 'standard'; // default behavior (backwards compatible)\n name: string;\n symbol: string;\n tokenURI: string;\n yearlyMintRate?: bigint; // Optional yearly mint rate (in WAD, default: 2% = 0.02e18)\n}\n\nexport interface Doppler404TokenConfig {\n type: 'doppler404';\n name: string;\n symbol: string;\n baseURI: string;\n // Optional unit for DN404 factory (uint256). Defaults to 1000 when omitted.\n unit?: bigint;\n}\n\nexport type TokenConfig = StandardTokenConfig | Doppler404TokenConfig;\n\nexport interface SaleConfig {\n initialSupply: bigint;\n numTokensToSell: bigint;\n numeraire: Address; // e.g., WETH address\n}\n\n// Static Auction Pool configuration\nexport interface StaticPoolConfig {\n startTick: number;\n endTick: number;\n fee: number; // e.g., 3000 for 0.3%\n // Optional parameters for lockable initializer\n numPositions?: number; // Number of liquidity positions (default: based on tick range)\n maxShareToBeSold?: bigint; // Maximum share of tokens to sell (in WAD, default: 1e18 = 100%)\n beneficiaries?: BeneficiaryData[]; // Optional beneficiaries for fee streaming\n}\n\n// Dynamic Auction configuration\nexport interface DynamicAuctionConfig {\n duration: number; // in seconds\n epochLength: number; // in seconds\n startTick: number;\n endTick: number;\n gamma?: number; // Optional, can be auto-calculated\n minProceeds: bigint;\n maxProceeds: bigint;\n numPdSlugs?: number; // Price discovery slugs (optional)\n}\n\n// Vesting configuration\nexport interface VestingConfig {\n duration: number; // in seconds\n cliffDuration: number; // in seconds\n recipients?: Address[]; // Optional array of recipient addresses (defaults to [userAddress] if not specified)\n amounts?: bigint[]; // Optional array of vesting amounts per recipient (must match recipients length if provided)\n}\n\n// Chains where no-op governance is enabled\nexport const NO_OP_ENABLED_CHAIN_IDS = [\n CHAIN_IDS.BASE,\n CHAIN_IDS.BASE_SEPOLIA,\n CHAIN_IDS.UNICHAIN,\n CHAIN_IDS.UNICHAIN_SEPOLIA,\n CHAIN_IDS.MONAD_TESTNET,\n CHAIN_IDS.MONAD_MAINNET,\n] as const;\n\nexport type NoOpEnabledChainId = (typeof NO_OP_ENABLED_CHAIN_IDS)[number];\n\n/**\n * Check if a chain supports no-op governance\n */\nexport function isNoOpEnabledChain(\n chainId: number,\n): chainId is NoOpEnabledChainId {\n return (NO_OP_ENABLED_CHAIN_IDS as readonly number[]).includes(chainId);\n}\n\n// Chains where launchpad governance is enabled\nexport const LAUNCHPAD_ENABLED_CHAIN_IDS = [\n CHAIN_IDS.BASE,\n CHAIN_IDS.MONAD_MAINNET,\n] as const;\n\nexport type LaunchpadEnabledChainId =\n (typeof LAUNCHPAD_ENABLED_CHAIN_IDS)[number];\n\n/**\n * Check if a chain supports launchpad governance\n */\nexport function isLaunchpadEnabledChain(\n chainId: number,\n): chainId is LaunchpadEnabledChainId {\n return (LAUNCHPAD_ENABLED_CHAIN_IDS as readonly number[]).includes(chainId);\n}\n\n// Governance configuration (discriminated union)\nexport type GovernanceDefault = { type: 'default' };\nexport interface GovernanceCustom {\n type: 'custom';\n initialVotingDelay: number;\n initialVotingPeriod: number;\n initialProposalThreshold: bigint;\n}\nexport type GovernanceNoOp = { type: 'noOp' };\nexport interface GovernanceLaunchpad {\n type: 'launchpad';\n multisig: Address;\n}\n\nexport type GovernanceOption<C extends SupportedChainId> =\n | GovernanceDefault\n | GovernanceCustom\n | (C extends NoOpEnabledChainId ? GovernanceNoOp : never)\n | (C extends LaunchpadEnabledChainId ? GovernanceLaunchpad : never);\n\n// Unified beneficiary data used for fee streaming, lockable initializers, and migration configs\n// Uses shares in WAD format (1e18 = 100%) for consistency across all beneficiary configurations\nexport interface BeneficiaryData {\n beneficiary: Address;\n shares: bigint; // shares in WAD (1e18 = 100%)\n}\n\n// Pool status for lockable initializer\nexport enum LockablePoolStatus {\n Uninitialized = 0,\n Initialized = 1,\n Locked = 2,\n Exited = 3,\n}\n\n// Lockable pool state\nexport interface LockablePoolState {\n asset: Address;\n numeraire: Address;\n tickLower: number;\n tickUpper: number;\n maxShareToBeSold: bigint;\n totalTokensOnBondingCurve: bigint;\n status: LockablePoolStatus;\n}\n\n// Multicurve pool state (V4 initializer)\nexport interface MulticurvePoolState {\n asset: Address;\n numeraire: Address;\n fee: number;\n tickSpacing: number;\n status: LockablePoolStatus; // Reuses the same enum\n poolKey: V4PoolKey;\n farTick: number;\n}\n\n// Migration configuration (discriminated union)\nexport type MigrationConfig =\n | { type: 'uniswapV2' } // Basic migration to a new Uniswap v2 pool\n | {\n type: 'uniswapV4';\n fee: number;\n tickSpacing: number;\n // Configuration for fee streaming via StreamableFeesLocker (optional)\n // When omitted, fees are not locked and beneficiaries are not configured\n // This is useful when using noOp governance where lock duration is not meaningful\n streamableFees?: {\n lockDuration: number; // in seconds\n beneficiaries: BeneficiaryData[]; // Uses shares in WAD (1e18 = 100%)\n };\n }\n | { type: 'noOp' }; // No migration - used with lockable beneficiaries\n\n// Create Static Auction parameters\nexport interface CreateStaticAuctionParams<\n C extends SupportedChainId = SupportedChainId,\n> {\n // Token configuration\n token: TokenConfig;\n\n // Sale configuration\n sale: SaleConfig;\n\n // Static Auction (Uniswap v3) Pool configuration\n pool: StaticPoolConfig;\n\n // Vesting configuration (optional)\n vesting?: VestingConfig;\n\n // Governance configuration (required). Use `{ type: 'noOp' }` where enabled,\n // `{ type: 'default' }` for standard defaults, or `{ type: 'custom', ... }` to customize.\n governance: GovernanceOption<C>;\n\n // Explicit Migration Configuration\n migration: MigrationConfig;\n\n // Integrator details\n integrator?: Address;\n userAddress: Address;\n\n // Optional address overrides for on-chain modules used during encoding/creation\n modules?: ModuleAddressOverrides;\n\n // Optional transaction gas limit override for the create() transaction\n // If omitted, SDK will default to 13,500,000 gas for create()\n gas?: bigint;\n}\n\n// Create Dynamic Auction parameters\nexport interface CreateDynamicAuctionParams<\n C extends SupportedChainId = SupportedChainId,\n> {\n // Token configuration\n token: TokenConfig;\n\n // Sale configuration\n sale: SaleConfig;\n\n // Dynamic Auction (Uniswap v4 Hook) configuration\n auction: DynamicAuctionConfig;\n\n // Pool configuration\n pool: {\n fee: number; // e.g., 3000 for 0.3%\n tickSpacing: number;\n };\n\n // Vesting configuration (optional)\n vesting?: VestingConfig;\n\n // Governance configuration (required). Use `{ type: 'noOp' }` where enabled,\n // `{ type: 'default' }` for standard defaults, or `{ type: 'custom', ... }` to customize.\n governance: GovernanceOption<C>;\n\n // Explicit Migration Configuration\n migration: MigrationConfig;\n\n // Integrator details\n integrator?: Address;\n userAddress: Address;\n\n // Time configuration (internal use)\n startTimeOffset?: number;\n blockTimestamp?: number; // Optional: use this block timestamp instead of fetching latest\n\n // Optional transaction gas limit override for the create() transaction\n // If omitted, SDK will default to 13,500,000 gas for create()\n gas?: bigint;\n\n // Optional address overrides for on-chain modules used during encoding/creation\n modules?: ModuleAddressOverrides;\n}\n\n// Price range configuration for automatic tick calculation\nexport interface PriceRange {\n startPrice: number;\n endPrice: number;\n}\n\n// Tick range configuration\nexport interface TickRange {\n startTick: number;\n endTick: number;\n}\n\n// ============================================================================\n// Market Cap Configuration Types\n// ============================================================================\n\n/**\n * Market cap range in USD for price configurations.\n * Used to define start and end market caps for bonding curves.\n */\nexport interface MarketCapRange {\n /** Starting market cap in USD (e.g., 100_000 for $100k) */\n start: number;\n /** Ending market cap in USD (e.g., 10_000_000 for $10M) */\n end: number;\n}\n\n/**\n * Base configuration for market cap-based tick calculations.\n * Used by builder methods to convert market caps to ticks.\n */\nexport interface MarketCapConfig {\n /** Target market cap range in USD */\n marketCap: MarketCapRange;\n /** Price of numeraire in USD (e.g., 3000 for ETH at $3000) */\n numerairePrice: number;\n /**\n * Token supply override. If not provided, inferred from saleConfig.initialSupply.\n * Must include decimals (e.g., parseEther('1000000000') for 1B tokens).\n */\n tokenSupply?: bigint;\n /** Token decimals (default: 18) */\n tokenDecimals?: number;\n /** Numeraire decimals (default: 18) */\n numeraireDecimals?: number;\n}\n\n/**\n * Market cap configuration for V3 Static Auctions.\n * Extends base config with V3-specific parameters.\n */\nexport interface StaticAuctionMarketCapConfig extends MarketCapConfig {\n /** Fee tier in basis points (e.g., 10000 for 1%). Default: 10000 */\n fee?: number;\n /** Number of liquidity positions. Default: 15 */\n numPositions?: number;\n /** Maximum share of tokens to sell per position (WAD). Default: 35% */\n maxShareToBeSold?: bigint;\n}\n\n/**\n * Market cap range for V4 Dynamic Auctions (Dutch auctions).\n * Uses start/min because price descends from start to minimum.\n */\nexport interface DynamicMarketCapRange {\n /** Starting market cap in USD - auction begins here (e.g., 500_000 for $500k) */\n start: number;\n /** Minimum market cap in USD - floor price the auction descends to (e.g., 50_000 for $50k) */\n min: number;\n}\n\n/**\n * Market cap configuration for V4 Dynamic Auctions.\n * Uses start/min (not start/end) because Dutch auctions descend from start to minimum.\n */\nexport interface DynamicAuctionMarketCapConfig {\n /** Target market cap range (start = launch price, min = floor price) */\n marketCap: DynamicMarketCapRange;\n /** Price of numeraire in USD (e.g., 3000 for ETH at $3000) */\n numerairePrice: number;\n /**\n * Token supply override. If not provided, inferred from saleConfig.initialSupply.\n * Must include decimals (e.g., parseEther('1000000000') for 1B tokens).\n */\n tokenSupply?: bigint;\n /** Token decimals (default: 18) */\n tokenDecimals?: number;\n /** Numeraire decimals (default: 18) */\n numeraireDecimals?: number;\n /**\n * Pool fee in basis points. Default: 10000 (1%)\n *\n * V4 pools support any fee from 0 to 100,000 (10%).\n * Standard tiers (100, 500, 3000, 10000) auto-derive tickSpacing.\n * Custom fees require explicit tickSpacing parameter.\n */\n fee?: number;\n /**\n * Tick spacing for the pool. Required for custom fees.\n *\n * Must be <= 30 for Doppler pools (MAX_TICK_SPACING constraint).\n * If not provided with a standard fee tier, defaults to 30.\n */\n tickSpacing?: number;\n /** Minimum proceeds required for successful auction */\n minProceeds: bigint;\n /** Maximum proceeds cap for the auction */\n maxProceeds: bigint;\n /** Auction duration in seconds. Default: 7 days */\n duration?: number;\n /** Epoch length in seconds. Default: 3600 (1 hour) */\n epochLength?: number;\n /** Gamma (tick decay per epoch). Auto-calculated if not provided */\n gamma?: number;\n /** Number of price discovery slugs. Default: 5 */\n numPdSlugs?: number;\n}\n\n/**\n * Result of market cap parameter validation.\n */\nexport interface MarketCapValidationResult {\n /** Whether all parameters are within normal bounds */\n valid: boolean;\n /** Warning messages for unusual but technically valid values */\n warnings: string[];\n}\n\n// ============================================================================\n// Market Cap Helper Function Parameter Types\n// ============================================================================\n\n/**\n * Parameters for converting market cap range to ticks for V3 Static Auctions.\n */\nexport interface StaticAuctionTickParams {\n marketCapRange: MarketCapRange;\n tokenSupply: bigint;\n numerairePriceUSD: number;\n tickSpacing: number;\n tokenDecimals?: number;\n numeraireDecimals?: number;\n}\n\n/**\n * Parameters for converting market cap range to ticks for V4 Dynamic Auctions.\n */\nexport interface DynamicAuctionTickParams {\n marketCapRange: MarketCapRange;\n tokenSupply: bigint;\n numerairePriceUSD: number;\n numeraire: Address;\n tickSpacing: number;\n tokenDecimals?: number;\n numeraireDecimals?: number;\n}\n\n/**\n * Parameters for converting market cap range to ticks for V4 Multicurve pools.\n */\nexport interface MulticurveTickRangeParams {\n marketCapLower: number;\n marketCapUpper: number | 'max';\n tokenSupply: bigint;\n numerairePriceUSD: number;\n tickSpacing: number;\n tokenDecimals?: number;\n numeraireDecimals?: number;\n}\n\n/**\n * Parameters for converting a single market cap to a tick for Multicurve.\n */\nexport interface MulticurveTickParams {\n marketCapUSD: number;\n tokenSupply: bigint;\n numerairePriceUSD: number;\n tickSpacing: number;\n tokenDecimals?: number;\n numeraireDecimals?: number;\n}\n\n/**\n * Parameters for converting a tick to market cap (reverse conversion).\n */\nexport interface TickToMarketCapParams {\n tick: number;\n tokenSupply: bigint;\n numerairePriceUSD: number;\n tokenDecimals?: number;\n numeraireDecimals?: number;\n}\n\n// ============================================================================\n// New Multicurve Market Cap API (no tick math required)\n// ============================================================================\n\n/**\n * Curve configuration for Multicurve pools using market cap ranges.\n * Each curve defines a market cap range and liquidity distribution.\n */\nexport interface MulticurveMarketCapRangeCurve {\n /** Market cap range for this curve */\n marketCap: {\n /** Start market cap in USD (for the first curve, this is the launch price) */\n start: number;\n /** End market cap in USD, or 'max' for MAX_TICK rounded to tick spacing */\n end: number | 'max';\n };\n /** Number of liquidity positions in this curve */\n numPositions: number;\n /** Share of total supply allocated to this curve (WAD, e.g., parseEther('0.3') = 30%) */\n shares: bigint;\n}\n\n/**\n * Market cap-based configuration for Multicurve pools.\n * No tick math required - just specify market caps in USD.\n */\nexport interface MulticurveMarketCapCurvesConfig {\n /** Price of numeraire in USD (e.g., 3000 for ETH at $3000) */\n numerairePrice: number;\n /**\n * Array of curves defining market cap ranges and liquidity distribution.\n * The first curve's marketCap.start is the launch price.\n * Curves must be contiguous (no gaps allowed).\n */\n curves: MulticurveMarketCapRangeCurve[];\n /** Token supply override */\n tokenSupply?: bigint;\n /** Token decimals (default: 18) */\n tokenDecimals?: number;\n /** Numeraire decimals (default: 18) */\n numeraireDecimals?: number;\n /** Fee tier (default: FEE_TIERS.LOW) */\n fee?: number;\n /** Tick spacing (derived from fee if not provided) */\n tickSpacing?: number;\n /** Optional beneficiaries for fee streaming */\n beneficiaries?: BeneficiaryData[];\n}\n\n// Build configuration for static auctions (V3-style)\nexport interface StaticAuctionBuildConfig {\n // Token details\n name: string;\n symbol: string;\n totalSupply?: bigint; // default: 1 billion\n numTokensToSell?: bigint; // default: 900 million\n tokenURI: string;\n\n // Time parameters\n startTimeOffset?: number; // Optional - seconds to add to current block timestamp (default: 30)\n\n // Price parameters - must provide either priceRange or tickRange\n numeraire: Address; // Required for V3\n tickRange?: TickRange;\n priceRange?: PriceRange;\n fee?: number; // default: 10000 (1%)\n\n // Pool parameters (V3 specific)\n numPositions?: number; // default: 15\n maxShareToBeSold?: bigint; // default: 35% in WAD\n\n // Vesting parameters\n yearlyMintRate?: bigint; // default: 2%\n vestingDuration?: bigint; // default: 1 year\n recipients?: Address[]; // defaults to [userAddress]\n amounts?: bigint[]; // defaults based on pre-mint calculation\n\n // Migration configuration\n migration: MigrationConfig;\n\n // Other parameters\n integrator?: Address;\n useGovernance?: boolean; // default: true\n}\n\n// Build configuration for dynamic auctions (V4-style)\nexport interface DynamicAuctionBuildConfig {\n // Token details\n name: string;\n symbol: string;\n totalSupply: bigint;\n numTokensToSell: bigint;\n tokenURI: string;\n\n // Time parameters\n startTimeOffset?: number; // Optional - seconds to add to block timestamp (default: 30)\n blockTimestamp?: number; // Optional - specific block timestamp to use (default: fetch latest)\n duration?: number; // in seconds (default: 604800 = 7 days)\n epochLength?: number; // in seconds (default: 3600)\n\n // Price parameters - must provide either priceRange or tickRange\n numeraire?: Address; // defaults to zero address\n tickRange?: TickRange;\n priceRange?: PriceRange;\n tickSpacing: number;\n gamma?: number; // auto-calculated if not provided\n fee: number; // In basis points\n\n // Sale parameters\n minProceeds: bigint;\n maxProceeds: bigint;\n numPdSlugs?: number; // default: 5\n\n // Vesting parameters\n yearlyMintRate?: bigint; // default: 2%\n vestingDuration: bigint;\n recipients: Address[];\n amounts: bigint[];\n\n // Migration configuration\n migration: MigrationConfig;\n\n // Other parameters\n integrator?: Address;\n useGovernance?: boolean; // default: true\n}\n\n// SDK initialization configuration\nexport interface DopplerSDKConfig {\n publicClient: SupportedPublicClient;\n walletClient?: WalletClient;\n chainId: number;\n}\n\n// Pool information types\nexport interface PoolInfo {\n address: Address;\n tokenAddress: Address;\n numeraireAddress: Address;\n fee: number;\n liquidity: bigint;\n sqrtPriceX96: bigint;\n}\n\nexport interface HookInfo {\n hookAddress: Address;\n tokenAddress: Address;\n numeraireAddress: Address;\n poolId: string;\n currentEpoch: number;\n totalProceeds: bigint;\n totalTokensSold: bigint;\n earlyExit: boolean;\n insufficientProceeds: boolean;\n startingTime: bigint;\n endingTime: bigint;\n epochLength: bigint;\n minimumProceeds: bigint;\n maximumProceeds: bigint;\n}\n\n// Quote result type\nexport interface QuoteResult {\n amountOut: bigint;\n priceImpact: number;\n fee: bigint;\n route: string[];\n}\n\n// Lockable Uniswap V3 Initializer encode params\nexport interface LockableV3InitializerParams {\n fee: number;\n tickLower: number;\n tickUpper: number;\n numPositions: number;\n maxShareToBeSold: bigint;\n beneficiaries: BeneficiaryData[];\n}\n\n// Multicurve curve configuration (mirrors solidity struct)\nexport interface MulticurveCurve {\n tickLower: number; // int24\n tickUpper: number; // int24\n numPositions: number; // uint16\n shares: bigint; // uint256 (WAD)\n}\n\nexport type MulticurveMarketCapPreset = 'low' | 'medium' | 'high';\n\nexport interface V4PoolKey {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n}\n\nexport interface MulticurveBundleExactOutResult {\n asset: Address;\n poolKey: V4PoolKey;\n amountIn: bigint;\n gasEstimate: bigint;\n}\n\nexport interface MulticurveBundleExactInResult {\n asset: Address;\n poolKey: V4PoolKey;\n amountOut: bigint;\n gasEstimate: bigint;\n}\n\n// RehypeDopplerHook configuration for fee distribution and buyback\nexport interface RehypeDopplerHookConfig {\n // The hook contract address (must be whitelisted in the initializer)\n hookAddress: Address;\n // Destination address for buyback tokens\n buybackDestination: Address;\n // Custom swap fee in basis points (e.g., 3000 = 0.3%)\n customFee: number;\n // Fee distribution percentages (must sum to 100% / WAD)\n // Percentage of fees used for asset buyback (in WAD, e.g., 0.2e18 = 20%)\n assetBuybackPercentWad: bigint;\n // Percentage of fees used for numeraire buyback (in WAD, e.g., 0.2e18 = 20%)\n numeraireBuybackPercentWad: bigint;\n // Percentage of fees distributed to beneficiaries (in WAD, e.g., 0.3e18 = 30%)\n beneficiaryPercentWad: bigint;\n // Percentage of fees distributed to LPs (in WAD, e.g., 0.3e18 = 30%)\n lpPercentWad: bigint;\n // Optional graduation calldata (called when pool graduates)\n graduationCalldata?: `0x${string}`;\n\n // Graduation threshold configuration (rehype-only)\n // Market cap in USD at which pool can graduate. Requires numerairePrice (from withCurves() or explicit).\n graduationMarketCap?: number;\n // Price of numeraire in USD. Optional if using withCurves() (reuses that value). Required with poolConfig().\n numerairePrice?: number;\n // Direct tick value for graduation threshold. Use graduationMarketCap for USD-based config.\n farTick?: number;\n}\n\n// Create Multicurve initializer parameters\nexport interface CreateMulticurveParams<\n C extends SupportedChainId = SupportedChainId,\n> {\n // Token configuration\n token: TokenConfig;\n\n // Sale configuration\n sale: SaleConfig;\n\n // Pool configuration for multicurve initializer\n pool: {\n fee: number;\n tickSpacing: number;\n curves: MulticurveCurve[];\n // Optional beneficiaries to lock the pool (fee collection only, no migration)\n beneficiaries?: BeneficiaryData[];\n };\n\n // Optional scheduled launch configuration\n schedule?: {\n startTime: number;\n };\n\n dopplerHook?: RehypeDopplerHookConfig;\n\n // Vesting configuration (optional)\n vesting?: VestingConfig;\n\n // Governance configuration\n governance: GovernanceOption<C>;\n\n // Migration configuration (can be any supported migrator: V2, V3, or V4)\n migration: MigrationConfig;\n\n // Integrator details\n integrator?: Address;\n userAddress: Address;\n\n // Optional address overrides for on-chain modules used during encoding/creation\n modules?: ModuleAddressOverrides;\n\n // Optional transaction gas limit override for the create() transaction\n gas?: bigint;\n}\n\n// Final Params object that gets passed as arg to create\nexport interface CreateParams {\n initialSupply: bigint;\n numTokensToSell: bigint;\n numeraire: Address;\n tokenFactory: Address;\n tokenFactoryData: `0x${string}`;\n governanceFactory: Address;\n governanceFactoryData: `0x${string}`;\n poolInitializer: Address;\n poolInitializerData: `0x${string}`;\n liquidityMigrator: Address;\n liquidityMigratorData: `0x${string}`;\n integrator: Address;\n salt: `0x${string}`;\n}\n\n// Optional per-call module address overrides. When provided, these take precedence\n// over chain defaults resolved via getAddresses(chainId).\nexport interface ModuleAddressOverrides {\n // Core deployment & routing\n airlock?: Address;\n tokenFactory?: Address;\n\n // Initializers\n v3Initializer?: Address;\n lockableV3Initializer?: Address;\n v4Initializer?: Address;\n v4MulticurveInitializer?: Address;\n v4ScheduledMulticurveInitializer?: Address;\n dopplerHookInitializer?: Address;\n\n // DopplerHooks\n rehypeDopplerHook?: Address;\n\n // Governance\n governanceFactory?: Address;\n\n // Dynamic auction infra\n poolManager?: Address;\n dopplerDeployer?: Address;\n\n // Migrators\n v2Migrator?: Address;\n v4Migrator?: Address;\n noOpMigrator?: Address;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"names":["CHAIN_IDS","LockablePoolStatus"],"mappings":";;;;;AA0EO,IAAM,uBAAA,GAA0B;AAAA,EACrCA,0BAAA,CAAU,IAAA;AAAA,EACVA,0BAAA,CAAU,YAAA;AAAA,EACVA,0BAAA,CAAU,QAAA;AAAA,EACVA,0BAAA,CAAU,gBAAA;AAAA,EACVA,0BAAA,CAAU,aAAA;AAAA,EACVA,0BAAA,CAAU;AACZ;AAOO,SAAS,mBACd,OAAA,EAC+B;AAC/B,EAAA,OAAQ,uBAAA,CAA8C,SAAS,OAAO,CAAA;AACxE;AAGO,IAAM,2BAAA,GAA8B;AAAA,EACzCA,0BAAA,CAAU,IAAA;AAAA,EACVA,0BAAA,CAAU;AACZ;AAQO,SAAS,wBACd,OAAA,EACoC;AACpC,EAAA,OAAQ,2BAAA,CAAkD,SAAS,OAAO,CAAA;AAC5E;AA8BO,IAAK,kBAAA,qBAAAC,mBAAAA,KAAL;AACL,EAAAA,mBAAAA,CAAAA,mBAAAA,CAAA,mBAAgB,CAAA,CAAA,GAAhB,eAAA;AACA,EAAAA,mBAAAA,CAAAA,mBAAAA,CAAA,iBAAc,CAAA,CAAA,GAAd,aAAA;AACA,EAAAA,mBAAAA,CAAAA,mBAAAA,CAAA,YAAS,CAAA,CAAA,GAAT,QAAA;AACA,EAAAA,mBAAAA,CAAAA,mBAAAA,CAAA,YAAS,CAAA,CAAA,GAAT,QAAA;AAJU,EAAA,OAAAA,mBAAAA;AAAA,CAAA,EAAA,kBAAA,IAAA,EAAA","file":"chunk-AS5UUJRI.js","sourcesContent":["import { base, baseSepolia, ink, unichain } from 'viem/chains';\nimport { CHAIN_IDS, type SupportedChainId } from './addresses';\n// Re-export SupportedChainId so consumers can import from this module\nexport { type SupportedChainId } from './addresses';\nimport type { Address, WalletClient } from 'viem';\n\nexport type SupportedChain =\n | typeof base\n | typeof baseSepolia\n | typeof ink\n | typeof unichain\n | typeof baseSepolia;\n// Use a wide type to avoid cross-package viem type identity issues when linking packages locally.\nexport type SupportedPublicClient = unknown;\n\n// Core configuration types\n// Token configuration (discriminated union)\nexport interface StandardTokenConfig {\n type?: 'standard'; // default behavior (backwards compatible)\n name: string;\n symbol: string;\n tokenURI: string;\n yearlyMintRate?: bigint; // Optional yearly mint rate (in WAD, default: 2% = 0.02e18)\n}\n\nexport interface Doppler404TokenConfig {\n type: 'doppler404';\n name: string;\n symbol: string;\n baseURI: string;\n // Optional unit for DN404 factory (uint256). Defaults to 1000 when omitted.\n unit?: bigint;\n}\n\nexport type TokenConfig = StandardTokenConfig | Doppler404TokenConfig;\n\nexport interface SaleConfig {\n initialSupply: bigint;\n numTokensToSell: bigint;\n numeraire: Address; // e.g., WETH address\n}\n\n// Static Auction Pool configuration\nexport interface StaticPoolConfig {\n startTick: number;\n endTick: number;\n fee: number; // e.g., 3000 for 0.3%\n // Optional parameters for lockable initializer\n numPositions?: number; // Number of liquidity positions (default: based on tick range)\n maxShareToBeSold?: bigint; // Maximum share of tokens to sell (in WAD, default: 1e18 = 100%)\n beneficiaries?: BeneficiaryData[]; // Optional beneficiaries for fee streaming\n}\n\n// Dynamic Auction configuration\nexport interface DynamicAuctionConfig {\n duration: number; // in seconds\n epochLength: number; // in seconds\n startTick: number;\n endTick: number;\n gamma?: number; // Optional, can be auto-calculated\n minProceeds: bigint;\n maxProceeds: bigint;\n numPdSlugs?: number; // Price discovery slugs (optional)\n}\n\n// Vesting configuration\nexport interface VestingConfig {\n duration: number; // in seconds\n cliffDuration: number; // in seconds\n recipients?: Address[]; // Optional array of recipient addresses (defaults to [userAddress] if not specified)\n amounts?: bigint[]; // Optional array of vesting amounts per recipient (must match recipients length if provided)\n}\n\n// Chains where no-op governance is enabled\nexport const NO_OP_ENABLED_CHAIN_IDS = [\n CHAIN_IDS.BASE,\n CHAIN_IDS.BASE_SEPOLIA,\n CHAIN_IDS.UNICHAIN,\n CHAIN_IDS.UNICHAIN_SEPOLIA,\n CHAIN_IDS.MONAD_TESTNET,\n CHAIN_IDS.MONAD_MAINNET,\n] as const;\n\nexport type NoOpEnabledChainId = (typeof NO_OP_ENABLED_CHAIN_IDS)[number];\n\n/**\n * Check if a chain supports no-op governance\n */\nexport function isNoOpEnabledChain(\n chainId: number,\n): chainId is NoOpEnabledChainId {\n return (NO_OP_ENABLED_CHAIN_IDS as readonly number[]).includes(chainId);\n}\n\n// Chains where launchpad governance is enabled\nexport const LAUNCHPAD_ENABLED_CHAIN_IDS = [\n CHAIN_IDS.BASE,\n CHAIN_IDS.MONAD_MAINNET,\n] as const;\n\nexport type LaunchpadEnabledChainId =\n (typeof LAUNCHPAD_ENABLED_CHAIN_IDS)[number];\n\n/**\n * Check if a chain supports launchpad governance\n */\nexport function isLaunchpadEnabledChain(\n chainId: number,\n): chainId is LaunchpadEnabledChainId {\n return (LAUNCHPAD_ENABLED_CHAIN_IDS as readonly number[]).includes(chainId);\n}\n\n// Governance configuration (discriminated union)\nexport type GovernanceDefault = { type: 'default' };\nexport interface GovernanceCustom {\n type: 'custom';\n initialVotingDelay: number;\n initialVotingPeriod: number;\n initialProposalThreshold: bigint;\n}\nexport type GovernanceNoOp = { type: 'noOp' };\nexport interface GovernanceLaunchpad {\n type: 'launchpad';\n multisig: Address;\n}\n\nexport type GovernanceOption<C extends SupportedChainId> =\n | GovernanceDefault\n | GovernanceCustom\n | (C extends NoOpEnabledChainId ? GovernanceNoOp : never)\n | (C extends LaunchpadEnabledChainId ? GovernanceLaunchpad : never);\n\n// Unified beneficiary data used for fee streaming, lockable initializers, and migration configs\n// Uses shares in WAD format (1e18 = 100%) for consistency across all beneficiary configurations\nexport interface BeneficiaryData {\n beneficiary: Address;\n shares: bigint; // shares in WAD (1e18 = 100%)\n}\n\n// Pool status for lockable initializer\nexport enum LockablePoolStatus {\n Uninitialized = 0,\n Initialized = 1,\n Locked = 2,\n Exited = 3,\n}\n\n// Lockable pool state\nexport interface LockablePoolState {\n asset: Address;\n numeraire: Address;\n tickLower: number;\n tickUpper: number;\n maxShareToBeSold: bigint;\n totalTokensOnBondingCurve: bigint;\n status: LockablePoolStatus;\n}\n\n// Multicurve pool state (V4 initializer)\nexport interface MulticurvePoolState {\n asset: Address;\n numeraire: Address;\n fee: number;\n tickSpacing: number;\n status: LockablePoolStatus; // Reuses the same enum\n poolKey: V4PoolKey;\n farTick: number;\n}\n\n// Migration configuration (discriminated union)\nexport type MigrationConfig =\n | { type: 'uniswapV2' } // Basic migration to a new Uniswap v2 pool\n | {\n type: 'uniswapV4';\n fee: number;\n tickSpacing: number;\n // Configuration for fee streaming via StreamableFeesLocker (optional)\n // When omitted, fees are not locked and beneficiaries are not configured\n // This is useful when using noOp governance where lock duration is not meaningful\n streamableFees?: {\n lockDuration: number; // in seconds\n beneficiaries: BeneficiaryData[]; // Uses shares in WAD (1e18 = 100%)\n };\n }\n | { type: 'noOp' }; // No migration - used with lockable beneficiaries\n\n// Create Static Auction parameters\nexport interface CreateStaticAuctionParams<\n C extends SupportedChainId = SupportedChainId,\n> {\n // Token configuration\n token: TokenConfig;\n\n // Sale configuration\n sale: SaleConfig;\n\n // Static Auction (Uniswap v3) Pool configuration\n pool: StaticPoolConfig;\n\n // Vesting configuration (optional)\n vesting?: VestingConfig;\n\n // Governance configuration (required). Use `{ type: 'noOp' }` where enabled,\n // `{ type: 'default' }` for standard defaults, or `{ type: 'custom', ... }` to customize.\n governance: GovernanceOption<C>;\n\n // Explicit Migration Configuration\n migration: MigrationConfig;\n\n // Integrator details\n integrator?: Address;\n userAddress: Address;\n\n // Optional address overrides for on-chain modules used during encoding/creation\n modules?: ModuleAddressOverrides;\n\n // Optional transaction gas limit override for the create() transaction\n // If omitted, SDK will default to 13,500,000 gas for create()\n gas?: bigint;\n}\n\n// Create Dynamic Auction parameters\nexport interface CreateDynamicAuctionParams<\n C extends SupportedChainId = SupportedChainId,\n> {\n // Token configuration\n token: TokenConfig;\n\n // Sale configuration\n sale: SaleConfig;\n\n // Dynamic Auction (Uniswap v4 Hook) configuration\n auction: DynamicAuctionConfig;\n\n // Pool configuration\n pool: {\n fee: number; // e.g., 3000 for 0.3%\n tickSpacing: number;\n };\n\n // Vesting configuration (optional)\n vesting?: VestingConfig;\n\n // Governance configuration (required). Use `{ type: 'noOp' }` where enabled,\n // `{ type: 'default' }` for standard defaults, or `{ type: 'custom', ... }` to customize.\n governance: GovernanceOption<C>;\n\n // Explicit Migration Configuration\n migration: MigrationConfig;\n\n // Integrator details\n integrator?: Address;\n userAddress: Address;\n\n // Time configuration (internal use)\n startTimeOffset?: number;\n blockTimestamp?: number; // Optional: use this block timestamp instead of fetching latest\n\n // Optional transaction gas limit override for the create() transaction\n // If omitted, SDK will default to 13,500,000 gas for create()\n gas?: bigint;\n\n // Optional address overrides for on-chain modules used during encoding/creation\n modules?: ModuleAddressOverrides;\n}\n\n// Price range configuration for automatic tick calculation\nexport interface PriceRange {\n startPrice: number;\n endPrice: number;\n}\n\n// Tick range configuration\nexport interface TickRange {\n startTick: number;\n endTick: number;\n}\n\n// ============================================================================\n// Market Cap Configuration Types\n// ============================================================================\n\n/**\n * Market cap range in USD for price configurations.\n * Used to define start and end market caps for bonding curves.\n */\nexport interface MarketCapRange {\n /** Starting market cap in USD (e.g., 100_000 for $100k) */\n start: number;\n /** Ending market cap in USD (e.g., 10_000_000 for $10M) */\n end: number;\n}\n\n/**\n * Base configuration for market cap-based tick calculations.\n * Used by builder methods to convert market caps to ticks.\n */\nexport interface MarketCapConfig {\n /** Target market cap range in USD */\n marketCap: MarketCapRange;\n /** Price of numeraire in USD (e.g., 3000 for ETH at $3000) */\n numerairePrice: number;\n /**\n * Token supply override. If not provided, inferred from saleConfig.initialSupply.\n * Must include decimals (e.g., parseEther('1000000000') for 1B tokens).\n */\n tokenSupply?: bigint;\n /** Token decimals (default: 18) */\n tokenDecimals?: number;\n /** Numeraire decimals (default: 18) */\n numeraireDecimals?: number;\n}\n\n/**\n * Market cap configuration for V3 Static Auctions.\n * Extends base config with V3-specific parameters.\n */\nexport interface StaticAuctionMarketCapConfig extends MarketCapConfig {\n /** Fee tier in basis points (e.g., 10000 for 1%). Default: 10000 */\n fee?: number;\n /** Number of liquidity positions. Default: 15 */\n numPositions?: number;\n /** Maximum share of tokens to sell per position (WAD). Default: 35% */\n maxShareToBeSold?: bigint;\n}\n\n/**\n * Market cap range for V4 Dynamic Auctions (Dutch auctions).\n * Uses start/min because price descends from start to minimum.\n */\nexport interface DynamicMarketCapRange {\n /** Starting market cap in USD - auction begins here (e.g., 500_000 for $500k) */\n start: number;\n /** Minimum market cap in USD - floor price the auction descends to (e.g., 50_000 for $50k) */\n min: number;\n}\n\n/**\n * Market cap configuration for V4 Dynamic Auctions.\n * Uses start/min (not start/end) because Dutch auctions descend from start to minimum.\n */\nexport interface DynamicAuctionMarketCapConfig {\n /** Target market cap range (start = launch price, min = floor price) */\n marketCap: DynamicMarketCapRange;\n /** Price of numeraire in USD (e.g., 3000 for ETH at $3000) */\n numerairePrice: number;\n /**\n * Token supply override. If not provided, inferred from saleConfig.initialSupply.\n * Must include decimals (e.g., parseEther('1000000000') for 1B tokens).\n */\n tokenSupply?: bigint;\n /** Token decimals (default: 18) */\n tokenDecimals?: number;\n /** Numeraire decimals (default: 18) */\n numeraireDecimals?: number;\n /**\n * Pool fee in basis points. Default: 10000 (1%)\n *\n * V4 pools support any fee from 0 to 100,000 (10%).\n * Standard tiers (100, 500, 3000, 10000) auto-derive tickSpacing.\n * Custom fees require explicit tickSpacing parameter.\n */\n fee?: number;\n /**\n * Tick spacing for the pool. Required for custom fees.\n *\n * Must be <= 30 for Doppler pools (MAX_TICK_SPACING constraint).\n * If not provided with a standard fee tier, defaults to 30.\n */\n tickSpacing?: number;\n /** Minimum proceeds required for successful auction */\n minProceeds: bigint;\n /** Maximum proceeds cap for the auction */\n maxProceeds: bigint;\n /** Auction duration in seconds. Default: 7 days */\n duration?: number;\n /** Epoch length in seconds. Default: 3600 (1 hour) */\n epochLength?: number;\n /** Gamma (tick decay per epoch). Auto-calculated if not provided */\n gamma?: number;\n /** Number of price discovery slugs. Default: 5 */\n numPdSlugs?: number;\n}\n\n/**\n * Result of market cap parameter validation.\n */\nexport interface MarketCapValidationResult {\n /** Whether all parameters are within normal bounds */\n valid: boolean;\n /** Warning messages for unusual but technically valid values */\n warnings: string[];\n}\n\n// ============================================================================\n// Market Cap Helper Function Parameter Types\n// ============================================================================\n\n/**\n * Parameters for converting market cap range to ticks for V3 Static Auctions.\n */\nexport interface StaticAuctionTickParams {\n marketCapRange: MarketCapRange;\n tokenSupply: bigint;\n numerairePriceUSD: number;\n tickSpacing: number;\n tokenDecimals?: number;\n numeraireDecimals?: number;\n}\n\n/**\n * Parameters for converting market cap range to ticks for V4 Dynamic Auctions.\n */\nexport interface DynamicAuctionTickParams {\n marketCapRange: MarketCapRange;\n tokenSupply: bigint;\n numerairePriceUSD: number;\n numeraire: Address;\n tickSpacing: number;\n tokenDecimals?: number;\n numeraireDecimals?: number;\n}\n\n/**\n * Parameters for converting market cap range to ticks for V4 Multicurve pools.\n */\nexport interface MulticurveTickRangeParams {\n marketCapLower: number;\n marketCapUpper: number | 'max';\n tokenSupply: bigint;\n numerairePriceUSD: number;\n tickSpacing: number;\n tokenDecimals?: number;\n numeraireDecimals?: number;\n}\n\n/**\n * Parameters for converting a single market cap to a tick for Multicurve.\n */\nexport interface MulticurveTickParams {\n marketCapUSD: number;\n tokenSupply: bigint;\n numerairePriceUSD: number;\n tickSpacing: number;\n tokenDecimals?: number;\n numeraireDecimals?: number;\n}\n\n/**\n * Parameters for converting a tick to market cap (reverse conversion).\n */\nexport interface TickToMarketCapParams {\n tick: number;\n tokenSupply: bigint;\n numerairePriceUSD: number;\n tokenDecimals?: number;\n numeraireDecimals?: number;\n}\n\n// ============================================================================\n// New Multicurve Market Cap API (no tick math required)\n// ============================================================================\n\n/**\n * Curve configuration for Multicurve pools using market cap ranges.\n * Each curve defines a market cap range and liquidity distribution.\n */\nexport interface MulticurveMarketCapRangeCurve {\n /** Market cap range for this curve */\n marketCap: {\n /** Start market cap in USD (for the first curve, this is the launch price) */\n start: number;\n /** End market cap in USD, or 'max' for MAX_TICK rounded to tick spacing */\n end: number | 'max';\n };\n /** Number of liquidity positions in this curve */\n numPositions: number;\n /** Share of total supply allocated to this curve (WAD, e.g., parseEther('0.3') = 30%) */\n shares: bigint;\n}\n\n/**\n * Market cap-based configuration for Multicurve pools.\n * No tick math required - just specify market caps in USD.\n */\nexport interface MulticurveMarketCapCurvesConfig {\n /** Price of numeraire in USD (e.g., 3000 for ETH at $3000) */\n numerairePrice: number;\n /**\n * Array of curves defining market cap ranges and liquidity distribution.\n * The first curve's marketCap.start is the launch price.\n * Curves must be contiguous (no gaps allowed).\n */\n curves: MulticurveMarketCapRangeCurve[];\n /** Token supply override */\n tokenSupply?: bigint;\n /** Token decimals (default: 18) */\n tokenDecimals?: number;\n /** Numeraire decimals (default: 18) */\n numeraireDecimals?: number;\n /** Fee tier (default: FEE_TIERS.LOW) */\n fee?: number;\n /** Tick spacing (derived from fee if not provided) */\n tickSpacing?: number;\n /** Optional beneficiaries for fee streaming */\n beneficiaries?: BeneficiaryData[];\n}\n\n// Build configuration for static auctions (V3-style)\nexport interface StaticAuctionBuildConfig {\n // Token details\n name: string;\n symbol: string;\n totalSupply?: bigint; // default: 1 billion\n numTokensToSell?: bigint; // default: 900 million\n tokenURI: string;\n\n // Time parameters\n startTimeOffset?: number; // Optional - seconds to add to current block timestamp (default: 30)\n\n // Price parameters - must provide either priceRange or tickRange\n numeraire: Address; // Required for V3\n tickRange?: TickRange;\n priceRange?: PriceRange;\n fee?: number; // default: 10000 (1%)\n\n // Pool parameters (V3 specific)\n numPositions?: number; // default: 15\n maxShareToBeSold?: bigint; // default: 35% in WAD\n\n // Vesting parameters\n yearlyMintRate?: bigint; // default: 2%\n vestingDuration?: bigint; // default: 1 year\n recipients?: Address[]; // defaults to [userAddress]\n amounts?: bigint[]; // defaults based on pre-mint calculation\n\n // Migration configuration\n migration: MigrationConfig;\n\n // Other parameters\n integrator?: Address;\n useGovernance?: boolean; // default: true\n}\n\n// Build configuration for dynamic auctions (V4-style)\nexport interface DynamicAuctionBuildConfig {\n // Token details\n name: string;\n symbol: string;\n totalSupply: bigint;\n numTokensToSell: bigint;\n tokenURI: string;\n\n // Time parameters\n startTimeOffset?: number; // Optional - seconds to add to block timestamp (default: 30)\n blockTimestamp?: number; // Optional - specific block timestamp to use (default: fetch latest)\n duration?: number; // in seconds (default: 604800 = 7 days)\n epochLength?: number; // in seconds (default: 3600)\n\n // Price parameters - must provide either priceRange or tickRange\n numeraire?: Address; // defaults to zero address\n tickRange?: TickRange;\n priceRange?: PriceRange;\n tickSpacing: number;\n gamma?: number; // auto-calculated if not provided\n fee: number; // In basis points\n\n // Sale parameters\n minProceeds: bigint;\n maxProceeds: bigint;\n numPdSlugs?: number; // default: 5\n\n // Vesting parameters\n yearlyMintRate?: bigint; // default: 2%\n vestingDuration: bigint;\n recipients: Address[];\n amounts: bigint[];\n\n // Migration configuration\n migration: MigrationConfig;\n\n // Other parameters\n integrator?: Address;\n useGovernance?: boolean; // default: true\n}\n\n// SDK initialization configuration\nexport interface DopplerSDKConfig {\n publicClient: SupportedPublicClient;\n walletClient?: WalletClient;\n chainId: number;\n}\n\n// Pool information types\nexport interface PoolInfo {\n address: Address;\n tokenAddress: Address;\n numeraireAddress: Address;\n fee: number;\n liquidity: bigint;\n sqrtPriceX96: bigint;\n}\n\nexport interface HookInfo {\n hookAddress: Address;\n tokenAddress: Address;\n numeraireAddress: Address;\n poolId: string;\n currentEpoch: number;\n totalProceeds: bigint;\n totalTokensSold: bigint;\n earlyExit: boolean;\n insufficientProceeds: boolean;\n startingTime: bigint;\n endingTime: bigint;\n epochLength: bigint;\n minimumProceeds: bigint;\n maximumProceeds: bigint;\n}\n\n// Quote result type\nexport interface QuoteResult {\n amountOut: bigint;\n priceImpact: number;\n fee: bigint;\n route: string[];\n}\n\n// Lockable Uniswap V3 Initializer encode params\nexport interface LockableV3InitializerParams {\n fee: number;\n tickLower: number;\n tickUpper: number;\n numPositions: number;\n maxShareToBeSold: bigint;\n beneficiaries: BeneficiaryData[];\n}\n\n// Multicurve curve configuration (mirrors solidity struct)\nexport interface MulticurveCurve {\n tickLower: number; // int24\n tickUpper: number; // int24\n numPositions: number; // uint16\n shares: bigint; // uint256 (WAD)\n}\n\nexport type MulticurveMarketCapPreset = 'low' | 'medium' | 'high';\n\nexport interface V4PoolKey {\n currency0: Address;\n currency1: Address;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n}\n\nexport interface MulticurveBundleExactOutResult {\n asset: Address;\n poolKey: V4PoolKey;\n amountIn: bigint;\n gasEstimate: bigint;\n}\n\nexport interface MulticurveBundleExactInResult {\n asset: Address;\n poolKey: V4PoolKey;\n amountOut: bigint;\n gasEstimate: bigint;\n}\n\n// RehypeDopplerHook configuration for fee distribution and buyback\nexport interface RehypeDopplerHookConfig {\n // The hook contract address (must be whitelisted in the initializer)\n hookAddress: Address;\n // Destination address for buyback tokens\n buybackDestination: Address;\n // Custom swap fee in basis points (e.g., 3000 = 0.3%)\n customFee: number;\n // Fee distribution percentages (must sum to 100% / WAD)\n // Percentage of fees used for asset buyback (in WAD, e.g., 0.2e18 = 20%)\n assetBuybackPercentWad: bigint;\n // Percentage of fees used for numeraire buyback (in WAD, e.g., 0.2e18 = 20%)\n numeraireBuybackPercentWad: bigint;\n // Percentage of fees distributed to beneficiaries (in WAD, e.g., 0.3e18 = 30%)\n beneficiaryPercentWad: bigint;\n // Percentage of fees distributed to LPs (in WAD, e.g., 0.3e18 = 30%)\n lpPercentWad: bigint;\n // Optional graduation calldata (called when pool graduates)\n graduationCalldata?: `0x${string}`;\n\n // Graduation threshold configuration (rehype-only)\n // Market cap in USD at which pool can graduate. Requires numerairePrice (from withCurves() or explicit).\n graduationMarketCap?: number;\n // Price of numeraire in USD. Optional if using withCurves() (reuses that value). Required with poolConfig().\n numerairePrice?: number;\n // Direct tick value for graduation threshold. Use graduationMarketCap for USD-based config.\n farTick?: number;\n}\n\n// Decay fee schedule state for multicurve pools using a dynamic-fee hook\nexport interface MulticurveDecayFeeSchedule {\n startingTime: number;\n startFee: number;\n endFee: number;\n lastFee: number;\n durationSeconds: number;\n}\n\nexport type MulticurveInitializerConfig =\n | { type: 'standard' }\n | { type: 'scheduled'; startTime: number }\n | {\n type: 'decay';\n startTime: number;\n startFee: number;\n durationSeconds: number;\n }\n | { type: 'rehype'; config: RehypeDopplerHookConfig };\n\n// Create Multicurve initializer parameters\nexport interface CreateMulticurveParams<\n C extends SupportedChainId = SupportedChainId,\n> {\n // Token configuration\n token: TokenConfig;\n\n // Sale configuration\n sale: SaleConfig;\n\n // Pool configuration for multicurve initializer\n pool: {\n // For decay initializer mode, this is the terminal fee (endFee).\n fee: number;\n tickSpacing: number;\n curves: MulticurveCurve[];\n // Optional beneficiaries to lock the pool (fee collection only, no migration)\n beneficiaries?: BeneficiaryData[];\n };\n\n // Preferred initializer configuration. Defaults to { type: 'standard' }.\n initializer?: MulticurveInitializerConfig;\n\n /**\n * @deprecated Use initializer: { type: 'scheduled', startTime } instead.\n * Retained for backwards compatibility.\n */\n // Optional scheduled launch configuration\n schedule?: {\n startTime: number;\n };\n\n /**\n * @deprecated Use initializer: { type: 'rehype', config } instead.\n * Retained for backwards compatibility.\n */\n dopplerHook?: RehypeDopplerHookConfig;\n\n // Vesting configuration (optional)\n vesting?: VestingConfig;\n\n // Governance configuration\n governance: GovernanceOption<C>;\n\n // Migration configuration (can be any supported migrator: V2, V3, or V4)\n migration: MigrationConfig;\n\n // Integrator details\n integrator?: Address;\n userAddress: Address;\n\n // Optional address overrides for on-chain modules used during encoding/creation\n modules?: ModuleAddressOverrides;\n\n // Optional transaction gas limit override for the create() transaction\n gas?: bigint;\n}\n\n// Final Params object that gets passed as arg to create\nexport interface CreateParams {\n initialSupply: bigint;\n numTokensToSell: bigint;\n numeraire: Address;\n tokenFactory: Address;\n tokenFactoryData: `0x${string}`;\n governanceFactory: Address;\n governanceFactoryData: `0x${string}`;\n poolInitializer: Address;\n poolInitializerData: `0x${string}`;\n liquidityMigrator: Address;\n liquidityMigratorData: `0x${string}`;\n integrator: Address;\n salt: `0x${string}`;\n}\n\n// Optional per-call module address overrides. When provided, these take precedence\n// over chain defaults resolved via getAddresses(chainId).\nexport interface ModuleAddressOverrides {\n // Core deployment & routing\n airlock?: Address;\n tokenFactory?: Address;\n\n // Initializers\n v3Initializer?: Address;\n lockableV3Initializer?: Address;\n v4Initializer?: Address;\n v4MulticurveInitializer?: Address;\n v4ScheduledMulticurveInitializer?: Address;\n v4DecayMulticurveInitializer?: Address;\n dopplerHookInitializer?: Address;\n\n // DopplerHooks\n rehypeDopplerHook?: Address;\n\n // Governance\n governanceFactory?: Address;\n\n // Dynamic auction infra\n poolManager?: Address;\n dopplerDeployer?: Address;\n\n // Migrators\n v2Migrator?: Address;\n v4Migrator?: Address;\n noOpMigrator?: Address;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CHAIN_IDS } from './chunk-
|
|
1
|
+
import { CHAIN_IDS } from './chunk-NWZGO2CH.mjs';
|
|
2
2
|
|
|
3
3
|
// src/types.ts
|
|
4
4
|
var NO_OP_ENABLED_CHAIN_IDS = [
|
|
@@ -28,5 +28,5 @@ var LockablePoolStatus = /* @__PURE__ */ ((LockablePoolStatus2) => {
|
|
|
28
28
|
})(LockablePoolStatus || {});
|
|
29
29
|
|
|
30
30
|
export { LAUNCHPAD_ENABLED_CHAIN_IDS, LockablePoolStatus, NO_OP_ENABLED_CHAIN_IDS, isLaunchpadEnabledChain, isNoOpEnabledChain };
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
31
|
+
//# sourceMappingURL=chunk-BFJGY436.mjs.map
|
|
32
|
+
//# sourceMappingURL=chunk-BFJGY436.mjs.map
|