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