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.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
MIN_LIQUIDITY_BPS: () => MIN_LIQUIDITY_BPS,
|
|
30
30
|
PRICE_SCALE: () => PRICE_SCALE,
|
|
31
31
|
USDC_ADDRESSES: () => USDC_ADDRESSES,
|
|
32
|
+
WETH_ADDRESSES: () => WETH_ADDRESSES,
|
|
32
33
|
applySellSlippage: () => applySellSlippage,
|
|
33
34
|
applySlippage: () => applySlippage,
|
|
34
35
|
calculateBuyCost: () => calculateBuyCost,
|
|
@@ -38,7 +39,8 @@ __export(index_exports, {
|
|
|
38
39
|
formatCurvePrice: () => formatCurvePrice,
|
|
39
40
|
maxBuyable: () => maxBuyable,
|
|
40
41
|
parseCurvePrice: () => parseCurvePrice,
|
|
41
|
-
spotPrice: () => spotPrice
|
|
42
|
+
spotPrice: () => spotPrice,
|
|
43
|
+
tokenAuctionAbi: () => tokenAuctionAbi
|
|
42
44
|
});
|
|
43
45
|
module.exports = __toCommonJS(index_exports);
|
|
44
46
|
|
|
@@ -117,7 +119,7 @@ var AuctionBuilder = class {
|
|
|
117
119
|
|
|
118
120
|
// src/constants/addresses.ts
|
|
119
121
|
var AUCTION_ADDRESSES = {
|
|
120
|
-
84532: "
|
|
122
|
+
84532: "0x990a04ffe0d49356321271629889fa0413ad1bdc",
|
|
121
123
|
8453: "0x0000000000000000000000000000000000000000"
|
|
122
124
|
// not yet deployed
|
|
123
125
|
};
|
|
@@ -125,6 +127,10 @@ var USDC_ADDRESSES = {
|
|
|
125
127
|
84532: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
126
128
|
8453: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
|
|
127
129
|
};
|
|
130
|
+
var WETH_ADDRESSES = {
|
|
131
|
+
84532: "0x4200000000000000000000000000000000000006",
|
|
132
|
+
8453: "0x4200000000000000000000000000000000000006"
|
|
133
|
+
};
|
|
128
134
|
|
|
129
135
|
// src/abis/token-auction.ts
|
|
130
136
|
var tokenAuctionAbi = [
|
|
@@ -145,10 +151,19 @@ var tokenAuctionAbi = [
|
|
|
145
151
|
"name": "positionManager_",
|
|
146
152
|
"type": "address",
|
|
147
153
|
"internalType": "contract INonfungiblePositionManager"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "weth_",
|
|
157
|
+
"type": "address",
|
|
158
|
+
"internalType": "contract IWETH9"
|
|
148
159
|
}
|
|
149
160
|
],
|
|
150
161
|
"stateMutability": "nonpayable"
|
|
151
162
|
},
|
|
163
|
+
{
|
|
164
|
+
"type": "receive",
|
|
165
|
+
"stateMutability": "payable"
|
|
166
|
+
},
|
|
152
167
|
{
|
|
153
168
|
"type": "function",
|
|
154
169
|
"name": "MAX_FEE_BPS",
|
|
@@ -201,6 +216,13 @@ var tokenAuctionAbi = [
|
|
|
201
216
|
],
|
|
202
217
|
"stateMutability": "view"
|
|
203
218
|
},
|
|
219
|
+
{
|
|
220
|
+
"type": "function",
|
|
221
|
+
"name": "acceptOwnership",
|
|
222
|
+
"inputs": [],
|
|
223
|
+
"outputs": [],
|
|
224
|
+
"stateMutability": "nonpayable"
|
|
225
|
+
},
|
|
204
226
|
{
|
|
205
227
|
"type": "function",
|
|
206
228
|
"name": "auctionCount",
|
|
@@ -318,6 +340,86 @@ var tokenAuctionAbi = [
|
|
|
318
340
|
"outputs": [],
|
|
319
341
|
"stateMutability": "nonpayable"
|
|
320
342
|
},
|
|
343
|
+
{
|
|
344
|
+
"type": "function",
|
|
345
|
+
"name": "buyTokensWithETH",
|
|
346
|
+
"inputs": [
|
|
347
|
+
{
|
|
348
|
+
"name": "auctionId",
|
|
349
|
+
"type": "uint256",
|
|
350
|
+
"internalType": "uint256"
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"name": "amount",
|
|
354
|
+
"type": "uint256",
|
|
355
|
+
"internalType": "uint256"
|
|
356
|
+
}
|
|
357
|
+
],
|
|
358
|
+
"outputs": [],
|
|
359
|
+
"stateMutability": "payable"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"type": "function",
|
|
363
|
+
"name": "claim",
|
|
364
|
+
"inputs": [
|
|
365
|
+
{
|
|
366
|
+
"name": "token",
|
|
367
|
+
"type": "address",
|
|
368
|
+
"internalType": "contract IERC20"
|
|
369
|
+
}
|
|
370
|
+
],
|
|
371
|
+
"outputs": [
|
|
372
|
+
{
|
|
373
|
+
"name": "amount",
|
|
374
|
+
"type": "uint256",
|
|
375
|
+
"internalType": "uint256"
|
|
376
|
+
}
|
|
377
|
+
],
|
|
378
|
+
"stateMutability": "nonpayable"
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"type": "function",
|
|
382
|
+
"name": "claimProtocolFees",
|
|
383
|
+
"inputs": [
|
|
384
|
+
{
|
|
385
|
+
"name": "token",
|
|
386
|
+
"type": "address",
|
|
387
|
+
"internalType": "contract IERC20"
|
|
388
|
+
}
|
|
389
|
+
],
|
|
390
|
+
"outputs": [
|
|
391
|
+
{
|
|
392
|
+
"name": "amount",
|
|
393
|
+
"type": "uint256",
|
|
394
|
+
"internalType": "uint256"
|
|
395
|
+
}
|
|
396
|
+
],
|
|
397
|
+
"stateMutability": "nonpayable"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"type": "function",
|
|
401
|
+
"name": "claimable",
|
|
402
|
+
"inputs": [
|
|
403
|
+
{
|
|
404
|
+
"name": "",
|
|
405
|
+
"type": "address",
|
|
406
|
+
"internalType": "address"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"name": "",
|
|
410
|
+
"type": "address",
|
|
411
|
+
"internalType": "address"
|
|
412
|
+
}
|
|
413
|
+
],
|
|
414
|
+
"outputs": [
|
|
415
|
+
{
|
|
416
|
+
"name": "",
|
|
417
|
+
"type": "uint256",
|
|
418
|
+
"internalType": "uint256"
|
|
419
|
+
}
|
|
420
|
+
],
|
|
421
|
+
"stateMutability": "view"
|
|
422
|
+
},
|
|
321
423
|
{
|
|
322
424
|
"type": "function",
|
|
323
425
|
"name": "collectFees",
|
|
@@ -519,6 +621,11 @@ var tokenAuctionAbi = [
|
|
|
519
621
|
"name": "metadataURI",
|
|
520
622
|
"type": "string",
|
|
521
623
|
"internalType": "string"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"name": "paymentToken",
|
|
627
|
+
"type": "address",
|
|
628
|
+
"internalType": "address"
|
|
522
629
|
}
|
|
523
630
|
],
|
|
524
631
|
"outputs": [
|
|
@@ -532,8 +639,14 @@ var tokenAuctionAbi = [
|
|
|
532
639
|
},
|
|
533
640
|
{
|
|
534
641
|
"type": "function",
|
|
535
|
-
"name": "
|
|
536
|
-
"inputs": [
|
|
642
|
+
"name": "launchPresets",
|
|
643
|
+
"inputs": [
|
|
644
|
+
{
|
|
645
|
+
"name": "",
|
|
646
|
+
"type": "address",
|
|
647
|
+
"internalType": "address"
|
|
648
|
+
}
|
|
649
|
+
],
|
|
537
650
|
"outputs": [
|
|
538
651
|
{
|
|
539
652
|
"name": "paymentToken",
|
|
@@ -594,6 +707,58 @@ var tokenAuctionAbi = [
|
|
|
594
707
|
],
|
|
595
708
|
"stateMutability": "view"
|
|
596
709
|
},
|
|
710
|
+
{
|
|
711
|
+
"type": "function",
|
|
712
|
+
"name": "pause",
|
|
713
|
+
"inputs": [],
|
|
714
|
+
"outputs": [],
|
|
715
|
+
"stateMutability": "nonpayable"
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
"type": "function",
|
|
719
|
+
"name": "paused",
|
|
720
|
+
"inputs": [],
|
|
721
|
+
"outputs": [
|
|
722
|
+
{
|
|
723
|
+
"name": "",
|
|
724
|
+
"type": "bool",
|
|
725
|
+
"internalType": "bool"
|
|
726
|
+
}
|
|
727
|
+
],
|
|
728
|
+
"stateMutability": "view"
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
"type": "function",
|
|
732
|
+
"name": "paymentTokenAllowed",
|
|
733
|
+
"inputs": [
|
|
734
|
+
{
|
|
735
|
+
"name": "",
|
|
736
|
+
"type": "address",
|
|
737
|
+
"internalType": "address"
|
|
738
|
+
}
|
|
739
|
+
],
|
|
740
|
+
"outputs": [
|
|
741
|
+
{
|
|
742
|
+
"name": "",
|
|
743
|
+
"type": "bool",
|
|
744
|
+
"internalType": "bool"
|
|
745
|
+
}
|
|
746
|
+
],
|
|
747
|
+
"stateMutability": "view"
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
"type": "function",
|
|
751
|
+
"name": "pendingOwner",
|
|
752
|
+
"inputs": [],
|
|
753
|
+
"outputs": [
|
|
754
|
+
{
|
|
755
|
+
"name": "",
|
|
756
|
+
"type": "address",
|
|
757
|
+
"internalType": "address"
|
|
758
|
+
}
|
|
759
|
+
],
|
|
760
|
+
"stateMutability": "view"
|
|
761
|
+
},
|
|
597
762
|
{
|
|
598
763
|
"type": "function",
|
|
599
764
|
"name": "poolOf",
|
|
@@ -677,6 +842,25 @@ var tokenAuctionAbi = [
|
|
|
677
842
|
],
|
|
678
843
|
"stateMutability": "view"
|
|
679
844
|
},
|
|
845
|
+
{
|
|
846
|
+
"type": "function",
|
|
847
|
+
"name": "protocolFees",
|
|
848
|
+
"inputs": [
|
|
849
|
+
{
|
|
850
|
+
"name": "",
|
|
851
|
+
"type": "address",
|
|
852
|
+
"internalType": "address"
|
|
853
|
+
}
|
|
854
|
+
],
|
|
855
|
+
"outputs": [
|
|
856
|
+
{
|
|
857
|
+
"name": "",
|
|
858
|
+
"type": "uint256",
|
|
859
|
+
"internalType": "uint256"
|
|
860
|
+
}
|
|
861
|
+
],
|
|
862
|
+
"stateMutability": "view"
|
|
863
|
+
},
|
|
680
864
|
{
|
|
681
865
|
"type": "function",
|
|
682
866
|
"name": "renounceOwnership",
|
|
@@ -707,6 +891,29 @@ var tokenAuctionAbi = [
|
|
|
707
891
|
"outputs": [],
|
|
708
892
|
"stateMutability": "nonpayable"
|
|
709
893
|
},
|
|
894
|
+
{
|
|
895
|
+
"type": "function",
|
|
896
|
+
"name": "sellTokensForETH",
|
|
897
|
+
"inputs": [
|
|
898
|
+
{
|
|
899
|
+
"name": "auctionId",
|
|
900
|
+
"type": "uint256",
|
|
901
|
+
"internalType": "uint256"
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
"name": "amount",
|
|
905
|
+
"type": "uint256",
|
|
906
|
+
"internalType": "uint256"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
"name": "minProceeds",
|
|
910
|
+
"type": "uint256",
|
|
911
|
+
"internalType": "uint256"
|
|
912
|
+
}
|
|
913
|
+
],
|
|
914
|
+
"outputs": [],
|
|
915
|
+
"stateMutability": "nonpayable"
|
|
916
|
+
},
|
|
710
917
|
{
|
|
711
918
|
"type": "function",
|
|
712
919
|
"name": "setDefaultFeeBps",
|
|
@@ -778,6 +985,24 @@ var tokenAuctionAbi = [
|
|
|
778
985
|
"outputs": [],
|
|
779
986
|
"stateMutability": "nonpayable"
|
|
780
987
|
},
|
|
988
|
+
{
|
|
989
|
+
"type": "function",
|
|
990
|
+
"name": "setPaymentTokenAllowed",
|
|
991
|
+
"inputs": [
|
|
992
|
+
{
|
|
993
|
+
"name": "token",
|
|
994
|
+
"type": "address",
|
|
995
|
+
"internalType": "address"
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
"name": "allowed",
|
|
999
|
+
"type": "bool",
|
|
1000
|
+
"internalType": "bool"
|
|
1001
|
+
}
|
|
1002
|
+
],
|
|
1003
|
+
"outputs": [],
|
|
1004
|
+
"stateMutability": "nonpayable"
|
|
1005
|
+
},
|
|
781
1006
|
{
|
|
782
1007
|
"type": "function",
|
|
783
1008
|
"name": "setProtocolFeeRecipient",
|
|
@@ -845,6 +1070,13 @@ var tokenAuctionAbi = [
|
|
|
845
1070
|
"outputs": [],
|
|
846
1071
|
"stateMutability": "nonpayable"
|
|
847
1072
|
},
|
|
1073
|
+
{
|
|
1074
|
+
"type": "function",
|
|
1075
|
+
"name": "unpause",
|
|
1076
|
+
"inputs": [],
|
|
1077
|
+
"outputs": [],
|
|
1078
|
+
"stateMutability": "nonpayable"
|
|
1079
|
+
},
|
|
848
1080
|
{
|
|
849
1081
|
"type": "function",
|
|
850
1082
|
"name": "userPurchases",
|
|
@@ -869,6 +1101,19 @@ var tokenAuctionAbi = [
|
|
|
869
1101
|
],
|
|
870
1102
|
"stateMutability": "view"
|
|
871
1103
|
},
|
|
1104
|
+
{
|
|
1105
|
+
"type": "function",
|
|
1106
|
+
"name": "weth",
|
|
1107
|
+
"inputs": [],
|
|
1108
|
+
"outputs": [
|
|
1109
|
+
{
|
|
1110
|
+
"name": "",
|
|
1111
|
+
"type": "address",
|
|
1112
|
+
"internalType": "contract IWETH9"
|
|
1113
|
+
}
|
|
1114
|
+
],
|
|
1115
|
+
"stateMutability": "view"
|
|
1116
|
+
},
|
|
872
1117
|
{
|
|
873
1118
|
"type": "function",
|
|
874
1119
|
"name": "withdrawProceeds",
|
|
@@ -1005,6 +1250,31 @@ var tokenAuctionAbi = [
|
|
|
1005
1250
|
],
|
|
1006
1251
|
"anonymous": false
|
|
1007
1252
|
},
|
|
1253
|
+
{
|
|
1254
|
+
"type": "event",
|
|
1255
|
+
"name": "Claimed",
|
|
1256
|
+
"inputs": [
|
|
1257
|
+
{
|
|
1258
|
+
"name": "token",
|
|
1259
|
+
"type": "address",
|
|
1260
|
+
"indexed": true,
|
|
1261
|
+
"internalType": "address"
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
"name": "account",
|
|
1265
|
+
"type": "address",
|
|
1266
|
+
"indexed": true,
|
|
1267
|
+
"internalType": "address"
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
"name": "amount",
|
|
1271
|
+
"type": "uint256",
|
|
1272
|
+
"indexed": false,
|
|
1273
|
+
"internalType": "uint256"
|
|
1274
|
+
}
|
|
1275
|
+
],
|
|
1276
|
+
"anonymous": false
|
|
1277
|
+
},
|
|
1008
1278
|
{
|
|
1009
1279
|
"type": "event",
|
|
1010
1280
|
"name": "DefaultFeeBpsUpdated",
|
|
@@ -1123,6 +1393,25 @@ var tokenAuctionAbi = [
|
|
|
1123
1393
|
],
|
|
1124
1394
|
"anonymous": false
|
|
1125
1395
|
},
|
|
1396
|
+
{
|
|
1397
|
+
"type": "event",
|
|
1398
|
+
"name": "OwnershipTransferStarted",
|
|
1399
|
+
"inputs": [
|
|
1400
|
+
{
|
|
1401
|
+
"name": "previousOwner",
|
|
1402
|
+
"type": "address",
|
|
1403
|
+
"indexed": true,
|
|
1404
|
+
"internalType": "address"
|
|
1405
|
+
},
|
|
1406
|
+
{
|
|
1407
|
+
"name": "newOwner",
|
|
1408
|
+
"type": "address",
|
|
1409
|
+
"indexed": true,
|
|
1410
|
+
"internalType": "address"
|
|
1411
|
+
}
|
|
1412
|
+
],
|
|
1413
|
+
"anonymous": false
|
|
1414
|
+
},
|
|
1126
1415
|
{
|
|
1127
1416
|
"type": "event",
|
|
1128
1417
|
"name": "OwnershipTransferred",
|
|
@@ -1142,6 +1431,38 @@ var tokenAuctionAbi = [
|
|
|
1142
1431
|
],
|
|
1143
1432
|
"anonymous": false
|
|
1144
1433
|
},
|
|
1434
|
+
{
|
|
1435
|
+
"type": "event",
|
|
1436
|
+
"name": "Paused",
|
|
1437
|
+
"inputs": [
|
|
1438
|
+
{
|
|
1439
|
+
"name": "account",
|
|
1440
|
+
"type": "address",
|
|
1441
|
+
"indexed": false,
|
|
1442
|
+
"internalType": "address"
|
|
1443
|
+
}
|
|
1444
|
+
],
|
|
1445
|
+
"anonymous": false
|
|
1446
|
+
},
|
|
1447
|
+
{
|
|
1448
|
+
"type": "event",
|
|
1449
|
+
"name": "PaymentTokenAllowedUpdated",
|
|
1450
|
+
"inputs": [
|
|
1451
|
+
{
|
|
1452
|
+
"name": "token",
|
|
1453
|
+
"type": "address",
|
|
1454
|
+
"indexed": true,
|
|
1455
|
+
"internalType": "address"
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
"name": "allowed",
|
|
1459
|
+
"type": "bool",
|
|
1460
|
+
"indexed": false,
|
|
1461
|
+
"internalType": "bool"
|
|
1462
|
+
}
|
|
1463
|
+
],
|
|
1464
|
+
"anonymous": false
|
|
1465
|
+
},
|
|
1145
1466
|
{
|
|
1146
1467
|
"type": "event",
|
|
1147
1468
|
"name": "ProceedsWithdrawn",
|
|
@@ -1186,6 +1507,31 @@ var tokenAuctionAbi = [
|
|
|
1186
1507
|
],
|
|
1187
1508
|
"anonymous": false
|
|
1188
1509
|
},
|
|
1510
|
+
{
|
|
1511
|
+
"type": "event",
|
|
1512
|
+
"name": "ProtocolFeesClaimed",
|
|
1513
|
+
"inputs": [
|
|
1514
|
+
{
|
|
1515
|
+
"name": "token",
|
|
1516
|
+
"type": "address",
|
|
1517
|
+
"indexed": true,
|
|
1518
|
+
"internalType": "address"
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
"name": "recipient",
|
|
1522
|
+
"type": "address",
|
|
1523
|
+
"indexed": true,
|
|
1524
|
+
"internalType": "address"
|
|
1525
|
+
},
|
|
1526
|
+
{
|
|
1527
|
+
"name": "amount",
|
|
1528
|
+
"type": "uint256",
|
|
1529
|
+
"indexed": false,
|
|
1530
|
+
"internalType": "uint256"
|
|
1531
|
+
}
|
|
1532
|
+
],
|
|
1533
|
+
"anonymous": false
|
|
1534
|
+
},
|
|
1189
1535
|
{
|
|
1190
1536
|
"type": "event",
|
|
1191
1537
|
"name": "Swept",
|
|
@@ -1309,6 +1655,29 @@ var tokenAuctionAbi = [
|
|
|
1309
1655
|
],
|
|
1310
1656
|
"anonymous": false
|
|
1311
1657
|
},
|
|
1658
|
+
{
|
|
1659
|
+
"type": "event",
|
|
1660
|
+
"name": "Unpaused",
|
|
1661
|
+
"inputs": [
|
|
1662
|
+
{
|
|
1663
|
+
"name": "account",
|
|
1664
|
+
"type": "address",
|
|
1665
|
+
"indexed": false,
|
|
1666
|
+
"internalType": "address"
|
|
1667
|
+
}
|
|
1668
|
+
],
|
|
1669
|
+
"anonymous": false
|
|
1670
|
+
},
|
|
1671
|
+
{
|
|
1672
|
+
"type": "error",
|
|
1673
|
+
"name": "EnforcedPause",
|
|
1674
|
+
"inputs": []
|
|
1675
|
+
},
|
|
1676
|
+
{
|
|
1677
|
+
"type": "error",
|
|
1678
|
+
"name": "ExpectedPause",
|
|
1679
|
+
"inputs": []
|
|
1680
|
+
},
|
|
1312
1681
|
{
|
|
1313
1682
|
"type": "error",
|
|
1314
1683
|
"name": "OwnableInvalidOwner",
|
|
@@ -1413,7 +1782,7 @@ function fillPurchase(currentSupply, requested, basePrice, slope, totalRaised, m
|
|
|
1413
1782
|
if (cost < remaining) return { amount: requested, cost, fillsAuction: false };
|
|
1414
1783
|
if (cost === remaining) return { amount: requested, cost, fillsAuction: true };
|
|
1415
1784
|
const amount = maxBuyable(currentSupply, remaining, basePrice, slope, requested);
|
|
1416
|
-
if (amount === 0n)
|
|
1785
|
+
if (amount === 0n) return { amount: 0n, cost: 0n, fillsAuction: true };
|
|
1417
1786
|
return {
|
|
1418
1787
|
amount,
|
|
1419
1788
|
cost: calculateBuyCost(currentSupply, amount, basePrice, slope),
|
|
@@ -1491,9 +1860,10 @@ var AuctionFlowSDK = class {
|
|
|
1491
1860
|
}
|
|
1492
1861
|
/**
|
|
1493
1862
|
* One-click launch: a token with the protocol's standard curve, threshold
|
|
1494
|
-
* and liquidity share
|
|
1863
|
+
* and liquidity share for `paymentToken`. Trading starts immediately.
|
|
1864
|
+
* Defaults to WETH, so the token trades in plain ETH (see `buyTokensWithETH`).
|
|
1495
1865
|
*/
|
|
1496
|
-
async launch(name, symbol, metadataURI = "") {
|
|
1866
|
+
async launch(name, symbol, metadataURI = "", paymentToken = WETH_ADDRESSES[this.chainId]) {
|
|
1497
1867
|
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1498
1868
|
return this.walletClient.writeContract({
|
|
1499
1869
|
chain: this.chain,
|
|
@@ -1501,9 +1871,20 @@ var AuctionFlowSDK = class {
|
|
|
1501
1871
|
address: this.auctionAddress,
|
|
1502
1872
|
abi: tokenAuctionAbi,
|
|
1503
1873
|
functionName: "launch",
|
|
1504
|
-
args: [name, symbol, metadataURI]
|
|
1874
|
+
args: [name, symbol, metadataURI, paymentToken]
|
|
1505
1875
|
});
|
|
1506
1876
|
}
|
|
1877
|
+
/** The standard launch for `paymentToken`, or null if none is configured. */
|
|
1878
|
+
async getLaunchPreset(paymentToken) {
|
|
1879
|
+
const [token, maxSupply, basePrice, slope, maxRaise, liquidityBps] = await this.publicClient.readContract({
|
|
1880
|
+
address: this.auctionAddress,
|
|
1881
|
+
abi: tokenAuctionAbi,
|
|
1882
|
+
functionName: "launchPresets",
|
|
1883
|
+
args: [paymentToken]
|
|
1884
|
+
});
|
|
1885
|
+
if (token === import_viem2.zeroAddress) return null;
|
|
1886
|
+
return { paymentToken: token, maxSupply, basePrice, slope, maxRaise, liquidityBps };
|
|
1887
|
+
}
|
|
1507
1888
|
/**
|
|
1508
1889
|
* Sell `amount` tokens (in token wei) back to the curve before graduation.
|
|
1509
1890
|
* The contract reverts if the price fell below the bound before the
|
|
@@ -1525,6 +1906,25 @@ var AuctionFlowSDK = class {
|
|
|
1525
1906
|
args: [auctionId, amount, minProceeds]
|
|
1526
1907
|
});
|
|
1527
1908
|
}
|
|
1909
|
+
/**
|
|
1910
|
+
* `sellTokens` for an auction priced in WETH, paid out in plain ETH. Takes
|
|
1911
|
+
* the same `minProceeds` / `slippageBps` options.
|
|
1912
|
+
*/
|
|
1913
|
+
async sellTokensForETH(auctionId, amount, options = {}) {
|
|
1914
|
+
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1915
|
+
const minProceeds = options.minProceeds ?? applySellSlippage(
|
|
1916
|
+
(await this.getSellQuote(auctionId, amount)).netProceeds,
|
|
1917
|
+
options.slippageBps ?? DEFAULT_SLIPPAGE_BPS
|
|
1918
|
+
);
|
|
1919
|
+
return this.walletClient.writeContract({
|
|
1920
|
+
chain: this.chain,
|
|
1921
|
+
account: this.walletClient.account,
|
|
1922
|
+
address: this.auctionAddress,
|
|
1923
|
+
abi: tokenAuctionAbi,
|
|
1924
|
+
functionName: "sellTokensForETH",
|
|
1925
|
+
args: [auctionId, amount, minProceeds]
|
|
1926
|
+
});
|
|
1927
|
+
}
|
|
1528
1928
|
/** What selling `amount` tokens back to the curve would pay right now. */
|
|
1529
1929
|
async getSellQuote(auctionId, amount) {
|
|
1530
1930
|
const auction = await this.getAuction(auctionId);
|
|
@@ -1561,6 +1961,33 @@ var AuctionFlowSDK = class {
|
|
|
1561
1961
|
});
|
|
1562
1962
|
return hash;
|
|
1563
1963
|
}
|
|
1964
|
+
/**
|
|
1965
|
+
* `buyTokens` for an auction priced in WETH, paid in plain ETH, with no
|
|
1966
|
+
* token approval. The ETH sent is the most the purchase may cost (`maxCost`,
|
|
1967
|
+
* or a fresh quote plus `slippageBps`); whatever it doesn't use is refunded
|
|
1968
|
+
* in the same transaction.
|
|
1969
|
+
*/
|
|
1970
|
+
async buyTokensWithETH(auctionId, amount, options = {}) {
|
|
1971
|
+
if (!this.walletClient) throw new Error("Wallet client required");
|
|
1972
|
+
const maxCost = options.maxCost ?? applySlippage(
|
|
1973
|
+
(await this.getQuote(auctionId, amount)).totalCost,
|
|
1974
|
+
options.slippageBps ?? DEFAULT_SLIPPAGE_BPS
|
|
1975
|
+
);
|
|
1976
|
+
return this.walletClient.writeContract({
|
|
1977
|
+
chain: this.chain,
|
|
1978
|
+
account: this.walletClient.account,
|
|
1979
|
+
address: this.auctionAddress,
|
|
1980
|
+
abi: tokenAuctionAbi,
|
|
1981
|
+
functionName: "buyTokensWithETH",
|
|
1982
|
+
args: [auctionId, amount],
|
|
1983
|
+
value: maxCost
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
/** Is this auction priced in WETH, so it can be bought and sold with plain ETH? */
|
|
1987
|
+
async isPricedInETH(auctionId) {
|
|
1988
|
+
const auction = await this.getAuction(auctionId);
|
|
1989
|
+
return auction.paymentToken.toLowerCase() === WETH_ADDRESSES[this.chainId].toLowerCase();
|
|
1990
|
+
}
|
|
1564
1991
|
/**
|
|
1565
1992
|
* Pay a completed auction's creator their share of the raise: everything
|
|
1566
1993
|
* not reserved for Uniswap liquidity. Creator only, once, before or after
|
|
@@ -1587,12 +2014,24 @@ var AuctionFlowSDK = class {
|
|
|
1587
2014
|
return this.write("migrate", [auctionId]);
|
|
1588
2015
|
}
|
|
1589
2016
|
/**
|
|
1590
|
-
* Collect the migrated pool's trading fees. The protocol
|
|
1591
|
-
* the
|
|
2017
|
+
* Collect the migrated pool's trading fees. The protocol's share accrues to
|
|
2018
|
+
* the protocol and the rest is credited to the creator, who withdraws it
|
|
2019
|
+
* with `claim`. Anyone may call it.
|
|
1592
2020
|
*/
|
|
1593
2021
|
async collectFees(auctionId) {
|
|
1594
2022
|
return this.write("collectFees", [auctionId]);
|
|
1595
2023
|
}
|
|
2024
|
+
/**
|
|
2025
|
+
* Withdraw everything credited to the connected account in `token`: a
|
|
2026
|
+
* creator's share of pool fees, and any reserve migration couldn't place.
|
|
2027
|
+
*/
|
|
2028
|
+
async claim(token) {
|
|
2029
|
+
return this.write("claim", [token]);
|
|
2030
|
+
}
|
|
2031
|
+
/** Send the protocol's unclaimed fees in `token` to the fee recipient. Anyone may call it. */
|
|
2032
|
+
async claimProtocolFees(token) {
|
|
2033
|
+
return this.write("claimProtocolFees", [token]);
|
|
2034
|
+
}
|
|
1596
2035
|
/** The Uniswap pool and position for a migrated auction. */
|
|
1597
2036
|
async getMigration(auctionId) {
|
|
1598
2037
|
const [pool, positionId] = await Promise.all([
|
|
@@ -1634,15 +2073,66 @@ var AuctionFlowSDK = class {
|
|
|
1634
2073
|
args: [auctionId]
|
|
1635
2074
|
});
|
|
1636
2075
|
}
|
|
2076
|
+
// Read: Is the protocol paused? While paused, launches and curve buys
|
|
2077
|
+
// revert; selling back, migration, withdrawals, fee collection and claims
|
|
2078
|
+
// still work.
|
|
2079
|
+
async isPaused() {
|
|
2080
|
+
return this.publicClient.readContract({
|
|
2081
|
+
address: this.auctionAddress,
|
|
2082
|
+
abi: tokenAuctionAbi,
|
|
2083
|
+
functionName: "paused"
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
// Read: How much of `token` is credited to `account`, waiting for `claim`?
|
|
2087
|
+
async getClaimable(token, account) {
|
|
2088
|
+
return this.publicClient.readContract({
|
|
2089
|
+
address: this.auctionAddress,
|
|
2090
|
+
abi: tokenAuctionAbi,
|
|
2091
|
+
functionName: "claimable",
|
|
2092
|
+
args: [token, account]
|
|
2093
|
+
});
|
|
2094
|
+
}
|
|
2095
|
+
// Read: Protocol fees in `token` earned and not yet claimed.
|
|
2096
|
+
async getProtocolFees(token) {
|
|
2097
|
+
return this.publicClient.readContract({
|
|
2098
|
+
address: this.auctionAddress,
|
|
2099
|
+
abi: tokenAuctionAbi,
|
|
2100
|
+
functionName: "protocolFees",
|
|
2101
|
+
args: [token]
|
|
2102
|
+
});
|
|
2103
|
+
}
|
|
2104
|
+
// Read: May new auctions be priced in `token`?
|
|
2105
|
+
async isPaymentTokenAllowed(token) {
|
|
2106
|
+
return this.publicClient.readContract({
|
|
2107
|
+
address: this.auctionAddress,
|
|
2108
|
+
abi: tokenAuctionAbi,
|
|
2109
|
+
functionName: "paymentTokenAllowed",
|
|
2110
|
+
args: [token]
|
|
2111
|
+
});
|
|
2112
|
+
}
|
|
1637
2113
|
// Read: Get auction data
|
|
1638
2114
|
async getAuction(auctionId) {
|
|
1639
|
-
const
|
|
2115
|
+
const [config, state, totalRaised, totalSold] = await this.publicClient.readContract({
|
|
1640
2116
|
address: this.auctionAddress,
|
|
1641
2117
|
abi: tokenAuctionAbi,
|
|
1642
2118
|
functionName: "auctions",
|
|
1643
2119
|
args: [auctionId]
|
|
1644
2120
|
});
|
|
1645
|
-
return
|
|
2121
|
+
return {
|
|
2122
|
+
id: auctionId,
|
|
2123
|
+
token: config.token,
|
|
2124
|
+
paymentToken: config.paymentToken,
|
|
2125
|
+
creator: config.creator,
|
|
2126
|
+
basePrice: config.basePrice,
|
|
2127
|
+
slope: config.slope,
|
|
2128
|
+
maxRaise: config.maxRaise,
|
|
2129
|
+
state,
|
|
2130
|
+
totalRaised,
|
|
2131
|
+
totalSold,
|
|
2132
|
+
protocolFeeBps: config.protocolFeeBps,
|
|
2133
|
+
liquidityBps: config.liquidityBps,
|
|
2134
|
+
lpFeeShareBps: config.lpFeeShareBps
|
|
2135
|
+
};
|
|
1646
2136
|
}
|
|
1647
2137
|
// Read: Get buy quote (off-chain calculation)
|
|
1648
2138
|
async getQuote(auctionId, amount) {
|
|
@@ -1674,23 +2164,6 @@ var AuctionFlowSDK = class {
|
|
|
1674
2164
|
args: [auctionId]
|
|
1675
2165
|
});
|
|
1676
2166
|
}
|
|
1677
|
-
parseAuctionResult(id, raw) {
|
|
1678
|
-
return {
|
|
1679
|
-
id,
|
|
1680
|
-
token: raw.config.token,
|
|
1681
|
-
paymentToken: raw.config.paymentToken,
|
|
1682
|
-
creator: raw.config.creator,
|
|
1683
|
-
basePrice: raw.config.basePrice,
|
|
1684
|
-
slope: raw.config.slope,
|
|
1685
|
-
maxRaise: raw.config.maxRaise,
|
|
1686
|
-
state: raw.state,
|
|
1687
|
-
totalRaised: raw.totalRaised,
|
|
1688
|
-
totalSold: raw.totalSold,
|
|
1689
|
-
protocolFeeBps: raw.config.protocolFeeBps,
|
|
1690
|
-
liquidityBps: raw.config.liquidityBps,
|
|
1691
|
-
lpFeeShareBps: raw.config.lpFeeShareBps
|
|
1692
|
-
};
|
|
1693
|
-
}
|
|
1694
2167
|
};
|
|
1695
2168
|
|
|
1696
2169
|
// src/types/index.ts
|
|
@@ -1712,6 +2185,7 @@ var AuctionState = /* @__PURE__ */ ((AuctionState2) => {
|
|
|
1712
2185
|
MIN_LIQUIDITY_BPS,
|
|
1713
2186
|
PRICE_SCALE,
|
|
1714
2187
|
USDC_ADDRESSES,
|
|
2188
|
+
WETH_ADDRESSES,
|
|
1715
2189
|
applySellSlippage,
|
|
1716
2190
|
applySlippage,
|
|
1717
2191
|
calculateBuyCost,
|
|
@@ -1721,6 +2195,7 @@ var AuctionState = /* @__PURE__ */ ((AuctionState2) => {
|
|
|
1721
2195
|
formatCurvePrice,
|
|
1722
2196
|
maxBuyable,
|
|
1723
2197
|
parseCurvePrice,
|
|
1724
|
-
spotPrice
|
|
2198
|
+
spotPrice,
|
|
2199
|
+
tokenAuctionAbi
|
|
1725
2200
|
});
|
|
1726
2201
|
//# sourceMappingURL=index.js.map
|