@jpool/bond-sdk 0.9.0-next.2 → 0.9.0-next.4

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