@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
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlvrAutoCommit = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
const errors_1 = require("../errors");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
/**
|
|
8
|
-
* SlvrAutoCommitV2 contract interface
|
|
9
|
-
*
|
|
10
|
-
* V2 economics: executors calling executeFor/claimFor are reimbursed their
|
|
11
|
-
* metered gas (plus a premium, capped at maxFeePerExecution — both owner-tunable
|
|
12
|
-
* within hard ceilings) from the user's plan balance — there is no flat
|
|
13
|
-
* AUTOMATION_FEE and the execution functions are nonpayable. Claimable winning
|
|
14
|
-
* rounds are discovered off-chain and passed in explicitly via claimRounds.
|
|
15
|
-
*/
|
|
16
|
-
class SlvrAutoCommit {
|
|
17
|
-
constructor(publicClient, walletClient, address) {
|
|
18
|
-
this.publicClient = publicClient;
|
|
19
|
-
this.walletClient = walletClient;
|
|
20
|
-
this.address = address;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Update the wallet client
|
|
24
|
-
* @param walletClient New wallet client
|
|
25
|
-
*/
|
|
26
|
-
setWalletClient(walletClient) {
|
|
27
|
-
this.walletClient = walletClient;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Get plan information for a user
|
|
31
|
-
*/
|
|
32
|
-
async planInfo(user) {
|
|
33
|
-
const result = await this.publicClient.readContract({
|
|
34
|
-
address: this.address,
|
|
35
|
-
abi: SlvrAutoCommit.ABI,
|
|
36
|
-
functionName: 'planInfo',
|
|
37
|
-
args: [user],
|
|
38
|
-
});
|
|
39
|
-
return {
|
|
40
|
-
enabled: result[0],
|
|
41
|
-
nextRoundId: result[1],
|
|
42
|
-
playsRemaining: Number(result[2]),
|
|
43
|
-
amountPerPlay: result[3],
|
|
44
|
-
balance: result[4],
|
|
45
|
-
autoClaim: result[5],
|
|
46
|
-
squares: result[6].map((s) => Number(s)),
|
|
47
|
-
bpsAlloc: result[7].map((b) => Number(b)),
|
|
48
|
-
planStartRoundId: result[8],
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Check whether a plan is ready to execute, and if not, why
|
|
53
|
-
*/
|
|
54
|
-
async needsExecution(user) {
|
|
55
|
-
const [ready, reason] = await this.publicClient.readContract({
|
|
56
|
-
address: this.address,
|
|
57
|
-
abi: SlvrAutoCommit.ABI,
|
|
58
|
-
functionName: 'needsExecution',
|
|
59
|
-
args: [user],
|
|
60
|
-
});
|
|
61
|
-
return { ready, reason };
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Check whether a specific round has already been executed for a user
|
|
65
|
-
*/
|
|
66
|
-
async executedRound(user, roundId) {
|
|
67
|
-
return await this.publicClient.readContract({
|
|
68
|
-
address: this.address,
|
|
69
|
-
abi: SlvrAutoCommit.ABI,
|
|
70
|
-
functionName: 'executedRounds',
|
|
71
|
-
args: [user, roundId],
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Get lottery contract address
|
|
76
|
-
*/
|
|
77
|
-
async lottery() {
|
|
78
|
-
return await this.publicClient.readContract({
|
|
79
|
-
address: this.address,
|
|
80
|
-
abi: SlvrAutoCommit.ABI,
|
|
81
|
-
functionName: 'LOTTERY',
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Get the sentinel plays value meaning "unlimited plays"
|
|
86
|
-
*/
|
|
87
|
-
async unlimitedPlays() {
|
|
88
|
-
return await this.publicClient.readContract({
|
|
89
|
-
address: this.address,
|
|
90
|
-
abi: SlvrAutoCommit.ABI,
|
|
91
|
-
functionName: 'UNLIMITED_PLAYS',
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Get max plays per execution
|
|
96
|
-
*/
|
|
97
|
-
async maxPlaysPerExecution() {
|
|
98
|
-
return await this.publicClient.readContract({
|
|
99
|
-
address: this.address,
|
|
100
|
-
abi: SlvrAutoCommit.ABI,
|
|
101
|
-
functionName: 'MAX_PLAYS_PER_EXECUTION',
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Get max claim rounds accepted per execution
|
|
106
|
-
*/
|
|
107
|
-
async maxClaimsPerExecution() {
|
|
108
|
-
return await this.publicClient.readContract({
|
|
109
|
-
address: this.address,
|
|
110
|
-
abi: SlvrAutoCommit.ABI,
|
|
111
|
-
functionName: 'MAX_CLAIMS_PER_EXECUTION',
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Get the current cap on the executor fee reimbursed per execution
|
|
116
|
-
* (owner-tunable within the contract's hard ceiling)
|
|
117
|
-
*/
|
|
118
|
-
async maxFeePerExecution() {
|
|
119
|
-
return await this.publicClient.readContract({
|
|
120
|
-
address: this.address,
|
|
121
|
-
abi: SlvrAutoCommit.ABI,
|
|
122
|
-
functionName: 'maxFeePerExecution',
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get the current executor-fee premium in basis points
|
|
127
|
-
* (owner-tunable within the contract's hard ceiling)
|
|
128
|
-
*/
|
|
129
|
-
async feePremiumBps() {
|
|
130
|
-
return await this.publicClient.readContract({
|
|
131
|
-
address: this.address,
|
|
132
|
-
abi: SlvrAutoCommit.ABI,
|
|
133
|
-
functionName: 'feePremiumBps',
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Deposit native tokens to auto-commit plan
|
|
138
|
-
* @param value Amount to deposit
|
|
139
|
-
* @returns Transaction hash
|
|
140
|
-
* @throws WalletClientRequiredError if wallet client is not available
|
|
141
|
-
* @throws ValidationError if amount is invalid
|
|
142
|
-
* @throws ContractCallError if contract call fails
|
|
143
|
-
*/
|
|
144
|
-
async deposit(value) {
|
|
145
|
-
if (!this.walletClient) {
|
|
146
|
-
throw new errors_1.WalletClientRequiredError('depositing');
|
|
147
|
-
}
|
|
148
|
-
(0, utils_1.validateAmount)(value, 'deposit amount');
|
|
149
|
-
try {
|
|
150
|
-
return await this.walletClient.writeContract({
|
|
151
|
-
address: this.address,
|
|
152
|
-
abi: SlvrAutoCommit.ABI,
|
|
153
|
-
functionName: 'deposit',
|
|
154
|
-
value,
|
|
155
|
-
account: this.walletClient.account,
|
|
156
|
-
chain: null,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
if (error instanceof errors_1.WalletClientRequiredError || error instanceof errors_1.ContractCallError) {
|
|
161
|
-
throw error;
|
|
162
|
-
}
|
|
163
|
-
throw new errors_1.ContractCallError(`Failed to deposit: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Withdraw from auto-commit plan
|
|
168
|
-
* @param amount Amount to withdraw
|
|
169
|
-
* @param to Recipient address
|
|
170
|
-
* @returns Transaction hash
|
|
171
|
-
* @throws WalletClientRequiredError if wallet client is not available
|
|
172
|
-
* @throws ValidationError if inputs are invalid
|
|
173
|
-
* @throws ContractCallError if contract call fails
|
|
174
|
-
*/
|
|
175
|
-
async withdraw(amount, to) {
|
|
176
|
-
if (!this.walletClient) {
|
|
177
|
-
throw new errors_1.WalletClientRequiredError('withdrawing');
|
|
178
|
-
}
|
|
179
|
-
(0, utils_1.validateAmount)(amount, 'withdraw amount');
|
|
180
|
-
const recipient = (0, utils_1.validateAddress)(to, 'recipient');
|
|
181
|
-
try {
|
|
182
|
-
return await this.walletClient.writeContract({
|
|
183
|
-
address: this.address,
|
|
184
|
-
abi: SlvrAutoCommit.ABI,
|
|
185
|
-
functionName: 'withdraw',
|
|
186
|
-
args: [amount, recipient],
|
|
187
|
-
account: this.walletClient.account,
|
|
188
|
-
chain: null,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
catch (error) {
|
|
192
|
-
if (error instanceof errors_1.WalletClientRequiredError || error instanceof errors_1.ContractCallError) {
|
|
193
|
-
throw error;
|
|
194
|
-
}
|
|
195
|
-
throw new errors_1.ContractCallError(`Failed to withdraw: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Configure auto-commit plan
|
|
200
|
-
* @param plays Number of plays (UNLIMITED_PLAYS = 4294967295 for unlimited;
|
|
201
|
-
* forced to unlimited on-chain when autoClaim is true)
|
|
202
|
-
* @param amountPerPlay Amount per play
|
|
203
|
-
* @param squares Square indices to bet on
|
|
204
|
-
* @param bpsAlloc Basis points allocation for each square (must sum to 10000)
|
|
205
|
-
* @param autoClaim Whether the keeper should claim winnings back into the plan balance
|
|
206
|
-
* @returns Transaction hash
|
|
207
|
-
* @throws WalletClientRequiredError if wallet client is not available
|
|
208
|
-
* @throws ValidationError if inputs are invalid
|
|
209
|
-
* @throws ContractCallError if contract call fails
|
|
210
|
-
*/
|
|
211
|
-
async configurePlan(plays, amountPerPlay, squares, bpsAlloc, autoClaim) {
|
|
212
|
-
if (!this.walletClient) {
|
|
213
|
-
throw new errors_1.WalletClientRequiredError('configuring plan');
|
|
214
|
-
}
|
|
215
|
-
this.validatePlanConfig(plays, amountPerPlay, squares, bpsAlloc);
|
|
216
|
-
try {
|
|
217
|
-
return await this.walletClient.writeContract({
|
|
218
|
-
address: this.address,
|
|
219
|
-
abi: SlvrAutoCommit.ABI,
|
|
220
|
-
functionName: 'configurePlan',
|
|
221
|
-
args: [plays, amountPerPlay, squares, bpsAlloc, autoClaim],
|
|
222
|
-
account: this.walletClient.account,
|
|
223
|
-
chain: null,
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
catch (error) {
|
|
227
|
-
if (error instanceof errors_1.WalletClientRequiredError || error instanceof errors_1.ContractCallError) {
|
|
228
|
-
throw error;
|
|
229
|
-
}
|
|
230
|
-
throw new errors_1.ContractCallError(`Failed to configure plan: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Configure auto-commit plan and deposit funds in a single transaction
|
|
235
|
-
* @param plays Number of plays (see configurePlan)
|
|
236
|
-
* @param amountPerPlay Amount per play
|
|
237
|
-
* @param squares Square indices to bet on
|
|
238
|
-
* @param bpsAlloc Basis points allocation for each square (must sum to 10000)
|
|
239
|
-
* @param autoClaim Whether the keeper should claim winnings back into the plan balance
|
|
240
|
-
* @param value Amount to deposit
|
|
241
|
-
* @returns Transaction hash
|
|
242
|
-
* @throws WalletClientRequiredError if wallet client is not available
|
|
243
|
-
* @throws ValidationError if inputs are invalid
|
|
244
|
-
* @throws ContractCallError if contract call fails
|
|
245
|
-
*/
|
|
246
|
-
async configurePlanAndDeposit(plays, amountPerPlay, squares, bpsAlloc, autoClaim, value) {
|
|
247
|
-
if (!this.walletClient) {
|
|
248
|
-
throw new errors_1.WalletClientRequiredError('configuring plan');
|
|
249
|
-
}
|
|
250
|
-
this.validatePlanConfig(plays, amountPerPlay, squares, bpsAlloc);
|
|
251
|
-
(0, utils_1.validateAmount)(value, 'deposit amount');
|
|
252
|
-
try {
|
|
253
|
-
return await this.walletClient.writeContract({
|
|
254
|
-
address: this.address,
|
|
255
|
-
abi: SlvrAutoCommit.ABI,
|
|
256
|
-
functionName: 'configurePlanAndDeposit',
|
|
257
|
-
args: [plays, amountPerPlay, squares, bpsAlloc, autoClaim],
|
|
258
|
-
value,
|
|
259
|
-
account: this.walletClient.account,
|
|
260
|
-
chain: null,
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
catch (error) {
|
|
264
|
-
if (error instanceof errors_1.WalletClientRequiredError || error instanceof errors_1.ContractCallError) {
|
|
265
|
-
throw error;
|
|
266
|
-
}
|
|
267
|
-
throw new errors_1.ContractCallError(`Failed to configure plan: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Disable auto-commit plan
|
|
272
|
-
* @returns Transaction hash
|
|
273
|
-
* @throws WalletClientRequiredError if wallet client is not available
|
|
274
|
-
* @throws ContractCallError if contract call fails
|
|
275
|
-
*/
|
|
276
|
-
async disablePlan() {
|
|
277
|
-
if (!this.walletClient) {
|
|
278
|
-
throw new errors_1.WalletClientRequiredError('disabling plan');
|
|
279
|
-
}
|
|
280
|
-
try {
|
|
281
|
-
return await this.walletClient.writeContract({
|
|
282
|
-
address: this.address,
|
|
283
|
-
abi: SlvrAutoCommit.ABI,
|
|
284
|
-
functionName: 'disablePlan',
|
|
285
|
-
account: this.walletClient.account,
|
|
286
|
-
chain: null,
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
catch (error) {
|
|
290
|
-
if (error instanceof errors_1.WalletClientRequiredError || error instanceof errors_1.ContractCallError) {
|
|
291
|
-
throw error;
|
|
292
|
-
}
|
|
293
|
-
throw new errors_1.ContractCallError(`Failed to disable plan: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Cancel the plan and refund the entire remaining balance to the caller
|
|
298
|
-
* @returns Transaction hash
|
|
299
|
-
* @throws WalletClientRequiredError if wallet client is not available
|
|
300
|
-
* @throws ContractCallError if contract call fails
|
|
301
|
-
*/
|
|
302
|
-
async cancelPlan() {
|
|
303
|
-
if (!this.walletClient) {
|
|
304
|
-
throw new errors_1.WalletClientRequiredError('cancelling plan');
|
|
305
|
-
}
|
|
306
|
-
try {
|
|
307
|
-
return await this.walletClient.writeContract({
|
|
308
|
-
address: this.address,
|
|
309
|
-
abi: SlvrAutoCommit.ABI,
|
|
310
|
-
functionName: 'cancelPlan',
|
|
311
|
-
account: this.walletClient.account,
|
|
312
|
-
chain: null,
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
catch (error) {
|
|
316
|
-
if (error instanceof errors_1.WalletClientRequiredError || error instanceof errors_1.ContractCallError) {
|
|
317
|
-
throw error;
|
|
318
|
-
}
|
|
319
|
-
throw new errors_1.ContractCallError(`Failed to cancel plan: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Execute auto-commit plan for a user (anyone can call).
|
|
324
|
-
* The caller is reimbursed metered gas + premium from the user's plan balance.
|
|
325
|
-
* @param user User address
|
|
326
|
-
* @param maxPlays Maximum number of plays to execute
|
|
327
|
-
* @param claimRounds Winning round ids to claim into the plan balance before
|
|
328
|
-
* betting (discovered off-chain; non-claimable entries are no-ops)
|
|
329
|
-
* @returns Transaction hash
|
|
330
|
-
* @throws WalletClientRequiredError if wallet client is not available
|
|
331
|
-
* @throws ValidationError if inputs are invalid
|
|
332
|
-
* @throws ContractCallError if contract call fails
|
|
333
|
-
*/
|
|
334
|
-
async executeFor(user, maxPlays, claimRounds = []) {
|
|
335
|
-
if (!this.walletClient) {
|
|
336
|
-
throw new errors_1.WalletClientRequiredError('executing plan');
|
|
337
|
-
}
|
|
338
|
-
const userAddress = (0, utils_1.validateAddress)(user, 'user');
|
|
339
|
-
if (!Number.isInteger(maxPlays) || maxPlays <= 0) {
|
|
340
|
-
throw new errors_1.ContractCallError('maxPlays must be a positive integer');
|
|
341
|
-
}
|
|
342
|
-
try {
|
|
343
|
-
return await this.walletClient.writeContract({
|
|
344
|
-
address: this.address,
|
|
345
|
-
abi: SlvrAutoCommit.ABI,
|
|
346
|
-
functionName: 'executeFor',
|
|
347
|
-
args: [userAddress, maxPlays, claimRounds],
|
|
348
|
-
account: this.walletClient.account,
|
|
349
|
-
chain: null,
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
catch (error) {
|
|
353
|
-
if (error instanceof errors_1.WalletClientRequiredError || error instanceof errors_1.ContractCallError) {
|
|
354
|
-
throw error;
|
|
355
|
-
}
|
|
356
|
-
throw new errors_1.ContractCallError(`Failed to execute plan: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Claim winning rounds into a user's plan balance without betting (anyone can
|
|
361
|
-
* call). Useful when the plan balance is too low to bet until winnings land.
|
|
362
|
-
* @param user User address
|
|
363
|
-
* @param claimRounds Winning round ids to claim (discovered off-chain)
|
|
364
|
-
* @returns Transaction hash
|
|
365
|
-
* @throws WalletClientRequiredError if wallet client is not available
|
|
366
|
-
* @throws ValidationError if inputs are invalid
|
|
367
|
-
* @throws ContractCallError if contract call fails
|
|
368
|
-
*/
|
|
369
|
-
async claimFor(user, claimRounds) {
|
|
370
|
-
if (!this.walletClient) {
|
|
371
|
-
throw new errors_1.WalletClientRequiredError('claiming');
|
|
372
|
-
}
|
|
373
|
-
const userAddress = (0, utils_1.validateAddress)(user, 'user');
|
|
374
|
-
if (claimRounds.length === 0) {
|
|
375
|
-
throw new errors_1.ContractCallError('claimRounds must not be empty');
|
|
376
|
-
}
|
|
377
|
-
try {
|
|
378
|
-
return await this.walletClient.writeContract({
|
|
379
|
-
address: this.address,
|
|
380
|
-
abi: SlvrAutoCommit.ABI,
|
|
381
|
-
functionName: 'claimFor',
|
|
382
|
-
args: [userAddress, claimRounds],
|
|
383
|
-
account: this.walletClient.account,
|
|
384
|
-
chain: null,
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
catch (error) {
|
|
388
|
-
if (error instanceof errors_1.WalletClientRequiredError || error instanceof errors_1.ContractCallError) {
|
|
389
|
-
throw error;
|
|
390
|
-
}
|
|
391
|
-
throw new errors_1.ContractCallError(`Failed to claim: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
validatePlanConfig(plays, amountPerPlay, squares, bpsAlloc) {
|
|
395
|
-
if (!Number.isInteger(plays) || plays <= 0) {
|
|
396
|
-
throw new errors_1.ContractCallError('Plays must be a positive integer');
|
|
397
|
-
}
|
|
398
|
-
(0, utils_1.validateAmount)(amountPerPlay, 'amountPerPlay');
|
|
399
|
-
(0, utils_1.validateSquares)(squares);
|
|
400
|
-
(0, utils_1.validateArrayLengths)([squares, bpsAlloc], ['squares', 'bpsAlloc']);
|
|
401
|
-
(0, utils_1.validateBpsSum)(bpsAlloc, 'bpsAlloc');
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
exports.SlvrAutoCommit = SlvrAutoCommit;
|
|
405
|
-
SlvrAutoCommit.ABI = (0, viem_1.parseAbi)([
|
|
406
|
-
// View functions
|
|
407
|
-
'function planInfo(address user) view returns (bool enabled, uint256 nextRoundId, uint32 playsRemaining, uint256 amountPerPlay, uint256 balance, bool autoClaim, uint8[] squares, uint16[] bpsAlloc, uint256 planStartRoundId)',
|
|
408
|
-
'function needsExecution(address user) view returns (bool ready, string reason)',
|
|
409
|
-
'function executedRounds(address user, uint256 roundId) view returns (bool)',
|
|
410
|
-
'function LOTTERY() view returns (address)',
|
|
411
|
-
'function UNLIMITED_PLAYS() view returns (uint32)',
|
|
412
|
-
'function MAX_PLAYS_PER_EXECUTION() view returns (uint32)',
|
|
413
|
-
'function MAX_CLAIMS_PER_EXECUTION() view returns (uint256)',
|
|
414
|
-
'function maxFeePerExecution() view returns (uint256)',
|
|
415
|
-
'function feePremiumBps() view returns (uint16)',
|
|
416
|
-
// Write functions
|
|
417
|
-
'function deposit() payable',
|
|
418
|
-
'function withdraw(uint256 amount, address to)',
|
|
419
|
-
'function configurePlan(uint32 plays, uint256 amountPerPlay, uint8[] squares, uint16[] bpsAlloc, bool autoClaim)',
|
|
420
|
-
'function configurePlanAndDeposit(uint32 plays, uint256 amountPerPlay, uint8[] squares, uint16[] bpsAlloc, bool autoClaim) payable',
|
|
421
|
-
'function disablePlan()',
|
|
422
|
-
'function cancelPlan()',
|
|
423
|
-
'function executeFor(address user, uint32 maxPlays, uint256[] claimRounds)',
|
|
424
|
-
'function claimFor(address user, uint256[] claimRounds) returns (uint256 claimed)',
|
|
425
|
-
]);
|
|
426
|
-
//# sourceMappingURL=autoCommit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autoCommit.js","sourceRoot":"","sources":["../../src/contracts/autoCommit.ts"],"names":[],"mappings":";;;AAAA,+BAAqE;AAErE,sCAAyE;AACzE,oCAAkH;AAElH;;;;;;;;GAQG;AACH,MAAa,cAAc;IA4BzB,YAAY,YAA0B,EAAE,YAAsC,EAAE,OAAgB;QAC9F,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,I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,2CAA2C;IAC3C,kDAAkD;IAClD,0DAA0D;IAC1D,4DAA4D;IAC5D,sDAAsD;IACtD,gDAAgD;IAEhD,kBAAkB;IAClB,4BAA4B;IAC5B,+CAA+C;IAC/C,iHAAiH;IACjH,mIAAmI;IACnI,wBAAwB;IACxB,uBAAuB;IACvB,2EAA2E;IAC3E,kFAAkF;CACnF,CAAC,CAAC"}
|
package/dist/contracts/hub.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Address, PublicClient, WalletClient } from 'viem';
|
|
2
|
-
/**
|
|
3
|
-
* SlvrHub contract interface (read-only).
|
|
4
|
-
*
|
|
5
|
-
* The hub is the protocol emission/sink router: it gates per-game SLVR emission, fans many games
|
|
6
|
-
* into one shared veNFT staker stream, and into one shared jackpot. These bindings expose the
|
|
7
|
-
* informational view surface (emission rate, pending emission, sink addresses); the hub's
|
|
8
|
-
* fee-routing writes are keeper/protocol operations and are intentionally not included.
|
|
9
|
-
*/
|
|
10
|
-
export declare class SlvrHub {
|
|
11
|
-
private publicClient;
|
|
12
|
-
private address;
|
|
13
|
-
private static readonly ABI;
|
|
14
|
-
constructor(publicClient: PublicClient, _walletClient: WalletClient | undefined, address: Address);
|
|
15
|
-
setWalletClient(_walletClient: WalletClient | undefined): void;
|
|
16
|
-
/**
|
|
17
|
-
* Accrued-but-unminted SLVR emission currently available to a game (its bucket + streamed since
|
|
18
|
-
* last accrual, hard-capped at one maxAccrualSeconds window of the game's effective rate).
|
|
19
|
-
*/
|
|
20
|
-
pendingEmission(gameId: bigint): Promise<bigint>;
|
|
21
|
-
/**
|
|
22
|
-
* Base SLVR/sec emission rate across the whole active game set
|
|
23
|
-
*/
|
|
24
|
-
emissionRatePerSec(): Promise<bigint>;
|
|
25
|
-
/**
|
|
26
|
-
* Soft-cap target supply (0 => use token MAX_SUPPLY)
|
|
27
|
-
*/
|
|
28
|
-
targetSupply(): Promise<bigint>;
|
|
29
|
-
/**
|
|
30
|
-
* Idle-forfeiture window: cap on dt per accrual (seconds)
|
|
31
|
-
*/
|
|
32
|
-
maxAccrualSeconds(): Promise<bigint>;
|
|
33
|
-
/**
|
|
34
|
-
* Address of the shared veNFT staking contract
|
|
35
|
-
*/
|
|
36
|
-
staking(): Promise<Address>;
|
|
37
|
-
/**
|
|
38
|
-
* Address of the shared jackpot contract
|
|
39
|
-
*/
|
|
40
|
-
jackpot(): Promise<Address>;
|
|
41
|
-
/**
|
|
42
|
-
* Hub-owned sequential counter used to feed the staking contract's round numbering
|
|
43
|
-
*/
|
|
44
|
-
stakerSeq(): Promise<bigint>;
|
|
45
|
-
/**
|
|
46
|
-
* Native staker rewards received but not yet flushed to the staking stream
|
|
47
|
-
*/
|
|
48
|
-
pendingStakerRewards(): Promise<bigint>;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=hub.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../../src/contracts/hub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,YAAY,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAErE;;;;;;;GAOG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,OAAO,CAAU;IAEzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAUxB;gBAES,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO;IAMjG,eAAe,CAAC,aAAa,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI;IAM9D;;;OAGG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAStD;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAQ3C;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAQrC;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAQ1C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAQjC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAQjC;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAQlC;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CAO9C"}
|
package/dist/contracts/hub.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlvrHub = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
/**
|
|
6
|
-
* SlvrHub contract interface (read-only).
|
|
7
|
-
*
|
|
8
|
-
* The hub is the protocol emission/sink router: it gates per-game SLVR emission, fans many games
|
|
9
|
-
* into one shared veNFT staker stream, and into one shared jackpot. These bindings expose the
|
|
10
|
-
* informational view surface (emission rate, pending emission, sink addresses); the hub's
|
|
11
|
-
* fee-routing writes are keeper/protocol operations and are intentionally not included.
|
|
12
|
-
*/
|
|
13
|
-
class SlvrHub {
|
|
14
|
-
constructor(publicClient, _walletClient, address) {
|
|
15
|
-
this.publicClient = publicClient;
|
|
16
|
-
this.address = address;
|
|
17
|
-
}
|
|
18
|
-
// Read-only module; kept for a uniform module interface.
|
|
19
|
-
setWalletClient(_walletClient) { }
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
|
-
// Views
|
|
22
|
-
// ---------------------------------------------------------------------------
|
|
23
|
-
/**
|
|
24
|
-
* Accrued-but-unminted SLVR emission currently available to a game (its bucket + streamed since
|
|
25
|
-
* last accrual, hard-capped at one maxAccrualSeconds window of the game's effective rate).
|
|
26
|
-
*/
|
|
27
|
-
async pendingEmission(gameId) {
|
|
28
|
-
return await this.publicClient.readContract({
|
|
29
|
-
address: this.address,
|
|
30
|
-
abi: SlvrHub.ABI,
|
|
31
|
-
functionName: 'pendingEmission',
|
|
32
|
-
args: [gameId],
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Base SLVR/sec emission rate across the whole active game set
|
|
37
|
-
*/
|
|
38
|
-
async emissionRatePerSec() {
|
|
39
|
-
return await this.publicClient.readContract({
|
|
40
|
-
address: this.address,
|
|
41
|
-
abi: SlvrHub.ABI,
|
|
42
|
-
functionName: 'emissionRatePerSec',
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Soft-cap target supply (0 => use token MAX_SUPPLY)
|
|
47
|
-
*/
|
|
48
|
-
async targetSupply() {
|
|
49
|
-
return await this.publicClient.readContract({
|
|
50
|
-
address: this.address,
|
|
51
|
-
abi: SlvrHub.ABI,
|
|
52
|
-
functionName: 'targetSupply',
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Idle-forfeiture window: cap on dt per accrual (seconds)
|
|
57
|
-
*/
|
|
58
|
-
async maxAccrualSeconds() {
|
|
59
|
-
return await this.publicClient.readContract({
|
|
60
|
-
address: this.address,
|
|
61
|
-
abi: SlvrHub.ABI,
|
|
62
|
-
functionName: 'maxAccrualSeconds',
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Address of the shared veNFT staking contract
|
|
67
|
-
*/
|
|
68
|
-
async staking() {
|
|
69
|
-
return await this.publicClient.readContract({
|
|
70
|
-
address: this.address,
|
|
71
|
-
abi: SlvrHub.ABI,
|
|
72
|
-
functionName: 'staking',
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Address of the shared jackpot contract
|
|
77
|
-
*/
|
|
78
|
-
async jackpot() {
|
|
79
|
-
return await this.publicClient.readContract({
|
|
80
|
-
address: this.address,
|
|
81
|
-
abi: SlvrHub.ABI,
|
|
82
|
-
functionName: 'jackpot',
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Hub-owned sequential counter used to feed the staking contract's round numbering
|
|
87
|
-
*/
|
|
88
|
-
async stakerSeq() {
|
|
89
|
-
return await this.publicClient.readContract({
|
|
90
|
-
address: this.address,
|
|
91
|
-
abi: SlvrHub.ABI,
|
|
92
|
-
functionName: 'stakerSeq',
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Native staker rewards received but not yet flushed to the staking stream
|
|
97
|
-
*/
|
|
98
|
-
async pendingStakerRewards() {
|
|
99
|
-
return await this.publicClient.readContract({
|
|
100
|
-
address: this.address,
|
|
101
|
-
abi: SlvrHub.ABI,
|
|
102
|
-
functionName: 'pendingStakerRewards',
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.SlvrHub = SlvrHub;
|
|
107
|
-
SlvrHub.ABI = (0, viem_1.parseAbi)([
|
|
108
|
-
// View functions
|
|
109
|
-
'function pendingEmission(uint256 gameId) view returns (uint256)',
|
|
110
|
-
'function emissionRatePerSec() view returns (uint256)',
|
|
111
|
-
'function targetSupply() view returns (uint256)',
|
|
112
|
-
'function maxAccrualSeconds() view returns (uint256)',
|
|
113
|
-
'function staking() view returns (address)',
|
|
114
|
-
'function jackpot() view returns (address)',
|
|
115
|
-
'function stakerSeq() view returns (uint256)',
|
|
116
|
-
'function pendingStakerRewards() view returns (uint256)',
|
|
117
|
-
]);
|
|
118
|
-
//# sourceMappingURL=hub.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hub.js","sourceRoot":"","sources":["../../src/contracts/hub.ts"],"names":[],"mappings":";;;AAAA,+BAAqE;AAErE;;;;;;;GAOG;AACH,MAAa,OAAO;IAgBlB,YAAY,YAA0B,EAAE,aAAuC,EAAE,OAAgB;QAC/F,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,yDAAyD;IACzD,eAAe,CAAC,aAA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AO;QACX,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;YAC1C,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,YAAY,EAAE,SAAS;SACxB,CAAY,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS;QACb,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;YAC1C,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,YAAY,EAAE,WAAW;SAC1B,CAAW,CAAC;IACf,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB;QACxB,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;YAC1C,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,YAAY,EAAE,sBAAsB;SACrC,CAAW,CAAC;IACf,CAAC;;AApHH,0BAqHC;AAjHyB,WAAG,GAAG,IAAA,eAAQ,EAAC;IACrC,iBAAiB;IACjB,iEAAiE;IACjE,sDAAsD;IACtD,gDAAgD;IAChD,qDAAqD;IACrD,2CAA2C;IAC3C,2CAA2C;IAC3C,6CAA6C;IAC7C,wDAAwD;CACzD,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { SlvrGridLottery } from './lottery';
|
|
2
|
-
export { SlvrStaking } from './staking';
|
|
3
|
-
export { SlvrToken } from './token';
|
|
4
|
-
export { SlvrAutoCommit } from './autoCommit';
|
|
5
|
-
export { SlvrHub } from './hub';
|
|
6
|
-
export { SlvrGameRegistry } from './registry';
|
|
7
|
-
export { SlvrJackpot } from './jackpot';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/contracts/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlvrJackpot = exports.SlvrGameRegistry = exports.SlvrHub = exports.SlvrAutoCommit = exports.SlvrToken = exports.SlvrStaking = exports.SlvrGridLottery = void 0;
|
|
4
|
-
var lottery_1 = require("./lottery");
|
|
5
|
-
Object.defineProperty(exports, "SlvrGridLottery", { enumerable: true, get: function () { return lottery_1.SlvrGridLottery; } });
|
|
6
|
-
var staking_1 = require("./staking");
|
|
7
|
-
Object.defineProperty(exports, "SlvrStaking", { enumerable: true, get: function () { return staking_1.SlvrStaking; } });
|
|
8
|
-
var token_1 = require("./token");
|
|
9
|
-
Object.defineProperty(exports, "SlvrToken", { enumerable: true, get: function () { return token_1.SlvrToken; } });
|
|
10
|
-
var autoCommit_1 = require("./autoCommit");
|
|
11
|
-
Object.defineProperty(exports, "SlvrAutoCommit", { enumerable: true, get: function () { return autoCommit_1.SlvrAutoCommit; } });
|
|
12
|
-
var hub_1 = require("./hub");
|
|
13
|
-
Object.defineProperty(exports, "SlvrHub", { enumerable: true, get: function () { return hub_1.SlvrHub; } });
|
|
14
|
-
var registry_1 = require("./registry");
|
|
15
|
-
Object.defineProperty(exports, "SlvrGameRegistry", { enumerable: true, get: function () { return registry_1.SlvrGameRegistry; } });
|
|
16
|
-
var jackpot_1 = require("./jackpot");
|
|
17
|
-
Object.defineProperty(exports, "SlvrJackpot", { enumerable: true, get: function () { return jackpot_1.SlvrJackpot; } });
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAAnC,0GAAA,eAAe,OAAA;AACxB,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;AACpB,iCAAoC;AAA3B,kGAAA,SAAS,OAAA;AAClB,2CAA8C;AAArC,4GAAA,cAAc,OAAA;AACvB,6BAAgC;AAAvB,8FAAA,OAAO,OAAA;AAChB,uCAA8C;AAArC,4GAAA,gBAAgB,OAAA;AACzB,qCAAwC;AAA/B,sGAAA,WAAW,OAAA"}
|