@jpool/bond-sdk 0.9.0 → 0.10.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.mts CHANGED
@@ -1,6 +1,29 @@
1
- import * as _solana_web3_js from '@solana/web3.js';
2
- import { PublicKey, Transaction, VersionedTransaction, Keypair, Connection, PublicKeyInitData } from '@solana/web3.js';
3
- import { BN, AnchorProvider, Program } from '@coral-xyz/anchor';
1
+ import { Fee } from '@solana/spl-stake-pool/src/layouts';
2
+ import { PublicKey, TransactionInstruction, Connection, PublicKeyInitData, Transaction, VersionedTransaction, Keypair } from '@solana/web3.js';
3
+ import * as bn_js from 'bn.js';
4
+ import bn_js__default from 'bn.js';
5
+ import { IdlTypes, IdlAccounts, Program, Provider } from '@coral-xyz/anchor';
6
+
7
+ type StakePoolManager = {
8
+ stakePoolAddress: PublicKey;
9
+ depositSol: (lamports: bn_js__default) => TransactionInstruction;
10
+ withdrawSol: (poolTokens: bn_js__default) => TransactionInstruction;
11
+ readonly exchangeRate: number;
12
+ readonly withdrawSolFee: Fee;
13
+ };
14
+
15
+ declare const JPOOL_STAKE_POOL: PublicKey;
16
+ declare enum Seeds {
17
+ GlobalState = "global_state",
18
+ BondState = "bond_state",
19
+ ValidatorBond = "validator_bond",
20
+ StandardBond = "standard",
21
+ CrowdFundingBond = "crowdfunding"
22
+ }
23
+ /**
24
+ * Program IDs for different environments
25
+ */
26
+ declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
4
27
 
5
28
  /**
6
29
  * Program IDL in camelCase format in order to be used in JS/TS.
@@ -9,71 +32,50 @@ import { BN, AnchorProvider, Program } from '@coral-xyz/anchor';
9
32
  * IDL can be found at `target/idl/jbond.json`.
10
33
  */
