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