@0xslots/sdk 0.6.0 → 0.8.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 CHANGED
@@ -7,6 +7,7 @@ import { getSlotsHubAddress, slotAbi, slotFactoryAbi } from '@0xslots/contracts'
7
7
  var AccountFieldsFragmentDoc = gql`
8
8
  fragment AccountFields on Account {
9
9
  id
10
+ type
10
11
  slotCount
11
12
  occupiedCount
12
13
  slotsAsRecipient {
@@ -17,19 +18,30 @@ var AccountFieldsFragmentDoc = gql`
17
18
  }
18
19
  }
19
20
  `;
21
+ var CurrencyFieldsFragmentDoc = gql`
22
+ fragment CurrencyFields on Currency {
23
+ id
24
+ name
25
+ symbol
26
+ decimals
27
+ }
28
+ `;
20
29
  var SlotFieldsFragmentDoc = gql`
21
30
  fragment SlotFields on Slot {
22
31
  id
23
32
  recipient
24
33
  recipientAccount {
25
34
  id
35
+ type
26
36
  slotCount
27
37
  occupiedCount
28
38
  }
29
- currency
30
- currencyName
31
- currencySymbol
32
- currencyDecimals
39
+ currency {
40
+ id
41
+ name
42
+ symbol
43
+ decimals
44
+ }
33
45
  manager
34
46
  mutableTax
35
47
  mutableModule
@@ -43,6 +55,7 @@ var SlotFieldsFragmentDoc = gql`
43
55
  occupant
44
56
  occupantAccount {
45
57
  id
58
+ type
46
59
  slotCount
47
60
  occupiedCount
48
61
  }
@@ -85,6 +98,9 @@ var GetRecentEventsDocument = gql`
85
98
  slot {
86
99
  id
87
100
  }
101
+ currency {
102
+ ...CurrencyFields
103
+ }
88
104
  buyer
89
105
  previousOccupant
90
106
  price
@@ -98,6 +114,9 @@ var GetRecentEventsDocument = gql`
98
114
  slot {
99
115
  id
100
116
  }
117
+ currency {
118
+ ...CurrencyFields
119
+ }
101
120
  occupant
102
121
  refund
103
122
  timestamp
@@ -108,6 +127,9 @@ var GetRecentEventsDocument = gql`
108
127
  slot {
109
128
  id
110
129
  }
130
+ currency {
131
+ ...CurrencyFields
132
+ }
111
133
  liquidator
112
134
  occupant
113
135
  bounty
@@ -119,6 +141,9 @@ var GetRecentEventsDocument = gql`
119
141
  slot {
120
142
  id
121
143
  }
144
+ currency {
145
+ ...CurrencyFields
146
+ }
122
147
  oldPrice
123
148
  newPrice
124
149
  timestamp
@@ -129,6 +154,9 @@ var GetRecentEventsDocument = gql`
129
154
  slot {
130
155
  id
131
156
  }
157
+ currency {
158
+ ...CurrencyFields
159
+ }
132
160
  depositor
133
161
  amount
134
162
  timestamp
@@ -139,6 +167,9 @@ var GetRecentEventsDocument = gql`
139
167
  slot {
140
168
  id
141
169
  }
170
+ currency {
171
+ ...CurrencyFields
172
+ }
142
173
  occupant
143
174
  amount
144
175
  timestamp
@@ -149,6 +180,9 @@ var GetRecentEventsDocument = gql`
149
180
  slot {
150
181
  id
151
182
  }
183
+ currency {
184
+ ...CurrencyFields
185
+ }
152
186
  recipient
153
187
  amount
154
188
  timestamp
@@ -189,7 +223,7 @@ var GetRecentEventsDocument = gql`
189
223
  tx
190
224
  }
191
225
  }
192
- `;
226
+ ${CurrencyFieldsFragmentDoc}`;
193
227
  var GetBoughtEventsDocument = gql`
194
228
  query GetBoughtEvents($first: Int!, $skip: Int, $orderBy: BoughtEvent_orderBy, $orderDirection: OrderDirection, $where: BoughtEvent_filter, $block: Block_height) {
195
229
  boughtEvents(
@@ -204,6 +238,9 @@ var GetBoughtEventsDocument = gql`
204
238
  slot {
205
239
  id
206
240
  }
241
+ currency {
242
+ ...CurrencyFields
243
+ }
207
244
  buyer
208
245
  previousOccupant
209
246
  price
@@ -214,7 +251,7 @@ var GetBoughtEventsDocument = gql`
214
251
  tx
215
252
  }
216
253
  }
217
- `;
254
+ ${CurrencyFieldsFragmentDoc}`;
218
255
  var GetReleasedEventsDocument = gql`
219
256
  query GetReleasedEvents($first: Int!, $skip: Int, $orderBy: ReleasedEvent_orderBy, $orderDirection: OrderDirection, $where: ReleasedEvent_filter, $block: Block_height) {
220
257
  releasedEvents(
@@ -229,6 +266,9 @@ var GetReleasedEventsDocument = gql`
229
266
  slot {
230
267
  id
231
268
  }
269
+ currency {
270
+ ...CurrencyFields
271
+ }
232
272
  occupant
233
273
  refund
234
274
  timestamp
@@ -236,7 +276,7 @@ var GetReleasedEventsDocument = gql`
236
276
  tx
237
277
  }
238
278
  }
239
- `;
279
+ ${CurrencyFieldsFragmentDoc}`;
240
280
  var GetLiquidatedEventsDocument = gql`
241
281
  query GetLiquidatedEvents($first: Int!, $skip: Int, $orderBy: LiquidatedEvent_orderBy, $orderDirection: OrderDirection, $where: LiquidatedEvent_filter, $block: Block_height) {
242
282
  liquidatedEvents(
@@ -251,6 +291,9 @@ var GetLiquidatedEventsDocument = gql`
251
291
  slot {
252
292
  id
253
293
  }
294
+ currency {
295
+ ...CurrencyFields
296
+ }
254
297
  liquidator
255
298
  occupant
256
299
  bounty
@@ -259,7 +302,7 @@ var GetLiquidatedEventsDocument = gql`
259
302
  tx
260
303
  }
261
304
  }
262
- `;
305
+ ${CurrencyFieldsFragmentDoc}`;
263
306
  var GetSettledEventsDocument = gql`
264
307
  query GetSettledEvents($first: Int!, $skip: Int, $orderBy: SettledEvent_orderBy, $orderDirection: OrderDirection, $where: SettledEvent_filter, $block: Block_height) {
265
308
  settledEvents(
@@ -274,6 +317,9 @@ var GetSettledEventsDocument = gql`
274
317
  slot {
275
318
  id
276
319
  }
320
+ currency {
321
+ ...CurrencyFields
322
+ }
277
323
  taxOwed
278
324
  taxPaid
279
325
  depositRemaining
@@ -282,7 +328,7 @@ var GetSettledEventsDocument = gql`
282
328
  tx
283
329
  }
284
330
  }
285
- `;
331
+ ${CurrencyFieldsFragmentDoc}`;
286
332
  var GetTaxCollectedEventsDocument = gql`
287
333
  query GetTaxCollectedEvents($first: Int!, $skip: Int, $orderBy: TaxCollectedEvent_orderBy, $orderDirection: OrderDirection, $where: TaxCollectedEvent_filter, $block: Block_height) {
288
334
  taxCollectedEvents(
@@ -297,6 +343,9 @@ var GetTaxCollectedEventsDocument = gql`
297
343
  slot {
298
344
  id
299
345
  }
346
+ currency {
347
+ ...CurrencyFields
348
+ }
300
349
  recipient
301
350
  amount
302
351
  timestamp
@@ -304,7 +353,7 @@ var GetTaxCollectedEventsDocument = gql`
304
353
  tx
305
354
  }
306
355
  }
307
- `;
356
+ ${CurrencyFieldsFragmentDoc}`;
308
357
  var GetDepositedEventsDocument = gql`
309
358
  query GetDepositedEvents($first: Int!, $skip: Int, $orderBy: DepositedEvent_orderBy, $orderDirection: OrderDirection, $where: DepositedEvent_filter, $block: Block_height) {
310
359
  depositedEvents(
@@ -319,6 +368,9 @@ var GetDepositedEventsDocument = gql`
319
368
  slot {
320
369
  id
321
370
  }
371
+ currency {
372
+ ...CurrencyFields
373
+ }
322
374
  depositor
323
375
  amount
324
376
  timestamp
@@ -326,7 +378,7 @@ var GetDepositedEventsDocument = gql`
326
378
  tx
327
379
  }
328
380
  }
329
- `;
381
+ ${CurrencyFieldsFragmentDoc}`;
330
382
  var GetWithdrawnEventsDocument = gql`
331
383
  query GetWithdrawnEvents($first: Int!, $skip: Int, $orderBy: WithdrawnEvent_orderBy, $orderDirection: OrderDirection, $where: WithdrawnEvent_filter, $block: Block_height) {
332
384
  withdrawnEvents(
@@ -341,6 +393,9 @@ var GetWithdrawnEventsDocument = gql`
341
393
  slot {
342
394
  id
343
395
  }
396
+ currency {
397
+ ...CurrencyFields
398
+ }
344
399
  occupant
345
400
  amount
346
401
  timestamp
@@ -348,7 +403,7 @@ var GetWithdrawnEventsDocument = gql`
348
403
  tx
349
404
  }
350
405
  }
351
- `;
406
+ ${CurrencyFieldsFragmentDoc}`;
352
407
  var GetPriceUpdatedEventsDocument = gql`
353
408
  query GetPriceUpdatedEvents($first: Int!, $skip: Int, $orderBy: PriceUpdatedEvent_orderBy, $orderDirection: OrderDirection, $where: PriceUpdatedEvent_filter, $block: Block_height) {
354
409
  priceUpdatedEvents(
@@ -363,6 +418,9 @@ var GetPriceUpdatedEventsDocument = gql`
363
418
  slot {
364
419
  id
365
420
  }
421
+ currency {
422
+ ...CurrencyFields
423
+ }
366
424
  oldPrice
367
425
  newPrice
368
426
  timestamp
@@ -370,7 +428,7 @@ var GetPriceUpdatedEventsDocument = gql`
370
428
  tx
371
429
  }
372
430
  }
373
- `;
431
+ ${CurrencyFieldsFragmentDoc}`;
374
432
  var GetSlotActivityDocument = gql`
375
433
  query GetSlotActivity($slotId: String!, $first: Int!) {
376
434
  boughtEvents(
@@ -380,6 +438,9 @@ var GetSlotActivityDocument = gql`
380
438
  where: {slot: $slotId}
381
439
  ) {
382
440
  id
441
+ currency {
442
+ ...CurrencyFields
443
+ }
383
444
  buyer
384
445
  previousOccupant
385
446
  price
@@ -395,6 +456,9 @@ var GetSlotActivityDocument = gql`
395
456
  where: {slot: $slotId}
396
457
  ) {
397
458
  id
459
+ currency {
460
+ ...CurrencyFields
461
+ }
398
462
  occupant
399
463
  refund
400
464
  timestamp
@@ -407,6 +471,9 @@ var GetSlotActivityDocument = gql`
407
471
  where: {slot: $slotId}
408
472
  ) {
409
473
  id
474
+ currency {
475
+ ...CurrencyFields
476
+ }
410
477
  liquidator
411
478
  occupant
412
479
  bounty
@@ -420,6 +487,9 @@ var GetSlotActivityDocument = gql`
420
487
  where: {slot: $slotId}
421
488
  ) {
422
489
  id
490
+ currency {
491
+ ...CurrencyFields
492
+ }
423
493
  oldPrice
424
494
  newPrice
425
495
  timestamp
@@ -432,6 +502,9 @@ var GetSlotActivityDocument = gql`
432
502
  where: {slot: $slotId}
433
503
  ) {
434
504
  id
505
+ currency {
506
+ ...CurrencyFields
507
+ }
435
508
  depositor
436
509
  amount
437
510
  timestamp
@@ -444,6 +517,9 @@ var GetSlotActivityDocument = gql`
444
517
  where: {slot: $slotId}
445
518
  ) {
446
519
  id
520
+ currency {
521
+ ...CurrencyFields
522
+ }
447
523
  occupant
448
524
  amount
449
525
  timestamp
@@ -456,6 +532,9 @@ var GetSlotActivityDocument = gql`
456
532
  where: {slot: $slotId}
457
533
  ) {
458
534
  id
535
+ currency {
536
+ ...CurrencyFields
537
+ }
459
538
  recipient
460
539
  amount
461
540
  timestamp
@@ -494,7 +573,7 @@ var GetSlotActivityDocument = gql`
494
573
  tx
495
574
  }
496
575
  }
497
- `;
576
+ ${CurrencyFieldsFragmentDoc}`;
498
577
  var GetFactoryDocument = gql`
499
578
  query GetFactory {
500
579
  factories(first: 1) {
@@ -621,6 +700,19 @@ function getSdk(client, withWrapper = defaultWrapper) {
621
700
  }
622
701
  };
623
702
  }
703
+
704
+ // src/errors.ts
705
+ var SlotsError = class extends Error {
706
+ constructor(operation, cause) {
707
+ const msg = cause instanceof Error ? cause.message : String(cause);
708
+ super(`${operation}: ${msg}`);
709
+ this.operation = operation;
710
+ this.name = "SlotsError";
711
+ this.cause = cause;
712
+ }
713
+ };
714
+
715
+ // src/client.ts
624
716
  var META_QUERY = gql$1`
625
717
  query GetMeta {
626
718
  _meta {
@@ -654,12 +746,15 @@ var SlotsClient = class {
654
746
  this.sdk = getSdk(this.gqlClient);
655
747
  }
656
748
  // ─── Accessors ──────────────────────────────────────────────────────────────
749
+ /** Returns the chain ID this client was configured for. */
657
750
  getChainId() {
658
751
  return this.chainId;
659
752
  }
753
+ /** Returns the underlying GraphQL client (for advanced usage). */
660
754
  getClient() {
661
755
  return this.gqlClient;
662
756
  }
757
+ /** Returns the generated GraphQL SDK (for queries not wrapped by this client). */
663
758
  getSdk() {
664
759
  return this.sdk;
665
760
  }
@@ -680,111 +775,171 @@ var SlotsClient = class {
680
775
  if (!account) throw new Error("WalletClient must have an account");
681
776
  return account.address;
682
777
  }
778
+ get chain() {
779
+ const chain = this.wallet.chain;
780
+ if (!chain) throw new Error("WalletClient must have a chain");
781
+ return chain;
782
+ }
783
+ // ─── Helpers ────────────────────────────────────────────────────────────────
784
+ assertPositive(value, name) {
785
+ if (value <= 0n) throw new SlotsError(name, `${name} must be > 0`);
786
+ }
787
+ async query(operation, fn) {
788
+ try {
789
+ return await fn();
790
+ } catch (error) {
791
+ throw new SlotsError(operation, error);
792
+ }
793
+ }
683
794
  // ═══════════════════════════════════════════════════════════════════════════
684
795
  // READ — Subgraph Queries
685
796
  // ═══════════════════════════════════════════════════════════════════════════
686
797
  // Slot queries
798
+ /** Fetch a paginated list of slots. */
687
799
  getSlots(...args) {
688
- return this.sdk.GetSlots(...args);
800
+ return this.query("getSlots", () => this.sdk.GetSlots(...args));
689
801
  }
802
+ /** Fetch a single slot by its address. */
690
803
  getSlot(...args) {
691
- return this.sdk.GetSlot(...args);
804
+ return this.query("getSlot", () => this.sdk.GetSlot(...args));
692
805
  }
806
+ /** Fetch all slots owned by a given recipient address. */
693
807
  getSlotsByRecipient(...args) {
694
- return this.sdk.GetSlotsByRecipient(...args);
808
+ return this.query("getSlotsByRecipient", () => this.sdk.GetSlotsByRecipient(...args));
695
809
  }
810
+ /** Fetch all slots currently occupied by a given address. */
696
811
  getSlotsByOccupant(...args) {
697
- return this.sdk.GetSlotsByOccupant(...args);
812
+ return this.query("getSlotsByOccupant", () => this.sdk.GetSlotsByOccupant(...args));
698
813
  }
699
814
  // Factory queries
815
+ /** Fetch factory configuration. */
700
816
  getFactory() {
701
- return this.sdk.GetFactory();
817
+ return this.query("getFactory", () => this.sdk.GetFactory());
702
818
  }
819
+ /** Fetch registered modules. */
703
820
  getModules(...args) {
704
- return this.sdk.GetModules(...args);
821
+ return this.query("getModules", () => this.sdk.GetModules(...args));
705
822
  }
706
823
  // Event queries
824
+ /** Fetch bought events with optional filters. */
707
825
  getBoughtEvents(...args) {
708
- return this.sdk.GetBoughtEvents(...args);
826
+ return this.query("getBoughtEvents", () => this.sdk.GetBoughtEvents(...args));
709
827
  }
828
+ /** Fetch settled events with optional filters. */
710
829
  getSettledEvents(...args) {
711
- return this.sdk.GetSettledEvents(...args);
830
+ return this.query("getSettledEvents", () => this.sdk.GetSettledEvents(...args));
712
831
  }
832
+ /** Fetch tax-collected events with optional filters. */
713
833
  getTaxCollectedEvents(...args) {
714
- return this.sdk.GetTaxCollectedEvents(...args);
834
+ return this.query("getTaxCollectedEvents", () => this.sdk.GetTaxCollectedEvents(...args));
715
835
  }
836
+ /** Fetch all activity for a specific slot (all event types). */
716
837
  getSlotActivity(...args) {
717
- return this.sdk.GetSlotActivity(...args);
838
+ return this.query("getSlotActivity", () => this.sdk.GetSlotActivity(...args));
718
839
  }
840
+ /** Fetch the most recent events across all slots. */
719
841
  getRecentEvents(...args) {
720
- return this.sdk.GetRecentEvents(...args);
842
+ return this.query("getRecentEvents", () => this.sdk.GetRecentEvents(...args));
721
843
  }
722
844
  // Account queries
845
+ /** Fetch a single account by address. */
723
846
  getAccount(...args) {
724
- return this.sdk.GetAccount(...args);
847
+ return this.query("getAccount", () => this.sdk.GetAccount(...args));
725
848
  }
849
+ /** Fetch a paginated list of accounts. */
726
850
  getAccounts(...args) {
727
- return this.sdk.GetAccounts(...args);
851
+ return this.query("getAccounts", () => this.sdk.GetAccounts(...args));
728
852
  }
729
853
  // Individual event queries
854
+ /** Fetch released events with optional filters. */
730
855
  getReleasedEvents(...args) {
731
- return this.sdk.GetReleasedEvents(...args);
856
+ return this.query("getReleasedEvents", () => this.sdk.GetReleasedEvents(...args));
732
857
  }
858
+ /** Fetch liquidated events with optional filters. */
733
859
  getLiquidatedEvents(...args) {
734
- return this.sdk.GetLiquidatedEvents(...args);
860
+ return this.query("getLiquidatedEvents", () => this.sdk.GetLiquidatedEvents(...args));
735
861
  }
862
+ /** Fetch deposited events with optional filters. */
736
863
  getDepositedEvents(...args) {
737
- return this.sdk.GetDepositedEvents(...args);
864
+ return this.query("getDepositedEvents", () => this.sdk.GetDepositedEvents(...args));
738
865
  }
866
+ /** Fetch withdrawn events with optional filters. */
739
867
  getWithdrawnEvents(...args) {
740
- return this.sdk.GetWithdrawnEvents(...args);
868
+ return this.query("getWithdrawnEvents", () => this.sdk.GetWithdrawnEvents(...args));
741
869
  }
870
+ /** Fetch price-updated events with optional filters. */
742
871
  getPriceUpdatedEvents(...args) {
743
- return this.sdk.GetPriceUpdatedEvents(...args);
872
+ return this.query("getPriceUpdatedEvents", () => this.sdk.GetPriceUpdatedEvents(...args));
744
873
  }
745
874
  // Meta
875
+ /** Fetch subgraph indexing metadata (latest block, indexing errors). */
746
876
  getMeta() {
747
- return this.gqlClient.request(META_QUERY);
877
+ return this.query("getMeta", () => this.gqlClient.request(META_QUERY));
748
878
  }
749
879
  // ═══════════════════════════════════════════════════════════════════════════
750
880
  // READ — On-chain (RPC)
751
881
  // ═══════════════════════════════════════════════════════════════════════════
752
- /** Read full slot info from on-chain (RPC, not subgraph). */
753
- async getSlotInfo(slot) {
754
- return this.publicClient.readContract({
755
- address: slot,
756
- abi: slotAbi,
757
- functionName: "getSlotInfo"
758
- });
882
+ /**
883
+ * Read full slot info from on-chain (RPC, not subgraph).
884
+ * @param slot - Slot contract address.
885
+ * @returns On-chain slot info tuple.
886
+ * @throws {SlotsError} If the RPC call fails.
887
+ */
888
+ getSlotInfo(slot) {
889
+ return this.query(
890
+ "getSlotInfo",
891
+ () => this.publicClient.readContract({
892
+ address: slot,
893
+ abi: slotAbi,
894
+ functionName: "getSlotInfo"
895
+ })
896
+ );
759
897
  }
760
898
  // ═══════════════════════════════════════════════════════════════════════════
761
899
  // WRITE — Factory Functions
762
900
  // ═══════════════════════════════════════════════════════════════════════════
901
+ /**
902
+ * Deploy a new slot via the factory contract.
903
+ * @param params - Slot creation parameters (recipient, currency, config, initParams).
904
+ * @returns Transaction hash.
905
+ */
763
906
  async createSlot(params) {
764
907
  return this.wallet.writeContract({
765
908
  address: this.factory,
766
909
  abi: slotFactoryAbi,
767
910
  functionName: "createSlot",
768
911
  args: [params.recipient, params.currency, params.config, params.initParams],
769
- account: this.wallet.account,
770
- chain: this.wallet.chain
912
+ account: this.account,
913
+ chain: this.chain
771
914
  });
772
915
  }
916
+ /**
917
+ * Deploy multiple identical slots in a single transaction via the factory contract.
918
+ * @param params - Slot creation parameters including count.
919
+ * @returns Transaction hash.
920
+ */
773
921
  async createSlots(params) {
774
922
  return this.wallet.writeContract({
775
923
  address: this.factory,
776
924
  abi: slotFactoryAbi,
777
925
  functionName: "createSlots",
778
926
  args: [params.recipient, params.currency, params.config, params.initParams, params.count],
779
- account: this.wallet.account,
780
- chain: this.wallet.chain
927
+ account: this.account,
928
+ chain: this.chain
781
929
  });
782
930
  }
783
931
  // ═══════════════════════════════════════════════════════════════════════════
784
932
  // WRITE — Slot Functions
785
933
  // ═══════════════════════════════════════════════════════════════════════════
786
- /** Buy a slot (or force buy an occupied one). Handles ERC-20 approval automatically. */
934
+ /**
935
+ * Buy a slot (or force-buy an occupied one). Handles ERC-20 approval automatically.
936
+ * @param params - Buy parameters (slot address, deposit amount, self-assessed price).
937
+ * @returns Transaction hash.
938
+ * @throws {SlotsError} If depositAmount or selfAssessedPrice is not positive, or the transaction fails.
939
+ */
787
940
  async buy(params) {
941
+ this.assertPositive(params.depositAmount, "depositAmount");
942
+ this.assertPositive(params.selfAssessedPrice, "selfAssessedPrice");
788
943
  return this.withAllowance(params.slot, params.depositAmount, {
789
944
  to: params.slot,
790
945
  abi: slotAbi,
@@ -792,19 +947,31 @@ var SlotsClient = class {
792
947
  args: [params.depositAmount, params.selfAssessedPrice]
793
948
  });
794
949
  }
795
- /** Self-assess a new price for an occupied slot (occupant only). */
950
+ /**
951
+ * Self-assess a new price for an occupied slot (occupant only).
952
+ * @param slot - The slot contract address.
953
+ * @param newPrice - The new self-assessed price (can be 0).
954
+ * @returns Transaction hash.
955
+ */
796
956
  async selfAssess(slot, newPrice) {
797
957
  return this.wallet.writeContract({
798
958
  address: slot,
799
959
  abi: slotAbi,
800
960
  functionName: "selfAssess",
801
961
  args: [newPrice],
802
- account: this.wallet.account,
803
- chain: this.wallet.chain
962
+ account: this.account,
963
+ chain: this.chain
804
964
  });
805
965
  }
806
- /** Top up deposit on a slot (occupant only). Handles ERC-20 approval automatically. */
966
+ /**
967
+ * Top up deposit on a slot (occupant only). Handles ERC-20 approval automatically.
968
+ * @param slot - The slot contract address.
969
+ * @param amount - The amount to deposit (must be > 0).
970
+ * @returns Transaction hash.
971
+ * @throws {SlotsError} If amount is not positive, or the transaction fails.
972
+ */
807
973
  async topUp(slot, amount) {
974
+ this.assertPositive(amount, "amount");
808
975
  return this.withAllowance(slot, amount, {
809
976
  to: slot,
810
977
  abi: slotAbi,
@@ -812,98 +979,145 @@ var SlotsClient = class {
812
979
  args: [amount]
813
980
  });
814
981
  }
815
- /** Withdraw from deposit (occupant only). Cannot go below minimum deposit. */
982
+ /**
983
+ * Withdraw from deposit (occupant only). Cannot go below minimum deposit.
984
+ * @param slot - The slot contract address.
985
+ * @param amount - The amount to withdraw (must be > 0).
986
+ * @returns Transaction hash.
987
+ * @throws {SlotsError} If amount is not positive, or the transaction fails.
988
+ */
816
989
  async withdraw(slot, amount) {
990
+ this.assertPositive(amount, "amount");
817
991
  return this.wallet.writeContract({
818
992
  address: slot,
819
993
  abi: slotAbi,
820
994
  functionName: "withdraw",
821
995
  args: [amount],
822
- account: this.wallet.account,
823
- chain: this.wallet.chain
996
+ account: this.account,
997
+ chain: this.chain
824
998
  });
825
999
  }
826
- /** Release a slot (occupant only). Returns remaining deposit. */
1000
+ /**
1001
+ * Release a slot (occupant only). Returns remaining deposit to the occupant.
1002
+ * @param slot - The slot contract address.
1003
+ * @returns Transaction hash.
1004
+ */
827
1005
  async release(slot) {
828
1006
  return this.wallet.writeContract({
829
1007
  address: slot,
830
1008
  abi: slotAbi,
831
1009
  functionName: "release",
832
- account: this.wallet.account,
833
- chain: this.wallet.chain
1010
+ account: this.account,
1011
+ chain: this.chain
834
1012
  });
835
1013
  }
836
- /** Collect accumulated tax (permissionless). */
1014
+ /**
1015
+ * Collect accumulated tax (permissionless).
1016
+ * @param slot - The slot contract address.
1017
+ * @returns Transaction hash.
1018
+ */
837
1019
  async collect(slot) {
838
1020
  return this.wallet.writeContract({
839
1021
  address: slot,
840
1022
  abi: slotAbi,
841
1023
  functionName: "collect",
842
- account: this.wallet.account,
843
- chain: this.wallet.chain
1024
+ account: this.account,
1025
+ chain: this.chain
844
1026
  });
845
1027
  }
846
- /** Liquidate an insolvent slot (permissionless). Caller receives bounty. */
1028
+ /**
1029
+ * Liquidate an insolvent slot (permissionless). Caller receives bounty.
1030
+ * @param slot - The slot contract address.
1031
+ * @returns Transaction hash.
1032
+ */
847
1033
  async liquidate(slot) {
848
1034
  return this.wallet.writeContract({
849
1035
  address: slot,
850
1036
  abi: slotAbi,
851
1037
  functionName: "liquidate",
852
- account: this.wallet.account,
853
- chain: this.wallet.chain
1038
+ account: this.account,
1039
+ chain: this.chain
854
1040
  });
855
1041
  }
856
1042
  // ═══════════════════════════════════════════════════════════════════════════
857
1043
  // WRITE — Manager Functions
858
1044
  // ═══════════════════════════════════════════════════════════════════════════
859
- /** Propose a tax rate update (manager only, slot must have mutableTax). */
1045
+ /**
1046
+ * Propose a tax rate update (manager only, slot must have mutableTax).
1047
+ * @param slot - The slot contract address.
1048
+ * @param newPct - The new tax percentage.
1049
+ * @returns Transaction hash.
1050
+ */
860
1051
  async proposeTaxUpdate(slot, newPct) {
861
1052
  return this.wallet.writeContract({
862
1053
  address: slot,
863
1054
  abi: slotAbi,
864
1055
  functionName: "proposeTaxUpdate",
865
1056
  args: [newPct],
866
- account: this.wallet.account,
867
- chain: this.wallet.chain
1057
+ account: this.account,
1058
+ chain: this.chain
868
1059
  });
869
1060
  }
870
- /** Propose a module update (manager only, slot must have mutableModule). */
1061
+ /**
1062
+ * Propose a module update (manager only, slot must have mutableModule).
1063
+ * @param slot - The slot contract address.
1064
+ * @param newModule - The new module contract address.
1065
+ * @returns Transaction hash.
1066
+ */
871
1067
  async proposeModuleUpdate(slot, newModule) {
872
1068
  return this.wallet.writeContract({
873
1069
  address: slot,
874
1070
  abi: slotAbi,
875
1071
  functionName: "proposeModuleUpdate",
876
1072
  args: [newModule],
877
- account: this.wallet.account,
878
- chain: this.wallet.chain
1073
+ account: this.account,
1074
+ chain: this.chain
879
1075
  });
880
1076
  }
881
- /** Cancel pending updates (manager only). */
1077
+ /**
1078
+ * Cancel pending updates (manager only).
1079
+ * @param slot - The slot contract address.
1080
+ * @returns Transaction hash.
1081
+ */
882
1082
  async cancelPendingUpdates(slot) {
883
1083
  return this.wallet.writeContract({
884
1084
  address: slot,
885
1085
  abi: slotAbi,
886
1086
  functionName: "cancelPendingUpdates",
887
- account: this.wallet.account,
888
- chain: this.wallet.chain
1087
+ account: this.account,
1088
+ chain: this.chain
889
1089
  });
890
1090
  }
891
- /** Set liquidation bounty bps (manager only). */
1091
+ /**
1092
+ * Set liquidation bounty bps (manager only).
1093
+ * @param slot - The slot contract address.
1094
+ * @param newBps - The new bounty in basis points (0-10000).
1095
+ * @returns Transaction hash.
1096
+ * @throws {SlotsError} If newBps is outside 0-10000, or the transaction fails.
1097
+ */
892
1098
  async setLiquidationBounty(slot, newBps) {
1099
+ if (newBps < 0n || newBps > 10000n) throw new SlotsError("setLiquidationBounty", "newBps must be 0-10000");
893
1100
  return this.wallet.writeContract({
894
1101
  address: slot,
895
1102
  abi: slotAbi,
896
1103
  functionName: "setLiquidationBounty",
897
1104
  args: [newBps],
898
- account: this.wallet.account,
899
- chain: this.wallet.chain
1105
+ account: this.account,
1106
+ chain: this.chain
900
1107
  });
901
1108
  }
902
1109
  // ═══════════════════════════════════════════════════════════════════════════
903
1110
  // WRITE — Multicall
904
1111
  // ═══════════════════════════════════════════════════════════════════════════
905
- /** Batch multiple slot calls into one transaction via multicall. */
1112
+ /**
1113
+ * Batch multiple slot calls into one transaction via multicall.
1114
+ * @param slot - The slot contract address.
1115
+ * @param calls - Array of function calls to batch.
1116
+ * @returns Transaction hash.
1117
+ * @throws {SlotsError} If calls array is empty, or the transaction fails.
1118
+ */
906
1119
  async multicall(slot, calls) {
1120
+ if (calls.length === 0) throw new SlotsError("multicall", "calls array must not be empty");
907
1121
  const data = calls.map(
908
1122
  (call) => encodeFunctionData({
909
1123
  abi: slotAbi,
@@ -916,8 +1130,8 @@ var SlotsClient = class {
916
1130
  abi: slotAbi,
917
1131
  functionName: "multicall",
918
1132
  args: [data],
919
- account: this.wallet.account,
920
- chain: this.wallet.chain
1133
+ account: this.account,
1134
+ chain: this.chain
921
1135
  });
922
1136
  }
923
1137
  // ─── Internals ──────────────────────────────────────────────────────────────
@@ -930,7 +1144,7 @@ var SlotsClient = class {
930
1144
  this._atomicSupport = false;
931
1145
  return false;
932
1146
  }
933
- const chainId = this.wallet.chain.id;
1147
+ const chainId = this.chain.id;
934
1148
  const chainCaps = capabilities[chainId] || capabilities[`0x${chainId.toString(16)}`];
935
1149
  const atomic = chainCaps?.atomicBatch ?? chainCaps?.atomic;
936
1150
  const status = atomic && typeof atomic === "object" && "status" in atomic ? atomic.status : void 0;
@@ -987,8 +1201,8 @@ var SlotsClient = class {
987
1201
  args: call.args
988
1202
  });
989
1203
  const id = await this.wallet.sendCalls({
990
- account: this.wallet.account,
991
- chain: this.wallet.chain,
1204
+ account: this.account,
1205
+ chain: this.chain,
992
1206
  calls: [
993
1207
  { to: currency, data: approveData },
994
1208
  { to: call.to, data: actionData }
@@ -1003,8 +1217,8 @@ var SlotsClient = class {
1003
1217
  abi: erc20Abi,
1004
1218
  functionName: "approve",
1005
1219
  args: [spender, amount],
1006
- account: this.wallet.account,
1007
- chain: this.wallet.chain
1220
+ account: this.account,
1221
+ chain: this.chain
1008
1222
  });
1009
1223
  await this.publicClient.waitForTransactionReceipt({ hash });
1010
1224
  }
@@ -1013,8 +1227,8 @@ var SlotsClient = class {
1013
1227
  abi: call.abi,
1014
1228
  functionName: call.functionName,
1015
1229
  args: call.args,
1016
- account: this.wallet.account,
1017
- chain: this.wallet.chain
1230
+ account: this.account,
1231
+ chain: this.chain
1018
1232
  });
1019
1233
  }
1020
1234
  };
@@ -1022,6 +1236,6 @@ function createSlotsClient(config) {
1022
1236
  return new SlotsClient(config);
1023
1237
  }
1024
1238
 
1025
- export { AccountFieldsFragmentDoc, GetAccountDocument, GetAccountsDocument, GetBoughtEventsDocument, GetDepositedEventsDocument, GetFactoryDocument, GetLiquidatedEventsDocument, GetModulesDocument, GetPriceUpdatedEventsDocument, GetRecentEventsDocument, GetReleasedEventsDocument, GetSettledEventsDocument, GetSlotActivityDocument, GetSlotDocument, GetSlotsByOccupantDocument, GetSlotsByRecipientDocument, GetSlotsDocument, GetTaxCollectedEventsDocument, GetWithdrawnEventsDocument, SUBGRAPH_URLS, SlotFieldsFragmentDoc, SlotsChain, SlotsClient, createSlotsClient, getSdk };
1239
+ export { AccountFieldsFragmentDoc, CurrencyFieldsFragmentDoc, GetAccountDocument, GetAccountsDocument, GetBoughtEventsDocument, GetDepositedEventsDocument, GetFactoryDocument, GetLiquidatedEventsDocument, GetModulesDocument, GetPriceUpdatedEventsDocument, GetRecentEventsDocument, GetReleasedEventsDocument, GetSettledEventsDocument, GetSlotActivityDocument, GetSlotDocument, GetSlotsByOccupantDocument, GetSlotsByRecipientDocument, GetSlotsDocument, GetTaxCollectedEventsDocument, GetWithdrawnEventsDocument, SUBGRAPH_URLS, SlotFieldsFragmentDoc, SlotsChain, SlotsClient, SlotsError, createSlotsClient, getSdk };
1026
1240
  //# sourceMappingURL=index.js.map
1027
1241
  //# sourceMappingURL=index.js.map