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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,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";
253
+ },
254
+ {
255
+ "name": "associatedTokenProgram";
256
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
257
+ },
258
+ {
259
+ "name": "systemProgram";
260
+ "address": "11111111111111111111111111111111";
261
+ },
262
+ {
263
+ "name": "tokenProgram";
264
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
241
265
  },
242
266
  {
243
- name: 'reserve';
267
+ "name": "reserveTokenAccount";
268
+ "writable": true;
269
+ "optional": true;
244
270
  },
245
271
  {
246
- name: 'systemProgram';
247
- address: '11111111111111111111111111111111';
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;
361
+ },
362
+ {
363
+ "name": "systemProgram";
364
+ "address": "11111111111111111111111111111111";
365
+ },
366
+ {
367
+ "name": "tokenProgram";
368
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
369
+ },
370
+ {
371
+ "name": "associatedTokenProgram";
372
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
346
373
  },
347
374
  {
348
- name: 'systemProgram';
349
- address: '11111111111111111111111111111111';
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": [
423
+ {
424
+ "name": "bondState";
425
+ },
383
426
  {
384
- name: 'validatorBond';
385
- writable: true;
386
- pda: {
387
- seeds: [
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;
486
546
  },
487
547
  {
488
- name: 'systemProgram';
489
- address: '11111111111111111111111111111111';
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";
565
+ },
566
+ {
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,226 @@ 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
+ ];
552
722
  }
553
723
  ];
554
724
  };
555
725
  },
556
726
  {
557
- name: 'withdrawalAuthority';
558
- writable: true;
559
- signer: true;
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
+ ];
782
+ }
783
+ ];
784
+ };
560
785
  },
561
786
  {
562
- name: 'destination';
563
- writable: true;
787
+ "name": "authority";
788
+ "writable": true;
789
+ "signer": true;
564
790
  },
565
791
  {
566
- name: 'epochSchedule';
567
- address: 'SysvarEpochSchedu1e111111111111111111111111';
792
+ "name": "systemProgram";
793
+ "address": "11111111111111111111111111111111";
794
+ }
795
+ ];
796
+ "args": [];
797
+ },
798
+ {
799
+ "name": "sessionStart";
800
+ "docs": [
801
+ "Starts a paused bond, allowing deposits and withdrawals to resume."
802
+ ];
803
+ "discriminator": [
804
+ 132,
805
+ 93,
806
+ 83,
807
+ 152,
808
+ 141,
809
+ 32,
810
+ 58,
811
+ 92
812
+ ];
813
+ "accounts": [
814
+ {
815
+ "name": "bondState";
816
+ "writable": true;
568
817
  },
569
818
  {
570
- name: 'systemProgram';
571
- address: '11111111111111111111111111111111';
819
+ "name": "authority";
820
+ "writable": true;
821
+ "signer": true;
822
+ "relations": [
823
+ "bondState"
824
+ ];
572
825
  }
573
826
  ];
574
- args: [
827
+ "args": [
575
828
  {
576
- name: 'amount';
577
- type: 'u64';
829
+ "name": "durationSecs";
830
+ "type": "u64";
578
831
  }
579
832
  ];
580
833
  }
581
834
  ];
