auctionflow-sdk 1.2.0 → 1.3.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 +59 -11
- package/dist/index.d.mts +82 -4
- package/dist/index.d.ts +82 -4
- package/dist/index.js +623 -62
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +617 -62
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,10 @@ import {
|
|
|
5
5
|
zeroAddress
|
|
6
6
|
} from "viem";
|
|
7
7
|
|
|
8
|
+
// src/constants/protocol.ts
|
|
9
|
+
var MIN_LIQUIDITY_BPS = 2e3;
|
|
10
|
+
var DEFAULT_LIQUIDITY_BPS = 5e3;
|
|
11
|
+
|
|
8
12
|
// src/builders/auction-builder.ts
|
|
9
13
|
var AuctionBuilder = class {
|
|
10
14
|
config = {};
|
|
@@ -27,6 +31,16 @@ var AuctionBuilder = class {
|
|
|
27
31
|
this.config.maxRaise = maxRaise;
|
|
28
32
|
return this;
|
|
29
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Share of the raise, in basis points, seeded into a Uniswap pool when the
|
|
36
|
+
* auction migrates (5000 = 50%). The rest goes to the creator. Defaults to
|
|
37
|
+
* 50%; must be between 20% and 100%.
|
|
38
|
+
*/
|
|
39
|
+
withLiquidity(liquidityBps) {
|
|
40
|
+
if (!Number.isInteger(liquidityBps)) throw new Error("liquidityBps must be an integer");
|
|
41
|
+
this.config.liquidityBps = BigInt(liquidityBps);
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
30
44
|
withSchedule(startTime, endTime) {
|
|
31
45
|
this.config.startTime = startTime;
|
|
32
46
|
this.config.endTime = endTime;
|
|
@@ -49,11 +63,15 @@ var AuctionBuilder = class {
|
|
|
49
63
|
throw new Error(`Missing required field: ${key}`);
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
|
-
const config = this.config;
|
|
66
|
+
const config = { liquidityBps: BigInt(DEFAULT_LIQUIDITY_BPS), ...this.config };
|
|
53
67
|
if (config.maxSupply <= 0n) throw new Error("maxSupply must be greater than 0");
|
|
54
68
|
if (config.basePrice <= 0n) throw new Error("basePrice must be greater than 0");
|
|
55
69
|
if (config.slope < 0n) throw new Error("slope must not be negative");
|
|
56
70
|
if (config.maxRaise <= 0n) throw new Error("maxRaise must be greater than 0");
|
|
71
|
+
const liquidityBps = config.liquidityBps;
|
|
72
|
+
if (liquidityBps < BigInt(MIN_LIQUIDITY_BPS) || liquidityBps > 10000n) {
|
|
73
|
+
throw new Error(`liquidityBps must be between ${MIN_LIQUIDITY_BPS} and 10000`);
|
|
74
|
+
}
|
|
57
75
|
if (config.startTime >= config.endTime) {
|
|
58
76
|
throw new Error("startTime must be before endTime");
|
|
59
77
|
}
|
|
@@ -63,7 +81,7 @@ var AuctionBuilder = class {
|
|
|
63
81
|
|
|
64
82
|
// src/constants/addresses.ts
|
|
65
83
|
var AUCTION_ADDRESSES = {
|
|
66
|
-
84532: "
|
|
84
|
+
84532: "0x722f4521b96aca1df7c65a1dbe3b1713803ccea9",
|
|
67
85
|
8453: "0x0000000000000000000000000000000000000000"
|
|
68
86
|
// not yet deployed
|
|
69
87
|
};
|
|
@@ -86,10 +104,67 @@ var tokenAuctionAbi = [
|
|
|
86
104
|
"name": "defaultFeeBps_",
|
|
87
105
|
"type": "uint256",
|
|
88
106
|
"internalType": "uint256"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "positionManager_",
|
|
110
|
+
"type": "address",
|
|
111
|
+
"internalType": "contract INonfungiblePositionManager"
|
|
89
112
|
}
|
|
90
113
|
],
|
|
91
114
|
"stateMutability": "nonpayable"
|
|
92
115
|
},
|
|
116
|
+
{
|
|
117
|
+
"type": "function",
|
|
118
|
+
"name": "MAX_FEE_BPS",
|
|
119
|
+
"inputs": [],
|
|
120
|
+
"outputs": [
|
|
121
|
+
{
|
|
122
|
+
"name": "",
|
|
123
|
+
"type": "uint256",
|
|
124
|
+
"internalType": "uint256"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"stateMutability": "view"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"type": "function",
|
|
131
|
+
"name": "MAX_LP_FEE_SHARE_BPS",
|
|
132
|
+
"inputs": [],
|
|
133
|
+
"outputs": [
|
|
134
|
+
{
|
|
135
|
+
"name": "",
|
|
136
|
+
"type": "uint256",
|
|
137
|
+
"internalType": "uint256"
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
"stateMutability": "view"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"type": "function",
|
|
144
|
+
"name": "MIN_LIQUIDITY_BPS",
|
|
145
|
+
"inputs": [],
|
|
146
|
+
"outputs": [
|
|
147
|
+
{
|
|
148
|
+
"name": "",
|
|
149
|
+
"type": "uint256",
|
|
150
|
+
"internalType": "uint256"
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
"stateMutability": "view"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"type": "function",
|
|
157
|
+
"name": "POOL_FEE",
|
|
158
|
+
"inputs": [],
|
|
159
|
+
"outputs": [
|
|
160
|
+
{
|
|
161
|
+
"name": "",
|
|
162
|
+
"type": "uint24",
|
|
163
|
+
"internalType": "uint24"
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
"stateMutability": "view"
|
|
167
|
+
},
|
|
93
168
|
{
|
|
94
169
|
"type": "function",
|
|
95
170
|
"name": "auctionCount",
|
|
@@ -163,6 +238,16 @@ var tokenAuctionAbi = [
|
|
|
163
238
|
"name": "protocolFeeBps",
|
|
164
239
|
"type": "uint256",
|
|
165
240
|
"internalType": "uint256"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "liquidityBps",
|
|
244
|
+
"type": "uint256",
|
|
245
|
+
"internalType": "uint256"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"name": "lpFeeShareBps",
|
|
249
|
+
"type": "uint256",
|
|
250
|
+
"internalType": "uint256"
|
|
166
251
|
}
|
|
167
252
|
]
|
|
168
253
|
},
|
|
@@ -197,11 +282,40 @@ var tokenAuctionAbi = [
|
|
|
197
282
|
"name": "amount",
|
|
198
283
|
"type": "uint256",
|
|
199
284
|
"internalType": "uint256"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"name": "maxCost",
|
|
288
|
+
"type": "uint256",
|
|
289
|
+
"internalType": "uint256"
|
|
200
290
|
}
|
|
201
291
|
],
|
|
202
292
|
"outputs": [],
|
|
203
293
|
"stateMutability": "nonpayable"
|
|
204
294
|
},
|
|
295
|
+
{
|
|
296
|
+
"type": "function",
|
|
297
|
+
"name": "collectFees",
|
|
298
|
+
"inputs": [
|
|
299
|
+
{
|
|
300
|
+
"name": "auctionId",
|
|
301
|
+
"type": "uint256",
|
|
302
|
+
"internalType": "uint256"
|
|
303
|
+
}
|
|
304
|
+
],
|
|
305
|
+
"outputs": [
|
|
306
|
+
{
|
|
307
|
+
"name": "tokenFees",
|
|
308
|
+
"type": "uint256",
|
|
309
|
+
"internalType": "uint256"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"name": "paymentFees",
|
|
313
|
+
"type": "uint256",
|
|
314
|
+
"internalType": "uint256"
|
|
315
|
+
}
|
|
316
|
+
],
|
|
317
|
+
"stateMutability": "nonpayable"
|
|
318
|
+
},
|
|
205
319
|
{
|
|
206
320
|
"type": "function",
|
|
207
321
|
"name": "completeAuction",
|
|
@@ -220,63 +334,107 @@ var tokenAuctionAbi = [
|
|
|
220
334
|
"name": "createAuction",
|
|
221
335
|
"inputs": [
|
|
222
336
|
{
|
|
223
|
-
"name": "
|
|
224
|
-
"type": "
|
|
225
|
-
"internalType": "
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
337
|
+
"name": "p",
|
|
338
|
+
"type": "tuple",
|
|
339
|
+
"internalType": "struct TokenAuction.AuctionParams",
|
|
340
|
+
"components": [
|
|
341
|
+
{
|
|
342
|
+
"name": "name",
|
|
343
|
+
"type": "string",
|
|
344
|
+
"internalType": "string"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"name": "symbol",
|
|
348
|
+
"type": "string",
|
|
349
|
+
"internalType": "string"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"name": "maxSupply",
|
|
353
|
+
"type": "uint256",
|
|
354
|
+
"internalType": "uint256"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"name": "paymentToken",
|
|
358
|
+
"type": "address",
|
|
359
|
+
"internalType": "address"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"name": "basePrice",
|
|
363
|
+
"type": "uint256",
|
|
364
|
+
"internalType": "uint256"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"name": "slope",
|
|
368
|
+
"type": "uint256",
|
|
369
|
+
"internalType": "uint256"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"name": "maxRaise",
|
|
373
|
+
"type": "uint256",
|
|
374
|
+
"internalType": "uint256"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"name": "startTime",
|
|
378
|
+
"type": "uint256",
|
|
379
|
+
"internalType": "uint256"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"name": "endTime",
|
|
383
|
+
"type": "uint256",
|
|
384
|
+
"internalType": "uint256"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
"name": "liquidityBps",
|
|
388
|
+
"type": "uint256",
|
|
389
|
+
"internalType": "uint256"
|
|
390
|
+
}
|
|
391
|
+
]
|
|
392
|
+
}
|
|
393
|
+
],
|
|
394
|
+
"outputs": [
|
|
232
395
|
{
|
|
233
|
-
"name": "
|
|
396
|
+
"name": "auctionId",
|
|
234
397
|
"type": "uint256",
|
|
235
398
|
"internalType": "uint256"
|
|
236
|
-
}
|
|
399
|
+
}
|
|
400
|
+
],
|
|
401
|
+
"stateMutability": "nonpayable"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"type": "function",
|
|
405
|
+
"name": "custodied",
|
|
406
|
+
"inputs": [
|
|
237
407
|
{
|
|
238
|
-
"name": "
|
|
408
|
+
"name": "",
|
|
239
409
|
"type": "address",
|
|
240
410
|
"internalType": "address"
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
"type": "uint256",
|
|
245
|
-
"internalType": "uint256"
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
"name": "slope",
|
|
249
|
-
"type": "uint256",
|
|
250
|
-
"internalType": "uint256"
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
"name": "maxRaise",
|
|
254
|
-
"type": "uint256",
|
|
255
|
-
"internalType": "uint256"
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
"name": "startTime",
|
|
259
|
-
"type": "uint256",
|
|
260
|
-
"internalType": "uint256"
|
|
261
|
-
},
|
|
411
|
+
}
|
|
412
|
+
],
|
|
413
|
+
"outputs": [
|
|
262
414
|
{
|
|
263
|
-
"name": "
|
|
415
|
+
"name": "",
|
|
264
416
|
"type": "uint256",
|
|
265
417
|
"internalType": "uint256"
|
|
266
418
|
}
|
|
267
419
|
],
|
|
420
|
+
"stateMutability": "view"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"type": "function",
|
|
424
|
+
"name": "defaultFeeBps",
|
|
425
|
+
"inputs": [],
|
|
268
426
|
"outputs": [
|
|
269
427
|
{
|
|
270
|
-
"name": "
|
|
428
|
+
"name": "",
|
|
271
429
|
"type": "uint256",
|
|
272
430
|
"internalType": "uint256"
|
|
273
431
|
}
|
|
274
432
|
],
|
|
275
|
-
"stateMutability": "
|
|
433
|
+
"stateMutability": "view"
|
|
276
434
|
},
|
|
277
435
|
{
|
|
278
436
|
"type": "function",
|
|
279
|
-
"name": "
|
|
437
|
+
"name": "defaultLpFeeShareBps",
|
|
280
438
|
"inputs": [],
|
|
281
439
|
"outputs": [
|
|
282
440
|
{
|
|
@@ -335,6 +493,19 @@ var tokenAuctionAbi = [
|
|
|
335
493
|
],
|
|
336
494
|
"stateMutability": "view"
|
|
337
495
|
},
|
|
496
|
+
{
|
|
497
|
+
"type": "function",
|
|
498
|
+
"name": "migrate",
|
|
499
|
+
"inputs": [
|
|
500
|
+
{
|
|
501
|
+
"name": "auctionId",
|
|
502
|
+
"type": "uint256",
|
|
503
|
+
"internalType": "uint256"
|
|
504
|
+
}
|
|
505
|
+
],
|
|
506
|
+
"outputs": [],
|
|
507
|
+
"stateMutability": "nonpayable"
|
|
508
|
+
},
|
|
338
509
|
{
|
|
339
510
|
"type": "function",
|
|
340
511
|
"name": "owner",
|
|
@@ -348,6 +519,57 @@ var tokenAuctionAbi = [
|
|
|
348
519
|
],
|
|
349
520
|
"stateMutability": "view"
|
|
350
521
|
},
|
|
522
|
+
{
|
|
523
|
+
"type": "function",
|
|
524
|
+
"name": "poolOf",
|
|
525
|
+
"inputs": [
|
|
526
|
+
{
|
|
527
|
+
"name": "",
|
|
528
|
+
"type": "uint256",
|
|
529
|
+
"internalType": "uint256"
|
|
530
|
+
}
|
|
531
|
+
],
|
|
532
|
+
"outputs": [
|
|
533
|
+
{
|
|
534
|
+
"name": "",
|
|
535
|
+
"type": "address",
|
|
536
|
+
"internalType": "address"
|
|
537
|
+
}
|
|
538
|
+
],
|
|
539
|
+
"stateMutability": "view"
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
"type": "function",
|
|
543
|
+
"name": "positionId",
|
|
544
|
+
"inputs": [
|
|
545
|
+
{
|
|
546
|
+
"name": "",
|
|
547
|
+
"type": "uint256",
|
|
548
|
+
"internalType": "uint256"
|
|
549
|
+
}
|
|
550
|
+
],
|
|
551
|
+
"outputs": [
|
|
552
|
+
{
|
|
553
|
+
"name": "",
|
|
554
|
+
"type": "uint256",
|
|
555
|
+
"internalType": "uint256"
|
|
556
|
+
}
|
|
557
|
+
],
|
|
558
|
+
"stateMutability": "view"
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
"type": "function",
|
|
562
|
+
"name": "positionManager",
|
|
563
|
+
"inputs": [],
|
|
564
|
+
"outputs": [
|
|
565
|
+
{
|
|
566
|
+
"name": "",
|
|
567
|
+
"type": "address",
|
|
568
|
+
"internalType": "contract INonfungiblePositionManager"
|
|
569
|
+
}
|
|
570
|
+
],
|
|
571
|
+
"stateMutability": "view"
|
|
572
|
+
},
|
|
351
573
|
{
|
|
352
574
|
"type": "function",
|
|
353
575
|
"name": "proceedsWithdrawn",
|
|
@@ -387,6 +609,63 @@ var tokenAuctionAbi = [
|
|
|
387
609
|
"outputs": [],
|
|
388
610
|
"stateMutability": "nonpayable"
|
|
389
611
|
},
|
|
612
|
+
{
|
|
613
|
+
"type": "function",
|
|
614
|
+
"name": "setDefaultFeeBps",
|
|
615
|
+
"inputs": [
|
|
616
|
+
{
|
|
617
|
+
"name": "feeBps",
|
|
618
|
+
"type": "uint256",
|
|
619
|
+
"internalType": "uint256"
|
|
620
|
+
}
|
|
621
|
+
],
|
|
622
|
+
"outputs": [],
|
|
623
|
+
"stateMutability": "nonpayable"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"type": "function",
|
|
627
|
+
"name": "setDefaultLpFeeShareBps",
|
|
628
|
+
"inputs": [
|
|
629
|
+
{
|
|
630
|
+
"name": "shareBps",
|
|
631
|
+
"type": "uint256",
|
|
632
|
+
"internalType": "uint256"
|
|
633
|
+
}
|
|
634
|
+
],
|
|
635
|
+
"outputs": [],
|
|
636
|
+
"stateMutability": "nonpayable"
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
"type": "function",
|
|
640
|
+
"name": "setProtocolFeeRecipient",
|
|
641
|
+
"inputs": [
|
|
642
|
+
{
|
|
643
|
+
"name": "recipient",
|
|
644
|
+
"type": "address",
|
|
645
|
+
"internalType": "address"
|
|
646
|
+
}
|
|
647
|
+
],
|
|
648
|
+
"outputs": [],
|
|
649
|
+
"stateMutability": "nonpayable"
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
"type": "function",
|
|
653
|
+
"name": "sweep",
|
|
654
|
+
"inputs": [
|
|
655
|
+
{
|
|
656
|
+
"name": "token",
|
|
657
|
+
"type": "address",
|
|
658
|
+
"internalType": "contract IERC20"
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
"name": "to",
|
|
662
|
+
"type": "address",
|
|
663
|
+
"internalType": "address"
|
|
664
|
+
}
|
|
665
|
+
],
|
|
666
|
+
"outputs": [],
|
|
667
|
+
"stateMutability": "nonpayable"
|
|
668
|
+
},
|
|
390
669
|
{
|
|
391
670
|
"type": "function",
|
|
392
671
|
"name": "transferOwnership",
|
|
@@ -400,6 +679,29 @@ var tokenAuctionAbi = [
|
|
|
400
679
|
"outputs": [],
|
|
401
680
|
"stateMutability": "nonpayable"
|
|
402
681
|
},
|
|
682
|
+
{
|
|
683
|
+
"type": "function",
|
|
684
|
+
"name": "uniswapV3SwapCallback",
|
|
685
|
+
"inputs": [
|
|
686
|
+
{
|
|
687
|
+
"name": "amount0Delta",
|
|
688
|
+
"type": "int256",
|
|
689
|
+
"internalType": "int256"
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
"name": "amount1Delta",
|
|
693
|
+
"type": "int256",
|
|
694
|
+
"internalType": "int256"
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
"name": "data",
|
|
698
|
+
"type": "bytes",
|
|
699
|
+
"internalType": "bytes"
|
|
700
|
+
}
|
|
701
|
+
],
|
|
702
|
+
"outputs": [],
|
|
703
|
+
"stateMutability": "nonpayable"
|
|
704
|
+
},
|
|
403
705
|
{
|
|
404
706
|
"type": "function",
|
|
405
707
|
"name": "userPurchases",
|
|
@@ -519,6 +821,12 @@ var tokenAuctionAbi = [
|
|
|
519
821
|
"type": "uint256",
|
|
520
822
|
"indexed": false,
|
|
521
823
|
"internalType": "uint256"
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
"name": "liquidityBps",
|
|
827
|
+
"type": "uint256",
|
|
828
|
+
"indexed": false,
|
|
829
|
+
"internalType": "uint256"
|
|
522
830
|
}
|
|
523
831
|
],
|
|
524
832
|
"anonymous": false
|
|
@@ -534,10 +842,103 @@ var tokenAuctionAbi = [
|
|
|
534
842
|
"internalType": "uint256"
|
|
535
843
|
},
|
|
536
844
|
{
|
|
537
|
-
"name": "
|
|
845
|
+
"name": "pool",
|
|
538
846
|
"type": "address",
|
|
539
847
|
"indexed": false,
|
|
540
848
|
"internalType": "address"
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
"name": "positionId",
|
|
852
|
+
"type": "uint256",
|
|
853
|
+
"indexed": false,
|
|
854
|
+
"internalType": "uint256"
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
"name": "tokenLiquidity",
|
|
858
|
+
"type": "uint256",
|
|
859
|
+
"indexed": false,
|
|
860
|
+
"internalType": "uint256"
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
"name": "paymentLiquidity",
|
|
864
|
+
"type": "uint256",
|
|
865
|
+
"indexed": false,
|
|
866
|
+
"internalType": "uint256"
|
|
867
|
+
}
|
|
868
|
+
],
|
|
869
|
+
"anonymous": false
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
"type": "event",
|
|
873
|
+
"name": "DefaultFeeBpsUpdated",
|
|
874
|
+
"inputs": [
|
|
875
|
+
{
|
|
876
|
+
"name": "previous",
|
|
877
|
+
"type": "uint256",
|
|
878
|
+
"indexed": false,
|
|
879
|
+
"internalType": "uint256"
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
"name": "current",
|
|
883
|
+
"type": "uint256",
|
|
884
|
+
"indexed": false,
|
|
885
|
+
"internalType": "uint256"
|
|
886
|
+
}
|
|
887
|
+
],
|
|
888
|
+
"anonymous": false
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
"type": "event",
|
|
892
|
+
"name": "DefaultLpFeeShareBpsUpdated",
|
|
893
|
+
"inputs": [
|
|
894
|
+
{
|
|
895
|
+
"name": "previous",
|
|
896
|
+
"type": "uint256",
|
|
897
|
+
"indexed": false,
|
|
898
|
+
"internalType": "uint256"
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
"name": "current",
|
|
902
|
+
"type": "uint256",
|
|
903
|
+
"indexed": false,
|
|
904
|
+
"internalType": "uint256"
|
|
905
|
+
}
|
|
906
|
+
],
|
|
907
|
+
"anonymous": false
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
"type": "event",
|
|
911
|
+
"name": "LpFeesCollected",
|
|
912
|
+
"inputs": [
|
|
913
|
+
{
|
|
914
|
+
"name": "auctionId",
|
|
915
|
+
"type": "uint256",
|
|
916
|
+
"indexed": true,
|
|
917
|
+
"internalType": "uint256"
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
"name": "creatorTokenFees",
|
|
921
|
+
"type": "uint256",
|
|
922
|
+
"indexed": false,
|
|
923
|
+
"internalType": "uint256"
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
"name": "creatorPaymentFees",
|
|
927
|
+
"type": "uint256",
|
|
928
|
+
"indexed": false,
|
|
929
|
+
"internalType": "uint256"
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"name": "protocolTokenFees",
|
|
933
|
+
"type": "uint256",
|
|
934
|
+
"indexed": false,
|
|
935
|
+
"internalType": "uint256"
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
"name": "protocolPaymentFees",
|
|
939
|
+
"type": "uint256",
|
|
940
|
+
"indexed": false,
|
|
941
|
+
"internalType": "uint256"
|
|
541
942
|
}
|
|
542
943
|
],
|
|
543
944
|
"anonymous": false
|
|
@@ -586,6 +987,50 @@ var tokenAuctionAbi = [
|
|
|
586
987
|
],
|
|
587
988
|
"anonymous": false
|
|
588
989
|
},
|
|
990
|
+
{
|
|
991
|
+
"type": "event",
|
|
992
|
+
"name": "ProtocolFeeRecipientUpdated",
|
|
993
|
+
"inputs": [
|
|
994
|
+
{
|
|
995
|
+
"name": "previous",
|
|
996
|
+
"type": "address",
|
|
997
|
+
"indexed": true,
|
|
998
|
+
"internalType": "address"
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
"name": "current",
|
|
1002
|
+
"type": "address",
|
|
1003
|
+
"indexed": true,
|
|
1004
|
+
"internalType": "address"
|
|
1005
|
+
}
|
|
1006
|
+
],
|
|
1007
|
+
"anonymous": false
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
"type": "event",
|
|
1011
|
+
"name": "Swept",
|
|
1012
|
+
"inputs": [
|
|
1013
|
+
{
|
|
1014
|
+
"name": "token",
|
|
1015
|
+
"type": "address",
|
|
1016
|
+
"indexed": true,
|
|
1017
|
+
"internalType": "address"
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
"name": "to",
|
|
1021
|
+
"type": "address",
|
|
1022
|
+
"indexed": true,
|
|
1023
|
+
"internalType": "address"
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
"name": "amount",
|
|
1027
|
+
"type": "uint256",
|
|
1028
|
+
"indexed": false,
|
|
1029
|
+
"internalType": "uint256"
|
|
1030
|
+
}
|
|
1031
|
+
],
|
|
1032
|
+
"anonymous": false
|
|
1033
|
+
},
|
|
589
1034
|
{
|
|
590
1035
|
"type": "event",
|
|
591
1036
|
"name": "TokensPurchased",
|
|
@@ -677,9 +1122,13 @@ var tokenAuctionAbi = [
|
|
|
677
1122
|
|
|
678
1123
|
// src/utils/bonding-curve.ts
|
|
679
1124
|
var TOKEN_SCALE = 10n ** 18n;
|
|
1125
|
+
var ceilDiv = (a, b) => (a + b - 1n) / b;
|
|
680
1126
|
function calculateBuyCost(currentSupply, amount, basePrice, slope) {
|
|
681
|
-
const linearCost = basePrice * amount
|
|
682
|
-
const curveCost =
|
|
1127
|
+
const linearCost = ceilDiv(basePrice * amount, TOKEN_SCALE);
|
|
1128
|
+
const curveCost = ceilDiv(
|
|
1129
|
+
slope * amount * (2n * currentSupply + amount),
|
|
1130
|
+
2n * TOKEN_SCALE * TOKEN_SCALE
|
|
1131
|
+
);
|
|
683
1132
|
return linearCost + curveCost;
|
|
684
1133
|
}
|
|
685
1134
|
function spotPrice(currentSupply, basePrice, slope) {
|
|
@@ -695,6 +1144,37 @@ function calculateBuyQuote(currentSupply, amount, basePrice, slope, feeBps) {
|
|
|
695
1144
|
spotPriceAfter: spotPrice(currentSupply + amount, basePrice, slope)
|
|
696
1145
|
};
|
|
697
1146
|
}
|
|
1147
|
+
var DEFAULT_SLIPPAGE_BPS = 100;
|
|
1148
|
+
function applySlippage(total, slippageBps) {
|
|
1149
|
+
if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > 1e4) {
|
|
1150
|
+
throw new Error("slippageBps must be an integer between 0 and 10000");
|
|
1151
|
+
}
|
|
1152
|
+
return (total * BigInt(1e4 + slippageBps) + 9999n) / 10000n;
|
|
1153
|
+
}
|
|
1154
|
+
function maxBuyable(currentSupply, budget, basePrice, slope, upperBound) {
|
|
1155
|
+
let hi = budget * TOKEN_SCALE / basePrice + 1n;
|
|
1156
|
+
if (hi > upperBound) hi = upperBound;
|
|
1157
|
+
let lo = 0n;
|
|
1158
|
+
while (lo < hi) {
|
|
1159
|
+
const mid = (lo + hi + 1n) / 2n;
|
|
1160
|
+
if (calculateBuyCost(currentSupply, mid, basePrice, slope) <= budget) lo = mid;
|
|
1161
|
+
else hi = mid - 1n;
|
|
1162
|
+
}
|
|
1163
|
+
return lo;
|
|
1164
|
+
}
|
|
1165
|
+
function fillPurchase(currentSupply, requested, basePrice, slope, totalRaised, maxRaise) {
|
|
1166
|
+
const remaining = maxRaise - totalRaised;
|
|
1167
|
+
const cost = calculateBuyCost(currentSupply, requested, basePrice, slope);
|
|
1168
|
+
if (cost < remaining) return { amount: requested, cost, fillsAuction: false };
|
|
1169
|
+
if (cost === remaining) return { amount: requested, cost, fillsAuction: true };
|
|
1170
|
+
const amount = maxBuyable(currentSupply, remaining, basePrice, slope, requested);
|
|
1171
|
+
if (amount === 0n) throw new Error("Auction is sold out");
|
|
1172
|
+
return {
|
|
1173
|
+
amount,
|
|
1174
|
+
cost: calculateBuyCost(currentSupply, amount, basePrice, slope),
|
|
1175
|
+
fillsAuction: true
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
698
1178
|
|
|
699
1179
|
// src/utils/chains.ts
|
|
700
1180
|
import { base, baseSepolia } from "viem/chains";
|
|
@@ -743,34 +1223,50 @@ var AuctionFlowSDK = class {
|
|
|
743
1223
|
abi: tokenAuctionAbi,
|
|
744
1224
|
functionName: "createAuction",
|
|
745
1225
|
args: [
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
1226
|
+
{
|
|
1227
|
+
name: config.name,
|
|
1228
|
+
symbol: config.symbol,
|
|
1229
|
+
maxSupply: config.maxSupply,
|
|
1230
|
+
paymentToken: config.paymentToken,
|
|
1231
|
+
basePrice: config.basePrice,
|
|
1232
|
+
slope: config.slope,
|
|
1233
|
+
maxRaise: config.maxRaise,
|
|
1234
|
+
startTime: config.startTime,
|
|
1235
|
+
endTime: config.endTime,
|
|
1236
|
+
liquidityBps: config.liquidityBps ?? BigInt(DEFAULT_LIQUIDITY_BPS)
|
|
1237
|
+
}
|
|
755
1238
|
]
|
|
756
1239
|
});
|
|
757
1240
|
return hash;
|
|
758
1241
|
}
|
|
759
|
-
|
|
1242
|
+
/**
|
|
1243
|
+
* Buy `amount` tokens (in token wei). The price rises with every purchase, so
|
|
1244
|
+
* the contract takes a maximum total cost and reverts if the price moved past
|
|
1245
|
+
* it before the transaction landed.
|
|
1246
|
+
*
|
|
1247
|
+
* Pass `maxCost` to set that bound exactly, or `slippageBps` to derive it
|
|
1248
|
+
* from a fresh quote (default 100 = 1% above the quoted total).
|
|
1249
|
+
*/
|
|
1250
|
+
async buyTokens(auctionId, amount, options = {}) {
|
|
760
1251
|
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1252
|
+
const maxCost = options.maxCost ?? applySlippage(
|
|
1253
|
+
(await this.getQuote(auctionId, amount)).totalCost,
|
|
1254
|
+
options.slippageBps ?? DEFAULT_SLIPPAGE_BPS
|
|
1255
|
+
);
|
|
761
1256
|
const hash = await this.walletClient.writeContract({
|
|
762
1257
|
chain: this.chain,
|
|
763
1258
|
account: this.walletClient.account,
|
|
764
1259
|
address: this.auctionAddress,
|
|
765
1260
|
abi: tokenAuctionAbi,
|
|
766
1261
|
functionName: "buyTokens",
|
|
767
|
-
args: [auctionId, amount]
|
|
1262
|
+
args: [auctionId, amount, maxCost]
|
|
768
1263
|
});
|
|
769
1264
|
return hash;
|
|
770
1265
|
}
|
|
771
1266
|
/**
|
|
772
|
-
*
|
|
773
|
-
*
|
|
1267
|
+
* Pay a completed auction's creator their share of the raise: everything
|
|
1268
|
+
* not reserved for Uniswap liquidity. Creator only, once, before or after
|
|
1269
|
+
* migration.
|
|
774
1270
|
*/
|
|
775
1271
|
async withdrawProceeds(auctionId) {
|
|
776
1272
|
if (!this.walletClient) throw new Error("Wallet client required");
|
|
@@ -784,6 +1280,53 @@ var AuctionFlowSDK = class {
|
|
|
784
1280
|
});
|
|
785
1281
|
return hash;
|
|
786
1282
|
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Move a completed auction's liquidity into a Uniswap v3 pool at the
|
|
1285
|
+
* auction's final price, lock it, and unlock the token for trading. Anyone
|
|
1286
|
+
* may call it.
|
|
1287
|
+
*/
|
|
1288
|
+
async migrate(auctionId) {
|
|
1289
|
+
return this.write("migrate", [auctionId]);
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Collect the migrated pool's trading fees. The protocol takes its share and
|
|
1293
|
+
* the creator receives the rest. Anyone may call it.
|
|
1294
|
+
*/
|
|
1295
|
+
async collectFees(auctionId) {
|
|
1296
|
+
return this.write("collectFees", [auctionId]);
|
|
1297
|
+
}
|
|
1298
|
+
/** The Uniswap pool and position for a migrated auction. */
|
|
1299
|
+
async getMigration(auctionId) {
|
|
1300
|
+
const [pool, positionId] = await Promise.all([
|
|
1301
|
+
this.publicClient.readContract({
|
|
1302
|
+
address: this.auctionAddress,
|
|
1303
|
+
abi: tokenAuctionAbi,
|
|
1304
|
+
functionName: "poolOf",
|
|
1305
|
+
args: [auctionId]
|
|
1306
|
+
}),
|
|
1307
|
+
this.publicClient.readContract({
|
|
1308
|
+
address: this.auctionAddress,
|
|
1309
|
+
abi: tokenAuctionAbi,
|
|
1310
|
+
functionName: "positionId",
|
|
1311
|
+
args: [auctionId]
|
|
1312
|
+
})
|
|
1313
|
+
]);
|
|
1314
|
+
return {
|
|
1315
|
+
pool: pool === zeroAddress ? null : pool,
|
|
1316
|
+
positionId: positionId === 0n ? null : positionId
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
async write(functionName, args) {
|
|
1320
|
+
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1321
|
+
return this.walletClient.writeContract({
|
|
1322
|
+
chain: this.chain,
|
|
1323
|
+
account: this.walletClient.account,
|
|
1324
|
+
address: this.auctionAddress,
|
|
1325
|
+
abi: tokenAuctionAbi,
|
|
1326
|
+
functionName,
|
|
1327
|
+
args
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
787
1330
|
// Read: Has an auction's creator already withdrawn its proceeds?
|
|
788
1331
|
async hasWithdrawnProceeds(auctionId) {
|
|
789
1332
|
return this.publicClient.readContract({
|
|
@@ -806,18 +1349,22 @@ var AuctionFlowSDK = class {
|
|
|
806
1349
|
// Read: Get buy quote (off-chain calculation)
|
|
807
1350
|
async getQuote(auctionId, amount) {
|
|
808
1351
|
const auction = await this.getAuction(auctionId);
|
|
809
|
-
const
|
|
1352
|
+
const fill = fillPurchase(
|
|
810
1353
|
auction.totalSold,
|
|
811
1354
|
amount,
|
|
812
1355
|
auction.basePrice,
|
|
813
1356
|
auction.slope,
|
|
814
|
-
auction.
|
|
1357
|
+
auction.totalRaised,
|
|
1358
|
+
auction.maxRaise
|
|
815
1359
|
);
|
|
1360
|
+
const fee = fill.cost * auction.protocolFeeBps / 10000n;
|
|
816
1361
|
return {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
1362
|
+
amount: fill.amount,
|
|
1363
|
+
cost: fill.cost,
|
|
1364
|
+
fee,
|
|
1365
|
+
totalCost: fill.cost + fee,
|
|
1366
|
+
spotPriceAfter: spotPrice(auction.totalSold + fill.amount, auction.basePrice, auction.slope),
|
|
1367
|
+
fillsAuction: fill.fillsAuction
|
|
821
1368
|
};
|
|
822
1369
|
}
|
|
823
1370
|
// Read: Get spot price
|
|
@@ -843,7 +1390,9 @@ var AuctionFlowSDK = class {
|
|
|
843
1390
|
state: raw.state,
|
|
844
1391
|
totalRaised: raw.totalRaised,
|
|
845
1392
|
totalSold: raw.totalSold,
|
|
846
|
-
protocolFeeBps: raw.config.protocolFeeBps
|
|
1393
|
+
protocolFeeBps: raw.config.protocolFeeBps,
|
|
1394
|
+
liquidityBps: raw.config.liquidityBps,
|
|
1395
|
+
lpFeeShareBps: raw.config.lpFeeShareBps
|
|
847
1396
|
};
|
|
848
1397
|
}
|
|
849
1398
|
};
|
|
@@ -861,9 +1410,15 @@ export {
|
|
|
861
1410
|
AuctionBuilder,
|
|
862
1411
|
AuctionFlowSDK,
|
|
863
1412
|
AuctionState,
|
|
1413
|
+
DEFAULT_LIQUIDITY_BPS,
|
|
1414
|
+
DEFAULT_SLIPPAGE_BPS,
|
|
1415
|
+
MIN_LIQUIDITY_BPS,
|
|
864
1416
|
USDC_ADDRESSES,
|
|
1417
|
+
applySlippage,
|
|
865
1418
|
calculateBuyCost,
|
|
866
1419
|
calculateBuyQuote,
|
|
1420
|
+
fillPurchase,
|
|
1421
|
+
maxBuyable,
|
|
867
1422
|
spotPrice
|
|
868
1423
|
};
|
|
869
1424
|
//# sourceMappingURL=index.mjs.map
|