@jpool/bond-sdk 0.3.0-next.7 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,86 @@
1
- import * as _solana_web3_js from '@solana/web3.js';
2
- import { PublicKey, Connection, Keypair, Transaction, VersionedTransaction } from '@solana/web3.js';
3
- import { BN, AnchorProvider, Program, Wallet as Wallet$1 } from '@coral-xyz/anchor';
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
+ };
7
+ type ValidatorBondAccount = {
8
+ identity: PublicKey;
9
+ voteAccount: PublicKey;
10
+ withdrawalAuthority?: string;
11
+ totalWithdrawn: number;
12
+ lastWithdrawalEpoch: number;
13
+ isActive: boolean;
14
+ createdAt: number;
15
+ bump: number;
16
+ };
17
+ type InitializeProps = {
18
+ authority: PublicKey;
19
+ reserveAddress: PublicKey;
20
+ };
21
+ type RegisterValidatorProps = {
22
+ creator: PublicKey;
23
+ identity: PublicKey;
24
+ voteAccount: PublicKey;
25
+ initialCollateral: number;
26
+ withdrawalAuthority?: PublicKey;
27
+ };
28
+ type TopUpCollateralProps = {
29
+ user: PublicKey;
30
+ voteAccount: PublicKey;
31
+ amount: number;
32
+ };
33
+ type WithdrawCollateralProps = {
34
+ withdrawalAuthority: PublicKey;
35
+ voteAccount: PublicKey;
36
+ destination: PublicKey;
37
+ amount: number;
38
+ };
39
+ type WithdrawCompensationProps = {
40
+ authority: PublicKey;
41
+ voteAccount: PublicKey;
42
+ amount: number;
43
+ };
44
+ type GetHistoryProps = {
45
+ voteAccount: PublicKey;
46
+ options?: {
47
+ limit?: number;
48
+ before?: string;
49
+ until?: string;
50
+ };
51
+ };
52
+ type GetHistoryGroupedProps = {
53
+ voteAccount: PublicKey;
54
+ epochsCount?: number;
55
+ };
56
+ type GlobalState = {
57
+ authority: PublicKey;
58
+ totalValidators: number;
59
+ totalCollateral: BN;
60
+ totalWithdrawn: BN;
61
+ bump: number;
62
+ };
63
+ type EpochHistoryItem = {
64
+ epoch: number;
65
+ deposits: number;
66
+ withdrawals: number;
67
+ balanceChange: number;
68
+ signatures: string[];
69
+ };
70
+ type TransactionHistoryItem = {
71
+ signature: string;
72
+ slot: number;
73
+ epoch: number;
74
+ type: BondTransactionType;
75
+ amount: number;
76
+ beforeBalance?: number;
77
+ afterBalance?: number;
78
+ };
79
+ declare enum BondTransactionType {
80
+ Deposit = "deposit",
81
+ Withdrawal = "withdrawal",
82
+ Compensation = "compensation"
83
+ }
4
84
 
5
85
  /**
6
86
  * Program IDL in camelCase format in order to be used in JS/TS.
@@ -9,46 +89,38 @@ import { BN, AnchorProvider, Program, Wallet as Wallet$1 } from '@coral-xyz/anch
9
89
  * IDL can be found at `target/idl/jbond.json`.
10
90
  */
