@slvr-labs/sdk 0.1.0 → 0.1.2

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.
Files changed (83) hide show
  1. package/README.md +42 -0
  2. package/dist/index.d.mts +2117 -0
  3. package/dist/index.d.ts +1903 -34
  4. package/dist/index.js +3091 -427
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +3035 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +19 -11
  9. package/skills/slvr-bot/SKILL.md +9 -8
  10. package/skills/slvr-bot/references/api.md +8 -0
  11. package/dist/connect.d.ts +0 -47
  12. package/dist/connect.d.ts.map +0 -1
  13. package/dist/connect.js +0 -56
  14. package/dist/connect.js.map +0 -1
  15. package/dist/contracts/autoCommit.d.ts +0 -151
  16. package/dist/contracts/autoCommit.d.ts.map +0 -1
  17. package/dist/contracts/autoCommit.js +0 -426
  18. package/dist/contracts/autoCommit.js.map +0 -1
  19. package/dist/contracts/hub.d.ts +0 -50
  20. package/dist/contracts/hub.d.ts.map +0 -1
  21. package/dist/contracts/hub.js +0 -118
  22. package/dist/contracts/hub.js.map +0 -1
  23. package/dist/contracts/index.d.ts +0 -8
  24. package/dist/contracts/index.d.ts.map +0 -1
  25. package/dist/contracts/index.js +0 -18
  26. package/dist/contracts/index.js.map +0 -1
  27. package/dist/contracts/jackpot.d.ts +0 -21
  28. package/dist/contracts/jackpot.d.ts.map +0 -1
  29. package/dist/contracts/jackpot.js +0 -44
  30. package/dist/contracts/jackpot.js.map +0 -1
  31. package/dist/contracts/lottery.d.ts +0 -256
  32. package/dist/contracts/lottery.d.ts.map +0 -1
  33. package/dist/contracts/lottery.js +0 -767
  34. package/dist/contracts/lottery.js.map +0 -1
  35. package/dist/contracts/registry.d.ts +0 -53
  36. package/dist/contracts/registry.d.ts.map +0 -1
  37. package/dist/contracts/registry.js +0 -143
  38. package/dist/contracts/registry.js.map +0 -1
  39. package/dist/contracts/staking.d.ts +0 -101
  40. package/dist/contracts/staking.d.ts.map +0 -1
  41. package/dist/contracts/staking.js +0 -306
  42. package/dist/contracts/staking.js.map +0 -1
  43. package/dist/contracts/token.d.ts +0 -95
  44. package/dist/contracts/token.d.ts.map +0 -1
  45. package/dist/contracts/token.js +0 -273
  46. package/dist/contracts/token.js.map +0 -1
  47. package/dist/deployments.d.ts +0 -117
  48. package/dist/deployments.d.ts.map +0 -1
  49. package/dist/deployments.js +0 -74
  50. package/dist/deployments.js.map +0 -1
  51. package/dist/errors.d.ts +0 -39
  52. package/dist/errors.d.ts.map +0 -1
  53. package/dist/errors.js +0 -67
  54. package/dist/errors.js.map +0 -1
  55. package/dist/ev.d.ts +0 -123
  56. package/dist/ev.d.ts.map +0 -1
  57. package/dist/ev.js +0 -111
  58. package/dist/ev.js.map +0 -1
  59. package/dist/events.d.ts +0 -418
  60. package/dist/events.d.ts.map +0 -1
  61. package/dist/events.js +0 -87
  62. package/dist/events.js.map +0 -1
  63. package/dist/index.d.ts.map +0 -1
  64. package/dist/oracle.d.ts +0 -48
  65. package/dist/oracle.d.ts.map +0 -1
  66. package/dist/oracle.js +0 -77
  67. package/dist/oracle.js.map +0 -1
  68. package/dist/price.d.ts +0 -52
  69. package/dist/price.d.ts.map +0 -1
  70. package/dist/price.js +0 -78
  71. package/dist/price.js.map +0 -1
  72. package/dist/transaction.d.ts +0 -54
  73. package/dist/transaction.d.ts.map +0 -1
  74. package/dist/transaction.js +0 -105
  75. package/dist/transaction.js.map +0 -1
  76. package/dist/types.d.ts +0 -162
  77. package/dist/types.d.ts.map +0 -1
  78. package/dist/types.js +0 -23
  79. package/dist/types.js.map +0 -1
  80. package/dist/utils.d.ts +0 -58
  81. package/dist/utils.d.ts.map +0 -1
  82. package/dist/utils.js +0 -110
  83. package/dist/utils.js.map +0 -1
