@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.
- package/README.md +42 -0
- package/dist/index.d.mts +2117 -0
- package/dist/index.d.ts +1903 -34
- package/dist/index.js +3091 -427
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3035 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +19 -11
- package/skills/slvr-bot/SKILL.md +9 -8
- package/skills/slvr-bot/references/api.md +8 -0
- package/dist/connect.d.ts +0 -47
- package/dist/connect.d.ts.map +0 -1
- package/dist/connect.js +0 -56
- package/dist/connect.js.map +0 -1
- package/dist/contracts/autoCommit.d.ts +0 -151
- package/dist/contracts/autoCommit.d.ts.map +0 -1
- package/dist/contracts/autoCommit.js +0 -426
- package/dist/contracts/autoCommit.js.map +0 -1
- package/dist/contracts/hub.d.ts +0 -50
- package/dist/contracts/hub.d.ts.map +0 -1
- package/dist/contracts/hub.js +0 -118
- package/dist/contracts/hub.js.map +0 -1
- package/dist/contracts/index.d.ts +0 -8
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js +0 -18
- package/dist/contracts/index.js.map +0 -1
- package/dist/contracts/jackpot.d.ts +0 -21
- package/dist/contracts/jackpot.d.ts.map +0 -1
- package/dist/contracts/jackpot.js +0 -44
- package/dist/contracts/jackpot.js.map +0 -1
- package/dist/contracts/lottery.d.ts +0 -256
- package/dist/contracts/lottery.d.ts.map +0 -1
- package/dist/contracts/lottery.js +0 -767
- package/dist/contracts/lottery.js.map +0 -1
- package/dist/contracts/registry.d.ts +0 -53
- package/dist/contracts/registry.d.ts.map +0 -1
- package/dist/contracts/registry.js +0 -143
- package/dist/contracts/registry.js.map +0 -1
- package/dist/contracts/staking.d.ts +0 -101
- package/dist/contracts/staking.d.ts.map +0 -1
- package/dist/contracts/staking.js +0 -306
- package/dist/contracts/staking.js.map +0 -1
- package/dist/contracts/token.d.ts +0 -95
- package/dist/contracts/token.d.ts.map +0 -1
- package/dist/contracts/token.js +0 -273
- package/dist/contracts/token.js.map +0 -1
- package/dist/deployments.d.ts +0 -117
- package/dist/deployments.d.ts.map +0 -1
- package/dist/deployments.js +0 -74
- package/dist/deployments.js.map +0 -1
- package/dist/errors.d.ts +0 -39
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -67
- package/dist/errors.js.map +0 -1
- package/dist/ev.d.ts +0 -123
- package/dist/ev.d.ts.map +0 -1
- package/dist/ev.js +0 -111
- package/dist/ev.js.map +0 -1
- package/dist/events.d.ts +0 -418
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js +0 -87
- package/dist/events.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/oracle.d.ts +0 -48
- package/dist/oracle.d.ts.map +0 -1
- package/dist/oracle.js +0 -77
- package/dist/oracle.js.map +0 -1
- package/dist/price.d.ts +0 -52
- package/dist/price.d.ts.map +0 -1
- package/dist/price.js +0 -78
- package/dist/price.js.map +0 -1
- package/dist/transaction.d.ts +0 -54
- package/dist/transaction.d.ts.map +0 -1
- package/dist/transaction.js +0 -105
- package/dist/transaction.js.map +0 -1
- package/dist/types.d.ts +0 -162
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -23
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -58
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -110
- package/dist/utils.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,1896 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import * as viem from 'viem';
|
|
2
|
+
import { Address, PublicClient, WalletClient, Log, Transport, Account, Chain } from 'viem';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for the Slvr SDK
|
|
6
|
+
*/
|
|
7
|
+
interface SlvrConfig {
|
|
8
|
+
/** Public client for read operations */
|
|
9
|
+
publicClient: PublicClient;
|
|
10
|
+
/** Wallet client for write operations (optional, required for transactions) */
|
|
11
|
+
walletClient?: WalletClient;
|
|
12
|
+
/** Contract addresses */
|
|
13
|
+
addresses: {
|
|
14
|
+
lottery: Address;
|
|
15
|
+
staking: Address;
|
|
16
|
+
token: Address;
|
|
17
|
+
autoCommit?: Address;
|
|
18
|
+
/** SlvrHub address (optional, for emission/staker/jackpot stats and keeper/admin ops) */
|
|
19
|
+
hub?: Address;
|
|
20
|
+
/** SlvrGameRegistry address (optional, for game weight/status stats) */
|
|
21
|
+
registry?: Address;
|
|
22
|
+
/** SlvrJackpot address (optional, for jackpot pool reads) */
|
|
23
|
+
jackpot?: Address;
|
|
24
|
+
/** SLVR/ETH UniswapV2 pair address (optional, enables `sdk.price` SLVR price reads) */
|
|
25
|
+
slvrEthPair?: Address;
|
|
26
|
+
/**
|
|
27
|
+
* Chainlink-style ETH/USD price feed address (optional, enables `sdk.ethUsd`
|
|
28
|
+
* and USD-denominated prices). Only set on chains that actually have a feed.
|
|
29
|
+
*/
|
|
30
|
+
chainlinkEthUsd?: Address;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A SLVR price quote in both ETH and USD.
|
|
35
|
+
*/
|
|
36
|
+
interface PriceQuote {
|
|
37
|
+
/** Price in ETH (ETH per SLVR). */
|
|
38
|
+
eth: number;
|
|
39
|
+
/** Price in USD, or `null` if no ETH/USD source was available. */
|
|
40
|
+
usd: number | null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Round information
|
|
44
|
+
*/
|
|
45
|
+
interface RoundInfo {
|
|
46
|
+
roundId: bigint;
|
|
47
|
+
requestedAt: bigint;
|
|
48
|
+
resolved: boolean;
|
|
49
|
+
randomnessId: `0x${string}`;
|
|
50
|
+
randomnessValue: bigint;
|
|
51
|
+
winningSquare: number;
|
|
52
|
+
jackpotHit: boolean;
|
|
53
|
+
singleMinerRound: boolean;
|
|
54
|
+
singleMinerWinner: Address;
|
|
55
|
+
totalWager: bigint;
|
|
56
|
+
fee: bigint;
|
|
57
|
+
winnerTotal: bigint;
|
|
58
|
+
potForWinners: bigint;
|
|
59
|
+
slvrForWinners: bigint;
|
|
60
|
+
payoutMulWad: bigint;
|
|
61
|
+
slvrMulWad: bigint;
|
|
62
|
+
totalUnclaimedSlvr: bigint;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Miner state information
|
|
66
|
+
*/
|
|
67
|
+
interface MinerState {
|
|
68
|
+
rewardsSlvr: bigint;
|
|
69
|
+
refinedAccrued: bigint;
|
|
70
|
+
indexSnapshot: bigint;
|
|
71
|
+
hasAccount: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Treasury state information
|
|
75
|
+
*/
|
|
76
|
+
interface TreasuryState {
|
|
77
|
+
minerIndex: bigint;
|
|
78
|
+
totalUnclaimed: bigint;
|
|
79
|
+
totalRefined: bigint;
|
|
80
|
+
jackpotPool: bigint;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Staking information for a staked veNFT tokenId
|
|
84
|
+
*/
|
|
85
|
+
interface StakingInfo {
|
|
86
|
+
/** Total tracked weight across all staked tokens */
|
|
87
|
+
totalWeight: bigint;
|
|
88
|
+
/** Tracked weight (balance) of this tokenId */
|
|
89
|
+
balance: bigint;
|
|
90
|
+
/** Claimable rewards for this tokenId */
|
|
91
|
+
rewards: bigint;
|
|
92
|
+
/** Accumulated reward per unit of weight (1e18 precision) */
|
|
93
|
+
rewardPerWeightStored: bigint;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* AutoCommit plan information
|
|
97
|
+
*/
|
|
98
|
+
interface AutoCommitPlan {
|
|
99
|
+
enabled: boolean;
|
|
100
|
+
nextRoundId: bigint;
|
|
101
|
+
playsRemaining: number;
|
|
102
|
+
amountPerPlay: bigint;
|
|
103
|
+
balance: bigint;
|
|
104
|
+
autoClaim: boolean;
|
|
105
|
+
squares: number[];
|
|
106
|
+
bpsAlloc: number[];
|
|
107
|
+
planStartRoundId: bigint;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Game status in the registry (mirrors ISlvrGameRegistry.Status)
|
|
111
|
+
*/
|
|
112
|
+
declare enum GameStatus {
|
|
113
|
+
Pending = 0,
|
|
114
|
+
Active = 1,
|
|
115
|
+
Paused = 2,
|
|
116
|
+
Retired = 3
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Game tier in the registry (mirrors ISlvrGameRegistry.Tier)
|
|
120
|
+
*/
|
|
121
|
+
declare enum GameTier {
|
|
122
|
+
Core = 0,
|
|
123
|
+
Community = 1,
|
|
124
|
+
Experimental = 2
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Full registry record for a game (mirrors ISlvrGameRegistry.GameInfo)
|
|
128
|
+
*/
|
|
129
|
+
interface GameInfo {
|
|
130
|
+
game: Address;
|
|
131
|
+
gameType: `0x${string}`;
|
|
132
|
+
status: GameStatus;
|
|
133
|
+
tier: GameTier;
|
|
134
|
+
emissionWeight: number;
|
|
135
|
+
maxWeightBps: number;
|
|
136
|
+
exists: boolean;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Optional transaction overrides passed through to viem's `writeContract`
|
|
140
|
+
* (e.g. to manage gas or nonce in a high-throughput bot).
|
|
141
|
+
*/
|
|
142
|
+
interface TxOverrides {
|
|
143
|
+
gas?: bigint;
|
|
144
|
+
nonce?: number;
|
|
145
|
+
maxFeePerGas?: bigint;
|
|
146
|
+
maxPriorityFeePerGas?: bigint;
|
|
147
|
+
gasPrice?: bigint;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Bet parameters
|
|
151
|
+
*/
|
|
152
|
+
interface BetParams {
|
|
153
|
+
roundId: bigint;
|
|
154
|
+
squares: number[];
|
|
155
|
+
amounts: bigint[];
|
|
156
|
+
beneficiary?: Address;
|
|
157
|
+
/** Optional gas/nonce overrides for the transaction. */
|
|
158
|
+
overrides?: TxOverrides;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Claim parameters
|
|
162
|
+
*/
|
|
163
|
+
interface ClaimParams {
|
|
164
|
+
roundId: bigint;
|
|
165
|
+
/** Optional gas/nonce overrides for the transaction. */
|
|
166
|
+
overrides?: TxOverrides;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Advanced claim parameters (unified claim function)
|
|
170
|
+
*/
|
|
171
|
+
interface ClaimParamsAdvanced {
|
|
172
|
+
user: Address;
|
|
173
|
+
roundId: bigint;
|
|
174
|
+
recipientNative?: Address;
|
|
175
|
+
recipientSlvr?: Address;
|
|
176
|
+
bypassFee?: boolean;
|
|
177
|
+
ethOnly?: boolean;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Event ABIs for Slvr contracts
|
|
182
|
+
*/
|
|
183
|
+
declare const SlvrGridLotteryEvents: readonly [{
|
|
184
|
+
readonly name: "BetPlaced";
|
|
185
|
+
readonly type: "event";
|
|
186
|
+
readonly inputs: readonly [{
|
|
187
|
+
readonly type: "uint256";
|
|
188
|
+
readonly name: "roundId";
|
|
189
|
+
readonly indexed: true;
|
|
190
|
+
}, {
|
|
191
|
+
readonly type: "address";
|
|
192
|
+
readonly name: "beneficiary";
|
|
193
|
+
readonly indexed: true;
|
|
194
|
+
}, {
|
|
195
|
+
readonly type: "uint256";
|
|
196
|
+
readonly name: "total";
|
|
197
|
+
}, {
|
|
198
|
+
readonly type: "uint8[]";
|
|
199
|
+
readonly name: "squares";
|
|
200
|
+
}];
|
|
201
|
+
}, {
|
|
202
|
+
readonly name: "Claimed";
|
|
203
|
+
readonly type: "event";
|
|
204
|
+
readonly inputs: readonly [{
|
|
205
|
+
readonly type: "uint256";
|
|
206
|
+
readonly name: "roundId";
|
|
207
|
+
readonly indexed: true;
|
|
208
|
+
}, {
|
|
209
|
+
readonly type: "address";
|
|
210
|
+
readonly name: "user";
|
|
211
|
+
readonly indexed: true;
|
|
212
|
+
}, {
|
|
213
|
+
readonly type: "uint256";
|
|
214
|
+
readonly name: "nativeOut";
|
|
215
|
+
}, {
|
|
216
|
+
readonly type: "uint256";
|
|
217
|
+
readonly name: "slvrOut";
|
|
218
|
+
}, {
|
|
219
|
+
readonly type: "uint256";
|
|
220
|
+
readonly name: "refinedOut";
|
|
221
|
+
}, {
|
|
222
|
+
readonly type: "uint256";
|
|
223
|
+
readonly name: "refiningFee";
|
|
224
|
+
}];
|
|
225
|
+
}, {
|
|
226
|
+
readonly name: "RoundResolved";
|
|
227
|
+
readonly type: "event";
|
|
228
|
+
readonly inputs: readonly [{
|
|
229
|
+
readonly type: "uint256";
|
|
230
|
+
readonly name: "roundId";
|
|
231
|
+
readonly indexed: true;
|
|
232
|
+
}, {
|
|
233
|
+
readonly type: "uint8";
|
|
234
|
+
readonly name: "winningSquare";
|
|
235
|
+
}, {
|
|
236
|
+
readonly type: "bool";
|
|
237
|
+
readonly name: "jackpotHit";
|
|
238
|
+
}, {
|
|
239
|
+
readonly type: "bool";
|
|
240
|
+
readonly name: "singleMinerRound";
|
|
241
|
+
}, {
|
|
242
|
+
readonly type: "address";
|
|
243
|
+
readonly name: "singleMinerWinner";
|
|
244
|
+
readonly indexed: true;
|
|
245
|
+
}, {
|
|
246
|
+
readonly type: "uint256";
|
|
247
|
+
readonly name: "winnerTotal";
|
|
248
|
+
}, {
|
|
249
|
+
readonly type: "uint256";
|
|
250
|
+
readonly name: "potForWinners";
|
|
251
|
+
}, {
|
|
252
|
+
readonly type: "uint256";
|
|
253
|
+
readonly name: "slvrForWinners";
|
|
254
|
+
}, {
|
|
255
|
+
readonly type: "uint256";
|
|
256
|
+
readonly name: "totalUnclaimedSlvr";
|
|
257
|
+
}];
|
|
258
|
+
}, {
|
|
259
|
+
readonly name: "RandomnessRequested";
|
|
260
|
+
readonly type: "event";
|
|
261
|
+
readonly inputs: readonly [{
|
|
262
|
+
readonly type: "uint256";
|
|
263
|
+
readonly name: "roundId";
|
|
264
|
+
readonly indexed: true;
|
|
265
|
+
}, {
|
|
266
|
+
readonly type: "bytes32";
|
|
267
|
+
readonly name: "randomnessId";
|
|
268
|
+
}];
|
|
269
|
+
}];
|
|
270
|
+
/**
|
|
271
|
+
* Events for the veNFT staker (`SlvrVoteEscrowStaking`). All staking events are
|
|
272
|
+
* keyed by the veNFT `tokenId`; there are no raw-ERC20-amount stake events.
|
|
273
|
+
*/
|
|
274
|
+
declare const SlvrStakingEvents: readonly [{
|
|
275
|
+
readonly name: "Staked";
|
|
276
|
+
readonly type: "event";
|
|
277
|
+
readonly inputs: readonly [{
|
|
278
|
+
readonly type: "uint256";
|
|
279
|
+
readonly name: "tokenId";
|
|
280
|
+
readonly indexed: true;
|
|
281
|
+
}, {
|
|
282
|
+
readonly type: "address";
|
|
283
|
+
readonly name: "user";
|
|
284
|
+
readonly indexed: true;
|
|
285
|
+
}, {
|
|
286
|
+
readonly type: "uint256";
|
|
287
|
+
readonly name: "weight";
|
|
288
|
+
}];
|
|
289
|
+
}, {
|
|
290
|
+
readonly name: "Unstaked";
|
|
291
|
+
readonly type: "event";
|
|
292
|
+
readonly inputs: readonly [{
|
|
293
|
+
readonly type: "uint256";
|
|
294
|
+
readonly name: "tokenId";
|
|
295
|
+
readonly indexed: true;
|
|
296
|
+
}, {
|
|
297
|
+
readonly type: "address";
|
|
298
|
+
readonly name: "user";
|
|
299
|
+
readonly indexed: true;
|
|
300
|
+
}, {
|
|
301
|
+
readonly type: "uint256";
|
|
302
|
+
readonly name: "weight";
|
|
303
|
+
}];
|
|
304
|
+
}, {
|
|
305
|
+
readonly name: "RewardClaimed";
|
|
306
|
+
readonly type: "event";
|
|
307
|
+
readonly inputs: readonly [{
|
|
308
|
+
readonly type: "uint256";
|
|
309
|
+
readonly name: "tokenId";
|
|
310
|
+
readonly indexed: true;
|
|
311
|
+
}, {
|
|
312
|
+
readonly type: "address";
|
|
313
|
+
readonly name: "user";
|
|
314
|
+
readonly indexed: true;
|
|
315
|
+
}, {
|
|
316
|
+
readonly type: "uint256";
|
|
317
|
+
readonly name: "amount";
|
|
318
|
+
}];
|
|
319
|
+
}, {
|
|
320
|
+
readonly name: "RewardDistributed";
|
|
321
|
+
readonly type: "event";
|
|
322
|
+
readonly inputs: readonly [{
|
|
323
|
+
readonly type: "uint256";
|
|
324
|
+
readonly name: "amount";
|
|
325
|
+
}];
|
|
326
|
+
}, {
|
|
327
|
+
readonly name: "Checkpoint";
|
|
328
|
+
readonly type: "event";
|
|
329
|
+
readonly inputs: readonly [{
|
|
330
|
+
readonly type: "uint256";
|
|
331
|
+
readonly name: "tokenId";
|
|
332
|
+
readonly indexed: true;
|
|
333
|
+
}, {
|
|
334
|
+
readonly type: "uint256";
|
|
335
|
+
readonly name: "oldWeight";
|
|
336
|
+
}, {
|
|
337
|
+
readonly type: "uint256";
|
|
338
|
+
readonly name: "newWeight";
|
|
339
|
+
}];
|
|
340
|
+
}, {
|
|
341
|
+
readonly name: "RewardsSettledOnBurn";
|
|
342
|
+
readonly type: "event";
|
|
343
|
+
readonly inputs: readonly [{
|
|
344
|
+
readonly type: "uint256";
|
|
345
|
+
readonly name: "tokenId";
|
|
346
|
+
readonly indexed: true;
|
|
347
|
+
}, {
|
|
348
|
+
readonly type: "address";
|
|
349
|
+
readonly name: "owner";
|
|
350
|
+
readonly indexed: true;
|
|
351
|
+
}, {
|
|
352
|
+
readonly type: "uint256";
|
|
353
|
+
readonly name: "amount";
|
|
354
|
+
}];
|
|
355
|
+
}, {
|
|
356
|
+
readonly name: "PendingRewardsClaimed";
|
|
357
|
+
readonly type: "event";
|
|
358
|
+
readonly inputs: readonly [{
|
|
359
|
+
readonly type: "address";
|
|
360
|
+
readonly name: "user";
|
|
361
|
+
readonly indexed: true;
|
|
362
|
+
}, {
|
|
363
|
+
readonly type: "uint256";
|
|
364
|
+
readonly name: "amount";
|
|
365
|
+
}];
|
|
366
|
+
}];
|
|
367
|
+
declare const SlvrTokenEvents: readonly [{
|
|
368
|
+
readonly name: "Transfer";
|
|
369
|
+
readonly type: "event";
|
|
370
|
+
readonly inputs: readonly [{
|
|
371
|
+
readonly type: "address";
|
|
372
|
+
readonly name: "from";
|
|
373
|
+
readonly indexed: true;
|
|
374
|
+
}, {
|
|
375
|
+
readonly type: "address";
|
|
376
|
+
readonly name: "to";
|
|
377
|
+
readonly indexed: true;
|
|
378
|
+
}, {
|
|
379
|
+
readonly type: "uint256";
|
|
380
|
+
readonly name: "value";
|
|
381
|
+
}];
|
|
382
|
+
}, {
|
|
383
|
+
readonly name: "Approval";
|
|
384
|
+
readonly type: "event";
|
|
385
|
+
readonly inputs: readonly [{
|
|
386
|
+
readonly type: "address";
|
|
387
|
+
readonly name: "owner";
|
|
388
|
+
readonly indexed: true;
|
|
389
|
+
}, {
|
|
390
|
+
readonly type: "address";
|
|
391
|
+
readonly name: "spender";
|
|
392
|
+
readonly indexed: true;
|
|
393
|
+
}, {
|
|
394
|
+
readonly type: "uint256";
|
|
395
|
+
readonly name: "value";
|
|
396
|
+
}];
|
|
397
|
+
}];
|
|
398
|
+
declare const SlvrAutoCommitEvents: readonly [{
|
|
399
|
+
readonly name: "PlanConfigured";
|
|
400
|
+
readonly type: "event";
|
|
401
|
+
readonly inputs: readonly [{
|
|
402
|
+
readonly type: "address";
|
|
403
|
+
readonly name: "user";
|
|
404
|
+
readonly indexed: true;
|
|
405
|
+
}, {
|
|
406
|
+
readonly type: "uint256";
|
|
407
|
+
readonly name: "nextRoundId";
|
|
408
|
+
}, {
|
|
409
|
+
readonly type: "uint32";
|
|
410
|
+
readonly name: "plays";
|
|
411
|
+
}, {
|
|
412
|
+
readonly type: "uint256";
|
|
413
|
+
readonly name: "amountPerPlay";
|
|
414
|
+
}, {
|
|
415
|
+
readonly type: "bool";
|
|
416
|
+
readonly name: "autoClaim";
|
|
417
|
+
}];
|
|
418
|
+
}, {
|
|
419
|
+
readonly name: "PlanDisabled";
|
|
420
|
+
readonly type: "event";
|
|
421
|
+
readonly inputs: readonly [{
|
|
422
|
+
readonly type: "address";
|
|
423
|
+
readonly name: "user";
|
|
424
|
+
readonly indexed: true;
|
|
425
|
+
}];
|
|
426
|
+
}, {
|
|
427
|
+
readonly name: "PlanCancelled";
|
|
428
|
+
readonly type: "event";
|
|
429
|
+
readonly inputs: readonly [{
|
|
430
|
+
readonly type: "address";
|
|
431
|
+
readonly name: "user";
|
|
432
|
+
readonly indexed: true;
|
|
433
|
+
}, {
|
|
434
|
+
readonly type: "uint256";
|
|
435
|
+
readonly name: "refundAmount";
|
|
436
|
+
}];
|
|
437
|
+
}, {
|
|
438
|
+
readonly name: "Deposited";
|
|
439
|
+
readonly type: "event";
|
|
440
|
+
readonly inputs: readonly [{
|
|
441
|
+
readonly type: "address";
|
|
442
|
+
readonly name: "user";
|
|
443
|
+
readonly indexed: true;
|
|
444
|
+
}, {
|
|
445
|
+
readonly type: "uint256";
|
|
446
|
+
readonly name: "amount";
|
|
447
|
+
}];
|
|
448
|
+
}, {
|
|
449
|
+
readonly name: "Withdrawn";
|
|
450
|
+
readonly type: "event";
|
|
451
|
+
readonly inputs: readonly [{
|
|
452
|
+
readonly type: "address";
|
|
453
|
+
readonly name: "user";
|
|
454
|
+
readonly indexed: true;
|
|
455
|
+
}, {
|
|
456
|
+
readonly type: "uint256";
|
|
457
|
+
readonly name: "amount";
|
|
458
|
+
}, {
|
|
459
|
+
readonly type: "address";
|
|
460
|
+
readonly name: "to";
|
|
461
|
+
}];
|
|
462
|
+
}, {
|
|
463
|
+
readonly name: "RoundExecuted";
|
|
464
|
+
readonly type: "event";
|
|
465
|
+
readonly inputs: readonly [{
|
|
466
|
+
readonly type: "address";
|
|
467
|
+
readonly name: "user";
|
|
468
|
+
readonly indexed: true;
|
|
469
|
+
}, {
|
|
470
|
+
readonly type: "uint256";
|
|
471
|
+
readonly name: "roundId";
|
|
472
|
+
readonly indexed: true;
|
|
473
|
+
}, {
|
|
474
|
+
readonly type: "uint32";
|
|
475
|
+
readonly name: "playsRemaining";
|
|
476
|
+
}];
|
|
477
|
+
}, {
|
|
478
|
+
readonly name: "Claimed";
|
|
479
|
+
readonly type: "event";
|
|
480
|
+
readonly inputs: readonly [{
|
|
481
|
+
readonly type: "address";
|
|
482
|
+
readonly name: "user";
|
|
483
|
+
readonly indexed: true;
|
|
484
|
+
}, {
|
|
485
|
+
readonly type: "uint256";
|
|
486
|
+
readonly name: "roundId";
|
|
487
|
+
readonly indexed: true;
|
|
488
|
+
}, {
|
|
489
|
+
readonly type: "uint256";
|
|
490
|
+
readonly name: "nativeAmount";
|
|
491
|
+
}, {
|
|
492
|
+
readonly type: "uint256";
|
|
493
|
+
readonly name: "addedToBalance";
|
|
494
|
+
}];
|
|
495
|
+
}, {
|
|
496
|
+
readonly name: "BalanceUpdated";
|
|
497
|
+
readonly type: "event";
|
|
498
|
+
readonly inputs: readonly [{
|
|
499
|
+
readonly type: "address";
|
|
500
|
+
readonly name: "user";
|
|
501
|
+
readonly indexed: true;
|
|
502
|
+
}, {
|
|
503
|
+
readonly type: "uint256";
|
|
504
|
+
readonly name: "newBalance";
|
|
505
|
+
}, {
|
|
506
|
+
readonly type: "uint256";
|
|
507
|
+
readonly name: "amountAdded";
|
|
508
|
+
}];
|
|
509
|
+
}, {
|
|
510
|
+
readonly name: "ExecutorFeePaid";
|
|
511
|
+
readonly type: "event";
|
|
512
|
+
readonly inputs: readonly [{
|
|
513
|
+
readonly type: "address";
|
|
514
|
+
readonly name: "user";
|
|
515
|
+
readonly indexed: true;
|
|
516
|
+
}, {
|
|
517
|
+
readonly type: "address";
|
|
518
|
+
readonly name: "executor";
|
|
519
|
+
readonly indexed: true;
|
|
520
|
+
}, {
|
|
521
|
+
readonly type: "uint256";
|
|
522
|
+
readonly name: "fee";
|
|
523
|
+
}, {
|
|
524
|
+
readonly type: "uint256";
|
|
525
|
+
readonly name: "gasUsed";
|
|
526
|
+
}];
|
|
527
|
+
}];
|
|
528
|
+
/**
|
|
529
|
+
* Decode a log using the provided ABI
|
|
530
|
+
* @param abi Contract ABI
|
|
531
|
+
* @param log Log to decode
|
|
532
|
+
* @returns Decoded event or null if decoding fails
|
|
533
|
+
*/
|
|
534
|
+
declare function decodeEvent<T = unknown>(abi: readonly unknown[], log: Log): T | null;
|
|
535
|
+
/**
|
|
536
|
+
* Filter and decode events from logs
|
|
537
|
+
* @param abi Contract ABI
|
|
538
|
+
* @param logs Array of logs
|
|
539
|
+
* @param eventName Optional event name to filter by
|
|
540
|
+
* @returns Array of decoded events
|
|
541
|
+
*/
|
|
542
|
+
declare function decodeEvents<T = unknown>(abi: readonly unknown[], logs: Log[], eventName?: string): T[];
|
|
543
|
+
/**
|
|
544
|
+
* BetPlaced event data
|
|
545
|
+
*/
|
|
546
|
+
interface BetPlacedEvent {
|
|
547
|
+
eventName: 'BetPlaced';
|
|
548
|
+
args: {
|
|
549
|
+
roundId: bigint;
|
|
550
|
+
beneficiary: Address;
|
|
551
|
+
total: bigint;
|
|
552
|
+
squares: readonly number[];
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Claimed event data
|
|
557
|
+
*/
|
|
558
|
+
interface ClaimedEvent {
|
|
559
|
+
eventName: 'Claimed';
|
|
560
|
+
args: {
|
|
561
|
+
roundId: bigint;
|
|
562
|
+
user: Address;
|
|
563
|
+
nativeOut: bigint;
|
|
564
|
+
slvrOut: bigint;
|
|
565
|
+
refinedOut: bigint;
|
|
566
|
+
refiningFee: bigint;
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Round resolved event data
|
|
571
|
+
*/
|
|
572
|
+
interface RoundResolvedEvent {
|
|
573
|
+
eventName: 'RoundResolved';
|
|
574
|
+
args: {
|
|
575
|
+
roundId: bigint;
|
|
576
|
+
winningSquare: number;
|
|
577
|
+
jackpotHit: boolean;
|
|
578
|
+
singleMinerRound: boolean;
|
|
579
|
+
singleMinerWinner: Address;
|
|
580
|
+
winnerTotal: bigint;
|
|
581
|
+
potForWinners: bigint;
|
|
582
|
+
slvrForWinners: bigint;
|
|
583
|
+
totalUnclaimedSlvr: bigint;
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* RandomnessRequested event data
|
|
588
|
+
*/
|
|
589
|
+
interface RandomnessRequestedEvent {
|
|
590
|
+
eventName: 'RandomnessRequested';
|
|
591
|
+
args: {
|
|
592
|
+
roundId: bigint;
|
|
593
|
+
randomnessId: `0x${string}`;
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* SlvrGridLottery contract interface
|
|
599
|
+
*/
|
|
600
|
+
declare class SlvrGridLottery {
|
|
601
|
+
private publicClient;
|
|
602
|
+
private walletClient?;
|
|
603
|
+
private address;
|
|
604
|
+
private static readonly ABI;
|
|
605
|
+
constructor(publicClient: PublicClient, walletClient: WalletClient | undefined, address: Address);
|
|
606
|
+
/**
|
|
607
|
+
* Update the wallet client
|
|
608
|
+
* @param walletClient New wallet client
|
|
609
|
+
*/
|
|
610
|
+
setWalletClient(walletClient: WalletClient | undefined): void;
|
|
611
|
+
/**
|
|
612
|
+
* Get the current round ID
|
|
613
|
+
*/
|
|
614
|
+
currentRoundId(): Promise<bigint>;
|
|
615
|
+
/**
|
|
616
|
+
* Get round start time
|
|
617
|
+
*/
|
|
618
|
+
roundStart(roundId: bigint): Promise<bigint>;
|
|
619
|
+
/**
|
|
620
|
+
* Get round end time
|
|
621
|
+
*/
|
|
622
|
+
roundEnd(roundId: bigint): Promise<bigint>;
|
|
623
|
+
/**
|
|
624
|
+
* Check if round is open for betting
|
|
625
|
+
*/
|
|
626
|
+
roundOpen(roundId: bigint): Promise<boolean>;
|
|
627
|
+
/**
|
|
628
|
+
* Get the betting cutoff timestamp (unix seconds) for a round.
|
|
629
|
+
*
|
|
630
|
+
* Bets are only accepted until this time, which can be earlier than
|
|
631
|
+
* {@link roundEnd}. Bots deciding whether they can still bet should gate on
|
|
632
|
+
* this rather than on `roundEnd`.
|
|
633
|
+
*/
|
|
634
|
+
bettingEnd(roundId: bigint): Promise<bigint>;
|
|
635
|
+
/**
|
|
636
|
+
* Estimate the reward an account would receive for a round, in wei.
|
|
637
|
+
*
|
|
638
|
+
* Thin pass-through to the contract's `getExpectedReward`. Useful for sizing
|
|
639
|
+
* bets or deciding whether a claim is worth the gas.
|
|
640
|
+
*/
|
|
641
|
+
getExpectedReward(account: Address, roundId: bigint): Promise<bigint>;
|
|
642
|
+
/**
|
|
643
|
+
* Get the latest resolved round ID (type(uint256).max sentinel when none resolved yet)
|
|
644
|
+
*/
|
|
645
|
+
latestResolvedRoundId(): Promise<bigint>;
|
|
646
|
+
/**
|
|
647
|
+
* Get full round information
|
|
648
|
+
*/
|
|
649
|
+
getRound(roundId: bigint): Promise<RoundInfo>;
|
|
650
|
+
/**
|
|
651
|
+
* Get a compact, batched snapshot of a round's live state — the fields a bot
|
|
652
|
+
* checks every tick — in one shot. Defaults to the current round.
|
|
653
|
+
*
|
|
654
|
+
* `secondsUntilBettingClose` is computed from the chain's `block.timestamp`
|
|
655
|
+
* (not the local clock), so it's accurate even if your device clock drifts.
|
|
656
|
+
* With a multicall-batching client the reads collapse into ~2 RPC calls.
|
|
657
|
+
*/
|
|
658
|
+
getRoundState(roundId?: bigint): Promise<{
|
|
659
|
+
roundId: bigint;
|
|
660
|
+
open: boolean;
|
|
661
|
+
resolved: boolean;
|
|
662
|
+
bettingEnd: bigint;
|
|
663
|
+
roundEnd: bigint;
|
|
664
|
+
totalWager: bigint;
|
|
665
|
+
winningSquare: number;
|
|
666
|
+
secondsUntilBettingClose: number;
|
|
667
|
+
}>;
|
|
668
|
+
/**
|
|
669
|
+
* Get the jackpot contract address for a round (zero address if no jackpot is
|
|
670
|
+
* set). Read that contract's `jackpotPool()` for the pool balance — or use the
|
|
671
|
+
* SDK helper `getJackpotPool(roundId)`.
|
|
672
|
+
*/
|
|
673
|
+
getRoundJackpot(roundId: bigint): Promise<Address>;
|
|
674
|
+
/**
|
|
675
|
+
* Get total amount bet on a square for a round
|
|
676
|
+
*/
|
|
677
|
+
getTotalOnSquare(roundId: bigint, square: number): Promise<bigint>;
|
|
678
|
+
/**
|
|
679
|
+
* Get number of bettors on a square for a round
|
|
680
|
+
*/
|
|
681
|
+
getBettorsOnSquare(roundId: bigint, square: number): Promise<bigint>;
|
|
682
|
+
/**
|
|
683
|
+
* Get a user's bet amount on a square for a round
|
|
684
|
+
*/
|
|
685
|
+
getUserBet(roundId: bigint, square: number, bettor: Address): Promise<bigint>;
|
|
686
|
+
/**
|
|
687
|
+
* Check if a user has claimed rewards for a round
|
|
688
|
+
*/
|
|
689
|
+
getHasClaimed(roundId: bigint, user: Address): Promise<boolean>;
|
|
690
|
+
/**
|
|
691
|
+
* Get miner state for an account
|
|
692
|
+
*/
|
|
693
|
+
getMinerState(account: Address): Promise<MinerState>;
|
|
694
|
+
/**
|
|
695
|
+
* Check if an account exists
|
|
696
|
+
*/
|
|
697
|
+
hasAccount(account: Address): Promise<boolean>;
|
|
698
|
+
/**
|
|
699
|
+
* Get carry-over winner native pool (when no winners)
|
|
700
|
+
*/
|
|
701
|
+
carryWinnerNativePool(): Promise<bigint>;
|
|
702
|
+
/**
|
|
703
|
+
* Get staker rewards that failed to distribute (owed)
|
|
704
|
+
*/
|
|
705
|
+
carryStakerNativeOwed(): Promise<bigint>;
|
|
706
|
+
/**
|
|
707
|
+
* Get jackpot funds that failed to add (owed)
|
|
708
|
+
*/
|
|
709
|
+
carryJackpotNativeOwed(): Promise<bigint>;
|
|
710
|
+
/**
|
|
711
|
+
* Get carry-over SLVR pool
|
|
712
|
+
*/
|
|
713
|
+
carrySlvrPool(): Promise<bigint>;
|
|
714
|
+
/**
|
|
715
|
+
* Get the configured SLVR-per-round value.
|
|
716
|
+
*
|
|
717
|
+
* NOTE: This is no longer the authoritative emission number. Emission is hub-gated: the amount
|
|
718
|
+
* actually minted each round is bounded by the game's streamed emission budget on SlvrHub
|
|
719
|
+
* (see SlvrHub.pendingEmission / mintReward). Treat this only as the requested/target value.
|
|
720
|
+
*/
|
|
721
|
+
slvrPerRound(): Promise<bigint>;
|
|
722
|
+
/**
|
|
723
|
+
* Get protocol fee in basis points
|
|
724
|
+
*/
|
|
725
|
+
protocolFeeBps(): Promise<number>;
|
|
726
|
+
/**
|
|
727
|
+
* Get grid size (should be 25)
|
|
728
|
+
*/
|
|
729
|
+
grid(): Promise<number>;
|
|
730
|
+
/**
|
|
731
|
+
* Get account deposit amount
|
|
732
|
+
*/
|
|
733
|
+
accountDeposit(): Promise<bigint>;
|
|
734
|
+
/**
|
|
735
|
+
* Place a bet on the current round
|
|
736
|
+
* Note: The contract will automatically handle account deposit for new accounts.
|
|
737
|
+
* If the beneficiary is a new account, ensure msg.value >= ACCOUNT_DEPOSIT + total bet amount.
|
|
738
|
+
* @param params Bet parameters
|
|
739
|
+
* @returns Transaction hash
|
|
740
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
741
|
+
* @throws ValidationError if inputs are invalid
|
|
742
|
+
* @throws ContractCallError if contract call fails
|
|
743
|
+
*/
|
|
744
|
+
bet(params: BetParams): Promise<`0x${string}`>;
|
|
745
|
+
/**
|
|
746
|
+
* Preflight a bet with `eth_call` (no transaction sent). Resolves if the bet
|
|
747
|
+
* would succeed; otherwise throws a {@link SlvrRevertError} with the decoded
|
|
748
|
+
* custom error (e.g. `RoundNotOpen`, `InsufficientValue`). Catch reverts before
|
|
749
|
+
* spending gas.
|
|
750
|
+
*/
|
|
751
|
+
simulateBet(params: BetParams): Promise<void>;
|
|
752
|
+
/**
|
|
753
|
+
* Claim rewards for a round
|
|
754
|
+
* @param params Claim parameters
|
|
755
|
+
* @returns Transaction hash
|
|
756
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
757
|
+
* @throws ValidationError if inputs are invalid
|
|
758
|
+
* @throws ContractCallError if contract call fails
|
|
759
|
+
*/
|
|
760
|
+
claim(params: ClaimParams): Promise<`0x${string}`>;
|
|
761
|
+
/**
|
|
762
|
+
* Advanced claim function covering all claim variants
|
|
763
|
+
* Handles: user vs delegate, native/SLVR recipients, bypassFee, ethOnly
|
|
764
|
+
* @param params Advanced claim parameters
|
|
765
|
+
* @returns Transaction hash
|
|
766
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
767
|
+
* @throws ValidationError if inputs are invalid
|
|
768
|
+
* @throws ContractCallError if contract call fails
|
|
769
|
+
*/
|
|
770
|
+
claimAdvanced(params: ClaimParamsAdvanced): Promise<`0x${string}`>;
|
|
771
|
+
/**
|
|
772
|
+
* Batch claim rewards for multiple rounds
|
|
773
|
+
* Note: This sends multiple transactions sequentially. For better UX, consider
|
|
774
|
+
* using a multicall contract or batching in your application layer.
|
|
775
|
+
* @param roundIds Array of round IDs to claim
|
|
776
|
+
* @param user User address to claim for (defaults to wallet client account)
|
|
777
|
+
* @param options Optional configuration
|
|
778
|
+
* @param options.waitForReceipt Whether to wait for each transaction receipt (default: false)
|
|
779
|
+
* @returns Array of transaction hashes
|
|
780
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
781
|
+
* @throws ValidationError if inputs are invalid
|
|
782
|
+
* @throws ContractCallError if contract call fails
|
|
783
|
+
*/
|
|
784
|
+
batchClaim(roundIds: bigint[], user?: Address, options?: {
|
|
785
|
+
waitForReceipt?: boolean;
|
|
786
|
+
}): Promise<`0x${string}`[]>;
|
|
787
|
+
/**
|
|
788
|
+
* Approve a delegate to claim rewards on your behalf
|
|
789
|
+
*/
|
|
790
|
+
approveDelegate(delegate: Address): Promise<`0x${string}`>;
|
|
791
|
+
/**
|
|
792
|
+
* Revoke a delegate's approval to claim on your behalf
|
|
793
|
+
*/
|
|
794
|
+
revokeDelegate(delegate: Address): Promise<`0x${string}`>;
|
|
795
|
+
/**
|
|
796
|
+
* Check if a delegate is approved for a user
|
|
797
|
+
*/
|
|
798
|
+
getDelegate(user: Address, delegate: Address): Promise<boolean>;
|
|
799
|
+
/**
|
|
800
|
+
* Donate SLVR tokens directly to the jackpot pool.
|
|
801
|
+
* Note: caller must have approved the lottery to spend `amount` of SLVR beforehand.
|
|
802
|
+
*/
|
|
803
|
+
donateSlvrToJackpot(amount: bigint): Promise<`0x${string}`>;
|
|
804
|
+
/**
|
|
805
|
+
* Add ETH (native) tokens to the jackpot pool
|
|
806
|
+
* @param value Amount of native ETH to deposit
|
|
807
|
+
*/
|
|
808
|
+
addEthToJackpot(value: bigint): Promise<`0x${string}`>;
|
|
809
|
+
/**
|
|
810
|
+
* Withdraw your accumulated mined SLVR (the "refine and cash out" path).
|
|
811
|
+
*
|
|
812
|
+
* Settles your miner accrual (auto-checkpoints) and transfers your SLVR out,
|
|
813
|
+
* net of the refining fee. This is the function a mining bot wants to realize
|
|
814
|
+
* SLVR rewards outside of a specific round claim. Reverts if you have nothing to
|
|
815
|
+
* withdraw. The exact `(totalPayout, refiningFee)` are in the emitted `Claimed`
|
|
816
|
+
* event; this returns the transaction hash.
|
|
817
|
+
*/
|
|
818
|
+
withdrawUnrefinedSlvr(): Promise<`0x${string}`>;
|
|
819
|
+
/**
|
|
820
|
+
* Force on-chain settlement of a miner's refined-reward accrual (lazy
|
|
821
|
+
* "checkpoint"). Permissionless — you can checkpoint any account.
|
|
822
|
+
*
|
|
823
|
+
* This only updates accounting (rolls index growth into `refinedAccrued`); it
|
|
824
|
+
* moves no tokens. You rarely need it: `claim` and {@link withdrawUnrefinedSlvr}
|
|
825
|
+
* both checkpoint internally, and the up-to-date figure can be derived off-chain
|
|
826
|
+
* from {@link getMinerState}. Use it when you want state settled without a
|
|
827
|
+
* claim/withdraw — e.g. to make a subsequent `getMinerState` read exact.
|
|
828
|
+
*/
|
|
829
|
+
checkpoint(account: Address): Promise<`0x${string}`>;
|
|
830
|
+
/**
|
|
831
|
+
* Get all square data for a round
|
|
832
|
+
*/
|
|
833
|
+
getRoundSquares(roundId: bigint): Promise<Array<{
|
|
834
|
+
square: number;
|
|
835
|
+
total: bigint;
|
|
836
|
+
bettors: bigint;
|
|
837
|
+
}>>;
|
|
838
|
+
/**
|
|
839
|
+
* Get user's bets for a round
|
|
840
|
+
*/
|
|
841
|
+
getUserBets(roundId: bigint, user: Address): Promise<Array<{
|
|
842
|
+
square: number;
|
|
843
|
+
amount: bigint;
|
|
844
|
+
}>>;
|
|
845
|
+
/**
|
|
846
|
+
* Wait until a round is resolved, resolving with its final {@link RoundInfo}.
|
|
847
|
+
* Polls `getRound` on an interval — handy for "bet, then claim once it settles".
|
|
848
|
+
*
|
|
849
|
+
* @param opts.pollIntervalMs how often to check (default 4000)
|
|
850
|
+
* @param opts.timeoutMs give up after this long (default: wait indefinitely)
|
|
851
|
+
* @throws {Error} if `timeoutMs` elapses before resolution
|
|
852
|
+
*/
|
|
853
|
+
waitForResolution(roundId: bigint, opts?: {
|
|
854
|
+
pollIntervalMs?: number;
|
|
855
|
+
timeoutMs?: number;
|
|
856
|
+
}): Promise<RoundInfo>;
|
|
857
|
+
/**
|
|
858
|
+
* Subscribe to `RoundResolved` events. Returns an unsubscribe function.
|
|
859
|
+
*
|
|
860
|
+
* @example
|
|
861
|
+
* ```typescript
|
|
862
|
+
* const stop = sdk.lottery.watchRoundResolved((e) => {
|
|
863
|
+
* console.log(`round ${e.roundId} won by square ${e.winningSquare}`);
|
|
864
|
+
* });
|
|
865
|
+
* // later: stop();
|
|
866
|
+
* ```
|
|
867
|
+
*/
|
|
868
|
+
watchRoundResolved(onResolved: (event: RoundResolvedEvent['args']) => void, opts?: {
|
|
869
|
+
onError?: (error: Error) => void;
|
|
870
|
+
}): () => void;
|
|
871
|
+
/**
|
|
872
|
+
* Subscribe to `BetPlaced` events (optionally for one round). Returns an
|
|
873
|
+
* unsubscribe function. Useful for reacting to pot changes in real time.
|
|
874
|
+
*/
|
|
875
|
+
watchBets(onBet: (event: BetPlacedEvent['args']) => void, opts?: {
|
|
876
|
+
roundId?: bigint;
|
|
877
|
+
onError?: (error: Error) => void;
|
|
878
|
+
}): () => void;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* SlvrVoteEscrowStaking contract interface.
|
|
883
|
+
*
|
|
884
|
+
* This is a veNFT-based staker: stakers deposit a vote-escrow NFT (by tokenId) rather than a raw
|
|
885
|
+
* ERC20 amount. Rewards accrue per unit of the token's tracked weight and are claimed per tokenId.
|
|
886
|
+
*/
|
|
887
|
+
declare class SlvrStaking {
|
|
888
|
+
private publicClient;
|
|
889
|
+
private walletClient?;
|
|
890
|
+
private address;
|
|
891
|
+
private static readonly ABI;
|
|
892
|
+
constructor(publicClient: PublicClient, walletClient: WalletClient | undefined, address: Address);
|
|
893
|
+
/**
|
|
894
|
+
* Update the wallet client
|
|
895
|
+
* @param walletClient New wallet client
|
|
896
|
+
*/
|
|
897
|
+
setWalletClient(walletClient: WalletClient | undefined): void;
|
|
898
|
+
/**
|
|
899
|
+
* Get claimable rewards for a staked veNFT tokenId
|
|
900
|
+
*/
|
|
901
|
+
getStakerRewards(tokenId: bigint): Promise<bigint>;
|
|
902
|
+
/**
|
|
903
|
+
* Get the total tracked weight across all staked tokens
|
|
904
|
+
*/
|
|
905
|
+
getTotalWeight(): Promise<bigint>;
|
|
906
|
+
/**
|
|
907
|
+
* Get the accumulated reward per unit of weight (1e18 precision)
|
|
908
|
+
*/
|
|
909
|
+
rewardPerWeightStored(): Promise<bigint>;
|
|
910
|
+
/**
|
|
911
|
+
* Get the last rewardPerWeightStored snapshot recorded for a tokenId
|
|
912
|
+
*/
|
|
913
|
+
rewardPerWeightPaid(tokenId: bigint): Promise<bigint>;
|
|
914
|
+
/**
|
|
915
|
+
* Get the tracked weight (balance) for a staked tokenId
|
|
916
|
+
*/
|
|
917
|
+
balance(tokenId: bigint): Promise<bigint>;
|
|
918
|
+
/**
|
|
919
|
+
* Get the accrued (checkpointed) claimable rewards stored for a tokenId
|
|
920
|
+
*/
|
|
921
|
+
rewards(tokenId: bigint): Promise<bigint>;
|
|
922
|
+
/**
|
|
923
|
+
* Get the total tracked weight (public storage var)
|
|
924
|
+
*/
|
|
925
|
+
totalWeight(): Promise<bigint>;
|
|
926
|
+
/**
|
|
927
|
+
* Get unallocated rewards (distributed while no weight was staked)
|
|
928
|
+
*/
|
|
929
|
+
unallocated(): Promise<bigint>;
|
|
930
|
+
/**
|
|
931
|
+
* Get the last distributed round ID (type(uint256).max sentinel when none)
|
|
932
|
+
*/
|
|
933
|
+
lastDistributedRoundId(): Promise<bigint>;
|
|
934
|
+
/**
|
|
935
|
+
* Get the lottery address authorized to distribute rewards
|
|
936
|
+
*/
|
|
937
|
+
lottery(): Promise<Address>;
|
|
938
|
+
/**
|
|
939
|
+
* Get complete staking info for a staked veNFT tokenId
|
|
940
|
+
*/
|
|
941
|
+
getStakingInfo(tokenId: bigint): Promise<StakingInfo>;
|
|
942
|
+
/**
|
|
943
|
+
* Stake a vote-escrow NFT by tokenId
|
|
944
|
+
* @param tokenId The veNFT token ID to stake
|
|
945
|
+
* @returns Transaction hash
|
|
946
|
+
*/
|
|
947
|
+
stake(tokenId: bigint): Promise<`0x${string}`>;
|
|
948
|
+
/**
|
|
949
|
+
* Unstake a vote-escrow NFT by tokenId
|
|
950
|
+
* @param tokenId The veNFT token ID to unstake
|
|
951
|
+
* @returns Transaction hash
|
|
952
|
+
*/
|
|
953
|
+
unstake(tokenId: bigint): Promise<`0x${string}`>;
|
|
954
|
+
/**
|
|
955
|
+
* Claim staker rewards for a tokenId
|
|
956
|
+
* @param tokenId The veNFT token ID to claim rewards for
|
|
957
|
+
* @returns Transaction hash
|
|
958
|
+
*/
|
|
959
|
+
claimStakerRewards(tokenId: bigint): Promise<`0x${string}`>;
|
|
960
|
+
/**
|
|
961
|
+
* Checkpoint a token's reward accounting
|
|
962
|
+
* @param tokenId The veNFT token ID to checkpoint
|
|
963
|
+
* @returns Transaction hash
|
|
964
|
+
*/
|
|
965
|
+
checkpoint(tokenId: bigint): Promise<`0x${string}`>;
|
|
966
|
+
/**
|
|
967
|
+
* Poke a token to refresh its tracked weight
|
|
968
|
+
* @param tokenId The veNFT token ID to poke
|
|
969
|
+
* @returns Transaction hash
|
|
970
|
+
*/
|
|
971
|
+
poke(tokenId: bigint): Promise<`0x${string}`>;
|
|
972
|
+
/**
|
|
973
|
+
* Poke many tokens to refresh their tracked weight in one call
|
|
974
|
+
* @param tokenIds The veNFT token IDs to poke
|
|
975
|
+
* @returns Transaction hash
|
|
976
|
+
*/
|
|
977
|
+
pokeMany(tokenIds: bigint[]): Promise<`0x${string}`>;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* SlvrToken contract interface
|
|
982
|
+
*/
|
|
983
|
+
declare class SlvrToken {
|
|
984
|
+
private publicClient;
|
|
985
|
+
private walletClient?;
|
|
986
|
+
private address;
|
|
987
|
+
private static readonly ABI;
|
|
988
|
+
constructor(publicClient: PublicClient, walletClient: WalletClient | undefined, address: Address);
|
|
989
|
+
/**
|
|
990
|
+
* Update the wallet client
|
|
991
|
+
* @param walletClient New wallet client
|
|
992
|
+
*/
|
|
993
|
+
setWalletClient(walletClient: WalletClient | undefined): void;
|
|
994
|
+
/**
|
|
995
|
+
* Get total supply
|
|
996
|
+
*/
|
|
997
|
+
totalSupply(): Promise<bigint>;
|
|
998
|
+
/**
|
|
999
|
+
* Get balance of an account
|
|
1000
|
+
*/
|
|
1001
|
+
balanceOf(account: Address): Promise<bigint>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Get allowance
|
|
1004
|
+
*/
|
|
1005
|
+
allowance(owner: Address, spender: Address): Promise<bigint>;
|
|
1006
|
+
/**
|
|
1007
|
+
* Get token name
|
|
1008
|
+
*/
|
|
1009
|
+
name(): Promise<string>;
|
|
1010
|
+
/**
|
|
1011
|
+
* Get token symbol
|
|
1012
|
+
*/
|
|
1013
|
+
symbol(): Promise<string>;
|
|
1014
|
+
/**
|
|
1015
|
+
* Get token decimals
|
|
1016
|
+
*/
|
|
1017
|
+
decimals(): Promise<number>;
|
|
1018
|
+
/**
|
|
1019
|
+
* Get maximum supply
|
|
1020
|
+
*/
|
|
1021
|
+
maxSupply(): Promise<bigint>;
|
|
1022
|
+
/**
|
|
1023
|
+
* Transfer tokens
|
|
1024
|
+
* @param to Recipient address
|
|
1025
|
+
* @param amount Amount to transfer
|
|
1026
|
+
* @returns Transaction hash
|
|
1027
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1028
|
+
* @throws ValidationError if inputs are invalid
|
|
1029
|
+
* @throws ContractCallError if contract call fails
|
|
1030
|
+
*/
|
|
1031
|
+
transfer(to: Address, amount: bigint): Promise<`0x${string}`>;
|
|
1032
|
+
/**
|
|
1033
|
+
* Approve spender
|
|
1034
|
+
* @param spender Address to approve
|
|
1035
|
+
* @param amount Amount to approve
|
|
1036
|
+
* @returns Transaction hash
|
|
1037
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1038
|
+
* @throws ValidationError if inputs are invalid
|
|
1039
|
+
* @throws ContractCallError if contract call fails
|
|
1040
|
+
*/
|
|
1041
|
+
approve(spender: Address, amount: bigint): Promise<`0x${string}`>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Transfer from (requires approval)
|
|
1044
|
+
* @param from Sender address
|
|
1045
|
+
* @param to Recipient address
|
|
1046
|
+
* @param amount Amount to transfer
|
|
1047
|
+
* @returns Transaction hash
|
|
1048
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1049
|
+
* @throws ValidationError if inputs are invalid
|
|
1050
|
+
* @throws ContractCallError if contract call fails
|
|
1051
|
+
*/
|
|
1052
|
+
transferFrom(from: Address, to: Address, amount: bigint): Promise<`0x${string}`>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Burn tokens
|
|
1055
|
+
* @param amount Amount to burn
|
|
1056
|
+
* @returns Transaction hash
|
|
1057
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1058
|
+
* @throws ValidationError if amount is invalid
|
|
1059
|
+
* @throws ContractCallError if contract call fails
|
|
1060
|
+
*/
|
|
1061
|
+
burn(amount: bigint): Promise<`0x${string}`>;
|
|
1062
|
+
/**
|
|
1063
|
+
* Burn tokens from account
|
|
1064
|
+
* @param account Account to burn from
|
|
1065
|
+
* @param amount Amount to burn
|
|
1066
|
+
* @returns Transaction hash
|
|
1067
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1068
|
+
* @throws ValidationError if inputs are invalid
|
|
1069
|
+
* @throws ContractCallError if contract call fails
|
|
1070
|
+
*/
|
|
1071
|
+
burnFrom(account: Address, amount: bigint): Promise<`0x${string}`>;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* SlvrAutoCommitV2 contract interface
|
|
1076
|
+
*
|
|
1077
|
+
* V2 economics: executors calling executeFor/claimFor are reimbursed their
|
|
1078
|
+
* metered gas (plus a premium, capped at maxFeePerExecution — both owner-tunable
|
|
1079
|
+
* within hard ceilings) from the user's plan balance — there is no flat
|
|
1080
|
+
* AUTOMATION_FEE and the execution functions are nonpayable. Claimable winning
|
|
1081
|
+
* rounds are discovered off-chain and passed in explicitly via claimRounds.
|
|
1082
|
+
*/
|
|
1083
|
+
declare class SlvrAutoCommit {
|
|
1084
|
+
private publicClient;
|
|
1085
|
+
private walletClient?;
|
|
1086
|
+
private address;
|
|
1087
|
+
private static readonly ABI;
|
|
1088
|
+
constructor(publicClient: PublicClient, walletClient: WalletClient | undefined, address: Address);
|
|
1089
|
+
/**
|
|
1090
|
+
* Update the wallet client
|
|
1091
|
+
* @param walletClient New wallet client
|
|
1092
|
+
*/
|
|
1093
|
+
setWalletClient(walletClient: WalletClient | undefined): void;
|
|
1094
|
+
/**
|
|
1095
|
+
* Get plan information for a user
|
|
1096
|
+
*/
|
|
1097
|
+
planInfo(user: Address): Promise<AutoCommitPlan>;
|
|
1098
|
+
/**
|
|
1099
|
+
* Check whether a plan is ready to execute, and if not, why
|
|
1100
|
+
*/
|
|
1101
|
+
needsExecution(user: Address): Promise<{
|
|
1102
|
+
ready: boolean;
|
|
1103
|
+
reason: string;
|
|
1104
|
+
}>;
|
|
1105
|
+
/**
|
|
1106
|
+
* Check whether a specific round has already been executed for a user
|
|
1107
|
+
*/
|
|
1108
|
+
executedRound(user: Address, roundId: bigint): Promise<boolean>;
|
|
1109
|
+
/**
|
|
1110
|
+
* Get lottery contract address
|
|
1111
|
+
*/
|
|
1112
|
+
lottery(): Promise<Address>;
|
|
1113
|
+
/**
|
|
1114
|
+
* Get the sentinel plays value meaning "unlimited plays"
|
|
1115
|
+
*/
|
|
1116
|
+
unlimitedPlays(): Promise<number>;
|
|
1117
|
+
/**
|
|
1118
|
+
* Get max plays per execution
|
|
1119
|
+
*/
|
|
1120
|
+
maxPlaysPerExecution(): Promise<number>;
|
|
1121
|
+
/**
|
|
1122
|
+
* Get max claim rounds accepted per execution
|
|
1123
|
+
*/
|
|
1124
|
+
maxClaimsPerExecution(): Promise<bigint>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Get the current cap on the executor fee reimbursed per execution
|
|
1127
|
+
* (owner-tunable within the contract's hard ceiling)
|
|
1128
|
+
*/
|
|
1129
|
+
maxFeePerExecution(): Promise<bigint>;
|
|
1130
|
+
/**
|
|
1131
|
+
* Get the current executor-fee premium in basis points
|
|
1132
|
+
* (owner-tunable within the contract's hard ceiling)
|
|
1133
|
+
*/
|
|
1134
|
+
feePremiumBps(): Promise<number>;
|
|
1135
|
+
/**
|
|
1136
|
+
* Deposit native tokens to auto-commit plan
|
|
1137
|
+
* @param value Amount to deposit
|
|
1138
|
+
* @returns Transaction hash
|
|
1139
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1140
|
+
* @throws ValidationError if amount is invalid
|
|
1141
|
+
* @throws ContractCallError if contract call fails
|
|
1142
|
+
*/
|
|
1143
|
+
deposit(value: bigint): Promise<`0x${string}`>;
|
|
1144
|
+
/**
|
|
1145
|
+
* Withdraw from auto-commit plan
|
|
1146
|
+
* @param amount Amount to withdraw
|
|
1147
|
+
* @param to Recipient address
|
|
1148
|
+
* @returns Transaction hash
|
|
1149
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1150
|
+
* @throws ValidationError if inputs are invalid
|
|
1151
|
+
* @throws ContractCallError if contract call fails
|
|
1152
|
+
*/
|
|
1153
|
+
withdraw(amount: bigint, to: Address): Promise<`0x${string}`>;
|
|
1154
|
+
/**
|
|
1155
|
+
* Configure auto-commit plan
|
|
1156
|
+
* @param plays Number of plays (UNLIMITED_PLAYS = 4294967295 for unlimited;
|
|
1157
|
+
* forced to unlimited on-chain when autoClaim is true)
|
|
1158
|
+
* @param amountPerPlay Amount per play
|
|
1159
|
+
* @param squares Square indices to bet on
|
|
1160
|
+
* @param bpsAlloc Basis points allocation for each square (must sum to 10000)
|
|
1161
|
+
* @param autoClaim Whether the keeper should claim winnings back into the plan balance
|
|
1162
|
+
* @returns Transaction hash
|
|
1163
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1164
|
+
* @throws ValidationError if inputs are invalid
|
|
1165
|
+
* @throws ContractCallError if contract call fails
|
|
1166
|
+
*/
|
|
1167
|
+
configurePlan(plays: number, amountPerPlay: bigint, squares: number[], bpsAlloc: number[], autoClaim: boolean): Promise<`0x${string}`>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Configure auto-commit plan and deposit funds in a single transaction
|
|
1170
|
+
* @param plays Number of plays (see configurePlan)
|
|
1171
|
+
* @param amountPerPlay Amount per play
|
|
1172
|
+
* @param squares Square indices to bet on
|
|
1173
|
+
* @param bpsAlloc Basis points allocation for each square (must sum to 10000)
|
|
1174
|
+
* @param autoClaim Whether the keeper should claim winnings back into the plan balance
|
|
1175
|
+
* @param value Amount to deposit
|
|
1176
|
+
* @returns Transaction hash
|
|
1177
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1178
|
+
* @throws ValidationError if inputs are invalid
|
|
1179
|
+
* @throws ContractCallError if contract call fails
|
|
1180
|
+
*/
|
|
1181
|
+
configurePlanAndDeposit(plays: number, amountPerPlay: bigint, squares: number[], bpsAlloc: number[], autoClaim: boolean, value: bigint): Promise<`0x${string}`>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Disable auto-commit plan
|
|
1184
|
+
* @returns Transaction hash
|
|
1185
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1186
|
+
* @throws ContractCallError if contract call fails
|
|
1187
|
+
*/
|
|
1188
|
+
disablePlan(): Promise<`0x${string}`>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Cancel the plan and refund the entire remaining balance to the caller
|
|
1191
|
+
* @returns Transaction hash
|
|
1192
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1193
|
+
* @throws ContractCallError if contract call fails
|
|
1194
|
+
*/
|
|
1195
|
+
cancelPlan(): Promise<`0x${string}`>;
|
|
1196
|
+
/**
|
|
1197
|
+
* Execute auto-commit plan for a user (anyone can call).
|
|
1198
|
+
* The caller is reimbursed metered gas + premium from the user's plan balance.
|
|
1199
|
+
* @param user User address
|
|
1200
|
+
* @param maxPlays Maximum number of plays to execute
|
|
1201
|
+
* @param claimRounds Winning round ids to claim into the plan balance before
|
|
1202
|
+
* betting (discovered off-chain; non-claimable entries are no-ops)
|
|
1203
|
+
* @returns Transaction hash
|
|
1204
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1205
|
+
* @throws ValidationError if inputs are invalid
|
|
1206
|
+
* @throws ContractCallError if contract call fails
|
|
1207
|
+
*/
|
|
1208
|
+
executeFor(user: Address, maxPlays: number, claimRounds?: bigint[]): Promise<`0x${string}`>;
|
|
1209
|
+
/**
|
|
1210
|
+
* Claim winning rounds into a user's plan balance without betting (anyone can
|
|
1211
|
+
* call). Useful when the plan balance is too low to bet until winnings land.
|
|
1212
|
+
* @param user User address
|
|
1213
|
+
* @param claimRounds Winning round ids to claim (discovered off-chain)
|
|
1214
|
+
* @returns Transaction hash
|
|
1215
|
+
* @throws WalletClientRequiredError if wallet client is not available
|
|
1216
|
+
* @throws ValidationError if inputs are invalid
|
|
1217
|
+
* @throws ContractCallError if contract call fails
|
|
1218
|
+
*/
|
|
1219
|
+
claimFor(user: Address, claimRounds: bigint[]): Promise<`0x${string}`>;
|
|
1220
|
+
private validatePlanConfig;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* SlvrHub contract interface (read-only).
|
|
1225
|
+
*
|
|
1226
|
+
* The hub is the protocol emission/sink router: it gates per-game SLVR emission, fans many games
|
|
1227
|
+
* into one shared veNFT staker stream, and into one shared jackpot. These bindings expose the
|
|
1228
|
+
* informational view surface (emission rate, pending emission, sink addresses); the hub's
|
|
1229
|
+
* fee-routing writes are keeper/protocol operations and are intentionally not included.
|
|
1230
|
+
*/
|
|
1231
|
+
declare class SlvrHub {
|
|
1232
|
+
private publicClient;
|
|
1233
|
+
private address;
|
|
1234
|
+
private static readonly ABI;
|
|
1235
|
+
constructor(publicClient: PublicClient, _walletClient: WalletClient | undefined, address: Address);
|
|
1236
|
+
setWalletClient(_walletClient: WalletClient | undefined): void;
|
|
1237
|
+
/**
|
|
1238
|
+
* Accrued-but-unminted SLVR emission currently available to a game (its bucket + streamed since
|
|
1239
|
+
* last accrual, hard-capped at one maxAccrualSeconds window of the game's effective rate).
|
|
1240
|
+
*/
|
|
1241
|
+
pendingEmission(gameId: bigint): Promise<bigint>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Base SLVR/sec emission rate across the whole active game set
|
|
1244
|
+
*/
|
|
1245
|
+
emissionRatePerSec(): Promise<bigint>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Soft-cap target supply (0 => use token MAX_SUPPLY)
|
|
1248
|
+
*/
|
|
1249
|
+
targetSupply(): Promise<bigint>;
|
|
1250
|
+
/**
|
|
1251
|
+
* Idle-forfeiture window: cap on dt per accrual (seconds)
|
|
1252
|
+
*/
|
|
1253
|
+
maxAccrualSeconds(): Promise<bigint>;
|
|
1254
|
+
/**
|
|
1255
|
+
* Address of the shared veNFT staking contract
|
|
1256
|
+
*/
|
|
1257
|
+
staking(): Promise<Address>;
|
|
1258
|
+
/**
|
|
1259
|
+
* Address of the shared jackpot contract
|
|
1260
|
+
*/
|
|
1261
|
+
jackpot(): Promise<Address>;
|
|
1262
|
+
/**
|
|
1263
|
+
* Hub-owned sequential counter used to feed the staking contract's round numbering
|
|
1264
|
+
*/
|
|
1265
|
+
stakerSeq(): Promise<bigint>;
|
|
1266
|
+
/**
|
|
1267
|
+
* Native staker rewards received but not yet flushed to the staking stream
|
|
1268
|
+
*/
|
|
1269
|
+
pendingStakerRewards(): Promise<bigint>;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* SlvrGameRegistry contract interface (read-only surface).
|
|
1274
|
+
*
|
|
1275
|
+
* Single source of truth for which games exist, their status/tier, and their share of the shared
|
|
1276
|
+
* emission stream.
|
|
1277
|
+
*/
|
|
1278
|
+
declare class SlvrGameRegistry {
|
|
1279
|
+
private publicClient;
|
|
1280
|
+
private address;
|
|
1281
|
+
private static readonly ABI;
|
|
1282
|
+
constructor(publicClient: PublicClient, _walletClient: WalletClient | undefined, address: Address);
|
|
1283
|
+
/** Read-only contract: no wallet client needed. Kept for a consistent SDK surface. */
|
|
1284
|
+
setWalletClient(_walletClient: WalletClient | undefined): void;
|
|
1285
|
+
/**
|
|
1286
|
+
* Registry id for a game address (0 if not registered; ids are 1-based)
|
|
1287
|
+
*/
|
|
1288
|
+
gameIdOf(game: Address): Promise<bigint>;
|
|
1289
|
+
/**
|
|
1290
|
+
* Full record for a game id
|
|
1291
|
+
*/
|
|
1292
|
+
gameInfo(gameId: bigint): Promise<GameInfo>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Is this address a registered, Active game?
|
|
1295
|
+
*/
|
|
1296
|
+
isActive(game: Address): Promise<boolean>;
|
|
1297
|
+
/**
|
|
1298
|
+
* Status enum for a game id
|
|
1299
|
+
*/
|
|
1300
|
+
statusOf(gameId: bigint): Promise<GameStatus>;
|
|
1301
|
+
/**
|
|
1302
|
+
* Tier enum for a game id
|
|
1303
|
+
*/
|
|
1304
|
+
tierOf(gameId: bigint): Promise<GameTier>;
|
|
1305
|
+
/**
|
|
1306
|
+
* Emission weight (relative share of the global stream) for a game id
|
|
1307
|
+
*/
|
|
1308
|
+
weightOf(gameId: bigint): Promise<bigint>;
|
|
1309
|
+
/**
|
|
1310
|
+
* Max realized-fraction ceiling (bps of 10000) for a game id
|
|
1311
|
+
*/
|
|
1312
|
+
maxWeightBpsOf(gameId: bigint): Promise<number>;
|
|
1313
|
+
/**
|
|
1314
|
+
* Sum of emissionWeight across all Active games (denominator for the split)
|
|
1315
|
+
*/
|
|
1316
|
+
totalActiveWeight(): Promise<bigint>;
|
|
1317
|
+
/**
|
|
1318
|
+
* Number of registered games
|
|
1319
|
+
*/
|
|
1320
|
+
gameCount(): Promise<bigint>;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* SlvrJackpot contract interface (read-only pool surface).
|
|
1325
|
+
*/
|
|
1326
|
+
declare class SlvrJackpot {
|
|
1327
|
+
private publicClient;
|
|
1328
|
+
private address;
|
|
1329
|
+
private static readonly ABI;
|
|
1330
|
+
constructor(publicClient: PublicClient, _walletClient: WalletClient | undefined, address: Address);
|
|
1331
|
+
/** Read-only contract: no wallet client needed. Kept for a consistent SDK surface. */
|
|
1332
|
+
setWalletClient(_walletClient: WalletClient | undefined): void;
|
|
1333
|
+
/**
|
|
1334
|
+
* Native (ETH) jackpot pool balance
|
|
1335
|
+
*/
|
|
1336
|
+
jackpotPool(): Promise<bigint>;
|
|
1337
|
+
/**
|
|
1338
|
+
* SLVR jackpot pool balance
|
|
1339
|
+
*/
|
|
1340
|
+
jackpotSlvrPool(): Promise<bigint>;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/**
|
|
1344
|
+
* Reserves of the SLVR/ETH UniswapV2 pair, with the token ordering resolved.
|
|
1345
|
+
*/
|
|
1346
|
+
interface SlvrReserves {
|
|
1347
|
+
/** SLVR reserve, in wei (18 decimals). */
|
|
1348
|
+
slvrReserve: bigint;
|
|
1349
|
+
/** ETH (WETH) reserve, in wei (18 decimals). */
|
|
1350
|
+
ethReserve: bigint;
|
|
1351
|
+
/** Whether SLVR is `token0` in the pair (ordering is resolved for you). */
|
|
1352
|
+
token0IsSlvr: boolean;
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Reads the SLVR price from the SLVR/ETH UniswapV2 pair.
|
|
1356
|
+
*
|
|
1357
|
+
* Mirrors the web app's price logic: it reads the pair's `getReserves()` and
|
|
1358
|
+
* `token0()`, figures out which reserve is SLVR (never assumes ordering), and
|
|
1359
|
+
* prices SLVR as `ethReserve / slvrReserve`. Both tokens are 18-decimal, so the
|
|
1360
|
+
* raw reserve ratio is already ETH-per-SLVR.
|
|
1361
|
+
*
|
|
1362
|
+
* This is a **spot** price straight from reserves — no TWAP, no slippage model.
|
|
1363
|
+
* Fine for sizing bets and EV estimates; do not use it as an oracle for anything
|
|
1364
|
+
* that must resist manipulation.
|
|
1365
|
+
*
|
|
1366
|
+
* @example
|
|
1367
|
+
* ```typescript
|
|
1368
|
+
* import { SlvrPrice } from '@slvr-labs/sdk';
|
|
1369
|
+
* const price = new SlvrPrice(publicClient, pairAddress, slvrTokenAddress);
|
|
1370
|
+
* const ethPerSlvr = await price.getPriceInEth();
|
|
1371
|
+
* ```
|
|
1372
|
+
*/
|
|
1373
|
+
declare class SlvrPrice {
|
|
1374
|
+
private publicClient;
|
|
1375
|
+
private pairAddress;
|
|
1376
|
+
private slvrTokenAddress;
|
|
1377
|
+
private static readonly PAIR_ABI;
|
|
1378
|
+
constructor(publicClient: PublicClient, pairAddress: Address, slvrTokenAddress: Address);
|
|
1379
|
+
/** Read the pair reserves and resolve which side is SLVR. */
|
|
1380
|
+
getReserves(): Promise<SlvrReserves>;
|
|
1381
|
+
/**
|
|
1382
|
+
* SLVR price in ETH (ETH per SLVR), as a floating-point number.
|
|
1383
|
+
* @throws {Error} if the pair has no SLVR liquidity (zero reserve).
|
|
1384
|
+
*/
|
|
1385
|
+
getPriceInEth(): Promise<number>;
|
|
1386
|
+
/**
|
|
1387
|
+
* SLVR price in ETH as a WAD (1e18-scaled `bigint`), for callers that want to
|
|
1388
|
+
* stay in integer math: `priceWad = ethReserve * 1e18 / slvrReserve`.
|
|
1389
|
+
* @throws {Error} if the pair has no SLVR liquidity (zero reserve).
|
|
1390
|
+
*/
|
|
1391
|
+
getPriceInEthWad(): Promise<bigint>;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* Reads a Chainlink-style price feed (`AggregatorV3Interface`).
|
|
1396
|
+
*
|
|
1397
|
+
* Works with any standard aggregator — the canonical use here is an **ETH/USD**
|
|
1398
|
+
* feed, which lets the SDK convert the pair-derived SLVR/ETH price into USD.
|
|
1399
|
+
*
|
|
1400
|
+
* Robinhood Chain has a Chainlink ETH/USD feed (`ETH / USD`, 8 decimals), wired
|
|
1401
|
+
* into `deployments.robinhood.addresses.chainlinkEthUsd`, so `sdk.ethUsd` and USD
|
|
1402
|
+
* prices work out of the box there. On chains without a feed, pass a USD price
|
|
1403
|
+
* into {@link SlvrSDK.getSlvrPrice} instead, or wire your own off-chain source.
|
|
1404
|
+
*
|
|
1405
|
+
* @example
|
|
1406
|
+
* ```typescript
|
|
1407
|
+
* import { ChainlinkPriceFeed } from '@slvr-labs/sdk';
|
|
1408
|
+
* const ethUsd = new ChainlinkPriceFeed(publicClient, ethUsdFeedAddress);
|
|
1409
|
+
* const price = await ethUsd.getPrice(); // e.g. 1797.35
|
|
1410
|
+
* ```
|
|
1411
|
+
*/
|
|
1412
|
+
declare class ChainlinkPriceFeed {
|
|
1413
|
+
private publicClient;
|
|
1414
|
+
private feedAddress;
|
|
1415
|
+
private maxStalenessSec?;
|
|
1416
|
+
private static readonly ABI;
|
|
1417
|
+
/**
|
|
1418
|
+
* @param publicClient viem public client
|
|
1419
|
+
* @param feedAddress the aggregator address
|
|
1420
|
+
* @param opts.maxStalenessSec if set, {@link getPrice} throws when the feed's
|
|
1421
|
+
* `updatedAt` is older than this many seconds (checked against the local
|
|
1422
|
+
* clock). Off by default — enable it only where the local clock is trusted.
|
|
1423
|
+
*/
|
|
1424
|
+
constructor(publicClient: PublicClient, feedAddress: Address, opts?: {
|
|
1425
|
+
maxStalenessSec?: number;
|
|
1426
|
+
});
|
|
1427
|
+
/** Raw `latestRoundData` answer plus the feed's decimals. */
|
|
1428
|
+
getRoundData(): Promise<{
|
|
1429
|
+
answer: bigint;
|
|
1430
|
+
decimals: number;
|
|
1431
|
+
updatedAt: bigint;
|
|
1432
|
+
}>;
|
|
1433
|
+
/**
|
|
1434
|
+
* The feed price as a floating-point number (`answer / 10 ** decimals`).
|
|
1435
|
+
* @throws {Error} if the answer is non-positive, or (when `maxStalenessSec` is
|
|
1436
|
+
* set) if the feed is stale.
|
|
1437
|
+
*/
|
|
1438
|
+
getPrice(): Promise<number>;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
/**
|
|
1442
|
+
* Expected-value math for SLVR grid mining.
|
|
1443
|
+
*
|
|
1444
|
+
* This is a direct port of the protocol's "grid-mining edge" model — the same
|
|
1445
|
+
* math the web calculator uses — so an SDK bot and the site agree.
|
|
1446
|
+
*
|
|
1447
|
+
* ## The model
|
|
1448
|
+
*
|
|
1449
|
+
* The winning square each round is chosen **uniformly** at random over the
|
|
1450
|
+
* {@link GRID_SIZE}-square grid (`randomnessValue % 25`), independent of how much
|
|
1451
|
+
* was wagered where. Wagers only decide how the pot is split *among* the winners.
|
|
1452
|
+
*
|
|
1453
|
+
* The strategy this models is **grid mining**: spread your stake across the grid
|
|
1454
|
+
* in proportion to the current pot so you always hold a `share = stake / pot`
|
|
1455
|
+
* slice of whichever square wins. Under that strategy, per round:
|
|
1456
|
+
*
|
|
1457
|
+
* - **ETH is a wash minus the protocol fee.** The whole pot minus the fee is paid
|
|
1458
|
+
* pro-rata to the winning square, and your slice of it equals your slice of the
|
|
1459
|
+
* pot — i.e. you get back `(1 - fee) * stake` in expectation. So your ETH cost
|
|
1460
|
+
* ("bleed") is exactly `feeFraction * stake`.
|
|
1461
|
+
* - **SLVR is mined pro-rata:** `slvrMined = share * emissionPerRound`. (Whether a
|
|
1462
|
+
* round is "single-miner" — winner-take-all SLVR — changes the *variance*, not
|
|
1463
|
+
* the mean, so it does not affect EV.)
|
|
1464
|
+
* - **Jackpot** pays your `share` of the pool with probability `1 / jackpotOdds`.
|
|
1465
|
+
*
|
|
1466
|
+
* Net EV per round (in ETH):
|
|
1467
|
+
*
|
|
1468
|
+
* ```
|
|
1469
|
+
* netEth = slvrMined * slvrPriceEth * realize // SLVR value (realize = 1 - refineFee when cashing out)
|
|
1470
|
+
* - feeFraction * stake // ETH bleed
|
|
1471
|
+
* + (1 / jackpotOdds) * share * jackpotPool
|
|
1472
|
+
* ```
|
|
1473
|
+
*
|
|
1474
|
+
* Because both the SLVR reward and the bleed scale with `stake`, **the edge does
|
|
1475
|
+
* not depend on how much you bet** — only on `pot` vs `slvrPriceEth`. A smaller
|
|
1476
|
+
* pot means a bigger `share`, so mining is profitable while the pot is *below* the
|
|
1477
|
+
* {@link GridMiningEv.breakEvenPot break-even pot}.
|
|
1478
|
+
*/
|
|
1479
|
+
/** Grid size — the winning square is `randomnessValue % GRID_SIZE`. */
|
|
1480
|
+
declare const GRID_SIZE = 25;
|
|
1481
|
+
/** Probability any one square wins a round (uniform selection). */
|
|
1482
|
+
declare const SINGLE_SQUARE_WIN_PROBABILITY: number;
|
|
1483
|
+
/** Default protocol fee in basis points (10%), taken out of the pot before winners. */
|
|
1484
|
+
declare const PROTOCOL_FEE_BPS = 1000;
|
|
1485
|
+
/** Default SLVR refining fee in basis points (10%), charged when you cash SLVR out to ETH. */
|
|
1486
|
+
declare const REFINING_FEE_BPS = 1000;
|
|
1487
|
+
/** Default jackpot odds — the jackpot fires when `randomnessValue % JACKPOT_ODDS == 0`. */
|
|
1488
|
+
declare const JACKPOT_ODDS = 625;
|
|
1489
|
+
/**
|
|
1490
|
+
* Inputs to {@link computeGridMiningEv}. All ETH-denominated values are plain
|
|
1491
|
+
* numbers in whole ETH (not wei) and `slvrPriceEth` is ETH per SLVR — use
|
|
1492
|
+
* `Number(formatEther(...))` to convert on-chain `bigint` wei.
|
|
1493
|
+
*/
|
|
1494
|
+
interface GridMiningEvInput {
|
|
1495
|
+
/** ETH you would commit to the round. */
|
|
1496
|
+
stake: number;
|
|
1497
|
+
/** Total ETH currently wagered in the round (the pot). */
|
|
1498
|
+
pot: number;
|
|
1499
|
+
/** SLVR minted to the winning square this round (the emission target). */
|
|
1500
|
+
emissionPerRound: number;
|
|
1501
|
+
/** Price of SLVR in ETH (ETH per SLVR). */
|
|
1502
|
+
slvrPriceEth: number;
|
|
1503
|
+
/** Protocol fee in bps. Defaults to {@link PROTOCOL_FEE_BPS} (1000 = 10%). */
|
|
1504
|
+
feeBps?: number;
|
|
1505
|
+
/**
|
|
1506
|
+
* If `true`, value mined SLVR net of the refining fee (you intend to cash out
|
|
1507
|
+
* to ETH). If `false` (default), value it at full price (you hold/stake it).
|
|
1508
|
+
*/
|
|
1509
|
+
cashOut?: boolean;
|
|
1510
|
+
/** Refining fee in bps, applied only when `cashOut` is true. Defaults to {@link REFINING_FEE_BPS}. */
|
|
1511
|
+
refineFeeBps?: number;
|
|
1512
|
+
/** ETH currently in the jackpot pool. Defaults to 0 (jackpot ignored). */
|
|
1513
|
+
jackpotPool?: number;
|
|
1514
|
+
/** Jackpot odds (1-in-N per round). Defaults to {@link JACKPOT_ODDS} (625). */
|
|
1515
|
+
jackpotOdds?: number;
|
|
1516
|
+
}
|
|
1517
|
+
/** Result of {@link computeGridMiningEv}. All ETH-denominated. */
|
|
1518
|
+
interface GridMiningEv {
|
|
1519
|
+
/** Your fraction of the pot, `stake / pot`. */
|
|
1520
|
+
share: number;
|
|
1521
|
+
/** ETH lost per round to the protocol fee, `feeFraction * stake`. */
|
|
1522
|
+
ethBleed: number;
|
|
1523
|
+
/** SLVR mined per round, `share * emissionPerRound`. */
|
|
1524
|
+
slvrMined: number;
|
|
1525
|
+
/** ETH value of the mined SLVR after the realize factor. */
|
|
1526
|
+
slvrValueEth: number;
|
|
1527
|
+
/** Expected jackpot contribution per round, in ETH. */
|
|
1528
|
+
jackpotEvEth: number;
|
|
1529
|
+
/** Net EV per round excluding the jackpot, in ETH. */
|
|
1530
|
+
netEthNoJackpot: number;
|
|
1531
|
+
/** Net EV per round including the jackpot, in ETH. */
|
|
1532
|
+
netEth: number;
|
|
1533
|
+
/** Net EV as a fraction of stake (`netEth / stake`) — the per-round edge. */
|
|
1534
|
+
edgeRatio: number;
|
|
1535
|
+
/** Pot size at which `netEth` crosses zero. Mining is profitable below this. */
|
|
1536
|
+
breakEvenPot: number;
|
|
1537
|
+
/** SLVR price (ETH) at which `netEth` crosses zero for the current pot. */
|
|
1538
|
+
breakEvenSlvrPriceEth: number;
|
|
1539
|
+
/** Whether the round is +EV (`netEth > 0`). */
|
|
1540
|
+
profitable: boolean;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Compute the per-round expected value of grid mining for a given stake, pot,
|
|
1544
|
+
* emission and SLVR price. Pure function — does no I/O.
|
|
1545
|
+
*
|
|
1546
|
+
* @throws {Error} if `stake` or `pot` is not positive.
|
|
1547
|
+
*
|
|
1548
|
+
* @example
|
|
1549
|
+
* ```typescript
|
|
1550
|
+
* import { computeGridMiningEv } from '@slvr-labs/sdk';
|
|
1551
|
+
*
|
|
1552
|
+
* const ev = computeGridMiningEv({
|
|
1553
|
+
* stake: 0.1, // 0.1 ETH per round
|
|
1554
|
+
* pot: 0.5, // 0.5 ETH in the pot
|
|
1555
|
+
* emissionPerRound: 1, // 1 SLVR minted/round
|
|
1556
|
+
* slvrPriceEth: 0.0005, // SLVR price in ETH
|
|
1557
|
+
* jackpotPool: 5, // 5 ETH jackpot
|
|
1558
|
+
* });
|
|
1559
|
+
* if (ev.profitable) console.log(`+${ev.netEth} ETH/round, edge ${(ev.edgeRatio * 100).toFixed(1)}%`);
|
|
1560
|
+
* ```
|
|
1561
|
+
*/
|
|
1562
|
+
declare function computeGridMiningEv(input: GridMiningEvInput): GridMiningEv;
|
|
1563
|
+
|
|
1564
|
+
/**
|
|
1565
|
+
* A known Slvr deployment: chain metadata plus the on-chain addresses the SDK needs.
|
|
1566
|
+
*
|
|
1567
|
+
* Addresses mirror the canonical values the production interface ships
|
|
1568
|
+
* (`interface/config/constants.ts`). `hub`, `registry`, and `jackpot` are only
|
|
1569
|
+
* present on deployments that run the emission/sink hub architecture — they are
|
|
1570
|
+
* omitted here for deployments that don't, and the corresponding `sdk.hub` /
|
|
1571
|
+
* `sdk.registry` / `sdk.jackpot` bindings will be `undefined`.
|
|
1572
|
+
*/
|
|
1573
|
+
interface SlvrDeployment {
|
|
1574
|
+
/** EVM chain id */
|
|
1575
|
+
chainId: number;
|
|
1576
|
+
/** Human-readable network name */
|
|
1577
|
+
name: string;
|
|
1578
|
+
/** Default JSON-RPC endpoint */
|
|
1579
|
+
rpcUrl: string;
|
|
1580
|
+
/** Block explorer base URL, if any */
|
|
1581
|
+
blockExplorer?: string;
|
|
1582
|
+
/** Goldsky/hosted subgraph GraphQL endpoint, if any */
|
|
1583
|
+
subgraphUrl?: string;
|
|
1584
|
+
/** Contract addresses, shaped to drop straight into `new SlvrSDK({ addresses })` */
|
|
1585
|
+
addresses: {
|
|
1586
|
+
/** SlvrGridLottery */
|
|
1587
|
+
lottery: Address;
|
|
1588
|
+
/** SlvrVoteEscrowStaking (the veNFT staker) */
|
|
1589
|
+
staking: Address;
|
|
1590
|
+
/** SlvrToken (ERC20) */
|
|
1591
|
+
token: Address;
|
|
1592
|
+
/** SlvrAutoCommitV2 (optional) */
|
|
1593
|
+
autoCommit?: Address;
|
|
1594
|
+
/** SlvrVoteEscrow NFT — needed to approve/own the tokenIds you stake (optional) */
|
|
1595
|
+
voteEscrow?: Address;
|
|
1596
|
+
/** SLVR/ETH UniswapV2 pair — enables SLVR price reads via `sdk.price` (optional) */
|
|
1597
|
+
slvrEthPair?: Address;
|
|
1598
|
+
/**
|
|
1599
|
+
* Chainlink-style ETH/USD feed — enables USD prices via `sdk.ethUsd` (optional).
|
|
1600
|
+
* Absent on deployments (like Robinhood Chain) that have no on-chain feed.
|
|
1601
|
+
*/
|
|
1602
|
+
chainlinkEthUsd?: Address;
|
|
1603
|
+
/** Multicall3 — lets the SDK batch multi-square reads into a single RPC call (optional). */
|
|
1604
|
+
multicall3?: Address;
|
|
1605
|
+
/** SlvrHub emission/sink router (optional; only on hub deployments) */
|
|
1606
|
+
hub?: Address;
|
|
1607
|
+
/** SlvrGameRegistry (optional; only on hub deployments) */
|
|
1608
|
+
registry?: Address;
|
|
1609
|
+
/** SlvrJackpot (optional; only on hub deployments) */
|
|
1610
|
+
jackpot?: Address;
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
/**
|
|
1614
|
+
* Robinhood Chain mainnet — the canonical production Slvr deployment.
|
|
1615
|
+
*
|
|
1616
|
+
* Addresses populated from `DeployRobinhood.s.sol` (2026-07-09); `autoCommit`
|
|
1617
|
+
* is SlvrAutoCommitV2. The live deployment does not run the hub architecture,
|
|
1618
|
+
* so `hub`/`registry`/`jackpot` are intentionally absent.
|
|
1619
|
+
*/
|
|
1620
|
+
declare const robinhood: SlvrDeployment;
|
|
1621
|
+
/**
|
|
1622
|
+
* All known Slvr deployments, keyed by a short network slug.
|
|
1623
|
+
*
|
|
1624
|
+
* @example
|
|
1625
|
+
* ```typescript
|
|
1626
|
+
* import { deployments } from '@slvr-labs/sdk';
|
|
1627
|
+
* const { addresses, rpcUrl } = deployments.robinhood;
|
|
1628
|
+
* ```
|
|
1629
|
+
*/
|
|
1630
|
+
declare const deployments: {
|
|
1631
|
+
readonly robinhood: SlvrDeployment;
|
|
1632
|
+
};
|
|
1633
|
+
/**
|
|
1634
|
+
* A ready-to-use viem `Chain` for Robinhood Chain mainnet, so you don't have to
|
|
1635
|
+
* hand-roll `defineChain`.
|
|
1636
|
+
*
|
|
1637
|
+
* @example
|
|
1638
|
+
* ```typescript
|
|
1639
|
+
* import { createPublicClient, http } from 'viem';
|
|
1640
|
+
* import { robinhoodChain } from '@slvr-labs/sdk';
|
|
1641
|
+
*
|
|
1642
|
+
* const publicClient = createPublicClient({ chain: robinhoodChain, transport: http() });
|
|
1643
|
+
* ```
|
|
1644
|
+
*/
|
|
1645
|
+
declare const robinhoodChain: {
|
|
1646
|
+
blockExplorers: {
|
|
1647
|
+
readonly default: {
|
|
1648
|
+
readonly name: "Blockscout";
|
|
1649
|
+
readonly url: "https://robinhoodchain.blockscout.com";
|
|
1650
|
+
};
|
|
1651
|
+
};
|
|
1652
|
+
blockTime?: number | undefined | undefined;
|
|
1653
|
+
contracts: {
|
|
1654
|
+
readonly multicall3: {
|
|
1655
|
+
readonly address: `0x${string}`;
|
|
1656
|
+
};
|
|
1657
|
+
};
|
|
1658
|
+
ensTlds?: readonly string[] | undefined;
|
|
1659
|
+
id: number;
|
|
1660
|
+
name: string;
|
|
1661
|
+
nativeCurrency: {
|
|
1662
|
+
readonly decimals: 18;
|
|
1663
|
+
readonly name: "Ether";
|
|
1664
|
+
readonly symbol: "ETH";
|
|
1665
|
+
};
|
|
1666
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
1667
|
+
rpcUrls: {
|
|
1668
|
+
readonly default: {
|
|
1669
|
+
readonly http: readonly [string];
|
|
1670
|
+
};
|
|
1671
|
+
};
|
|
1672
|
+
sourceId?: number | undefined | undefined;
|
|
1673
|
+
testnet?: boolean | undefined | undefined;
|
|
1674
|
+
custom?: Record<string, unknown> | undefined;
|
|
1675
|
+
fees?: viem.ChainFees<undefined> | undefined;
|
|
1676
|
+
formatters?: undefined;
|
|
1677
|
+
serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
|
|
1678
|
+
};
|
|
1679
|
+
|
|
1680
|
+
/**
|
|
1681
|
+
* Options for {@link createSlvrClients} / {@link SlvrSDK.connect}.
|
|
1682
|
+
*/
|
|
1683
|
+
interface ConnectOptions {
|
|
1684
|
+
/** Which deployment to target. Defaults to `robinhood`. */
|
|
1685
|
+
deployment?: SlvrDeployment;
|
|
1686
|
+
/** RPC URL. Defaults to the deployment's `rpcUrl`. Ignored if `transport` is given. */
|
|
1687
|
+
rpcUrl?: string;
|
|
1688
|
+
/** A fully-custom viem transport (overrides `rpcUrl`). */
|
|
1689
|
+
transport?: Transport;
|
|
1690
|
+
/** A private key to build a wallet client from (for sending transactions). */
|
|
1691
|
+
privateKey?: `0x${string}`;
|
|
1692
|
+
/** …or an already-built viem `Account` (alternative to `privateKey`). */
|
|
1693
|
+
account?: Account;
|
|
1694
|
+
/** Auto-batch concurrent reads through Multicall3. Defaults to `true`. */
|
|
1695
|
+
batchMulticall?: boolean;
|
|
1696
|
+
/** viem polling interval (ms) used by event watchers. */
|
|
1697
|
+
pollingInterval?: number;
|
|
1698
|
+
}
|
|
1699
|
+
/**
|
|
1700
|
+
* Build a viem `Chain` for a deployment. Returns the shipped `robinhoodChain`
|
|
1701
|
+
* (which already registers Multicall3) for the Robinhood deployment; otherwise
|
|
1702
|
+
* synthesizes one, wiring `multicall3` when the deployment provides it.
|
|
1703
|
+
*/
|
|
1704
|
+
declare function chainFromDeployment(deployment: SlvrDeployment): Chain;
|
|
1705
|
+
/** Clients returned by {@link createSlvrClients}. */
|
|
1706
|
+
interface SlvrClients {
|
|
1707
|
+
chain: Chain;
|
|
1708
|
+
publicClient: PublicClient;
|
|
1709
|
+
/** Present only when a `privateKey` or `account` was supplied. */
|
|
1710
|
+
walletClient?: WalletClient;
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Create ready-to-use viem clients for a Slvr deployment with sensible, resilient
|
|
1714
|
+
* defaults — Multicall3 auto-batching, a longer timeout, and retries — so you
|
|
1715
|
+
* don't have to hand-tune the transport for a polling bot.
|
|
1716
|
+
*
|
|
1717
|
+
* @example
|
|
1718
|
+
* ```typescript
|
|
1719
|
+
* import { createSlvrClients } from '@slvr-labs/sdk';
|
|
1720
|
+
* const { publicClient, walletClient } = createSlvrClients({ privateKey: process.env.PRIVATE_KEY });
|
|
1721
|
+
* ```
|
|
1722
|
+
*/
|
|
1723
|
+
declare function createSlvrClients(opts?: ConnectOptions): SlvrClients;
|
|
1724
|
+
|
|
1725
|
+
/**
|
|
1726
|
+
* Base error class for all SDK errors
|
|
1727
|
+
*/
|
|
1728
|
+
declare class SlvrSDKError extends Error {
|
|
1729
|
+
readonly code?: string | undefined;
|
|
1730
|
+
constructor(message: string, code?: string | undefined);
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Error thrown when wallet client is required but not provided
|
|
1734
|
+
*/
|
|
1735
|
+
declare class WalletClientRequiredError extends SlvrSDKError {
|
|
1736
|
+
constructor(operation: string);
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Error thrown when contract call fails
|
|
1740
|
+
*/
|
|
1741
|
+
declare class ContractCallError extends SlvrSDKError {
|
|
1742
|
+
readonly cause?: unknown | undefined;
|
|
1743
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
1744
|
+
}
|
|
1745
|
+
/**
|
|
1746
|
+
* Error thrown when input validation fails
|
|
1747
|
+
*/
|
|
1748
|
+
declare class ValidationError extends SlvrSDKError {
|
|
1749
|
+
readonly field?: string | undefined;
|
|
1750
|
+
constructor(message: string, field?: string | undefined);
|
|
1751
|
+
}
|
|
1752
|
+
/**
|
|
1753
|
+
* Error thrown when transaction fails
|
|
1754
|
+
*/
|
|
1755
|
+
declare class TransactionError extends SlvrSDKError {
|
|
1756
|
+
readonly txHash?: `0x${string}` | undefined;
|
|
1757
|
+
readonly cause?: unknown | undefined;
|
|
1758
|
+
constructor(message: string, txHash?: `0x${string}` | undefined, cause?: unknown | undefined);
|
|
1759
|
+
}
|
|
1760
|
+
/**
|
|
1761
|
+
* A decoded on-chain revert. `errorName` is the protocol's custom error (e.g.
|
|
1762
|
+
* `InsufficientValue`) when it could be decoded from the ABI.
|
|
1763
|
+
*/
|
|
1764
|
+
declare class SlvrRevertError extends SlvrSDKError {
|
|
1765
|
+
readonly errorName: string | undefined;
|
|
1766
|
+
readonly args?: readonly unknown[] | undefined;
|
|
1767
|
+
readonly cause?: unknown | undefined;
|
|
1768
|
+
constructor(errorName: string | undefined, message: string, args?: readonly unknown[] | undefined, cause?: unknown | undefined);
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Decode a viem contract error into a {@link SlvrRevertError} with the protocol's
|
|
1772
|
+
* custom error name and a plain-English hint. Returns `null` if `err` isn't a
|
|
1773
|
+
* decodable contract revert (so you can rethrow the original). Useful around
|
|
1774
|
+
* `simulateBet`, reads, or any caught write error.
|
|
1775
|
+
*
|
|
1776
|
+
* @example
|
|
1777
|
+
* ```typescript
|
|
1778
|
+
* try { await sdk.lottery.simulateBet(params); }
|
|
1779
|
+
* catch (e) { const r = decodeSlvrRevert(e); if (r) console.log(r.errorName, r.message); }
|
|
1780
|
+
* ```
|
|
1781
|
+
*/
|
|
1782
|
+
declare function decodeSlvrRevert(err: unknown): SlvrRevertError | null;
|
|
1783
|
+
|
|
1784
|
+
/**
|
|
1785
|
+
* Validate and normalize an Ethereum address
|
|
1786
|
+
* @param address Address to validate
|
|
1787
|
+
* @param fieldName Field name for error message
|
|
1788
|
+
* @returns Checksummed address
|
|
1789
|
+
* @throws ValidationError if address is invalid
|
|
1790
|
+
*/
|
|
1791
|
+
declare function validateAddress(address: string, fieldName?: string): Address;
|
|
1792
|
+
/**
|
|
1793
|
+
* Validate that an amount is positive
|
|
1794
|
+
* @param amount Amount to validate
|
|
1795
|
+
* @param fieldName Field name for error message
|
|
1796
|
+
* @throws ValidationError if amount is invalid
|
|
1797
|
+
*/
|
|
1798
|
+
declare function validateAmount(amount: bigint, fieldName?: string): void;
|
|
1799
|
+
/**
|
|
1800
|
+
* Validate square indices are within valid range
|
|
1801
|
+
* @param squares Array of square indices
|
|
1802
|
+
* @param gridSize Grid size (default 25)
|
|
1803
|
+
* @throws ValidationError if squares are invalid
|
|
1804
|
+
*/
|
|
1805
|
+
declare function validateSquares(squares: number[], gridSize?: number): void;
|
|
1806
|
+
/**
|
|
1807
|
+
* Validate that arrays have matching lengths
|
|
1808
|
+
* @param arrays Arrays to validate
|
|
1809
|
+
* @param fieldNames Field names for error message
|
|
1810
|
+
* @throws ValidationError if arrays don't match
|
|
1811
|
+
*/
|
|
1812
|
+
declare function validateArrayLengths(arrays: unknown[][], fieldNames: string[]): void;
|
|
1813
|
+
/**
|
|
1814
|
+
* Validate basis points (0-10000)
|
|
1815
|
+
* @param bps Basis points value
|
|
1816
|
+
* @param fieldName Field name for error message
|
|
1817
|
+
* @throws ValidationError if bps is invalid
|
|
1818
|
+
*/
|
|
1819
|
+
declare function validateBps(bps: number, fieldName?: string): void;
|
|
1820
|
+
/**
|
|
1821
|
+
* Validate that basis points array sums to 10000
|
|
1822
|
+
* @param bpsArray Array of basis points
|
|
1823
|
+
* @param fieldName Field name for error message
|
|
1824
|
+
* @throws ValidationError if bps don't sum to 10000
|
|
1825
|
+
*/
|
|
1826
|
+
declare function validateBpsSum(bpsArray: number[], fieldName?: string): void;
|
|
1827
|
+
/**
|
|
1828
|
+
* Wait for transaction receipt with timeout
|
|
1829
|
+
* @param publicClient Public client
|
|
1830
|
+
* @param hash Transaction hash
|
|
1831
|
+
* @param timeout Timeout in milliseconds (default 120000 = 2 minutes)
|
|
1832
|
+
* @returns Transaction receipt
|
|
1833
|
+
*/
|
|
1834
|
+
declare function waitForTransactionReceipt(publicClient: {
|
|
1835
|
+
waitForTransactionReceipt?: (args: {
|
|
1836
|
+
hash: `0x${string}`;
|
|
1837
|
+
timeout?: number;
|
|
1838
|
+
}) => Promise<unknown>;
|
|
1839
|
+
}, hash: `0x${string}`, timeout?: number): Promise<unknown>;
|
|
1840
|
+
|
|
1841
|
+
/**
|
|
1842
|
+
* Options for transaction execution
|
|
1843
|
+
*/
|
|
1844
|
+
interface TransactionOptions {
|
|
1845
|
+
/** Maximum gas to use */
|
|
1846
|
+
gas?: bigint;
|
|
1847
|
+
/** Gas price (legacy) */
|
|
1848
|
+
gasPrice?: bigint;
|
|
1849
|
+
/** Max fee per gas (EIP-1559) */
|
|
1850
|
+
maxFeePerGas?: bigint;
|
|
1851
|
+
/** Max priority fee per gas (EIP-1559) */
|
|
1852
|
+
maxPriorityFeePerGas?: bigint;
|
|
1853
|
+
/** Whether to wait for transaction receipt */
|
|
1854
|
+
waitForReceipt?: boolean;
|
|
1855
|
+
/** Timeout for waiting for receipt (milliseconds) */
|
|
1856
|
+
receiptTimeout?: number;
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Estimate gas for a contract write operation
|
|
1860
|
+
* @param publicClient Public client
|
|
1861
|
+
* @param address Contract address
|
|
1862
|
+
* @param abi Contract ABI
|
|
1863
|
+
* @param functionName Function name
|
|
1864
|
+
* @param args Function arguments
|
|
1865
|
+
* @param value Optional value to send
|
|
1866
|
+
* @param account Optional account address
|
|
1867
|
+
* @returns Estimated gas
|
|
1868
|
+
*/
|
|
1869
|
+
declare function estimateGas(publicClient: PublicClient, address: Address, abi: readonly unknown[], functionName: string, args: unknown[], value?: bigint, account?: Address): Promise<bigint>;
|
|
1870
|
+
/**
|
|
1871
|
+
* Wait for transaction receipt with error handling
|
|
1872
|
+
* @param publicClient Public client
|
|
1873
|
+
* @param hash Transaction hash
|
|
1874
|
+
* @param timeout Timeout in milliseconds
|
|
1875
|
+
* @returns Transaction receipt
|
|
1876
|
+
* @throws TransactionError if transaction fails or times out
|
|
1877
|
+
*/
|
|
1878
|
+
declare function waitForReceipt(publicClient: PublicClient, hash: `0x${string}`, timeout?: number): Promise<unknown>;
|
|
1879
|
+
/**
|
|
1880
|
+
* Execute a contract write with options
|
|
1881
|
+
* @param walletClient Wallet client
|
|
1882
|
+
* @param publicClient Public client
|
|
1883
|
+
* @param address Contract address
|
|
1884
|
+
* @param abi Contract ABI
|
|
1885
|
+
* @param functionName Function name
|
|
1886
|
+
* @param args Function arguments
|
|
1887
|
+
* @param options Transaction options
|
|
1888
|
+
* @returns Transaction hash or receipt
|
|
1889
|
+
*/
|
|
1890
|
+
declare function executeTransaction(walletClient: WalletClient, publicClient: PublicClient, address: Address, abi: readonly unknown[], functionName: string, args: unknown[], options?: TransactionOptions & {
|
|
1891
|
+
value?: bigint;
|
|
1892
|
+
}): Promise<`0x${string}` | unknown>;
|
|
1893
|
+
|
|
14
1894
|
/**
|
|
15
1895
|
* Main Slvr SDK class
|
|
16
1896
|
*
|
|
@@ -51,7 +1931,7 @@ import { ConnectOptions } from './connect';
|
|
|
51
1931
|
* });
|
|
52
1932
|
* ```
|
|
53
1933
|
*/
|
|
54
|
-
|
|
1934
|
+
declare class SlvrSDK {
|
|
55
1935
|
readonly lottery: SlvrGridLottery;
|
|
56
1936
|
readonly staking: SlvrStaking;
|
|
57
1937
|
readonly token: SlvrToken;
|
|
@@ -225,24 +2105,13 @@ export declare class SlvrSDK {
|
|
|
225
2105
|
/** Override the pot (ETH). Defaults to the sum of the round's squares. */
|
|
226
2106
|
pot?: number;
|
|
227
2107
|
}): Promise<GridMiningEv>;
|
|
2108
|
+
/**
|
|
2109
|
+
* Helper: current jackpot pool for a round, in wei (0 if no jackpot is set).
|
|
2110
|
+
*
|
|
2111
|
+
* Resolves the round's jackpot contract via `getRoundJackpot` and reads its
|
|
2112
|
+
* `jackpotPool()`. Defaults to the current round.
|
|
2113
|
+
*/
|
|
2114
|
+
getJackpotPool(roundId?: bigint): Promise<bigint>;
|
|
228
2115
|
}
|
|
229
|
-
|
|
230
|
-
export
|
|
231
|
-
export * from './ev';
|
|
232
|
-
export { SlvrPrice } from './price';
|
|
233
|
-
export type { SlvrReserves } from './price';
|
|
234
|
-
export { ChainlinkPriceFeed } from './oracle';
|
|
235
|
-
export { createSlvrClients, chainFromDeployment } from './connect';
|
|
236
|
-
export type { ConnectOptions, SlvrClients } from './connect';
|
|
237
|
-
export { SlvrGridLottery } from './contracts/lottery';
|
|
238
|
-
export { SlvrStaking } from './contracts/staking';
|
|
239
|
-
export { SlvrToken } from './contracts/token';
|
|
240
|
-
export { SlvrAutoCommit } from './contracts/autoCommit';
|
|
241
|
-
export { SlvrHub } from './contracts/hub';
|
|
242
|
-
export { SlvrGameRegistry } from './contracts/registry';
|
|
243
|
-
export { SlvrJackpot } from './contracts/jackpot';
|
|
244
|
-
export * from './errors';
|
|
245
|
-
export * from './utils';
|
|
246
|
-
export * from './transaction';
|
|
247
|
-
export * from './events';
|
|
248
|
-
//# sourceMappingURL=index.d.ts.map
|
|
2116
|
+
|
|
2117
|
+
export { type AutoCommitPlan, type BetParams, type BetPlacedEvent, ChainlinkPriceFeed, type ClaimParams, type ClaimParamsAdvanced, type ClaimedEvent, type ConnectOptions, ContractCallError, GRID_SIZE, type GameInfo, GameStatus, GameTier, type GridMiningEv, type GridMiningEvInput, JACKPOT_ODDS, type MinerState, PROTOCOL_FEE_BPS, type PriceQuote, REFINING_FEE_BPS, type RandomnessRequestedEvent, type RoundInfo, type RoundResolvedEvent, SINGLE_SQUARE_WIN_PROBABILITY, SlvrAutoCommit, SlvrAutoCommitEvents, type SlvrClients, type SlvrConfig, type SlvrDeployment, SlvrGameRegistry, SlvrGridLottery, SlvrGridLotteryEvents, SlvrHub, SlvrJackpot, SlvrPrice, type SlvrReserves, SlvrRevertError, SlvrSDK, SlvrSDKError, SlvrStaking, SlvrStakingEvents, SlvrToken, SlvrTokenEvents, type StakingInfo, TransactionError, type TransactionOptions, type TreasuryState, type TxOverrides, ValidationError, WalletClientRequiredError, chainFromDeployment, computeGridMiningEv, createSlvrClients, decodeEvent, decodeEvents, decodeSlvrRevert, deployments, estimateGas, executeTransaction, robinhood, robinhoodChain, validateAddress, validateAmount, validateArrayLengths, validateBps, validateBpsSum, validateSquares, waitForReceipt, waitForTransactionReceipt };
|