@jpool/bond-sdk 0.1.0-next.1 → 0.1.0-next.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/dist/index.d.mts +866 -0
- package/dist/index.d.ts +866 -0
- package/dist/index.js +1202 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1191 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +8 -4
- package/.release-it.cjs +0 -1
- package/CHANGELOG.md +0 -21
- package/src/client.ts +0 -568
- package/src/common.ts +0 -2
- package/src/config.ts +0 -31
- package/src/helpers.ts +0 -7
- package/src/idl/jbond.json +0 -707
- package/src/index.ts +0 -8
- package/src/types/index.ts +0 -96
- package/src/types/jbond.ts +0 -713
- package/src/utils/wallet.ts +0 -45
- package/tsconfig.json +0 -39
- package/tsup.config.ts +0 -19
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,866 @@
|
|
|
1
|
+
import { BN, Program, AnchorProvider, Wallet } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey, Connection, Keypair, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
+
|
|
4
|
+
type Config = {
|
|
5
|
+
rpcUrl: string;
|
|
6
|
+
programId: PublicKey;
|
|
7
|
+
reserveAddress: PublicKey;
|
|
8
|
+
};
|
|
9
|
+
type ValidatorBondAccount = {
|
|
10
|
+
identity: PublicKey;
|
|
11
|
+
voteAccount: PublicKey;
|
|
12
|
+
withdrawalAuthority?: string;
|
|
13
|
+
totalWithdrawn: number;
|
|
14
|
+
lastWithdrawalEpoch: number;
|
|
15
|
+
isActive: boolean;
|
|
16
|
+
createdAt: number;
|
|
17
|
+
bump: number;
|
|
18
|
+
};
|
|
19
|
+
type InitializeProps = {
|
|
20
|
+
authority: PublicKey;
|
|
21
|
+
};
|
|
22
|
+
type RegisterValidatorProps = {
|
|
23
|
+
creator: PublicKey;
|
|
24
|
+
identity: PublicKey;
|
|
25
|
+
voteAccount: PublicKey;
|
|
26
|
+
initialCollateral: number;
|
|
27
|
+
withdrawalAuthority?: PublicKey;
|
|
28
|
+
};
|
|
29
|
+
type TopUpCollateralProps = {
|
|
30
|
+
user: PublicKey;
|
|
31
|
+
voteAccount: PublicKey;
|
|
32
|
+
amount: number;
|
|
33
|
+
};
|
|
34
|
+
type WithdrawCollateralProps = {
|
|
35
|
+
withdrawalAuthority: PublicKey;
|
|
36
|
+
voteAccount: PublicKey;
|
|
37
|
+
destination: PublicKey;
|
|
38
|
+
amount: number;
|
|
39
|
+
};
|
|
40
|
+
type WithdrawCompensationProps = {
|
|
41
|
+
authority: PublicKey;
|
|
42
|
+
voteAccount: PublicKey;
|
|
43
|
+
amount: number;
|
|
44
|
+
};
|
|
45
|
+
type GetHistoryProps = {
|
|
46
|
+
voteAccount: PublicKey;
|
|
47
|
+
options?: {
|
|
48
|
+
limit?: number;
|
|
49
|
+
before?: string;
|
|
50
|
+
until?: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
type GetHistoryGroupedProps = {
|
|
54
|
+
voteAccount: PublicKey;
|
|
55
|
+
epochsCount?: number;
|
|
56
|
+
};
|
|
57
|
+
type GlobalState = {
|
|
58
|
+
authority: PublicKey;
|
|
59
|
+
totalValidators: number;
|
|
60
|
+
totalCollateral: BN;
|
|
61
|
+
totalWithdrawn: BN;
|
|
62
|
+
bump: number;
|
|
63
|
+
};
|
|
64
|
+
type EpochHistoryItem = {
|
|
65
|
+
epoch: number;
|
|
66
|
+
deposits: number;
|
|
67
|
+
withdrawals: number;
|
|
68
|
+
balanceChange: number;
|
|
69
|
+
signatures: string[];
|
|
70
|
+
};
|
|
71
|
+
type TransactionHistoryItem = {
|
|
72
|
+
signature: string;
|
|
73
|
+
slot: number;
|
|
74
|
+
epoch: number;
|
|
75
|
+
type: BondTransactionType;
|
|
76
|
+
amount: number;
|
|
77
|
+
beforeBalance?: number;
|
|
78
|
+
afterBalance?: number;
|
|
79
|
+
};
|
|
80
|
+
declare enum BondTransactionType {
|
|
81
|
+
Deposit = "deposit",
|
|
82
|
+
Withdrawal = "withdrawal",
|
|
83
|
+
Compensation = "compensation"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
88
|
+
*
|
|
89
|
+
* Note that this is only a type helper and is not the actual IDL. The original
|
|
90
|
+
* IDL can be found at `target/idl/jbond.json`.
|
|
91
|
+
*/
|
|
92
|
+
type Jbond = {
|
|
93
|
+
address: '4a3YovKEfm4jWhczCzJciHXL1xVkXWfGQjRCaMft7M4G';
|
|
94
|
+
metadata: {
|
|
95
|
+
name: 'jbond';
|
|
96
|
+
version: '0.1.0';
|
|
97
|
+
spec: '0.1.0';
|
|
98
|
+
description: 'Validator compensation program for boosting APR';
|
|
99
|
+
};
|
|
100
|
+
instructions: [
|
|
101
|
+
{
|
|
102
|
+
name: 'bondInit';
|
|
103
|
+
docs: [
|
|
104
|
+
'Register validator and fund initial collateral'
|
|
105
|
+
];
|
|
106
|
+
discriminator: [
|
|
107
|
+
220,
|
|
108
|
+
108,
|
|
109
|
+
156,
|
|
110
|
+
81,
|
|
111
|
+
16,
|
|
112
|
+
185,
|
|
113
|
+
144,
|
|
114
|
+
157
|
|
115
|
+
];
|
|
116
|
+
accounts: [
|
|
117
|
+
{
|
|
118
|
+
name: 'globalState';
|
|
119
|
+
writable: true;
|
|
120
|
+
pda: {
|
|
121
|
+
seeds: [
|
|
122
|
+
{
|
|
123
|
+
kind: 'const';
|
|
124
|
+
value: [
|
|
125
|
+
103,
|
|
126
|
+
108,
|
|
127
|
+
111,
|
|
128
|
+
98,
|
|
129
|
+
97,
|
|
130
|
+
108,
|
|
131
|
+
95,
|
|
132
|
+
115,
|
|
133
|
+
116,
|
|
134
|
+
97,
|
|
135
|
+
116,
|
|
136
|
+
101
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
];
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'validatorBondAccount';
|
|
144
|
+
writable: true;
|
|
145
|
+
pda: {
|
|
146
|
+
seeds: [
|
|
147
|
+
{
|
|
148
|
+
kind: 'const';
|
|
149
|
+
value: [
|
|
150
|
+
118,
|
|
151
|
+
97,
|
|
152
|
+
108,
|
|
153
|
+
105,
|
|
154
|
+
100,
|
|
155
|
+
97,
|
|
156
|
+
116,
|
|
157
|
+
111,
|
|
158
|
+
114,
|
|
159
|
+
95,
|
|
160
|
+
98,
|
|
161
|
+
111,
|
|
162
|
+
110,
|
|
163
|
+
100
|
|
164
|
+
];
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
kind: 'account';
|
|
168
|
+
path: 'voteAccount';
|
|
169
|
+
}
|
|
170
|
+
];
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'identity';
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: 'voteAccount';
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: 'creator';
|
|
181
|
+
docs: [
|
|
182
|
+
'The account creating the bond (pays for account creation and initial collateral)'
|
|
183
|
+
];
|
|
184
|
+
writable: true;
|
|
185
|
+
signer: true;
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'systemProgram';
|
|
189
|
+
address: '11111111111111111111111111111111';
|
|
190
|
+
}
|
|
191
|
+
];
|
|
192
|
+
args: [
|
|
193
|
+
{
|
|
194
|
+
name: 'initialCollateral';
|
|
195
|
+
type: 'u64';
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'withdrawalAuthority';
|
|
199
|
+
type: {
|
|
200
|
+
option: 'pubkey';
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
];
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: 'bondTopUp';
|
|
207
|
+
docs: [
|
|
208
|
+
'Top up collateral for existing validator'
|
|
209
|
+
];
|
|
210
|
+
discriminator: [
|
|
211
|
+
132,
|
|
212
|
+
225,
|
|
213
|
+
254,
|
|
214
|
+
187,
|
|
215
|
+
152,
|
|
216
|
+
162,
|
|
217
|
+
176,
|
|
218
|
+
66
|
|
219
|
+
];
|
|
220
|
+
accounts: [
|
|
221
|
+
{
|
|
222
|
+
name: 'validatorBondAccount';
|
|
223
|
+
writable: true;
|
|
224
|
+
pda: {
|
|
225
|
+
seeds: [
|
|
226
|
+
{
|
|
227
|
+
kind: 'const';
|
|
228
|
+
value: [
|
|
229
|
+
118,
|
|
230
|
+
97,
|
|
231
|
+
108,
|
|
232
|
+
105,
|
|
233
|
+
100,
|
|
234
|
+
97,
|
|
235
|
+
116,
|
|
236
|
+
111,
|
|
237
|
+
114,
|
|
238
|
+
95,
|
|
239
|
+
98,
|
|
240
|
+
111,
|
|
241
|
+
110,
|
|
242
|
+
100
|
|
243
|
+
];
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
kind: 'account';
|
|
247
|
+
path: 'validator_bond_account.vote_account';
|
|
248
|
+
account: 'validatorBondAccount';
|
|
249
|
+
}
|
|
250
|
+
];
|
|
251
|
+
};
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: 'depositor';
|
|
255
|
+
writable: true;
|
|
256
|
+
signer: true;
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: 'systemProgram';
|
|
260
|
+
address: '11111111111111111111111111111111';
|
|
261
|
+
}
|
|
262
|
+
];
|
|
263
|
+
args: [
|
|
264
|
+
{
|
|
265
|
+
name: 'amount';
|
|
266
|
+
type: 'u64';
|
|
267
|
+
}
|
|
268
|
+
];
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: 'bondWithdraw';
|
|
272
|
+
discriminator: [
|
|
273
|
+
99,
|
|
274
|
+
64,
|
|
275
|
+
127,
|
|
276
|
+
178,
|
|
277
|
+
53,
|
|
278
|
+
117,
|
|
279
|
+
70,
|
|
280
|
+
204
|
|
281
|
+
];
|
|
282
|
+
accounts: [
|
|
283
|
+
{
|
|
284
|
+
name: 'validatorBondAccount';
|
|
285
|
+
writable: true;
|
|
286
|
+
pda: {
|
|
287
|
+
seeds: [
|
|
288
|
+
{
|
|
289
|
+
kind: 'const';
|
|
290
|
+
value: [
|
|
291
|
+
118,
|
|
292
|
+
97,
|
|
293
|
+
108,
|
|
294
|
+
105,
|
|
295
|
+
100,
|
|
296
|
+
97,
|
|
297
|
+
116,
|
|
298
|
+
111,
|
|
299
|
+
114,
|
|
300
|
+
95,
|
|
301
|
+
98,
|
|
302
|
+
111,
|
|
303
|
+
110,
|
|
304
|
+
100
|
|
305
|
+
];
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
kind: 'account';
|
|
309
|
+
path: 'validator_bond_account.vote_account';
|
|
310
|
+
account: 'validatorBondAccount';
|
|
311
|
+
}
|
|
312
|
+
];
|
|
313
|
+
};
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
name: 'withdrawalAuthority';
|
|
317
|
+
writable: true;
|
|
318
|
+
signer: true;
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: 'destination';
|
|
322
|
+
writable: true;
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
name: 'systemProgram';
|
|
326
|
+
address: '11111111111111111111111111111111';
|
|
327
|
+
}
|
|
328
|
+
];
|
|
329
|
+
args: [
|
|
330
|
+
{
|
|
331
|
+
name: 'amount';
|
|
332
|
+
type: 'u64';
|
|
333
|
+
}
|
|
334
|
+
];
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: 'initialize';
|
|
338
|
+
docs: [
|
|
339
|
+
'Initialize the global state and reserve vault'
|
|
340
|
+
];
|
|
341
|
+
discriminator: [
|
|
342
|
+
175,
|
|
343
|
+
175,
|
|
344
|
+
109,
|
|
345
|
+
31,
|
|
346
|
+
13,
|
|
347
|
+
152,
|
|
348
|
+
155,
|
|
349
|
+
237
|
|
350
|
+
];
|
|
351
|
+
accounts: [
|
|
352
|
+
{
|
|
353
|
+
name: 'globalState';
|
|
354
|
+
writable: true;
|
|
355
|
+
pda: {
|
|
356
|
+
seeds: [
|
|
357
|
+
{
|
|
358
|
+
kind: 'const';
|
|
359
|
+
value: [
|
|
360
|
+
103,
|
|
361
|
+
108,
|
|
362
|
+
111,
|
|
363
|
+
98,
|
|
364
|
+
97,
|
|
365
|
+
108,
|
|
366
|
+
95,
|
|
367
|
+
115,
|
|
368
|
+
116,
|
|
369
|
+
97,
|
|
370
|
+
116,
|
|
371
|
+
101
|
|
372
|
+
];
|
|
373
|
+
}
|
|
374
|
+
];
|
|
375
|
+
};
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
name: 'authority';
|
|
379
|
+
writable: true;
|
|
380
|
+
signer: true;
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: 'reserve';
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
name: 'systemProgram';
|
|
387
|
+
address: '11111111111111111111111111111111';
|
|
388
|
+
}
|
|
389
|
+
];
|
|
390
|
+
args: [];
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
name: 'withdrawCompensation';
|
|
394
|
+
docs: [
|
|
395
|
+
'Withdraw compensation from validator to reserve (oracle only)'
|
|
396
|
+
];
|
|
397
|
+
discriminator: [
|
|
398
|
+
10,
|
|
399
|
+
228,
|
|
400
|
+
22,
|
|
401
|
+
213,
|
|
402
|
+
205,
|
|
403
|
+
117,
|
|
404
|
+
181,
|
|
405
|
+
75
|
|
406
|
+
];
|
|
407
|
+
accounts: [
|
|
408
|
+
{
|
|
409
|
+
name: 'globalState';
|
|
410
|
+
writable: true;
|
|
411
|
+
pda: {
|
|
412
|
+
seeds: [
|
|
413
|
+
{
|
|
414
|
+
kind: 'const';
|
|
415
|
+
value: [
|
|
416
|
+
103,
|
|
417
|
+
108,
|
|
418
|
+
111,
|
|
419
|
+
98,
|
|
420
|
+
97,
|
|
421
|
+
108,
|
|
422
|
+
95,
|
|
423
|
+
115,
|
|
424
|
+
116,
|
|
425
|
+
97,
|
|
426
|
+
116,
|
|
427
|
+
101
|
|
428
|
+
];
|
|
429
|
+
}
|
|
430
|
+
];
|
|
431
|
+
};
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
name: 'validatorBondAccount';
|
|
435
|
+
writable: true;
|
|
436
|
+
pda: {
|
|
437
|
+
seeds: [
|
|
438
|
+
{
|
|
439
|
+
kind: 'const';
|
|
440
|
+
value: [
|
|
441
|
+
118,
|
|
442
|
+
97,
|
|
443
|
+
108,
|
|
444
|
+
105,
|
|
445
|
+
100,
|
|
446
|
+
97,
|
|
447
|
+
116,
|
|
448
|
+
111,
|
|
449
|
+
114,
|
|
450
|
+
95,
|
|
451
|
+
98,
|
|
452
|
+
111,
|
|
453
|
+
110,
|
|
454
|
+
100
|
|
455
|
+
];
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
kind: 'account';
|
|
459
|
+
path: 'validator_bond_account.vote_account';
|
|
460
|
+
account: 'validatorBondAccount';
|
|
461
|
+
}
|
|
462
|
+
];
|
|
463
|
+
};
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
name: 'reserve';
|
|
467
|
+
writable: true;
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
name: 'authority';
|
|
471
|
+
docs: [
|
|
472
|
+
'Authority that can trigger claims'
|
|
473
|
+
];
|
|
474
|
+
signer: true;
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
name: 'systemProgram';
|
|
478
|
+
address: '11111111111111111111111111111111';
|
|
479
|
+
}
|
|
480
|
+
];
|
|
481
|
+
args: [
|
|
482
|
+
{
|
|
483
|
+
name: 'amount';
|
|
484
|
+
type: 'u64';
|
|
485
|
+
}
|
|
486
|
+
];
|
|
487
|
+
}
|
|
488
|
+
];
|
|
489
|
+
accounts: [
|
|
490
|
+
{
|
|
491
|
+
name: 'globalState';
|
|
492
|
+
discriminator: [
|
|
493
|
+
163,
|
|
494
|
+
46,
|
|
495
|
+
74,
|
|
496
|
+
168,
|
|
497
|
+
216,
|
|
498
|
+
123,
|
|
499
|
+
133,
|
|
500
|
+
98
|
|
501
|
+
];
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
name: 'validatorBondAccount';
|
|
505
|
+
discriminator: [
|
|
506
|
+
25,
|
|
507
|
+
67,
|
|
508
|
+
241,
|
|
509
|
+
227,
|
|
510
|
+
226,
|
|
511
|
+
104,
|
|
512
|
+
108,
|
|
513
|
+
73
|
|
514
|
+
];
|
|
515
|
+
}
|
|
516
|
+
];
|
|
517
|
+
events: [
|
|
518
|
+
{
|
|
519
|
+
name: 'collateralToppedUp';
|
|
520
|
+
discriminator: [
|
|
521
|
+
189,
|
|
522
|
+
137,
|
|
523
|
+
204,
|
|
524
|
+
58,
|
|
525
|
+
135,
|
|
526
|
+
182,
|
|
527
|
+
19,
|
|
528
|
+
176
|
|
529
|
+
];
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
name: 'collateralWithdrawn';
|
|
533
|
+
discriminator: [
|
|
534
|
+
51,
|
|
535
|
+
224,
|
|
536
|
+
133,
|
|
537
|
+
106,
|
|
538
|
+
74,
|
|
539
|
+
173,
|
|
540
|
+
72,
|
|
541
|
+
82
|
|
542
|
+
];
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
name: 'compensationClaimed';
|
|
546
|
+
discriminator: [
|
|
547
|
+
36,
|
|
548
|
+
159,
|
|
549
|
+
41,
|
|
550
|
+
178,
|
|
551
|
+
104,
|
|
552
|
+
135,
|
|
553
|
+
220,
|
|
554
|
+
32
|
|
555
|
+
];
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
name: 'validatorRegistered';
|
|
559
|
+
discriminator: [
|
|
560
|
+
20,
|
|
561
|
+
20,
|
|
562
|
+
190,
|
|
563
|
+
191,
|
|
564
|
+
53,
|
|
565
|
+
174,
|
|
566
|
+
95,
|
|
567
|
+
72
|
|
568
|
+
];
|
|
569
|
+
}
|
|
570
|
+
];
|
|
571
|
+
errors: [
|
|
572
|
+
{
|
|
573
|
+
code: 6000;
|
|
574
|
+
name: 'invalidVoteAccount';
|
|
575
|
+
msg: 'Invalid vote account';
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
code: 6001;
|
|
579
|
+
name: 'identityMismatch';
|
|
580
|
+
msg: 'Identity does not match vote account';
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
code: 6002;
|
|
584
|
+
name: 'insufficientCollateral';
|
|
585
|
+
msg: 'Insufficient collateral amount';
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
code: 6003;
|
|
589
|
+
name: 'targetAprTooLow';
|
|
590
|
+
msg: 'Target APR is below minimum threshold';
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
code: 6004;
|
|
594
|
+
name: 'mathOverflow';
|
|
595
|
+
msg: 'Math overflow';
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
code: 6005;
|
|
599
|
+
name: 'invalidAmount';
|
|
600
|
+
msg: 'Invalid amount';
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
code: 6006;
|
|
604
|
+
name: 'validatorNotActive';
|
|
605
|
+
msg: 'Validator boost account is not active';
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
code: 6007;
|
|
609
|
+
name: 'validatorAlreadyRegistered';
|
|
610
|
+
msg: 'Validator already registered';
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
code: 6008;
|
|
614
|
+
name: 'unauthorized';
|
|
615
|
+
msg: 'unauthorized';
|
|
616
|
+
}
|
|
617
|
+
];
|
|
618
|
+
types: [
|
|
619
|
+
{
|
|
620
|
+
name: 'collateralToppedUp';
|
|
621
|
+
type: {
|
|
622
|
+
kind: 'struct';
|
|
623
|
+
fields: [
|
|
624
|
+
{
|
|
625
|
+
name: 'validator';
|
|
626
|
+
type: 'pubkey';
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
name: 'amount';
|
|
630
|
+
type: 'u64';
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
name: 'newTotal';
|
|
634
|
+
type: 'u64';
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
name: 'timestamp';
|
|
638
|
+
type: 'i64';
|
|
639
|
+
}
|
|
640
|
+
];
|
|
641
|
+
};
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
name: 'collateralWithdrawn';
|
|
645
|
+
type: {
|
|
646
|
+
kind: 'struct';
|
|
647
|
+
fields: [
|
|
648
|
+
{
|
|
649
|
+
name: 'validator';
|
|
650
|
+
type: 'pubkey';
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
name: 'amount';
|
|
654
|
+
type: 'u64';
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
name: 'remainingCollateral';
|
|
658
|
+
type: 'u64';
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
name: 'timestamp';
|
|
662
|
+
type: 'i64';
|
|
663
|
+
}
|
|
664
|
+
];
|
|
665
|
+
};
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
name: 'compensationClaimed';
|
|
669
|
+
type: {
|
|
670
|
+
kind: 'struct';
|
|
671
|
+
fields: [
|
|
672
|
+
{
|
|
673
|
+
name: 'validator';
|
|
674
|
+
type: 'pubkey';
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
name: 'amount';
|
|
678
|
+
type: 'u64';
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
name: 'remainingCollateral';
|
|
682
|
+
type: 'u64';
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
name: 'totalWithdrawn';
|
|
686
|
+
type: 'u64';
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
name: 'epoch';
|
|
690
|
+
type: 'u64';
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
name: 'timestamp';
|
|
694
|
+
type: 'i64';
|
|
695
|
+
}
|
|
696
|
+
];
|
|
697
|
+
};
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
name: 'globalState';
|
|
701
|
+
type: {
|
|
702
|
+
kind: 'struct';
|
|
703
|
+
fields: [
|
|
704
|
+
{
|
|
705
|
+
name: 'authority';
|
|
706
|
+
type: 'pubkey';
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
name: 'reserve';
|
|
710
|
+
type: 'pubkey';
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
name: 'totalValidators';
|
|
714
|
+
type: 'u32';
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
name: 'totalWithdrawn';
|
|
718
|
+
type: 'u64';
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
name: 'bump';
|
|
722
|
+
type: 'u8';
|
|
723
|
+
}
|
|
724
|
+
];
|
|
725
|
+
};
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
name: 'validatorBondAccount';
|
|
729
|
+
type: {
|
|
730
|
+
kind: 'struct';
|
|
731
|
+
fields: [
|
|
732
|
+
{
|
|
733
|
+
name: 'identity';
|
|
734
|
+
type: 'pubkey';
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
name: 'voteAccount';
|
|
738
|
+
type: 'pubkey';
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
name: 'creator';
|
|
742
|
+
type: 'pubkey';
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
name: 'withdrawalAuthority';
|
|
746
|
+
type: {
|
|
747
|
+
option: 'pubkey';
|
|
748
|
+
};
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
name: 'totalWithdrawn';
|
|
752
|
+
type: 'u64';
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
name: 'lastWithdrawalEpoch';
|
|
756
|
+
type: 'u64';
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
name: 'isActive';
|
|
760
|
+
type: 'bool';
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
name: 'createdAt';
|
|
764
|
+
type: 'i64';
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
name: 'bump';
|
|
768
|
+
type: 'u8';
|
|
769
|
+
}
|
|
770
|
+
];
|
|
771
|
+
};
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
name: 'validatorRegistered';
|
|
775
|
+
type: {
|
|
776
|
+
kind: 'struct';
|
|
777
|
+
fields: [
|
|
778
|
+
{
|
|
779
|
+
name: 'validator';
|
|
780
|
+
type: 'pubkey';
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
name: 'voteAccount';
|
|
784
|
+
type: 'pubkey';
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
name: 'collateralAmount';
|
|
788
|
+
type: 'u64';
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
name: 'timestamp';
|
|
792
|
+
type: 'i64';
|
|
793
|
+
}
|
|
794
|
+
];
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
];
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
declare class JBondClient {
|
|
801
|
+
connection: Connection;
|
|
802
|
+
program: Program<Jbond>;
|
|
803
|
+
provider: AnchorProvider;
|
|
804
|
+
config: Config;
|
|
805
|
+
constructor(config: Config, wallet?: Wallet);
|
|
806
|
+
/**
|
|
807
|
+
* Creates an instance of `JBondClient` using a provided connection and wallet.
|
|
808
|
+
*/
|
|
809
|
+
static fromWallet(config: Config, wallet?: Wallet): JBondClient;
|
|
810
|
+
/**
|
|
811
|
+
* Creates an instance of `JBondClient` using the provided connection and keypair.
|
|
812
|
+
*/
|
|
813
|
+
static fromKeypair(config: Config, keypair: Keypair): JBondClient;
|
|
814
|
+
getGlobalStatePDA(): [PublicKey, number];
|
|
815
|
+
getValidatorBondPDA(voteAccount: PublicKey): [PublicKey, number];
|
|
816
|
+
buildInitializeInstruction(props: InitializeProps): Promise<TransactionInstruction>;
|
|
817
|
+
buildRegisterValidatorInstruction(props: RegisterValidatorProps): Promise<TransactionInstruction>;
|
|
818
|
+
buildTopUpCollateralInstruction(props: TopUpCollateralProps): Promise<TransactionInstruction>;
|
|
819
|
+
buildWithdrawCollateralInstruction(props: WithdrawCollateralProps): Promise<TransactionInstruction>;
|
|
820
|
+
buildWithdrawCompensationInstruction(props: WithdrawCompensationProps): Promise<TransactionInstruction>;
|
|
821
|
+
buildWithdrawCompensationsInstructions(authority: PublicKey, withdrawals: Array<{
|
|
822
|
+
voteAccount: PublicKey;
|
|
823
|
+
amount: number;
|
|
824
|
+
}>): Promise<TransactionInstruction[]>;
|
|
825
|
+
getValidatorBondAccount(voteAccount: PublicKey): Promise<ValidatorBondAccount | null>;
|
|
826
|
+
/**
|
|
827
|
+
* Get the collateral balance of a validator bond account
|
|
828
|
+
* @param voteAccount - The vote account public key
|
|
829
|
+
* @returns The available collateral balance in SOL (excluding rent-exempt amount)
|
|
830
|
+
*/
|
|
831
|
+
getValidatorCollateralBalance(voteAccount: PublicKey): Promise<number>;
|
|
832
|
+
getGlobalState(): Promise<{
|
|
833
|
+
authority: string;
|
|
834
|
+
totalValidators: number;
|
|
835
|
+
totalWithdrawn: number;
|
|
836
|
+
} | null>;
|
|
837
|
+
getCurrentEpoch(): Promise<number>;
|
|
838
|
+
initialize(authority?: PublicKey): Promise<string>;
|
|
839
|
+
registerValidator(voteAccount: PublicKey, initialCollateral: number, withdrawalAuthority?: PublicKey, identity?: PublicKey): Promise<string>;
|
|
840
|
+
topUpCollateral(voteAccount: PublicKey, amount: number, validator?: PublicKey): Promise<string>;
|
|
841
|
+
withdrawCollateral(voteAccount: PublicKey, destination: PublicKey, amount: number, withdrawalAuthority?: PublicKey): Promise<string>;
|
|
842
|
+
claimCompensation(voteAccount: PublicKey, amount: number, authority?: PublicKey): Promise<string>;
|
|
843
|
+
/**
|
|
844
|
+
* Get transaction history grouped by epochs
|
|
845
|
+
* @param voteAccount - The vote account to get history for
|
|
846
|
+
* @param epochsCount - Number of recent epochs to return (default: 10)
|
|
847
|
+
* @returns Array of epoch history items sorted by epoch (descending)
|
|
848
|
+
*/
|
|
849
|
+
getHistoryGroupedByEpochs(voteAccount: PublicKey, epochsCount?: number): Promise<EpochHistoryItem[]>;
|
|
850
|
+
getHistory(voteAccount: PublicKey, options?: {
|
|
851
|
+
cluster?: 'mainnet-beta' | 'testnet' | 'devnet';
|
|
852
|
+
limit?: number;
|
|
853
|
+
before?: string;
|
|
854
|
+
until?: string;
|
|
855
|
+
}): Promise<TransactionHistoryItem[]>;
|
|
856
|
+
getFullHistory(voteAccount: PublicKey, pageSize?: number): Promise<TransactionHistoryItem[]>;
|
|
857
|
+
private getInstructionDiscriminator;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
declare const PROGRAM_ID = "4a3YovKEfm4jWhczCzJciHXL1xVkXWfGQjRCaMft7M4G";
|
|
861
|
+
declare const RESERVE_ADDRESS = "61mS9nEir6jx6cvte6NzQpyrFk3Fj4krMNLuHhi4tjJz";
|
|
862
|
+
|
|
863
|
+
declare function loadConfig(): Config;
|
|
864
|
+
declare function loadKeypair(keypairPath: string): Keypair;
|
|
865
|
+
|
|
866
|
+
export { BondTransactionType, type Config, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, PROGRAM_ID, RESERVE_ADDRESS, type RegisterValidatorProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBondAccount, type WithdrawCollateralProps, type WithdrawCompensationProps, loadConfig, loadKeypair };
|