@zebec-network/zebec-stake-sdk 1.0.3 → 1.0.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/artifacts/zebec_stake_v1.d.ts +46 -1
- package/dist/artifacts/zebec_stake_v1.json +687 -45
- package/dist/constants.js +2 -2
- package/dist/service.d.ts +10 -1
- package/dist/service.js +60 -11
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* IDL can be found at `target/idl/zebec_stake.json`.
|
|
6
6
|
*/
|
|
7
7
|
export type ZebecStake = {
|
|
8
|
-
address: "
|
|
8
|
+
address: "zSTKzGLiN6T6EVzhBiL6sjULXMahDavAS2p4R62afGv";
|
|
9
9
|
metadata: {
|
|
10
10
|
name: "zebecStake";
|
|
11
11
|
version: "0.1.0";
|
|
@@ -954,6 +954,20 @@ export type ZebecStake = {
|
|
|
954
954
|
},
|
|
955
955
|
{
|
|
956
956
|
name: "lockup";
|
|
957
|
+
writable: true;
|
|
958
|
+
pda: {
|
|
959
|
+
seeds: [
|
|
960
|
+
{
|
|
961
|
+
kind: "const";
|
|
962
|
+
value: [122, 101, 98, 101, 99, 95, 108, 111, 99, 107, 117, 112];
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
kind: "account";
|
|
966
|
+
path: "lockup.stake_info.name";
|
|
967
|
+
account: "lockup";
|
|
968
|
+
}
|
|
969
|
+
];
|
|
970
|
+
};
|
|
957
971
|
},
|
|
958
972
|
{
|
|
959
973
|
name: "userNonce";
|
|
@@ -1088,6 +1102,21 @@ export type ZebecStake = {
|
|
|
1088
1102
|
code: 6011;
|
|
1089
1103
|
name: "rewardIsZero";
|
|
1090
1104
|
msg: "Reward Is Zero";
|
|
1105
|
+
},
|
|
1106
|
+
{
|
|
1107
|
+
code: 6012;
|
|
1108
|
+
name: "stakeAlreadyClaimed";
|
|
1109
|
+
msg: "Stake Already Claimed";
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
code: 6013;
|
|
1113
|
+
name: "stakeNotClaimable";
|
|
1114
|
+
msg: "Stake Not Claimable";
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
code: 6014;
|
|
1118
|
+
name: "minimumStakeNotMet";
|
|
1119
|
+
msg: "minimum Stake Not Met";
|
|
1091
1120
|
}
|
|
1092
1121
|
];
|
|
1093
1122
|
types: [
|
|
@@ -1140,6 +1169,10 @@ export type ZebecStake = {
|
|
|
1140
1169
|
name: "feeVault";
|
|
1141
1170
|
type: "pubkey";
|
|
1142
1171
|
},
|
|
1172
|
+
{
|
|
1173
|
+
name: "minimumStake";
|
|
1174
|
+
type: "u64";
|
|
1175
|
+
},
|
|
1143
1176
|
{
|
|
1144
1177
|
name: "durationMap";
|
|
1145
1178
|
type: {
|
|
@@ -1218,6 +1251,10 @@ export type ZebecStake = {
|
|
|
1218
1251
|
name: "creator";
|
|
1219
1252
|
type: "pubkey";
|
|
1220
1253
|
},
|
|
1254
|
+
{
|
|
1255
|
+
name: "minimumStake";
|
|
1256
|
+
type: "u64";
|
|
1257
|
+
},
|
|
1221
1258
|
{
|
|
1222
1259
|
name: "durationMap";
|
|
1223
1260
|
type: {
|
|
@@ -1307,6 +1344,14 @@ export type ZebecStake = {
|
|
|
1307
1344
|
{
|
|
1308
1345
|
name: "lockPeriod";
|
|
1309
1346
|
type: "i64";
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
name: "staker";
|
|
1350
|
+
type: "pubkey";
|
|
1351
|
+
},
|
|
1352
|
+
{
|
|
1353
|
+
name: "lockup";
|
|
1354
|
+
type: "pubkey";
|
|
1310
1355
|
}
|
|
1311
1356
|
];
|
|
1312
1357
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"address": "
|
|
2
|
+
"address": "zSTKzGLiN6T6EVzhBiL6sjULXMahDavAS2p4R62afGv",
|
|
3
3
|
"metadata": {
|
|
4
4
|
"name": "zebec_stake",
|
|
5
5
|
"version": "0.1.0",
|
|
@@ -9,7 +9,16 @@
|
|
|
9
9
|
"instructions": [
|
|
10
10
|
{
|
|
11
11
|
"name": "init_lockup",
|
|
12
|
-
"discriminator": [
|
|
12
|
+
"discriminator": [
|
|
13
|
+
6,
|
|
14
|
+
96,
|
|
15
|
+
207,
|
|
16
|
+
185,
|
|
17
|
+
103,
|
|
18
|
+
62,
|
|
19
|
+
239,
|
|
20
|
+
168
|
|
21
|
+
],
|
|
13
22
|
"accounts": [
|
|
14
23
|
{
|
|
15
24
|
"name": "creator",
|
|
@@ -23,7 +32,20 @@
|
|
|
23
32
|
"seeds": [
|
|
24
33
|
{
|
|
25
34
|
"kind": "const",
|
|
26
|
-
"value": [
|
|
35
|
+
"value": [
|
|
36
|
+
122,
|
|
37
|
+
101,
|
|
38
|
+
98,
|
|
39
|
+
101,
|
|
40
|
+
99,
|
|
41
|
+
95,
|
|
42
|
+
108,
|
|
43
|
+
111,
|
|
44
|
+
99,
|
|
45
|
+
107,
|
|
46
|
+
117,
|
|
47
|
+
112
|
|
48
|
+
]
|
|
27
49
|
},
|
|
28
50
|
{
|
|
29
51
|
"kind": "arg",
|
|
@@ -39,7 +61,19 @@
|
|
|
39
61
|
"seeds": [
|
|
40
62
|
{
|
|
41
63
|
"kind": "const",
|
|
42
|
-
"value": [
|
|
64
|
+
"value": [
|
|
65
|
+
115,
|
|
66
|
+
116,
|
|
67
|
+
97,
|
|
68
|
+
107,
|
|
69
|
+
101,
|
|
70
|
+
95,
|
|
71
|
+
118,
|
|
72
|
+
97,
|
|
73
|
+
117,
|
|
74
|
+
108,
|
|
75
|
+
116
|
|
76
|
+
]
|
|
43
77
|
},
|
|
44
78
|
{
|
|
45
79
|
"kind": "account",
|
|
@@ -55,7 +89,20 @@
|
|
|
55
89
|
"seeds": [
|
|
56
90
|
{
|
|
57
91
|
"kind": "const",
|
|
58
|
-
"value": [
|
|
92
|
+
"value": [
|
|
93
|
+
114,
|
|
94
|
+
101,
|
|
95
|
+
119,
|
|
96
|
+
97,
|
|
97
|
+
114,
|
|
98
|
+
100,
|
|
99
|
+
95,
|
|
100
|
+
118,
|
|
101
|
+
97,
|
|
102
|
+
117,
|
|
103
|
+
108,
|
|
104
|
+
116
|
|
105
|
+
]
|
|
59
106
|
},
|
|
60
107
|
{
|
|
61
108
|
"kind": "account",
|
|
@@ -96,7 +143,16 @@
|
|
|
96
143
|
},
|
|
97
144
|
{
|
|
98
145
|
"name": "stake_zbcn",
|
|
99
|
-
"discriminator": [
|
|
146
|
+
"discriminator": [
|
|
147
|
+
93,
|
|
148
|
+
162,
|
|
149
|
+
156,
|
|
150
|
+
54,
|
|
151
|
+
43,
|
|
152
|
+
11,
|
|
153
|
+
15,
|
|
154
|
+
122
|
|
155
|
+
],
|
|
100
156
|
"accounts": [
|
|
101
157
|
{
|
|
102
158
|
"name": "staker",
|
|
@@ -110,7 +166,20 @@
|
|
|
110
166
|
"seeds": [
|
|
111
167
|
{
|
|
112
168
|
"kind": "const",
|
|
113
|
-
"value": [
|
|
169
|
+
"value": [
|
|
170
|
+
122,
|
|
171
|
+
101,
|
|
172
|
+
98,
|
|
173
|
+
101,
|
|
174
|
+
99,
|
|
175
|
+
95,
|
|
176
|
+
108,
|
|
177
|
+
111,
|
|
178
|
+
99,
|
|
179
|
+
107,
|
|
180
|
+
117,
|
|
181
|
+
112
|
|
182
|
+
]
|
|
114
183
|
},
|
|
115
184
|
{
|
|
116
185
|
"kind": "account",
|
|
@@ -171,8 +240,38 @@
|
|
|
171
240
|
{
|
|
172
241
|
"kind": "const",
|
|
173
242
|
"value": [
|
|
174
|
-
6,
|
|
175
|
-
|
|
243
|
+
6,
|
|
244
|
+
221,
|
|
245
|
+
246,
|
|
246
|
+
225,
|
|
247
|
+
215,
|
|
248
|
+
101,
|
|
249
|
+
161,
|
|
250
|
+
147,
|
|
251
|
+
217,
|
|
252
|
+
203,
|
|
253
|
+
225,
|
|
254
|
+
70,
|
|
255
|
+
206,
|
|
256
|
+
235,
|
|
257
|
+
121,
|
|
258
|
+
172,
|
|
259
|
+
28,
|
|
260
|
+
180,
|
|
261
|
+
133,
|
|
262
|
+
237,
|
|
263
|
+
95,
|
|
264
|
+
91,
|
|
265
|
+
55,
|
|
266
|
+
145,
|
|
267
|
+
58,
|
|
268
|
+
140,
|
|
269
|
+
245,
|
|
270
|
+
133,
|
|
271
|
+
126,
|
|
272
|
+
255,
|
|
273
|
+
0,
|
|
274
|
+
169
|
|
176
275
|
]
|
|
177
276
|
},
|
|
178
277
|
{
|
|
@@ -183,8 +282,38 @@
|
|
|
183
282
|
"program": {
|
|
184
283
|
"kind": "const",
|
|
185
284
|
"value": [
|
|
186
|
-
140,
|
|
187
|
-
|
|
285
|
+
140,
|
|
286
|
+
151,
|
|
287
|
+
37,
|
|
288
|
+
143,
|
|
289
|
+
78,
|
|
290
|
+
36,
|
|
291
|
+
137,
|
|
292
|
+
241,
|
|
293
|
+
187,
|
|
294
|
+
61,
|
|
295
|
+
16,
|
|
296
|
+
41,
|
|
297
|
+
20,
|
|
298
|
+
142,
|
|
299
|
+
13,
|
|
300
|
+
131,
|
|
301
|
+
11,
|
|
302
|
+
90,
|
|
303
|
+
19,
|
|
304
|
+
153,
|
|
305
|
+
218,
|
|
306
|
+
255,
|
|
307
|
+
16,
|
|
308
|
+
132,
|
|
309
|
+
4,
|
|
310
|
+
142,
|
|
311
|
+
123,
|
|
312
|
+
216,
|
|
313
|
+
219,
|
|
314
|
+
233,
|
|
315
|
+
248,
|
|
316
|
+
89
|
|
188
317
|
]
|
|
189
318
|
}
|
|
190
319
|
}
|
|
@@ -196,7 +325,19 @@
|
|
|
196
325
|
"seeds": [
|
|
197
326
|
{
|
|
198
327
|
"kind": "const",
|
|
199
|
-
"value": [
|
|
328
|
+
"value": [
|
|
329
|
+
115,
|
|
330
|
+
116,
|
|
331
|
+
97,
|
|
332
|
+
107,
|
|
333
|
+
101,
|
|
334
|
+
95,
|
|
335
|
+
118,
|
|
336
|
+
97,
|
|
337
|
+
117,
|
|
338
|
+
108,
|
|
339
|
+
116
|
|
340
|
+
]
|
|
200
341
|
},
|
|
201
342
|
{
|
|
202
343
|
"kind": "account",
|
|
@@ -217,8 +358,38 @@
|
|
|
217
358
|
{
|
|
218
359
|
"kind": "const",
|
|
219
360
|
"value": [
|
|
220
|
-
6,
|
|
221
|
-
|
|
361
|
+
6,
|
|
362
|
+
221,
|
|
363
|
+
246,
|
|
364
|
+
225,
|
|
365
|
+
215,
|
|
366
|
+
101,
|
|
367
|
+
161,
|
|
368
|
+
147,
|
|
369
|
+
217,
|
|
370
|
+
203,
|
|
371
|
+
225,
|
|
372
|
+
70,
|
|
373
|
+
206,
|
|
374
|
+
235,
|
|
375
|
+
121,
|
|
376
|
+
172,
|
|
377
|
+
28,
|
|
378
|
+
180,
|
|
379
|
+
133,
|
|
380
|
+
237,
|
|
381
|
+
95,
|
|
382
|
+
91,
|
|
383
|
+
55,
|
|
384
|
+
145,
|
|
385
|
+
58,
|
|
386
|
+
140,
|
|
387
|
+
245,
|
|
388
|
+
133,
|
|
389
|
+
126,
|
|
390
|
+
255,
|
|
391
|
+
0,
|
|
392
|
+
169
|
|
222
393
|
]
|
|
223
394
|
},
|
|
224
395
|
{
|
|
@@ -229,8 +400,38 @@
|
|
|
229
400
|
"program": {
|
|
230
401
|
"kind": "const",
|
|
231
402
|
"value": [
|
|
232
|
-
140,
|
|
233
|
-
|
|
403
|
+
140,
|
|
404
|
+
151,
|
|
405
|
+
37,
|
|
406
|
+
143,
|
|
407
|
+
78,
|
|
408
|
+
36,
|
|
409
|
+
137,
|
|
410
|
+
241,
|
|
411
|
+
187,
|
|
412
|
+
61,
|
|
413
|
+
16,
|
|
414
|
+
41,
|
|
415
|
+
20,
|
|
416
|
+
142,
|
|
417
|
+
13,
|
|
418
|
+
131,
|
|
419
|
+
11,
|
|
420
|
+
90,
|
|
421
|
+
19,
|
|
422
|
+
153,
|
|
423
|
+
218,
|
|
424
|
+
255,
|
|
425
|
+
16,
|
|
426
|
+
132,
|
|
427
|
+
4,
|
|
428
|
+
142,
|
|
429
|
+
123,
|
|
430
|
+
216,
|
|
431
|
+
219,
|
|
432
|
+
233,
|
|
433
|
+
248,
|
|
434
|
+
89
|
|
234
435
|
]
|
|
235
436
|
}
|
|
236
437
|
}
|
|
@@ -261,7 +462,16 @@
|
|
|
261
462
|
},
|
|
262
463
|
{
|
|
263
464
|
"name": "unstake_zbcn",
|
|
264
|
-
"discriminator": [
|
|
465
|
+
"discriminator": [
|
|
466
|
+
90,
|
|
467
|
+
202,
|
|
468
|
+
101,
|
|
469
|
+
187,
|
|
470
|
+
218,
|
|
471
|
+
99,
|
|
472
|
+
244,
|
|
473
|
+
1
|
|
474
|
+
],
|
|
265
475
|
"accounts": [
|
|
266
476
|
{
|
|
267
477
|
"name": "staker",
|
|
@@ -275,7 +485,20 @@
|
|
|
275
485
|
"seeds": [
|
|
276
486
|
{
|
|
277
487
|
"kind": "const",
|
|
278
|
-
"value": [
|
|
488
|
+
"value": [
|
|
489
|
+
122,
|
|
490
|
+
101,
|
|
491
|
+
98,
|
|
492
|
+
101,
|
|
493
|
+
99,
|
|
494
|
+
95,
|
|
495
|
+
108,
|
|
496
|
+
111,
|
|
497
|
+
99,
|
|
498
|
+
107,
|
|
499
|
+
117,
|
|
500
|
+
112
|
|
501
|
+
]
|
|
279
502
|
},
|
|
280
503
|
{
|
|
281
504
|
"kind": "account",
|
|
@@ -323,8 +546,38 @@
|
|
|
323
546
|
{
|
|
324
547
|
"kind": "const",
|
|
325
548
|
"value": [
|
|
326
|
-
6,
|
|
327
|
-
|
|
549
|
+
6,
|
|
550
|
+
221,
|
|
551
|
+
246,
|
|
552
|
+
225,
|
|
553
|
+
215,
|
|
554
|
+
101,
|
|
555
|
+
161,
|
|
556
|
+
147,
|
|
557
|
+
217,
|
|
558
|
+
203,
|
|
559
|
+
225,
|
|
560
|
+
70,
|
|
561
|
+
206,
|
|
562
|
+
235,
|
|
563
|
+
121,
|
|
564
|
+
172,
|
|
565
|
+
28,
|
|
566
|
+
180,
|
|
567
|
+
133,
|
|
568
|
+
237,
|
|
569
|
+
95,
|
|
570
|
+
91,
|
|
571
|
+
55,
|
|
572
|
+
145,
|
|
573
|
+
58,
|
|
574
|
+
140,
|
|
575
|
+
245,
|
|
576
|
+
133,
|
|
577
|
+
126,
|
|
578
|
+
255,
|
|
579
|
+
0,
|
|
580
|
+
169
|
|
328
581
|
]
|
|
329
582
|
},
|
|
330
583
|
{
|
|
@@ -335,8 +588,38 @@
|
|
|
335
588
|
"program": {
|
|
336
589
|
"kind": "const",
|
|
337
590
|
"value": [
|
|
338
|
-
140,
|
|
339
|
-
|
|
591
|
+
140,
|
|
592
|
+
151,
|
|
593
|
+
37,
|
|
594
|
+
143,
|
|
595
|
+
78,
|
|
596
|
+
36,
|
|
597
|
+
137,
|
|
598
|
+
241,
|
|
599
|
+
187,
|
|
600
|
+
61,
|
|
601
|
+
16,
|
|
602
|
+
41,
|
|
603
|
+
20,
|
|
604
|
+
142,
|
|
605
|
+
13,
|
|
606
|
+
131,
|
|
607
|
+
11,
|
|
608
|
+
90,
|
|
609
|
+
19,
|
|
610
|
+
153,
|
|
611
|
+
218,
|
|
612
|
+
255,
|
|
613
|
+
16,
|
|
614
|
+
132,
|
|
615
|
+
4,
|
|
616
|
+
142,
|
|
617
|
+
123,
|
|
618
|
+
216,
|
|
619
|
+
219,
|
|
620
|
+
233,
|
|
621
|
+
248,
|
|
622
|
+
89
|
|
340
623
|
]
|
|
341
624
|
}
|
|
342
625
|
}
|
|
@@ -353,8 +636,38 @@
|
|
|
353
636
|
{
|
|
354
637
|
"kind": "const",
|
|
355
638
|
"value": [
|
|
356
|
-
6,
|
|
357
|
-
|
|
639
|
+
6,
|
|
640
|
+
221,
|
|
641
|
+
246,
|
|
642
|
+
225,
|
|
643
|
+
215,
|
|
644
|
+
101,
|
|
645
|
+
161,
|
|
646
|
+
147,
|
|
647
|
+
217,
|
|
648
|
+
203,
|
|
649
|
+
225,
|
|
650
|
+
70,
|
|
651
|
+
206,
|
|
652
|
+
235,
|
|
653
|
+
121,
|
|
654
|
+
172,
|
|
655
|
+
28,
|
|
656
|
+
180,
|
|
657
|
+
133,
|
|
658
|
+
237,
|
|
659
|
+
95,
|
|
660
|
+
91,
|
|
661
|
+
55,
|
|
662
|
+
145,
|
|
663
|
+
58,
|
|
664
|
+
140,
|
|
665
|
+
245,
|
|
666
|
+
133,
|
|
667
|
+
126,
|
|
668
|
+
255,
|
|
669
|
+
0,
|
|
670
|
+
169
|
|
358
671
|
]
|
|
359
672
|
},
|
|
360
673
|
{
|
|
@@ -365,8 +678,38 @@
|
|
|
365
678
|
"program": {
|
|
366
679
|
"kind": "const",
|
|
367
680
|
"value": [
|
|
368
|
-
140,
|
|
369
|
-
|
|
681
|
+
140,
|
|
682
|
+
151,
|
|
683
|
+
37,
|
|
684
|
+
143,
|
|
685
|
+
78,
|
|
686
|
+
36,
|
|
687
|
+
137,
|
|
688
|
+
241,
|
|
689
|
+
187,
|
|
690
|
+
61,
|
|
691
|
+
16,
|
|
692
|
+
41,
|
|
693
|
+
20,
|
|
694
|
+
142,
|
|
695
|
+
13,
|
|
696
|
+
131,
|
|
697
|
+
11,
|
|
698
|
+
90,
|
|
699
|
+
19,
|
|
700
|
+
153,
|
|
701
|
+
218,
|
|
702
|
+
255,
|
|
703
|
+
16,
|
|
704
|
+
132,
|
|
705
|
+
4,
|
|
706
|
+
142,
|
|
707
|
+
123,
|
|
708
|
+
216,
|
|
709
|
+
219,
|
|
710
|
+
233,
|
|
711
|
+
248,
|
|
712
|
+
89
|
|
370
713
|
]
|
|
371
714
|
}
|
|
372
715
|
}
|
|
@@ -378,7 +721,19 @@
|
|
|
378
721
|
"seeds": [
|
|
379
722
|
{
|
|
380
723
|
"kind": "const",
|
|
381
|
-
"value": [
|
|
724
|
+
"value": [
|
|
725
|
+
115,
|
|
726
|
+
116,
|
|
727
|
+
97,
|
|
728
|
+
107,
|
|
729
|
+
101,
|
|
730
|
+
95,
|
|
731
|
+
118,
|
|
732
|
+
97,
|
|
733
|
+
117,
|
|
734
|
+
108,
|
|
735
|
+
116
|
|
736
|
+
]
|
|
382
737
|
},
|
|
383
738
|
{
|
|
384
739
|
"kind": "account",
|
|
@@ -394,7 +749,20 @@
|
|
|
394
749
|
"seeds": [
|
|
395
750
|
{
|
|
396
751
|
"kind": "const",
|
|
397
|
-
"value": [
|
|
752
|
+
"value": [
|
|
753
|
+
114,
|
|
754
|
+
101,
|
|
755
|
+
119,
|
|
756
|
+
97,
|
|
757
|
+
114,
|
|
758
|
+
100,
|
|
759
|
+
95,
|
|
760
|
+
118,
|
|
761
|
+
97,
|
|
762
|
+
117,
|
|
763
|
+
108,
|
|
764
|
+
116
|
|
765
|
+
]
|
|
398
766
|
},
|
|
399
767
|
{
|
|
400
768
|
"kind": "account",
|
|
@@ -415,8 +783,38 @@
|
|
|
415
783
|
{
|
|
416
784
|
"kind": "const",
|
|
417
785
|
"value": [
|
|
418
|
-
6,
|
|
419
|
-
|
|
786
|
+
6,
|
|
787
|
+
221,
|
|
788
|
+
246,
|
|
789
|
+
225,
|
|
790
|
+
215,
|
|
791
|
+
101,
|
|
792
|
+
161,
|
|
793
|
+
147,
|
|
794
|
+
217,
|
|
795
|
+
203,
|
|
796
|
+
225,
|
|
797
|
+
70,
|
|
798
|
+
206,
|
|
799
|
+
235,
|
|
800
|
+
121,
|
|
801
|
+
172,
|
|
802
|
+
28,
|
|
803
|
+
180,
|
|
804
|
+
133,
|
|
805
|
+
237,
|
|
806
|
+
95,
|
|
807
|
+
91,
|
|
808
|
+
55,
|
|
809
|
+
145,
|
|
810
|
+
58,
|
|
811
|
+
140,
|
|
812
|
+
245,
|
|
813
|
+
133,
|
|
814
|
+
126,
|
|
815
|
+
255,
|
|
816
|
+
0,
|
|
817
|
+
169
|
|
420
818
|
]
|
|
421
819
|
},
|
|
422
820
|
{
|
|
@@ -427,8 +825,38 @@
|
|
|
427
825
|
"program": {
|
|
428
826
|
"kind": "const",
|
|
429
827
|
"value": [
|
|
430
|
-
140,
|
|
431
|
-
|
|
828
|
+
140,
|
|
829
|
+
151,
|
|
830
|
+
37,
|
|
831
|
+
143,
|
|
832
|
+
78,
|
|
833
|
+
36,
|
|
834
|
+
137,
|
|
835
|
+
241,
|
|
836
|
+
187,
|
|
837
|
+
61,
|
|
838
|
+
16,
|
|
839
|
+
41,
|
|
840
|
+
20,
|
|
841
|
+
142,
|
|
842
|
+
13,
|
|
843
|
+
131,
|
|
844
|
+
11,
|
|
845
|
+
90,
|
|
846
|
+
19,
|
|
847
|
+
153,
|
|
848
|
+
218,
|
|
849
|
+
255,
|
|
850
|
+
16,
|
|
851
|
+
132,
|
|
852
|
+
4,
|
|
853
|
+
142,
|
|
854
|
+
123,
|
|
855
|
+
216,
|
|
856
|
+
219,
|
|
857
|
+
233,
|
|
858
|
+
248,
|
|
859
|
+
89
|
|
432
860
|
]
|
|
433
861
|
}
|
|
434
862
|
}
|
|
@@ -445,8 +873,38 @@
|
|
|
445
873
|
{
|
|
446
874
|
"kind": "const",
|
|
447
875
|
"value": [
|
|
448
|
-
6,
|
|
449
|
-
|
|
876
|
+
6,
|
|
877
|
+
221,
|
|
878
|
+
246,
|
|
879
|
+
225,
|
|
880
|
+
215,
|
|
881
|
+
101,
|
|
882
|
+
161,
|
|
883
|
+
147,
|
|
884
|
+
217,
|
|
885
|
+
203,
|
|
886
|
+
225,
|
|
887
|
+
70,
|
|
888
|
+
206,
|
|
889
|
+
235,
|
|
890
|
+
121,
|
|
891
|
+
172,
|
|
892
|
+
28,
|
|
893
|
+
180,
|
|
894
|
+
133,
|
|
895
|
+
237,
|
|
896
|
+
95,
|
|
897
|
+
91,
|
|
898
|
+
55,
|
|
899
|
+
145,
|
|
900
|
+
58,
|
|
901
|
+
140,
|
|
902
|
+
245,
|
|
903
|
+
133,
|
|
904
|
+
126,
|
|
905
|
+
255,
|
|
906
|
+
0,
|
|
907
|
+
169
|
|
450
908
|
]
|
|
451
909
|
},
|
|
452
910
|
{
|
|
@@ -457,8 +915,38 @@
|
|
|
457
915
|
"program": {
|
|
458
916
|
"kind": "const",
|
|
459
917
|
"value": [
|
|
460
|
-
140,
|
|
461
|
-
|
|
918
|
+
140,
|
|
919
|
+
151,
|
|
920
|
+
37,
|
|
921
|
+
143,
|
|
922
|
+
78,
|
|
923
|
+
36,
|
|
924
|
+
137,
|
|
925
|
+
241,
|
|
926
|
+
187,
|
|
927
|
+
61,
|
|
928
|
+
16,
|
|
929
|
+
41,
|
|
930
|
+
20,
|
|
931
|
+
142,
|
|
932
|
+
13,
|
|
933
|
+
131,
|
|
934
|
+
11,
|
|
935
|
+
90,
|
|
936
|
+
19,
|
|
937
|
+
153,
|
|
938
|
+
218,
|
|
939
|
+
255,
|
|
940
|
+
16,
|
|
941
|
+
132,
|
|
942
|
+
4,
|
|
943
|
+
142,
|
|
944
|
+
123,
|
|
945
|
+
216,
|
|
946
|
+
219,
|
|
947
|
+
233,
|
|
948
|
+
248,
|
|
949
|
+
89
|
|
462
950
|
]
|
|
463
951
|
}
|
|
464
952
|
}
|
|
@@ -479,8 +967,38 @@
|
|
|
479
967
|
{
|
|
480
968
|
"kind": "const",
|
|
481
969
|
"value": [
|
|
482
|
-
6,
|
|
483
|
-
|
|
970
|
+
6,
|
|
971
|
+
221,
|
|
972
|
+
246,
|
|
973
|
+
225,
|
|
974
|
+
215,
|
|
975
|
+
101,
|
|
976
|
+
161,
|
|
977
|
+
147,
|
|
978
|
+
217,
|
|
979
|
+
203,
|
|
980
|
+
225,
|
|
981
|
+
70,
|
|
982
|
+
206,
|
|
983
|
+
235,
|
|
984
|
+
121,
|
|
985
|
+
172,
|
|
986
|
+
28,
|
|
987
|
+
180,
|
|
988
|
+
133,
|
|
989
|
+
237,
|
|
990
|
+
95,
|
|
991
|
+
91,
|
|
992
|
+
55,
|
|
993
|
+
145,
|
|
994
|
+
58,
|
|
995
|
+
140,
|
|
996
|
+
245,
|
|
997
|
+
133,
|
|
998
|
+
126,
|
|
999
|
+
255,
|
|
1000
|
+
0,
|
|
1001
|
+
169
|
|
484
1002
|
]
|
|
485
1003
|
},
|
|
486
1004
|
{
|
|
@@ -491,8 +1009,38 @@
|
|
|
491
1009
|
"program": {
|
|
492
1010
|
"kind": "const",
|
|
493
1011
|
"value": [
|
|
494
|
-
140,
|
|
495
|
-
|
|
1012
|
+
140,
|
|
1013
|
+
151,
|
|
1014
|
+
37,
|
|
1015
|
+
143,
|
|
1016
|
+
78,
|
|
1017
|
+
36,
|
|
1018
|
+
137,
|
|
1019
|
+
241,
|
|
1020
|
+
187,
|
|
1021
|
+
61,
|
|
1022
|
+
16,
|
|
1023
|
+
41,
|
|
1024
|
+
20,
|
|
1025
|
+
142,
|
|
1026
|
+
13,
|
|
1027
|
+
131,
|
|
1028
|
+
11,
|
|
1029
|
+
90,
|
|
1030
|
+
19,
|
|
1031
|
+
153,
|
|
1032
|
+
218,
|
|
1033
|
+
255,
|
|
1034
|
+
16,
|
|
1035
|
+
132,
|
|
1036
|
+
4,
|
|
1037
|
+
142,
|
|
1038
|
+
123,
|
|
1039
|
+
216,
|
|
1040
|
+
219,
|
|
1041
|
+
233,
|
|
1042
|
+
248,
|
|
1043
|
+
89
|
|
496
1044
|
]
|
|
497
1045
|
}
|
|
498
1046
|
}
|
|
@@ -519,7 +1067,16 @@
|
|
|
519
1067
|
},
|
|
520
1068
|
{
|
|
521
1069
|
"name": "whitelist_staker",
|
|
522
|
-
"discriminator": [
|
|
1070
|
+
"discriminator": [
|
|
1071
|
+
13,
|
|
1072
|
+
211,
|
|
1073
|
+
22,
|
|
1074
|
+
179,
|
|
1075
|
+
35,
|
|
1076
|
+
177,
|
|
1077
|
+
63,
|
|
1078
|
+
155
|
|
1079
|
+
],
|
|
523
1080
|
"accounts": [
|
|
524
1081
|
{
|
|
525
1082
|
"name": "admin",
|
|
@@ -527,7 +1084,34 @@
|
|
|
527
1084
|
"signer": true
|
|
528
1085
|
},
|
|
529
1086
|
{
|
|
530
|
-
"name": "lockup"
|
|
1087
|
+
"name": "lockup",
|
|
1088
|
+
"writable": true,
|
|
1089
|
+
"pda": {
|
|
1090
|
+
"seeds": [
|
|
1091
|
+
{
|
|
1092
|
+
"kind": "const",
|
|
1093
|
+
"value": [
|
|
1094
|
+
122,
|
|
1095
|
+
101,
|
|
1096
|
+
98,
|
|
1097
|
+
101,
|
|
1098
|
+
99,
|
|
1099
|
+
95,
|
|
1100
|
+
108,
|
|
1101
|
+
111,
|
|
1102
|
+
99,
|
|
1103
|
+
107,
|
|
1104
|
+
117,
|
|
1105
|
+
112
|
|
1106
|
+
]
|
|
1107
|
+
},
|
|
1108
|
+
{
|
|
1109
|
+
"kind": "account",
|
|
1110
|
+
"path": "lockup.stake_info.name",
|
|
1111
|
+
"account": "Lockup"
|
|
1112
|
+
}
|
|
1113
|
+
]
|
|
1114
|
+
}
|
|
531
1115
|
},
|
|
532
1116
|
{
|
|
533
1117
|
"name": "user_nonce",
|
|
@@ -591,15 +1175,42 @@
|
|
|
591
1175
|
"accounts": [
|
|
592
1176
|
{
|
|
593
1177
|
"name": "Lockup",
|
|
594
|
-
"discriminator": [
|
|
1178
|
+
"discriminator": [
|
|
1179
|
+
1,
|
|
1180
|
+
45,
|
|
1181
|
+
32,
|
|
1182
|
+
32,
|
|
1183
|
+
57,
|
|
1184
|
+
81,
|
|
1185
|
+
88,
|
|
1186
|
+
67
|
|
1187
|
+
]
|
|
595
1188
|
},
|
|
596
1189
|
{
|
|
597
1190
|
"name": "UserNonce",
|
|
598
|
-
"discriminator": [
|
|
1191
|
+
"discriminator": [
|
|
1192
|
+
235,
|
|
1193
|
+
133,
|
|
1194
|
+
1,
|
|
1195
|
+
243,
|
|
1196
|
+
18,
|
|
1197
|
+
135,
|
|
1198
|
+
88,
|
|
1199
|
+
224
|
|
1200
|
+
]
|
|
599
1201
|
},
|
|
600
1202
|
{
|
|
601
1203
|
"name": "UserStakeData",
|
|
602
|
-
"discriminator": [
|
|
1204
|
+
"discriminator": [
|
|
1205
|
+
105,
|
|
1206
|
+
207,
|
|
1207
|
+
3,
|
|
1208
|
+
141,
|
|
1209
|
+
114,
|
|
1210
|
+
114,
|
|
1211
|
+
232,
|
|
1212
|
+
147
|
|
1213
|
+
]
|
|
603
1214
|
}
|
|
604
1215
|
],
|
|
605
1216
|
"errors": [
|
|
@@ -662,6 +1273,21 @@
|
|
|
662
1273
|
"code": 6011,
|
|
663
1274
|
"name": "RewardIsZero",
|
|
664
1275
|
"msg": "Reward Is Zero"
|
|
1276
|
+
},
|
|
1277
|
+
{
|
|
1278
|
+
"code": 6012,
|
|
1279
|
+
"name": "StakeAlreadyClaimed",
|
|
1280
|
+
"msg": "Stake Already Claimed"
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
"code": 6013,
|
|
1284
|
+
"name": "StakeNotClaimable",
|
|
1285
|
+
"msg": "Stake Not Claimable"
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
"code": 6014,
|
|
1289
|
+
"name": "MinimumStakeNotMet",
|
|
1290
|
+
"msg": "minimum Stake Not Met"
|
|
665
1291
|
}
|
|
666
1292
|
],
|
|
667
1293
|
"types": [
|
|
@@ -714,6 +1340,10 @@
|
|
|
714
1340
|
"name": "fee_vault",
|
|
715
1341
|
"type": "pubkey"
|
|
716
1342
|
},
|
|
1343
|
+
{
|
|
1344
|
+
"name": "minimum_stake",
|
|
1345
|
+
"type": "u64"
|
|
1346
|
+
},
|
|
717
1347
|
{
|
|
718
1348
|
"name": "duration_map",
|
|
719
1349
|
"type": {
|
|
@@ -792,6 +1422,10 @@
|
|
|
792
1422
|
"name": "creator",
|
|
793
1423
|
"type": "pubkey"
|
|
794
1424
|
},
|
|
1425
|
+
{
|
|
1426
|
+
"name": "minimum_stake",
|
|
1427
|
+
"type": "u64"
|
|
1428
|
+
},
|
|
795
1429
|
{
|
|
796
1430
|
"name": "duration_map",
|
|
797
1431
|
"type": {
|
|
@@ -881,6 +1515,14 @@
|
|
|
881
1515
|
{
|
|
882
1516
|
"name": "lock_period",
|
|
883
1517
|
"type": "i64"
|
|
1518
|
+
},
|
|
1519
|
+
{
|
|
1520
|
+
"name": "staker",
|
|
1521
|
+
"type": "pubkey"
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
"name": "lockup",
|
|
1525
|
+
"type": "pubkey"
|
|
884
1526
|
}
|
|
885
1527
|
]
|
|
886
1528
|
}
|
package/dist/constants.js
CHANGED
|
@@ -16,9 +16,9 @@ exports.isSdkEnvDev = SDK_ENV === "development";
|
|
|
16
16
|
*/
|
|
17
17
|
exports.ZEBEC_STAKE_PROGRAM = {
|
|
18
18
|
/** Mainnet Program Id */
|
|
19
|
-
mainnet: "
|
|
19
|
+
mainnet: "zSTKzGLiN6T6EVzhBiL6sjULXMahDavAS2p4R62afGv",
|
|
20
20
|
/** Devnet Program Id */
|
|
21
|
-
devnet: "
|
|
21
|
+
devnet: "zSTKzGLiN6T6EVzhBiL6sjULXMahDavAS2p4R62afGv",
|
|
22
22
|
};
|
|
23
23
|
exports.ZBCN = new web3_js_1.PublicKey("ZBCNpuD7YMXzTHB2fhGkGi78MNsHGLRXUhRewNRm9RU");
|
|
24
24
|
/** BigNumber Object for 10 */
|
package/dist/service.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export declare class StakeService {
|
|
|
54
54
|
fee: Numeric;
|
|
55
55
|
feeVault: Address;
|
|
56
56
|
rewardSchemes: RewardScheme[];
|
|
57
|
+
minimumStake: Numeric;
|
|
57
58
|
}): Promise<TransactionPayload>;
|
|
58
59
|
stake(params: {
|
|
59
60
|
lockupName: string;
|
|
@@ -70,15 +71,17 @@ export declare class StakeService {
|
|
|
70
71
|
getLockupInfo(lockupAddress: Address): Promise<LockupInfo | null>;
|
|
71
72
|
getStakeInfo(stakeAddress: Address, lockupAddress: Address): Promise<StakeInfo | null>;
|
|
72
73
|
getUserNonceInfo(userNonceAddress: Address): Promise<UserNonceInfo | null>;
|
|
73
|
-
|
|
74
|
+
getAllStakesInfo(userAdress: Address, lockupAddress: Address): Promise<(StakeInfo & {
|
|
74
75
|
hash: string;
|
|
75
76
|
})[]>;
|
|
77
|
+
getTotalStakeCount(lockupAddress: Address): Promise<number>;
|
|
76
78
|
}
|
|
77
79
|
export type InitLockupInstructionData = {
|
|
78
80
|
rewardSchemes: ParsedRewardScheme[];
|
|
79
81
|
fee: BN;
|
|
80
82
|
feeVault: PublicKey;
|
|
81
83
|
name: string;
|
|
84
|
+
minimumStake: BN;
|
|
82
85
|
};
|
|
83
86
|
export type ParsedRewardScheme = {
|
|
84
87
|
duration: BN;
|
|
@@ -95,6 +98,7 @@ export type StakeInstructionData = {
|
|
|
95
98
|
nonce: BN;
|
|
96
99
|
};
|
|
97
100
|
export type LockupInfo = {
|
|
101
|
+
address: string;
|
|
98
102
|
feeInfo: {
|
|
99
103
|
fee: string;
|
|
100
104
|
feeVault: string;
|
|
@@ -110,17 +114,22 @@ export type LockupInfo = {
|
|
|
110
114
|
name: string;
|
|
111
115
|
creator: string;
|
|
112
116
|
rewardSchemes: RewardScheme[];
|
|
117
|
+
minimumStake: string;
|
|
113
118
|
};
|
|
114
119
|
};
|
|
115
120
|
export type StakeInfo = {
|
|
121
|
+
address: string;
|
|
116
122
|
nonce: bigint;
|
|
117
123
|
createdTime: number;
|
|
118
124
|
stakedAmount: string;
|
|
119
125
|
rewardAmount: string;
|
|
120
126
|
stakeClaimed: boolean;
|
|
121
127
|
lockPeriod: number;
|
|
128
|
+
staker: string;
|
|
129
|
+
lockup: string;
|
|
122
130
|
};
|
|
123
131
|
export type UserNonceInfo = {
|
|
132
|
+
address: string;
|
|
124
133
|
nonce: bigint;
|
|
125
134
|
};
|
|
126
135
|
export type StakeInfoWithHash = StakeInfo & {
|
package/dist/service.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.StakeService = exports.StakeServiceBuilder = void 0;
|
|
7
|
+
const assert_1 = __importDefault(require("assert"));
|
|
4
8
|
const bignumber_js_1 = require("bignumber.js");
|
|
5
9
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
6
10
|
const web3_js_1 = require("@solana/web3.js");
|
|
@@ -129,6 +133,7 @@ class StakeService {
|
|
|
129
133
|
durationMap: data.rewardSchemes,
|
|
130
134
|
feeVault: data.feeVault,
|
|
131
135
|
name: data.name,
|
|
136
|
+
minimumStake: data.minimumStake,
|
|
132
137
|
})
|
|
133
138
|
.accountsPartial({
|
|
134
139
|
creator,
|
|
@@ -171,6 +176,7 @@ class StakeService {
|
|
|
171
176
|
const rewardToken = (0, anchor_1.translateAddress)(params.rewardToken);
|
|
172
177
|
const feeVault = (0, anchor_1.translateAddress)(params.feeVault);
|
|
173
178
|
const stakeTokenDecimals = await (0, solana_common_1.getMintDecimals)(this.provider.connection, stakeToken);
|
|
179
|
+
const UNITS_PER_STAKE_TOKEN = constants_1.TEN_BIGNUM.pow(stakeTokenDecimals);
|
|
174
180
|
const rewardSchemes = params.rewardSchemes.map((value) => {
|
|
175
181
|
return {
|
|
176
182
|
duration: new anchor_1.BN(value.duration),
|
|
@@ -180,12 +186,14 @@ class StakeService {
|
|
|
180
186
|
const lockup = (0, pda_1.deriveLockupAddress)(params.name, this.program.programId);
|
|
181
187
|
const rewardVault = (0, pda_1.deriveRewardVaultAddress)(lockup, this.program.programId);
|
|
182
188
|
const stakeVault = (0, pda_1.deriveStakeVaultAddress)(lockup, this.program.programId);
|
|
183
|
-
const fee = new anchor_1.BN((0, bignumber_js_1.BigNumber)(params.fee).times(
|
|
189
|
+
const fee = new anchor_1.BN((0, bignumber_js_1.BigNumber)(params.fee).times(UNITS_PER_STAKE_TOKEN).toFixed(0));
|
|
190
|
+
const minimumStake = new anchor_1.BN((0, bignumber_js_1.BigNumber)(params.minimumStake).times(UNITS_PER_STAKE_TOKEN).toFixed(0));
|
|
184
191
|
const instruction = await this.getInitLockupInstruction(creator, lockup, stakeToken, rewardToken, rewardVault, stakeVault, {
|
|
185
192
|
fee,
|
|
186
193
|
feeVault: feeVault,
|
|
187
194
|
name: params.name,
|
|
188
195
|
rewardSchemes,
|
|
196
|
+
minimumStake,
|
|
189
197
|
});
|
|
190
198
|
return this._createPayload(creator, [instruction]);
|
|
191
199
|
}
|
|
@@ -251,6 +259,7 @@ class StakeService {
|
|
|
251
259
|
const stakeTokenDecimals = await (0, solana_common_1.getMintDecimals)(this.provider.connection, stakeTokenAddress);
|
|
252
260
|
const UNITS_PER_STAKE_TOKEN = constants_1.TEN_BIGNUM.pow(stakeTokenDecimals);
|
|
253
261
|
return {
|
|
262
|
+
address: lockupAddress.toString(),
|
|
254
263
|
feeInfo: {
|
|
255
264
|
fee: (0, bignumber_js_1.BigNumber)(lockupAccount.feeInfo.fee.toString()).div(UNITS_PER_STAKE_TOKEN).toFixed(),
|
|
256
265
|
feeVault: lockupAccount.feeInfo.feeVault.toString(),
|
|
@@ -269,6 +278,7 @@ class StakeService {
|
|
|
269
278
|
duration: value.duration.toNumber(),
|
|
270
279
|
rewardRate: (0, core_utils_1.bpsToPercent)(value.reward.toString()),
|
|
271
280
|
})),
|
|
281
|
+
minimumStake: (0, bignumber_js_1.BigNumber)(lockupAccount.stakeInfo.minimumStake.toString()).div(UNITS_PER_STAKE_TOKEN).toFixed(),
|
|
272
282
|
},
|
|
273
283
|
};
|
|
274
284
|
}
|
|
@@ -288,12 +298,15 @@ class StakeService {
|
|
|
288
298
|
return null;
|
|
289
299
|
}
|
|
290
300
|
return {
|
|
301
|
+
address: stakeAddress.toString(),
|
|
291
302
|
nonce: BigInt(stakeAccount.nonce.toString()),
|
|
292
303
|
createdTime: stakeAccount.createdTime.toNumber(),
|
|
293
304
|
stakedAmount: (0, bignumber_js_1.BigNumber)(stakeAccount.stakedAmount.toString()).div(UNITS_PER_STAKE_TOKEN).toFixed(),
|
|
294
305
|
rewardAmount: (0, bignumber_js_1.BigNumber)(stakeAccount.rewardAmount.toString()).div(UNITS_PER_REWARD_TOKEN).toFixed(),
|
|
295
306
|
stakeClaimed: stakeAccount.stakeClaimed,
|
|
296
307
|
lockPeriod: stakeAccount.lockPeriod.toNumber(),
|
|
308
|
+
lockup: stakeAccount.lockup.toString(),
|
|
309
|
+
staker: stakeAccount.staker.toString(),
|
|
297
310
|
};
|
|
298
311
|
}
|
|
299
312
|
async getUserNonceInfo(userNonceAddress) {
|
|
@@ -302,10 +315,11 @@ class StakeService {
|
|
|
302
315
|
return null;
|
|
303
316
|
}
|
|
304
317
|
return {
|
|
318
|
+
address: userNonceAddress.toString(),
|
|
305
319
|
nonce: BigInt(userNonceAccount.nonce.toString()),
|
|
306
320
|
};
|
|
307
321
|
}
|
|
308
|
-
async
|
|
322
|
+
async getAllStakesInfo(userAdress, lockupAddress) {
|
|
309
323
|
const lockupAccount = await this.program.account.lockup.fetchNullable(lockupAddress, this.provider.connection.commitment);
|
|
310
324
|
if (!lockupAccount) {
|
|
311
325
|
throw new Error("Lockup account does not exists for address: " + lockupAddress);
|
|
@@ -323,26 +337,61 @@ class StakeService {
|
|
|
323
337
|
}
|
|
324
338
|
const currentNonce = userNonceAccount.nonce.toNumber();
|
|
325
339
|
const nonces = Array.from({ length: currentNonce }, (_, i) => BigInt(i));
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
const signatureInfo = stakeSignatures[stakeSignatures.length - 1];
|
|
340
|
+
const stakeAddresses = nonces.map((nonce) => (0, pda_1.deriveStakeAddress)(userAdress, lockupAddress, nonce, this.program.programId));
|
|
341
|
+
const accountInfos = await this.provider.connection.getMultipleAccountsInfo(stakeAddresses, {
|
|
342
|
+
commitment: "finalized",
|
|
343
|
+
});
|
|
344
|
+
const stakeAccountsInfo = accountInfos.map((value, i) => {
|
|
345
|
+
(0, assert_1.default)(value, "Account does not exists for stake address: " + stakeAddresses[i] + " at nonce: " + nonces[i]);
|
|
346
|
+
const stakeAccount = this.program.coder.accounts.decode(this.program.idl.accounts[2].name, value.data);
|
|
334
347
|
const info = {
|
|
335
|
-
|
|
348
|
+
address: stakeAddresses[i].toString(),
|
|
336
349
|
nonce: BigInt(stakeAccount.nonce.toString()),
|
|
337
350
|
createdTime: stakeAccount.createdTime.toNumber(),
|
|
338
351
|
stakedAmount: (0, bignumber_js_1.BigNumber)(stakeAccount.stakedAmount.toString()).div(UNITS_PER_STAKE_TOKEN).toFixed(),
|
|
339
352
|
rewardAmount: (0, bignumber_js_1.BigNumber)(stakeAccount.rewardAmount.toString()).div(UNITS_PER_REWARD_TOKEN).toFixed(),
|
|
340
353
|
stakeClaimed: stakeAccount.stakeClaimed,
|
|
341
354
|
lockPeriod: stakeAccount.lockPeriod.toNumber(),
|
|
355
|
+
lockup: stakeAccount.lockup.toString(),
|
|
356
|
+
staker: stakeAccount.staker.toString(),
|
|
357
|
+
};
|
|
358
|
+
return info;
|
|
359
|
+
});
|
|
360
|
+
const promises = stakeAccountsInfo.map(async (stakeInfo) => {
|
|
361
|
+
const signatures = await this.provider.connection.getSignaturesForAddress((0, anchor_1.translateAddress)(stakeInfo.address), {}, "finalized");
|
|
362
|
+
const stakeSignatures = signatures.filter((s) => {
|
|
363
|
+
return !s.err && (s.blockTime ?? 0) === stakeInfo.createdTime;
|
|
364
|
+
});
|
|
365
|
+
const signatureInfo = stakeSignatures[stakeSignatures.length - 1];
|
|
366
|
+
const info = {
|
|
367
|
+
hash: signatureInfo ? signatureInfo.signature : "",
|
|
368
|
+
...stakeInfo,
|
|
342
369
|
};
|
|
343
370
|
return info;
|
|
344
371
|
});
|
|
345
372
|
return Promise.all(promises);
|
|
346
373
|
}
|
|
374
|
+
async getTotalStakeCount(lockupAddress) {
|
|
375
|
+
const dataSize = this.program.account.userStakeData.size;
|
|
376
|
+
const accountInfos = await this.provider.connection.getProgramAccounts(this.program.programId, {
|
|
377
|
+
commitment: "finalized",
|
|
378
|
+
dataSlice: {
|
|
379
|
+
length: 0,
|
|
380
|
+
offset: 0,
|
|
381
|
+
},
|
|
382
|
+
filters: [
|
|
383
|
+
{
|
|
384
|
+
dataSize,
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
memcmp: {
|
|
388
|
+
bytes: lockupAddress.toString(),
|
|
389
|
+
offset: 81,
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
],
|
|
393
|
+
});
|
|
394
|
+
return accountInfos.length;
|
|
395
|
+
}
|
|
347
396
|
}
|
|
348
397
|
exports.StakeService = StakeService;
|