auctionflow-sdk 2.0.1 → 3.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 +48 -11
- package/dist/index.d.mts +1288 -6
- package/dist/index.d.ts +1288 -6
- package/dist/index.js +505 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +502 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -77,7 +77,7 @@ var AuctionBuilder = class {
|
|
|
77
77
|
|
|
78
78
|
// src/constants/addresses.ts
|
|
79
79
|
var AUCTION_ADDRESSES = {
|
|
80
|
-
84532: "
|
|
80
|
+
84532: "0x990a04ffe0d49356321271629889fa0413ad1bdc",
|
|
81
81
|
8453: "0x0000000000000000000000000000000000000000"
|
|
82
82
|
// not yet deployed
|
|
83
83
|
};
|
|
@@ -85,6 +85,10 @@ var USDC_ADDRESSES = {
|
|
|
85
85
|
84532: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
86
86
|
8453: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
87
87
|
};
|
|
88
|
+
var WETH_ADDRESSES = {
|
|
89
|
+
84532: "0x4200000000000000000000000000000000000006",
|
|
90
|
+
8453: "0x4200000000000000000000000000000000000006"
|
|
91
|
+
};
|
|
88
92
|
|
|
89
93
|
// src/abis/token-auction.ts
|
|
90
94
|
var tokenAuctionAbi = [
|
|
@@ -105,10 +109,19 @@ var tokenAuctionAbi = [
|
|
|
105
109
|
"name": "positionManager_",
|
|
106
110
|
"type": "address",
|
|
107
111
|
"internalType": "contract INonfungiblePositionManager"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "weth_",
|
|
115
|
+
"type": "address",
|
|
116
|
+
"internalType": "contract IWETH9"
|
|
108
117
|
}
|
|
109
118
|
],
|
|
110
119
|
"stateMutability": "nonpayable"
|
|
111
120
|
},
|
|
121
|
+
{
|
|
122
|
+
"type": "receive",
|
|
123
|
+
"stateMutability": "payable"
|
|
124
|
+
},
|
|
112
125
|
{
|
|
113
126
|
"type": "function",
|
|
114
127
|
"name": "MAX_FEE_BPS",
|
|
@@ -161,6 +174,13 @@ var tokenAuctionAbi = [
|
|
|
161
174
|
],
|
|
162
175
|
"stateMutability": "view"
|
|
163
176
|
},
|
|
177
|
+
{
|
|
178
|
+
"type": "function",
|
|
179
|
+
"name": "acceptOwnership",
|
|
180
|
+
"inputs": [],
|
|
181
|
+
"outputs": [],
|
|
182
|
+
"stateMutability": "nonpayable"
|
|
183
|
+
},
|
|
164
184
|
{
|
|
165
185
|
"type": "function",
|
|
166
186
|
"name": "auctionCount",
|
|
@@ -278,6 +298,86 @@ var tokenAuctionAbi = [
|
|
|
278
298
|
"outputs": [],
|
|
279
299
|
"stateMutability": "nonpayable"
|
|
280
300
|
},
|
|
301
|
+
{
|
|
302
|
+
"type": "function",
|
|
303
|
+
"name": "buyTokensWithETH",
|
|
304
|
+
"inputs": [
|
|
305
|
+
{
|
|
306
|
+
"name": "auctionId",
|
|
307
|
+
"type": "uint256",
|
|
308
|
+
"internalType": "uint256"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"name": "amount",
|
|
312
|
+
"type": "uint256",
|
|
313
|
+
"internalType": "uint256"
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
"outputs": [],
|
|
317
|
+
"stateMutability": "payable"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"type": "function",
|
|
321
|
+
"name": "claim",
|
|
322
|
+
"inputs": [
|
|
323
|
+
{
|
|
324
|
+
"name": "token",
|
|
325
|
+
"type": "address",
|
|
326
|
+
"internalType": "contract IERC20"
|
|
327
|
+
}
|
|
328
|
+
],
|
|
329
|
+
"outputs": [
|
|
330
|
+
{
|
|
331
|
+
"name": "amount",
|
|
332
|
+
"type": "uint256",
|
|
333
|
+
"internalType": "uint256"
|
|
334
|
+
}
|
|
335
|
+
],
|
|
336
|
+
"stateMutability": "nonpayable"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"type": "function",
|
|
340
|
+
"name": "claimProtocolFees",
|
|
341
|
+
"inputs": [
|
|
342
|
+
{
|
|
343
|
+
"name": "token",
|
|
344
|
+
"type": "address",
|
|
345
|
+
"internalType": "contract IERC20"
|
|
346
|
+
}
|
|
347
|
+
],
|
|
348
|
+
"outputs": [
|
|
349
|
+
{
|
|
350
|
+
"name": "amount",
|
|
351
|
+
"type": "uint256",
|
|
352
|
+
"internalType": "uint256"
|
|
353
|
+
}
|
|
354
|
+
],
|
|
355
|
+
"stateMutability": "nonpayable"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
"type": "function",
|
|
359
|
+
"name": "claimable",
|
|
360
|
+
"inputs": [
|
|
361
|
+
{
|
|
362
|
+
"name": "",
|
|
363
|
+
"type": "address",
|
|
364
|
+
"internalType": "address"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"name": "",
|
|
368
|
+
"type": "address",
|
|
369
|
+
"internalType": "address"
|
|
370
|
+
}
|
|
371
|
+
],
|
|
372
|
+
"outputs": [
|
|
373
|
+
{
|
|
374
|
+
"name": "",
|
|
375
|
+
"type": "uint256",
|
|
376
|
+
"internalType": "uint256"
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
"stateMutability": "view"
|
|
380
|
+
},
|
|
281
381
|
{
|
|
282
382
|
"type": "function",
|
|
283
383
|
"name": "collectFees",
|
|
@@ -479,6 +579,11 @@ var tokenAuctionAbi = [
|
|
|
479
579
|
"name": "metadataURI",
|
|
480
580
|
"type": "string",
|
|
481
581
|
"internalType": "string"
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
"name": "paymentToken",
|
|
585
|
+
"type": "address",
|
|
586
|
+
"internalType": "address"
|
|
482
587
|
}
|
|
483
588
|
],
|
|
484
589
|
"outputs": [
|
|
@@ -492,8 +597,14 @@ var tokenAuctionAbi = [
|
|
|
492
597
|
},
|
|
493
598
|
{
|
|
494
599
|
"type": "function",
|
|
495
|
-
"name": "
|
|
496
|
-
"inputs": [
|
|
600
|
+
"name": "launchPresets",
|
|
601
|
+
"inputs": [
|
|
602
|
+
{
|
|
603
|
+
"name": "",
|
|
604
|
+
"type": "address",
|
|
605
|
+
"internalType": "address"
|
|
606
|
+
}
|
|
607
|
+
],
|
|
497
608
|
"outputs": [
|
|
498
609
|
{
|
|
499
610
|
"name": "paymentToken",
|
|
@@ -554,6 +665,58 @@ var tokenAuctionAbi = [
|
|
|
554
665
|
],
|
|
555
666
|
"stateMutability": "view"
|
|
556
667
|
},
|
|
668
|
+
{
|
|
669
|
+
"type": "function",
|
|
670
|
+
"name": "pause",
|
|
671
|
+
"inputs": [],
|
|
672
|
+
"outputs": [],
|
|
673
|
+
"stateMutability": "nonpayable"
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
"type": "function",
|
|
677
|
+
"name": "paused",
|
|
678
|
+
"inputs": [],
|
|
679
|
+
"outputs": [
|
|
680
|
+
{
|
|
681
|
+
"name": "",
|
|
682
|
+
"type": "bool",
|
|
683
|
+
"internalType": "bool"
|
|
684
|
+
}
|
|
685
|
+
],
|
|
686
|
+
"stateMutability": "view"
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
"type": "function",
|
|
690
|
+
"name": "paymentTokenAllowed",
|
|
691
|
+
"inputs": [
|
|
692
|
+
{
|
|
693
|
+
"name": "",
|
|
694
|
+
"type": "address",
|
|
695
|
+
"internalType": "address"
|
|
696
|
+
}
|
|
697
|
+
],
|
|
698
|
+
"outputs": [
|
|
699
|
+
{
|
|
700
|
+
"name": "",
|
|
701
|
+
"type": "bool",
|
|
702
|
+
"internalType": "bool"
|
|
703
|
+
}
|
|
704
|
+
],
|
|
705
|
+
"stateMutability": "view"
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
"type": "function",
|
|
709
|
+
"name": "pendingOwner",
|
|
710
|
+
"inputs": [],
|
|
711
|
+
"outputs": [
|
|
712
|
+
{
|
|
713
|
+
"name": "",
|
|
714
|
+
"type": "address",
|
|
715
|
+
"internalType": "address"
|
|
716
|
+
}
|
|
717
|
+
],
|
|
718
|
+
"stateMutability": "view"
|
|
719
|
+
},
|
|
557
720
|
{
|
|
558
721
|
"type": "function",
|
|
559
722
|
"name": "poolOf",
|
|
@@ -637,6 +800,25 @@ var tokenAuctionAbi = [
|
|
|
637
800
|
],
|
|
638
801
|
"stateMutability": "view"
|
|
639
802
|
},
|
|
803
|
+
{
|
|
804
|
+
"type": "function",
|
|
805
|
+
"name": "protocolFees",
|
|
806
|
+
"inputs": [
|
|
807
|
+
{
|
|
808
|
+
"name": "",
|
|
809
|
+
"type": "address",
|
|
810
|
+
"internalType": "address"
|
|
811
|
+
}
|
|
812
|
+
],
|
|
813
|
+
"outputs": [
|
|
814
|
+
{
|
|
815
|
+
"name": "",
|
|
816
|
+
"type": "uint256",
|
|
817
|
+
"internalType": "uint256"
|
|
818
|
+
}
|
|
819
|
+
],
|
|
820
|
+
"stateMutability": "view"
|
|
821
|
+
},
|
|
640
822
|
{
|
|
641
823
|
"type": "function",
|
|
642
824
|
"name": "renounceOwnership",
|
|
@@ -667,6 +849,29 @@ var tokenAuctionAbi = [
|
|
|
667
849
|
"outputs": [],
|
|
668
850
|
"stateMutability": "nonpayable"
|
|
669
851
|
},
|
|
852
|
+
{
|
|
853
|
+
"type": "function",
|
|
854
|
+
"name": "sellTokensForETH",
|
|
855
|
+
"inputs": [
|
|
856
|
+
{
|
|
857
|
+
"name": "auctionId",
|
|
858
|
+
"type": "uint256",
|
|
859
|
+
"internalType": "uint256"
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
"name": "amount",
|
|
863
|
+
"type": "uint256",
|
|
864
|
+
"internalType": "uint256"
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
"name": "minProceeds",
|
|
868
|
+
"type": "uint256",
|
|
869
|
+
"internalType": "uint256"
|
|
870
|
+
}
|
|
871
|
+
],
|
|
872
|
+
"outputs": [],
|
|
873
|
+
"stateMutability": "nonpayable"
|
|
874
|
+
},
|
|
670
875
|
{
|
|
671
876
|
"type": "function",
|
|
672
877
|
"name": "setDefaultFeeBps",
|
|
@@ -738,6 +943,24 @@ var tokenAuctionAbi = [
|
|
|
738
943
|
"outputs": [],
|
|
739
944
|
"stateMutability": "nonpayable"
|
|
740
945
|
},
|
|
946
|
+
{
|
|
947
|
+
"type": "function",
|
|
948
|
+
"name": "setPaymentTokenAllowed",
|
|
949
|
+
"inputs": [
|
|
950
|
+
{
|
|
951
|
+
"name": "token",
|
|
952
|
+
"type": "address",
|
|
953
|
+
"internalType": "address"
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
"name": "allowed",
|
|
957
|
+
"type": "bool",
|
|
958
|
+
"internalType": "bool"
|
|
959
|
+
}
|
|
960
|
+
],
|
|
961
|
+
"outputs": [],
|
|
962
|
+
"stateMutability": "nonpayable"
|
|
963
|
+
},
|
|
741
964
|
{
|
|
742
965
|
"type": "function",
|
|
743
966
|
"name": "setProtocolFeeRecipient",
|
|
@@ -805,6 +1028,13 @@ var tokenAuctionAbi = [
|
|
|
805
1028
|
"outputs": [],
|
|
806
1029
|
"stateMutability": "nonpayable"
|
|
807
1030
|
},
|
|
1031
|
+
{
|
|
1032
|
+
"type": "function",
|
|
1033
|
+
"name": "unpause",
|
|
1034
|
+
"inputs": [],
|
|
1035
|
+
"outputs": [],
|
|
1036
|
+
"stateMutability": "nonpayable"
|
|
1037
|
+
},
|
|
808
1038
|
{
|
|
809
1039
|
"type": "function",
|
|
810
1040
|
"name": "userPurchases",
|
|
@@ -829,6 +1059,19 @@ var tokenAuctionAbi = [
|
|
|
829
1059
|
],
|
|
830
1060
|
"stateMutability": "view"
|
|
831
1061
|
},
|
|
1062
|
+
{
|
|
1063
|
+
"type": "function",
|
|
1064
|
+
"name": "weth",
|
|
1065
|
+
"inputs": [],
|
|
1066
|
+
"outputs": [
|
|
1067
|
+
{
|
|
1068
|
+
"name": "",
|
|
1069
|
+
"type": "address",
|
|
1070
|
+
"internalType": "contract IWETH9"
|
|
1071
|
+
}
|
|
1072
|
+
],
|
|
1073
|
+
"stateMutability": "view"
|
|
1074
|
+
},
|
|
832
1075
|
{
|
|
833
1076
|
"type": "function",
|
|
834
1077
|
"name": "withdrawProceeds",
|
|
@@ -965,6 +1208,31 @@ var tokenAuctionAbi = [
|
|
|
965
1208
|
],
|
|
966
1209
|
"anonymous": false
|
|
967
1210
|
},
|
|
1211
|
+
{
|
|
1212
|
+
"type": "event",
|
|
1213
|
+
"name": "Claimed",
|
|
1214
|
+
"inputs": [
|
|
1215
|
+
{
|
|
1216
|
+
"name": "token",
|
|
1217
|
+
"type": "address",
|
|
1218
|
+
"indexed": true,
|
|
1219
|
+
"internalType": "address"
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
"name": "account",
|
|
1223
|
+
"type": "address",
|
|
1224
|
+
"indexed": true,
|
|
1225
|
+
"internalType": "address"
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
"name": "amount",
|
|
1229
|
+
"type": "uint256",
|
|
1230
|
+
"indexed": false,
|
|
1231
|
+
"internalType": "uint256"
|
|
1232
|
+
}
|
|
1233
|
+
],
|
|
1234
|
+
"anonymous": false
|
|
1235
|
+
},
|
|
968
1236
|
{
|
|
969
1237
|
"type": "event",
|
|
970
1238
|
"name": "DefaultFeeBpsUpdated",
|
|
@@ -1083,6 +1351,25 @@ var tokenAuctionAbi = [
|
|
|
1083
1351
|
],
|
|
1084
1352
|
"anonymous": false
|
|
1085
1353
|
},
|
|
1354
|
+
{
|
|
1355
|
+
"type": "event",
|
|
1356
|
+
"name": "OwnershipTransferStarted",
|
|
1357
|
+
"inputs": [
|
|
1358
|
+
{
|
|
1359
|
+
"name": "previousOwner",
|
|
1360
|
+
"type": "address",
|
|
1361
|
+
"indexed": true,
|
|
1362
|
+
"internalType": "address"
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
"name": "newOwner",
|
|
1366
|
+
"type": "address",
|
|
1367
|
+
"indexed": true,
|
|
1368
|
+
"internalType": "address"
|
|
1369
|
+
}
|
|
1370
|
+
],
|
|
1371
|
+
"anonymous": false
|
|
1372
|
+
},
|
|
1086
1373
|
{
|
|
1087
1374
|
"type": "event",
|
|
1088
1375
|
"name": "OwnershipTransferred",
|
|
@@ -1102,6 +1389,38 @@ var tokenAuctionAbi = [
|
|
|
1102
1389
|
],
|
|
1103
1390
|
"anonymous": false
|
|
1104
1391
|
},
|
|
1392
|
+
{
|
|
1393
|
+
"type": "event",
|
|
1394
|
+
"name": "Paused",
|
|
1395
|
+
"inputs": [
|
|
1396
|
+
{
|
|
1397
|
+
"name": "account",
|
|
1398
|
+
"type": "address",
|
|
1399
|
+
"indexed": false,
|
|
1400
|
+
"internalType": "address"
|
|
1401
|
+
}
|
|
1402
|
+
],
|
|
1403
|
+
"anonymous": false
|
|
1404
|
+
},
|
|
1405
|
+
{
|
|
1406
|
+
"type": "event",
|
|
1407
|
+
"name": "PaymentTokenAllowedUpdated",
|
|
1408
|
+
"inputs": [
|
|
1409
|
+
{
|
|
1410
|
+
"name": "token",
|
|
1411
|
+
"type": "address",
|
|
1412
|
+
"indexed": true,
|
|
1413
|
+
"internalType": "address"
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
"name": "allowed",
|
|
1417
|
+
"type": "bool",
|
|
1418
|
+
"indexed": false,
|
|
1419
|
+
"internalType": "bool"
|
|
1420
|
+
}
|
|
1421
|
+
],
|
|
1422
|
+
"anonymous": false
|
|
1423
|
+
},
|
|
1105
1424
|
{
|
|
1106
1425
|
"type": "event",
|
|
1107
1426
|
"name": "ProceedsWithdrawn",
|
|
@@ -1146,6 +1465,31 @@ var tokenAuctionAbi = [
|
|
|
1146
1465
|
],
|
|
1147
1466
|
"anonymous": false
|
|
1148
1467
|
},
|
|
1468
|
+
{
|
|
1469
|
+
"type": "event",
|
|
1470
|
+
"name": "ProtocolFeesClaimed",
|
|
1471
|
+
"inputs": [
|
|
1472
|
+
{
|
|
1473
|
+
"name": "token",
|
|
1474
|
+
"type": "address",
|
|
1475
|
+
"indexed": true,
|
|
1476
|
+
"internalType": "address"
|
|
1477
|
+
},
|
|
1478
|
+
{
|
|
1479
|
+
"name": "recipient",
|
|
1480
|
+
"type": "address",
|
|
1481
|
+
"indexed": true,
|
|
1482
|
+
"internalType": "address"
|
|
1483
|
+
},
|
|
1484
|
+
{
|
|
1485
|
+
"name": "amount",
|
|
1486
|
+
"type": "uint256",
|
|
1487
|
+
"indexed": false,
|
|
1488
|
+
"internalType": "uint256"
|
|
1489
|
+
}
|
|
1490
|
+
],
|
|
1491
|
+
"anonymous": false
|
|
1492
|
+
},
|
|
1149
1493
|
{
|
|
1150
1494
|
"type": "event",
|
|
1151
1495
|
"name": "Swept",
|
|
@@ -1269,6 +1613,29 @@ var tokenAuctionAbi = [
|
|
|
1269
1613
|
],
|
|
1270
1614
|
"anonymous": false
|
|
1271
1615
|
},
|
|
1616
|
+
{
|
|
1617
|
+
"type": "event",
|
|
1618
|
+
"name": "Unpaused",
|
|
1619
|
+
"inputs": [
|
|
1620
|
+
{
|
|
1621
|
+
"name": "account",
|
|
1622
|
+
"type": "address",
|
|
1623
|
+
"indexed": false,
|
|
1624
|
+
"internalType": "address"
|
|
1625
|
+
}
|
|
1626
|
+
],
|
|
1627
|
+
"anonymous": false
|
|
1628
|
+
},
|
|
1629
|
+
{
|
|
1630
|
+
"type": "error",
|
|
1631
|
+
"name": "EnforcedPause",
|
|
1632
|
+
"inputs": []
|
|
1633
|
+
},
|
|
1634
|
+
{
|
|
1635
|
+
"type": "error",
|
|
1636
|
+
"name": "ExpectedPause",
|
|
1637
|
+
"inputs": []
|
|
1638
|
+
},
|
|
1272
1639
|
{
|
|
1273
1640
|
"type": "error",
|
|
1274
1641
|
"name": "OwnableInvalidOwner",
|
|
@@ -1373,7 +1740,7 @@ function fillPurchase(currentSupply, requested, basePrice, slope, totalRaised, m
|
|
|
1373
1740
|
if (cost < remaining) return { amount: requested, cost, fillsAuction: false };
|
|
1374
1741
|
if (cost === remaining) return { amount: requested, cost, fillsAuction: true };
|
|
1375
1742
|
const amount = maxBuyable(currentSupply, remaining, basePrice, slope, requested);
|
|
1376
|
-
if (amount === 0n)
|
|
1743
|
+
if (amount === 0n) return { amount: 0n, cost: 0n, fillsAuction: true };
|
|
1377
1744
|
return {
|
|
1378
1745
|
amount,
|
|
1379
1746
|
cost: calculateBuyCost(currentSupply, amount, basePrice, slope),
|
|
@@ -1451,9 +1818,10 @@ var AuctionFlowSDK = class {
|
|
|
1451
1818
|
}
|
|
1452
1819
|
/**
|
|
1453
1820
|
* One-click launch: a token with the protocol's standard curve, threshold
|
|
1454
|
-
* and liquidity share
|
|
1821
|
+
* and liquidity share for `paymentToken`. Trading starts immediately.
|
|
1822
|
+
* Defaults to WETH, so the token trades in plain ETH (see `buyTokensWithETH`).
|
|
1455
1823
|
*/
|
|
1456
|
-
async launch(name, symbol, metadataURI = "") {
|
|
1824
|
+
async launch(name, symbol, metadataURI = "", paymentToken = WETH_ADDRESSES[this.chainId]) {
|
|
1457
1825
|
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1458
1826
|
return this.walletClient.writeContract({
|
|
1459
1827
|
chain: this.chain,
|
|
@@ -1461,9 +1829,20 @@ var AuctionFlowSDK = class {
|
|
|
1461
1829
|
address: this.auctionAddress,
|
|
1462
1830
|
abi: tokenAuctionAbi,
|
|
1463
1831
|
functionName: "launch",
|
|
1464
|
-
args: [name, symbol, metadataURI]
|
|
1832
|
+
args: [name, symbol, metadataURI, paymentToken]
|
|
1465
1833
|
});
|
|
1466
1834
|
}
|
|
1835
|
+
/** The standard launch for `paymentToken`, or null if none is configured. */
|
|
1836
|
+
async getLaunchPreset(paymentToken) {
|
|
1837
|
+
const [token, maxSupply, basePrice, slope, maxRaise, liquidityBps] = await this.publicClient.readContract({
|
|
1838
|
+
address: this.auctionAddress,
|
|
1839
|
+
abi: tokenAuctionAbi,
|
|
1840
|
+
functionName: "launchPresets",
|
|
1841
|
+
args: [paymentToken]
|
|
1842
|
+
});
|
|
1843
|
+
if (token === zeroAddress) return null;
|
|
1844
|
+
return { paymentToken: token, maxSupply, basePrice, slope, maxRaise, liquidityBps };
|
|
1845
|
+
}
|
|
1467
1846
|
/**
|
|
1468
1847
|
* Sell `amount` tokens (in token wei) back to the curve before graduation.
|
|
1469
1848
|
* The contract reverts if the price fell below the bound before the
|
|
@@ -1485,6 +1864,25 @@ var AuctionFlowSDK = class {
|
|
|
1485
1864
|
args: [auctionId, amount, minProceeds]
|
|
1486
1865
|
});
|
|
1487
1866
|
}
|
|
1867
|
+
/**
|
|
1868
|
+
* `sellTokens` for an auction priced in WETH, paid out in plain ETH. Takes
|
|
1869
|
+
* the same `minProceeds` / `slippageBps` options.
|
|
1870
|
+
*/
|
|
1871
|
+
async sellTokensForETH(auctionId, amount, options = {}) {
|
|
1872
|
+
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1873
|
+
const minProceeds = options.minProceeds ?? applySellSlippage(
|
|
1874
|
+
(await this.getSellQuote(auctionId, amount)).netProceeds,
|
|
1875
|
+
options.slippageBps ?? DEFAULT_SLIPPAGE_BPS
|
|
1876
|
+
);
|
|
1877
|
+
return this.walletClient.writeContract({
|
|
1878
|
+
chain: this.chain,
|
|
1879
|
+
account: this.walletClient.account,
|
|
1880
|
+
address: this.auctionAddress,
|
|
1881
|
+
abi: tokenAuctionAbi,
|
|
1882
|
+
functionName: "sellTokensForETH",
|
|
1883
|
+
args: [auctionId, amount, minProceeds]
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1488
1886
|
/** What selling `amount` tokens back to the curve would pay right now. */
|
|
1489
1887
|
async getSellQuote(auctionId, amount) {
|
|
1490
1888
|
const auction = await this.getAuction(auctionId);
|
|
@@ -1521,6 +1919,33 @@ var AuctionFlowSDK = class {
|
|
|
1521
1919
|
});
|
|
1522
1920
|
return hash;
|
|
1523
1921
|
}
|
|
1922
|
+
/**
|
|
1923
|
+
* `buyTokens` for an auction priced in WETH, paid in plain ETH, with no
|
|
1924
|
+
* token approval. The ETH sent is the most the purchase may cost (`maxCost`,
|
|
1925
|
+
* or a fresh quote plus `slippageBps`); whatever it doesn't use is refunded
|
|
1926
|
+
* in the same transaction.
|
|
1927
|
+
*/
|
|
1928
|
+
async buyTokensWithETH(auctionId, amount, options = {}) {
|
|
1929
|
+
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1930
|
+
const maxCost = options.maxCost ?? applySlippage(
|
|
1931
|
+
(await this.getQuote(auctionId, amount)).totalCost,
|
|
1932
|
+
options.slippageBps ?? DEFAULT_SLIPPAGE_BPS
|
|
1933
|
+
);
|
|
1934
|
+
return this.walletClient.writeContract({
|
|
1935
|
+
chain: this.chain,
|
|
1936
|
+
account: this.walletClient.account,
|
|
1937
|
+
address: this.auctionAddress,
|
|
1938
|
+
abi: tokenAuctionAbi,
|
|
1939
|
+
functionName: "buyTokensWithETH",
|
|
1940
|
+
args: [auctionId, amount],
|
|
1941
|
+
value: maxCost
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
/** Is this auction priced in WETH, so it can be bought and sold with plain ETH? */
|
|
1945
|
+
async isPricedInETH(auctionId) {
|
|
1946
|
+
const auction = await this.getAuction(auctionId);
|
|
1947
|
+
return auction.paymentToken.toLowerCase() === WETH_ADDRESSES[this.chainId].toLowerCase();
|
|
1948
|
+
}
|
|
1524
1949
|
/**
|
|
1525
1950
|
* Pay a completed auction's creator their share of the raise: everything
|
|
1526
1951
|
* not reserved for Uniswap liquidity. Creator only, once, before or after
|
|
@@ -1547,12 +1972,24 @@ var AuctionFlowSDK = class {
|
|
|
1547
1972
|
return this.write("migrate", [auctionId]);
|
|
1548
1973
|
}
|
|
1549
1974
|
/**
|
|
1550
|
-
* Collect the migrated pool's trading fees. The protocol
|
|
1551
|
-
* the
|
|
1975
|
+
* Collect the migrated pool's trading fees. The protocol's share accrues to
|
|
1976
|
+
* the protocol and the rest is credited to the creator, who withdraws it
|
|
1977
|
+
* with `claim`. Anyone may call it.
|
|
1552
1978
|
*/
|
|
1553
1979
|
async collectFees(auctionId) {
|
|
1554
1980
|
return this.write("collectFees", [auctionId]);
|
|
1555
1981
|
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Withdraw everything credited to the connected account in `token`: a
|
|
1984
|
+
* creator's share of pool fees, and any reserve migration couldn't place.
|
|
1985
|
+
*/
|
|
1986
|
+
async claim(token) {
|
|
1987
|
+
return this.write("claim", [token]);
|
|
1988
|
+
}
|
|
1989
|
+
/** Send the protocol's unclaimed fees in `token` to the fee recipient. Anyone may call it. */
|
|
1990
|
+
async claimProtocolFees(token) {
|
|
1991
|
+
return this.write("claimProtocolFees", [token]);
|
|
1992
|
+
}
|
|
1556
1993
|
/** The Uniswap pool and position for a migrated auction. */
|
|
1557
1994
|
async getMigration(auctionId) {
|
|
1558
1995
|
const [pool, positionId] = await Promise.all([
|
|
@@ -1594,15 +2031,66 @@ var AuctionFlowSDK = class {
|
|
|
1594
2031
|
args: [auctionId]
|
|
1595
2032
|
});
|
|
1596
2033
|
}
|
|
2034
|
+
// Read: Is the protocol paused? While paused, launches and curve buys
|
|
2035
|
+
// revert; selling back, migration, withdrawals, fee collection and claims
|
|
2036
|
+
// still work.
|
|
2037
|
+
async isPaused() {
|
|
2038
|
+
return this.publicClient.readContract({
|
|
2039
|
+
address: this.auctionAddress,
|
|
2040
|
+
abi: tokenAuctionAbi,
|
|
2041
|
+
functionName: "paused"
|
|
2042
|
+
});
|
|
2043
|
+
}
|
|
2044
|
+
// Read: How much of `token` is credited to `account`, waiting for `claim`?
|
|
2045
|
+
async getClaimable(token, account) {
|
|
2046
|
+
return this.publicClient.readContract({
|
|
2047
|
+
address: this.auctionAddress,
|
|
2048
|
+
abi: tokenAuctionAbi,
|
|
2049
|
+
functionName: "claimable",
|
|
2050
|
+
args: [token, account]
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
// Read: Protocol fees in `token` earned and not yet claimed.
|
|
2054
|
+
async getProtocolFees(token) {
|
|
2055
|
+
return this.publicClient.readContract({
|
|
2056
|
+
address: this.auctionAddress,
|
|
2057
|
+
abi: tokenAuctionAbi,
|
|
2058
|
+
functionName: "protocolFees",
|
|
2059
|
+
args: [token]
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
// Read: May new auctions be priced in `token`?
|
|
2063
|
+
async isPaymentTokenAllowed(token) {
|
|
2064
|
+
return this.publicClient.readContract({
|
|
2065
|
+
address: this.auctionAddress,
|
|
2066
|
+
abi: tokenAuctionAbi,
|
|
2067
|
+
functionName: "paymentTokenAllowed",
|
|
2068
|
+
args: [token]
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
1597
2071
|
// Read: Get auction data
|
|
1598
2072
|
async getAuction(auctionId) {
|
|
1599
|
-
const
|
|
2073
|
+
const [config, state, totalRaised, totalSold] = await this.publicClient.readContract({
|
|
1600
2074
|
address: this.auctionAddress,
|
|
1601
2075
|
abi: tokenAuctionAbi,
|
|
1602
2076
|
functionName: "auctions",
|
|
1603
2077
|
args: [auctionId]
|
|
1604
2078
|
});
|
|
1605
|
-
return
|
|
2079
|
+
return {
|
|
2080
|
+
id: auctionId,
|
|
2081
|
+
token: config.token,
|
|
2082
|
+
paymentToken: config.paymentToken,
|
|
2083
|
+
creator: config.creator,
|
|
2084
|
+
basePrice: config.basePrice,
|
|
2085
|
+
slope: config.slope,
|
|
2086
|
+
maxRaise: config.maxRaise,
|
|
2087
|
+
state,
|
|
2088
|
+
totalRaised,
|
|
2089
|
+
totalSold,
|
|
2090
|
+
protocolFeeBps: config.protocolFeeBps,
|
|
2091
|
+
liquidityBps: config.liquidityBps,
|
|
2092
|
+
lpFeeShareBps: config.lpFeeShareBps
|
|
2093
|
+
};
|
|
1606
2094
|
}
|
|
1607
2095
|
// Read: Get buy quote (off-chain calculation)
|
|
1608
2096
|
async getQuote(auctionId, amount) {
|
|
@@ -1634,23 +2122,6 @@ var AuctionFlowSDK = class {
|
|
|
1634
2122
|
args: [auctionId]
|
|
1635
2123
|
});
|
|
1636
2124
|
}
|
|
1637
|
-
parseAuctionResult(id, raw) {
|
|
1638
|
-
return {
|
|
1639
|
-
id,
|
|
1640
|
-
token: raw.config.token,
|
|
1641
|
-
paymentToken: raw.config.paymentToken,
|
|
1642
|
-
creator: raw.config.creator,
|
|
1643
|
-
basePrice: raw.config.basePrice,
|
|
1644
|
-
slope: raw.config.slope,
|
|
1645
|
-
maxRaise: raw.config.maxRaise,
|
|
1646
|
-
state: raw.state,
|
|
1647
|
-
totalRaised: raw.totalRaised,
|
|
1648
|
-
totalSold: raw.totalSold,
|
|
1649
|
-
protocolFeeBps: raw.config.protocolFeeBps,
|
|
1650
|
-
liquidityBps: raw.config.liquidityBps,
|
|
1651
|
-
lpFeeShareBps: raw.config.lpFeeShareBps
|
|
1652
|
-
};
|
|
1653
|
-
}
|
|
1654
2125
|
};
|
|
1655
2126
|
|
|
1656
2127
|
// src/types/index.ts
|
|
@@ -1671,6 +2142,7 @@ export {
|
|
|
1671
2142
|
MIN_LIQUIDITY_BPS,
|
|
1672
2143
|
PRICE_SCALE,
|
|
1673
2144
|
USDC_ADDRESSES,
|
|
2145
|
+
WETH_ADDRESSES,
|
|
1674
2146
|
applySellSlippage,
|
|
1675
2147
|
applySlippage,
|
|
1676
2148
|
calculateBuyCost,
|
|
@@ -1680,6 +2152,7 @@ export {
|
|
|
1680
2152
|
formatCurvePrice,
|
|
1681
2153
|
maxBuyable,
|
|
1682
2154
|
parseCurvePrice,
|
|
1683
|
-
spotPrice
|
|
2155
|
+
spotPrice,
|
|
2156
|
+
tokenAuctionAbi
|
|
1684
2157
|
};
|
|
1685
2158
|
//# sourceMappingURL=index.mjs.map
|