auctionflow-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,893 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AUCTION_ADDRESSES: () => AUCTION_ADDRESSES,
24
+ AuctionBuilder: () => AuctionBuilder,
25
+ AuctionFlowSDK: () => AuctionFlowSDK,
26
+ AuctionState: () => AuctionState,
27
+ USDC_ADDRESSES: () => USDC_ADDRESSES,
28
+ calculateBuyCost: () => calculateBuyCost,
29
+ calculateBuyQuote: () => calculateBuyQuote,
30
+ spotPrice: () => spotPrice
31
+ });
32
+ module.exports = __toCommonJS(index_exports);
33
+
34
+ // src/client.ts
35
+ var import_viem = require("viem");
36
+
37
+ // src/builders/auction-builder.ts
38
+ var AuctionBuilder = class {
39
+ config = {};
40
+ withToken(name, symbol, maxSupply) {
41
+ this.config.name = name;
42
+ this.config.symbol = symbol;
43
+ this.config.maxSupply = maxSupply;
44
+ return this;
45
+ }
46
+ withPaymentToken(address) {
47
+ this.config.paymentToken = address;
48
+ return this;
49
+ }
50
+ withBondingCurve(basePrice, slope) {
51
+ this.config.basePrice = basePrice;
52
+ this.config.slope = slope;
53
+ return this;
54
+ }
55
+ withMaxRaise(maxRaise) {
56
+ this.config.maxRaise = maxRaise;
57
+ return this;
58
+ }
59
+ withSchedule(startTime, endTime) {
60
+ this.config.startTime = startTime;
61
+ this.config.endTime = endTime;
62
+ return this;
63
+ }
64
+ build() {
65
+ const required = [
66
+ "name",
67
+ "symbol",
68
+ "maxSupply",
69
+ "paymentToken",
70
+ "basePrice",
71
+ "slope",
72
+ "maxRaise",
73
+ "startTime",
74
+ "endTime"
75
+ ];
76
+ for (const key of required) {
77
+ if (this.config[key] === void 0) {
78
+ throw new Error(`Missing required field: ${key}`);
79
+ }
80
+ }
81
+ const config = this.config;
82
+ if (config.maxSupply <= 0n) throw new Error("maxSupply must be greater than 0");
83
+ if (config.basePrice <= 0n) throw new Error("basePrice must be greater than 0");
84
+ if (config.slope < 0n) throw new Error("slope must not be negative");
85
+ if (config.maxRaise <= 0n) throw new Error("maxRaise must be greater than 0");
86
+ if (config.startTime >= config.endTime) {
87
+ throw new Error("startTime must be before endTime");
88
+ }
89
+ return config;
90
+ }
91
+ };
92
+
93
+ // src/constants/addresses.ts
94
+ var AUCTION_ADDRESSES = {
95
+ 84532: "0xadc3e02e962eed3856d7bee0315f84d187be1fea",
96
+ 8453: "0x0000000000000000000000000000000000000000"
97
+ // not yet deployed
98
+ };
99
+ var USDC_ADDRESSES = {
100
+ 84532: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
101
+ 8453: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
102
+ };
103
+
104
+ // src/abis/token-auction.ts
105
+ var tokenAuctionAbi = [
106
+ {
107
+ "type": "constructor",
108
+ "inputs": [
109
+ {
110
+ "name": "feeRecipient_",
111
+ "type": "address",
112
+ "internalType": "address"
113
+ },
114
+ {
115
+ "name": "defaultFeeBps_",
116
+ "type": "uint256",
117
+ "internalType": "uint256"
118
+ }
119
+ ],
120
+ "stateMutability": "nonpayable"
121
+ },
122
+ {
123
+ "type": "function",
124
+ "name": "auctionCount",
125
+ "inputs": [],
126
+ "outputs": [
127
+ {
128
+ "name": "",
129
+ "type": "uint256",
130
+ "internalType": "uint256"
131
+ }
132
+ ],
133
+ "stateMutability": "view"
134
+ },
135
+ {
136
+ "type": "function",
137
+ "name": "auctions",
138
+ "inputs": [
139
+ {
140
+ "name": "",
141
+ "type": "uint256",
142
+ "internalType": "uint256"
143
+ }
144
+ ],
145
+ "outputs": [
146
+ {
147
+ "name": "config",
148
+ "type": "tuple",
149
+ "internalType": "struct TokenAuction.AuctionConfig",
150
+ "components": [
151
+ {
152
+ "name": "token",
153
+ "type": "address",
154
+ "internalType": "contract AuctionToken"
155
+ },
156
+ {
157
+ "name": "paymentToken",
158
+ "type": "address",
159
+ "internalType": "contract IERC20"
160
+ },
161
+ {
162
+ "name": "basePrice",
163
+ "type": "uint256",
164
+ "internalType": "uint256"
165
+ },
166
+ {
167
+ "name": "slope",
168
+ "type": "uint256",
169
+ "internalType": "uint256"
170
+ },
171
+ {
172
+ "name": "maxRaise",
173
+ "type": "uint256",
174
+ "internalType": "uint256"
175
+ },
176
+ {
177
+ "name": "startTime",
178
+ "type": "uint256",
179
+ "internalType": "uint256"
180
+ },
181
+ {
182
+ "name": "endTime",
183
+ "type": "uint256",
184
+ "internalType": "uint256"
185
+ },
186
+ {
187
+ "name": "creator",
188
+ "type": "address",
189
+ "internalType": "address"
190
+ },
191
+ {
192
+ "name": "protocolFeeBps",
193
+ "type": "uint256",
194
+ "internalType": "uint256"
195
+ }
196
+ ]
197
+ },
198
+ {
199
+ "name": "state",
200
+ "type": "uint8",
201
+ "internalType": "enum TokenAuction.AuctionState"
202
+ },
203
+ {
204
+ "name": "totalRaised",
205
+ "type": "uint256",
206
+ "internalType": "uint256"
207
+ },
208
+ {
209
+ "name": "totalSold",
210
+ "type": "uint256",
211
+ "internalType": "uint256"
212
+ }
213
+ ],
214
+ "stateMutability": "view"
215
+ },
216
+ {
217
+ "type": "function",
218
+ "name": "buyTokens",
219
+ "inputs": [
220
+ {
221
+ "name": "auctionId",
222
+ "type": "uint256",
223
+ "internalType": "uint256"
224
+ },
225
+ {
226
+ "name": "amount",
227
+ "type": "uint256",
228
+ "internalType": "uint256"
229
+ }
230
+ ],
231
+ "outputs": [],
232
+ "stateMutability": "nonpayable"
233
+ },
234
+ {
235
+ "type": "function",
236
+ "name": "completeAuction",
237
+ "inputs": [
238
+ {
239
+ "name": "auctionId",
240
+ "type": "uint256",
241
+ "internalType": "uint256"
242
+ }
243
+ ],
244
+ "outputs": [],
245
+ "stateMutability": "nonpayable"
246
+ },
247
+ {
248
+ "type": "function",
249
+ "name": "createAuction",
250
+ "inputs": [
251
+ {
252
+ "name": "name",
253
+ "type": "string",
254
+ "internalType": "string"
255
+ },
256
+ {
257
+ "name": "symbol",
258
+ "type": "string",
259
+ "internalType": "string"
260
+ },
261
+ {
262
+ "name": "maxSupply",
263
+ "type": "uint256",
264
+ "internalType": "uint256"
265
+ },
266
+ {
267
+ "name": "paymentToken",
268
+ "type": "address",
269
+ "internalType": "address"
270
+ },
271
+ {
272
+ "name": "basePrice",
273
+ "type": "uint256",
274
+ "internalType": "uint256"
275
+ },
276
+ {
277
+ "name": "slope",
278
+ "type": "uint256",
279
+ "internalType": "uint256"
280
+ },
281
+ {
282
+ "name": "maxRaise",
283
+ "type": "uint256",
284
+ "internalType": "uint256"
285
+ },
286
+ {
287
+ "name": "startTime",
288
+ "type": "uint256",
289
+ "internalType": "uint256"
290
+ },
291
+ {
292
+ "name": "endTime",
293
+ "type": "uint256",
294
+ "internalType": "uint256"
295
+ }
296
+ ],
297
+ "outputs": [
298
+ {
299
+ "name": "auctionId",
300
+ "type": "uint256",
301
+ "internalType": "uint256"
302
+ }
303
+ ],
304
+ "stateMutability": "nonpayable"
305
+ },
306
+ {
307
+ "type": "function",
308
+ "name": "defaultFeeBps",
309
+ "inputs": [],
310
+ "outputs": [
311
+ {
312
+ "name": "",
313
+ "type": "uint256",
314
+ "internalType": "uint256"
315
+ }
316
+ ],
317
+ "stateMutability": "view"
318
+ },
319
+ {
320
+ "type": "function",
321
+ "name": "getBuyCost",
322
+ "inputs": [
323
+ {
324
+ "name": "auctionId",
325
+ "type": "uint256",
326
+ "internalType": "uint256"
327
+ },
328
+ {
329
+ "name": "amount",
330
+ "type": "uint256",
331
+ "internalType": "uint256"
332
+ }
333
+ ],
334
+ "outputs": [
335
+ {
336
+ "name": "cost",
337
+ "type": "uint256",
338
+ "internalType": "uint256"
339
+ },
340
+ {
341
+ "name": "fee",
342
+ "type": "uint256",
343
+ "internalType": "uint256"
344
+ }
345
+ ],
346
+ "stateMutability": "view"
347
+ },
348
+ {
349
+ "type": "function",
350
+ "name": "getSpotPrice",
351
+ "inputs": [
352
+ {
353
+ "name": "auctionId",
354
+ "type": "uint256",
355
+ "internalType": "uint256"
356
+ }
357
+ ],
358
+ "outputs": [
359
+ {
360
+ "name": "",
361
+ "type": "uint256",
362
+ "internalType": "uint256"
363
+ }
364
+ ],
365
+ "stateMutability": "view"
366
+ },
367
+ {
368
+ "type": "function",
369
+ "name": "owner",
370
+ "inputs": [],
371
+ "outputs": [
372
+ {
373
+ "name": "",
374
+ "type": "address",
375
+ "internalType": "address"
376
+ }
377
+ ],
378
+ "stateMutability": "view"
379
+ },
380
+ {
381
+ "type": "function",
382
+ "name": "proceedsWithdrawn",
383
+ "inputs": [
384
+ {
385
+ "name": "",
386
+ "type": "uint256",
387
+ "internalType": "uint256"
388
+ }
389
+ ],
390
+ "outputs": [
391
+ {
392
+ "name": "",
393
+ "type": "bool",
394
+ "internalType": "bool"
395
+ }
396
+ ],
397
+ "stateMutability": "view"
398
+ },
399
+ {
400
+ "type": "function",
401
+ "name": "protocolFeeRecipient",
402
+ "inputs": [],
403
+ "outputs": [
404
+ {
405
+ "name": "",
406
+ "type": "address",
407
+ "internalType": "address"
408
+ }
409
+ ],
410
+ "stateMutability": "view"
411
+ },
412
+ {
413
+ "type": "function",
414
+ "name": "renounceOwnership",
415
+ "inputs": [],
416
+ "outputs": [],
417
+ "stateMutability": "nonpayable"
418
+ },
419
+ {
420
+ "type": "function",
421
+ "name": "transferOwnership",
422
+ "inputs": [
423
+ {
424
+ "name": "newOwner",
425
+ "type": "address",
426
+ "internalType": "address"
427
+ }
428
+ ],
429
+ "outputs": [],
430
+ "stateMutability": "nonpayable"
431
+ },
432
+ {
433
+ "type": "function",
434
+ "name": "userPurchases",
435
+ "inputs": [
436
+ {
437
+ "name": "",
438
+ "type": "uint256",
439
+ "internalType": "uint256"
440
+ },
441
+ {
442
+ "name": "",
443
+ "type": "address",
444
+ "internalType": "address"
445
+ }
446
+ ],
447
+ "outputs": [
448
+ {
449
+ "name": "",
450
+ "type": "uint256",
451
+ "internalType": "uint256"
452
+ }
453
+ ],
454
+ "stateMutability": "view"
455
+ },
456
+ {
457
+ "type": "function",
458
+ "name": "withdrawProceeds",
459
+ "inputs": [
460
+ {
461
+ "name": "auctionId",
462
+ "type": "uint256",
463
+ "internalType": "uint256"
464
+ }
465
+ ],
466
+ "outputs": [],
467
+ "stateMutability": "nonpayable"
468
+ },
469
+ {
470
+ "type": "event",
471
+ "name": "AuctionCompleted",
472
+ "inputs": [
473
+ {
474
+ "name": "auctionId",
475
+ "type": "uint256",
476
+ "indexed": true,
477
+ "internalType": "uint256"
478
+ },
479
+ {
480
+ "name": "totalRaised",
481
+ "type": "uint256",
482
+ "indexed": false,
483
+ "internalType": "uint256"
484
+ },
485
+ {
486
+ "name": "totalSold",
487
+ "type": "uint256",
488
+ "indexed": false,
489
+ "internalType": "uint256"
490
+ }
491
+ ],
492
+ "anonymous": false
493
+ },
494
+ {
495
+ "type": "event",
496
+ "name": "AuctionCreated",
497
+ "inputs": [
498
+ {
499
+ "name": "auctionId",
500
+ "type": "uint256",
501
+ "indexed": true,
502
+ "internalType": "uint256"
503
+ },
504
+ {
505
+ "name": "creator",
506
+ "type": "address",
507
+ "indexed": true,
508
+ "internalType": "address"
509
+ },
510
+ {
511
+ "name": "token",
512
+ "type": "address",
513
+ "indexed": false,
514
+ "internalType": "address"
515
+ },
516
+ {
517
+ "name": "paymentToken",
518
+ "type": "address",
519
+ "indexed": false,
520
+ "internalType": "address"
521
+ },
522
+ {
523
+ "name": "basePrice",
524
+ "type": "uint256",
525
+ "indexed": false,
526
+ "internalType": "uint256"
527
+ },
528
+ {
529
+ "name": "slope",
530
+ "type": "uint256",
531
+ "indexed": false,
532
+ "internalType": "uint256"
533
+ },
534
+ {
535
+ "name": "maxRaise",
536
+ "type": "uint256",
537
+ "indexed": false,
538
+ "internalType": "uint256"
539
+ },
540
+ {
541
+ "name": "startTime",
542
+ "type": "uint256",
543
+ "indexed": false,
544
+ "internalType": "uint256"
545
+ },
546
+ {
547
+ "name": "endTime",
548
+ "type": "uint256",
549
+ "indexed": false,
550
+ "internalType": "uint256"
551
+ }
552
+ ],
553
+ "anonymous": false
554
+ },
555
+ {
556
+ "type": "event",
557
+ "name": "AuctionMigrated",
558
+ "inputs": [
559
+ {
560
+ "name": "auctionId",
561
+ "type": "uint256",
562
+ "indexed": true,
563
+ "internalType": "uint256"
564
+ },
565
+ {
566
+ "name": "liquidityPool",
567
+ "type": "address",
568
+ "indexed": false,
569
+ "internalType": "address"
570
+ }
571
+ ],
572
+ "anonymous": false
573
+ },
574
+ {
575
+ "type": "event",
576
+ "name": "OwnershipTransferred",
577
+ "inputs": [
578
+ {
579
+ "name": "previousOwner",
580
+ "type": "address",
581
+ "indexed": true,
582
+ "internalType": "address"
583
+ },
584
+ {
585
+ "name": "newOwner",
586
+ "type": "address",
587
+ "indexed": true,
588
+ "internalType": "address"
589
+ }
590
+ ],
591
+ "anonymous": false
592
+ },
593
+ {
594
+ "type": "event",
595
+ "name": "ProceedsWithdrawn",
596
+ "inputs": [
597
+ {
598
+ "name": "auctionId",
599
+ "type": "uint256",
600
+ "indexed": true,
601
+ "internalType": "uint256"
602
+ },
603
+ {
604
+ "name": "creator",
605
+ "type": "address",
606
+ "indexed": true,
607
+ "internalType": "address"
608
+ },
609
+ {
610
+ "name": "amount",
611
+ "type": "uint256",
612
+ "indexed": false,
613
+ "internalType": "uint256"
614
+ }
615
+ ],
616
+ "anonymous": false
617
+ },
618
+ {
619
+ "type": "event",
620
+ "name": "TokensPurchased",
621
+ "inputs": [
622
+ {
623
+ "name": "auctionId",
624
+ "type": "uint256",
625
+ "indexed": true,
626
+ "internalType": "uint256"
627
+ },
628
+ {
629
+ "name": "buyer",
630
+ "type": "address",
631
+ "indexed": true,
632
+ "internalType": "address"
633
+ },
634
+ {
635
+ "name": "amount",
636
+ "type": "uint256",
637
+ "indexed": false,
638
+ "internalType": "uint256"
639
+ },
640
+ {
641
+ "name": "cost",
642
+ "type": "uint256",
643
+ "indexed": false,
644
+ "internalType": "uint256"
645
+ },
646
+ {
647
+ "name": "protocolFee",
648
+ "type": "uint256",
649
+ "indexed": false,
650
+ "internalType": "uint256"
651
+ },
652
+ {
653
+ "name": "newTotalRaised",
654
+ "type": "uint256",
655
+ "indexed": false,
656
+ "internalType": "uint256"
657
+ },
658
+ {
659
+ "name": "newTotalSold",
660
+ "type": "uint256",
661
+ "indexed": false,
662
+ "internalType": "uint256"
663
+ }
664
+ ],
665
+ "anonymous": false
666
+ },
667
+ {
668
+ "type": "error",
669
+ "name": "OwnableInvalidOwner",
670
+ "inputs": [
671
+ {
672
+ "name": "owner",
673
+ "type": "address",
674
+ "internalType": "address"
675
+ }
676
+ ]
677
+ },
678
+ {
679
+ "type": "error",
680
+ "name": "OwnableUnauthorizedAccount",
681
+ "inputs": [
682
+ {
683
+ "name": "account",
684
+ "type": "address",
685
+ "internalType": "address"
686
+ }
687
+ ]
688
+ },
689
+ {
690
+ "type": "error",
691
+ "name": "ReentrancyGuardReentrantCall",
692
+ "inputs": []
693
+ },
694
+ {
695
+ "type": "error",
696
+ "name": "SafeERC20FailedOperation",
697
+ "inputs": [
698
+ {
699
+ "name": "token",
700
+ "type": "address",
701
+ "internalType": "address"
702
+ }
703
+ ]
704
+ }
705
+ ];
706
+
707
+ // src/utils/bonding-curve.ts
708
+ function calculateBuyCost(currentSupply, amount, basePrice, slope) {
709
+ const linearCost = basePrice * amount;
710
+ const curveCost = slope * amount * (2n * currentSupply + amount) / 2n;
711
+ return linearCost + curveCost;
712
+ }
713
+ function spotPrice(currentSupply, basePrice, slope) {
714
+ return basePrice + slope * currentSupply;
715
+ }
716
+ function calculateBuyQuote(currentSupply, amount, basePrice, slope, feeBps) {
717
+ const cost = calculateBuyCost(currentSupply, amount, basePrice, slope);
718
+ const fee = cost * feeBps / 10000n;
719
+ return {
720
+ cost,
721
+ fee,
722
+ total: cost + fee,
723
+ spotPriceAfter: spotPrice(currentSupply + amount, basePrice, slope)
724
+ };
725
+ }
726
+
727
+ // src/utils/chains.ts
728
+ var import_chains = require("viem/chains");
729
+ var CHAINS = {
730
+ 84532: import_chains.baseSepolia,
731
+ 8453: import_chains.base
732
+ };
733
+
734
+ // src/client.ts
735
+ var AuctionFlowSDK = class {
736
+ publicClient;
737
+ walletClient;
738
+ auctionAddress;
739
+ chainId;
740
+ chain;
741
+ constructor(params) {
742
+ this.chainId = params.chainId;
743
+ this.chain = CHAINS[params.chainId];
744
+ this.auctionAddress = AUCTION_ADDRESSES[params.chainId];
745
+ if (this.auctionAddress === import_viem.zeroAddress) {
746
+ throw new Error(
747
+ `AuctionFlow is not yet deployed on chain ${params.chainId}. Supported chains: ${Object.entries(AUCTION_ADDRESSES).filter(([, addr]) => addr !== import_viem.zeroAddress).map(([id]) => id).join(", ")}.`
748
+ );
749
+ }
750
+ this.publicClient = (0, import_viem.createPublicClient)({
751
+ chain: this.chain,
752
+ transport: (0, import_viem.http)(params.rpcUrl)
753
+ });
754
+ this.walletClient = params.walletClient;
755
+ }
756
+ // Builder
757
+ buildAuction() {
758
+ return new AuctionBuilder();
759
+ }
760
+ async createAuction(config) {
761
+ if (!this.walletClient) throw new Error("Wallet client required");
762
+ const hash = await this.walletClient.writeContract({
763
+ chain: this.chain,
764
+ account: this.walletClient.account,
765
+ address: this.auctionAddress,
766
+ abi: tokenAuctionAbi,
767
+ functionName: "createAuction",
768
+ args: [
769
+ config.name,
770
+ config.symbol,
771
+ config.maxSupply,
772
+ config.paymentToken,
773
+ config.basePrice,
774
+ config.slope,
775
+ config.maxRaise,
776
+ config.startTime,
777
+ config.endTime
778
+ ]
779
+ });
780
+ return hash;
781
+ }
782
+ async buyTokens(auctionId, amount) {
783
+ if (!this.walletClient) throw new Error("Wallet client required");
784
+ const hash = await this.walletClient.writeContract({
785
+ chain: this.chain,
786
+ account: this.walletClient.account,
787
+ address: this.auctionAddress,
788
+ abi: tokenAuctionAbi,
789
+ functionName: "buyTokens",
790
+ args: [auctionId, amount]
791
+ });
792
+ return hash;
793
+ }
794
+ /**
795
+ * Withdraw a completed auction's raised payment tokens to its creator.
796
+ * Only the auction's creator can call this, and only once.
797
+ */
798
+ async withdrawProceeds(auctionId) {
799
+ if (!this.walletClient) throw new Error("Wallet client required");
800
+ const hash = await this.walletClient.writeContract({
801
+ chain: this.chain,
802
+ account: this.walletClient.account,
803
+ address: this.auctionAddress,
804
+ abi: tokenAuctionAbi,
805
+ functionName: "withdrawProceeds",
806
+ args: [auctionId]
807
+ });
808
+ return hash;
809
+ }
810
+ // Read: Has an auction's creator already withdrawn its proceeds?
811
+ async hasWithdrawnProceeds(auctionId) {
812
+ return this.publicClient.readContract({
813
+ address: this.auctionAddress,
814
+ abi: tokenAuctionAbi,
815
+ functionName: "proceedsWithdrawn",
816
+ args: [auctionId]
817
+ });
818
+ }
819
+ // Read: Get auction data
820
+ async getAuction(auctionId) {
821
+ const result = await this.publicClient.readContract({
822
+ address: this.auctionAddress,
823
+ abi: tokenAuctionAbi,
824
+ functionName: "auctions",
825
+ args: [auctionId]
826
+ });
827
+ return this.parseAuctionResult(auctionId, result);
828
+ }
829
+ // Read: Get buy quote (off-chain calculation)
830
+ async getQuote(auctionId, amount) {
831
+ const auction = await this.getAuction(auctionId);
832
+ const quote = calculateBuyQuote(
833
+ auction.totalSold,
834
+ amount,
835
+ auction.basePrice,
836
+ auction.slope,
837
+ auction.protocolFeeBps
838
+ );
839
+ return {
840
+ cost: quote.cost,
841
+ fee: quote.fee,
842
+ totalCost: quote.total,
843
+ spotPriceAfter: quote.spotPriceAfter
844
+ };
845
+ }
846
+ // Read: Get spot price
847
+ async getSpotPrice(auctionId) {
848
+ return this.publicClient.readContract({
849
+ address: this.auctionAddress,
850
+ abi: tokenAuctionAbi,
851
+ functionName: "getSpotPrice",
852
+ args: [auctionId]
853
+ });
854
+ }
855
+ parseAuctionResult(id, raw) {
856
+ return {
857
+ id,
858
+ token: raw.config.token,
859
+ paymentToken: raw.config.paymentToken,
860
+ creator: raw.config.creator,
861
+ basePrice: raw.config.basePrice,
862
+ slope: raw.config.slope,
863
+ maxRaise: raw.config.maxRaise,
864
+ startTime: raw.config.startTime,
865
+ endTime: raw.config.endTime,
866
+ state: raw.state,
867
+ totalRaised: raw.totalRaised,
868
+ totalSold: raw.totalSold,
869
+ protocolFeeBps: raw.config.protocolFeeBps
870
+ };
871
+ }
872
+ };
873
+
874
+ // src/types/index.ts
875
+ var AuctionState = /* @__PURE__ */ ((AuctionState2) => {
876
+ AuctionState2[AuctionState2["PENDING"] = 0] = "PENDING";
877
+ AuctionState2[AuctionState2["ACTIVE"] = 1] = "ACTIVE";
878
+ AuctionState2[AuctionState2["COMPLETED"] = 2] = "COMPLETED";
879
+ AuctionState2[AuctionState2["MIGRATED"] = 3] = "MIGRATED";
880
+ return AuctionState2;
881
+ })(AuctionState || {});
882
+ // Annotate the CommonJS export names for ESM import in node:
883
+ 0 && (module.exports = {
884
+ AUCTION_ADDRESSES,
885
+ AuctionBuilder,
886
+ AuctionFlowSDK,
887
+ AuctionState,
888
+ USDC_ADDRESSES,
889
+ calculateBuyCost,
890
+ calculateBuyQuote,
891
+ spotPrice
892
+ });
893
+ //# sourceMappingURL=index.js.map