582
- accounts: [
835
+ "accounts": [
836
+ {
837
+ "name": "bondState";
838
+ "discriminator": [
839
+ 251,
840
+ 95,
841
+ 76,
842
+ 47,
843
+ 191,
844
+ 108,
845
+ 163,
846
+ 92
847
+ ];
848
+ },
583
849
  {
584
- name: 'globalState';
585
- discriminator: [
850
+ "name": "globalState";
851
+ "discriminator": [
586
852
  163,
587
853
  46,
588
854
  74,
@@ -594,8 +860,8 @@ type Jbond = {
594
860
  ];
595
861
  },
596
862
  {
597
- name: 'validatorBond';
598
- discriminator: [
863
+ "name": "validatorBond";
864
+ "discriminator": [
599
865
  82,
600
866
  127,
601
867
  243,
@@ -607,10 +873,36 @@ type Jbond = {
607
873
  ];
608
874
  }
609
875
  ];
610
- events: [
876
+ "events": [
611
877
  {
612
- name: 'collateralToppedUp';
613
- discriminator: [
878
+ "name": "bondFinished";
879
+ "discriminator": [
880
+ 223,
881
+ 254,
882
+ 3,
883
+ 161,
884
+ 90,
885
+ 190,
886
+ 150,
887
+ 191
888
+ ];
889
+ },
890
+ {
891
+ "name": "bondStarted";
892
+ "discriminator": [
893
+ 235,
894
+ 69,
895
+ 80,
896
+ 63,
897
+ 209,
898
+ 252,
899
+ 232,
900
+ 64
901
+ ];
902
+ },
903
+ {
904
+ "name": "collateralToppedUp";
905
+ "discriminator": [
614
906
  189,
615
907
  137,
616
908
  204,
@@ -622,8 +914,8 @@ type Jbond = {
622
914
  ];
623
915
  },
624
916
  {
625
- name: 'collateralWithdrawn';
626
- discriminator: [
917
+ "name": "collateralWithdrawn";
918
+ "discriminator": [
627
919
  51,
628
920
  224,
629
921
  133,
@@ -635,8 +927,8 @@ type Jbond = {
635
927
  ];
636
928
  },
637
929
  {
638
- name: 'compensationClaimed';
639
- discriminator: [
930
+ "name": "compensationClaimed";
931
+ "discriminator": [
640
932
  36,
641
933
  159,
642
934
  41,
@@ -648,8 +940,8 @@ type Jbond = {
648
940
  ];
649
941
  },
650
942
  {
651
- name: 'validatorRegistered';
652
- discriminator: [
943
+ "name": "validatorRegistered";
944
+ "discriminator": [
653
945
  20,
654
946
  20,
655
947
  190,
@@ -661,347 +953,606 @@ type Jbond = {
661
953
  ];
662
954
  }
663
955
  ];
664
- errors: [
956
+ "errors": [
957
+ {
958
+ "code": 6000;
959
+ "name": "invalidVoteAccount";
960
+ "msg": "Invalid vote account";
961
+ },
962
+ {
963
+ "code": 6001;
964
+ "name": "identityMismatch";
965
+ "msg": "Identity does not match vote account";
966
+ },
967
+ {
968
+ "code": 6002;
969
+ "name": "insufficientCollateral";
970
+ "msg": "Insufficient collateral amount";
971
+ },
972
+ {
973
+ "code": 6003;
974
+ "name": "targetAprTooLow";
975
+ "msg": "Target APR is below minimum threshold";
976
+ },
977
+ {
978
+ "code": 6004;
979
+ "name": "mathOverflow";
980
+ "msg": "Math overflow";
981
+ },
982
+ {
983
+ "code": 6005;
984
+ "name": "invalidAmount";
985
+ "msg": "Invalid amount";
986
+ },
665
987
  {
666
- code: 6000;
667
- name: 'invalidVoteAccount';
668
- msg: 'Invalid vote account';
988
+ "code": 6006;
989
+ "name": "validatorNotActive";
990
+ "msg": "Validator bond account is not active";
669
991
  },
670
992
  {
671
- code: 6001;
672
- name: 'identityMismatch';
673
- msg: 'Identity does not match vote account';
993
+ "code": 6007;
994
+ "name": "validatorAlreadyRegistered";
995
+ "msg": "Validator already registered";
674
996
  },
675
997
  {
676
- code: 6002;
677
- name: 'insufficientCollateral';
678
- msg: 'Insufficient collateral amount';
998
+ "code": 6008;
999
+ "name": "unauthorized";
1000
+ "msg": "unauthorized";
679
1001
  },
680
1002
  {
681
- code: 6003;
682
- name: 'targetAprTooLow';
683
- msg: 'Target APR is below minimum threshold';
1003
+ "code": 6009;
1004
+ "name": "withdrawalLockedNearEpochEnd";
1005
+ "msg": "Withdrawals are locked near the end of the epoch.";
684
1006
  },
685
1007
  {
686
- code: 6004;
687
- name: 'mathOverflow';
688
- msg: 'Math overflow';
1008
+ "code": 6010;
1009
+ "name": "missingTokenAccounts";
1010
+ "msg": "Missing token accounts for token collateral type";
689
1011
  },
690
1012
  {
691
- code: 6005;
692
- name: 'invalidAmount';
693
- msg: 'Invalid amount';
1013
+ "code": 6011;
1014
+ "name": "missingTokenProgram";
1015
+ "msg": "Token program is required for token collateral type";
694
1016
  },
695
1017
  {
696
- code: 6006;
697
- name: 'validatorNotActive';
698
- msg: 'Validator bond account is not active';
1018
+ "code": 6012;
1019
+ "name": "invalidMint";
1020
+ "msg": "Invalid mint for token collateral type";
699
1021
  },
700
1022
  {
701
- code: 6007;
702
- name: 'validatorAlreadyRegistered';
703
- msg: 'Validator already registered';
1023
+ "code": 6013;
1024
+ "name": "missingStakeAccount";
1025
+ "msg": "Stake account is required for stake account collateral type";
704
1026
  },
705
1027
  {
706
- code: 6008;
707
- name: 'unauthorized';
708
- msg: 'unauthorized';
1028
+ "code": 6014;
1029
+ "name": "missingStakeProgram";
1030
+ "msg": "Stake program is required for stake account collateral type";
709
1031
  },
710
1032
  {
711
- code: 6009;
712
- name: 'withdrawalLockedNearEpochEnd';
713
- msg: 'Withdrawals are locked near the end of the epoch.';
1033
+ "code": 6015;
1034
+ "name": "bondFinished";
1035
+ "msg": "Bond is finished (deposits/withdrawals disabled)";
1036
+ },
1037
+ {
1038
+ "code": 6016;
1039
+ "name": "bondNotFinished";
1040
+ "msg": "Bond is not finished";
1041
+ },
1042
+ {
1043
+ "code": 6017;
1044
+ "name": "unsupportedCollateralType";
1045
+ "msg": "Unsupported collateral type";
1046
+ },
1047
+ {
1048
+ "code": 6018;
1049
+ "name": "overflow";
1050
+ "msg": "Math operation overflowed";
1051
+ },
1052
+ {
1053
+ "code": 6019;
1054
+ "name": "incorrectBondType";
1055
+ "msg": "Incorrect bond type for this operation";
1056
+ },
1057
+ {
1058
+ "code": 6020;
1059
+ "name": "bondNotFinishable";
1060
+ "msg": "This bond type can't be finished";
1061
+ },
1062
+ {
1063
+ "code": 6021;
1064
+ "name": "invalidArgument";
1065
+ "msg": "Invalid argument provided";
714
1066
  }
715
1067
  ];
716
- types: [
1068
+ "types": [
717
1069
  {
718
- name: 'collateralToppedUp';
719
- type: {
720
- kind: 'struct';
721
- fields: [
1070
+ "name": "bondConfigureData";
1071
+ "type": {
1072
+ "kind": "struct";
1073
+ "fields": [
722
1074
  {
723
- name: 'validator';
724
- type: 'pubkey';
1075
+ "name": "newReserve";
1076
+ "type": {
1077
+ "option": "pubkey";
1078
+ };
725
1079
  },
726
1080
  {
727
- name: 'amount';
728
- type: 'u64';
1081
+ "name": "newAuthority";
1082
+ "type": {
1083
+ "option": "pubkey";
1084
+ };
1085
+ }
1086
+ ];
1087
+ };
1088
+ },
1089
+ {
1090
+ "name": "bondFinished";
1091
+ "type": {
1092
+ "kind": "struct";
1093
+ "fields": [
1094
+ {
1095
+ "name": "bond";
1096
+ "type": "pubkey";
729
1097
  },
730
1098
  {
731
- name: 'postBalance';
732
- type: 'u64';
1099
+ "name": "authority";
1100
+ "type": "pubkey";
733
1101
  },
734
1102
  {
735
- name: 'timestamp';
736
- type: 'i64';
1103
+ "name": "timestamp";
1104
+ "type": "i64";
737
1105
  }
738
1106
  ];
739
1107
  };
740
1108
  },
741
1109
  {
742
- name: 'collateralWithdrawn';
743
- type: {
744
- kind: 'struct';
745
- fields: [
1110
+ "name": "bondInitializeData";
1111
+ "docs": [
1112
+ "Data required to initialize a performance bond"
1113
+ ];
1114
+ "type": {
1115
+ "kind": "struct";
1116
+ "fields": [
746
1117
  {
747
- name: 'validator';
748
- type: 'pubkey';
1118
+ "name": "name";
1119
+ "type": "string";
749
1120
  },
750
1121
  {
751
- name: 'amount';
752
- type: 'u64';
1122
+ "name": "bondType";
1123
+ "type": {
1124
+ "defined": {
1125
+ "name": "bondType";
1126
+ };
1127
+ };
753
1128
  },
754
1129
  {
755
- name: 'postBalance';
756
- type: 'u64';
1130
+ "name": "reserve";
1131
+ "type": "pubkey";
757
1132
  },
758
1133
  {
759
- name: 'timestamp';
760
- type: 'i64';
1134
+ "name": "collateralType";
1135
+ "type": {
1136
+ "defined": {
1137
+ "name": "collateralType";
1138
+ };
1139
+ };
761
1140
  }
762
1141
  ];
763
1142
  };
764
1143
  },
765
1144
  {
766
- name: 'compensationClaimed';
767
- type: {
768
- kind: 'struct';
769
- fields: [
1145
+ "name": "bondStarted";
1146
+ "type": {
1147
+ "kind": "struct";
1148
+ "fields": [
1149
+ {
1150
+ "name": "bond";
1151
+ "type": "pubkey";
1152
+ },
1153
+ {
1154
+ "name": "authority";
1155
+ "type": "pubkey";
1156
+ },
1157
+ {
1158
+ "name": "timestamp";
1159
+ "type": "i64";
1160
+ }
1161
+ ];
1162
+ };
1163
+ },
1164
+ {
1165
+ "name": "bondState";
1166
+ "type": {
1167
+ "kind": "struct";
1168
+ "fields": [
1169
+ {
1170
+ "name": "name";
1171
+ "type": "string";
1172
+ },
1173
+ {
1174
+ "name": "bondType";
1175
+ "docs": [
1176
+ "The type of bond (e.g., Performance, Crowdfunding)"
1177
+ ];
1178
+ "type": {
1179
+ "defined": {
1180
+ "name": "bondType";
1181
+ };
1182
+ };
1183
+ },
1184
+ {
1185
+ "name": "collateralType";
1186
+ "docs": [
1187
+ "The type of collateral accepted for this bond"
1188
+ ];
1189
+ "type": {
1190
+ "defined": {
1191
+ "name": "collateralType";
1192
+ };
1193
+ };
1194
+ },
770
1195
  {
771
- name: 'validator';
772
- type: 'pubkey';
1196
+ "name": "reserve";
1197
+ "docs": [
1198
+ "Reserve account where collateral is held"
1199
+ ];
1200
+ "type": "pubkey";
1201
+ },
1202
+ {
1203
+ "name": "authority";
1204
+ "docs": [
1205
+ "Authority allowed to manage the bond configuration"
1206
+ ];
1207
+ "type": "pubkey";
773
1208
  },
774
1209
  {
775
- name: 'amount';
776
- type: 'u64';
1210
+ "name": "sessionId";
1211
+ "docs": [
1212
+ "Unique identifier for the bonding session"
1213
+ ];
1214
+ "type": "u32";
777
1215
  },
778
1216
  {
779
- name: 'postBalance';
780
- type: 'u64';
1217
+ "name": "totalMembers";
1218
+ "docs": [
1219
+ "Total number of users who have participated in the bond"
1220
+ ];
1221
+ "type": "u16";
781
1222
  },
782
1223
  {
783
- name: 'epoch';
784
- type: 'u64';
1224
+ "name": "totalCompensationAmount";
1225
+ "docs": [
1226
+ "Total compensation amount paid out"
1227
+ ];
1228
+ "type": "u64";
785
1229
  },
786
1230
  {
787
- name: 'timestamp';
788
- type: 'i64';
1231
+ "name": "sessionStartTs";
1232
+ "docs": [
1233
+ "Start timestamp of the current session (unix seconds). 0 — not set."
1234
+ ];
1235
+ "type": "i64";
1236
+ },
1237
+ {
1238
+ "name": "sessionFinishTs";
1239
+ "docs": [
1240
+ "Finish timestamp of the current session (unix seconds). 0 — not set."
1241
+ ];
1242
+ "type": "i64";
1243
+ },
1244
+ {
1245
+ "name": "bump";
1246
+ "docs": [
1247
+ "Bump for the PDA"
1248
+ ];
1249
+ "type": "u8";
789
1250
  }
790
1251
  ];
791
1252
  };
792
1253
  },
793
1254
  {
794
- name: 'configureData';
795
- type: {
796
- kind: 'struct';
797
- fields: [
1255
+ "name": "bondType";
1256
+ "docs": [
1257
+ "Types of bonds supported by the program"
1258
+ ];
1259
+ "type": {
1260
+ "kind": "enum";
1261
+ "variants": [
798
1262
  {
799
- name: 'newAuthority';
800
- type: {
801
- option: 'pubkey';
802
- };
1263
+ "name": "performance";
803
1264
  },
804
1265
  {
805
- name: 'newReserve';
806
- type: {
807
- option: 'pubkey';
808
- };
1266
+ "name": "crowdfunding";
809
1267
  }
810
1268
  ];
811
1269
  };
812
1270
  },
813
1271
  {
814
- name: 'globalState';
815
- type: {
816
- kind: 'struct';
817
- fields: [
1272
+ "name": "collateralToppedUp";
1273
+ "type": {
1274
+ "kind": "struct";
1275
+ "fields": [
818
1276
  {
819
- name: 'authority';
820
- docs: [
821
- 'The authority allowed to manage the program'
822
- ];
823
- type: 'pubkey';
1277
+ "name": "validator";
1278
+ "type": "pubkey";
824
1279
  },
825
1280
  {
826
- name: 'reserve';
827
- docs: [
828
- 'The reserve vault holding SOL for bonding and compensation'
829
- ];
830
- type: 'pubkey';
1281
+ "name": "amount";
1282
+ "type": "u64";
831
1283
  },
832
1284
  {
833
- name: 'totalValidators';
834
- docs: [
835
- 'Total number of registered validators'
836
- ];
837
- type: 'u16';
1285
+ "name": "postBalance";
1286
+ "type": "u64";
838
1287
  },
839
1288
  {
840
- name: 'totalCompensationAmount';
841
- docs: [
842
- 'Total compensation amount paid out'
843
- ];
844
- type: 'u64';
1289
+ "name": "timestamp";
1290
+ "type": "i64";
1291
+ }
1292
+ ];
1293
+ };
1294
+ },
1295
+ {
1296
+ "name": "collateralType";
1297
+ "docs": [
1298
+ "Types of collateral that can be used for bond deposit"
1299
+ ];
1300
+ "type": {
1301
+ "kind": "enum";
1302
+ "variants": [
1303
+ {
1304
+ "name": "native";
845
1305
  },
846
1306
  {
847
- name: 'bump';
848
- docs: [
849
- 'Bump for the PDA'
1307
+ "name": "stakeAccount";
1308
+ },
1309
+ {
1310
+ "name": "token";
1311
+ "fields": [
1312
+ "pubkey"
850
1313
  ];
851
- type: 'u8';
852
1314
  }
853
1315
  ];
854
1316
  };
855
1317
  },
856
1318
  {
857
- name: 'validatorBond';
858
- type: {
859
- kind: 'struct';
860
- fields: [
1319
+ "name": "collateralWithdrawn";
1320
+ "type": {
1321
+ "kind": "struct";
1322
+ "fields": [
861
1323
  {
862
- name: 'identity';
863
- docs: [
864
- 'The validator identity pubkey'
865
- ];
866
- type: 'pubkey';
1324
+ "name": "validator";
1325
+ "type": "pubkey";
867
1326
  },
868
1327
  {
869
- name: 'voteAccount';
870
- docs: [
871
- 'The validator vote account pubkey'
872
- ];
873
- type: 'pubkey';
1328
+ "name": "amount";
1329
+ "type": "u64";
874
1330
  },
875
1331
  {
876
- name: 'creator';
877
- docs: [
878
- 'Creator of the validator bond account'
879
- ];
880
- type: 'pubkey';
1332
+ "name": "postBalance";
1333
+ "type": "u64";
881
1334
  },
882
1335
  {
883
- name: 'withdrawalAuthority';
884
- docs: [
885
- 'Authority allowed to withdraw funds (if None, only identity can withdraw)'
886
- ];
887
- type: {
888
- option: 'pubkey';
889
- };
1336
+ "name": "timestamp";
1337
+ "type": "i64";
1338
+ }
1339
+ ];
1340
+ };
1341
+ },
1342
+ {
1343
+ "name": "compensationClaimed";
1344
+ "type": {
1345
+ "kind": "struct";
1346
+ "fields": [
1347
+ {
1348
+ "name": "validator";
1349
+ "type": "pubkey";
890
1350
  },
891
1351
  {
892
- name: 'totalCompensationAmount';
893
- docs: [
894
- 'Total compensation claimed for the validator'
895
- ];
896
- type: 'u64';
1352
+ "name": "amount";
1353
+ "type": "u64";
897
1354
  },
898
1355
  {
899
- name: 'lastCompensationAmount';
900
- docs: [
901
- 'Last compensation amount claimed'
902
- ];
903
- type: 'u64';
1356
+ "name": "postBalance";
1357
+ "type": "u64";
904
1358
  },
905
1359
  {
906
- name: 'lastCompensationEpoch';
907
- docs: [
908
- 'Last epoch when compensation was claimed'
909
- ];
910
- type: 'u64';
1360
+ "name": "epoch";
1361
+ "type": "u64";
911
1362
  },
912
1363
  {
913
- name: 'createdAt';
914
- docs: [
915
- 'Timestamp when the bond account was created'
1364
+ "name": "timestamp";
1365
+ "type": "i64";
1366
+ }
1367
+ ];
1368
+ };
1369
+ },
1370
+ {
1371
+ "name": "globalConfigureData";
1372
+ "type": {
1373
+ "kind": "struct";
1374
+ "fields": [
1375
+ {
1376
+ "name": "newAuthority";
1377
+ "type": {
1378
+ "option": "pubkey";
1379
+ };
1380
+ }
1381
+ ];
1382
+ };
1383
+ },
1384
+ {
1385
+ "name": "globalState";
1386
+ "type": {
1387
+ "kind": "struct";
1388
+ "fields": [
1389
+ {
1390
+ "name": "bonds";
1391
+ "docs": [
1392
+ "List of all registered bonds"
916
1393
  ];
917
- type: 'i64';
1394
+ "type": {
1395
+ "vec": "pubkey";
1396
+ };
918
1397
  },
919
1398
  {
920
- name: 'isActive';
921
- docs: [
922
- 'Whether the validator is currently active'
1399
+ "name": "authority";
1400
+ "docs": [
1401
+ "The authority allowed to manage the program"
923
1402
  ];
924
- type: 'bool';
1403
+ "type": "pubkey";
925
1404
  },
926
1405
  {
927
- name: 'bump';
928
- docs: [
929
- 'Bump for the PDA'
1406
+ "name": "bump";
1407
+ "docs": [
1408
+ "Bump for the PDA"
930
1409
  ];
931
- type: 'u8';
1410
+ "type": "u8";
932
1411
  }
933
1412
  ];
934
1413
  };
935
1414
  },
936
1415
  {
937
- name: 'validatorRegistered';
938
- type: {
939
- kind: 'struct';
940
- fields: [
1416
+ "name": "validatorBond";
1417
+ "type": {
1418
+ "kind": "struct";
1419
+ "fields": [
941
1420
  {
942
- name: 'identity';
943
- type: 'pubkey';
1421
+ "name": "bond";
1422
+ "type": "pubkey";
944
1423
  },
945
1424
  {
946
- name: 'voteAccount';
947
- type: 'pubkey';
1425
+ "name": "identity";
1426
+ "type": "pubkey";
948
1427
  },
949
1428
  {
950
- name: 'initialCollateral';
951
- type: 'u64';
1429
+ "name": "voteAccount";
1430
+ "type": "pubkey";
952
1431
  },
953
1432
  {
954
- name: 'timestamp';
955
- type: 'i64';
1433
+ "name": "creator";
1434
+ "type": "pubkey";
1435
+ },
1436
+ {
1437
+ "name": "withdrawalAuthority";
1438
+ "type": {
1439
+ "option": "pubkey";
1440
+ };
1441
+ },
1442
+ {
1443
+ "name": "totalCompensationAmount";
1444
+ "type": "u64";
1445
+ },
1446
+ {
1447
+ "name": "lastCompensationAmount";
1448
+ "type": "u64";
1449
+ },
1450
+ {
1451
+ "name": "lastCompensationEpoch";
1452
+ "type": "u64";
1453
+ },
1454
+ {
1455
+ "name": "createdAt";
1456
+ "type": "i64";
1457
+ },
1458
+ {
1459
+ "name": "isActive";
1460
+ "type": "bool";
1461
+ },
1462
+ {
1463
+ "name": "bump";
1464
+ "type": "u8";
956
1465
  }
957
1466
  ];
958
1467
  };
1468
+ },
1469
+ {
1470
+ "name": "validatorRegistered";
1471
+ "type": {
1472
+ "kind": "struct";
1473
+ "fields": [
1474
+ {
1475
+ "name": "identity";
1476
+ "type": "pubkey";
1477
+ },
1478
+ {
1479
+ "name": "voteAccount";
1480
+ "type": "pubkey";
1481
+ },
1482
+ {
1483
+ "name": "timestamp";
1484
+ "type": "i64";
1485
+ }
1486
+ ];
1487
+ };
1488
+ }
1489
+ ];
1490
+ "constants": [
1491
+ {
1492
+ "name": "epochLockedSlotTail";
1493
+ "docs": [
1494
+ "Epoch slot index at the end of an epoch after which withdrawals are locked"
1495
+ ];
1496
+ "type": "u64";
1497
+ "value": "420000";
959
1498
  }
960
1499
  ];
961
1500
  };
962
1501
 
963
- type GlobalState = {
964
- authority: PublicKey;
965
- reserve: PublicKey;
966
- totalValidators: number;
967
- totalCompensationAmount: BN;
968
- bump: number;
1502
+ type GlobalState = IdlAccounts<Jbond>['globalState'];
1503
+ type BondState = IdlAccounts<Jbond>['bondState'];
1504
+ type ValidatorBond = IdlAccounts<Jbond>['validatorBond'];
1505
+ type BondType = IdlTypes<Jbond>['bondType'];
1506
+ type CollateralType = IdlTypes<Jbond>['collateralType'];
1507
+ type BondStateStats = {
1508
+ totalCollected: number;
1509
+ status: SessionStatus;
969
1510
  };
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;
1511
+ declare const bondTypeToSeed: {
1512
+ performance: Seeds;
1513
+ crowdfunding: Seeds;
1514
+ };
1515
+ declare const BondTypeVariant: {
1516
+ Performance: BondType;
1517
+ Crowdfunding: BondType;
981
1518
  };
982
- type InitializeProps = {
1519
+ type GlobalInitializeProps = {
983
1520
  authority?: PublicKey;
1521
+ };
1522
+ type BondInitializeProps = {
1523
+ bondType: BondType;
1524
+ name: string;
1525
+ authority?: PublicKey;
1526
+ collateralType: CollateralType;
984
1527
  reserve: PublicKey;
985
1528
  };
986
1529
  type RegisterValidatorProps = {
1530
+ bondType: BondType;
1531
+ name: string;
987
1532
  identity: PublicKey;
988
1533
  voteAccount: PublicKey;
989
- initialCollateral: number;
990
1534
  creator?: PublicKey;
991
1535
  };
992
1536
  type TopUpCollateralProps = {
993
- amount: number;
1537
+ bondType: BondType;
1538
+ name: string;
1539
+ identity: PublicKey;
994
1540
  voteAccount: PublicKey;
1541
+ collateral: BondCollateral;
995
1542
  payer?: PublicKey;
996
1543
  };
997
1544
  type WithdrawCollateralProps = {
998
- amount: number;
1545
+ bondType: BondType;
1546
+ name: string;
1547
+ withdraw: BondCollateral;
999
1548
  voteAccount: PublicKey;
1000
1549
  destination?: PublicKey;
1001
1550
  withdrawalAuthority?: PublicKey;
1002
1551
  };
1003
1552
  type ClaimProps = {
1004
- amount: number;
1553
+ bondType: BondType;
1554
+ name: string;
1555
+ claim: BondCollateral;
1005
1556
  voteAccount: PublicKey;
1006
1557
  reserve?: PublicKey;
1007
1558
  authority?: PublicKey;
@@ -1018,12 +1569,20 @@ type GetHistoryGroupedProps = {
1018
1569
  voteAccount: PublicKey;
1019
1570
  epochsCount?: number;
1020
1571
  };
1021
- type ConfigureProps = {
1572
+ type BondConfigureProps = {
1573
+ bondType: BondType;
1574
+ name: string;
1022
1575
  authority?: PublicKey;
1023
1576
  newAuthority?: PublicKey;
1024
1577
  newReserve?: PublicKey;
1025
1578
  };
1579
+ type GlobalConfigureProps = {
1580
+ authority?: PublicKey;
1581
+ newAuthority?: PublicKey;
1582
+ };
1026
1583
  type SetWithdrawAuthorityProps = {
1584
+ bondType: BondType;
1585
+ name: string;
1027
1586
  voteAccount: PublicKey;
1028
1587
  newWithdrawAuthority?: PublicKey | null;
1029
1588
  identity?: PublicKey;
@@ -1049,6 +1608,34 @@ declare enum BondTransactionType {
1049
1608
  Withdrawal = "withdrawal",
1050
1609
  Compensation = "compensation"
1051
1610
  }
1611
+ type BondCollateral = {
1612
+ amount?: number;
1613
+ mint?: PublicKey;
1614
+ stakeAccount?: PublicKey;
1615
+ };
1616
+ declare enum SessionStatus {
1617
+ Live = 0,
1618
+ Finished = 1
1619
+ }
1620
+
1621
+ type GetHistoryOpts = {
1622
+ cluster?: 'mainnet-beta' | 'testnet' | 'devnet';
1623
+ limit?: number;
1624
+ before?: string;
1625
+ until?: string;
1626
+ };
1627
+ declare class HistoryManager {
1628
+ private program;
1629
+ private connection;
1630
+ private programId;
1631
+ private discCache;
1632
+ constructor(program: Program<Jbond>, connection: Connection, programId: PublicKey);
1633
+ getHistory(bondType: BondType, vote: PublicKeyInitData, pdaDeriver: (bondType: BondType, vote: PublicKeyInitData) => [PublicKey, number], options?: GetHistoryOpts): Promise<TransactionHistoryItem[]>;
1634
+ private fetchSignaturesForAddress;
1635
+ private fetchParsedTransactions;
1636
+ private getInstructionDiscriminator;
1637
+ private decodeInstructionData;
1638
+ }
1052
1639
 
1053
1640
  type Wallet = {
1054
1641
  publicKey: PublicKey;
@@ -1076,14 +1663,14 @@ declare enum BondClientEnv {
1076
1663
  * Options for configuring the JBondClient.
1077
1664
  */
1078
1665
  type ClientOptions = {
1079
- programId?: PublicKey;
1080
1666
  debug?: boolean;
1081
1667
  } & Record<string, any>;
1082
1668
  declare class JBondClient {
1083
- readonly provider: AnchorProvider;
1669
+ readonly provider: Provider;
1084
1670
  readonly options: ClientOptions;
1085
1671
  readonly program: Program<Jbond>;
1086
- constructor(provider: AnchorProvider, options?: ClientOptions);
1672
+ readonly history: HistoryManager;
1673
+ constructor(provider: Provider, options?: ClientOptions);
1087
1674
  /**
1088
1675
  * Creates an instance of `JBondClient` using a provided connection and wallet.
1089
1676
  */
@@ -1095,7 +1682,7 @@ declare class JBondClient {
1095
1682
  /**
1096
1683
  * Get the current program ID.
1097
1684
  */
1098
- get programId(): PublicKey;
1685
+ get programId(): any;
1099
1686
  /**
1100
1687
  * Get the current connection.
1101
1688
  */
@@ -1108,121 +1695,150 @@ declare class JBondClient {
1108
1695
  * Configure a specific option.
1109
1696
  */
1110
1697
  configureEnv<K extends keyof ClientOptions>(key: K, val: ClientOptions[K]): this;
1698
+ private getBondTypeSeed;
1111
1699
  /**
1112
1700
  * Program Derived Addresses (PDAs)
1113
1701
  */
1114
1702
  pda: {
1115
1703
  globalState: () => [PublicKey, number];
1116
- validatorBond: (vote: PublicKeyInitData) => [PublicKey, number];
1704
+ bondState: (bondType: BondType, bondName: string) => [PublicKey, number];
1705
+ validatorBond: (bondType: BondType, bondName: string, vote: PublicKeyInitData) => [PublicKey, number];
1117
1706
  };
1707
+ globalInitialize(props: GlobalInitializeProps): Promise<string | undefined>;
1118
1708
  /**
1119
1709
  * Initialize the program
1120
1710
  * Default authority is the provider's wallet
1121
1711
  */
1122
- initialize(props: InitializeProps): Promise<string>;
1712
+ bondInitialize(props: BondInitializeProps): Promise<string | undefined>;
1123
1713
  /**
1124
1714
  * Register a new validator
1125
1715
  * Default creator is the provider's wallet
1126
1716
  */
1127
- registerValidator(props: RegisterValidatorProps): Promise<string>;
1717
+ registerValidator(props: RegisterValidatorProps): Promise<string | undefined>;
1128
1718
  /**
1129
1719
  * Top up collateral
1130
1720
  * Default payer is the provider's wallet
1131
1721
  */
1132
- topUpCollateral(props: TopUpCollateralProps): Promise<string>;
1722
+ topUpCollateral(props: TopUpCollateralProps): Promise<string | undefined>;
1133
1723
  /**
1134
1724
  * Withdraw collateral
1135
1725
  * Default withdrawal authority is the provider's wallet
1136
1726
  * Default destination is the provider's wallet
1137
1727
  * @return Transaction signature
1138
1728
  */
1139
- withdrawCollateral(props: WithdrawCollateralProps): Promise<string>;
1729
+ withdrawCollateral(props: WithdrawCollateralProps): Promise<string | undefined>;
1140
1730
  /**
1141
1731
  * Claim compensation
1142
1732
  * Default authority is the provider's wallet
1143
1733
  * @return Transaction signature
1144
1734
  */
1145
- claimCompensation(props: ClaimProps): Promise<string>;
1735
+ claimCompensation(props: ClaimProps): Promise<string | undefined>;
1736
+ /**
1737
+ * Update global configuration for the program
1738
+ * Default authority is the provider's wallet
1739
+ * Only the current authority can call this
1740
+ * @return Transaction signature
1741
+ */
1742
+ globalConfigure(props: GlobalConfigureProps): Promise<string | undefined>;
1146
1743
  /**
1147
1744
  * Update global configuration for the program
1148
1745
  * Default authority is the provider's wallet
1149
1746
  * Only the current authority can call this
1150
1747
  * @return Transaction signature
1151
1748
  */
1152
- configure(props: ConfigureProps): Promise<string>;
1749
+ bondConfigure(props: BondConfigureProps): Promise<string | undefined>;
1153
1750
  /**
1154
1751
  * Set withdrawal authority for validator bond
1155
1752
  * Only the validator identity can call this
1156
1753
  * Default identity is the provider's wallet
1157
1754
  * @return Transaction signature
1158
1755
  */
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>;
1168
- /**
1169
- * Build top up collateral instruction
1170
- */
1171
- buildTopUpCollateralInstruction(props: TopUpCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1756
+ setWithdrawAuthority(props: SetWithdrawAuthorityProps): Promise<string | undefined>;
1757
+ bondStart(props: {
1758
+ bondType: BondType;
1759
+ name: string;
1760
+ duration_secs: number;
1761
+ }): Promise<string | undefined>;
1762
+ bondFinish(props: {
1763
+ bondType: BondType;
1764
+ name: string;
1765
+ }): Promise<string | undefined>;
1766
+ buildBondGlobalStateInitializeIx(props: GlobalInitializeProps): Promise<TransactionInstruction>;
1172
1767
  /**
1173
- * Build withdraw collateral instruction
1768
+ * Build configure instruction
1174
1769
  */
1175
- buildWithdrawCollateralInstruction(props: WithdrawCollateralProps): Promise<_solana_web3_js.TransactionInstruction>;
1770
+ buildGlobalConfigureInstruction(props: GlobalConfigureProps): Promise<TransactionInstruction>;
1176
1771
  /**
1177
- * Build claim compensation instruction
1772
+ * Build initialize instruction
1178
1773
  */
1179
- buildClaimInstruction(props: ClaimProps): Promise<_solana_web3_js.TransactionInstruction>;
1774
+ buildBondInitializeIx(props: BondInitializeProps): Promise<TransactionInstruction>;
1775
+ buildConfigureIx(props: BondConfigureProps): Promise<TransactionInstruction>;
1776
+ buildRegisterIx(props: RegisterValidatorProps): Promise<TransactionInstruction>;
1777
+ buildTopUpIXs(props: TopUpCollateralProps): Promise<TransactionInstruction[]>;
1778
+ buildWithdrawIx(props: WithdrawCollateralProps): Promise<TransactionInstruction>;
1779
+ buildClaimIx(props: ClaimProps): Promise<TransactionInstruction>;
1780
+ buildSetWithdrawAuthorityIx(props: SetWithdrawAuthorityProps): Promise<TransactionInstruction>;
1781
+ buildBondFinishIx(_props: {
1782
+ bondType: BondType;
1783
+ name: string;
1784
+ }): Promise<TransactionInstruction>;
1785
+ buildBondStartIx(props: {
1786
+ bondType: BondType;
1787
+ name: string;
1788
+ duration_secs: number;
1789
+ }): Promise<TransactionInstruction>;
1180
1790
  /**
1181
- * Build configure instruction
1791
+ * Fetch global state or throw if not found
1182
1792
  */
1183
- buildConfigureInstruction(props: ConfigureProps): Promise<_solana_web3_js.TransactionInstruction>;
1793
+ getGlobalState(): Promise<GlobalState>;
1794
+ getBondState(bondType: BondType, bondName: string): Promise<BondState>;
1184
1795
  /**
1185
- * Build set withdraw authority instruction
1796
+ * Get all bond states with total collected collateral
1186
1797
  */
1187
- buildSetWithdrawAuthorityInstruction(props: SetWithdrawAuthorityProps): Promise<_solana_web3_js.TransactionInstruction>;
1798
+ getAllBondStates(bondType: BondType): Promise<Array<[BondState, BondStateStats]>>;
1188
1799
  /**
1189
- * Fetch global state or throw if not found
1800
+ * Get session status for bond state
1190
1801
  */
1191
- getGlobalState(): Promise<GlobalState>;
1802
+ private getBondStateSessionStatus;
1803
+ /** Get all validator bonds for a given bond state */
1804
+ private getValidatorBondsByState;
1192
1805
  /**
1193
1806
  * Fetch validator bond data or null if not found
1807
+ * @param bondType
1808
+ * @param bondName
1194
1809
  * @param vote
1195
1810
  */
1196
- getValidatorBond(vote: PublicKeyInitData): Promise<ValidatorBond | null>;
1811
+ getValidatorBond(bondType: BondType, bondName: string, vote: PublicKeyInitData): Promise<ValidatorBond | null>;
1812
+ /**
1813
+ * Get bond collateral type
1814
+ */
1815
+ getBondCollateralType(bondType: BondType, bondName: string): Promise<CollateralType>;
1197
1816
  /**
1198
1817
  * Get validator bond account balance (in SOL)
1818
+ * @param bondType - Type of the bond
1819
+ * @param bondName - Name of the bond
1199
1820
  * @param vote - Vote account public key
1200
- * @return Balance in SOL
1821
+ * @return Balance in lamports
1201
1822
  */
1202
- getValidatorBondBalance(vote: PublicKeyInitData): Promise<number>;
1823
+ getValidatorBondBalance(bondType: BondType, bondName: string, vote: PublicKeyInitData): Promise<number>;
1203
1824
  /**
1204
- * Get transaction history for a specific validator bond account
1825
+ * Load stake pool account and cache it if not already cached
1826
+ * @private
1205
1827
  */
1206
- getHistory(vote: PublicKey, options?: {
1207
- cluster?: 'mainnet-beta' | 'testnet' | 'devnet';
1208
- limit?: number;
1209
- before?: string;
1210
- until?: string;
1211
- }): Promise<TransactionHistoryItem[]>;
1828
+ private loadStakePoolAccount;
1212
1829
  /**
1213
- * Get instruction discriminator from IDL
1214
- * @param instructionName
1215
- * @private
1830
+ * Manages the interaction with a stake pool, allowing deposits and withdrawals of SOL.
1216
1831
  */
1217
- private getInstructionDiscriminator;
1218
- private fetchSignaturesForValidator;
1219
- private fetchParsedTransactions;
1220
- private decodeInstructionData;
1832
+ stakePoolManager(props?: {
1833
+ user?: PublicKey;
1834
+ }): Promise<StakePoolManager>;
1835
+ /**
1836
+ * Ensures that a valid user is provided. If a user is not explicitly passed
1837
+ * in the properties, it defaults to the provider's public key.
1838
+ * Throws an error if no user is available.
1839
+ */
1840
+ private ensureUser;
1841
+ private lamports;
1221
1842
  }
1222
1843
 
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 };
1844
+ 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 };