auctionflow-sdk 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -23
- package/dist/index.d.mts +134 -9
- package/dist/index.d.ts +134 -9
- package/dist/index.js +949 -122
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +932 -116
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24,15 +24,30 @@ __export(index_exports, {
|
|
|
24
24
|
AuctionBuilder: () => AuctionBuilder,
|
|
25
25
|
AuctionFlowSDK: () => AuctionFlowSDK,
|
|
26
26
|
AuctionState: () => AuctionState,
|
|
27
|
+
DEFAULT_LIQUIDITY_BPS: () => DEFAULT_LIQUIDITY_BPS,
|
|
28
|
+
DEFAULT_SLIPPAGE_BPS: () => DEFAULT_SLIPPAGE_BPS,
|
|
29
|
+
MIN_LIQUIDITY_BPS: () => MIN_LIQUIDITY_BPS,
|
|
30
|
+
PRICE_SCALE: () => PRICE_SCALE,
|
|
27
31
|
USDC_ADDRESSES: () => USDC_ADDRESSES,
|
|
32
|
+
applySellSlippage: () => applySellSlippage,
|
|
33
|
+
applySlippage: () => applySlippage,
|
|
28
34
|
calculateBuyCost: () => calculateBuyCost,
|
|
29
35
|
calculateBuyQuote: () => calculateBuyQuote,
|
|
36
|
+
calculateSellProceeds: () => calculateSellProceeds,
|
|
37
|
+
fillPurchase: () => fillPurchase,
|
|
38
|
+
formatCurvePrice: () => formatCurvePrice,
|
|
39
|
+
maxBuyable: () => maxBuyable,
|
|
40
|
+
parseCurvePrice: () => parseCurvePrice,
|
|
30
41
|
spotPrice: () => spotPrice
|
|
31
42
|
});
|
|
32
43
|
module.exports = __toCommonJS(index_exports);
|
|
33
44
|
|
|
34
45
|
// src/client.ts
|
|
35
|
-
var
|
|
46
|
+
var import_viem2 = require("viem");
|
|
47
|
+
|
|
48
|
+
// src/constants/protocol.ts
|
|
49
|
+
var MIN_LIQUIDITY_BPS = 2e3;
|
|
50
|
+
var DEFAULT_LIQUIDITY_BPS = 5e3;
|
|
36
51
|
|
|
37
52
|
// src/builders/auction-builder.ts
|
|
38
53
|
var AuctionBuilder = class {
|
|
@@ -52,13 +67,24 @@ var AuctionBuilder = class {
|
|
|
52
67
|
this.config.slope = slope;
|
|
53
68
|
return this;
|
|
54
69
|
}
|
|
70
|
+
/** Graduation threshold: once this much is raised, trading moves to Uniswap. */
|
|
55
71
|
withMaxRaise(maxRaise) {
|
|
56
72
|
this.config.maxRaise = maxRaise;
|
|
57
73
|
return this;
|
|
58
74
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Share of the raise, in basis points, seeded into a Uniswap pool when the
|
|
77
|
+
* auction migrates (5000 = 50%). The rest goes to the creator. Defaults to
|
|
78
|
+
* 50%; must be between 20% and 100%.
|
|
79
|
+
*/
|
|
80
|
+
withLiquidity(liquidityBps) {
|
|
81
|
+
if (!Number.isInteger(liquidityBps)) throw new Error("liquidityBps must be an integer");
|
|
82
|
+
this.config.liquidityBps = BigInt(liquidityBps);
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
/** Off-chain metadata for the token, such as its image (e.g. an IPFS URI). */
|
|
86
|
+
withMetadata(metadataURI) {
|
|
87
|
+
this.config.metadataURI = metadataURI;
|
|
62
88
|
return this;
|
|
63
89
|
}
|
|
64
90
|
build() {
|
|
@@ -69,22 +95,21 @@ var AuctionBuilder = class {
|
|
|
69
95
|
"paymentToken",
|
|
70
96
|
"basePrice",
|
|
71
97
|
"slope",
|
|
72
|
-
"maxRaise"
|
|
73
|
-
"startTime",
|
|
74
|
-
"endTime"
|
|
98
|
+
"maxRaise"
|
|
75
99
|
];
|
|
76
100
|
for (const key of required) {
|
|
77
101
|
if (this.config[key] === void 0) {
|
|
78
102
|
throw new Error(`Missing required field: ${key}`);
|
|
79
103
|
}
|
|
80
104
|
}
|
|
81
|
-
const config = this.config;
|
|
105
|
+
const config = { liquidityBps: BigInt(DEFAULT_LIQUIDITY_BPS), ...this.config };
|
|
82
106
|
if (config.maxSupply <= 0n) throw new Error("maxSupply must be greater than 0");
|
|
83
107
|
if (config.basePrice <= 0n) throw new Error("basePrice must be greater than 0");
|
|
84
108
|
if (config.slope < 0n) throw new Error("slope must not be negative");
|
|
85
109
|
if (config.maxRaise <= 0n) throw new Error("maxRaise must be greater than 0");
|
|
86
|
-
|
|
87
|
-
|
|
110
|
+
const liquidityBps = config.liquidityBps;
|
|
111
|
+
if (liquidityBps < BigInt(MIN_LIQUIDITY_BPS) || liquidityBps > 10000n) {
|
|
112
|
+
throw new Error(`liquidityBps must be between ${MIN_LIQUIDITY_BPS} and 10000`);
|
|
88
113
|
}
|
|
89
114
|
return config;
|
|
90
115
|
}
|
|
@@ -92,7 +117,7 @@ var AuctionBuilder = class {
|
|
|
92
117
|
|
|
93
118
|
// src/constants/addresses.ts
|
|
94
119
|
var AUCTION_ADDRESSES = {
|
|
95
|
-
84532: "
|
|
120
|
+
84532: "0xc6db1c900faeb4079281ecd6ec538c027cd18c28",
|
|
96
121
|
8453: "0x0000000000000000000000000000000000000000"
|
|
97
122
|
// not yet deployed
|
|
98
123
|
};
|
|
@@ -115,10 +140,67 @@ var tokenAuctionAbi = [
|
|
|
115
140
|
"name": "defaultFeeBps_",
|
|
116
141
|
"type": "uint256",
|
|
117
142
|
"internalType": "uint256"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"name": "positionManager_",
|
|
146
|
+
"type": "address",
|
|
147
|
+
"internalType": "contract INonfungiblePositionManager"
|
|
118
148
|
}
|
|
119
149
|
],
|
|
120
150
|
"stateMutability": "nonpayable"
|
|
121
151
|
},
|
|
152
|
+
{
|
|
153
|
+
"type": "function",
|
|
154
|
+
"name": "MAX_FEE_BPS",
|
|
155
|
+
"inputs": [],
|
|
156
|
+
"outputs": [
|
|
157
|
+
{
|
|
158
|
+
"name": "",
|
|
159
|
+
"type": "uint256",
|
|
160
|
+
"internalType": "uint256"
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
"stateMutability": "view"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"type": "function",
|
|
167
|
+
"name": "MAX_LP_FEE_SHARE_BPS",
|
|
168
|
+
"inputs": [],
|
|
169
|
+
"outputs": [
|
|
170
|
+
{
|
|
171
|
+
"name": "",
|
|
172
|
+
"type": "uint256",
|
|
173
|
+
"internalType": "uint256"
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
"stateMutability": "view"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"type": "function",
|
|
180
|
+
"name": "MIN_LIQUIDITY_BPS",
|
|
181
|
+
"inputs": [],
|
|
182
|
+
"outputs": [
|
|
183
|
+
{
|
|
184
|
+
"name": "",
|
|
185
|
+
"type": "uint256",
|
|
186
|
+
"internalType": "uint256"
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
"stateMutability": "view"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"type": "function",
|
|
193
|
+
"name": "POOL_FEE",
|
|
194
|
+
"inputs": [],
|
|
195
|
+
"outputs": [
|
|
196
|
+
{
|
|
197
|
+
"name": "",
|
|
198
|
+
"type": "uint24",
|
|
199
|
+
"internalType": "uint24"
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
"stateMutability": "view"
|
|
203
|
+
},
|
|
122
204
|
{
|
|
123
205
|
"type": "function",
|
|
124
206
|
"name": "auctionCount",
|
|
@@ -174,22 +256,22 @@ var tokenAuctionAbi = [
|
|
|
174
256
|
"internalType": "uint256"
|
|
175
257
|
},
|
|
176
258
|
{
|
|
177
|
-
"name": "
|
|
178
|
-
"type": "
|
|
179
|
-
"internalType": "
|
|
259
|
+
"name": "creator",
|
|
260
|
+
"type": "address",
|
|
261
|
+
"internalType": "address"
|
|
180
262
|
},
|
|
181
263
|
{
|
|
182
|
-
"name": "
|
|
264
|
+
"name": "protocolFeeBps",
|
|
183
265
|
"type": "uint256",
|
|
184
266
|
"internalType": "uint256"
|
|
185
267
|
},
|
|
186
268
|
{
|
|
187
|
-
"name": "
|
|
188
|
-
"type": "
|
|
189
|
-
"internalType": "
|
|
269
|
+
"name": "liquidityBps",
|
|
270
|
+
"type": "uint256",
|
|
271
|
+
"internalType": "uint256"
|
|
190
272
|
},
|
|
191
273
|
{
|
|
192
|
-
"name": "
|
|
274
|
+
"name": "lpFeeShareBps",
|
|
193
275
|
"type": "uint256",
|
|
194
276
|
"internalType": "uint256"
|
|
195
277
|
}
|
|
@@ -226,6 +308,11 @@ var tokenAuctionAbi = [
|
|
|
226
308
|
"name": "amount",
|
|
227
309
|
"type": "uint256",
|
|
228
310
|
"internalType": "uint256"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"name": "maxCost",
|
|
314
|
+
"type": "uint256",
|
|
315
|
+
"internalType": "uint256"
|
|
229
316
|
}
|
|
230
317
|
],
|
|
231
318
|
"outputs": [],
|
|
@@ -233,7 +320,7 @@ var tokenAuctionAbi = [
|
|
|
233
320
|
},
|
|
234
321
|
{
|
|
235
322
|
"type": "function",
|
|
236
|
-
"name": "
|
|
323
|
+
"name": "collectFees",
|
|
237
324
|
"inputs": [
|
|
238
325
|
{
|
|
239
326
|
"name": "auctionId",
|
|
@@ -241,12 +328,182 @@ var tokenAuctionAbi = [
|
|
|
241
328
|
"internalType": "uint256"
|
|
242
329
|
}
|
|
243
330
|
],
|
|
244
|
-
"outputs": [
|
|
331
|
+
"outputs": [
|
|
332
|
+
{
|
|
333
|
+
"name": "tokenFees",
|
|
334
|
+
"type": "uint256",
|
|
335
|
+
"internalType": "uint256"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"name": "paymentFees",
|
|
339
|
+
"type": "uint256",
|
|
340
|
+
"internalType": "uint256"
|
|
341
|
+
}
|
|
342
|
+
],
|
|
245
343
|
"stateMutability": "nonpayable"
|
|
246
344
|
},
|
|
247
345
|
{
|
|
248
346
|
"type": "function",
|
|
249
347
|
"name": "createAuction",
|
|
348
|
+
"inputs": [
|
|
349
|
+
{
|
|
350
|
+
"name": "p",
|
|
351
|
+
"type": "tuple",
|
|
352
|
+
"internalType": "struct TokenAuction.AuctionParams",
|
|
353
|
+
"components": [
|
|
354
|
+
{
|
|
355
|
+
"name": "name",
|
|
356
|
+
"type": "string",
|
|
357
|
+
"internalType": "string"
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"name": "symbol",
|
|
361
|
+
"type": "string",
|
|
362
|
+
"internalType": "string"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"name": "metadataURI",
|
|
366
|
+
"type": "string",
|
|
367
|
+
"internalType": "string"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
"name": "maxSupply",
|
|
371
|
+
"type": "uint256",
|
|
372
|
+
"internalType": "uint256"
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"name": "paymentToken",
|
|
376
|
+
"type": "address",
|
|
377
|
+
"internalType": "address"
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
"name": "basePrice",
|
|
381
|
+
"type": "uint256",
|
|
382
|
+
"internalType": "uint256"
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"name": "slope",
|
|
386
|
+
"type": "uint256",
|
|
387
|
+
"internalType": "uint256"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"name": "maxRaise",
|
|
391
|
+
"type": "uint256",
|
|
392
|
+
"internalType": "uint256"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"name": "liquidityBps",
|
|
396
|
+
"type": "uint256",
|
|
397
|
+
"internalType": "uint256"
|
|
398
|
+
}
|
|
399
|
+
]
|
|
400
|
+
}
|
|
401
|
+
],
|
|
402
|
+
"outputs": [
|
|
403
|
+
{
|
|
404
|
+
"name": "auctionId",
|
|
405
|
+
"type": "uint256",
|
|
406
|
+
"internalType": "uint256"
|
|
407
|
+
}
|
|
408
|
+
],
|
|
409
|
+
"stateMutability": "nonpayable"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"type": "function",
|
|
413
|
+
"name": "custodied",
|
|
414
|
+
"inputs": [
|
|
415
|
+
{
|
|
416
|
+
"name": "",
|
|
417
|
+
"type": "address",
|
|
418
|
+
"internalType": "address"
|
|
419
|
+
}
|
|
420
|
+
],
|
|
421
|
+
"outputs": [
|
|
422
|
+
{
|
|
423
|
+
"name": "",
|
|
424
|
+
"type": "uint256",
|
|
425
|
+
"internalType": "uint256"
|
|
426
|
+
}
|
|
427
|
+
],
|
|
428
|
+
"stateMutability": "view"
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
"type": "function",
|
|
432
|
+
"name": "defaultFeeBps",
|
|
433
|
+
"inputs": [],
|
|
434
|
+
"outputs": [
|
|
435
|
+
{
|
|
436
|
+
"name": "",
|
|
437
|
+
"type": "uint256",
|
|
438
|
+
"internalType": "uint256"
|
|
439
|
+
}
|
|
440
|
+
],
|
|
441
|
+
"stateMutability": "view"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"type": "function",
|
|
445
|
+
"name": "defaultLpFeeShareBps",
|
|
446
|
+
"inputs": [],
|
|
447
|
+
"outputs": [
|
|
448
|
+
{
|
|
449
|
+
"name": "",
|
|
450
|
+
"type": "uint256",
|
|
451
|
+
"internalType": "uint256"
|
|
452
|
+
}
|
|
453
|
+
],
|
|
454
|
+
"stateMutability": "view"
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
"type": "function",
|
|
458
|
+
"name": "getBuyCost",
|
|
459
|
+
"inputs": [
|
|
460
|
+
{
|
|
461
|
+
"name": "auctionId",
|
|
462
|
+
"type": "uint256",
|
|
463
|
+
"internalType": "uint256"
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
"name": "amount",
|
|
467
|
+
"type": "uint256",
|
|
468
|
+
"internalType": "uint256"
|
|
469
|
+
}
|
|
470
|
+
],
|
|
471
|
+
"outputs": [
|
|
472
|
+
{
|
|
473
|
+
"name": "cost",
|
|
474
|
+
"type": "uint256",
|
|
475
|
+
"internalType": "uint256"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"name": "fee",
|
|
479
|
+
"type": "uint256",
|
|
480
|
+
"internalType": "uint256"
|
|
481
|
+
}
|
|
482
|
+
],
|
|
483
|
+
"stateMutability": "view"
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
"type": "function",
|
|
487
|
+
"name": "getSpotPrice",
|
|
488
|
+
"inputs": [
|
|
489
|
+
{
|
|
490
|
+
"name": "auctionId",
|
|
491
|
+
"type": "uint256",
|
|
492
|
+
"internalType": "uint256"
|
|
493
|
+
}
|
|
494
|
+
],
|
|
495
|
+
"outputs": [
|
|
496
|
+
{
|
|
497
|
+
"name": "",
|
|
498
|
+
"type": "uint256",
|
|
499
|
+
"internalType": "uint256"
|
|
500
|
+
}
|
|
501
|
+
],
|
|
502
|
+
"stateMutability": "view"
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
"type": "function",
|
|
506
|
+
"name": "launch",
|
|
250
507
|
"inputs": [
|
|
251
508
|
{
|
|
252
509
|
"name": "name",
|
|
@@ -259,98 +516,109 @@ var tokenAuctionAbi = [
|
|
|
259
516
|
"internalType": "string"
|
|
260
517
|
},
|
|
261
518
|
{
|
|
262
|
-
"name": "
|
|
519
|
+
"name": "metadataURI",
|
|
520
|
+
"type": "string",
|
|
521
|
+
"internalType": "string"
|
|
522
|
+
}
|
|
523
|
+
],
|
|
524
|
+
"outputs": [
|
|
525
|
+
{
|
|
526
|
+
"name": "auctionId",
|
|
263
527
|
"type": "uint256",
|
|
264
528
|
"internalType": "uint256"
|
|
265
|
-
}
|
|
529
|
+
}
|
|
530
|
+
],
|
|
531
|
+
"stateMutability": "nonpayable"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
"type": "function",
|
|
535
|
+
"name": "launchPreset",
|
|
536
|
+
"inputs": [],
|
|
537
|
+
"outputs": [
|
|
266
538
|
{
|
|
267
539
|
"name": "paymentToken",
|
|
268
540
|
"type": "address",
|
|
269
541
|
"internalType": "address"
|
|
270
542
|
},
|
|
271
543
|
{
|
|
272
|
-
"name": "
|
|
544
|
+
"name": "maxSupply",
|
|
273
545
|
"type": "uint256",
|
|
274
546
|
"internalType": "uint256"
|
|
275
547
|
},
|
|
276
548
|
{
|
|
277
|
-
"name": "
|
|
549
|
+
"name": "basePrice",
|
|
278
550
|
"type": "uint256",
|
|
279
551
|
"internalType": "uint256"
|
|
280
552
|
},
|
|
281
553
|
{
|
|
282
|
-
"name": "
|
|
554
|
+
"name": "slope",
|
|
283
555
|
"type": "uint256",
|
|
284
556
|
"internalType": "uint256"
|
|
285
557
|
},
|
|
286
558
|
{
|
|
287
|
-
"name": "
|
|
559
|
+
"name": "maxRaise",
|
|
288
560
|
"type": "uint256",
|
|
289
561
|
"internalType": "uint256"
|
|
290
562
|
},
|
|
291
563
|
{
|
|
292
|
-
"name": "
|
|
564
|
+
"name": "liquidityBps",
|
|
293
565
|
"type": "uint256",
|
|
294
566
|
"internalType": "uint256"
|
|
295
567
|
}
|
|
296
568
|
],
|
|
297
|
-
"
|
|
569
|
+
"stateMutability": "view"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"type": "function",
|
|
573
|
+
"name": "migrate",
|
|
574
|
+
"inputs": [
|
|
298
575
|
{
|
|
299
576
|
"name": "auctionId",
|
|
300
577
|
"type": "uint256",
|
|
301
578
|
"internalType": "uint256"
|
|
302
579
|
}
|
|
303
580
|
],
|
|
581
|
+
"outputs": [],
|
|
304
582
|
"stateMutability": "nonpayable"
|
|
305
583
|
},
|
|
306
584
|
{
|
|
307
585
|
"type": "function",
|
|
308
|
-
"name": "
|
|
586
|
+
"name": "owner",
|
|
309
587
|
"inputs": [],
|
|
310
588
|
"outputs": [
|
|
311
589
|
{
|
|
312
590
|
"name": "",
|
|
313
|
-
"type": "
|
|
314
|
-
"internalType": "
|
|
591
|
+
"type": "address",
|
|
592
|
+
"internalType": "address"
|
|
315
593
|
}
|
|
316
594
|
],
|
|
317
595
|
"stateMutability": "view"
|
|
318
596
|
},
|
|
319
597
|
{
|
|
320
598
|
"type": "function",
|
|
321
|
-
"name": "
|
|
599
|
+
"name": "poolOf",
|
|
322
600
|
"inputs": [
|
|
323
601
|
{
|
|
324
|
-
"name": "
|
|
325
|
-
"type": "uint256",
|
|
326
|
-
"internalType": "uint256"
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
"name": "amount",
|
|
602
|
+
"name": "",
|
|
330
603
|
"type": "uint256",
|
|
331
604
|
"internalType": "uint256"
|
|
332
605
|
}
|
|
333
606
|
],
|
|
334
607
|
"outputs": [
|
|
335
608
|
{
|
|
336
|
-
"name": "
|
|
337
|
-
"type": "
|
|
338
|
-
"internalType": "
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
"name": "fee",
|
|
342
|
-
"type": "uint256",
|
|
343
|
-
"internalType": "uint256"
|
|
609
|
+
"name": "",
|
|
610
|
+
"type": "address",
|
|
611
|
+
"internalType": "address"
|
|
344
612
|
}
|
|
345
613
|
],
|
|
346
614
|
"stateMutability": "view"
|
|
347
615
|
},
|
|
348
616
|
{
|
|
349
617
|
"type": "function",
|
|
350
|
-
"name": "
|
|
618
|
+
"name": "positionId",
|
|
351
619
|
"inputs": [
|
|
352
620
|
{
|
|
353
|
-
"name": "
|
|
621
|
+
"name": "",
|
|
354
622
|
"type": "uint256",
|
|
355
623
|
"internalType": "uint256"
|
|
356
624
|
}
|
|
@@ -366,13 +634,13 @@ var tokenAuctionAbi = [
|
|
|
366
634
|
},
|
|
367
635
|
{
|
|
368
636
|
"type": "function",
|
|
369
|
-
"name": "
|
|
637
|
+
"name": "positionManager",
|
|
370
638
|
"inputs": [],
|
|
371
639
|
"outputs": [
|
|
372
640
|
{
|
|
373
641
|
"name": "",
|
|
374
642
|
"type": "address",
|
|
375
|
-
"internalType": "
|
|
643
|
+
"internalType": "contract INonfungiblePositionManager"
|
|
376
644
|
}
|
|
377
645
|
],
|
|
378
646
|
"stateMutability": "view"
|
|
@@ -416,6 +684,131 @@ var tokenAuctionAbi = [
|
|
|
416
684
|
"outputs": [],
|
|
417
685
|
"stateMutability": "nonpayable"
|
|
418
686
|
},
|
|
687
|
+
{
|
|
688
|
+
"type": "function",
|
|
689
|
+
"name": "sellTokens",
|
|
690
|
+
"inputs": [
|
|
691
|
+
{
|
|
692
|
+
"name": "auctionId",
|
|
693
|
+
"type": "uint256",
|
|
694
|
+
"internalType": "uint256"
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
"name": "amount",
|
|
698
|
+
"type": "uint256",
|
|
699
|
+
"internalType": "uint256"
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
"name": "minProceeds",
|
|
703
|
+
"type": "uint256",
|
|
704
|
+
"internalType": "uint256"
|
|
705
|
+
}
|
|
706
|
+
],
|
|
707
|
+
"outputs": [],
|
|
708
|
+
"stateMutability": "nonpayable"
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
"type": "function",
|
|
712
|
+
"name": "setDefaultFeeBps",
|
|
713
|
+
"inputs": [
|
|
714
|
+
{
|
|
715
|
+
"name": "feeBps",
|
|
716
|
+
"type": "uint256",
|
|
717
|
+
"internalType": "uint256"
|
|
718
|
+
}
|
|
719
|
+
],
|
|
720
|
+
"outputs": [],
|
|
721
|
+
"stateMutability": "nonpayable"
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
"type": "function",
|
|
725
|
+
"name": "setDefaultLpFeeShareBps",
|
|
726
|
+
"inputs": [
|
|
727
|
+
{
|
|
728
|
+
"name": "shareBps",
|
|
729
|
+
"type": "uint256",
|
|
730
|
+
"internalType": "uint256"
|
|
731
|
+
}
|
|
732
|
+
],
|
|
733
|
+
"outputs": [],
|
|
734
|
+
"stateMutability": "nonpayable"
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
"type": "function",
|
|
738
|
+
"name": "setLaunchPreset",
|
|
739
|
+
"inputs": [
|
|
740
|
+
{
|
|
741
|
+
"name": "preset",
|
|
742
|
+
"type": "tuple",
|
|
743
|
+
"internalType": "struct TokenAuction.LaunchPreset",
|
|
744
|
+
"components": [
|
|
745
|
+
{
|
|
746
|
+
"name": "paymentToken",
|
|
747
|
+
"type": "address",
|
|
748
|
+
"internalType": "address"
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
"name": "maxSupply",
|
|
752
|
+
"type": "uint256",
|
|
753
|
+
"internalType": "uint256"
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
"name": "basePrice",
|
|
757
|
+
"type": "uint256",
|
|
758
|
+
"internalType": "uint256"
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
"name": "slope",
|
|
762
|
+
"type": "uint256",
|
|
763
|
+
"internalType": "uint256"
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
"name": "maxRaise",
|
|
767
|
+
"type": "uint256",
|
|
768
|
+
"internalType": "uint256"
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
"name": "liquidityBps",
|
|
772
|
+
"type": "uint256",
|
|
773
|
+
"internalType": "uint256"
|
|
774
|
+
}
|
|
775
|
+
]
|
|
776
|
+
}
|
|
777
|
+
],
|
|
778
|
+
"outputs": [],
|
|
779
|
+
"stateMutability": "nonpayable"
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
"type": "function",
|
|
783
|
+
"name": "setProtocolFeeRecipient",
|
|
784
|
+
"inputs": [
|
|
785
|
+
{
|
|
786
|
+
"name": "recipient",
|
|
787
|
+
"type": "address",
|
|
788
|
+
"internalType": "address"
|
|
789
|
+
}
|
|
790
|
+
],
|
|
791
|
+
"outputs": [],
|
|
792
|
+
"stateMutability": "nonpayable"
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
"type": "function",
|
|
796
|
+
"name": "sweep",
|
|
797
|
+
"inputs": [
|
|
798
|
+
{
|
|
799
|
+
"name": "token",
|
|
800
|
+
"type": "address",
|
|
801
|
+
"internalType": "contract IERC20"
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
"name": "to",
|
|
805
|
+
"type": "address",
|
|
806
|
+
"internalType": "address"
|
|
807
|
+
}
|
|
808
|
+
],
|
|
809
|
+
"outputs": [],
|
|
810
|
+
"stateMutability": "nonpayable"
|
|
811
|
+
},
|
|
419
812
|
{
|
|
420
813
|
"type": "function",
|
|
421
814
|
"name": "transferOwnership",
|
|
@@ -429,46 +822,155 @@ var tokenAuctionAbi = [
|
|
|
429
822
|
"outputs": [],
|
|
430
823
|
"stateMutability": "nonpayable"
|
|
431
824
|
},
|
|
825
|
+
{
|
|
826
|
+
"type": "function",
|
|
827
|
+
"name": "uniswapV3SwapCallback",
|
|
828
|
+
"inputs": [
|
|
829
|
+
{
|
|
830
|
+
"name": "amount0Delta",
|
|
831
|
+
"type": "int256",
|
|
832
|
+
"internalType": "int256"
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
"name": "amount1Delta",
|
|
836
|
+
"type": "int256",
|
|
837
|
+
"internalType": "int256"
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
"name": "data",
|
|
841
|
+
"type": "bytes",
|
|
842
|
+
"internalType": "bytes"
|
|
843
|
+
}
|
|
844
|
+
],
|
|
845
|
+
"outputs": [],
|
|
846
|
+
"stateMutability": "nonpayable"
|
|
847
|
+
},
|
|
432
848
|
{
|
|
433
849
|
"type": "function",
|
|
434
850
|
"name": "userPurchases",
|
|
435
851
|
"inputs": [
|
|
436
852
|
{
|
|
437
|
-
"name": "",
|
|
853
|
+
"name": "",
|
|
854
|
+
"type": "uint256",
|
|
855
|
+
"internalType": "uint256"
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
"name": "",
|
|
859
|
+
"type": "address",
|
|
860
|
+
"internalType": "address"
|
|
861
|
+
}
|
|
862
|
+
],
|
|
863
|
+
"outputs": [
|
|
864
|
+
{
|
|
865
|
+
"name": "",
|
|
866
|
+
"type": "uint256",
|
|
867
|
+
"internalType": "uint256"
|
|
868
|
+
}
|
|
869
|
+
],
|
|
870
|
+
"stateMutability": "view"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
"type": "function",
|
|
874
|
+
"name": "withdrawProceeds",
|
|
875
|
+
"inputs": [
|
|
876
|
+
{
|
|
877
|
+
"name": "auctionId",
|
|
878
|
+
"type": "uint256",
|
|
879
|
+
"internalType": "uint256"
|
|
880
|
+
}
|
|
881
|
+
],
|
|
882
|
+
"outputs": [],
|
|
883
|
+
"stateMutability": "nonpayable"
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
"type": "event",
|
|
887
|
+
"name": "AuctionCompleted",
|
|
888
|
+
"inputs": [
|
|
889
|
+
{
|
|
890
|
+
"name": "auctionId",
|
|
891
|
+
"type": "uint256",
|
|
892
|
+
"indexed": true,
|
|
893
|
+
"internalType": "uint256"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"name": "totalRaised",
|
|
897
|
+
"type": "uint256",
|
|
898
|
+
"indexed": false,
|
|
899
|
+
"internalType": "uint256"
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
"name": "totalSold",
|
|
903
|
+
"type": "uint256",
|
|
904
|
+
"indexed": false,
|
|
905
|
+
"internalType": "uint256"
|
|
906
|
+
}
|
|
907
|
+
],
|
|
908
|
+
"anonymous": false
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
"type": "event",
|
|
912
|
+
"name": "AuctionCreated",
|
|
913
|
+
"inputs": [
|
|
914
|
+
{
|
|
915
|
+
"name": "auctionId",
|
|
916
|
+
"type": "uint256",
|
|
917
|
+
"indexed": true,
|
|
918
|
+
"internalType": "uint256"
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
"name": "creator",
|
|
922
|
+
"type": "address",
|
|
923
|
+
"indexed": true,
|
|
924
|
+
"internalType": "address"
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
"name": "token",
|
|
928
|
+
"type": "address",
|
|
929
|
+
"indexed": false,
|
|
930
|
+
"internalType": "address"
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
"name": "paymentToken",
|
|
934
|
+
"type": "address",
|
|
935
|
+
"indexed": false,
|
|
936
|
+
"internalType": "address"
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
"name": "basePrice",
|
|
438
940
|
"type": "uint256",
|
|
941
|
+
"indexed": false,
|
|
439
942
|
"internalType": "uint256"
|
|
440
943
|
},
|
|
441
944
|
{
|
|
442
|
-
"name": "",
|
|
443
|
-
"type": "
|
|
444
|
-
"
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
"outputs": [
|
|
945
|
+
"name": "slope",
|
|
946
|
+
"type": "uint256",
|
|
947
|
+
"indexed": false,
|
|
948
|
+
"internalType": "uint256"
|
|
949
|
+
},
|
|
448
950
|
{
|
|
449
|
-
"name": "",
|
|
951
|
+
"name": "maxRaise",
|
|
450
952
|
"type": "uint256",
|
|
953
|
+
"indexed": false,
|
|
451
954
|
"internalType": "uint256"
|
|
452
|
-
}
|
|
453
|
-
],
|
|
454
|
-
"stateMutability": "view"
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
"type": "function",
|
|
458
|
-
"name": "withdrawProceeds",
|
|
459
|
-
"inputs": [
|
|
955
|
+
},
|
|
460
956
|
{
|
|
461
|
-
"name": "
|
|
957
|
+
"name": "liquidityBps",
|
|
462
958
|
"type": "uint256",
|
|
959
|
+
"indexed": false,
|
|
463
960
|
"internalType": "uint256"
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
"name": "metadataURI",
|
|
964
|
+
"type": "string",
|
|
965
|
+
"indexed": false,
|
|
966
|
+
"internalType": "string"
|
|
464
967
|
}
|
|
465
968
|
],
|
|
466
|
-
"
|
|
467
|
-
"stateMutability": "nonpayable"
|
|
969
|
+
"anonymous": false
|
|
468
970
|
},
|
|
469
971
|
{
|
|
470
972
|
"type": "event",
|
|
471
|
-
"name": "
|
|
973
|
+
"name": "AuctionMigrated",
|
|
472
974
|
"inputs": [
|
|
473
975
|
{
|
|
474
976
|
"name": "auctionId",
|
|
@@ -477,13 +979,25 @@ var tokenAuctionAbi = [
|
|
|
477
979
|
"internalType": "uint256"
|
|
478
980
|
},
|
|
479
981
|
{
|
|
480
|
-
"name": "
|
|
982
|
+
"name": "pool",
|
|
983
|
+
"type": "address",
|
|
984
|
+
"indexed": false,
|
|
985
|
+
"internalType": "address"
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
"name": "positionId",
|
|
481
989
|
"type": "uint256",
|
|
482
990
|
"indexed": false,
|
|
483
991
|
"internalType": "uint256"
|
|
484
992
|
},
|
|
485
993
|
{
|
|
486
|
-
"name": "
|
|
994
|
+
"name": "tokenLiquidity",
|
|
995
|
+
"type": "uint256",
|
|
996
|
+
"indexed": false,
|
|
997
|
+
"internalType": "uint256"
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
"name": "paymentLiquidity",
|
|
487
1001
|
"type": "uint256",
|
|
488
1002
|
"indexed": false,
|
|
489
1003
|
"internalType": "uint256"
|
|
@@ -493,26 +1007,46 @@ var tokenAuctionAbi = [
|
|
|
493
1007
|
},
|
|
494
1008
|
{
|
|
495
1009
|
"type": "event",
|
|
496
|
-
"name": "
|
|
1010
|
+
"name": "DefaultFeeBpsUpdated",
|
|
497
1011
|
"inputs": [
|
|
498
1012
|
{
|
|
499
|
-
"name": "
|
|
1013
|
+
"name": "previous",
|
|
500
1014
|
"type": "uint256",
|
|
501
|
-
"indexed":
|
|
1015
|
+
"indexed": false,
|
|
502
1016
|
"internalType": "uint256"
|
|
503
1017
|
},
|
|
504
1018
|
{
|
|
505
|
-
"name": "
|
|
506
|
-
"type": "
|
|
507
|
-
"indexed":
|
|
508
|
-
"internalType": "
|
|
509
|
-
}
|
|
1019
|
+
"name": "current",
|
|
1020
|
+
"type": "uint256",
|
|
1021
|
+
"indexed": false,
|
|
1022
|
+
"internalType": "uint256"
|
|
1023
|
+
}
|
|
1024
|
+
],
|
|
1025
|
+
"anonymous": false
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
"type": "event",
|
|
1029
|
+
"name": "DefaultLpFeeShareBpsUpdated",
|
|
1030
|
+
"inputs": [
|
|
510
1031
|
{
|
|
511
|
-
"name": "
|
|
512
|
-
"type": "
|
|
1032
|
+
"name": "previous",
|
|
1033
|
+
"type": "uint256",
|
|
513
1034
|
"indexed": false,
|
|
514
|
-
"internalType": "
|
|
1035
|
+
"internalType": "uint256"
|
|
515
1036
|
},
|
|
1037
|
+
{
|
|
1038
|
+
"name": "current",
|
|
1039
|
+
"type": "uint256",
|
|
1040
|
+
"indexed": false,
|
|
1041
|
+
"internalType": "uint256"
|
|
1042
|
+
}
|
|
1043
|
+
],
|
|
1044
|
+
"anonymous": false
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
"type": "event",
|
|
1048
|
+
"name": "LaunchPresetUpdated",
|
|
1049
|
+
"inputs": [
|
|
516
1050
|
{
|
|
517
1051
|
"name": "paymentToken",
|
|
518
1052
|
"type": "address",
|
|
@@ -520,31 +1054,31 @@ var tokenAuctionAbi = [
|
|
|
520
1054
|
"internalType": "address"
|
|
521
1055
|
},
|
|
522
1056
|
{
|
|
523
|
-
"name": "
|
|
1057
|
+
"name": "maxSupply",
|
|
524
1058
|
"type": "uint256",
|
|
525
1059
|
"indexed": false,
|
|
526
1060
|
"internalType": "uint256"
|
|
527
1061
|
},
|
|
528
1062
|
{
|
|
529
|
-
"name": "
|
|
1063
|
+
"name": "basePrice",
|
|
530
1064
|
"type": "uint256",
|
|
531
1065
|
"indexed": false,
|
|
532
1066
|
"internalType": "uint256"
|
|
533
1067
|
},
|
|
534
1068
|
{
|
|
535
|
-
"name": "
|
|
1069
|
+
"name": "slope",
|
|
536
1070
|
"type": "uint256",
|
|
537
1071
|
"indexed": false,
|
|
538
1072
|
"internalType": "uint256"
|
|
539
1073
|
},
|
|
540
1074
|
{
|
|
541
|
-
"name": "
|
|
1075
|
+
"name": "maxRaise",
|
|
542
1076
|
"type": "uint256",
|
|
543
1077
|
"indexed": false,
|
|
544
1078
|
"internalType": "uint256"
|
|
545
1079
|
},
|
|
546
1080
|
{
|
|
547
|
-
"name": "
|
|
1081
|
+
"name": "liquidityBps",
|
|
548
1082
|
"type": "uint256",
|
|
549
1083
|
"indexed": false,
|
|
550
1084
|
"internalType": "uint256"
|
|
@@ -554,7 +1088,7 @@ var tokenAuctionAbi = [
|
|
|
554
1088
|
},
|
|
555
1089
|
{
|
|
556
1090
|
"type": "event",
|
|
557
|
-
"name": "
|
|
1091
|
+
"name": "LpFeesCollected",
|
|
558
1092
|
"inputs": [
|
|
559
1093
|
{
|
|
560
1094
|
"name": "auctionId",
|
|
@@ -563,10 +1097,28 @@ var tokenAuctionAbi = [
|
|
|
563
1097
|
"internalType": "uint256"
|
|
564
1098
|
},
|
|
565
1099
|
{
|
|
566
|
-
"name": "
|
|
567
|
-
"type": "
|
|
1100
|
+
"name": "creatorTokenFees",
|
|
1101
|
+
"type": "uint256",
|
|
568
1102
|
"indexed": false,
|
|
569
|
-
"internalType": "
|
|
1103
|
+
"internalType": "uint256"
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
"name": "creatorPaymentFees",
|
|
1107
|
+
"type": "uint256",
|
|
1108
|
+
"indexed": false,
|
|
1109
|
+
"internalType": "uint256"
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
"name": "protocolTokenFees",
|
|
1113
|
+
"type": "uint256",
|
|
1114
|
+
"indexed": false,
|
|
1115
|
+
"internalType": "uint256"
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
"name": "protocolPaymentFees",
|
|
1119
|
+
"type": "uint256",
|
|
1120
|
+
"indexed": false,
|
|
1121
|
+
"internalType": "uint256"
|
|
570
1122
|
}
|
|
571
1123
|
],
|
|
572
1124
|
"anonymous": false
|
|
@@ -615,6 +1167,50 @@ var tokenAuctionAbi = [
|
|
|
615
1167
|
],
|
|
616
1168
|
"anonymous": false
|
|
617
1169
|
},
|
|
1170
|
+
{
|
|
1171
|
+
"type": "event",
|
|
1172
|
+
"name": "ProtocolFeeRecipientUpdated",
|
|
1173
|
+
"inputs": [
|
|
1174
|
+
{
|
|
1175
|
+
"name": "previous",
|
|
1176
|
+
"type": "address",
|
|
1177
|
+
"indexed": true,
|
|
1178
|
+
"internalType": "address"
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
"name": "current",
|
|
1182
|
+
"type": "address",
|
|
1183
|
+
"indexed": true,
|
|
1184
|
+
"internalType": "address"
|
|
1185
|
+
}
|
|
1186
|
+
],
|
|
1187
|
+
"anonymous": false
|
|
1188
|
+
},
|
|
1189
|
+
{
|
|
1190
|
+
"type": "event",
|
|
1191
|
+
"name": "Swept",
|
|
1192
|
+
"inputs": [
|
|
1193
|
+
{
|
|
1194
|
+
"name": "token",
|
|
1195
|
+
"type": "address",
|
|
1196
|
+
"indexed": true,
|
|
1197
|
+
"internalType": "address"
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
"name": "to",
|
|
1201
|
+
"type": "address",
|
|
1202
|
+
"indexed": true,
|
|
1203
|
+
"internalType": "address"
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
"name": "amount",
|
|
1207
|
+
"type": "uint256",
|
|
1208
|
+
"indexed": false,
|
|
1209
|
+
"internalType": "uint256"
|
|
1210
|
+
}
|
|
1211
|
+
],
|
|
1212
|
+
"anonymous": false
|
|
1213
|
+
},
|
|
618
1214
|
{
|
|
619
1215
|
"type": "event",
|
|
620
1216
|
"name": "TokensPurchased",
|
|
@@ -664,6 +1260,55 @@ var tokenAuctionAbi = [
|
|
|
664
1260
|
],
|
|
665
1261
|
"anonymous": false
|
|
666
1262
|
},
|
|
1263
|
+
{
|
|
1264
|
+
"type": "event",
|
|
1265
|
+
"name": "TokensSold",
|
|
1266
|
+
"inputs": [
|
|
1267
|
+
{
|
|
1268
|
+
"name": "auctionId",
|
|
1269
|
+
"type": "uint256",
|
|
1270
|
+
"indexed": true,
|
|
1271
|
+
"internalType": "uint256"
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
"name": "seller",
|
|
1275
|
+
"type": "address",
|
|
1276
|
+
"indexed": true,
|
|
1277
|
+
"internalType": "address"
|
|
1278
|
+
},
|
|
1279
|
+
{
|
|
1280
|
+
"name": "amount",
|
|
1281
|
+
"type": "uint256",
|
|
1282
|
+
"indexed": false,
|
|
1283
|
+
"internalType": "uint256"
|
|
1284
|
+
},
|
|
1285
|
+
{
|
|
1286
|
+
"name": "proceeds",
|
|
1287
|
+
"type": "uint256",
|
|
1288
|
+
"indexed": false,
|
|
1289
|
+
"internalType": "uint256"
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
"name": "protocolFee",
|
|
1293
|
+
"type": "uint256",
|
|
1294
|
+
"indexed": false,
|
|
1295
|
+
"internalType": "uint256"
|
|
1296
|
+
},
|
|
1297
|
+
{
|
|
1298
|
+
"name": "newTotalRaised",
|
|
1299
|
+
"type": "uint256",
|
|
1300
|
+
"indexed": false,
|
|
1301
|
+
"internalType": "uint256"
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
"name": "newTotalSold",
|
|
1305
|
+
"type": "uint256",
|
|
1306
|
+
"indexed": false,
|
|
1307
|
+
"internalType": "uint256"
|
|
1308
|
+
}
|
|
1309
|
+
],
|
|
1310
|
+
"anonymous": false
|
|
1311
|
+
},
|
|
667
1312
|
{
|
|
668
1313
|
"type": "error",
|
|
669
1314
|
"name": "OwnableInvalidOwner",
|
|
@@ -705,12 +1350,32 @@ var tokenAuctionAbi = [
|
|
|
705
1350
|
];
|
|
706
1351
|
|
|
707
1352
|
// src/utils/bonding-curve.ts
|
|
1353
|
+
var import_viem = require("viem");
|
|
708
1354
|
var TOKEN_SCALE = 10n ** 18n;
|
|
1355
|
+
var PRICE_SCALE = 10n ** 18n;
|
|
1356
|
+
var SCALE = TOKEN_SCALE * PRICE_SCALE;
|
|
1357
|
+
function parseCurvePrice(price, paymentDecimals) {
|
|
1358
|
+
return (0, import_viem.parseUnits)(price, paymentDecimals + 18);
|
|
1359
|
+
}
|
|
1360
|
+
function formatCurvePrice(price, paymentDecimals) {
|
|
1361
|
+
return (0, import_viem.formatUnits)(price, paymentDecimals + 18);
|
|
1362
|
+
}
|
|
1363
|
+
var ceilDiv = (a, b) => (a + b - 1n) / b;
|
|
709
1364
|
function calculateBuyCost(currentSupply, amount, basePrice, slope) {
|
|
710
|
-
const linearCost = basePrice * amount
|
|
711
|
-
const curveCost =
|
|
1365
|
+
const linearCost = ceilDiv(basePrice * amount, SCALE);
|
|
1366
|
+
const curveCost = ceilDiv(
|
|
1367
|
+
slope * amount * (2n * currentSupply + amount),
|
|
1368
|
+
2n * SCALE * TOKEN_SCALE
|
|
1369
|
+
);
|
|
712
1370
|
return linearCost + curveCost;
|
|
713
1371
|
}
|
|
1372
|
+
function calculateSellProceeds(currentSupply, amount, basePrice, slope) {
|
|
1373
|
+
if (amount > currentSupply) throw new Error("Cannot sell more than is outstanding");
|
|
1374
|
+
const from = currentSupply - amount;
|
|
1375
|
+
const linear = basePrice * amount / SCALE;
|
|
1376
|
+
const curve = slope * amount * (2n * from + amount) / (2n * SCALE * TOKEN_SCALE);
|
|
1377
|
+
return linear + curve;
|
|
1378
|
+
}
|
|
714
1379
|
function spotPrice(currentSupply, basePrice, slope) {
|
|
715
1380
|
return basePrice + slope * currentSupply / TOKEN_SCALE;
|
|
716
1381
|
}
|
|
@@ -724,6 +1389,43 @@ function calculateBuyQuote(currentSupply, amount, basePrice, slope, feeBps) {
|
|
|
724
1389
|
spotPriceAfter: spotPrice(currentSupply + amount, basePrice, slope)
|
|
725
1390
|
};
|
|
726
1391
|
}
|
|
1392
|
+
var DEFAULT_SLIPPAGE_BPS = 100;
|
|
1393
|
+
function applySlippage(total, slippageBps) {
|
|
1394
|
+
if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > 1e4) {
|
|
1395
|
+
throw new Error("slippageBps must be an integer between 0 and 10000");
|
|
1396
|
+
}
|
|
1397
|
+
return (total * BigInt(1e4 + slippageBps) + 9999n) / 10000n;
|
|
1398
|
+
}
|
|
1399
|
+
function maxBuyable(currentSupply, budget, basePrice, slope, upperBound) {
|
|
1400
|
+
let hi = budget * SCALE / basePrice + 1n;
|
|
1401
|
+
if (hi > upperBound) hi = upperBound;
|
|
1402
|
+
let lo = 0n;
|
|
1403
|
+
while (lo < hi) {
|
|
1404
|
+
const mid = (lo + hi + 1n) / 2n;
|
|
1405
|
+
if (calculateBuyCost(currentSupply, mid, basePrice, slope) <= budget) lo = mid;
|
|
1406
|
+
else hi = mid - 1n;
|
|
1407
|
+
}
|
|
1408
|
+
return lo;
|
|
1409
|
+
}
|
|
1410
|
+
function fillPurchase(currentSupply, requested, basePrice, slope, totalRaised, maxRaise) {
|
|
1411
|
+
const remaining = maxRaise - totalRaised;
|
|
1412
|
+
const cost = calculateBuyCost(currentSupply, requested, basePrice, slope);
|
|
1413
|
+
if (cost < remaining) return { amount: requested, cost, fillsAuction: false };
|
|
1414
|
+
if (cost === remaining) return { amount: requested, cost, fillsAuction: true };
|
|
1415
|
+
const amount = maxBuyable(currentSupply, remaining, basePrice, slope, requested);
|
|
1416
|
+
if (amount === 0n) throw new Error("Auction is sold out");
|
|
1417
|
+
return {
|
|
1418
|
+
amount,
|
|
1419
|
+
cost: calculateBuyCost(currentSupply, amount, basePrice, slope),
|
|
1420
|
+
fillsAuction: true
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
function applySellSlippage(netProceeds, slippageBps) {
|
|
1424
|
+
if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > 1e4) {
|
|
1425
|
+
throw new Error("slippageBps must be an integer between 0 and 10000");
|
|
1426
|
+
}
|
|
1427
|
+
return netProceeds * BigInt(1e4 - slippageBps) / 10000n;
|
|
1428
|
+
}
|
|
727
1429
|
|
|
728
1430
|
// src/utils/chains.ts
|
|
729
1431
|
var import_chains = require("viem/chains");
|
|
@@ -743,19 +1445,19 @@ var AuctionFlowSDK = class {
|
|
|
743
1445
|
this.chainId = params.chainId;
|
|
744
1446
|
this.chain = CHAINS[params.chainId];
|
|
745
1447
|
this.auctionAddress = params.auctionAddress ?? AUCTION_ADDRESSES[params.chainId];
|
|
746
|
-
if (params.auctionAddress ===
|
|
1448
|
+
if (params.auctionAddress === import_viem2.zeroAddress) {
|
|
747
1449
|
throw new Error(
|
|
748
1450
|
"auctionAddress must not be the zero address."
|
|
749
1451
|
);
|
|
750
1452
|
}
|
|
751
|
-
if (this.auctionAddress ===
|
|
1453
|
+
if (this.auctionAddress === import_viem2.zeroAddress) {
|
|
752
1454
|
throw new Error(
|
|
753
|
-
`AuctionFlow has no canonical deployment on chain ${params.chainId}. Chains with a built-in deployment: ${Object.entries(AUCTION_ADDRESSES).filter(([, addr]) => addr !==
|
|
1455
|
+
`AuctionFlow has no canonical deployment on chain ${params.chainId}. Chains with a built-in deployment: ${Object.entries(AUCTION_ADDRESSES).filter(([, addr]) => addr !== import_viem2.zeroAddress).map(([id]) => id).join(", ")}. Pass \`auctionAddress\` to use your own deployment.`
|
|
754
1456
|
);
|
|
755
1457
|
}
|
|
756
|
-
this.publicClient = (0,
|
|
1458
|
+
this.publicClient = (0, import_viem2.createPublicClient)({
|
|
757
1459
|
chain: this.chain,
|
|
758
|
-
transport: (0,
|
|
1460
|
+
transport: (0, import_viem2.http)(params.rpcUrl)
|
|
759
1461
|
});
|
|
760
1462
|
this.walletClient = params.walletClient;
|
|
761
1463
|
}
|
|
@@ -772,34 +1474,97 @@ var AuctionFlowSDK = class {
|
|
|
772
1474
|
abi: tokenAuctionAbi,
|
|
773
1475
|
functionName: "createAuction",
|
|
774
1476
|
args: [
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
1477
|
+
{
|
|
1478
|
+
name: config.name,
|
|
1479
|
+
symbol: config.symbol,
|
|
1480
|
+
metadataURI: config.metadataURI ?? "",
|
|
1481
|
+
maxSupply: config.maxSupply,
|
|
1482
|
+
paymentToken: config.paymentToken,
|
|
1483
|
+
basePrice: config.basePrice,
|
|
1484
|
+
slope: config.slope,
|
|
1485
|
+
maxRaise: config.maxRaise,
|
|
1486
|
+
liquidityBps: config.liquidityBps ?? BigInt(DEFAULT_LIQUIDITY_BPS)
|
|
1487
|
+
}
|
|
784
1488
|
]
|
|
785
1489
|
});
|
|
786
1490
|
return hash;
|
|
787
1491
|
}
|
|
788
|
-
|
|
1492
|
+
/**
|
|
1493
|
+
* One-click launch: a token with the protocol's standard curve, threshold
|
|
1494
|
+
* and liquidity share. Trading starts immediately.
|
|
1495
|
+
*/
|
|
1496
|
+
async launch(name, symbol, metadataURI = "") {
|
|
1497
|
+
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1498
|
+
return this.walletClient.writeContract({
|
|
1499
|
+
chain: this.chain,
|
|
1500
|
+
account: this.walletClient.account,
|
|
1501
|
+
address: this.auctionAddress,
|
|
1502
|
+
abi: tokenAuctionAbi,
|
|
1503
|
+
functionName: "launch",
|
|
1504
|
+
args: [name, symbol, metadataURI]
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Sell `amount` tokens (in token wei) back to the curve before graduation.
|
|
1509
|
+
* The contract reverts if the price fell below the bound before the
|
|
1510
|
+
* transaction landed: pass `minProceeds` to set it exactly, or `slippageBps`
|
|
1511
|
+
* to derive it from a fresh quote (default 100 = 1% below it).
|
|
1512
|
+
*/
|
|
1513
|
+
async sellTokens(auctionId, amount, options = {}) {
|
|
1514
|
+
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1515
|
+
const minProceeds = options.minProceeds ?? applySellSlippage(
|
|
1516
|
+
(await this.getSellQuote(auctionId, amount)).netProceeds,
|
|
1517
|
+
options.slippageBps ?? DEFAULT_SLIPPAGE_BPS
|
|
1518
|
+
);
|
|
1519
|
+
return this.walletClient.writeContract({
|
|
1520
|
+
chain: this.chain,
|
|
1521
|
+
account: this.walletClient.account,
|
|
1522
|
+
address: this.auctionAddress,
|
|
1523
|
+
abi: tokenAuctionAbi,
|
|
1524
|
+
functionName: "sellTokens",
|
|
1525
|
+
args: [auctionId, amount, minProceeds]
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
/** What selling `amount` tokens back to the curve would pay right now. */
|
|
1529
|
+
async getSellQuote(auctionId, amount) {
|
|
1530
|
+
const auction = await this.getAuction(auctionId);
|
|
1531
|
+
const proceeds = calculateSellProceeds(auction.totalSold, amount, auction.basePrice, auction.slope);
|
|
1532
|
+
const fee = proceeds * auction.protocolFeeBps / 10000n;
|
|
1533
|
+
return {
|
|
1534
|
+
proceeds,
|
|
1535
|
+
fee,
|
|
1536
|
+
netProceeds: proceeds - fee,
|
|
1537
|
+
spotPriceAfter: spotPrice(auction.totalSold - amount, auction.basePrice, auction.slope)
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Buy `amount` tokens (in token wei). The price rises with every purchase, so
|
|
1542
|
+
* the contract takes a maximum total cost and reverts if the price moved past
|
|
1543
|
+
* it before the transaction landed.
|
|
1544
|
+
*
|
|
1545
|
+
* Pass `maxCost` to set that bound exactly, or `slippageBps` to derive it
|
|
1546
|
+
* from a fresh quote (default 100 = 1% above the quoted total).
|
|
1547
|
+
*/
|
|
1548
|
+
async buyTokens(auctionId, amount, options = {}) {
|
|
789
1549
|
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1550
|
+
const maxCost = options.maxCost ?? applySlippage(
|
|
1551
|
+
(await this.getQuote(auctionId, amount)).totalCost,
|
|
1552
|
+
options.slippageBps ?? DEFAULT_SLIPPAGE_BPS
|
|
1553
|
+
);
|
|
790
1554
|
const hash = await this.walletClient.writeContract({
|
|
791
1555
|
chain: this.chain,
|
|
792
1556
|
account: this.walletClient.account,
|
|
793
1557
|
address: this.auctionAddress,
|
|
794
1558
|
abi: tokenAuctionAbi,
|
|
795
1559
|
functionName: "buyTokens",
|
|
796
|
-
args: [auctionId, amount]
|
|
1560
|
+
args: [auctionId, amount, maxCost]
|
|
797
1561
|
});
|
|
798
1562
|
return hash;
|
|
799
1563
|
}
|
|
800
1564
|
/**
|
|
801
|
-
*
|
|
802
|
-
*
|
|
1565
|
+
* Pay a completed auction's creator their share of the raise: everything
|
|
1566
|
+
* not reserved for Uniswap liquidity. Creator only, once, before or after
|
|
1567
|
+
* migration.
|
|
803
1568
|
*/
|
|
804
1569
|
async withdrawProceeds(auctionId) {
|
|
805
1570
|
if (!this.walletClient) throw new Error("Wallet client required");
|
|
@@ -813,6 +1578,53 @@ var AuctionFlowSDK = class {
|
|
|
813
1578
|
});
|
|
814
1579
|
return hash;
|
|
815
1580
|
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Move a completed auction's liquidity into a Uniswap v3 pool at the
|
|
1583
|
+
* auction's final price, lock it, and unlock the token for trading. Anyone
|
|
1584
|
+
* may call it.
|
|
1585
|
+
*/
|
|
1586
|
+
async migrate(auctionId) {
|
|
1587
|
+
return this.write("migrate", [auctionId]);
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* Collect the migrated pool's trading fees. The protocol takes its share and
|
|
1591
|
+
* the creator receives the rest. Anyone may call it.
|
|
1592
|
+
*/
|
|
1593
|
+
async collectFees(auctionId) {
|
|
1594
|
+
return this.write("collectFees", [auctionId]);
|
|
1595
|
+
}
|
|
1596
|
+
/** The Uniswap pool and position for a migrated auction. */
|
|
1597
|
+
async getMigration(auctionId) {
|
|
1598
|
+
const [pool, positionId] = await Promise.all([
|
|
1599
|
+
this.publicClient.readContract({
|
|
1600
|
+
address: this.auctionAddress,
|
|
1601
|
+
abi: tokenAuctionAbi,
|
|
1602
|
+
functionName: "poolOf",
|
|
1603
|
+
args: [auctionId]
|
|
1604
|
+
}),
|
|
1605
|
+
this.publicClient.readContract({
|
|
1606
|
+
address: this.auctionAddress,
|
|
1607
|
+
abi: tokenAuctionAbi,
|
|
1608
|
+
functionName: "positionId",
|
|
1609
|
+
args: [auctionId]
|
|
1610
|
+
})
|
|
1611
|
+
]);
|
|
1612
|
+
return {
|
|
1613
|
+
pool: pool === import_viem2.zeroAddress ? null : pool,
|
|
1614
|
+
positionId: positionId === 0n ? null : positionId
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
async write(functionName, args) {
|
|
1618
|
+
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1619
|
+
return this.walletClient.writeContract({
|
|
1620
|
+
chain: this.chain,
|
|
1621
|
+
account: this.walletClient.account,
|
|
1622
|
+
address: this.auctionAddress,
|
|
1623
|
+
abi: tokenAuctionAbi,
|
|
1624
|
+
functionName,
|
|
1625
|
+
args
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
816
1628
|
// Read: Has an auction's creator already withdrawn its proceeds?
|
|
817
1629
|
async hasWithdrawnProceeds(auctionId) {
|
|
818
1630
|
return this.publicClient.readContract({
|
|
@@ -835,18 +1647,22 @@ var AuctionFlowSDK = class {
|
|
|
835
1647
|
// Read: Get buy quote (off-chain calculation)
|
|
836
1648
|
async getQuote(auctionId, amount) {
|
|
837
1649
|
const auction = await this.getAuction(auctionId);
|
|
838
|
-
const
|
|
1650
|
+
const fill = fillPurchase(
|
|
839
1651
|
auction.totalSold,
|
|
840
1652
|
amount,
|
|
841
1653
|
auction.basePrice,
|
|
842
1654
|
auction.slope,
|
|
843
|
-
auction.
|
|
1655
|
+
auction.totalRaised,
|
|
1656
|
+
auction.maxRaise
|
|
844
1657
|
);
|
|
1658
|
+
const fee = fill.cost * auction.protocolFeeBps / 10000n;
|
|
845
1659
|
return {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
1660
|
+
amount: fill.amount,
|
|
1661
|
+
cost: fill.cost,
|
|
1662
|
+
fee,
|
|
1663
|
+
totalCost: fill.cost + fee,
|
|
1664
|
+
spotPriceAfter: spotPrice(auction.totalSold + fill.amount, auction.basePrice, auction.slope),
|
|
1665
|
+
fillsAuction: fill.fillsAuction
|
|
850
1666
|
};
|
|
851
1667
|
}
|
|
852
1668
|
// Read: Get spot price
|
|
@@ -867,12 +1683,12 @@ var AuctionFlowSDK = class {
|
|
|
867
1683
|
basePrice: raw.config.basePrice,
|
|
868
1684
|
slope: raw.config.slope,
|
|
869
1685
|
maxRaise: raw.config.maxRaise,
|
|
870
|
-
startTime: raw.config.startTime,
|
|
871
|
-
endTime: raw.config.endTime,
|
|
872
1686
|
state: raw.state,
|
|
873
1687
|
totalRaised: raw.totalRaised,
|
|
874
1688
|
totalSold: raw.totalSold,
|
|
875
|
-
protocolFeeBps: raw.config.protocolFeeBps
|
|
1689
|
+
protocolFeeBps: raw.config.protocolFeeBps,
|
|
1690
|
+
liquidityBps: raw.config.liquidityBps,
|
|
1691
|
+
lpFeeShareBps: raw.config.lpFeeShareBps
|
|
876
1692
|
};
|
|
877
1693
|
}
|
|
878
1694
|
};
|
|
@@ -891,9 +1707,20 @@ var AuctionState = /* @__PURE__ */ ((AuctionState2) => {
|
|
|
891
1707
|
AuctionBuilder,
|
|
892
1708
|
AuctionFlowSDK,
|
|
893
1709
|
AuctionState,
|
|
1710
|
+
DEFAULT_LIQUIDITY_BPS,
|
|
1711
|
+
DEFAULT_SLIPPAGE_BPS,
|
|
1712
|
+
MIN_LIQUIDITY_BPS,
|
|
1713
|
+
PRICE_SCALE,
|
|
894
1714
|
USDC_ADDRESSES,
|
|
1715
|
+
applySellSlippage,
|
|
1716
|
+
applySlippage,
|
|
895
1717
|
calculateBuyCost,
|
|
896
1718
|
calculateBuyQuote,
|
|
1719
|
+
calculateSellProceeds,
|
|
1720
|
+
fillPurchase,
|
|
1721
|
+
formatCurvePrice,
|
|
1722
|
+
maxBuyable,
|
|
1723
|
+
parseCurvePrice,
|
|
897
1724
|
spotPrice
|
|
898
1725
|
});
|
|
899
1726
|
//# sourceMappingURL=index.js.map
|