package/dist/events.d.ts DELETED
@@ -1,418 +0,0 @@
1
- import { Address, Log } from 'viem';
2
- /**
3
- * Event ABIs for Slvr contracts
4
- */
5
- export declare const SlvrGridLotteryEvents: readonly [{
6
- readonly name: "BetPlaced";
7
- readonly type: "event";
8
- readonly inputs: readonly [{
9
- readonly type: "uint256";
10
- readonly name: "roundId";
11
- readonly indexed: true;
12
- }, {
13
- readonly type: "address";
14
- readonly name: "beneficiary";
15
- readonly indexed: true;
16
- }, {
17
- readonly type: "uint256";
18
- readonly name: "total";
19
- }, {
20
- readonly type: "uint8[]";
21
- readonly name: "squares";
22
- }];
23
- }, {
24
- readonly name: "Claimed";
25
- readonly type: "event";
26
- readonly inputs: readonly [{
27
- readonly type: "uint256";
28
- readonly name: "roundId";
29
- readonly indexed: true;
30
- }, {
31
- readonly type: "address";
32
- readonly name: "user";
33
- readonly indexed: true;
34
- }, {
35
- readonly type: "uint256";
36
- readonly name: "nativeOut";
37
- }, {
38
- readonly type: "uint256";
39
- readonly name: "slvrOut";
40
- }, {
41
- readonly type: "uint256";
42
- readonly name: "refinedOut";
43
- }, {
44
- readonly type: "uint256";
45
- readonly name: "refiningFee";
46
- }];
47
- }, {
48
- readonly name: "RoundResolved";
49
- readonly type: "event";
50
- readonly inputs: readonly [{
51
- readonly type: "uint256";
52
- readonly name: "roundId";
53
- readonly indexed: true;
54
- }, {
55
- readonly type: "uint8";
56
- readonly name: "winningSquare";
57
- }, {
58
- readonly type: "bool";
59
- readonly name: "jackpotHit";
60
- }, {
61
- readonly type: "bool";
62
- readonly name: "singleMinerRound";
63
- }, {
64
- readonly type: "address";
65
- readonly name: "singleMinerWinner";
66
- readonly indexed: true;
67
- }, {
68
- readonly type: "uint256";
69
- readonly name: "winnerTotal";
70
- }, {
71
- readonly type: "uint256";
72
- readonly name: "potForWinners";
73
- }, {
74
- readonly type: "uint256";
75
- readonly name: "slvrForWinners";
76
- }, {
77
- readonly type: "uint256";
78
- readonly name: "totalUnclaimedSlvr";
79
- }];
80
- }, {
81
- readonly name: "RandomnessRequested";
82
- readonly type: "event";
83
- readonly inputs: readonly [{
84
- readonly type: "uint256";
85
- readonly name: "roundId";
86
- readonly indexed: true;
87
- }, {
88
- readonly type: "bytes32";
89
- readonly name: "randomnessId";
90
- }];
91
- }];
92
- /**
93
- * Events for the veNFT staker (`SlvrVoteEscrowStaking`). All staking events are
94
- * keyed by the veNFT `tokenId`; there are no raw-ERC20-amount stake events.
95
- */
96
- export declare const SlvrStakingEvents: readonly [{
97
- readonly name: "Staked";
98
- readonly type: "event";
99
- readonly inputs: readonly [{
100
- readonly type: "uint256";
101
- readonly name: "tokenId";
102
- readonly indexed: true;
103
- }, {
104
- readonly type: "address";
105
- readonly name: "user";
106
- readonly indexed: true;
107
- }, {
108
- readonly type: "uint256";
109
- readonly name: "weight";
110
- }];
111
- }, {
112
- readonly name: "Unstaked";
113
- readonly type: "event";
114
- readonly inputs: readonly [{
115
- readonly type: "uint256";
116
- readonly name: "tokenId";
117
- readonly indexed: true;
118
- }, {
119
- readonly type: "address";
120
- readonly name: "user";
121
- readonly indexed: true;
122
- }, {
123
- readonly type: "uint256";
124
- readonly name: "weight";
125
- }];
126
- }, {
127
- readonly name: "RewardClaimed";
128
- readonly type: "event";
129
- readonly inputs: readonly [{
130
- readonly type: "uint256";
131
- readonly name: "tokenId";
132
- readonly indexed: true;
133
- }, {
134
- readonly type: "address";
135
- readonly name: "user";
136
- readonly indexed: true;
137
- }, {
138
- readonly type: "uint256";
139
- readonly name: "amount";
140
- }];
141
- }, {
142
- readonly name: "RewardDistributed";
143
- readonly type: "event";
144
- readonly inputs: readonly [{
145
- readonly type: "uint256";
146
- readonly name: "amount";
147
- }];
148
- }, {
149
- readonly name: "Checkpoint";
150
- readonly type: "event";
151
- readonly inputs: readonly [{
152
- readonly type: "uint256";
153
- readonly name: "tokenId";
154
- readonly indexed: true;
155
- }, {
156
- readonly type: "uint256";
157
- readonly name: "oldWeight";
158
- }, {
159
- readonly type: "uint256";
160
- readonly name: "newWeight";
161
- }];
162
- }, {
163
- readonly name: "RewardsSettledOnBurn";
164
- readonly type: "event";
165
- readonly inputs: readonly [{
166
- readonly type: "uint256";
167
- readonly name: "tokenId";
168
- readonly indexed: true;
169
- }, {
170
- readonly type: "address";
171
- readonly name: "owner";
172
- readonly indexed: true;
173
- }, {
174
- readonly type: "uint256";
175
- readonly name: "amount";
176
- }];
177
- }, {
178
- readonly name: "PendingRewardsClaimed";
179
- readonly type: "event";
180
- readonly inputs: readonly [{
181
- readonly type: "address";
182
- readonly name: "user";
183
- readonly indexed: true;
184
- }, {
185
- readonly type: "uint256";
186
- readonly name: "amount";
187
- }];
188
- }];
189
- export declare const SlvrTokenEvents: readonly [{
190
- readonly name: "Transfer";
191
- readonly type: "event";
192
- readonly inputs: readonly [{
193
- readonly type: "address";
194
- readonly name: "from";
195
- readonly indexed: true;
196
- }, {
197
- readonly type: "address";
198
- readonly name: "to";
199
- readonly indexed: true;
200
- }, {
201
- readonly type: "uint256";
202
- readonly name: "value";
203
- }];
204
- }, {
205
- readonly name: "Approval";
206
- readonly type: "event";
207
- readonly inputs: readonly [{
208
- readonly type: "address";
209
- readonly name: "owner";
210
- readonly indexed: true;
211
- }, {
212
- readonly type: "address";
213
- readonly name: "spender";
214
- readonly indexed: true;
215
- }, {
216
- readonly type: "uint256";
217
- readonly name: "value";
218
- }];
219
- }];
220
- export declare const SlvrAutoCommitEvents: readonly [{
221
- readonly name: "PlanConfigured";
222
- readonly type: "event";
223
- readonly inputs: readonly [{
224
- readonly type: "address";
225
- readonly name: "user";
226
- readonly indexed: true;
227
- }, {
228
- readonly type: "uint256";
229
- readonly name: "nextRoundId";
230
- }, {
231
- readonly type: "uint32";
232
- readonly name: "plays";
233
- }, {
234
- readonly type: "uint256";
235
- readonly name: "amountPerPlay";
236
- }, {
237
- readonly type: "bool";
238
- readonly name: "autoClaim";
239
- }];
240
- }, {
241
- readonly name: "PlanDisabled";
242
- readonly type: "event";
243
- readonly inputs: readonly [{
244
- readonly type: "address";
245
- readonly name: "user";
246
- readonly indexed: true;
247
- }];
248
- }, {
249
- readonly name: "PlanCancelled";
250
- readonly type: "event";
251
- readonly inputs: readonly [{
252
- readonly type: "address";
253
- readonly name: "user";
254
- readonly indexed: true;
255
- }, {
256
- readonly type: "uint256";
257
- readonly name: "refundAmount";
258
- }];
259
- }, {
260
- readonly name: "Deposited";
261
- readonly type: "event";
262
- readonly inputs: readonly [{
263
- readonly type: "address";
264
- readonly name: "user";
265
- readonly indexed: true;
266
- }, {
267
- readonly type: "uint256";
268
- readonly name: "amount";
269
- }];
270
- }, {
271
- readonly name: "Withdrawn";
272
- readonly type: "event";
273
- readonly inputs: readonly [{
274
- readonly type: "address";
275
- readonly name: "user";
276
- readonly indexed: true;
277
- }, {
278
- readonly type: "uint256";
279
- readonly name: "amount";
280
- }, {
281
- readonly type: "address";
282
- readonly name: "to";
283
- }];
284
- }, {
285
- readonly name: "RoundExecuted";
286
- readonly type: "event";
287
- readonly inputs: readonly [{
288
- readonly type: "address";
289
- readonly name: "user";
290
- readonly indexed: true;
291
- }, {
292
- readonly type: "uint256";
293
- readonly name: "roundId";
294
- readonly indexed: true;
295
- }, {
296
- readonly type: "uint32";
297
- readonly name: "playsRemaining";
298
- }];
299
- }, {
300
- readonly name: "Claimed";
301
- readonly type: "event";
302
- readonly inputs: readonly [{
303
- readonly type: "address";
304
- readonly name: "user";
305
- readonly indexed: true;
306
- }, {
307
- readonly type: "uint256";
308
- readonly name: "roundId";
309
- readonly indexed: true;
310
- }, {
311
- readonly type: "uint256";
312
- readonly name: "nativeAmount";
313
- }, {
314
- readonly type: "uint256";
315
- readonly name: "addedToBalance";
316
- }];
317
- }, {
318
- readonly name: "BalanceUpdated";
319
- readonly type: "event";
320
- readonly inputs: readonly [{
321
- readonly type: "address";
322
- readonly name: "user";
323
- readonly indexed: true;
324
- }, {
325
- readonly type: "uint256";
326
- readonly name: "newBalance";
327
- }, {
328
- readonly type: "uint256";
329
- readonly name: "amountAdded";
330
- }];
331
- }, {
332
- readonly name: "ExecutorFeePaid";
333
- readonly type: "event";
334
- readonly inputs: readonly [{
335
- readonly type: "address";
336
- readonly name: "user";
337
- readonly indexed: true;
338
- }, {
339
- readonly type: "address";
340
- readonly name: "executor";
341
- readonly indexed: true;
342
- }, {
343
- readonly type: "uint256";
344
- readonly name: "fee";
345
- }, {
346
- readonly type: "uint256";
347
- readonly name: "gasUsed";
348
- }];
349
- }];
350
- /**
351
- * Decode a log using the provided ABI
352
- * @param abi Contract ABI
353
- * @param log Log to decode
354
- * @returns Decoded event or null if decoding fails
355
- */
356
- export declare function decodeEvent<T = unknown>(abi: readonly unknown[], log: Log): T | null;
357
- /**
358
- * Filter and decode events from logs
359
- * @param abi Contract ABI
360
- * @param logs Array of logs
361
- * @param eventName Optional event name to filter by
362
- * @returns Array of decoded events
363
- */
364
- export declare function decodeEvents<T = unknown>(abi: readonly unknown[], logs: Log[], eventName?: string): T[];
365
- /**
366
- * BetPlaced event data
367
- */
368
- export interface BetPlacedEvent {
369
- eventName: 'BetPlaced';
370
- args: {
371
- roundId: bigint;
372
- beneficiary: Address;
373
- total: bigint;
374
- squares: readonly number[];
375
- };
376
- }
377
- /**
378
- * Claimed event data
379
- */
380
- export interface ClaimedEvent {
381
- eventName: 'Claimed';
382
- args: {
383
- roundId: bigint;
384
- user: Address;
385
- nativeOut: bigint;
386
- slvrOut: bigint;
387
- refinedOut: bigint;
388
- refiningFee: bigint;
389
- };
390
- }
391
- /**
392
- * Round resolved event data
393
- */
394
- export interface RoundResolvedEvent {
395
- eventName: 'RoundResolved';
396
- args: {
397
- roundId: bigint;
398
- winningSquare: number;
399
- jackpotHit: boolean;
400
- singleMinerRound: boolean;
401
- singleMinerWinner: Address;
402
- winnerTotal: bigint;
403
- potForWinners: bigint;
404
- slvrForWinners: bigint;
405
- totalUnclaimedSlvr: bigint;
406
- };
407
- }
408
- /**
409
- * RandomnessRequested event data
410
- */
411
- export interface RandomnessRequestedEvent {
412
- eventName: 'RandomnessRequested';
413
- args: {
414
- roundId: bigint;
415
- randomnessId: `0x${string}`;
416
- };
417
- }
418
- //# sourceMappingURL=events.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3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AM,EAAE,CAAC;KAC5B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,OAAO,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,eAAe,CAAC;IAC3B,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,OAAO,CAAC;QACpB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,iBAAiB,EAAE,OAAO,CAAC;QAC3B,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,qBAAqB,CAAC;IACjC,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,KAAK,MAAM,EAAE,CAAC;KAC7B,CAAC;CACH"}
package/dist/events.js DELETED
@@ -1,87 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlvrAutoCommitEvents = exports.SlvrTokenEvents = exports.SlvrStakingEvents = exports.SlvrGridLotteryEvents = void 0;
4
- exports.decodeEvent = decodeEvent;
5
- exports.decodeEvents = decodeEvents;
6
- const viem_1 = require("viem");
7
- /**
8
- * Event ABIs for Slvr contracts
9
- */
10
- exports.SlvrGridLotteryEvents = (0, viem_1.parseAbi)([
11
- 'event BetPlaced(uint256 indexed roundId, address indexed beneficiary, uint256 total, uint8[] squares)',
12
- 'event Claimed(uint256 indexed roundId, address indexed user, uint256 nativeOut, uint256 slvrOut, uint256 refinedOut, uint256 refiningFee)',
13
- 'event RoundResolved(uint256 indexed roundId, uint8 winningSquare, bool jackpotHit, bool singleMinerRound, address indexed singleMinerWinner, uint256 winnerTotal, uint256 potForWinners, uint256 slvrForWinners, uint256 totalUnclaimedSlvr)',
14
- 'event RandomnessRequested(uint256 indexed roundId, bytes32 randomnessId)',
15
- ]);
16
- /**
17
- * Events for the veNFT staker (`SlvrVoteEscrowStaking`). All staking events are
18
- * keyed by the veNFT `tokenId`; there are no raw-ERC20-amount stake events.
19
- */
20
- exports.SlvrStakingEvents = (0, viem_1.parseAbi)([
21
- 'event Staked(uint256 indexed tokenId, address indexed user, uint256 weight)',
22
- 'event Unstaked(uint256 indexed tokenId, address indexed user, uint256 weight)',
23
- 'event RewardClaimed(uint256 indexed tokenId, address indexed user, uint256 amount)',
24
- 'event RewardDistributed(uint256 amount)',
25
- 'event Checkpoint(uint256 indexed tokenId, uint256 oldWeight, uint256 newWeight)',
26
- 'event RewardsSettledOnBurn(uint256 indexed tokenId, address indexed owner, uint256 amount)',
27
- 'event PendingRewardsClaimed(address indexed user, uint256 amount)',
28
- ]);
29
- exports.SlvrTokenEvents = (0, viem_1.parseAbi)([
30
- 'event Transfer(address indexed from, address indexed to, uint256 value)',
31
- 'event Approval(address indexed owner, address indexed spender, uint256 value)',
32
- ]);
33
- exports.SlvrAutoCommitEvents = (0, viem_1.parseAbi)([
34
- 'event PlanConfigured(address indexed user, uint256 nextRoundId, uint32 plays, uint256 amountPerPlay, bool autoClaim)',
35
- 'event PlanDisabled(address indexed user)',
36
- 'event PlanCancelled(address indexed user, uint256 refundAmount)',
37
- 'event Deposited(address indexed user, uint256 amount)',
38
- 'event Withdrawn(address indexed user, uint256 amount, address to)',
39
- 'event RoundExecuted(address indexed user, uint256 indexed roundId, uint32 playsRemaining)',
40
- 'event Claimed(address indexed user, uint256 indexed roundId, uint256 nativeAmount, uint256 addedToBalance)',
41
- 'event BalanceUpdated(address indexed user, uint256 newBalance, uint256 amountAdded)',
42
- 'event ExecutorFeePaid(address indexed user, address indexed executor, uint256 fee, uint256 gasUsed)',
43
- ]);
44
- /**
45
- * Decode a log using the provided ABI
46
- * @param abi Contract ABI
47
- * @param log Log to decode
48
- * @returns Decoded event or null if decoding fails
49
- */
50
- function decodeEvent(abi, log) {
51
- try {
52
- const decoded = (0, viem_1.decodeEventLog)({
53
- abi,
54
- data: log.data,
55
- topics: log.topics,
56
- });
57
- return decoded;
58
- }
59
- catch {
60
- return null;
61
- }
62
- }
63
- /**
64
- * Filter and decode events from logs
65
- * @param abi Contract ABI
66
- * @param logs Array of logs
67
- * @param eventName Optional event name to filter by
68
- * @returns Array of decoded events
69
- */
70
- function decodeEvents(abi, logs, eventName) {
71
- const decoded = [];
72
- for (const log of logs) {
73
- try {
74
- const decodedEvent = decodeEvent(abi, log);
75
- if (decodedEvent) {
76
- if (!eventName || decodedEvent.eventName === eventName) {
77
- decoded.push(decodedEvent);
78
- }
79
- }
80
- }
81
- catch {
82
- // Skip invalid logs
83
- }
84
- }
85
- return decoded;
86
- }
87
- //# sourceMappingURL=events.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAiDA,kCAWC;AASD,oCAqBC;AA1FD,+BAA8D;AAE9D;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAA,eAAQ,EAAC;IAC5C,uGAAuG;IACvG,2IAA2I;IAC3I,8OAA8O;IAC9O,0EAA0E;CAC3E,CAAC,CAAC;AAEH;;;GAGG;AACU,QAAA,iBAAiB,GAAG,IAAA,eAAQ,EAAC;IACxC,6EAA6E;IAC7E,+EAA+E;IAC/E,oFAAoF;IACpF,yCAAyC;IACzC,iFAAiF;IACjF,4FAA4F;IAC5F,mEAAmE;CACpE,CAAC,CAAC;AAEU,QAAA,eAAe,GAAG,IAAA,eAAQ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,sBAAsB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,cAAc,UAAU,CAAC;AAGzB,cAAc,SAAS,CAAC;AAGxB,cAAc,eAAe,CAAC;AAG9B,cAAc,UAAU,CAAC"}
package/dist/oracle.d.ts DELETED
@@ -1,48 +0,0 @@
1
- import { Address, PublicClient } from 'viem';
2
- /**
3
- * Reads a Chainlink-style price feed (`AggregatorV3Interface`).
4
- *
5
- * Works with any standard aggregator — the canonical use here is an **ETH/USD**
6
- * feed, which lets the SDK convert the pair-derived SLVR/ETH price into USD.
7
- *
8
- * Robinhood Chain has a Chainlink ETH/USD feed (`ETH / USD`, 8 decimals), wired
9
- * into `deployments.robinhood.addresses.chainlinkEthUsd`, so `sdk.ethUsd` and USD
10
- * prices work out of the box there. On chains without a feed, pass a USD price
11
- * into {@link SlvrSDK.getSlvrPrice} instead, or wire your own off-chain source.
12
- *
13
- * @example
14
- * ```typescript
15
- * import { ChainlinkPriceFeed } from '@slvr-labs/sdk';
16
- * const ethUsd = new ChainlinkPriceFeed(publicClient, ethUsdFeedAddress);
17
- * const price = await ethUsd.getPrice(); // e.g. 1797.35
18
- * ```
19
- */
20
- export declare class ChainlinkPriceFeed {
21
- private publicClient;
22
- private feedAddress;
23
- private maxStalenessSec?;
24
- private static readonly ABI;
25
- /**
26
- * @param publicClient viem public client
27
- * @param feedAddress the aggregator address
28
- * @param opts.maxStalenessSec if set, {@link getPrice} throws when the feed's
29
- * `updatedAt` is older than this many seconds (checked against the local
30
- * clock). Off by default — enable it only where the local clock is trusted.
31
- */
32
- constructor(publicClient: PublicClient, feedAddress: Address, opts?: {
33
- maxStalenessSec?: number;
34
- });
35
- /** Raw `latestRoundData` answer plus the feed's decimals. */
36
- getRoundData(): Promise<{
37
- answer: bigint;
38
- decimals: number;
39
- updatedAt: bigint;
40
- }>;
41
- /**
42
- * The feed price as a floating-point number (`answer / 10 ** decimals`).
43
- * @throws {Error} if the answer is non-positive, or (when `maxStalenessSec` is
44
- * set) if the feed is stale.
45
- */
46
- getPrice(): Promise<number>;
47
- }
48
- //# sourceMappingURL=oracle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oracle.d.ts","sourceRoot":"","sources":["../src/oracle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAY,MAAM,MAAM,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,eAAe,CAAC,CAAS;IAEjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAGxB;IAEH;;;;;;OAMG;gBAED,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,OAAO,EACpB,IAAI,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE;IAOrC,6DAA6D;IACvD,YAAY,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAgBtF;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;CAgBlC"}
package/dist/oracle.js DELETED
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChainlinkPriceFeed = void 0;
4
- const viem_1 = require("viem");
5
- /**
6
- * Reads a Chainlink-style price feed (`AggregatorV3Interface`).
7
- *
8
- * Works with any standard aggregator — the canonical use here is an **ETH/USD**
9
- * feed, which lets the SDK convert the pair-derived SLVR/ETH price into USD.
10
- *
11
- * Robinhood Chain has a Chainlink ETH/USD feed (`ETH / USD`, 8 decimals), wired
12
- * into `deployments.robinhood.addresses.chainlinkEthUsd`, so `sdk.ethUsd` and USD
13
- * prices work out of the box there. On chains without a feed, pass a USD price
14
- * into {@link SlvrSDK.getSlvrPrice} instead, or wire your own off-chain source.
15
- *
16
- * @example
17
- * ```typescript
18
- * import { ChainlinkPriceFeed } from '@slvr-labs/sdk';
19
- * const ethUsd = new ChainlinkPriceFeed(publicClient, ethUsdFeedAddress);
20
- * const price = await ethUsd.getPrice(); // e.g. 1797.35
21
- * ```
22
- */
23
- class ChainlinkPriceFeed {
24
- /**
25
- * @param publicClient viem public client
26
- * @param feedAddress the aggregator address
27
- * @param opts.maxStalenessSec if set, {@link getPrice} throws when the feed's
28
- * `updatedAt` is older than this many seconds (checked against the local
29
- * clock). Off by default — enable it only where the local clock is trusted.
30
- */
31
- constructor(publicClient, feedAddress, opts) {
32
- this.publicClient = publicClient;
33
- this.feedAddress = feedAddress;
34
- this.maxStalenessSec = opts?.maxStalenessSec;
35
- }
36
- /** Raw `latestRoundData` answer plus the feed's decimals. */
37
- async getRoundData() {
38
- const [decimals, roundData] = await Promise.all([
39
- this.publicClient.readContract({
40
- address: this.feedAddress,
41
- abi: ChainlinkPriceFeed.ABI,
42
- functionName: 'decimals',
43
- }),
44
- this.publicClient.readContract({
45
- address: this.feedAddress,
46
- abi: ChainlinkPriceFeed.ABI,
47
- functionName: 'latestRoundData',
48
- }),
49
- ]);
50
- return { answer: roundData[1], decimals, updatedAt: roundData[3] };
51
- }
52
- /**
53
- * The feed price as a floating-point number (`answer / 10 ** decimals`).
54
- * @throws {Error} if the answer is non-positive, or (when `maxStalenessSec` is
55
- * set) if the feed is stale.
56
- */
57
- async getPrice() {
58
- const { answer, decimals, updatedAt } = await this.getRoundData();
59
- if (answer <= 0n) {
60
- throw new Error(`Chainlink feed ${this.feedAddress} returned a non-positive answer`);
61
- }
62
- if (this.maxStalenessSec !== undefined) {
63
- const nowSec = Math.floor(Date.now() / 1000);
64
- const age = nowSec - Number(updatedAt);
65
- if (age > this.maxStalenessSec) {
66
- throw new Error(`Chainlink feed ${this.feedAddress} is stale: ${age}s old (max ${this.maxStalenessSec}s)`);
67
- }
68
- }
69
- return Number(answer) / 10 ** decimals;
70
- }
71
- }
72
- exports.ChainlinkPriceFeed = ChainlinkPriceFeed;
73
- ChainlinkPriceFeed.ABI = (0, viem_1.parseAbi)([
74
- 'function decimals() view returns (uint8)',
75
- 'function latestRoundData() view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)',
76
- ]);
77
- //# sourceMappingURL=oracle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oracle.js","sourceRoot":"","sources":["../src/oracle.ts"],"names":[],"mappings":";;;AAAA,+BAAuD;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,kBAAkB;IAU7B;;;;;;OAMG;IACH,YACE,YAA0B,EAC1B,WAAoB,EACpB,IAAmC;QAEnC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,IAAI,EAAE,eAAe,CAAC;IAC/C,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,YAAY;QAChB,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC9C,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;gBAC7B,OAAO,EAAE,IAAI,CAAC,WAAW;gBACzB,GAAG,EAAE,kBAAkB,CAAC,GAAG;gBAC3B,YAAY,EAAE,UAAU;aACzB,CAAoB;YACrB,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;gBAC7B,OAAO,EAAE,IAAI,CAAC,WAAW;gBACzB,GAAG,EAAE,kBAAkB,CAAC,GAAG;gBAC3B,YAAY,EAAE,iBAAiB;aAChC,CAA+D;SACjE,CAAC,CAAC;QACH,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACH,KA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