11
91
  type Jbond = {
12
- "address": "BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU";
13
- "metadata": {
14
- "name": "jbond";
15
- "version": "0.2.0";
16
- "spec": "0.1.0";
17
- "description": "Jpool Bond Program";
92
+ address: '8vrqsFHnDdjMYMwahytRzmmYgRqCMmka8X6DJUXGQzWr';
93
+ metadata: {
94
+ name: 'jbond';
95
+ version: '0.1.0';
96
+ spec: '0.1.0';
97
+ description: 'Validator compensation program for boosting APR';
18
98
  };
19
- "instructions": [
99
+ instructions: [
20
100
  {
21
- "name": "claim";
22
- "docs": [
23
- "Claims compensation for a validator.",
24
- "Transfers funds from the validator's bond account to reserve.",
25
- "",
26
- "# Arguments",
27
- "* `amount` - Amount of compensation to claim (must be positive).",
28
- "",
29
- "# Errors",
30
- "Fails if the authority is invalid, if the validator is not active,",
31
- "if the amount is zero, or if there are insufficient funds."
101
+ name: 'bondInit';
102
+ docs: [
103
+ 'Register validator and fund initial collateral'
32
104
  ];
33
- "discriminator": [
34
- 62,
35
- 198,
36
- 214,
37
- 193,
38
- 213,
39
- 159,
105
+ discriminator: [
106
+ 220,
40
107
  108,
41
- 210
108
+ 156,
109
+ 81,
110
+ 16,
111
+ 185,
112
+ 144,
113
+ 157
42
114
  ];
43
- "accounts": [
115
+ accounts: [
44
116
  {
45
- "name": "globalState";
46
- "writable": true;
47
- "pda": {
48
- "seeds": [
117
+ name: 'globalState';
118
+ writable: true;
119
+ pda: {
120
+ seeds: [
49
121
  {
50
- "kind": "const";
51
- "value": [
122
+ kind: 'const';
123
+ value: [
52
124
  103,
53
125
  108,
54
126
  111,
@@ -67,13 +139,13 @@ type Jbond = {
67
139
  };
68
140
  },
69
141
  {
70
- "name": "validatorBond";
71
- "writable": true;
72
- "pda": {
73
- "seeds": [
142
+ name: 'validatorBondAccount';
143
+ writable: true;
144
+ pda: {
145
+ seeds: [
74
146
  {
75
- "kind": "const";
76
- "value": [
147
+ kind: 'const';
148
+ value: [
77
149
  118,
78
150
  97,
79
151
  108,
@@ -91,155 +163,130 @@ type Jbond = {
91
163
  ];
92
164
  },
93
165
  {
94
- "kind": "account";
95
- "path": "validator_bond.vote_account";
96
- "account": "validatorBond";
166
+ kind: 'account';
167
+ path: 'voteAccount';
97
168
  }
98
169
  ];
99
170
  };
100
171
  },
101
172
  {
102
- "name": "reserve";
103
- "writable": true;
173
+ name: 'identity';
104
174
  },
105
175
  {
106
- "name": "authority";
107
- "docs": [
108
- "Authority that can trigger claims"
176
+ name: 'voteAccount';
177
+ },
178
+ {
179
+ name: 'creator';
180
+ docs: [
181
+ 'The account creating the bond (pays for account creation and initial collateral)'
109
182
  ];
110
- "signer": true;
183
+ writable: true;
184
+ signer: true;
111
185
  },
112
186
  {
113
- "name": "systemProgram";
114
- "address": "11111111111111111111111111111111";
187
+ name: 'systemProgram';
188
+ address: '11111111111111111111111111111111';
115
189
  }
116
190
  ];
117
- "args": [
191
+ args: [
192
+ {
193
+ name: 'initialCollateral';
194
+ type: 'u64';
195
+ },
118
196
  {
119
- "name": "amount";
120
- "type": "u64";
197
+ name: 'withdrawalAuthority';
198
+ type: {
199
+ option: 'pubkey';
200
+ };
121
201
  }
122
202
  ];
123
203
  },
124
204
  {
125
- "name": "initialize";
126
- "docs": [
127
- "Initializes the global state for the bonding program.",
128
- "Sets the authority and reserve account for managing validator bonds.",
129
- "",
130
- "# Errors",
131
- "Fails if the global state account is already initialized or if the payer lacks",
132
- "sufficient funds."
205
+ name: 'bondTopUp';
206
+ docs: [
207
+ 'Top up collateral for existing validator'
133
208
  ];
134
- "discriminator": [
135
- 175,
136
- 175,
137
- 109,
138
- 31,
139
- 13,
209
+ discriminator: [
210
+ 132,
211
+ 225,
212
+ 254,
213
+ 187,
140
214
  152,
141
- 155,
142
- 237
215
+ 162,
216
+ 176,
217
+ 66
143
218
  ];
144
- "accounts": [
219
+ accounts: [
145
220
  {
146
- "name": "globalState";
147
- "writable": true;
148
- "pda": {
149
- "seeds": [
221
+ name: 'validatorBondAccount';
222
+ writable: true;
223
+ pda: {
224
+ seeds: [
150
225
  {
151
- "kind": "const";
152
- "value": [
153
- 103,
154
- 108,
155
- 111,
156
- 98,
226
+ kind: 'const';
227
+ value: [
228
+ 118,
157
229
  97,
158
230
  108,
159
- 95,
160
- 115,
161
- 116,
231
+ 105,
232
+ 100,
162
233
  97,
163
234
  116,
164
- 101
235
+ 111,
236
+ 114,
237
+ 95,
238
+ 98,
239
+ 111,
240
+ 110,
241
+ 100
165
242
  ];
243
+ },
244
+ {
245
+ kind: 'account';
246
+ path: 'validator_bond_account.vote_account';
247
+ account: 'validatorBondAccount';
166
248
  }
167
249
  ];
168
250
  };
169
251
  },
170
252
  {
171
- "name": "authority";
172
- "writable": true;
173
- "signer": true;
253
+ name: 'depositor';
254
+ writable: true;
255
+ signer: true;
174
256
  },
175
257
  {
176
- "name": "reserve";
177
- },
258
+ name: 'systemProgram';
259
+ address: '11111111111111111111111111111111';
260
+ }
261
+ ];
262
+ args: [
178
263
  {
179
- "name": "systemProgram";
180
- "address": "11111111111111111111111111111111";
264
+ name: 'amount';
265
+ type: 'u64';
181
266
  }
182
267
  ];
183
- "args": [];
184
268
  },
185
269
  {
186
- "name": "register";
187
- "docs": [
188
- "Registers a new validator with the bonding program.",
189
- "Sets up the validator's bond account and deposits initial collateral.",
190
- "",
191
- "# Arguments",
192
- "* `initial_collateral` - Amount of collateral to lock (must be positive).",
193
- "* `withdrawal_authority` - Optional key that can withdraw collateral later.",
194
- "",
195
- "# Errors",
196
- "Fails if the validator is already registered, if the vote account is invalid,",
197
- "or if the initial collateral transfer fails."
198
- ];
199
- "discriminator": [
200
- 211,
201
- 124,
202
- 67,
203
- 15,
204
- 211,
205
- 194,
270
+ name: 'bondWithdraw';
271
+ discriminator: [
272
+ 99,
273
+ 64,
274
+ 127,
206
275
  178,
207
- 240
276
+ 53,
277
+ 117,
278
+ 70,
279
+ 204
208
280
  ];
209
- "accounts": [
281
+ accounts: [
210
282
  {
211
- "name": "globalState";
212
- "writable": true;
213
- "pda": {
214
- "seeds": [
283
+ name: 'validatorBondAccount';
284
+ writable: true;
285
+ pda: {
286
+ seeds: [
215
287
  {
216
- "kind": "const";
217
- "value": [
218
- 103,
219
- 108,
220
- 111,
221
- 98,
222
- 97,
223
- 108,
224
- 95,
225
- 115,
226
- 116,
227
- 97,
228
- 116,
229
- 101
230
- ];
231
- }
232
- ];
233
- };
234
- },
235
- {
236
- "name": "validatorBond";
237
- "writable": true;
238
- "pda": {
239
- "seeds": [
240
- {
241
- "kind": "const";
242
- "value": [
288
+ kind: 'const';
289
+ value: [
243
290
  118,
244
291
  97,
245
292
  108,
@@ -257,57 +304,100 @@ type Jbond = {
257
304
  ];
258
305
  },
259
306
  {
260
- "kind": "account";
261
- "path": "voteAccount";
307
+ kind: 'account';
308
+ path: 'validator_bond_account.vote_account';
309
+ account: 'validatorBondAccount';
262
310
  }
263
311
  ];
264
312
  };
265
313
  },
266
314
  {
267
- "name": "identity";
315
+ name: 'withdrawalAuthority';
316
+ writable: true;
317
+ signer: true;
268
318
  },
269
319
  {
270
- "name": "voteAccount";
320
+ name: 'destination';
321
+ writable: true;
271
322
  },
272
323
  {
273
- "name": "creator";
274
- "docs": [
275
- "The account creating the bond (pays for account creation and initial collateral)"
276
- ];
277
- "writable": true;
278
- "signer": true;
324
+ name: 'epochSchedule';
325
+ address: 'SysvarEpochSchedu1e111111111111111111111111';
279
326
  },
280
327
  {
281
- "name": "systemProgram";
282
- "address": "11111111111111111111111111111111";
328
+ name: 'systemProgram';
329
+ address: '11111111111111111111111111111111';
283
330
  }
284
331
  ];
285
- "args": [
332
+ args: [
286
333
  {
287
- "name": "initialCollateral";
288
- "type": "u64";
289
- },
334
+ name: 'amount';
335
+ type: 'u64';
336
+ }
337
+ ];
338
+ },
339
+ {
340
+ name: 'initialize';
341
+ docs: [
342
+ 'Initialize the global state and reserve vault'
343
+ ];
344
+ discriminator: [
345
+ 175,
346
+ 175,
347
+ 109,
348
+ 31,
349
+ 13,
350
+ 152,
351
+ 155,
352
+ 237
353
+ ];
354
+ accounts: [
290
355
  {
291
- "name": "withdrawalAuthority";
292
- "type": {
293
- "option": "pubkey";
356
+ name: 'globalState';
357
+ writable: true;
358
+ pda: {
359
+ seeds: [
360
+ {
361
+ kind: 'const';
362
+ value: [
363
+ 103,
364
+ 108,
365
+ 111,
366
+ 98,
367
+ 97,
368
+ 108,
369
+ 95,
370
+ 115,
371
+ 116,
372
+ 97,
373
+ 116,
374
+ 101
375
+ ];
376
+ }
377
+ ];
294
378
  };
379
+ },
380
+ {
381
+ name: 'authority';
382
+ writable: true;
383
+ signer: true;
384
+ },
385
+ {
386
+ name: 'reserve';
387
+ },
388
+ {
389
+ name: 'systemProgram';
390
+ address: '11111111111111111111111111111111';
295
391
  }
296
392
  ];
393
+ args: [];
297
394
  },
298
395
  {
299
- "name": "setAuthority";
300
- "docs": [
301
- "Sets a new withdrawal authority for a validator's bond account.",
302
- "Allows changing who can withdraw collateral in the future.",
303
- "",
304
- "# Arguments",
305
- "* `new_authority` - Optional new authority key (None to restrict to identity).",
306
- "",
307
- "# Errors",
308
- "Fails if the signer is not authorized to change the authority."
396
+ name: 'setAuthority';
397
+ docs: [
398
+ 'Change the bond authority'
309
399
  ];
310
- "discriminator": [
400
+ discriminator: [
311
401
  133,
312
402
  250,
313
403
  37,
@@ -317,15 +407,15 @@ type Jbond = {
317
407
  26,
318
408
  121
319
409
  ];
320
- "accounts": [
410
+ accounts: [
321
411
  {
322
- "name": "globalState";
323
- "writable": true;
324
- "pda": {
325
- "seeds": [
412
+ name: 'globalState';
413
+ writable: true;
414
+ pda: {
415
+ seeds: [
326
416
  {
327
- "kind": "const";
328
- "value": [
417
+ kind: 'const';
418
+ value: [
329
419
  103,
330
420
  108,
331
421
  111,
@@ -344,124 +434,67 @@ type Jbond = {
344
434
  };
345
435
  },
346
436
  {
347
- "name": "authority";
348
- "signer": true;
349
- "relations": [
350
- "globalState"
437
+ name: 'authority';
438
+ signer: true;
439
+ relations: [
440
+ 'globalState'
351
441
  ];
352
442
  },
353
443
  {
354
- "name": "newAuthority";
444
+ name: 'newAuthority';
355
445
  }
356
446
  ];
357
- "args": [];
447
+ args: [];
358
448
  },
359
449
  {
360
- "name": "topUp";
361
- "docs": [
362
- "Adds additional collateral to an existing validator's bond.",
363
- "Increases the collateral balance, enhancing the validator's stake.",
364
- "",
365
- "# Arguments",
366
- "* `amount` - Amount to add.",
367
- "",
368
- "# Errors",
369
- "Fails if the validator is not active, if the amount is zero,",
370
- "or if the transfer of funds fails."
450
+ name: 'withdrawCompensation';
451
+ docs: [
452
+ 'Withdraw compensation from validator to reserve (oracle only)'
371
453
  ];
372
- "discriminator": [
373
- 236,
374
- 225,
375
- 96,
376
- 9,
377
- 60,
378
- 106,
379
- 77,
380
- 208
454
+ discriminator: [
455
+ 10,
456
+ 228,
457
+ 22,
458
+ 213,
459
+ 205,
460
+ 117,
461
+ 181,
462
+ 75
381
463
  ];
382
- "accounts": [
464
+ accounts: [
383
465
  {
384
- "name": "validatorBond";
385
- "writable": true;
386
- "pda": {
387
- "seeds": [
466
+ name: 'globalState';
467
+ writable: true;
468
+ pda: {
469
+ seeds: [
388
470
  {
389
- "kind": "const";
390
- "value": [
391
- 118,
471
+ kind: 'const';
472
+ value: [
473
+ 103,
474
+ 108,
475
+ 111,
476
+ 98,
392
477
  97,
393
478
  108,
394
- 105,
395
- 100,
479
+ 95,
480
+ 115,
481
+ 116,
396
482
  97,
397
483
  116,
398
- 111,
399
- 114,
400
- 95,
401
- 98,
402
- 111,
403
- 110,
404
- 100
484
+ 101
405
485
  ];
406
- },
407
- {
408
- "kind": "account";
409
- "path": "validator_bond.vote_account";
410
- "account": "validatorBond";
411
486
  }
412
487
  ];
413
488
  };
414
489
  },
415
490
  {
416
- "name": "payer";
417
- "writable": true;
418
- "signer": true;
419
- },
420
- {
421
- "name": "systemProgram";
422
- "address": "11111111111111111111111111111111";
423
- }
424
- ];
425
- "args": [
426
- {
427
- "name": "amount";
428
- "type": "u64";
429
- }
430
- ];
431
- },
432
- {
433
- "name": "withdraw";
434
- "docs": [
435
- "Withdraws collateral from a validator's bond.",
436
- "Decreases the collateral balance, allowing the validator to reclaim funds.",
437
- "",
438
- "# Arguments",
439
- "* `amount` - Amount to withdraw (must not exceed available balance).",
440
- "",
441
- "# Errors",
442
- "Fails if the validator is not active, if the amount is zero,",
443
- "if the withdrawal authority is invalid, or if the withdrawal would",
444
- "leave insufficient collateral."
445
- ];
446
- "discriminator": [
447
- 183,
448
- 18,
449
- 70,
450
- 156,
451
- 148,
452
- 109,
453
- 161,
454
- 34
455
- ];
456
- "accounts": [
457
- {
458
- "name": "validatorBond";
459
- "writable": true;
460
- "pda": {
461
- "seeds": [
491
+ name: 'validatorBondAccount';
492
+ writable: true;
493
+ pda: {
494
+ seeds: [
462
495
  {
463
- "kind": "const";
464
- "value": [
496
+ kind: 'const';
497
+ value: [
465
498
  118,
466
499
  97,
467
500
  108,
@@ -479,43 +512,41 @@ type Jbond = {
479
512
  ];
480
513
  },
481
514
  {
482
- "kind": "account";
483
- "path": "validator_bond.vote_account";
484
- "account": "validatorBond";
515
+ kind: 'account';
516
+ path: 'validator_bond_account.vote_account';
517
+ account: 'validatorBondAccount';
485
518
  }
486
519
  ];
487
520
  };
488
521
  },
489
522
  {
490
- "name": "withdrawalAuthority";
491
- "writable": true;
492
- "signer": true;
493
- },
494
- {
495
- "name": "destination";
496
- "writable": true;
523
+ name: 'reserve';
524
+ writable: true;
497
525
  },
498
526
  {
499
- "name": "epochSchedule";
500
- "address": "SysvarEpochSchedu1e111111111111111111111111";
527
+ name: 'authority';
528
+ docs: [
529
+ 'Authority that can trigger claims'
530
+ ];
531
+ signer: true;
501
532
  },
502
533
  {
503
- "name": "systemProgram";
504
- "address": "11111111111111111111111111111111";
534
+ name: 'systemProgram';
535
+ address: '11111111111111111111111111111111';
505
536
  }
506
537
  ];
507
- "args": [
538
+ args: [
508
539
  {
509
- "name": "amount";
510
- "type": "u64";
540
+ name: 'amount';
541
+ type: 'u64';
511
542
  }
512
543
  ];
513
544
  }
514
545
  ];
515
- "accounts": [
546
+ accounts: [
516
547
  {
517
- "name": "globalState";
518
- "discriminator": [
548
+ name: 'globalState';
549
+ discriminator: [
519
550
  163,
520
551
  46,
521
552
  74,
@@ -527,23 +558,23 @@ type Jbond = {
527
558
  ];
528
559
  },
529
560
  {
530
- "name": "validatorBond";
531
- "discriminator": [
532
- 82,
533
- 127,
534
- 243,
535
- 208,
536
- 195,
537
- 42,
538
- 80,
539
- 35
561
+ name: 'validatorBondAccount';
562
+ discriminator: [
563
+ 25,
564
+ 67,
565
+ 241,
566
+ 227,
567
+ 226,
568
+ 104,
569
+ 108,
570
+ 73
540
571
  ];
541
572
  }
542
573
  ];
543
- "events": [
574
+ events: [
544
575
  {
545
- "name": "collateralToppedUp";
546
- "discriminator": [
576
+ name: 'collateralToppedUp';
577
+ discriminator: [
547
578
  189,
548
579
  137,
549
580
  204,
@@ -555,8 +586,8 @@ type Jbond = {
555
586
  ];
556
587
  },
557
588
  {
558
- "name": "collateralWithdrawn";
559
- "discriminator": [
589
+ name: 'collateralWithdrawn';
590
+ discriminator: [
560
591
  51,
561
592
  224,
562
593
  133,
@@ -568,8 +599,8 @@ type Jbond = {
568
599
  ];
569
600
  },
570
601
  {
571
- "name": "compensationClaimed";
572
- "discriminator": [
602
+ name: 'compensationClaimed';
603
+ discriminator: [
573
604
  36,
574
605
  159,
575
606
  41,
@@ -581,8 +612,8 @@ type Jbond = {
581
612
  ];
582
613
  },
583
614
  {
584
- "name": "validatorRegistered";
585
- "discriminator": [
615
+ name: 'validatorRegistered';
616
+ discriminator: [
586
617
  20,
587
618
  20,
588
619
  190,
@@ -594,278 +625,233 @@ type Jbond = {
594
625
  ];
595
626
  }
596
627
  ];
597
- "errors": [
628
+ errors: [
598
629
  {
599
- "code": 6000;
600
- "name": "invalidVoteAccount";
601
- "msg": "Invalid vote account";
630
+ code: 6000;
631
+ name: 'invalidVoteAccount';
632
+ msg: 'Invalid vote account';
602
633
  },
603
634
  {
604
- "code": 6001;
605
- "name": "identityMismatch";
606
- "msg": "Identity does not match vote account";
635
+ code: 6001;
636
+ name: 'identityMismatch';
637
+ msg: 'Identity does not match vote account';
607
638
  },
608
639
  {
609
- "code": 6002;
610
- "name": "insufficientCollateral";
611
- "msg": "Insufficient collateral amount";
640
+ code: 6002;
641
+ name: 'insufficientCollateral';
642
+ msg: 'Insufficient collateral amount';
612
643
  },
613
644
  {
614
- "code": 6003;
615
- "name": "targetAprTooLow";
616
- "msg": "Target APR is below minimum threshold";
645
+ code: 6003;
646
+ name: 'targetAprTooLow';
647
+ msg: 'Target APR is below minimum threshold';
617
648
  },
618
649
  {
619
- "code": 6004;
620
- "name": "mathOverflow";
621
- "msg": "Math overflow";
650
+ code: 6004;
651
+ name: 'mathOverflow';
652
+ msg: 'Math overflow';
622
653
  },
623
654
  {
624
- "code": 6005;
625
- "name": "invalidAmount";
626
- "msg": "Invalid amount";
655
+ code: 6005;
656
+ name: 'invalidAmount';
657
+ msg: 'Invalid amount';
627
658
  },
628
659
  {
629
- "code": 6006;
630
- "name": "validatorNotActive";
631
- "msg": "Validator boost account is not active";
660
+ code: 6006;
661
+ name: 'validatorNotActive';
662
+ msg: 'Validator boost account is not active';
632
663
  },
633
664
  {
634
- "code": 6007;
635
- "name": "validatorAlreadyRegistered";
636
- "msg": "Validator already registered";
665
+ code: 6007;
666
+ name: 'validatorAlreadyRegistered';
667
+ msg: 'Validator already registered';
637
668
  },
638
669
  {
639
- "code": 6008;
640
- "name": "unauthorized";
641
- "msg": "unauthorized";
670
+ code: 6008;
671
+ name: 'unauthorized';
672
+ msg: 'unauthorized';
642
673
  },
643
674
  {
644
- "code": 6009;
645
- "name": "withdrawalLockedNearEpochEnd";
646
- "msg": "Withdrawals are locked near the end of the epoch.";
675
+ code: 6009;
676
+ name: 'withdrawalLockedNearEpochEnd';
677
+ msg: 'Withdrawals are locked near the end of the epoch.';
647
678
  }
648
679
  ];
649
- "types": [
680
+ types: [
650
681
  {
651
- "name": "collateralToppedUp";
652
- "type": {
653
- "kind": "struct";
654
- "fields": [
682
+ name: 'collateralToppedUp';
683
+ type: {
684
+ kind: 'struct';
685
+ fields: [
655
686
  {
656
- "name": "validator";
657
- "type": "pubkey";
687
+ name: 'validator';
688
+ type: 'pubkey';
658
689
  },
659
690
  {
660
- "name": "amount";
661
- "type": "u64";
691
+ name: 'amount';
692
+ type: 'u64';
662
693
  },
663
694
  {
664
- "name": "postBalance";
665
- "type": "u64";
695
+ name: 'newTotal';
696
+ type: 'u64';
666
697
  },
667
698
  {
668
- "name": "timestamp";
669
- "type": "i64";
699
+ name: 'timestamp';
700
+ type: 'i64';
670
701
  }
671
702
  ];
672
703
  };
673
704
  },
674
705
  {
675
- "name": "collateralWithdrawn";
676
- "type": {
677
- "kind": "struct";
678
- "fields": [
706
+ name: 'collateralWithdrawn';
707
+ type: {
708
+ kind: 'struct';
709
+ fields: [
679
710
  {
680
- "name": "validator";
681
- "type": "pubkey";
711
+ name: 'validator';
712
+ type: 'pubkey';
682
713
  },
683
714
  {
684
- "name": "amount";
685
- "type": "u64";
715
+ name: 'amount';
716
+ type: 'u64';
686
717
  },
687
718
  {
688
- "name": "postBalance";
689
- "type": "u64";
719
+ name: 'remainingCollateral';
720
+ type: 'u64';
690
721
  },
691
722
  {
692
- "name": "timestamp";
693
- "type": "i64";
723
+ name: 'timestamp';
724
+ type: 'i64';
694
725
  }
695
726
  ];
696
727
  };
697
728
  },
698
729
  {
699
- "name": "compensationClaimed";
700
- "type": {
701
- "kind": "struct";
702
- "fields": [
730
+ name: 'compensationClaimed';
731
+ type: {
732
+ kind: 'struct';
733
+ fields: [
703
734
  {
704
- "name": "validator";
705
- "type": "pubkey";
735
+ name: 'validator';
736
+ type: 'pubkey';
706
737
  },
707
738
  {
708
- "name": "amount";
709
- "type": "u64";
739
+ name: 'amount';
740
+ type: 'u64';
710
741
  },
711
742
  {
712
- "name": "postBalance";
713
- "type": "u64";
743
+ name: 'remainingCollateral';
744
+ type: 'u64';
714
745
  },
715
746
  {
716
- "name": "epoch";
717
- "type": "u64";
747
+ name: 'totalWithdrawn';
748
+ type: 'u64';
718
749
  },
719
750
  {
720
- "name": "timestamp";
721
- "type": "i64";
751
+ name: 'epoch';
752
+ type: 'u64';
753
+ },
754
+ {
755
+ name: 'timestamp';
756
+ type: 'i64';
722
757
  }
723
758
  ];
724
759
  };
725
760
  },
726
761
  {
727
- "name": "globalState";
728
- "type": {
729
- "kind": "struct";
730
- "fields": [
762
+ name: 'globalState';
763
+ type: {
764
+ kind: 'struct';
765
+ fields: [
731
766
  {
732
- "name": "authority";
733
- "docs": [
734
- "The authority allowed to manage the program"
735
- ];
736
- "type": "pubkey";
767
+ name: 'authority';
768
+ type: 'pubkey';
737
769
  },
738
770
  {
739
- "name": "reserve";
740
- "docs": [
741
- "The reserve vault holding SOL for bonding and compensation"
742
- ];
743
- "type": "pubkey";
771
+ name: 'reserve';
772
+ type: 'pubkey';
744
773
  },
745
774
  {
746
- "name": "totalValidators";
747
- "docs": [
748
- "Total number of registered validators"
749
- ];
750
- "type": "u16";
775
+ name: 'totalValidators';
776
+ type: 'u32';
751
777
  },
752
778
  {
753
- "name": "totalCompensationAmount";
754
- "docs": [
755
- "Total compensation amount paid out"
756
- ];
757
- "type": "u64";
779
+ name: 'totalWithdrawn';
780
+ type: 'u64';
758
781
  },
759
782
  {
760
- "name": "bump";
761
- "docs": [
762
- "Bump for the PDA"
763
- ];
764
- "type": "u8";
783
+ name: 'bump';
784
+ type: 'u8';
765
785
  }
766
786
  ];
767
787
  };
768
788
  },
769
789
  {
770
- "name": "validatorBond";
771
- "type": {
772
- "kind": "struct";
773
- "fields": [
790
+ name: 'validatorBondAccount';
791
+ type: {
792
+ kind: 'struct';
793
+ fields: [
774
794
  {
775
- "name": "identity";
776
- "docs": [
777
- "The validator identity pubkey"
778
- ];
779
- "type": "pubkey";
795
+ name: 'identity';
796
+ type: 'pubkey';
780
797
  },
781
798
  {
782
- "name": "voteAccount";
783
- "docs": [
784
- "The validator vote account pubkey"
785
- ];
786
- "type": "pubkey";
799
+ name: 'voteAccount';
800
+ type: 'pubkey';
787
801
  },
788
802
  {
789
- "name": "creator";
790
- "docs": [
791
- "Creator of the validator bond account"
792
- ];
793
- "type": "pubkey";
803
+ name: 'creator';
804
+ type: 'pubkey';
794
805
  },
795
806
  {
796
- "name": "withdrawalAuthority";
797
- "docs": [
798
- "Authority allowed to withdraw funds (if None, only identity can withdraw)"
799
- ];
800
- "type": {
801
- "option": "pubkey";
807
+ name: 'withdrawalAuthority';
808
+ type: {
809
+ option: 'pubkey';
802
810
  };
803
811
  },
804
812
  {
805
- "name": "totalCompensationAmount";
806
- "docs": [
807
- "Total compensation claimed for the validator"
808
- ];
809
- "type": "u64";
810
- },
811
- {
812
- "name": "lastCompensationAmount";
813
- "docs": [
814
- "Last compensation amount claimed"
815
- ];
816
- "type": "u64";
813
+ name: 'totalWithdrawn';
814
+ type: 'u64';
817
815
  },
818
816
  {
819
- "name": "lastCompensationEpoch";
820
- "docs": [
821
- "Last epoch when compensation was claimed"
822
- ];
823
- "type": "u64";
817
+ name: 'lastWithdrawalEpoch';
818
+ type: 'u64';
824
819
  },
825
820
  {
826
- "name": "createdAt";
827
- "docs": [
828
- "Timestamp when the bond account was created"
829
- ];
830
- "type": "i64";
821
+ name: 'isActive';
822
+ type: 'bool';
831
823
  },
832
824
  {
833
- "name": "isActive";
834
- "docs": [
835
- "Whether the validator is currently active"
836
- ];
837
- "type": "bool";
825
+ name: 'createdAt';
826
+ type: 'i64';
838
827
  },
839
828
  {
840
- "name": "bump";
841
- "docs": [
842
- "Bump for the PDA"
843
- ];
844
- "type": "u8";
829
+ name: 'bump';
830
+ type: 'u8';
845
831
  }
846
832
  ];
847
833
  };
848
834
  },
849
835
  {
850
- "name": "validatorRegistered";
851
- "type": {
852
- "kind": "struct";
853
- "fields": [
836
+ name: 'validatorRegistered';
837
+ type: {
838
+ kind: 'struct';
839
+ fields: [
854
840
  {
855
- "name": "identity";
856
- "type": "pubkey";
841
+ name: 'validator';
842
+ type: 'pubkey';
857
843
  },
858
844
  {
859
- "name": "voteAccount";
860
- "type": "pubkey";
845
+ name: 'voteAccount';
846
+ type: 'pubkey';
861
847
  },
862
848
  {
863
- "name": "initialCollateral";
864
- "type": "u64";
849
+ name: 'collateralAmount';
850
+ type: 'u64';
865
851
  },
866
852
  {
867
- "name": "timestamp";
868
- "type": "i64";
853
+ name: 'timestamp';
854
+ type: 'i64';
869
855
  }
870
856
  ];
871
857
  };
@@ -873,120 +859,29 @@ type Jbond = {
873
859
  ];
874
860
  };
875
861
 
876
- type ValidatorBond = {
877
- identity: PublicKey;
878
- voteAccount: PublicKey;
879
- withdrawalAuthority?: string;
880
- totalWithdrawn: number;
881
- lastWithdrawalEpoch: number;
882
- isActive: boolean;
883
- createdAt: number;
884
- bump: number;
885
- };
886
- type InitializeProps = {
887
- authority: PublicKey;
888
- reserveAddress: PublicKey;
889
- };
890
- type RegisterValidatorProps = {
891
- creator: PublicKey;
892
- identity: PublicKey;
893
- voteAccount: PublicKey;
894
- initialCollateral: number;
895
- withdrawalAuthority?: PublicKey;
896
- };
897
- type TopUpCollateralProps = {
898
- user: PublicKey;
899
- voteAccount: PublicKey;
900
- amount: number;
901
- };
902
- type WithdrawCollateralProps = {
903
- withdrawalAuthority: PublicKey;
904
- voteAccount: PublicKey;
905
- destination: PublicKey;
906
- amount: number;
907
- };
908
- type WithdrawCompensationProps = {
909
- authority: PublicKey;
910
- voteAccount: PublicKey;
911
- amount: number;
912
- };
913
- type GetHistoryProps = {
914
- voteAccount: PublicKey;
915
- options?: {
916
- limit?: number;
917
- before?: string;
918
- until?: string;
919
- };
920
- };
921
- type GetHistoryGroupedProps = {
922
- voteAccount: PublicKey;
923
- epochsCount?: number;
924
- };
925
- type GlobalState = {
926
- authority: PublicKey;
927
- totalValidators: number;
928
- totalCollateral: BN;
929
- totalWithdrawn: BN;
930
- bump: number;
931
- };
932
- type EpochHistoryItem = {
933
- epoch: number;
934
- deposits: number;
935
- withdrawals: number;
936
- balanceChange: number;
937
- signatures: string[];
938
- };
939
- type TransactionHistoryItem = {
940
- signature: string;
941
- slot: number;
942
- epoch: number;
943
- type: BondTransactionType;
944
- amount: number;
945
- beforeBalance?: number;
946
- afterBalance?: number;
947
- };
948
- declare enum BondTransactionType {
949
- Deposit = "deposit",
950
- Withdrawal = "withdrawal",
951
- Compensation = "compensation"
952
- }
953
-
954
- /**
955
- * Enum for different client environments.
956
- */
957
862
  declare enum BondClientEnv {
958
863
  DEV = "dev",
959
- STAGE = "stage",
960
864
  PROD = "prod"
961
865
  }
962
- /**
963
- * Options for configuring the JBondClient.
964
- */
965
- type ClientOptions = {
966
- programId?: PublicKey;
967
- debug?: boolean;
968
- } & Record<string, any>;
969
866
  declare class JBondClient {
970
- readonly provider: AnchorProvider;
867
+ connection: Connection;
868
+ program: Program<Jbond>;
869
+ provider: AnchorProvider;
870
+ config: Config;
971
871
  readonly options: ClientOptions;
972
- readonly program: Program<Jbond>;
973
- constructor(provider: AnchorProvider, options?: ClientOptions);
872
+ constructor(config: Config, wallet?: Wallet, options?: ClientOptions);
974
873
  /**
975
874
  * Creates an instance of `JBondClient` using a provided connection and wallet.
976
875
  */
977
- static fromWallet(connection: Connection, wallet?: Wallet$1, options?: ClientOptions): JBondClient;
876
+ static fromWallet(config: Config, wallet?: Wallet, options?: ClientOptions): JBondClient;
978
877
  /**
979
878
  * Creates an instance of `JBondClient` using the provided connection and keypair.
980
879
  */
981
- static fromKeypair(connection: Connection, keypair: Keypair, options?: ClientOptions): JBondClient;
880
+ static fromKeypair(config: Config, keypair: Keypair, options?: ClientOptions): JBondClient;
982
881
  /**
983
882
  * Get the current program ID.
984
883
  */
985
884
  get programId(): PublicKey;
986
- /**
987
- * Get the current connection.
988
- */
989
- private get connection();
990
885
  /**
991
886
  * Set the environment.
992
887
  */
@@ -995,87 +890,36 @@ declare class JBondClient {
995
890
  * Configure a specific option.
996
891
  */
997
892
  configure<K extends keyof ClientOptions>(key: K, val: ClientOptions[K]): this;
998
- /**
999
- * Program Derived Addresses (PDAs)
1000
- */
1001
- pda: {
1002
- globalState: () => [PublicKey, number];
1003
- validatorBond: (voteAccount: PublicKey) => [PublicKey, number];
1004
- };
1005
- /**
1006
- * Build initialize instruction
1007
- * @param props
1008
- */
1009
- buildInitializeInstruction(props: InitializeProps): Promise<_solana_web3_js.TransactionInstruction>;
1010
- /**
1011
- * Build register validator instruction
1012
- * @param props
1013
- */
1014
- buildRegisterValidatorInstruction(props: RegisterValidatorProps): Promise<_solana_web3_js.TransactionInstruction>;
1015
- /**
1016
- * Build top up collateral instruction
1017
- * @param props
1018
- */
1019
- buildTopUpCollateralInstruction(props: TopUpCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1020
- buildWithdrawCollateralInstruction(props: WithdrawCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1021
- /**
1022
- * Build withdraw compensation instruction
1023
- * @param props
1024
- */
1025
- buildWithdrawCompensationInstruction(props: WithdrawCompensationProps): Promise<_solana_web3_js.TransactionInstruction>;
1026
- /**
1027
- * Build multiple withdraw compensation instructions
1028
- * @param authority
1029
- * @param withdrawals
1030
- */
893
+ getGlobalStatePDA(): [PublicKey, number];
894
+ getValidatorBondPDA(voteAccount: PublicKey): [PublicKey, number];
895
+ buildInitializeInstruction(props: InitializeProps): Promise<TransactionInstruction>;
896
+ buildRegisterValidatorInstruction(props: RegisterValidatorProps): Promise<TransactionInstruction>;
897
+ buildTopUpCollateralInstruction(props: TopUpCollateralProps): Promise<TransactionInstruction>;
898
+ buildWithdrawCollateralInstruction(props: WithdrawCollateralProps): Promise<TransactionInstruction>;
899
+ buildWithdrawCompensationInstruction(props: WithdrawCompensationProps): Promise<TransactionInstruction>;
1031
900
  buildWithdrawCompensationsInstructions(authority: PublicKey, withdrawals: Array<{
1032
901
  voteAccount: PublicKey;
1033
902
  amount: number;
1034
- }>): Promise<_solana_web3_js.TransactionInstruction[]>;
1035
- /**
1036
- * Get validator bond account state
1037
- * @param vote
1038
- */
1039
- getValidatorBond(vote: PublicKey): Promise<{
1040
- identity: any;
1041
- voteAccount: any;
1042
- withdrawalAuthority: any;
1043
- totalCompensationAmount: number;
1044
- isActive: any;
1045
- createdAt: number;
1046
- bump: any;
1047
- } | null>;
1048
- /**
1049
- * Build set authority instruction
1050
- */
903
+ }>): Promise<TransactionInstruction[]>;
904
+ getValidatorBondAccount(voteAccount: PublicKey): Promise<ValidatorBondAccount | null>;
1051
905
  buildSetAuthorityInstruction(props: {
1052
906
  authority: PublicKey;
1053
907
  newAuthority: PublicKey;
1054
- }): Promise<_solana_web3_js.TransactionInstruction>;
908
+ }): Promise<TransactionInstruction>;
1055
909
  /**
1056
910
  * Get the collateral balance of a validator bond account
1057
- * @param vote - The vote account public key
911
+ * @param voteAccount - The vote account public key
1058
912
  * @returns The available collateral balance in SOL (excluding rent-exempt amount)
1059
913
  */
1060
- getValidatorCollateralBalance(vote: PublicKey): Promise<number>;
1061
- /**
1062
- * Get global state
1063
- */
914
+ getValidatorCollateralBalance(voteAccount: PublicKey): Promise<number>;
1064
915
  getGlobalState(): Promise<{
1065
916
  authority: string;
1066
917
  totalValidators: number;
1067
- totalCompensationAmount: number;
918
+ totalWithdrawn: number;
1068
919
  reserveAddress: string;
1069
- }>;
1070
- /**
1071
- * Get current epoch
1072
- */
920
+ } | null>;
1073
921
  getCurrentEpoch(): Promise<number>;
1074
- /**
1075
- * Helper methods for backward compatibility (can be removed if not needed)
1076
- * @param props
1077
- */
1078
- initialize(props: WithOptionalAuthority<InitializeProps>): Promise<string>;
922
+ initialize(reserveAddress: PublicKey, authority?: PublicKey): Promise<string>;
1079
923
  registerValidator(voteAccount: PublicKey, initialCollateral: number, withdrawalAuthority?: PublicKey, identity?: PublicKey): Promise<string>;
1080
924
  topUpCollateral(voteAccount: PublicKey, amount: number, validator?: PublicKey): Promise<string>;
1081
925
  withdrawCollateral(voteAccount: PublicKey, destination: PublicKey, amount: number, withdrawalAuthority?: PublicKey): Promise<string>;
@@ -1093,42 +937,15 @@ declare class JBondClient {
1093
937
  before?: string;
1094
938
  until?: string;
1095
939
  }): Promise<TransactionHistoryItem[]>;
1096
- /**
1097
- * Get full transaction history by paginating through results
1098
- * @param voteAccount
1099
- * @param pageSize
1100
- */
1101
940
  getFullHistory(voteAccount: PublicKey, pageSize?: number): Promise<TransactionHistoryItem[]>;
1102
- /**
1103
- * Get instruction discriminator from IDL
1104
- * @param instructionName
1105
- * @private
1106
- */
1107
941
  private getInstructionDiscriminator;
1108
942
  }
1109
- type WithOptionalAuthority<T extends {
1110
- authority: PublicKey;
1111
- }> = Omit<T, 'authority'> & {
1112
- authority?: PublicKey;
1113
- };
1114
-
1115
- /**
1116
- * Program IDs for different environments
1117
- */
1118
- declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
943
+ type ClientOptions = {
944
+ programId?: PublicKey;
945
+ debug?: boolean;
946
+ } & Record<string, any>;
1119
947
 
1120
- type Wallet = {
1121
- publicKey: PublicKey;
1122
- signMessage?: (message: Uint8Array) => Promise<Uint8Array>;
1123
- signTransaction: <T extends Transaction | VersionedTransaction>(tx: T) => Promise<T>;
1124
- signAllTransactions: <T extends Transaction | VersionedTransaction>(txs: T[]) => Promise<T[]>;
1125
- };
1126
- declare class NodeWallet implements Wallet {
1127
- readonly payer: Keypair;
1128
- constructor(payer: Keypair);
1129
- signTransaction<T extends Transaction | VersionedTransaction>(tx: T): Promise<T>;
1130
- signAllTransactions<T extends Transaction | VersionedTransaction>(txs: T[]): Promise<T[]>;
1131
- get publicKey(): PublicKey;
1132
- }
948
+ declare const PROGRAM_ID: PublicKey;
949
+ declare const DEV_PROGRAM_ID: PublicKey;
1133
950
 
1134
- export { BondClientEnv, BondTransactionType, type ClientOptions, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, NodeWallet, type RegisterValidatorProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps, type WithdrawCompensationProps };
951
+ export { BondClientEnv, BondTransactionType, type ClientOptions, type Config, DEV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, PROGRAM_ID, type RegisterValidatorProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBondAccount, type WithdrawCollateralProps, type WithdrawCompensationProps };