11
34
  type Jbond = {
12
- address: 'BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU';
13
- metadata: {
14
- name: 'jbond';
15
- version: '0.2.1';
16
- spec: '0.1.0';
17
- description: 'Jpool Bond Program';
35
+ "address": "BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU";
36
+ "metadata": {
37
+ "name": "jbond";
38
+ "version": "0.2.1";
39
+ "spec": "0.1.0";
40
+ "description": "Jpool Bond Program";
18
41
  };
19
- instructions: [
42
+ "instructions": [
20
43
  {
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.'
44
+ "name": "bondClaim";
45
+ "docs": [
46
+ "Claims compensation for a validator.",
47
+ "Transfers funds from the validator's bond account to reserve.",
48
+ "",
49
+ "# Arguments",
50
+ "* `amount` - Amount of compensation to claim (must be positive).",
51
+ "",
52
+ "# Errors",
53
+ "Fails if the authority is invalid, if the validator is not active,",
54
+ "if the amount is zero, or if there are insufficient funds."
32
55
  ];
33
- discriminator: [
34
- 62,
35
- 198,
36
- 214,
37
- 193,
38
- 213,
39
- 159,
40
- 108,
41
- 210
56
+ "discriminator": [
57
+ 151,
58
+ 92,
59
+ 10,
60
+ 205,
61
+ 66,
62
+ 250,
63
+ 188,
64
+ 129
42
65
  ];
43
- accounts: [
66
+ "accounts": [
44
67
  {
45
- name: 'globalState';
46
- writable: true;
47
- pda: {
48
- seeds: [
49
- {
50
- kind: 'const';
51
- value: [
52
- 103,
53
- 108,
54
- 111,
55
- 98,
56
- 97,
57
- 108,
58
- 95,
59
- 115,
60
- 116,
61
- 97,
62
- 116,
63
- 101
64
- ];
65
- }
66
- ];
67
- };
68
+ "name": "bondState";
69
+ "writable": true;
68
70
  },
69
71
  {
70
- name: 'validatorBond';
71
- writable: true;
72
- pda: {
73
- seeds: [
72
+ "name": "validatorBond";
73
+ "writable": true;
74
+ "pda": {
75
+ "seeds": [
74
76
  {
75
- kind: 'const';
76
- value: [
77
+ "kind": "const";
78
+ "value": [
77
79
  118,
78
80
  97,
79
81
  108,
@@ -91,73 +93,134 @@ type Jbond = {
91
93
  ];
92
94
  },
93
95
  {
94
- kind: 'account';
95
- path: 'validator_bond.vote_account';
96
- account: 'validatorBond';
96
+ "kind": "account";
97
+ "path": "bondState";
98
+ },
99
+ {
100
+ "kind": "account";
101
+ "path": "validator_bond.vote_account";
102
+ "account": "validatorBond";
97
103
  }
98
104
  ];
99
105
  };
100
106
  },
101
107
  {
102
- name: 'reserve';
103
- writable: true;
108
+ "name": "reserve";
109
+ "writable": true;
104
110
  },
105
111
  {
106
- name: 'authority';
107
- docs: [
108
- 'Authority that can trigger claims'
109
- ];
110
- signer: true;
112
+ "name": "authority";
113
+ "signer": true;
114
+ },
115
+ {
116
+ "name": "bondTokenAccount";
117
+ "writable": true;
118
+ "optional": true;
119
+ },
120
+ {
121
+ "name": "reserveTokenAccount";
122
+ "writable": true;
123
+ "optional": true;
124
+ },
125
+ {
126
+ "name": "stakeAccount";
127
+ "writable": true;
128
+ "optional": true;
129
+ },
130
+ {
131
+ "name": "systemProgram";
132
+ "address": "11111111111111111111111111111111";
133
+ },
134
+ {
135
+ "name": "tokenProgram";
136
+ "optional": true;
137
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
111
138
  },
112
139
  {
113
- name: 'systemProgram';
114
- address: '11111111111111111111111111111111';
140
+ "name": "stakeProgram";
141
+ "optional": true;
115
142
  }
116
143
  ];
117
- args: [
144
+ "args": [
118
145
  {
119
- name: 'amount';
120
- type: 'u64';
146
+ "name": "amount";
147
+ "type": "u64";
121
148
  }
122
149
  ];
123
150
  },
124
151
  {
125
- name: 'configure';
126
- docs: [
127
- 'Updates the global program configuration, including authority and reserve fields.',
128
- 'Allows changing the program\'s authority and updating the reserve account.',
129
- '',
130
- '# Arguments',
131
- '* `data` - Configuration data containing optional new authority and reserve keys.',
132
- '',
133
- '# Errors',
134
- 'Fails if the signer is not authorized to update the global configuration.'
152
+ "name": "bondConfigure";
153
+ "docs": [
154
+ "Updates bond configuration, including authority and reserve fields.",
155
+ "Allows changing the bond's authority and updating the reserve account."
135
156
  ];
136
- discriminator: [
137
- 245,
138
- 7,
157
+ "discriminator": [
158
+ 61,
159
+ 42,
160
+ 106,
161
+ 235,
139
162
  108,
140
- 117,
141
- 95,
142
- 196,
143
- 54,
144
- 217
163
+ 57,
164
+ 65,
165
+ 20
145
166
  ];
146
- accounts: [
167
+ "accounts": [
168
+ {
169
+ "name": "bondState";
170
+ "writable": true;
171
+ },
147
172
  {
148
- name: 'globalState';
149
- writable: true;
150
- pda: {
151
- seeds: [
173
+ "name": "authority";
174
+ "signer": true;
175
+ "relations": [
176
+ "bondState"
177
+ ];
178
+ }
179
+ ];
180
+ "args": [
181
+ {
182
+ "name": "data";
183
+ "type": {
184
+ "defined": {
185
+ "name": "bondConfigureData";
186
+ };
187
+ };
188
+ }
189
+ ];
190
+ },
191
+ {
192
+ "name": "bondInitialize";
193
+ "docs": [
194
+ "Initializes state for the bond.",
195
+ "Sets the authority and reserve account for managing validator bonds.",
196
+ "",
197
+ "# Errors",
198
+ "Fails if the global state account is already initialized or if the payer lacks",
199
+ "sufficient funds."
200
+ ];
201
+ "discriminator": [
202
+ 230,
203
+ 3,
204
+ 121,
205
+ 94,
206
+ 147,
207
+ 203,
208
+ 175,
209
+ 210
210
+ ];
211
+ "accounts": [
212
+ {
213
+ "name": "bondState";
214
+ "writable": true;
215
+ "pda": {
216
+ "seeds": [
152
217
  {
153
- kind: 'const';
154
- value: [
155
- 103,
156
- 108,
157
- 111,
218
+ "kind": "const";
219
+ "value": [
158
220
  98,
159
- 97,
160
- 108,
221
+ 111,
222
+ 110,
223
+ 100,
161
224
  95,
162
225
  115,
163
226
  116,
@@ -165,148 +228,281 @@ type Jbond = {
165
228
  116,
166
229
  101
167
230
  ];
231
+ },
232
+ {
233
+ "kind": "arg";
234
+ "path": "data.bond_type";
235
+ },
236
+ {
237
+ "kind": "arg";
238
+ "path": "data.name";
168
239
  }
169
240
  ];
170
241
  };
171
242
  },
172
243
  {
173
- name: 'authority';
174
- signer: true;
175
- relations: [
176
- 'globalState'
177
- ];
244
+ "name": "authority";
245
+ "writable": true;
246
+ "signer": true;
247
+ },
248
+ {
249
+ "name": "reserve";
250
+ },
251
+ {
252
+ "name": "associatedTokenProgram";
253
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
254
+ },
255
+ {
256
+ "name": "systemProgram";
257
+ "address": "11111111111111111111111111111111";
258
+ },
259
+ {
260
+ "name": "tokenProgram";
261
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
262
+ },
263
+ {
264
+ "name": "reserveTokenAccount";
265
+ "writable": true;
266
+ "optional": true;
267
+ },
268
+ {
269
+ "name": "mint";
270
+ "optional": true;
178
271
  }
179
272
  ];
180
- args: [
273
+ "args": [
181
274
  {
182
- name: 'data';
183
- type: {
184
- defined: {
185
- name: 'configureData';
275
+ "name": "data";
276
+ "type": {
277
+ "defined": {
278
+ "name": "bondInitializeData";
186
279
  };
187
280
  };
188
281
  }
189
282
  ];
190
283
  },
191
284
  {
192
- name: 'initialize';
193
- docs: [
194
- 'Initializes the global state for the bonding program.',
195
- 'Sets the authority and reserve account for managing validator bonds.',
196
- '',
197
- '# Errors',
198
- 'Fails if the global state account is already initialized or if the payer lacks',
199
- 'sufficient funds.'
285
+ "name": "bondRegister";
286
+ "docs": [
287
+ "Registers a new validator with the bond.",
288
+ "Sets up the validator's bond account and deposits initial collateral.",
289
+ "",
290
+ "# Arguments",
291
+ "* `initial_collateral` - Amount of collateral to lock (must be positive).",
292
+ "* `withdrawal_authority` - Optional key that can withdraw collateral later.",
293
+ "",
294
+ "# Errors",
295
+ "Fails if the validator is already registered, if the vote account is invalid,",
296
+ "or if the initial collateral transfer fails."
200
297
  ];
201
- discriminator: [
202
- 175,
298
+ "discriminator": [
299
+ 117,
300
+ 127,
301
+ 78,
302
+ 103,
303
+ 166,
203
304
  175,
204
- 109,
205
- 31,
206
- 13,
207
- 152,
208
- 155,
209
- 237
305
+ 163,
306
+ 83
210
307
  ];
211
- accounts: [
308
+ "accounts": [
309
+ {
310
+ "name": "bondState";
311
+ "writable": true;
312
+ },
212
313
  {
213
- name: 'globalState';
214
- writable: true;
215
- pda: {
216
- seeds: [
314
+ "name": "validatorBond";
315
+ "writable": true;
316
+ "pda": {
317
+ "seeds": [
217
318
  {
218
- kind: 'const';
219
- value: [
220
- 103,
221
- 108,
222
- 111,
223
- 98,
319
+ "kind": "const";
320
+ "value": [
321
+ 118,
224
322
  97,
225
323
  108,
226
- 95,
227
- 115,
228
- 116,
324
+ 105,
325
+ 100,
229
326
  97,
230
327
  116,
231
- 101
328
+ 111,
329
+ 114,
330
+ 95,
331
+ 98,
332
+ 111,
333
+ 110,
334
+ 100
232
335
  ];
336
+ },
337
+ {
338
+ "kind": "account";
339
+ "path": "bondState";
340
+ },
341
+ {
342
+ "kind": "account";
343
+ "path": "voteAccount";
233
344
  }
234
345
  ];
235
346
  };
236
347
  },
237
348
  {
238
- name: 'authority';
239
- writable: true;
240
- signer: true;
349
+ "name": "identity";
350
+ },
351
+ {
352
+ "name": "voteAccount";
353
+ },
354
+ {
355
+ "name": "creator";
356
+ "writable": true;
357
+ "signer": true;
358
+ },
359
+ {
360
+ "name": "systemProgram";
361
+ "address": "11111111111111111111111111111111";
362
+ },
363
+ {
364
+ "name": "tokenProgram";
365
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
366
+ },
367
+ {
368
+ "name": "associatedTokenProgram";
369
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
241
370
  },
242
371
  {
243
- name: 'reserve';
372
+ "name": "bondTokenAccount";
373
+ "writable": true;
374
+ "optional": true;
244
375
  },
245
376
  {
246
- name: 'systemProgram';
247
- address: '11111111111111111111111111111111';
377
+ "name": "mint";
378
+ "optional": true;
379
+ }
380
+ ];
381
+ "args": [
382
+ {
383
+ "name": "bondType";
384
+ "type": {
385
+ "defined": {
386
+ "name": "bondType";
387
+ };
388
+ };
389
+ },
390
+ {
391
+ "name": "bondName";
392
+ "type": "string";
248
393
  }
249
394
  ];
250
- args: [];
251
395
  },
252
396
  {
253
- name: 'register';
254
- docs: [
255
- 'Registers a new validator with the bonding program.',
256
- 'Sets up the validator\'s bond account and deposits initial collateral.',
257
- '',
258
- '# Arguments',
259
- '* `initial_collateral` - Amount of collateral to lock (must be positive).',
260
- '* `withdrawal_authority` - Optional key that can withdraw collateral later.',
261
- '',
262
- '# Errors',
263
- 'Fails if the validator is already registered, if the vote account is invalid,',
264
- 'or if the initial collateral transfer fails.'
397
+ "name": "bondSetWithdrawAuthority";
398
+ "docs": [
399
+ "Sets a new withdrawal authority for a validator's bond account.",
400
+ "Allows changing who can withdraw collateral in the future.",
401
+ "",
402
+ "# Arguments",
403
+ "* `new_withdraw_authority` - Optional new withdrawal authority key (None to restrict to",
404
+ "identity).",
405
+ "",
406
+ "# Errors",
407
+ "Fails if the signer is not authorized to change the withdrawal authority."
265
408
  ];
266
- discriminator: [
267
- 211,
268
- 124,
269
- 67,
270
- 15,
271
- 211,
272
- 194,
273
- 178,
274
- 240
409
+ "discriminator": [
410
+ 212,
411
+ 162,
412
+ 53,
413
+ 130,
414
+ 91,
415
+ 158,
416
+ 61,
417
+ 166
275
418
  ];
276
- accounts: [
419
+ "accounts": [
420
+ {
421
+ "name": "bondState";
422
+ },
277
423
  {
278
- name: 'globalState';
279
- writable: true;
280
- pda: {
281
- seeds: [
424
+ "name": "validatorBond";
425
+ "writable": true;
426
+ "pda": {
427
+ "seeds": [
282
428
  {
283
- kind: 'const';
284
- value: [
285
- 103,
286
- 108,
287
- 111,
288
- 98,
429
+ "kind": "const";
430
+ "value": [
431
+ 118,
289
432
  97,
290
433
  108,
291
- 95,
292
- 115,
293
- 116,
434
+ 105,
435
+ 100,
294
436
  97,
295
437
  116,
296
- 101
438
+ 111,
439
+ 114,
440
+ 95,
441
+ 98,
442
+ 111,
443
+ 110,
444
+ 100
297
445
  ];
446
+ },
447
+ {
448
+ "kind": "account";
449
+ "path": "bondState";
450
+ },
451
+ {
452
+ "kind": "account";
453
+ "path": "validator_bond.vote_account";
454
+ "account": "validatorBond";
298
455
  }
299
456
  ];
300
457
  };
301
458
  },
302
459
  {
303
- name: 'validatorBond';
304
- writable: true;
305
- pda: {
306
- seeds: [
460
+ "name": "identity";
461
+ "signer": true;
462
+ },
463
+ {
464
+ "name": "newWithdrawAuthority";
465
+ "optional": true;
466
+ }
467
+ ];
468
+ "args": [];
469
+ },
470
+ {
471
+ "name": "bondTopUp";
472
+ "docs": [
473
+ "Adds additional collateral to an existing validator's bond.",
474
+ "Increases the collateral balance, enhancing the validator's stake.",
475
+ "",
476
+ "# Arguments",
477
+ "* `amount` - Amount to add.",
478
+ "",
479
+ "# Errors",
480
+ "Fails if the validator is not active, if the amount is zero,",
481
+ "or if the transfer of funds fails."
482
+ ];
483
+ "discriminator": [
484
+ 132,
485
+ 225,
486
+ 254,
487
+ 187,
488
+ 152,
489
+ 162,
490
+ 176,
491
+ 66
492
+ ];
493
+ "accounts": [
494
+ {
495
+ "name": "bondState";
496
+ "writable": true;
497
+ },
498
+ {
499
+ "name": "validatorBond";
500
+ "writable": true;
501
+ "pda": {
502
+ "seeds": [
307
503
  {
308
- kind: 'const';
309
- value: [
504
+ "kind": "const";
505
+ "value": [
310
506
  118,
311
507
  97,
312
508
  108,
@@ -324,70 +520,95 @@ type Jbond = {
324
520
  ];
325
521
  },
326
522
  {
327
- kind: 'account';
328
- path: 'voteAccount';
523
+ "kind": "account";
524
+ "path": "bondState";
525
+ },
526
+ {
527
+ "kind": "account";
528
+ "path": "validator_bond.vote_account";
529
+ "account": "validatorBond";
329
530
  }
330
531
  ];
331
532
  };
332
533
  },
333
534
  {
334
- name: 'identity';
535
+ "name": "payer";
536
+ "writable": true;
537
+ "signer": true;
335
538
  },
336
539
  {
337
- name: 'voteAccount';
540
+ "name": "payerTokenAccount";
541
+ "writable": true;
542
+ "optional": true;
338
543
  },
339
544
  {
340
- name: 'creator';
341
- docs: [
342
- 'The account creating the bond (pays for account creation and initial collateral)'
343
- ];
344
- writable: true;
345
- signer: true;
545
+ "name": "bondTokenAccount";
546
+ "writable": true;
547
+ "optional": true;
548
+ },
549
+ {
550
+ "name": "stakeAccount";
551
+ "writable": true;
552
+ "optional": true;
346
553
  },
347
554
  {
348
- name: 'systemProgram';
349
- address: '11111111111111111111111111111111';
555
+ "name": "systemProgram";
556
+ "address": "11111111111111111111111111111111";
557
+ },
558
+ {
559
+ "name": "tokenProgram";
560
+ "optional": true;
561
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
562
+ },
563
+ {
564
+ "name": "stakeProgram";
565
+ "optional": true;
350
566
  }
351
567
  ];
352
- args: [
568
+ "args": [
353
569
  {
354
- name: 'initialCollateral';
355
- type: 'u64';
570
+ "name": "amount";
571
+ "type": "u64";
356
572
  }
357
573
  ];
358
574
  },
359
575
  {
360
- name: 'setWithdrawAuthority';
361
- docs: [
362
- 'Sets a new withdrawal authority for a validator\'s bond account.',
363
- 'Allows changing who can withdraw collateral in the future.',
364
- '',
365
- '# Arguments',
366
- '* `new_withdraw_authority` - Optional new withdrawal authority key (None to restrict to',
367
- 'identity).',
368
- '',
369
- '# Errors',
370
- 'Fails if the signer is not authorized to change the withdrawal authority.'
576
+ "name": "bondWithdraw";
577
+ "docs": [
578
+ "Withdraws collateral from a validator's bond.",
579
+ "Decreases the collateral balance, allowing the validator to reclaim funds.",
580
+ "",
581
+ "# Arguments",
582
+ "* `amount` - Amount to withdraw (must not exceed available balance).",
583
+ "",
584
+ "# Errors",
585
+ "Fails if the validator is not active, if the amount is zero,",
586
+ "if the withdrawal authority is invalid, or if the withdrawal would",
587
+ "leave insufficient collateral."
371
588
  ];
372
- discriminator: [
373
- 199,
374
- 146,
375
- 140,
376
- 67,
377
- 1,
378
- 90,
379
- 8,
380
- 222
589
+ "discriminator": [
590
+ 99,
591
+ 64,
592
+ 127,
593
+ 178,
594
+ 53,
595
+ 117,
596
+ 70,
597
+ 204
381
598
  ];
382
- accounts: [
599
+ "accounts": [
600
+ {
601
+ "name": "bondState";
602
+ "writable": true;
603
+ },
383
604
  {
384
- name: 'validatorBond';
385
- writable: true;
386
- pda: {
387
- seeds: [
605
+ "name": "validatorBond";
606
+ "writable": true;
607
+ "pda": {
608
+ "seeds": [
388
609
  {
389
- kind: 'const';
390
- value: [
610
+ "kind": "const";
611
+ "value": [
391
612
  118,
392
613
  97,
393
614
  108,
@@ -405,130 +626,204 @@ type Jbond = {
405
626
  ];
406
627
  },
407
628
  {
408
- kind: 'account';
409
- path: 'validator_bond.vote_account';
410
- account: 'validatorBond';
629
+ "kind": "account";
630
+ "path": "bondState";
631
+ },
632
+ {
633
+ "kind": "account";
634
+ "path": "validator_bond.vote_account";
635
+ "account": "validatorBond";
411
636
  }
412
637
  ];
413
638
  };
414
639
  },
415
640
  {
416
- name: 'identity';
417
- signer: true;
641
+ "name": "withdrawalAuthority";
642
+ "writable": true;
643
+ "signer": true;
644
+ },
645
+ {
646
+ "name": "destination";
647
+ "writable": true;
648
+ },
649
+ {
650
+ "name": "destinationTokenAccount";
651
+ "writable": true;
652
+ "optional": true;
653
+ },
654
+ {
655
+ "name": "bondTokenAccount";
656
+ "writable": true;
657
+ "optional": true;
658
+ },
659
+ {
660
+ "name": "stakeAccount";
661
+ "writable": true;
662
+ "optional": true;
663
+ },
664
+ {
665
+ "name": "systemProgram";
666
+ "address": "11111111111111111111111111111111";
418
667
  },
419
668
  {
420
- name: 'newWithdrawAuthority';
421
- optional: true;
669
+ "name": "tokenProgram";
670
+ "optional": true;
671
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
672
+ },
673
+ {
674
+ "name": "stakeProgram";
675
+ "optional": true;
676
+ }
677
+ ];
678
+ "args": [
679
+ {
680
+ "name": "amount";
681
+ "type": "u64";
422
682
  }
423
683
  ];
424
- args: [];
425
684
  },
426
685
  {
427
- name: 'topUp';
428
- docs: [
429
- 'Adds additional collateral to an existing validator\'s bond.',
430
- 'Increases the collateral balance, enhancing the validator\'s stake.',
431
- '',
432
- '# Arguments',
433
- '* `amount` - Amount to add.',
434
- '',
435
- '# Errors',
436
- 'Fails if the validator is not active, if the amount is zero,',
437
- 'or if the transfer of funds fails.'
438
- ];
439
- discriminator: [
440
- 236,
441
- 225,
442
- 96,
443
- 9,
444
- 60,
445
- 106,
446
- 77,
447
- 208
686
+ "name": "globalConfigure";
687
+ "discriminator": [
688
+ 67,
689
+ 142,
690
+ 164,
691
+ 250,
692
+ 90,
693
+ 233,
694
+ 144,
695
+ 187
448
696
  ];
449
- accounts: [
697
+ "accounts": [
450
698
  {
451
- name: 'validatorBond';
452
- writable: true;
453
- pda: {
454
- seeds: [
699
+ "name": "globalState";
700
+ "writable": true;
701
+ "pda": {
702
+ "seeds": [
455
703
  {
456
- kind: 'const';
457
- value: [
458
- 118,
704
+ "kind": "const";
705
+ "value": [
706
+ 103,
707
+ 108,
708
+ 111,
709
+ 98,
459
710
  97,
460
711
  108,
461
- 105,
462
- 100,
712
+ 95,
713
+ 115,
714
+ 116,
463
715
  97,
464
716
  116,
717
+ 101
718
+ ];
719
+ }
720
+ ];
721
+ };
722
+ },
723
+ {
724
+ "name": "authority";
725
+ "signer": true;
726
+ "relations": [
727
+ "globalState"
728
+ ];
729
+ }
730
+ ];
731
+ "args": [
732
+ {
733
+ "name": "data";
734
+ "type": {
735
+ "defined": {
736
+ "name": "globalConfigureData";
737
+ };
738
+ };
739
+ }
740
+ ];
741
+ },
742
+ {
743
+ "name": "globalInitialize";
744
+ "discriminator": [
745
+ 30,
746
+ 79,
747
+ 193,
748
+ 205,
749
+ 75,
750
+ 42,
751
+ 223,
752
+ 196
753
+ ];
754
+ "accounts": [
755
+ {
756
+ "name": "globalState";
757
+ "writable": true;
758
+ "pda": {
759
+ "seeds": [
760
+ {
761
+ "kind": "const";
762
+ "value": [
763
+ 103,
764
+ 108,
465
765
  111,
466
- 114,
467
- 95,
468
766
  98,
469
- 111,
470
- 110,
471
- 100
767
+ 97,
768
+ 108,
769
+ 95,
770
+ 115,
771
+ 116,
772
+ 97,
773
+ 116,
774
+ 101
472
775
  ];
473
- },
474
- {
475
- kind: 'account';
476
- path: 'validator_bond.vote_account';
477
- account: 'validatorBond';
478
776
  }
479
777
  ];
480
778
  };
481
779
  },
482
780
  {
483
- name: 'payer';
484
- writable: true;
485
- signer: true;
781
+ "name": "authority";
782
+ "writable": true;
783
+ "signer": true;
486
784
  },
487
785
  {
488
- name: 'systemProgram';
489
- address: '11111111111111111111111111111111';
490
- }
491
- ];
492
- args: [
493
- {
494
- name: 'amount';
495
- type: 'u64';
786
+ "name": "systemProgram";
787
+ "address": "11111111111111111111111111111111";
496
788
  }
497
789
  ];
790
+ "args": [];
498
791
  },
499
792
  {
500
- name: 'withdraw';
501
- docs: [
502
- 'Withdraws collateral from a validator\'s bond.',
503
- 'Decreases the collateral balance, allowing the validator to reclaim funds.',
504
- '',
505
- '# Arguments',
506
- '* `amount` - Amount to withdraw (must not exceed available balance).',
507
- '',
508
- '# Errors',
509
- 'Fails if the validator is not active, if the amount is zero,',
510
- 'if the withdrawal authority is invalid, or if the withdrawal would',
511
- 'leave insufficient collateral.'
793
+ "name": "migrateBond";
794
+ "docs": [
795
+ "Migrates validator bond data from legacy structure to new structure."
512
796
  ];
513
- discriminator: [
514
- 183,
797
+ "discriminator": [
798
+ 107,
799
+ 119,
800
+ 59,
801
+ 110,
802
+ 76,
515
803
  18,
516
- 70,
517
- 156,
518
- 148,
519
- 109,
520
- 161,
521
- 34
804
+ 37,
805
+ 163
522
806
  ];
523
- accounts: [
807
+ "accounts": [
524
808
  {
525
- name: 'validatorBond';
526
- writable: true;
527
- pda: {
528
- seeds: [
809
+ "name": "bondState";
810
+ "writable": true;
811
+ },
812
+ {
813
+ "name": "legacyValidatorBond";
814
+ "writable": true;
815
+ },
816
+ {
817
+ "name": "legacyVoteAccount";
818
+ },
819
+ {
820
+ "name": "validatorBond";
821
+ "writable": true;
822
+ "pda": {
823
+ "seeds": [
529
824
  {
530
- kind: 'const';
531
- value: [
825
+ "kind": "const";
826
+ "value": [
532
827
  118,
533
828
  97,
534
829
  108,
@@ -546,43 +841,113 @@ type Jbond = {
546
841
  ];
547
842
  },
548
843
  {
549
- kind: 'account';
550
- path: 'validator_bond.vote_account';
551
- account: 'validatorBond';
844
+ "kind": "account";
845
+ "path": "bondState";
846
+ },
847
+ {
848
+ "kind": "account";
849
+ "path": "legacyVoteAccount";
552
850
  }
553
851
  ];
554
852
  };
555
853
  },
556
854
  {
557
- name: 'withdrawalAuthority';
558
- writable: true;
559
- signer: true;
855
+ "name": "creator";
856
+ "writable": true;
857
+ "signer": true;
560
858
  },
561
859
  {
562
- name: 'destination';
563
- writable: true;
860
+ "name": "systemProgram";
861
+ "address": "11111111111111111111111111111111";
862
+ }
863
+ ];
864
+ "args": [];
865
+ },
866
+ {
867
+ "name": "sessionFinish";
868
+ "docs": [
869
+ "Finishes a bond, preventing further deposits and withdrawals."
870
+ ];
871
+ "discriminator": [
872
+ 230,
873
+ 209,
874
+ 54,
875
+ 205,
876
+ 127,
877
+ 141,
878
+ 137,
879
+ 113
880
+ ];
881
+ "accounts": [
882
+ {
883
+ "name": "bondState";
884
+ "writable": true;
564
885
  },
565
886
  {
566
- name: 'epochSchedule';
567
- address: 'SysvarEpochSchedu1e111111111111111111111111';
887
+ "name": "authority";
888
+ "writable": true;
889
+ "signer": true;
890
+ "relations": [
891
+ "bondState"
892
+ ];
893
+ }
894
+ ];
895
+ "args": [];
896
+ },
897
+ {
898
+ "name": "sessionStart";
899
+ "docs": [
900
+ "Starts a paused bond, allowing deposits and withdrawals to resume."
901
+ ];
902
+ "discriminator": [
903
+ 132,
904
+ 93,
905
+ 83,
906
+ 152,
907
+ 141,
908
+ 32,
909
+ 58,
910
+ 92
911
+ ];
912
+ "accounts": [
913
+ {
914
+ "name": "bondState";
915
+ "writable": true;
568
916
  },
569
917
  {
570
- name: 'systemProgram';
571
- address: '11111111111111111111111111111111';
918
+ "name": "authority";
919
+ "writable": true;
920
+ "signer": true;
921
+ "relations": [
922
+ "bondState"
923
+ ];
572
924
  }
573
925
  ];
574
- args: [
926
+ "args": [
575
927
  {
576
- name: 'amount';
577
- type: 'u64';
928
+ "name": "durationSecs";
929
+ "type": "u64";
578
930
  }
579
931
  ];
580
932
  }
581
933
  ];
582
- accounts: [
934
+ "accounts": [
935
+ {
936
+ "name": "bondState";
937
+ "discriminator": [
938
+ 251,
939
+ 95,
940
+ 76,
941
+ 47,
942
+ 191,
943
+ 108,
944
+ 163,
945
+ 92
946
+ ];
947
+ },
583
948
  {
584
- name: 'globalState';
585
- discriminator: [
949
+ "name": "globalState";
950
+ "discriminator": [
586
951
  163,
587
952
  46,
588
953
  74,
@@ -594,8 +959,8 @@ type Jbond = {
594
959
  ];
595
960
  },
596
961
  {
597
- name: 'validatorBond';
598
- discriminator: [
962
+ "name": "validatorBond";
963
+ "discriminator": [
599
964
  82,
600
965
  127,
601
966
  243,
@@ -607,10 +972,36 @@ type Jbond = {
607
972
  ];
608
973
  }
609
974
  ];
610
- events: [
975
+ "events": [
976
+ {
977
+ "name": "bondFinished";
978
+ "discriminator": [
979
+ 223,
980
+ 254,
981
+ 3,
982
+ 161,
983
+ 90,
984
+ 190,
985
+ 150,
986
+ 191
987
+ ];
988
+ },
989
+ {
990
+ "name": "bondStarted";
991
+ "discriminator": [
992
+ 235,
993
+ 69,
994
+ 80,
995
+ 63,
996
+ 209,
997
+ 252,
998
+ 232,
999
+ 64
1000
+ ];
1001
+ },
611
1002
  {
612
- name: 'collateralToppedUp';
613
- discriminator: [
1003
+ "name": "collateralToppedUp";
1004
+ "discriminator": [
614
1005
  189,
615
1006
  137,
616
1007
  204,
@@ -622,8 +1013,8 @@ type Jbond = {
622
1013
  ];
623
1014
  },
624
1015
  {
625
- name: 'collateralWithdrawn';
626
- discriminator: [
1016
+ "name": "collateralWithdrawn";
1017
+ "discriminator": [
627
1018
  51,
628
1019
  224,
629
1020
  133,
@@ -635,8 +1026,8 @@ type Jbond = {
635
1026
  ];
636
1027
  },
637
1028
  {
638
- name: 'compensationClaimed';
639
- discriminator: [
1029
+ "name": "compensationClaimed";
1030
+ "discriminator": [
640
1031
  36,
641
1032
  159,
642
1033
  41,
@@ -648,8 +1039,8 @@ type Jbond = {
648
1039
  ];
649
1040
  },
650
1041
  {
651
- name: 'validatorRegistered';
652
- discriminator: [
1042
+ "name": "validatorRegistered";
1043
+ "discriminator": [
653
1044
  20,
654
1045
  20,
655
1046
  190,
@@ -661,347 +1052,631 @@ type Jbond = {
661
1052
  ];
662
1053
  }
663
1054
  ];
664
- errors: [
1055
+ "errors": [
1056
+ {
1057
+ "code": 6000;
1058
+ "name": "invalidVoteAccount";
1059
+ "msg": "Invalid vote account";
1060
+ },
1061
+ {
1062
+ "code": 6001;
1063
+ "name": "identityMismatch";
1064
+ "msg": "Identity does not match vote account";
1065
+ },
1066
+ {
1067
+ "code": 6002;
1068
+ "name": "insufficientCollateral";
1069
+ "msg": "Insufficient collateral amount";
1070
+ },
1071
+ {
1072
+ "code": 6003;
1073
+ "name": "targetAprTooLow";
1074
+ "msg": "Target APR is below minimum threshold";
1075
+ },
1076
+ {
1077
+ "code": 6004;
1078
+ "name": "mathOverflow";
1079
+ "msg": "Math overflow";
1080
+ },
665
1081
  {
666
- code: 6000;
667
- name: 'invalidVoteAccount';
668
- msg: 'Invalid vote account';
1082
+ "code": 6005;
1083
+ "name": "invalidAmount";
1084
+ "msg": "Invalid amount";
669
1085
  },
670
1086
  {
671
- code: 6001;
672
- name: 'identityMismatch';
673
- msg: 'Identity does not match vote account';
1087
+ "code": 6006;
1088
+ "name": "validatorNotActive";
1089
+ "msg": "Validator bond account is not active";
674
1090
  },
675
1091
  {
676
- code: 6002;
677
- name: 'insufficientCollateral';
678
- msg: 'Insufficient collateral amount';
1092
+ "code": 6007;
1093
+ "name": "validatorAlreadyRegistered";
1094
+ "msg": "Validator already registered";
679
1095
  },
680
1096
  {
681
- code: 6003;
682
- name: 'targetAprTooLow';
683
- msg: 'Target APR is below minimum threshold';
1097
+ "code": 6008;
1098
+ "name": "unauthorized";
1099
+ "msg": "unauthorized";
684
1100
  },
685
1101
  {
686
- code: 6004;
687
- name: 'mathOverflow';
688
- msg: 'Math overflow';
1102
+ "code": 6009;
1103
+ "name": "withdrawalLockedNearEpochEnd";
1104
+ "msg": "Withdrawals are locked near the end of the epoch.";
689
1105
  },
690
1106
  {
691
- code: 6005;
692
- name: 'invalidAmount';
693
- msg: 'Invalid amount';
1107
+ "code": 6010;
1108
+ "name": "missingTokenAccounts";
1109
+ "msg": "Missing token accounts for token collateral type";
694
1110
  },
695
1111
  {
696
- code: 6006;
697
- name: 'validatorNotActive';
698
- msg: 'Validator bond account is not active';
1112
+ "code": 6011;
1113
+ "name": "missingTokenProgram";
1114
+ "msg": "Token program is required for token collateral type";
699
1115
  },
700
1116
  {
701
- code: 6007;
702
- name: 'validatorAlreadyRegistered';
703
- msg: 'Validator already registered';
1117
+ "code": 6012;
1118
+ "name": "invalidMint";
1119
+ "msg": "Invalid mint for token collateral type";
704
1120
  },
705
1121
  {
706
- code: 6008;
707
- name: 'unauthorized';
708
- msg: 'unauthorized';
1122
+ "code": 6013;
1123
+ "name": "missingStakeAccount";
1124
+ "msg": "Stake account is required for stake account collateral type";
709
1125
  },
710
1126
  {
711
- code: 6009;
712
- name: 'withdrawalLockedNearEpochEnd';
713
- msg: 'Withdrawals are locked near the end of the epoch.';
1127
+ "code": 6014;
1128
+ "name": "missingStakeProgram";
1129
+ "msg": "Stake program is required for stake account collateral type";
1130
+ },
1131
+ {
1132
+ "code": 6015;
1133
+ "name": "bondFinished";
1134
+ "msg": "Bond is finished (deposits/withdrawals disabled)";
1135
+ },
1136
+ {
1137
+ "code": 6016;
1138
+ "name": "bondNotFinished";
1139
+ "msg": "Bond is not finished";
1140
+ },
1141
+ {
1142
+ "code": 6017;
1143
+ "name": "unsupportedCollateralType";
1144
+ "msg": "Unsupported collateral type";
1145
+ },
1146
+ {
1147
+ "code": 6018;
1148
+ "name": "overflow";
1149
+ "msg": "Math operation overflowed";
1150
+ },
1151
+ {
1152
+ "code": 6019;
1153
+ "name": "incorrectBondType";
1154
+ "msg": "Incorrect bond type for this operation";
1155
+ },
1156
+ {
1157
+ "code": 6020;
1158
+ "name": "bondNotFinishable";
1159
+ "msg": "This bond type can't be finished";
1160
+ },
1161
+ {
1162
+ "code": 6021;
1163
+ "name": "invalidArgument";
1164
+ "msg": "Invalid argument provided";
1165
+ },
1166
+ {
1167
+ "code": 6022;
1168
+ "name": "bondNotDisabled";
1169
+ "msg": "Bond is not disabled";
1170
+ },
1171
+ {
1172
+ "code": 6023;
1173
+ "name": "bondNotEnabled";
1174
+ "msg": "Bond is not enabled";
714
1175
  }
715
1176
  ];
716
- types: [
1177
+ "types": [
717
1178
  {
718
- name: 'collateralToppedUp';
719
- type: {
720
- kind: 'struct';
721
- fields: [
722
- {
723
- name: 'validator';
724
- type: 'pubkey';
725
- },
1179
+ "name": "bondConfigureData";
1180
+ "type": {
1181
+ "kind": "struct";
1182
+ "fields": [
726
1183
  {
727
- name: 'amount';
728
- type: 'u64';
1184
+ "name": "status";
1185
+ "type": {
1186
+ "option": {
1187
+ "defined": {
1188
+ "name": "bondStatus";
1189
+ };
1190
+ };
1191
+ };
729
1192
  },
730
1193
  {
731
- name: 'postBalance';
732
- type: 'u64';
1194
+ "name": "newReserve";
1195
+ "type": {
1196
+ "option": "pubkey";
1197
+ };
733
1198
  },
734
1199
  {
735
- name: 'timestamp';
736
- type: 'i64';
1200
+ "name": "newAuthority";
1201
+ "type": {
1202
+ "option": "pubkey";
1203
+ };
737
1204
  }
738
1205
  ];
739
1206
  };
740
1207
  },
741
1208
  {
742
- name: 'collateralWithdrawn';
743
- type: {
744
- kind: 'struct';
745
- fields: [
746
- {
747
- name: 'validator';
748
- type: 'pubkey';
749
- },
1209
+ "name": "bondFinished";
1210
+ "type": {
1211
+ "kind": "struct";
1212
+ "fields": [
750
1213
  {
751
- name: 'amount';
752
- type: 'u64';
1214
+ "name": "bond";
1215
+ "type": "pubkey";
753
1216
  },
754
1217
  {
755
- name: 'postBalance';
756
- type: 'u64';
1218
+ "name": "authority";
1219
+ "type": "pubkey";
757
1220
  },
758
1221
  {
759
- name: 'timestamp';
760
- type: 'i64';
1222
+ "name": "timestamp";
1223
+ "type": "i64";
761
1224
  }
762
1225
  ];
763
1226
  };
764
1227
  },
765
1228
  {
766
- name: 'compensationClaimed';
767
- type: {
768
- kind: 'struct';
769
- fields: [
770
- {
771
- name: 'validator';
772
- type: 'pubkey';
773
- },
1229
+ "name": "bondInitializeData";
1230
+ "docs": [
1231
+ "Data required to initialize a performance bond"
1232
+ ];
1233
+ "type": {
1234
+ "kind": "struct";
1235
+ "fields": [
774
1236
  {
775
- name: 'amount';
776
- type: 'u64';
1237
+ "name": "name";
1238
+ "type": "string";
777
1239
  },
778
1240
  {
779
- name: 'postBalance';
780
- type: 'u64';
1241
+ "name": "bondType";
1242
+ "type": {
1243
+ "defined": {
1244
+ "name": "bondType";
1245
+ };
1246
+ };
781
1247
  },
782
1248
  {
783
- name: 'epoch';
784
- type: 'u64';
1249
+ "name": "reserve";
1250
+ "type": "pubkey";
785
1251
  },
786
1252
  {
787
- name: 'timestamp';
788
- type: 'i64';
1253
+ "name": "collateralType";
1254
+ "type": {
1255
+ "defined": {
1256
+ "name": "collateralType";
1257
+ };
1258
+ };
789
1259
  }
790
1260
  ];
791
1261
  };
792
1262
  },
793
1263
  {
794
- name: 'configureData';
795
- type: {
796
- kind: 'struct';
797
- fields: [
1264
+ "name": "bondStarted";
1265
+ "type": {
1266
+ "kind": "struct";
1267
+ "fields": [
798
1268
  {
799
- name: 'newAuthority';
800
- type: {
801
- option: 'pubkey';
802
- };
1269
+ "name": "bond";
1270
+ "type": "pubkey";
803
1271
  },
804
1272
  {
805
- name: 'newReserve';
806
- type: {
807
- option: 'pubkey';
808
- };
1273
+ "name": "authority";
1274
+ "type": "pubkey";
1275
+ },
1276
+ {
1277
+ "name": "timestamp";
1278
+ "type": "i64";
809
1279
  }
810
1280
  ];
811
1281
  };
812
1282
  },
813
1283
  {
814
- name: 'globalState';
815
- type: {
816
- kind: 'struct';
817
- fields: [
1284
+ "name": "bondState";
1285
+ "type": {
1286
+ "kind": "struct";
1287
+ "fields": [
818
1288
  {
819
- name: 'authority';
820
- docs: [
821
- 'The authority allowed to manage the program'
822
- ];
823
- type: 'pubkey';
1289
+ "name": "name";
1290
+ "type": "string";
824
1291
  },
825
1292
  {
826
- name: 'reserve';
827
- docs: [
828
- 'The reserve vault holding SOL for bonding and compensation'
1293
+ "name": "bondType";
1294
+ "docs": [
1295
+ "The type of bond (e.g., Standard, Crowdfunding)"
829
1296
  ];
830
- type: 'pubkey';
1297
+ "type": {
1298
+ "defined": {
1299
+ "name": "bondType";
1300
+ };
1301
+ };
831
1302
  },
832
1303
  {
833
- name: 'totalValidators';
834
- docs: [
835
- 'Total number of registered validators'
1304
+ "name": "collateralType";
1305
+ "docs": [
1306
+ "The type of collateral accepted for this bond"
836
1307
  ];
837
- type: 'u16';
1308
+ "type": {
1309
+ "defined": {
1310
+ "name": "collateralType";
1311
+ };
1312
+ };
838
1313
  },
839
1314
  {
840
- name: 'totalCompensationAmount';
841
- docs: [
842
- 'Total compensation amount paid out'
1315
+ "name": "reserve";
1316
+ "docs": [
1317
+ "Reserve account where collateral is held"
843
1318
  ];
844
- type: 'u64';
1319
+ "type": "pubkey";
845
1320
  },
846
1321
  {
847
- name: 'bump';
848
- docs: [
849
- 'Bump for the PDA'
1322
+ "name": "authority";
1323
+ "docs": [
1324
+ "Authority allowed to manage the bond configuration"
850
1325
  ];
851
- type: 'u8';
852
- }
853
- ];
854
- };
855
- },
856
- {
857
- name: 'validatorBond';
858
- type: {
859
- kind: 'struct';
860
- fields: [
1326
+ "type": "pubkey";
1327
+ },
861
1328
  {
862
- name: 'identity';
863
- docs: [
864
- 'The validator identity pubkey'
1329
+ "name": "sessionId";
1330
+ "docs": [
1331
+ "Unique identifier for the bonding session"
865
1332
  ];
866
- type: 'pubkey';
1333
+ "type": "u32";
867
1334
  },
868
1335
  {
869
- name: 'voteAccount';
870
- docs: [
871
- 'The validator vote account pubkey'
1336
+ "name": "totalMembers";
1337
+ "docs": [
1338
+ "Total number of users who have participated in the bond"
872
1339
  ];
873
- type: 'pubkey';
1340
+ "type": "u16";
874
1341
  },
875
1342
  {
876
- name: 'creator';
877
- docs: [
878
- 'Creator of the validator bond account'
1343
+ "name": "totalCompensationAmount";
1344
+ "docs": [
1345
+ "Total compensation amount paid out"
879
1346
  ];
880
- type: 'pubkey';
1347
+ "type": "u64";
881
1348
  },
882
1349
  {
883
- name: 'withdrawalAuthority';
884
- docs: [
885
- 'Authority allowed to withdraw funds (if None, only identity can withdraw)'
1350
+ "name": "sessionStartTs";
1351
+ "docs": [
1352
+ "Start timestamp of the current session (unix seconds). 0 not set."
886
1353
  ];
887
- type: {
888
- option: 'pubkey';
889
- };
1354
+ "type": "i64";
890
1355
  },
891
1356
  {
892
- name: 'totalCompensationAmount';
893
- docs: [
894
- 'Total compensation claimed for the validator'
1357
+ "name": "sessionFinishTs";
1358
+ "docs": [
1359
+ "Finish timestamp of the current session (unix seconds). 0 — not set."
895
1360
  ];
896
- type: 'u64';
1361
+ "type": "i64";
897
1362
  },
898
1363
  {
899
- name: 'lastCompensationAmount';
900
- docs: [
901
- 'Last compensation amount claimed'
1364
+ "name": "status";
1365
+ "docs": [
1366
+ "Current status of the bond"
902
1367
  ];
903
- type: 'u64';
1368
+ "type": {
1369
+ "defined": {
1370
+ "name": "bondStatus";
1371
+ };
1372
+ };
904
1373
  },
905
1374
  {
906
- name: 'lastCompensationEpoch';
907
- docs: [
908
- 'Last epoch when compensation was claimed'
1375
+ "name": "bump";
1376
+ "docs": [
1377
+ "Bump for the PDA"
909
1378
  ];
910
- type: 'u64';
1379
+ "type": "u8";
1380
+ }
1381
+ ];
1382
+ };
1383
+ },
1384
+ {
1385
+ "name": "bondStatus";
1386
+ "type": {
1387
+ "kind": "enum";
1388
+ "variants": [
1389
+ {
1390
+ "name": "active";
1391
+ },
1392
+ {
1393
+ "name": "disabled";
1394
+ }
1395
+ ];
1396
+ };
1397
+ },
1398
+ {
1399
+ "name": "bondType";
1400
+ "docs": [
1401
+ "Types of bonds supported by the program"
1402
+ ];
1403
+ "type": {
1404
+ "kind": "enum";
1405
+ "variants": [
1406
+ {
1407
+ "name": "standard";
1408
+ },
1409
+ {
1410
+ "name": "crowdfunding";
1411
+ }
1412
+ ];
1413
+ };
1414
+ },
1415
+ {
1416
+ "name": "collateralToppedUp";
1417
+ "type": {
1418
+ "kind": "struct";
1419
+ "fields": [
1420
+ {
1421
+ "name": "validator";
1422
+ "type": "pubkey";
1423
+ },
1424
+ {
1425
+ "name": "amount";
1426
+ "type": "u64";
1427
+ },
1428
+ {
1429
+ "name": "postBalance";
1430
+ "type": "u64";
1431
+ },
1432
+ {
1433
+ "name": "timestamp";
1434
+ "type": "i64";
1435
+ }
1436
+ ];
1437
+ };
1438
+ },
1439
+ {
1440
+ "name": "collateralType";
1441
+ "docs": [
1442
+ "Types of collateral that can be used for bond deposit"
1443
+ ];
1444
+ "type": {
1445
+ "kind": "enum";
1446
+ "variants": [
1447
+ {
1448
+ "name": "native";
1449
+ },
1450
+ {
1451
+ "name": "stakeAccount";
911
1452
  },
912
1453
  {
913
- name: 'createdAt';
914
- docs: [
915
- 'Timestamp when the bond account was created'
1454
+ "name": "token";
1455
+ "fields": [
1456
+ "pubkey"
916
1457
  ];
917
- type: 'i64';
1458
+ }
1459
+ ];
1460
+ };
1461
+ },
1462
+ {
1463
+ "name": "collateralWithdrawn";
1464
+ "type": {
1465
+ "kind": "struct";
1466
+ "fields": [
1467
+ {
1468
+ "name": "validator";
1469
+ "type": "pubkey";
1470
+ },
1471
+ {
1472
+ "name": "amount";
1473
+ "type": "u64";
1474
+ },
1475
+ {
1476
+ "name": "postBalance";
1477
+ "type": "u64";
1478
+ },
1479
+ {
1480
+ "name": "timestamp";
1481
+ "type": "i64";
1482
+ }
1483
+ ];
1484
+ };
1485
+ },
1486
+ {
1487
+ "name": "compensationClaimed";
1488
+ "type": {
1489
+ "kind": "struct";
1490
+ "fields": [
1491
+ {
1492
+ "name": "validator";
1493
+ "type": "pubkey";
1494
+ },
1495
+ {
1496
+ "name": "amount";
1497
+ "type": "u64";
1498
+ },
1499
+ {
1500
+ "name": "postBalance";
1501
+ "type": "u64";
1502
+ },
1503
+ {
1504
+ "name": "epoch";
1505
+ "type": "u64";
918
1506
  },
919
1507
  {
920
- name: 'isActive';
921
- docs: [
922
- 'Whether the validator is currently active'
1508
+ "name": "timestamp";
1509
+ "type": "i64";
1510
+ }
1511
+ ];
1512
+ };
1513
+ },
1514
+ {
1515
+ "name": "globalConfigureData";
1516
+ "type": {
1517
+ "kind": "struct";
1518
+ "fields": [
1519
+ {
1520
+ "name": "newAuthority";
1521
+ "type": {
1522
+ "option": "pubkey";
1523
+ };
1524
+ }
1525
+ ];
1526
+ };
1527
+ },
1528
+ {
1529
+ "name": "globalState";
1530
+ "type": {
1531
+ "kind": "struct";
1532
+ "fields": [
1533
+ {
1534
+ "name": "authority";
1535
+ "docs": [
1536
+ "The authority allowed to manage the program"
923
1537
  ];
924
- type: 'bool';
1538
+ "type": "pubkey";
925
1539
  },
926
1540
  {
927
- name: 'bump';
928
- docs: [
929
- 'Bump for the PDA'
1541
+ "name": "bump";
1542
+ "docs": [
1543
+ "Bump for the PDA"
930
1544
  ];
931
- type: 'u8';
1545
+ "type": "u8";
932
1546
  }
933
1547
  ];
934
1548
  };
935
1549
  },
936
1550
  {
937
- name: 'validatorRegistered';
938
- type: {
939
- kind: 'struct';
940
- fields: [
1551
+ "name": "validatorBond";
1552
+ "type": {
1553
+ "kind": "struct";
1554
+ "fields": [
1555
+ {
1556
+ "name": "state";
1557
+ "type": "pubkey";
1558
+ },
1559
+ {
1560
+ "name": "identity";
1561
+ "type": "pubkey";
1562
+ },
1563
+ {
1564
+ "name": "voteAccount";
1565
+ "type": "pubkey";
1566
+ },
1567
+ {
1568
+ "name": "creator";
1569
+ "type": "pubkey";
1570
+ },
941
1571
  {
942
- name: 'identity';
943
- type: 'pubkey';
1572
+ "name": "withdrawalAuthority";
1573
+ "type": {
1574
+ "option": "pubkey";
1575
+ };
1576
+ },
1577
+ {
1578
+ "name": "createdAt";
1579
+ "type": "i64";
944
1580
  },
945
1581
  {
946
- name: 'voteAccount';
947
- type: 'pubkey';
1582
+ "name": "bump";
1583
+ "type": "u8";
1584
+ }
1585
+ ];
1586
+ };
1587
+ },
1588
+ {
1589
+ "name": "validatorRegistered";
1590
+ "type": {
1591
+ "kind": "struct";
1592
+ "fields": [
1593
+ {
1594
+ "name": "identity";
1595
+ "type": "pubkey";
948
1596
  },
949
1597
  {
950
- name: 'initialCollateral';
951
- type: 'u64';
1598
+ "name": "voteAccount";
1599
+ "type": "pubkey";
952
1600
  },
953
1601
  {
954
- name: 'timestamp';
955
- type: 'i64';
1602
+ "name": "timestamp";
1603
+ "type": "i64";
956
1604
  }
957
1605
  ];
958
1606
  };
959
1607
  }
960
1608
  ];
1609
+ "constants": [
1610
+ {
1611
+ "name": "epochLockedSlotTail";
1612
+ "docs": [
1613
+ "Epoch slot index at the end of an epoch after which withdrawals are locked"
1614
+ ];
1615
+ "type": "u64";
1616
+ "value": "420000";
1617
+ }
1618
+ ];
961
1619
  };
962
1620
 
963
- type GlobalState = {
964
- authority: PublicKey;
965
- reserve: PublicKey;
966
- totalValidators: number;
967
- totalCompensationAmount: BN;
968
- bump: number;
1621
+ type GlobalState = IdlAccounts<Jbond>['globalState'];
1622
+ type BondState = IdlAccounts<Jbond>['bondState'];
1623
+ type ValidatorBond = IdlAccounts<Jbond>['validatorBond'];
1624
+ type BondType = IdlTypes<Jbond>['bondType'];
1625
+ type CollateralType = IdlTypes<Jbond>['collateralType'];
1626
+ type BondStateStatus = IdlTypes<Jbond>['bondStatus'];
1627
+ type BondStateStats = {
1628
+ totalCollected: number;
1629
+ status: SessionStatus;
969
1630
  };
970
- type ValidatorBond = {
971
- identity: PublicKey;
972
- voteAccount: PublicKey;
973
- creator: PublicKey;
974
- withdrawalAuthority: PublicKey | null;
975
- totalCompensationAmount: BN;
976
- lastCompensationAmount: BN;
977
- lastCompensationEpoch: BN;
978
- isActive: boolean;
979
- createdAt: BN;
980
- bump: number;
1631
+ declare const bondTypeToSeed: {
1632
+ standard: Seeds;
1633
+ crowdfunding: Seeds;
981
1634
  };
982
- type InitializeProps = {
1635
+ declare const BondTypeVariant: {
1636
+ Standard: BondType;
1637
+ Crowdfunding: BondType;
1638
+ };
1639
+ declare const BondStateStatusVariant: {
1640
+ Active: BondStateStatus;
1641
+ Disabled: BondStateStatus;
1642
+ };
1643
+ type GlobalInitializeProps = {
1644
+ authority?: PublicKey;
1645
+ };
1646
+ type BondInitializeProps = {
1647
+ bondType: BondType;
1648
+ name: string;
983
1649
  authority?: PublicKey;
1650
+ collateralType: CollateralType;
984
1651
  reserve: PublicKey;
985
1652
  };
986
1653
  type RegisterValidatorProps = {
1654
+ bondType: BondType;
1655
+ name: string;
987
1656
  identity: PublicKey;
988
1657
  voteAccount: PublicKey;
989
- initialCollateral: number;
990
1658
  creator?: PublicKey;
991
1659
  };
992
1660
  type TopUpCollateralProps = {
993
- amount: number;
1661
+ bondType: BondType;
1662
+ name: string;
1663
+ identity: PublicKey;
994
1664
  voteAccount: PublicKey;
1665
+ collateral: BondCollateral;
995
1666
  payer?: PublicKey;
996
1667
  };
997
1668
  type WithdrawCollateralProps = {
998
- amount: number;
1669
+ bondType: BondType;
1670
+ name: string;
1671
+ withdraw: BondCollateral;
999
1672
  voteAccount: PublicKey;
1000
1673
  destination?: PublicKey;
1001
1674
  withdrawalAuthority?: PublicKey;
1002
1675
  };
1003
1676
  type ClaimProps = {
1004
- amount: number;
1677
+ bondType: BondType;
1678
+ name: string;
1679
+ claim: BondCollateral;
1005
1680
  voteAccount: PublicKey;
1006
1681
  reserve?: PublicKey;
1007
1682
  authority?: PublicKey;
@@ -1018,12 +1693,21 @@ type GetHistoryGroupedProps = {
1018
1693
  voteAccount: PublicKey;
1019
1694
  epochsCount?: number;
1020
1695
  };
1021
- type ConfigureProps = {
1696
+ type BondConfigureProps = {
1697
+ bondType: BondType;
1698
+ name: string;
1022
1699
  authority?: PublicKey;
1700
+ bondStateStatus?: BondStateStatus;
1023
1701
  newAuthority?: PublicKey;
1024
1702
  newReserve?: PublicKey;
1025
1703
  };
1704
+ type GlobalConfigureProps = {
1705
+ authority?: PublicKey;
1706
+ newAuthority?: PublicKey;
1707
+ };
1026
1708
  type SetWithdrawAuthorityProps = {
1709
+ bondType: BondType;
1710
+ name: string;
1027
1711
  voteAccount: PublicKey;
1028
1712
  newWithdrawAuthority?: PublicKey | null;
1029
1713
  identity?: PublicKey;
@@ -1041,14 +1725,40 @@ type TransactionHistoryItem = {
1041
1725
  epoch: number;
1042
1726
  type: BondTransactionType;
1043
1727
  amount: number;
1044
- beforeBalance?: number;
1045
- afterBalance?: number;
1046
1728
  };
1047
1729
  declare enum BondTransactionType {
1048
1730
  Deposit = "deposit",
1049
1731
  Withdrawal = "withdrawal",
1050
1732
  Compensation = "compensation"
1051
1733
  }
1734
+ type BondCollateral = {
1735
+ amount?: number;
1736
+ mint?: PublicKey;
1737
+ stakeAccount?: PublicKey;
1738
+ };
1739
+ declare enum SessionStatus {
1740
+ Live = 0,
1741
+ Finished = 1
1742
+ }
1743
+
1744
+ type GetHistoryOpts = {
1745
+ cluster?: 'mainnet-beta' | 'testnet' | 'devnet';
1746
+ limit?: number;
1747
+ before?: string;
1748
+ until?: string;
1749
+ };
1750
+ declare class HistoryManager {
1751
+ private program;
1752
+ private connection;
1753
+ private programId;
1754
+ private discCache;
1755
+ constructor(program: Program<Jbond>, connection: Connection, programId: PublicKey);
1756
+ getHistory(bondType: BondType, vote: PublicKeyInitData, pdaDeriver: (bondType: BondType, vote: PublicKeyInitData) => [PublicKey, number], options?: GetHistoryOpts): Promise<TransactionHistoryItem[]>;
1757
+ private fetchSignaturesForAddress;
1758
+ private fetchParsedTransactions;
1759
+ private getInstructionDiscriminator;
1760
+ private decodeInstructionData;
1761
+ }
1052
1762
 
1053
1763
  type Wallet = {
1054
1764
  publicKey: PublicKey;
@@ -1076,14 +1786,14 @@ declare enum BondClientEnv {
1076
1786
  * Options for configuring the JBondClient.
1077
1787
  */
1078
1788
  type ClientOptions = {
1079
- programId?: PublicKey;
1080
1789
  debug?: boolean;
1081
1790
  } & Record<string, any>;
1082
1791
  declare class JBondClient {
1083
- readonly provider: AnchorProvider;
1792
+ readonly provider: Provider;
1084
1793
  readonly options: ClientOptions;
1085
1794
  readonly program: Program<Jbond>;
1086
- constructor(provider: AnchorProvider, options?: ClientOptions);
1795
+ readonly history: HistoryManager;
1796
+ constructor(provider: Provider, options?: ClientOptions);
1087
1797
  /**
1088
1798
  * Creates an instance of `JBondClient` using a provided connection and wallet.
1089
1799
  */
@@ -1095,7 +1805,7 @@ declare class JBondClient {
1095
1805
  /**
1096
1806
  * Get the current program ID.
1097
1807
  */
1098
- get programId(): PublicKey;
1808
+ get programId(): any;
1099
1809
  /**
1100
1810
  * Get the current connection.
1101
1811
  */
@@ -1108,109 +1818,211 @@ declare class JBondClient {
1108
1818
  * Configure a specific option.
1109
1819
  */
1110
1820
  configureEnv<K extends keyof ClientOptions>(key: K, val: ClientOptions[K]): this;
1821
+ private getBondTypeSeed;
1111
1822
  /**
1112
1823
  * Program Derived Addresses (PDAs)
1113
1824
  */
1114
1825
  pda: {
1115
1826
  globalState: () => [PublicKey, number];
1116
- validatorBond: (vote: PublicKeyInitData) => [PublicKey, number];
1827
+ bondState: (bondType: BondType, bondName: string) => [PublicKey, number];
1828
+ validatorBond: (bondType: BondType, bondName: string, vote: PublicKeyInitData) => [PublicKey, number];
1117
1829
  };
1830
+ globalInitialize(props: GlobalInitializeProps): Promise<string | undefined>;
1118
1831
  /**
1119
1832
  * Initialize the program
1120
1833
  * Default authority is the provider's wallet
1121
1834
  */
1122
- initialize(props: InitializeProps): Promise<string>;
1835
+ bondInitialize(props: BondInitializeProps): Promise<string | undefined>;
1123
1836
  /**
1124
1837
  * Register a new validator
1125
1838
  * Default creator is the provider's wallet
1126
1839
  */
1127
- registerValidator(props: RegisterValidatorProps): Promise<string>;
1840
+ registerValidator(props: RegisterValidatorProps): Promise<string | undefined>;
1128
1841
  /**
1129
1842
  * Top up collateral
1130
1843
  * Default payer is the provider's wallet
1131
1844
  */
1132
- topUpCollateral(props: TopUpCollateralProps): Promise<string>;
1845
+ topUpCollateral(props: TopUpCollateralProps): Promise<string | undefined>;
1133
1846
  /**
1134
1847
  * Withdraw collateral
1135
1848
  * Default withdrawal authority is the provider's wallet
1136
1849
  * Default destination is the provider's wallet
1137
1850
  * @return Transaction signature
1138
1851
  */
1139
- withdrawCollateral(props: WithdrawCollateralProps): Promise<string>;
1852
+ withdrawCollateral(props: WithdrawCollateralProps): Promise<string | undefined>;
1140
1853
  /**
1141
1854
  * Claim compensation
1142
1855
  * Default authority is the provider's wallet
1143
1856
  * @return Transaction signature
1144
1857
  */
1145
- claimCompensation(props: ClaimProps): Promise<string>;
1858
+ claimCompensation(props: ClaimProps): Promise<string | undefined>;
1859
+ /**
1860
+ * Update global configuration for the program
1861
+ * Default authority is the provider's wallet
1862
+ * Only the current authority can call this
1863
+ * @return Transaction signature
1864
+ */
1865
+ globalConfigure(props: GlobalConfigureProps): Promise<string | undefined>;
1146
1866
  /**
1147
1867
  * Update global configuration for the program
1148
1868
  * Default authority is the provider's wallet
1149
1869
  * Only the current authority can call this
1150
1870
  * @return Transaction signature
1151
1871
  */
1152
- configure(props: ConfigureProps): Promise<string>;
1872
+ bondConfigure(props: BondConfigureProps): Promise<string | undefined>;
1153
1873
  /**
1154
1874
  * Set withdrawal authority for validator bond
1155
1875
  * Only the validator identity can call this
1156
1876
  * Default identity is the provider's wallet
1157
1877
  * @return Transaction signature
1158
1878
  */
1159
- setWithdrawAuthority(props: SetWithdrawAuthorityProps): Promise<string>;
1879
+ setWithdrawAuthority(props: SetWithdrawAuthorityProps): Promise<string | undefined>;
1880
+ bondStart(props: {
1881
+ bondType: BondType;
1882
+ name: string;
1883
+ duration_secs: number;
1884
+ }): Promise<string | undefined>;
1885
+ bondFinish(props: {
1886
+ bondType: BondType;
1887
+ name: string;
1888
+ }): Promise<string | undefined>;
1889
+ buildBondGlobalStateInitializeIx(props: GlobalInitializeProps): Promise<TransactionInstruction>;
1160
1890
  /**
1161
- * Build initialize instruction
1891
+ * Build configure instruction
1162
1892
  */
1163
- buildInitializeInstruction(props: InitializeProps): Promise<_solana_web3_js.TransactionInstruction>;
1893
+ buildGlobalConfigureInstruction(props: GlobalConfigureProps): Promise<TransactionInstruction>;
1164
1894
  /**
1165
- * Build register validator instruction
1895
+ * Build initialize instruction
1166
1896
  */
1167
- buildRegisterValidatorInstruction(props: RegisterValidatorProps): Promise<_solana_web3_js.TransactionInstruction>;
1897
+ buildBondInitializeIx(props: BondInitializeProps): Promise<TransactionInstruction>;
1898
+ buildConfigureIx(props: BondConfigureProps): Promise<TransactionInstruction>;
1899
+ buildRegisterIx(props: RegisterValidatorProps): Promise<TransactionInstruction>;
1900
+ buildTopUpIXs(props: TopUpCollateralProps): Promise<TransactionInstruction[]>;
1901
+ buildWithdrawIx(props: WithdrawCollateralProps): Promise<TransactionInstruction>;
1902
+ buildClaimIx(props: ClaimProps): Promise<TransactionInstruction>;
1903
+ buildSetWithdrawAuthorityIx(props: SetWithdrawAuthorityProps): Promise<TransactionInstruction>;
1904
+ buildBondFinishIx(props: {
1905
+ bondType: BondType;
1906
+ name: string;
1907
+ }): Promise<TransactionInstruction>;
1908
+ migrateBond(props: {
1909
+ bondType: BondType;
1910
+ name: string;
1911
+ voteAccount: PublicKeyInitData;
1912
+ }): Promise<string | undefined>;
1913
+ buildBondMigrateIx(props: {
1914
+ bondType: BondType;
1915
+ name: string;
1916
+ voteAccount: PublicKeyInitData;
1917
+ }): Promise<TransactionInstruction>;
1918
+ buildBondStartIx(props: {
1919
+ bondType: BondType;
1920
+ name: string;
1921
+ duration_secs: number;
1922
+ }): Promise<TransactionInstruction>;
1168
1923
  /**
1169
- * Build top up collateral instruction
1924
+ * Fetch global state or throw if not found
1170
1925
  */
1171
- buildTopUpCollateralInstruction(props: TopUpCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1926
+ getGlobalState(): Promise<GlobalState>;
1172
1927
  /**
1173
- * Build withdraw collateral instruction
1928
+ * Fetch bond state with stats
1929
+ * @param bondType - Type of the bond
1930
+ * @param bondName - Name of the bond
1931
+ * @param withStats
1174
1932
  */
1175
- buildWithdrawCollateralInstruction(props: WithdrawCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1933
+ getBondState(bondType: BondType, bondName: string, withStats?: boolean): Promise<{
1934
+ bondState: BondState;
1935
+ stateStats: BondStateStats | null;
1936
+ }>;
1176
1937
  /**
1177
- * Build claim compensation instruction
1938
+ * Get all bond states with total collected collateral
1178
1939
  */
1179
- buildClaimInstruction(props: ClaimProps): Promise<_solana_web3_js.TransactionInstruction>;
1940
+ getAllBondStates(bondType: BondType, sessionStatus?: SessionStatus): Promise<{
1941
+ publicKey: PublicKey;
1942
+ bondState: {
1943
+ name: string;
1944
+ bondType: ({
1945
+ crowdfunding?: undefined;
1946
+ } & {
1947
+ standard: Record<string, never>;
1948
+ }) | ({
1949
+ standard?: undefined;
1950
+ } & {
1951
+ crowdfunding: Record<string, never>;
1952
+ });
1953
+ collateralType: ({
1954
+ native?: undefined;
1955
+ token?: undefined;
1956
+ } & {
1957
+ stakeAccount: Record<string, never>;
1958
+ }) | ({
1959
+ stakeAccount?: undefined;
1960
+ token?: undefined;
1961
+ } & {
1962
+ native: Record<string, never>;
1963
+ }) | ({
1964
+ stakeAccount?: undefined;
1965
+ native?: undefined;
1966
+ } & {
1967
+ token: {
1968
+ 0: PublicKey;
1969
+ };
1970
+ });
1971
+ reserve: PublicKey;
1972
+ authority: PublicKey;
1973
+ sessionId: number;
1974
+ totalMembers: number;
1975
+ totalCompensationAmount: bn_js;
1976
+ sessionStartTs: bn_js;
1977
+ sessionFinishTs: bn_js;
1978
+ status: ({
1979
+ disabled?: undefined;
1980
+ } & {
1981
+ active: Record<string, never>;
1982
+ }) | ({
1983
+ active?: undefined;
1984
+ } & {
1985
+ disabled: Record<string, never>;
1986
+ });
1987
+ bump: number;
1988
+ };
1989
+ stateStats: {
1990
+ totalCollected: number;
1991
+ status: SessionStatus;
1992
+ };
1993
+ }[]>;
1180
1994
  /**
1181
- * Build configure instruction
1995
+ * Get session status for bond state
1182
1996
  */
1183
- buildConfigureInstruction(props: ConfigureProps): Promise<_solana_web3_js.TransactionInstruction>;
1997
+ private getBondStateSessionStatus;
1184
1998
  /**
1185
- * Build set withdraw authority instruction
1999
+ * Get all validator bonds for a given bond state
1186
2000
  */
1187
- buildSetWithdrawAuthorityInstruction(props: SetWithdrawAuthorityProps): Promise<_solana_web3_js.TransactionInstruction>;
2001
+ private getValidatorBondsByState;
1188
2002
  /**
1189
- * Fetch global state or throw if not found
2003
+ * Fetch validator bond data or null if not found
1190
2004
  */
1191
- getGlobalState(): Promise<GlobalState>;
2005
+ getValidatorBond(bondType: BondType, bondName: string, vote: PublicKeyInitData): Promise<ValidatorBond | null>;
1192
2006
  /**
1193
- * Fetch validator bond data or null if not found
1194
- * @param vote
2007
+ * Get bond collateral type
1195
2008
  */
1196
- getValidatorBond(vote: PublicKeyInitData): Promise<ValidatorBond | null>;
2009
+ getBondCollateralType(bondType: BondType, bondName: string): Promise<CollateralType>;
1197
2010
  /**
1198
2011
  * Get validator bond account balance (in SOL)
2012
+ * @param bondType - Type of the bond
2013
+ * @param bondName - Name of the bond
1199
2014
  * @param vote - Vote account public key
1200
- * @return Balance in SOL
2015
+ * @return Balance in lamports
1201
2016
  */
1202
- getValidatorBondBalance(vote: PublicKeyInitData): Promise<number>;
2017
+ getValidatorBondBalance(bondType: BondType, bondName: string, vote: PublicKeyInitData): Promise<number>;
1203
2018
  /**
1204
- * Get transaction history grouped by epochs
1205
- * @param vote - The vote account to get history for
1206
- * @param epochsCount - Number of recent epochs to return (default: 10)
1207
- * @returns Array of epoch history items sorted by epoch (descending)
2019
+ * Get total collected collateral for a bond state
1208
2020
  */
1209
- getHistoryGroupedByEpochs(vote: PublicKeyInitData, epochsCount?: number): Promise<EpochHistoryItem[]>;
2021
+ getBondStateTotalCollected(bondType: BondType, bondName: string, votes: PublicKeyInitData[]): Promise<number>;
1210
2022
  /**
1211
2023
  * Get transaction history for a specific validator bond account
1212
2024
  */
1213
- getHistory(vote: PublicKey, options?: {
2025
+ getHistory(bondType: BondType, bondName: string, vote: PublicKey, options?: {
1214
2026
  cluster?: 'mainnet-beta' | 'testnet' | 'devnet';
1215
2027
  limit?: number;
1216
2028
  before?: string;
@@ -1218,21 +2030,42 @@ declare class JBondClient {
1218
2030
  }): Promise<TransactionHistoryItem[]>;
1219
2031
  /**
1220
2032
  * Get full transaction history by paginating through results
2033
+ * @param bondType
2034
+ * @param bondName
1221
2035
  * @param voteAccount
1222
2036
  * @param pageSize
1223
2037
  */
1224
- getFullHistory(voteAccount: PublicKey, pageSize?: number): Promise<TransactionHistoryItem[]>;
2038
+ getFullHistory(bondType: BondType, bondName: string, voteAccount: PublicKey, pageSize?: number): Promise<TransactionHistoryItem[]>;
1225
2039
  /**
1226
2040
  * Get instruction discriminator from IDL
1227
2041
  * @param instructionName
1228
2042
  * @private
1229
2043
  */
1230
2044
  private getInstructionDiscriminator;
2045
+ /**
2046
+ * Get bond state stats
2047
+ * @param state
2048
+ * @private
2049
+ */
2050
+ private getBondStateStats;
2051
+ /**
2052
+ * Load stake pool account and cache it if not already cached
2053
+ * @private
2054
+ */
2055
+ private loadStakePoolAccount;
2056
+ /**
2057
+ * Manages the interaction with a stake pool, allowing deposits and withdrawals of SOL.
2058
+ */
2059
+ stakePoolManager(props?: {
2060
+ user?: PublicKey;
2061
+ }): Promise<StakePoolManager>;
2062
+ /**
2063
+ * Ensures that a valid user is provided. If a user is not explicitly passed
2064
+ * in the properties, it defaults to the provider's public key.
2065
+ * Throws an error if no user is available.
2066
+ */
2067
+ private ensureUser;
2068
+ private lamports;
1231
2069
  }
1232
2070
 
1233
- /**
1234
- * Program IDs for different environments
1235
- */
1236
- declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
1237
-
1238
- export { BondClientEnv, BondTransactionType, type ClaimProps, type ClientOptions, type ConfigureProps, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalState, type InitializeProps, JBondClient, type Jbond, NodeWallet, type RegisterValidatorProps, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps };
2071
+ export { BondClientEnv, type BondCollateral, type BondConfigureProps, type BondInitializeProps, type BondState, type BondStateStats, type BondStateStatus, BondStateStatusVariant, BondTransactionType, type BondType, BondTypeVariant, type ClaimProps, type ClientOptions, type CollateralType, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalConfigureProps, type GlobalInitializeProps, type GlobalState, JBondClient, JPOOL_STAKE_POOL, type Jbond, NodeWallet, type RegisterValidatorProps, Seeds, SessionStatus, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps, bondTypeToSeed };