@0xslots/sdk 0.4.0 → 0.6.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 +44 -167
- package/dist/index.d.ts +1749 -1582
- package/dist/index.js +837 -261
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -1,327 +1,611 @@
|
|
|
1
|
-
import { GraphQLClient } from 'graphql-request';
|
|
1
|
+
import { gql as gql$1, GraphQLClient } from 'graphql-request';
|
|
2
2
|
import gql from 'graphql-tag';
|
|
3
|
+
import { encodeFunctionData, erc20Abi } from 'viem';
|
|
4
|
+
import { getSlotsHubAddress, slotAbi, slotFactoryAbi } from '@0xslots/contracts';
|
|
3
5
|
|
|
4
6
|
// src/client.ts
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
var AccountFieldsFragmentDoc = gql`
|
|
8
|
+
fragment AccountFields on Account {
|
|
9
|
+
id
|
|
10
|
+
slotCount
|
|
11
|
+
occupiedCount
|
|
12
|
+
slotsAsRecipient {
|
|
13
|
+
id
|
|
14
|
+
}
|
|
15
|
+
slotsAsOccupant {
|
|
16
|
+
id
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
var SlotFieldsFragmentDoc = gql`
|
|
21
|
+
fragment SlotFields on Slot {
|
|
22
|
+
id
|
|
23
|
+
recipient
|
|
24
|
+
recipientAccount {
|
|
25
|
+
id
|
|
26
|
+
slotCount
|
|
27
|
+
occupiedCount
|
|
28
|
+
}
|
|
29
|
+
currency
|
|
30
|
+
currencyName
|
|
31
|
+
currencySymbol
|
|
32
|
+
currencyDecimals
|
|
33
|
+
manager
|
|
34
|
+
mutableTax
|
|
35
|
+
mutableModule
|
|
36
|
+
taxPercentage
|
|
37
|
+
module {
|
|
38
|
+
id
|
|
39
|
+
verified
|
|
40
|
+
name
|
|
41
|
+
version
|
|
42
|
+
}
|
|
43
|
+
occupant
|
|
44
|
+
occupantAccount {
|
|
45
|
+
id
|
|
46
|
+
slotCount
|
|
47
|
+
occupiedCount
|
|
48
|
+
}
|
|
49
|
+
price
|
|
50
|
+
deposit
|
|
51
|
+
collectedTax
|
|
52
|
+
totalCollected
|
|
53
|
+
liquidationBountyBps
|
|
54
|
+
minDepositSeconds
|
|
55
|
+
createdAt
|
|
56
|
+
createdTx
|
|
57
|
+
updatedAt
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
var GetAccountDocument = gql`
|
|
61
|
+
query GetAccount($id: ID!, $block: Block_height) {
|
|
62
|
+
account(id: $id, block: $block) {
|
|
63
|
+
...AccountFields
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
${AccountFieldsFragmentDoc}`;
|
|
67
|
+
var GetAccountsDocument = gql`
|
|
68
|
+
query GetAccounts($first: Int!, $skip: Int, $orderBy: Account_orderBy, $orderDirection: OrderDirection, $where: Account_filter, $block: Block_height) {
|
|
69
|
+
accounts(
|
|
8
70
|
first: $first
|
|
9
71
|
skip: $skip
|
|
10
72
|
orderBy: $orderBy
|
|
11
73
|
orderDirection: $orderDirection
|
|
12
74
|
where: $where
|
|
75
|
+
block: $block
|
|
13
76
|
) {
|
|
77
|
+
...AccountFields
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
${AccountFieldsFragmentDoc}`;
|
|
81
|
+
var GetRecentEventsDocument = gql`
|
|
82
|
+
query GetRecentEvents($first: Int!) {
|
|
83
|
+
boughtEvents(first: $first, orderBy: timestamp, orderDirection: desc) {
|
|
14
84
|
id
|
|
15
85
|
slot {
|
|
16
86
|
id
|
|
17
|
-
slotId
|
|
18
|
-
land {
|
|
19
|
-
id
|
|
20
|
-
}
|
|
21
87
|
}
|
|
22
|
-
|
|
88
|
+
buyer
|
|
23
89
|
previousOccupant
|
|
90
|
+
price
|
|
91
|
+
selfAssessedPrice
|
|
92
|
+
deposit
|
|
93
|
+
timestamp
|
|
94
|
+
tx
|
|
95
|
+
}
|
|
96
|
+
releasedEvents(first: $first, orderBy: timestamp, orderDirection: desc) {
|
|
97
|
+
id
|
|
98
|
+
slot {
|
|
99
|
+
id
|
|
100
|
+
}
|
|
101
|
+
occupant
|
|
102
|
+
refund
|
|
103
|
+
timestamp
|
|
104
|
+
tx
|
|
105
|
+
}
|
|
106
|
+
liquidatedEvents(first: $first, orderBy: timestamp, orderDirection: desc) {
|
|
107
|
+
id
|
|
108
|
+
slot {
|
|
109
|
+
id
|
|
110
|
+
}
|
|
111
|
+
liquidator
|
|
112
|
+
occupant
|
|
113
|
+
bounty
|
|
114
|
+
timestamp
|
|
115
|
+
tx
|
|
116
|
+
}
|
|
117
|
+
priceUpdatedEvents(first: $first, orderBy: timestamp, orderDirection: desc) {
|
|
118
|
+
id
|
|
119
|
+
slot {
|
|
120
|
+
id
|
|
121
|
+
}
|
|
122
|
+
oldPrice
|
|
123
|
+
newPrice
|
|
124
|
+
timestamp
|
|
125
|
+
tx
|
|
126
|
+
}
|
|
127
|
+
depositedEvents(first: $first, orderBy: timestamp, orderDirection: desc) {
|
|
128
|
+
id
|
|
129
|
+
slot {
|
|
130
|
+
id
|
|
131
|
+
}
|
|
132
|
+
depositor
|
|
133
|
+
amount
|
|
134
|
+
timestamp
|
|
135
|
+
tx
|
|
136
|
+
}
|
|
137
|
+
withdrawnEvents(first: $first, orderBy: timestamp, orderDirection: desc) {
|
|
138
|
+
id
|
|
139
|
+
slot {
|
|
140
|
+
id
|
|
141
|
+
}
|
|
142
|
+
occupant
|
|
143
|
+
amount
|
|
144
|
+
timestamp
|
|
145
|
+
tx
|
|
146
|
+
}
|
|
147
|
+
taxCollectedEvents(first: $first, orderBy: timestamp, orderDirection: desc) {
|
|
148
|
+
id
|
|
149
|
+
slot {
|
|
150
|
+
id
|
|
151
|
+
}
|
|
152
|
+
recipient
|
|
153
|
+
amount
|
|
154
|
+
timestamp
|
|
155
|
+
tx
|
|
156
|
+
}
|
|
157
|
+
taxUpdateProposedEvents(first: $first, orderBy: timestamp, orderDirection: desc) {
|
|
158
|
+
id
|
|
159
|
+
slot {
|
|
160
|
+
id
|
|
161
|
+
}
|
|
162
|
+
newPercentage
|
|
163
|
+
timestamp
|
|
164
|
+
tx
|
|
165
|
+
}
|
|
166
|
+
moduleUpdateProposedEvents(
|
|
167
|
+
first: $first
|
|
168
|
+
orderBy: timestamp
|
|
169
|
+
orderDirection: desc
|
|
170
|
+
) {
|
|
171
|
+
id
|
|
172
|
+
slot {
|
|
173
|
+
id
|
|
174
|
+
}
|
|
175
|
+
newModule
|
|
176
|
+
timestamp
|
|
177
|
+
tx
|
|
178
|
+
}
|
|
179
|
+
pendingUpdateCancelledEvents(
|
|
180
|
+
first: $first
|
|
181
|
+
orderBy: timestamp
|
|
182
|
+
orderDirection: desc
|
|
183
|
+
) {
|
|
184
|
+
id
|
|
185
|
+
slot {
|
|
186
|
+
id
|
|
187
|
+
}
|
|
24
188
|
timestamp
|
|
25
|
-
blockNumber
|
|
26
189
|
tx
|
|
27
190
|
}
|
|
28
191
|
}
|
|
29
192
|
`;
|
|
30
|
-
var
|
|
31
|
-
query
|
|
32
|
-
|
|
193
|
+
var GetBoughtEventsDocument = gql`
|
|
194
|
+
query GetBoughtEvents($first: Int!, $skip: Int, $orderBy: BoughtEvent_orderBy, $orderDirection: OrderDirection, $where: BoughtEvent_filter, $block: Block_height) {
|
|
195
|
+
boughtEvents(
|
|
33
196
|
first: $first
|
|
197
|
+
skip: $skip
|
|
34
198
|
orderBy: $orderBy
|
|
35
199
|
orderDirection: $orderDirection
|
|
200
|
+
where: $where
|
|
201
|
+
block: $block
|
|
36
202
|
) {
|
|
37
203
|
id
|
|
38
|
-
|
|
204
|
+
slot {
|
|
39
205
|
id
|
|
40
206
|
}
|
|
41
|
-
|
|
207
|
+
buyer
|
|
208
|
+
previousOccupant
|
|
209
|
+
price
|
|
210
|
+
deposit
|
|
211
|
+
selfAssessedPrice
|
|
42
212
|
timestamp
|
|
43
213
|
blockNumber
|
|
44
214
|
tx
|
|
45
215
|
}
|
|
46
216
|
}
|
|
47
217
|
`;
|
|
48
|
-
var
|
|
49
|
-
query
|
|
50
|
-
|
|
218
|
+
var GetReleasedEventsDocument = gql`
|
|
219
|
+
query GetReleasedEvents($first: Int!, $skip: Int, $orderBy: ReleasedEvent_orderBy, $orderDirection: OrderDirection, $where: ReleasedEvent_filter, $block: Block_height) {
|
|
220
|
+
releasedEvents(
|
|
51
221
|
first: $first
|
|
222
|
+
skip: $skip
|
|
52
223
|
orderBy: $orderBy
|
|
53
224
|
orderDirection: $orderDirection
|
|
54
225
|
where: $where
|
|
226
|
+
block: $block
|
|
55
227
|
) {
|
|
56
228
|
id
|
|
57
229
|
slot {
|
|
58
230
|
id
|
|
59
|
-
slotId
|
|
60
231
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
currency
|
|
64
|
-
basePrice
|
|
65
|
-
taxPercentage
|
|
232
|
+
occupant
|
|
233
|
+
refund
|
|
66
234
|
timestamp
|
|
67
235
|
blockNumber
|
|
68
236
|
tx
|
|
69
237
|
}
|
|
70
238
|
}
|
|
71
239
|
`;
|
|
72
|
-
var
|
|
73
|
-
query
|
|
74
|
-
|
|
240
|
+
var GetLiquidatedEventsDocument = gql`
|
|
241
|
+
query GetLiquidatedEvents($first: Int!, $skip: Int, $orderBy: LiquidatedEvent_orderBy, $orderDirection: OrderDirection, $where: LiquidatedEvent_filter, $block: Block_height) {
|
|
242
|
+
liquidatedEvents(
|
|
75
243
|
first: $first
|
|
244
|
+
skip: $skip
|
|
76
245
|
orderBy: $orderBy
|
|
77
246
|
orderDirection: $orderDirection
|
|
78
247
|
where: $where
|
|
248
|
+
block: $block
|
|
79
249
|
) {
|
|
80
250
|
id
|
|
81
251
|
slot {
|
|
82
252
|
id
|
|
83
|
-
slotId
|
|
84
253
|
}
|
|
85
|
-
|
|
86
|
-
|
|
254
|
+
liquidator
|
|
255
|
+
occupant
|
|
256
|
+
bounty
|
|
87
257
|
timestamp
|
|
88
258
|
blockNumber
|
|
89
259
|
tx
|
|
90
260
|
}
|
|
91
261
|
}
|
|
92
262
|
`;
|
|
93
|
-
var
|
|
94
|
-
query
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
263
|
+
var GetSettledEventsDocument = gql`
|
|
264
|
+
query GetSettledEvents($first: Int!, $skip: Int, $orderBy: SettledEvent_orderBy, $orderDirection: OrderDirection, $where: SettledEvent_filter, $block: Block_height) {
|
|
265
|
+
settledEvents(
|
|
266
|
+
first: $first
|
|
267
|
+
skip: $skip
|
|
268
|
+
orderBy: $orderBy
|
|
269
|
+
orderDirection: $orderDirection
|
|
270
|
+
where: $where
|
|
271
|
+
block: $block
|
|
272
|
+
) {
|
|
273
|
+
id
|
|
274
|
+
slot {
|
|
102
275
|
id
|
|
103
|
-
name
|
|
104
|
-
symbol
|
|
105
|
-
decimals
|
|
106
276
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
moduleCallGasLimit
|
|
114
|
-
liquidationBountyBps
|
|
115
|
-
minDepositSeconds
|
|
277
|
+
taxOwed
|
|
278
|
+
taxPaid
|
|
279
|
+
depositRemaining
|
|
280
|
+
timestamp
|
|
281
|
+
blockNumber
|
|
282
|
+
tx
|
|
116
283
|
}
|
|
117
284
|
}
|
|
118
285
|
`;
|
|
119
|
-
var
|
|
120
|
-
query
|
|
121
|
-
|
|
286
|
+
var GetTaxCollectedEventsDocument = gql`
|
|
287
|
+
query GetTaxCollectedEvents($first: Int!, $skip: Int, $orderBy: TaxCollectedEvent_orderBy, $orderDirection: OrderDirection, $where: TaxCollectedEvent_filter, $block: Block_height) {
|
|
288
|
+
taxCollectedEvents(
|
|
289
|
+
first: $first
|
|
290
|
+
skip: $skip
|
|
291
|
+
orderBy: $orderBy
|
|
292
|
+
orderDirection: $orderDirection
|
|
293
|
+
where: $where
|
|
294
|
+
block: $block
|
|
295
|
+
) {
|
|
122
296
|
id
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
297
|
+
slot {
|
|
298
|
+
id
|
|
299
|
+
}
|
|
300
|
+
recipient
|
|
301
|
+
amount
|
|
302
|
+
timestamp
|
|
303
|
+
blockNumber
|
|
304
|
+
tx
|
|
126
305
|
}
|
|
127
306
|
}
|
|
128
307
|
`;
|
|
129
|
-
var
|
|
130
|
-
query
|
|
131
|
-
|
|
308
|
+
var GetDepositedEventsDocument = gql`
|
|
309
|
+
query GetDepositedEvents($first: Int!, $skip: Int, $orderBy: DepositedEvent_orderBy, $orderDirection: OrderDirection, $where: DepositedEvent_filter, $block: Block_height) {
|
|
310
|
+
depositedEvents(
|
|
311
|
+
first: $first
|
|
312
|
+
skip: $skip
|
|
313
|
+
orderBy: $orderBy
|
|
314
|
+
orderDirection: $orderDirection
|
|
315
|
+
where: $where
|
|
316
|
+
block: $block
|
|
317
|
+
) {
|
|
132
318
|
id
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
319
|
+
slot {
|
|
320
|
+
id
|
|
321
|
+
}
|
|
322
|
+
depositor
|
|
323
|
+
amount
|
|
324
|
+
timestamp
|
|
325
|
+
blockNumber
|
|
326
|
+
tx
|
|
136
327
|
}
|
|
137
328
|
}
|
|
138
329
|
`;
|
|
139
|
-
var
|
|
140
|
-
query
|
|
141
|
-
|
|
330
|
+
var GetWithdrawnEventsDocument = gql`
|
|
331
|
+
query GetWithdrawnEvents($first: Int!, $skip: Int, $orderBy: WithdrawnEvent_orderBy, $orderDirection: OrderDirection, $where: WithdrawnEvent_filter, $block: Block_height) {
|
|
332
|
+
withdrawnEvents(
|
|
142
333
|
first: $first
|
|
143
334
|
skip: $skip
|
|
144
335
|
orderBy: $orderBy
|
|
145
336
|
orderDirection: $orderDirection
|
|
337
|
+
where: $where
|
|
338
|
+
block: $block
|
|
146
339
|
) {
|
|
147
340
|
id
|
|
148
|
-
|
|
149
|
-
hub {
|
|
341
|
+
slot {
|
|
150
342
|
id
|
|
151
343
|
}
|
|
152
|
-
|
|
153
|
-
|
|
344
|
+
occupant
|
|
345
|
+
amount
|
|
346
|
+
timestamp
|
|
347
|
+
blockNumber
|
|
348
|
+
tx
|
|
154
349
|
}
|
|
155
350
|
}
|
|
156
351
|
`;
|
|
157
|
-
var
|
|
158
|
-
query
|
|
159
|
-
|
|
352
|
+
var GetPriceUpdatedEventsDocument = gql`
|
|
353
|
+
query GetPriceUpdatedEvents($first: Int!, $skip: Int, $orderBy: PriceUpdatedEvent_orderBy, $orderDirection: OrderDirection, $where: PriceUpdatedEvent_filter, $block: Block_height) {
|
|
354
|
+
priceUpdatedEvents(
|
|
355
|
+
first: $first
|
|
356
|
+
skip: $skip
|
|
357
|
+
orderBy: $orderBy
|
|
358
|
+
orderDirection: $orderDirection
|
|
359
|
+
where: $where
|
|
360
|
+
block: $block
|
|
361
|
+
) {
|
|
160
362
|
id
|
|
161
|
-
|
|
162
|
-
hub {
|
|
163
|
-
id
|
|
164
|
-
}
|
|
165
|
-
createdAt
|
|
166
|
-
createdTx
|
|
167
|
-
slots {
|
|
363
|
+
slot {
|
|
168
364
|
id
|
|
169
|
-
slotId
|
|
170
|
-
occupant
|
|
171
|
-
currency
|
|
172
|
-
price
|
|
173
|
-
taxPercentage
|
|
174
|
-
active
|
|
175
365
|
}
|
|
366
|
+
oldPrice
|
|
367
|
+
newPrice
|
|
368
|
+
timestamp
|
|
369
|
+
blockNumber
|
|
370
|
+
tx
|
|
176
371
|
}
|
|
177
372
|
}
|
|
178
373
|
`;
|
|
179
|
-
var
|
|
180
|
-
query
|
|
181
|
-
|
|
374
|
+
var GetSlotActivityDocument = gql`
|
|
375
|
+
query GetSlotActivity($slotId: String!, $first: Int!) {
|
|
376
|
+
boughtEvents(
|
|
377
|
+
first: $first
|
|
378
|
+
orderBy: timestamp
|
|
379
|
+
orderDirection: desc
|
|
380
|
+
where: {slot: $slotId}
|
|
381
|
+
) {
|
|
382
|
+
id
|
|
383
|
+
buyer
|
|
384
|
+
previousOccupant
|
|
385
|
+
price
|
|
386
|
+
selfAssessedPrice
|
|
387
|
+
deposit
|
|
388
|
+
timestamp
|
|
389
|
+
tx
|
|
390
|
+
}
|
|
391
|
+
releasedEvents(
|
|
392
|
+
first: $first
|
|
393
|
+
orderBy: timestamp
|
|
394
|
+
orderDirection: desc
|
|
395
|
+
where: {slot: $slotId}
|
|
396
|
+
) {
|
|
182
397
|
id
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
398
|
+
occupant
|
|
399
|
+
refund
|
|
400
|
+
timestamp
|
|
401
|
+
tx
|
|
402
|
+
}
|
|
403
|
+
liquidatedEvents(
|
|
404
|
+
first: $first
|
|
405
|
+
orderBy: timestamp
|
|
406
|
+
orderDirection: desc
|
|
407
|
+
where: {slot: $slotId}
|
|
408
|
+
) {
|
|
409
|
+
id
|
|
410
|
+
liquidator
|
|
411
|
+
occupant
|
|
412
|
+
bounty
|
|
413
|
+
timestamp
|
|
414
|
+
tx
|
|
415
|
+
}
|
|
416
|
+
priceUpdatedEvents(
|
|
417
|
+
first: $first
|
|
418
|
+
orderBy: timestamp
|
|
419
|
+
orderDirection: desc
|
|
420
|
+
where: {slot: $slotId}
|
|
421
|
+
) {
|
|
422
|
+
id
|
|
423
|
+
oldPrice
|
|
424
|
+
newPrice
|
|
425
|
+
timestamp
|
|
426
|
+
tx
|
|
427
|
+
}
|
|
428
|
+
depositedEvents(
|
|
429
|
+
first: $first
|
|
430
|
+
orderBy: timestamp
|
|
431
|
+
orderDirection: desc
|
|
432
|
+
where: {slot: $slotId}
|
|
433
|
+
) {
|
|
434
|
+
id
|
|
435
|
+
depositor
|
|
436
|
+
amount
|
|
437
|
+
timestamp
|
|
438
|
+
tx
|
|
439
|
+
}
|
|
440
|
+
withdrawnEvents(
|
|
441
|
+
first: $first
|
|
442
|
+
orderBy: timestamp
|
|
443
|
+
orderDirection: desc
|
|
444
|
+
where: {slot: $slotId}
|
|
445
|
+
) {
|
|
446
|
+
id
|
|
447
|
+
occupant
|
|
448
|
+
amount
|
|
449
|
+
timestamp
|
|
450
|
+
tx
|
|
451
|
+
}
|
|
452
|
+
taxCollectedEvents(
|
|
453
|
+
first: $first
|
|
454
|
+
orderBy: timestamp
|
|
455
|
+
orderDirection: desc
|
|
456
|
+
where: {slot: $slotId}
|
|
457
|
+
) {
|
|
458
|
+
id
|
|
459
|
+
recipient
|
|
460
|
+
amount
|
|
461
|
+
timestamp
|
|
462
|
+
tx
|
|
463
|
+
}
|
|
464
|
+
taxUpdateProposedEvents(
|
|
465
|
+
first: $first
|
|
466
|
+
orderBy: timestamp
|
|
467
|
+
orderDirection: desc
|
|
468
|
+
where: {slot: $slotId}
|
|
469
|
+
) {
|
|
470
|
+
id
|
|
471
|
+
newPercentage
|
|
472
|
+
timestamp
|
|
473
|
+
tx
|
|
474
|
+
}
|
|
475
|
+
moduleUpdateProposedEvents(
|
|
476
|
+
first: $first
|
|
477
|
+
orderBy: timestamp
|
|
478
|
+
orderDirection: desc
|
|
479
|
+
where: {slot: $slotId}
|
|
480
|
+
) {
|
|
481
|
+
id
|
|
482
|
+
newModule
|
|
483
|
+
timestamp
|
|
484
|
+
tx
|
|
485
|
+
}
|
|
486
|
+
pendingUpdateCancelledEvents(
|
|
487
|
+
first: $first
|
|
488
|
+
orderBy: timestamp
|
|
489
|
+
orderDirection: desc
|
|
490
|
+
where: {slot: $slotId}
|
|
491
|
+
) {
|
|
492
|
+
id
|
|
493
|
+
timestamp
|
|
494
|
+
tx
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
`;
|
|
498
|
+
var GetFactoryDocument = gql`
|
|
499
|
+
query GetFactory {
|
|
500
|
+
factories(first: 1) {
|
|
501
|
+
id
|
|
502
|
+
slotCount
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
`;
|
|
506
|
+
var GetModulesDocument = gql`
|
|
507
|
+
query GetModules($first: Int!) {
|
|
508
|
+
modules(first: $first) {
|
|
509
|
+
id
|
|
510
|
+
verified
|
|
511
|
+
name
|
|
512
|
+
version
|
|
186
513
|
}
|
|
187
514
|
}
|
|
188
515
|
`;
|
|
189
516
|
var GetSlotsDocument = gql`
|
|
190
|
-
query GetSlots($first: Int
|
|
517
|
+
query GetSlots($first: Int!, $skip: Int, $orderBy: Slot_orderBy, $orderDirection: OrderDirection, $where: Slot_filter, $block: Block_height) {
|
|
191
518
|
slots(
|
|
192
519
|
first: $first
|
|
193
520
|
skip: $skip
|
|
194
521
|
orderBy: $orderBy
|
|
195
522
|
orderDirection: $orderDirection
|
|
196
523
|
where: $where
|
|
524
|
+
block: $block
|
|
197
525
|
) {
|
|
198
|
-
|
|
199
|
-
land {
|
|
200
|
-
id
|
|
201
|
-
owner
|
|
202
|
-
}
|
|
203
|
-
slotId
|
|
204
|
-
occupant
|
|
205
|
-
currency
|
|
206
|
-
basePrice
|
|
207
|
-
price
|
|
208
|
-
taxPercentage
|
|
209
|
-
maxTaxPercentage
|
|
210
|
-
minTaxUpdatePeriod
|
|
211
|
-
module
|
|
212
|
-
active
|
|
213
|
-
createdAt
|
|
214
|
-
updatedAt
|
|
526
|
+
...SlotFields
|
|
215
527
|
}
|
|
216
528
|
}
|
|
217
|
-
`;
|
|
529
|
+
${SlotFieldsFragmentDoc}`;
|
|
218
530
|
var GetSlotDocument = gql`
|
|
219
|
-
query GetSlot($id: ID
|
|
220
|
-
slot(id: $id) {
|
|
221
|
-
|
|
222
|
-
land {
|
|
223
|
-
id
|
|
224
|
-
owner
|
|
225
|
-
}
|
|
226
|
-
slotId
|
|
227
|
-
occupant
|
|
228
|
-
currency
|
|
229
|
-
basePrice
|
|
230
|
-
price
|
|
231
|
-
taxPercentage
|
|
232
|
-
maxTaxPercentage
|
|
233
|
-
minTaxUpdatePeriod
|
|
234
|
-
module
|
|
235
|
-
active
|
|
236
|
-
createdAt
|
|
237
|
-
updatedAt
|
|
238
|
-
priceHistory(orderBy: timestamp, orderDirection: desc, first: 10) {
|
|
239
|
-
id
|
|
240
|
-
oldPrice
|
|
241
|
-
newPrice
|
|
242
|
-
timestamp
|
|
243
|
-
tx
|
|
244
|
-
}
|
|
245
|
-
taxUpdates(orderBy: timestamp, orderDirection: desc, first: 10) {
|
|
246
|
-
id
|
|
247
|
-
kind
|
|
248
|
-
oldPercentage
|
|
249
|
-
newPercentage
|
|
250
|
-
confirmableAt
|
|
251
|
-
timestamp
|
|
252
|
-
tx
|
|
253
|
-
}
|
|
531
|
+
query GetSlot($id: ID!, $block: Block_height) {
|
|
532
|
+
slot(id: $id, block: $block) {
|
|
533
|
+
...SlotFields
|
|
254
534
|
}
|
|
255
535
|
}
|
|
256
|
-
`;
|
|
257
|
-
var
|
|
258
|
-
query
|
|
259
|
-
slots(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
active
|
|
536
|
+
${SlotFieldsFragmentDoc}`;
|
|
537
|
+
var GetSlotsByRecipientDocument = gql`
|
|
538
|
+
query GetSlotsByRecipient($recipient: Bytes!, $first: Int!, $skip: Int, $orderBy: Slot_orderBy, $orderDirection: OrderDirection, $block: Block_height) {
|
|
539
|
+
slots(
|
|
540
|
+
first: $first
|
|
541
|
+
skip: $skip
|
|
542
|
+
orderBy: $orderBy
|
|
543
|
+
orderDirection: $orderDirection
|
|
544
|
+
where: {recipient: $recipient}
|
|
545
|
+
block: $block
|
|
546
|
+
) {
|
|
547
|
+
...SlotFields
|
|
269
548
|
}
|
|
270
549
|
}
|
|
271
|
-
`;
|
|
272
|
-
var
|
|
273
|
-
query
|
|
550
|
+
${SlotFieldsFragmentDoc}`;
|
|
551
|
+
var GetSlotsByOccupantDocument = gql`
|
|
552
|
+
query GetSlotsByOccupant($occupant: Bytes!, $first: Int!, $skip: Int, $orderBy: Slot_orderBy, $orderDirection: OrderDirection, $block: Block_height) {
|
|
274
553
|
slots(
|
|
275
|
-
where: {occupant: null, active: true}
|
|
276
554
|
first: $first
|
|
277
555
|
skip: $skip
|
|
278
|
-
orderBy:
|
|
279
|
-
orderDirection:
|
|
556
|
+
orderBy: $orderBy
|
|
557
|
+
orderDirection: $orderDirection
|
|
558
|
+
where: {occupant: $occupant}
|
|
559
|
+
block: $block
|
|
280
560
|
) {
|
|
281
|
-
|
|
282
|
-
land {
|
|
283
|
-
id
|
|
284
|
-
owner
|
|
285
|
-
}
|
|
286
|
-
slotId
|
|
287
|
-
currency
|
|
288
|
-
price
|
|
289
|
-
taxPercentage
|
|
561
|
+
...SlotFields
|
|
290
562
|
}
|
|
291
563
|
}
|
|
292
|
-
`;
|
|
564
|
+
${SlotFieldsFragmentDoc}`;
|
|
293
565
|
var defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
294
566
|
function getSdk(client, withWrapper = defaultWrapper) {
|
|
295
567
|
return {
|
|
296
|
-
|
|
297
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document:
|
|
568
|
+
GetAccount(variables, requestHeaders, signal) {
|
|
569
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAccountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAccount", "query", variables);
|
|
570
|
+
},
|
|
571
|
+
GetAccounts(variables, requestHeaders, signal) {
|
|
572
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAccountsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAccounts", "query", variables);
|
|
573
|
+
},
|
|
574
|
+
GetRecentEvents(variables, requestHeaders, signal) {
|
|
575
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetRecentEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetRecentEvents", "query", variables);
|
|
298
576
|
},
|
|
299
|
-
|
|
300
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document:
|
|
577
|
+
GetBoughtEvents(variables, requestHeaders, signal) {
|
|
578
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBoughtEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetBoughtEvents", "query", variables);
|
|
301
579
|
},
|
|
302
|
-
|
|
303
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document:
|
|
580
|
+
GetReleasedEvents(variables, requestHeaders, signal) {
|
|
581
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetReleasedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetReleasedEvents", "query", variables);
|
|
304
582
|
},
|
|
305
|
-
|
|
306
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document:
|
|
583
|
+
GetLiquidatedEvents(variables, requestHeaders, signal) {
|
|
584
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetLiquidatedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetLiquidatedEvents", "query", variables);
|
|
307
585
|
},
|
|
308
|
-
|
|
309
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document:
|
|
586
|
+
GetSettledEvents(variables, requestHeaders, signal) {
|
|
587
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSettledEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSettledEvents", "query", variables);
|
|
310
588
|
},
|
|
311
|
-
|
|
312
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document:
|
|
589
|
+
GetTaxCollectedEvents(variables, requestHeaders, signal) {
|
|
590
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetTaxCollectedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetTaxCollectedEvents", "query", variables);
|
|
313
591
|
},
|
|
314
|
-
|
|
315
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document:
|
|
592
|
+
GetDepositedEvents(variables, requestHeaders, signal) {
|
|
593
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetDepositedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetDepositedEvents", "query", variables);
|
|
316
594
|
},
|
|
317
|
-
|
|
318
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document:
|
|
595
|
+
GetWithdrawnEvents(variables, requestHeaders, signal) {
|
|
596
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetWithdrawnEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetWithdrawnEvents", "query", variables);
|
|
319
597
|
},
|
|
320
|
-
|
|
321
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document:
|
|
598
|
+
GetPriceUpdatedEvents(variables, requestHeaders, signal) {
|
|
599
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetPriceUpdatedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetPriceUpdatedEvents", "query", variables);
|
|
322
600
|
},
|
|
323
|
-
|
|
324
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document:
|
|
601
|
+
GetSlotActivity(variables, requestHeaders, signal) {
|
|
602
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotActivityDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlotActivity", "query", variables);
|
|
603
|
+
},
|
|
604
|
+
GetFactory(variables, requestHeaders, signal) {
|
|
605
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetFactoryDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetFactory", "query", variables);
|
|
606
|
+
},
|
|
607
|
+
GetModules(variables, requestHeaders, signal) {
|
|
608
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetModulesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetModules", "query", variables);
|
|
325
609
|
},
|
|
326
610
|
GetSlots(variables, requestHeaders, signal) {
|
|
327
611
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlots", "query", variables);
|
|
@@ -329,16 +613,26 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
329
613
|
GetSlot(variables, requestHeaders, signal) {
|
|
330
614
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlot", "query", variables);
|
|
331
615
|
},
|
|
616
|
+
GetSlotsByRecipient(variables, requestHeaders, signal) {
|
|
617
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotsByRecipientDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlotsByRecipient", "query", variables);
|
|
618
|
+
},
|
|
332
619
|
GetSlotsByOccupant(variables, requestHeaders, signal) {
|
|
333
620
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotsByOccupantDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlotsByOccupant", "query", variables);
|
|
334
|
-
},
|
|
335
|
-
GetAvailableSlots(variables, requestHeaders, signal) {
|
|
336
|
-
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAvailableSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAvailableSlots", "query", variables);
|
|
337
621
|
}
|
|
338
622
|
};
|
|
339
623
|
}
|
|
340
|
-
|
|
341
|
-
|
|
624
|
+
var META_QUERY = gql$1`
|
|
625
|
+
query GetMeta {
|
|
626
|
+
_meta {
|
|
627
|
+
block {
|
|
628
|
+
number
|
|
629
|
+
hash
|
|
630
|
+
timestamp
|
|
631
|
+
}
|
|
632
|
+
hasIndexingErrors
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
`;
|
|
342
636
|
var SlotsChain = /* @__PURE__ */ ((SlotsChain2) => {
|
|
343
637
|
SlotsChain2[SlotsChain2["BASE_SEPOLIA"] = 84532] = "BASE_SEPOLIA";
|
|
344
638
|
SlotsChain2[SlotsChain2["ARBITRUM"] = 42161] = "ARBITRUM";
|
|
@@ -349,72 +643,46 @@ var SUBGRAPH_URLS = {
|
|
|
349
643
|
[42161 /* ARBITRUM */]: "https://api.studio.thegraph.com/query/958/0-x-slots-arb/version/latest"
|
|
350
644
|
};
|
|
351
645
|
var SlotsClient = class {
|
|
352
|
-
/**
|
|
353
|
-
* Create a new SlotsClient instance
|
|
354
|
-
*
|
|
355
|
-
* @param config - Client configuration
|
|
356
|
-
*
|
|
357
|
-
* @example
|
|
358
|
-
* ```typescript
|
|
359
|
-
* import { SlotsClient, SlotsChain } from '@0xslots/sdk';
|
|
360
|
-
*
|
|
361
|
-
* const client = new SlotsClient({
|
|
362
|
-
* chainId: SlotsChain.BASE_SEPOLIA,
|
|
363
|
-
* });
|
|
364
|
-
*
|
|
365
|
-
* const hub = await client.getHub({ id: '0x...' });
|
|
366
|
-
* ```
|
|
367
|
-
*/
|
|
368
646
|
constructor(config) {
|
|
369
647
|
this.chainId = config.chainId;
|
|
648
|
+
this._publicClient = config.publicClient;
|
|
649
|
+
this.walletClient = config.walletClient;
|
|
650
|
+
this._factory = config.factoryAddress ?? getSlotsHubAddress(config.chainId);
|
|
370
651
|
const url = config.subgraphUrl || SUBGRAPH_URLS[config.chainId];
|
|
371
|
-
if (!url) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
this.client = new GraphQLClient(url, {
|
|
375
|
-
headers: config.headers
|
|
376
|
-
});
|
|
377
|
-
this.sdk = getSdk(this.client);
|
|
652
|
+
if (!url) throw new Error(`No subgraph URL for chain ${config.chainId}`);
|
|
653
|
+
this.gqlClient = new GraphQLClient(url, { headers: config.headers });
|
|
654
|
+
this.sdk = getSdk(this.gqlClient);
|
|
378
655
|
}
|
|
379
|
-
|
|
380
|
-
* Get the current chain ID
|
|
381
|
-
*/
|
|
656
|
+
// ─── Accessors ──────────────────────────────────────────────────────────────
|
|
382
657
|
getChainId() {
|
|
383
658
|
return this.chainId;
|
|
384
659
|
}
|
|
385
|
-
/**
|
|
386
|
-
* Get the underlying GraphQL client
|
|
387
|
-
*/
|
|
388
660
|
getClient() {
|
|
389
|
-
return this.
|
|
661
|
+
return this.gqlClient;
|
|
390
662
|
}
|
|
391
|
-
/**
|
|
392
|
-
* Get the generated SDK with all typed query methods
|
|
393
|
-
*/
|
|
394
663
|
getSdk() {
|
|
395
664
|
return this.sdk;
|
|
396
665
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
return this.sdk.GetHub(...args);
|
|
401
|
-
}
|
|
402
|
-
getAllowedModules(...args) {
|
|
403
|
-
return this.sdk.GetAllowedModules(...args);
|
|
666
|
+
get publicClient() {
|
|
667
|
+
if (!this._publicClient) throw new Error("No publicClient provided");
|
|
668
|
+
return this._publicClient;
|
|
404
669
|
}
|
|
405
|
-
|
|
406
|
-
|
|
670
|
+
get factory() {
|
|
671
|
+
if (!this._factory) throw new Error("No factoryAddress provided");
|
|
672
|
+
return this._factory;
|
|
407
673
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
return this.
|
|
674
|
+
get wallet() {
|
|
675
|
+
if (!this.walletClient) throw new Error("No walletClient provided");
|
|
676
|
+
return this.walletClient;
|
|
411
677
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
return this.sdk.GetLandsByOwner(...args);
|
|
678
|
+
get account() {
|
|
679
|
+
const account = this.wallet.account;
|
|
680
|
+
if (!account) throw new Error("WalletClient must have an account");
|
|
681
|
+
return account.address;
|
|
417
682
|
}
|
|
683
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
684
|
+
// READ — Subgraph Queries
|
|
685
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
418
686
|
// Slot queries
|
|
419
687
|
getSlots(...args) {
|
|
420
688
|
return this.sdk.GetSlots(...args);
|
|
@@ -422,30 +690,338 @@ var SlotsClient = class {
|
|
|
422
690
|
getSlot(...args) {
|
|
423
691
|
return this.sdk.GetSlot(...args);
|
|
424
692
|
}
|
|
693
|
+
getSlotsByRecipient(...args) {
|
|
694
|
+
return this.sdk.GetSlotsByRecipient(...args);
|
|
695
|
+
}
|
|
425
696
|
getSlotsByOccupant(...args) {
|
|
426
697
|
return this.sdk.GetSlotsByOccupant(...args);
|
|
427
698
|
}
|
|
428
|
-
|
|
429
|
-
|
|
699
|
+
// Factory queries
|
|
700
|
+
getFactory() {
|
|
701
|
+
return this.sdk.GetFactory();
|
|
702
|
+
}
|
|
703
|
+
getModules(...args) {
|
|
704
|
+
return this.sdk.GetModules(...args);
|
|
430
705
|
}
|
|
431
706
|
// Event queries
|
|
432
|
-
|
|
433
|
-
return this.sdk.
|
|
707
|
+
getBoughtEvents(...args) {
|
|
708
|
+
return this.sdk.GetBoughtEvents(...args);
|
|
709
|
+
}
|
|
710
|
+
getSettledEvents(...args) {
|
|
711
|
+
return this.sdk.GetSettledEvents(...args);
|
|
712
|
+
}
|
|
713
|
+
getTaxCollectedEvents(...args) {
|
|
714
|
+
return this.sdk.GetTaxCollectedEvents(...args);
|
|
715
|
+
}
|
|
716
|
+
getSlotActivity(...args) {
|
|
717
|
+
return this.sdk.GetSlotActivity(...args);
|
|
718
|
+
}
|
|
719
|
+
getRecentEvents(...args) {
|
|
720
|
+
return this.sdk.GetRecentEvents(...args);
|
|
721
|
+
}
|
|
722
|
+
// Account queries
|
|
723
|
+
getAccount(...args) {
|
|
724
|
+
return this.sdk.GetAccount(...args);
|
|
725
|
+
}
|
|
726
|
+
getAccounts(...args) {
|
|
727
|
+
return this.sdk.GetAccounts(...args);
|
|
728
|
+
}
|
|
729
|
+
// Individual event queries
|
|
730
|
+
getReleasedEvents(...args) {
|
|
731
|
+
return this.sdk.GetReleasedEvents(...args);
|
|
732
|
+
}
|
|
733
|
+
getLiquidatedEvents(...args) {
|
|
734
|
+
return this.sdk.GetLiquidatedEvents(...args);
|
|
735
|
+
}
|
|
736
|
+
getDepositedEvents(...args) {
|
|
737
|
+
return this.sdk.GetDepositedEvents(...args);
|
|
738
|
+
}
|
|
739
|
+
getWithdrawnEvents(...args) {
|
|
740
|
+
return this.sdk.GetWithdrawnEvents(...args);
|
|
434
741
|
}
|
|
435
|
-
|
|
436
|
-
return this.sdk.
|
|
742
|
+
getPriceUpdatedEvents(...args) {
|
|
743
|
+
return this.sdk.GetPriceUpdatedEvents(...args);
|
|
437
744
|
}
|
|
438
|
-
|
|
439
|
-
|
|
745
|
+
// Meta
|
|
746
|
+
getMeta() {
|
|
747
|
+
return this.gqlClient.request(META_QUERY);
|
|
440
748
|
}
|
|
441
|
-
|
|
442
|
-
|
|
749
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
750
|
+
// READ — On-chain (RPC)
|
|
751
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
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
|
+
});
|
|
759
|
+
}
|
|
760
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
761
|
+
// WRITE — Factory Functions
|
|
762
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
763
|
+
async createSlot(params) {
|
|
764
|
+
return this.wallet.writeContract({
|
|
765
|
+
address: this.factory,
|
|
766
|
+
abi: slotFactoryAbi,
|
|
767
|
+
functionName: "createSlot",
|
|
768
|
+
args: [params.recipient, params.currency, params.config, params.initParams],
|
|
769
|
+
account: this.wallet.account,
|
|
770
|
+
chain: this.wallet.chain
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
async createSlots(params) {
|
|
774
|
+
return this.wallet.writeContract({
|
|
775
|
+
address: this.factory,
|
|
776
|
+
abi: slotFactoryAbi,
|
|
777
|
+
functionName: "createSlots",
|
|
778
|
+
args: [params.recipient, params.currency, params.config, params.initParams, params.count],
|
|
779
|
+
account: this.wallet.account,
|
|
780
|
+
chain: this.wallet.chain
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
784
|
+
// WRITE — Slot Functions
|
|
785
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
786
|
+
/** Buy a slot (or force buy an occupied one). Handles ERC-20 approval automatically. */
|
|
787
|
+
async buy(params) {
|
|
788
|
+
return this.withAllowance(params.slot, params.depositAmount, {
|
|
789
|
+
to: params.slot,
|
|
790
|
+
abi: slotAbi,
|
|
791
|
+
functionName: "buy",
|
|
792
|
+
args: [params.depositAmount, params.selfAssessedPrice]
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
/** Self-assess a new price for an occupied slot (occupant only). */
|
|
796
|
+
async selfAssess(slot, newPrice) {
|
|
797
|
+
return this.wallet.writeContract({
|
|
798
|
+
address: slot,
|
|
799
|
+
abi: slotAbi,
|
|
800
|
+
functionName: "selfAssess",
|
|
801
|
+
args: [newPrice],
|
|
802
|
+
account: this.wallet.account,
|
|
803
|
+
chain: this.wallet.chain
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
/** Top up deposit on a slot (occupant only). Handles ERC-20 approval automatically. */
|
|
807
|
+
async topUp(slot, amount) {
|
|
808
|
+
return this.withAllowance(slot, amount, {
|
|
809
|
+
to: slot,
|
|
810
|
+
abi: slotAbi,
|
|
811
|
+
functionName: "topUp",
|
|
812
|
+
args: [amount]
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
/** Withdraw from deposit (occupant only). Cannot go below minimum deposit. */
|
|
816
|
+
async withdraw(slot, amount) {
|
|
817
|
+
return this.wallet.writeContract({
|
|
818
|
+
address: slot,
|
|
819
|
+
abi: slotAbi,
|
|
820
|
+
functionName: "withdraw",
|
|
821
|
+
args: [amount],
|
|
822
|
+
account: this.wallet.account,
|
|
823
|
+
chain: this.wallet.chain
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
/** Release a slot (occupant only). Returns remaining deposit. */
|
|
827
|
+
async release(slot) {
|
|
828
|
+
return this.wallet.writeContract({
|
|
829
|
+
address: slot,
|
|
830
|
+
abi: slotAbi,
|
|
831
|
+
functionName: "release",
|
|
832
|
+
account: this.wallet.account,
|
|
833
|
+
chain: this.wallet.chain
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
/** Collect accumulated tax (permissionless). */
|
|
837
|
+
async collect(slot) {
|
|
838
|
+
return this.wallet.writeContract({
|
|
839
|
+
address: slot,
|
|
840
|
+
abi: slotAbi,
|
|
841
|
+
functionName: "collect",
|
|
842
|
+
account: this.wallet.account,
|
|
843
|
+
chain: this.wallet.chain
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
/** Liquidate an insolvent slot (permissionless). Caller receives bounty. */
|
|
847
|
+
async liquidate(slot) {
|
|
848
|
+
return this.wallet.writeContract({
|
|
849
|
+
address: slot,
|
|
850
|
+
abi: slotAbi,
|
|
851
|
+
functionName: "liquidate",
|
|
852
|
+
account: this.wallet.account,
|
|
853
|
+
chain: this.wallet.chain
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
857
|
+
// WRITE — Manager Functions
|
|
858
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
859
|
+
/** Propose a tax rate update (manager only, slot must have mutableTax). */
|
|
860
|
+
async proposeTaxUpdate(slot, newPct) {
|
|
861
|
+
return this.wallet.writeContract({
|
|
862
|
+
address: slot,
|
|
863
|
+
abi: slotAbi,
|
|
864
|
+
functionName: "proposeTaxUpdate",
|
|
865
|
+
args: [newPct],
|
|
866
|
+
account: this.wallet.account,
|
|
867
|
+
chain: this.wallet.chain
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
/** Propose a module update (manager only, slot must have mutableModule). */
|
|
871
|
+
async proposeModuleUpdate(slot, newModule) {
|
|
872
|
+
return this.wallet.writeContract({
|
|
873
|
+
address: slot,
|
|
874
|
+
abi: slotAbi,
|
|
875
|
+
functionName: "proposeModuleUpdate",
|
|
876
|
+
args: [newModule],
|
|
877
|
+
account: this.wallet.account,
|
|
878
|
+
chain: this.wallet.chain
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
/** Cancel pending updates (manager only). */
|
|
882
|
+
async cancelPendingUpdates(slot) {
|
|
883
|
+
return this.wallet.writeContract({
|
|
884
|
+
address: slot,
|
|
885
|
+
abi: slotAbi,
|
|
886
|
+
functionName: "cancelPendingUpdates",
|
|
887
|
+
account: this.wallet.account,
|
|
888
|
+
chain: this.wallet.chain
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
/** Set liquidation bounty bps (manager only). */
|
|
892
|
+
async setLiquidationBounty(slot, newBps) {
|
|
893
|
+
return this.wallet.writeContract({
|
|
894
|
+
address: slot,
|
|
895
|
+
abi: slotAbi,
|
|
896
|
+
functionName: "setLiquidationBounty",
|
|
897
|
+
args: [newBps],
|
|
898
|
+
account: this.wallet.account,
|
|
899
|
+
chain: this.wallet.chain
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
903
|
+
// WRITE — Multicall
|
|
904
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
905
|
+
/** Batch multiple slot calls into one transaction via multicall. */
|
|
906
|
+
async multicall(slot, calls) {
|
|
907
|
+
const data = calls.map(
|
|
908
|
+
(call) => encodeFunctionData({
|
|
909
|
+
abi: slotAbi,
|
|
910
|
+
functionName: call.functionName,
|
|
911
|
+
args: call.args
|
|
912
|
+
})
|
|
913
|
+
);
|
|
914
|
+
return this.wallet.writeContract({
|
|
915
|
+
address: slot,
|
|
916
|
+
abi: slotAbi,
|
|
917
|
+
functionName: "multicall",
|
|
918
|
+
args: [data],
|
|
919
|
+
account: this.wallet.account,
|
|
920
|
+
chain: this.wallet.chain
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
// ─── Internals ──────────────────────────────────────────────────────────────
|
|
924
|
+
/** Check if wallet supports atomic batch calls (EIP-5792). */
|
|
925
|
+
async supportsAtomicBatch() {
|
|
926
|
+
if (this._atomicSupport !== void 0) return this._atomicSupport;
|
|
927
|
+
try {
|
|
928
|
+
const capabilities = await this.wallet.getCapabilities?.();
|
|
929
|
+
if (!capabilities) {
|
|
930
|
+
this._atomicSupport = false;
|
|
931
|
+
return false;
|
|
932
|
+
}
|
|
933
|
+
const chainId = this.wallet.chain.id;
|
|
934
|
+
const chainCaps = capabilities[chainId] || capabilities[`0x${chainId.toString(16)}`];
|
|
935
|
+
const atomic = chainCaps?.atomicBatch ?? chainCaps?.atomic;
|
|
936
|
+
const status = atomic && typeof atomic === "object" && "status" in atomic ? atomic.status : void 0;
|
|
937
|
+
this._atomicSupport = status === "supported" || status === "ready";
|
|
938
|
+
} catch {
|
|
939
|
+
this._atomicSupport = false;
|
|
940
|
+
}
|
|
941
|
+
return this._atomicSupport;
|
|
942
|
+
}
|
|
943
|
+
/** Poll EIP-5792 getCallsStatus until the batch settles, then return a tx hash. */
|
|
944
|
+
async pollBatchReceipt(id) {
|
|
945
|
+
const MAX_ATTEMPTS = 60;
|
|
946
|
+
const INTERVAL = 1500;
|
|
947
|
+
for (let i = 0; i < MAX_ATTEMPTS; i++) {
|
|
948
|
+
const result = await this.wallet.getCallsStatus({ id });
|
|
949
|
+
if (result.status === "success") {
|
|
950
|
+
const receipts = result.receipts ?? [];
|
|
951
|
+
return receipts[receipts.length - 1]?.transactionHash ?? id;
|
|
952
|
+
}
|
|
953
|
+
if (result.status === "failure") {
|
|
954
|
+
throw new Error("Batch transaction reverted");
|
|
955
|
+
}
|
|
956
|
+
await new Promise((r) => setTimeout(r, INTERVAL));
|
|
957
|
+
}
|
|
958
|
+
throw new Error("Batch transaction timed out");
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Execute a contract call that needs ERC-20 allowance.
|
|
962
|
+
* If wallet supports atomic batch (EIP-5792): sends approve + action as one atomic call.
|
|
963
|
+
* Otherwise: chains approve tx (if needed) then action tx.
|
|
964
|
+
*/
|
|
965
|
+
async withAllowance(spender, amount, call) {
|
|
966
|
+
const currency = await this.publicClient.readContract({
|
|
967
|
+
address: spender,
|
|
968
|
+
abi: slotAbi,
|
|
969
|
+
functionName: "currency"
|
|
970
|
+
});
|
|
971
|
+
const allowance = await this.publicClient.readContract({
|
|
972
|
+
address: currency,
|
|
973
|
+
abi: erc20Abi,
|
|
974
|
+
functionName: "allowance",
|
|
975
|
+
args: [this.account, spender]
|
|
976
|
+
});
|
|
977
|
+
const needsApproval = allowance < amount;
|
|
978
|
+
if (needsApproval && await this.supportsAtomicBatch()) {
|
|
979
|
+
const approveData = encodeFunctionData({
|
|
980
|
+
abi: erc20Abi,
|
|
981
|
+
functionName: "approve",
|
|
982
|
+
args: [spender, amount]
|
|
983
|
+
});
|
|
984
|
+
const actionData = encodeFunctionData({
|
|
985
|
+
abi: call.abi,
|
|
986
|
+
functionName: call.functionName,
|
|
987
|
+
args: call.args
|
|
988
|
+
});
|
|
989
|
+
const id = await this.wallet.sendCalls({
|
|
990
|
+
account: this.wallet.account,
|
|
991
|
+
chain: this.wallet.chain,
|
|
992
|
+
calls: [
|
|
993
|
+
{ to: currency, data: approveData },
|
|
994
|
+
{ to: call.to, data: actionData }
|
|
995
|
+
]
|
|
996
|
+
});
|
|
997
|
+
const txHash = await this.pollBatchReceipt(id);
|
|
998
|
+
return txHash;
|
|
999
|
+
}
|
|
1000
|
+
if (needsApproval) {
|
|
1001
|
+
const hash = await this.wallet.writeContract({
|
|
1002
|
+
address: currency,
|
|
1003
|
+
abi: erc20Abi,
|
|
1004
|
+
functionName: "approve",
|
|
1005
|
+
args: [spender, amount],
|
|
1006
|
+
account: this.wallet.account,
|
|
1007
|
+
chain: this.wallet.chain
|
|
1008
|
+
});
|
|
1009
|
+
await this.publicClient.waitForTransactionReceipt({ hash });
|
|
1010
|
+
}
|
|
1011
|
+
return this.wallet.writeContract({
|
|
1012
|
+
address: call.to,
|
|
1013
|
+
abi: call.abi,
|
|
1014
|
+
functionName: call.functionName,
|
|
1015
|
+
args: call.args,
|
|
1016
|
+
account: this.wallet.account,
|
|
1017
|
+
chain: this.wallet.chain
|
|
1018
|
+
});
|
|
443
1019
|
}
|
|
444
1020
|
};
|
|
445
1021
|
function createSlotsClient(config) {
|
|
446
1022
|
return new SlotsClient(config);
|
|
447
1023
|
}
|
|
448
1024
|
|
|
449
|
-
export {
|
|
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 };
|
|
450
1026
|
//# sourceMappingURL=index.js.map
|
|
451
1027
|
//# sourceMappingURL=index.js.map
|