@jpool/bond-sdk 0.9.0-next.1 → 0.9.0-next.11

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