auctionflow-sdk 2.0.0 → 2.1.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 CHANGED
@@ -186,8 +186,11 @@ if (!(await sdk.hasWithdrawnProceeds(0n))) {
186
186
  await sdk.withdrawProceeds(0n);
187
187
  }
188
188
 
189
- // 3. Later, collect the pool's trading fees.
189
+ // 3. Later, collect the pool's trading fees. The creator's share is
190
+ // credited to them, and they withdraw it (in both tokens) with claim.
190
191
  await sdk.collectFees(0n);
192
+ await sdk.claim(usdcAddress);
193
+ await sdk.claim(tokenAddress);
191
194
  ```
192
195
 
193
196
  **Migration** pairs the auction's liquidity share of the raise with newly
@@ -195,13 +198,16 @@ minted tokens and opens a 1% Uniswap v3 pool **at the auction's final price**,
195
198
  so there is no price jump to arbitrage. If someone initialised the pool
196
199
  beforehand at a different price, migration corrects it first. The position NFT
197
200
  stays in the auction contract forever, so the liquidity can never be pulled.
198
- Tokens Uniswap doesn't use are burned, and leftover funds go to the creator.
201
+ Tokens Uniswap doesn't use are burned, and leftover funds are credited to the
202
+ creator to `claim`.
199
203
 
200
204
  **Withdrawal** pays the creator everything not reserved for liquidity: with the
201
205
  default 50% share, half the raise. It works before or after migration.
202
206
 
203
- **Trading fees** from the pool go to the creator, minus the protocol's share
204
- (`lpFeeShareBps`, at most 50%), fixed when the auction is created.
207
+ **Trading fees** from the pool are credited to the creator, minus the
208
+ protocol's share (`lpFeeShareBps`, at most 50%), fixed when the auction is
209
+ created. Payouts are claimed rather than sent, so no recipient (for example an
210
+ address USDC has blacklisted) can block a trade or a migration.
205
211
 
206
212
  ## How the bonding curve works
207
213
 
@@ -245,8 +251,14 @@ Early buyers pay less; later buyers pay more.
245
251
  | `migrate(auctionId)` | Open the Uniswap v3 pool at the final price, lock the liquidity, unlock the token. Anyone may call. |
246
252
  | `getMigration(auctionId)` | The pool address and position NFT id, or `null` before migration. |
247
253
  | `withdrawProceeds(auctionId)` | Pay the creator their share of the raise (what isn't reserved for liquidity). Creator-only, once. |
248
- | `collectFees(auctionId)` | Collect the pool's trading fees: protocol share to the protocol, the rest to the creator. Anyone may call. |
254
+ | `collectFees(auctionId)` | Collect the pool's trading fees: the protocol's share accrues to the protocol and the rest is credited to the creator. Anyone may call. |
255
+ | `claim(token)` | Withdraw everything credited to the connected account in `token`: a creator's share of pool fees, and any reserve migration couldn't place. |
256
+ | `getClaimable(token, account)` | How much of `token` is credited to `account`. |
257
+ | `claimProtocolFees(token)` | Send the protocol's unclaimed fees in `token` to the fee recipient. Anyone may call. |
258
+ | `getProtocolFees(token)` | The protocol's unclaimed fees in `token`. |
259
+ | `isPaymentTokenAllowed(token)` | Whether new auctions may be priced in `token`. Only owner-approved tokens (USDC) can be used. |
249
260
  | `hasWithdrawnProceeds(auctionId)` | Whether the creator has already claimed the proceeds. |
261
+ | `isPaused()` | Whether the protocol is paused. While paused, `launch`, `createAuction` and `buyTokens` revert; selling back, migration, withdrawals, fee collection and claims still work. |
250
262
 
251
263
  ## License
252
264
 
package/dist/index.d.mts CHANGED
@@ -142,14 +142,26 @@ declare class AuctionFlowSDK {
142
142
  */
143
143
  migrate(auctionId: bigint): Promise<Hash>;
144
144
  /**
145
- * Collect the migrated pool's trading fees. The protocol takes its share and
146
- * the creator receives the rest. Anyone may call it.
145
+ * Collect the migrated pool's trading fees. The protocol's share accrues to
146
+ * the protocol and the rest is credited to the creator, who withdraws it
147
+ * with `claim`. Anyone may call it.
147
148
  */
148
149
  collectFees(auctionId: bigint): Promise<Hash>;
150
+ /**
151
+ * Withdraw everything credited to the connected account in `token`: a
152
+ * creator's share of pool fees, and any reserve migration couldn't place.
153
+ */
154
+ claim(token: Address): Promise<Hash>;
155
+ /** Send the protocol's unclaimed fees in `token` to the fee recipient. Anyone may call it. */
156
+ claimProtocolFees(token: Address): Promise<Hash>;
149
157
  /** The Uniswap pool and position for a migrated auction. */
150
158
  getMigration(auctionId: bigint): Promise<MigrationInfo>;
151
159
  private write;
152
160
  hasWithdrawnProceeds(auctionId: bigint): Promise<boolean>;
161
+ isPaused(): Promise<boolean>;
162
+ getClaimable(token: Address, account: Address): Promise<bigint>;
163
+ getProtocolFees(token: Address): Promise<bigint>;
164
+ isPaymentTokenAllowed(token: Address): Promise<boolean>;
153
165
  getAuction(auctionId: bigint): Promise<AuctionData>;
154
166
  getQuote(auctionId: bigint, amount: bigint): Promise<BuyQuote>;
155
167
  getSpotPrice(auctionId: bigint): Promise<bigint>;
package/dist/index.d.ts CHANGED
@@ -142,14 +142,26 @@ declare class AuctionFlowSDK {
142
142
  */
143
143
  migrate(auctionId: bigint): Promise<Hash>;
144
144
  /**
145
- * Collect the migrated pool's trading fees. The protocol takes its share and
146
- * the creator receives the rest. Anyone may call it.
145
+ * Collect the migrated pool's trading fees. The protocol's share accrues to
146
+ * the protocol and the rest is credited to the creator, who withdraws it
147
+ * with `claim`. Anyone may call it.
147
148
  */
148
149
  collectFees(auctionId: bigint): Promise<Hash>;
150
+ /**
151
+ * Withdraw everything credited to the connected account in `token`: a
152
+ * creator's share of pool fees, and any reserve migration couldn't place.
153
+ */
154
+ claim(token: Address): Promise<Hash>;
155
+ /** Send the protocol's unclaimed fees in `token` to the fee recipient. Anyone may call it. */
156
+ claimProtocolFees(token: Address): Promise<Hash>;
149
157
  /** The Uniswap pool and position for a migrated auction. */
150
158
  getMigration(auctionId: bigint): Promise<MigrationInfo>;
151
159
  private write;
152
160
  hasWithdrawnProceeds(auctionId: bigint): Promise<boolean>;
161
+ isPaused(): Promise<boolean>;
162
+ getClaimable(token: Address, account: Address): Promise<bigint>;
163
+ getProtocolFees(token: Address): Promise<bigint>;
164
+ isPaymentTokenAllowed(token: Address): Promise<boolean>;
153
165
  getAuction(auctionId: bigint): Promise<AuctionData>;
154
166
  getQuote(auctionId: bigint, amount: bigint): Promise<BuyQuote>;
155
167
  getSpotPrice(auctionId: bigint): Promise<bigint>;
package/dist/index.js CHANGED
@@ -117,7 +117,7 @@ var AuctionBuilder = class {
117
117
 
118
118
  // src/constants/addresses.ts
119
119
  var AUCTION_ADDRESSES = {
120
- 84532: "0xc6db1c900faeb4079281ecd6ec538c027cd18c28",
120
+ 84532: "0xe57fe62e31666a9b749e89086a8a5487a530153b",
121
121
  8453: "0x0000000000000000000000000000000000000000"
122
122
  // not yet deployed
123
123
  };
@@ -201,6 +201,13 @@ var tokenAuctionAbi = [
201
201
  ],
202
202
  "stateMutability": "view"
203
203
  },
204
+ {
205
+ "type": "function",
206
+ "name": "acceptOwnership",
207
+ "inputs": [],
208
+ "outputs": [],
209
+ "stateMutability": "nonpayable"
210
+ },
204
211
  {
205
212
  "type": "function",
206
213
  "name": "auctionCount",
@@ -318,6 +325,68 @@ var tokenAuctionAbi = [
318
325
  "outputs": [],
319
326
  "stateMutability": "nonpayable"
320
327
  },
328
+ {
329
+ "type": "function",
330
+ "name": "claim",
331
+ "inputs": [
332
+ {
333
+ "name": "token",
334
+ "type": "address",
335
+ "internalType": "contract IERC20"
336
+ }
337
+ ],
338
+ "outputs": [
339
+ {
340
+ "name": "amount",
341
+ "type": "uint256",
342
+ "internalType": "uint256"
343
+ }
344
+ ],
345
+ "stateMutability": "nonpayable"
346
+ },
347
+ {
348
+ "type": "function",
349
+ "name": "claimProtocolFees",
350
+ "inputs": [
351
+ {
352
+ "name": "token",
353
+ "type": "address",
354
+ "internalType": "contract IERC20"
355
+ }
356
+ ],
357
+ "outputs": [
358
+ {
359
+ "name": "amount",
360
+ "type": "uint256",
361
+ "internalType": "uint256"
362
+ }
363
+ ],
364
+ "stateMutability": "nonpayable"
365
+ },
366
+ {
367
+ "type": "function",
368
+ "name": "claimable",
369
+ "inputs": [
370
+ {
371
+ "name": "",
372
+ "type": "address",
373
+ "internalType": "address"
374
+ },
375
+ {
376
+ "name": "",
377
+ "type": "address",
378
+ "internalType": "address"
379
+ }
380
+ ],
381
+ "outputs": [
382
+ {
383
+ "name": "",
384
+ "type": "uint256",
385
+ "internalType": "uint256"
386
+ }
387
+ ],
388
+ "stateMutability": "view"
389
+ },
321
390
  {
322
391
  "type": "function",
323
392
  "name": "collectFees",
@@ -594,6 +663,58 @@ var tokenAuctionAbi = [
594
663
  ],
595
664
  "stateMutability": "view"
596
665
  },
666
+ {
667
+ "type": "function",
668
+ "name": "pause",
669
+ "inputs": [],
670
+ "outputs": [],
671
+ "stateMutability": "nonpayable"
672
+ },
673
+ {
674
+ "type": "function",
675
+ "name": "paused",
676
+ "inputs": [],
677
+ "outputs": [
678
+ {
679
+ "name": "",
680
+ "type": "bool",
681
+ "internalType": "bool"
682
+ }
683
+ ],
684
+ "stateMutability": "view"
685
+ },
686
+ {
687
+ "type": "function",
688
+ "name": "paymentTokenAllowed",
689
+ "inputs": [
690
+ {
691
+ "name": "",
692
+ "type": "address",
693
+ "internalType": "address"
694
+ }
695
+ ],
696
+ "outputs": [
697
+ {
698
+ "name": "",
699
+ "type": "bool",
700
+ "internalType": "bool"
701
+ }
702
+ ],
703
+ "stateMutability": "view"
704
+ },
705
+ {
706
+ "type": "function",
707
+ "name": "pendingOwner",
708
+ "inputs": [],
709
+ "outputs": [
710
+ {
711
+ "name": "",
712
+ "type": "address",
713
+ "internalType": "address"
714
+ }
715
+ ],
716
+ "stateMutability": "view"
717
+ },
597
718
  {
598
719
  "type": "function",
599
720
  "name": "poolOf",
@@ -677,6 +798,25 @@ var tokenAuctionAbi = [
677
798
  ],
678
799
  "stateMutability": "view"
679
800
  },
801
+ {
802
+ "type": "function",
803
+ "name": "protocolFees",
804
+ "inputs": [
805
+ {
806
+ "name": "",
807
+ "type": "address",
808
+ "internalType": "address"
809
+ }
810
+ ],
811
+ "outputs": [
812
+ {
813
+ "name": "",
814
+ "type": "uint256",
815
+ "internalType": "uint256"
816
+ }
817
+ ],
818
+ "stateMutability": "view"
819
+ },
680
820
  {
681
821
  "type": "function",
682
822
  "name": "renounceOwnership",
@@ -778,6 +918,24 @@ var tokenAuctionAbi = [
778
918
  "outputs": [],
779
919
  "stateMutability": "nonpayable"
780
920
  },
921
+ {
922
+ "type": "function",
923
+ "name": "setPaymentTokenAllowed",
924
+ "inputs": [
925
+ {
926
+ "name": "token",
927
+ "type": "address",
928
+ "internalType": "address"
929
+ },
930
+ {
931
+ "name": "allowed",
932
+ "type": "bool",
933
+ "internalType": "bool"
934
+ }
935
+ ],
936
+ "outputs": [],
937
+ "stateMutability": "nonpayable"
938
+ },
781
939
  {
782
940
  "type": "function",
783
941
  "name": "setProtocolFeeRecipient",
@@ -845,6 +1003,13 @@ var tokenAuctionAbi = [
845
1003
  "outputs": [],
846
1004
  "stateMutability": "nonpayable"
847
1005
  },
1006
+ {
1007
+ "type": "function",
1008
+ "name": "unpause",
1009
+ "inputs": [],
1010
+ "outputs": [],
1011
+ "stateMutability": "nonpayable"
1012
+ },
848
1013
  {
849
1014
  "type": "function",
850
1015
  "name": "userPurchases",
@@ -1005,6 +1170,31 @@ var tokenAuctionAbi = [
1005
1170
  ],
1006
1171
  "anonymous": false
1007
1172
  },
1173
+ {
1174
+ "type": "event",
1175
+ "name": "Claimed",
1176
+ "inputs": [
1177
+ {
1178
+ "name": "token",
1179
+ "type": "address",
1180
+ "indexed": true,
1181
+ "internalType": "address"
1182
+ },
1183
+ {
1184
+ "name": "account",
1185
+ "type": "address",
1186
+ "indexed": true,
1187
+ "internalType": "address"
1188
+ },
1189
+ {
1190
+ "name": "amount",
1191
+ "type": "uint256",
1192
+ "indexed": false,
1193
+ "internalType": "uint256"
1194
+ }
1195
+ ],
1196
+ "anonymous": false
1197
+ },
1008
1198
  {
1009
1199
  "type": "event",
1010
1200
  "name": "DefaultFeeBpsUpdated",
@@ -1123,6 +1313,25 @@ var tokenAuctionAbi = [
1123
1313
  ],
1124
1314
  "anonymous": false
1125
1315
  },
1316
+ {
1317
+ "type": "event",
1318
+ "name": "OwnershipTransferStarted",
1319
+ "inputs": [
1320
+ {
1321
+ "name": "previousOwner",
1322
+ "type": "address",
1323
+ "indexed": true,
1324
+ "internalType": "address"
1325
+ },
1326
+ {
1327
+ "name": "newOwner",
1328
+ "type": "address",
1329
+ "indexed": true,
1330
+ "internalType": "address"
1331
+ }
1332
+ ],
1333
+ "anonymous": false
1334
+ },
1126
1335
  {
1127
1336
  "type": "event",
1128
1337
  "name": "OwnershipTransferred",
@@ -1142,6 +1351,38 @@ var tokenAuctionAbi = [
1142
1351
  ],
1143
1352
  "anonymous": false
1144
1353
  },
1354
+ {
1355
+ "type": "event",
1356
+ "name": "Paused",
1357
+ "inputs": [
1358
+ {
1359
+ "name": "account",
1360
+ "type": "address",
1361
+ "indexed": false,
1362
+ "internalType": "address"
1363
+ }
1364
+ ],
1365
+ "anonymous": false
1366
+ },
1367
+ {
1368
+ "type": "event",
1369
+ "name": "PaymentTokenAllowedUpdated",
1370
+ "inputs": [
1371
+ {
1372
+ "name": "token",
1373
+ "type": "address",
1374
+ "indexed": true,
1375
+ "internalType": "address"
1376
+ },
1377
+ {
1378
+ "name": "allowed",
1379
+ "type": "bool",
1380
+ "indexed": false,
1381
+ "internalType": "bool"
1382
+ }
1383
+ ],
1384
+ "anonymous": false
1385
+ },
1145
1386
  {
1146
1387
  "type": "event",
1147
1388
  "name": "ProceedsWithdrawn",
@@ -1186,6 +1427,31 @@ var tokenAuctionAbi = [
1186
1427
  ],
1187
1428
  "anonymous": false
1188
1429
  },
1430
+ {
1431
+ "type": "event",
1432
+ "name": "ProtocolFeesClaimed",
1433
+ "inputs": [
1434
+ {
1435
+ "name": "token",
1436
+ "type": "address",
1437
+ "indexed": true,
1438
+ "internalType": "address"
1439
+ },
1440
+ {
1441
+ "name": "recipient",
1442
+ "type": "address",
1443
+ "indexed": true,
1444
+ "internalType": "address"
1445
+ },
1446
+ {
1447
+ "name": "amount",
1448
+ "type": "uint256",
1449
+ "indexed": false,
1450
+ "internalType": "uint256"
1451
+ }
1452
+ ],
1453
+ "anonymous": false
1454
+ },
1189
1455
  {
1190
1456
  "type": "event",
1191
1457
  "name": "Swept",
@@ -1309,6 +1575,29 @@ var tokenAuctionAbi = [
1309
1575
  ],
1310
1576
  "anonymous": false
1311
1577
  },
1578
+ {
1579
+ "type": "event",
1580
+ "name": "Unpaused",
1581
+ "inputs": [
1582
+ {
1583
+ "name": "account",
1584
+ "type": "address",
1585
+ "indexed": false,
1586
+ "internalType": "address"
1587
+ }
1588
+ ],
1589
+ "anonymous": false
1590
+ },
1591
+ {
1592
+ "type": "error",
1593
+ "name": "EnforcedPause",
1594
+ "inputs": []
1595
+ },
1596
+ {
1597
+ "type": "error",
1598
+ "name": "ExpectedPause",
1599
+ "inputs": []
1600
+ },
1312
1601
  {
1313
1602
  "type": "error",
1314
1603
  "name": "OwnableInvalidOwner",
@@ -1587,12 +1876,24 @@ var AuctionFlowSDK = class {
1587
1876
  return this.write("migrate", [auctionId]);
1588
1877
  }
1589
1878
  /**
1590
- * Collect the migrated pool's trading fees. The protocol takes its share and
1591
- * the creator receives the rest. Anyone may call it.
1879
+ * Collect the migrated pool's trading fees. The protocol's share accrues to
1880
+ * the protocol and the rest is credited to the creator, who withdraws it
1881
+ * with `claim`. Anyone may call it.
1592
1882
  */
1593
1883
  async collectFees(auctionId) {
1594
1884
  return this.write("collectFees", [auctionId]);
1595
1885
  }
1886
+ /**
1887
+ * Withdraw everything credited to the connected account in `token`: a
1888
+ * creator's share of pool fees, and any reserve migration couldn't place.
1889
+ */
1890
+ async claim(token) {
1891
+ return this.write("claim", [token]);
1892
+ }
1893
+ /** Send the protocol's unclaimed fees in `token` to the fee recipient. Anyone may call it. */
1894
+ async claimProtocolFees(token) {
1895
+ return this.write("claimProtocolFees", [token]);
1896
+ }
1596
1897
  /** The Uniswap pool and position for a migrated auction. */
1597
1898
  async getMigration(auctionId) {
1598
1899
  const [pool, positionId] = await Promise.all([
@@ -1634,6 +1935,43 @@ var AuctionFlowSDK = class {
1634
1935
  args: [auctionId]
1635
1936
  });
1636
1937
  }
1938
+ // Read: Is the protocol paused? While paused, launches and curve buys
1939
+ // revert; selling back, migration, withdrawals, fee collection and claims
1940
+ // still work.
1941
+ async isPaused() {
1942
+ return this.publicClient.readContract({
1943
+ address: this.auctionAddress,
1944
+ abi: tokenAuctionAbi,
1945
+ functionName: "paused"
1946
+ });
1947
+ }
1948
+ // Read: How much of `token` is credited to `account`, waiting for `claim`?
1949
+ async getClaimable(token, account) {
1950
+ return this.publicClient.readContract({
1951
+ address: this.auctionAddress,
1952
+ abi: tokenAuctionAbi,
1953
+ functionName: "claimable",
1954
+ args: [token, account]
1955
+ });
1956
+ }
1957
+ // Read: Protocol fees in `token` earned and not yet claimed.
1958
+ async getProtocolFees(token) {
1959
+ return this.publicClient.readContract({
1960
+ address: this.auctionAddress,
1961
+ abi: tokenAuctionAbi,
1962
+ functionName: "protocolFees",
1963
+ args: [token]
1964
+ });
1965
+ }
1966
+ // Read: May new auctions be priced in `token`?
1967
+ async isPaymentTokenAllowed(token) {
1968
+ return this.publicClient.readContract({
1969
+ address: this.auctionAddress,
1970
+ abi: tokenAuctionAbi,
1971
+ functionName: "paymentTokenAllowed",
1972
+ args: [token]
1973
+ });
1974
+ }
1637
1975
  // Read: Get auction data
1638
1976
  async getAuction(auctionId) {
1639
1977
  const result = await this.publicClient.readContract({