@wireio/stake 0.0.6 → 0.1.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.
Files changed (44) hide show
  1. package/README.md +203 -13
  2. package/lib/stake.browser.js +2800 -3329
  3. package/lib/stake.browser.js.map +1 -1
  4. package/lib/stake.d.ts +376 -6261
  5. package/lib/stake.js +2937 -3476
  6. package/lib/stake.js.map +1 -1
  7. package/lib/stake.m.js +2800 -3329
  8. package/lib/stake.m.js.map +1 -1
  9. package/package.json +2 -2
  10. package/src/assets/solana/idl/deposit.json +46 -10
  11. package/src/assets/solana/idl/distribution.json +40 -8
  12. package/src/assets/solana/idl/liq_sol_token.json +25 -2
  13. package/src/assets/solana/idl/mint_helper.json +110 -0
  14. package/src/assets/solana/idl/read_tracked_balance.json +140 -0
  15. package/src/assets/solana/idl/stake_controller.json +1141 -780
  16. package/src/assets/solana/idl/treasury.json +1 -227
  17. package/src/assets/solana/idl/validator_leaderboard.json +88 -47
  18. package/src/assets/solana/idl/validator_registry.json +115 -46
  19. package/src/assets/solana/idl/yield_oracle.json +1 -1
  20. package/src/assets/solana/types/deposit.ts +46 -10
  21. package/src/assets/solana/types/distribution.ts +40 -8
  22. package/src/assets/solana/types/liq_sol_token.ts +25 -2
  23. package/src/assets/solana/types/mint_helper.ts +116 -0
  24. package/src/assets/solana/types/read_tracked_balance.ts +146 -0
  25. package/src/assets/solana/types/stake_controller.ts +1141 -780
  26. package/src/assets/solana/types/treasury.ts +1 -227
  27. package/src/assets/solana/types/validator_leaderboard.ts +88 -47
  28. package/src/assets/solana/types/validator_registry.ts +115 -46
  29. package/src/assets/solana/types/yield_oracle.ts +1 -1
  30. package/src/index.ts +3 -4
  31. package/src/networks/ethereum/ethereum.ts +2 -2
  32. package/src/networks/solana/clients/deposit.client.ts +71 -80
  33. package/src/networks/solana/clients/distribution.client.ts +392 -141
  34. package/src/networks/solana/clients/leaderboard.client.ts +82 -107
  35. package/src/networks/solana/constants.ts +141 -56
  36. package/src/networks/solana/program.ts +36 -89
  37. package/src/networks/solana/solana.ts +168 -34
  38. package/src/networks/solana/types.ts +57 -0
  39. package/src/scripts/fetch-artifacts.sh +24 -0
  40. package/src/staker/staker.ts +32 -28
  41. package/src/staker/types.ts +24 -21
  42. package/src/assets/solana/idl/stake_registry.json +0 -435
  43. package/src/networks/solana/utils.ts +0 -122
  44. /package/src/{utils.ts → common/utils.ts} +0 -0
@@ -5,124 +5,13 @@
5
5
  * IDL can be found at `target/idl/treasury.json`.
6
6
  */
7
7
  export type Treasury = {
8
- "address": "GJXKqEbdu76rRW6HcAVVupxdS3TetKfm7Dg8q3trHR8T",
8
+ "address": "98srSwC7RPw2BjUQE5oTuQMEhdWJ2GEK8GBLB4Ei2Awm",
9
9
  "metadata": {
10
10
  "name": "treasury",
11
11
  "version": "0.1.0",
12
12
  "spec": "0.1.0"
13
13
  },
14
14
  "instructions": [
15
- {
16
- "name": "addAuthority",
17
- "discriminator": [
18
- 229,
19
- 9,
20
- 106,
21
- 73,
22
- 91,
23
- 213,
24
- 109,
25
- 183
26
- ],
27
- "accounts": [
28
- {
29
- "name": "treasuryConfig",
30
- "writable": true,
31
- "pda": {
32
- "seeds": [
33
- {
34
- "kind": "const",
35
- "value": [
36
- 116,
37
- 114,
38
- 101,
39
- 97,
40
- 115,
41
- 117,
42
- 114,
43
- 121,
44
- 95,
45
- 99,
46
- 111,
47
- 110,
48
- 102,
49
- 105,
50
- 103
51
- ]
52
- }
53
- ]
54
- }
55
- },
56
- {
57
- "name": "admin",
58
- "signer": true
59
- }
60
- ],
61
- "args": [
62
- {
63
- "name": "newAuthority",
64
- "type": "pubkey"
65
- }
66
- ]
67
- },
68
- {
69
- "name": "initializeConfig",
70
- "discriminator": [
71
- 208,
72
- 127,
73
- 21,
74
- 1,
75
- 194,
76
- 190,
77
- 196,
78
- 70
79
- ],
80
- "accounts": [
81
- {
82
- "name": "treasuryConfig",
83
- "writable": true,
84
- "pda": {
85
- "seeds": [
86
- {
87
- "kind": "const",
88
- "value": [
89
- 116,
90
- 114,
91
- 101,
92
- 97,
93
- 115,
94
- 117,
95
- 114,
96
- 121,
97
- 95,
98
- 99,
99
- 111,
100
- 110,
101
- 102,
102
- 105,
103
- 103
104
- ]
105
- }
106
- ]
107
- }
108
- },
109
- {
110
- "name": "payer",
111
- "writable": true,
112
- "signer": true
113
- },
114
- {
115
- "name": "systemProgram",
116
- "address": "11111111111111111111111111111111"
117
- }
118
- ],
119
- "args": [
120
- {
121
- "name": "authority",
122
- "type": "pubkey"
123
- }
124
- ]
125
- },
126
15
  {
127
16
  "name": "initializeTreasury",
128
17
  "discriminator": [
@@ -194,33 +83,6 @@ export type Treasury = {
194
83
  "name": "recipient",
195
84
  "writable": true
196
85
  },
197
- {
198
- "name": "treasuryConfig",
199
- "pda": {
200
- "seeds": [
201
- {
202
- "kind": "const",
203
- "value": [
204
- 116,
205
- 114,
206
- 101,
207
- 97,
208
- 115,
209
- 117,
210
- 114,
211
- 121,
212
- 95,
213
- 99,
214
- 111,
215
- 110,
216
- 102,
217
- 105,
218
- 103
219
- ]
220
- }
221
- ]
222
- }
223
- },
224
86
  {
225
87
  "name": "systemProgram",
226
88
  "address": "11111111111111111111111111111111"
@@ -232,74 +94,6 @@ export type Treasury = {
232
94
  "type": "u64"
233
95
  }
234
96
  ]
235
- },
236
- {
237
- "name": "removeAuthority",
238
- "discriminator": [
239
- 242,
240
- 104,
241
- 208,
242
- 132,
243
- 190,
244
- 250,
245
- 74,
246
- 216
247
- ],
248
- "accounts": [
249
- {
250
- "name": "treasuryConfig",
251
- "writable": true,
252
- "pda": {
253
- "seeds": [
254
- {
255
- "kind": "const",
256
- "value": [
257
- 116,
258
- 114,
259
- 101,
260
- 97,
261
- 115,
262
- 117,
263
- 114,
264
- 121,
265
- 95,
266
- 99,
267
- 111,
268
- 110,
269
- 102,
270
- 105,
271
- 103
272
- ]
273
- }
274
- ]
275
- }
276
- },
277
- {
278
- "name": "admin",
279
- "signer": true
280
- }
281
- ],
282
- "args": [
283
- {
284
- "name": "target",
285
- "type": "pubkey"
286
- }
287
- ]
288
- }
289
- ],
290
- "accounts": [
291
- {
292
- "name": "treasuryConfig",
293
- "discriminator": [
294
- 124,
295
- 54,
296
- 212,
297
- 227,
298
- 213,
299
- 189,
300
- 168,
301
- 41
302
- ]
303
97
  }
304
98
  ],
305
99
  "errors": [
@@ -318,25 +112,5 @@ export type Treasury = {
318
112
  "name": "alreadyInitialized",
319
113
  "msg": "Treasury PDA already initialised"
320
114
  }
321
- ],
322
- "types": [
323
- {
324
- "name": "treasuryConfig",
325
- "type": {
326
- "kind": "struct",
327
- "fields": [
328
- {
329
- "name": "authorities",
330
- "type": {
331
- "vec": "pubkey"
332
- }
333
- },
334
- {
335
- "name": "bump",
336
- "type": "u8"
337
- }
338
- ]
339
- }
340
- }
341
115
  ]
342
116
  };
@@ -5,7 +5,7 @@
5
5
  * IDL can be found at `target/idl/validator_leaderboard.json`.
6
6
  */
7
7
  export type ValidatorLeaderboard = {
8
- "address": "4tY1rN1EX7SfyhjwgRh8nEFp9AwCGwXrcUXnWDMac35e",
8
+ "address": "CYxrJjaraGmdVjnB6EDNyx73pz9Lk2dqpaVtysNo7EXj",
9
9
  "metadata": {
10
10
  "name": "validatorLeaderboard",
11
11
  "version": "0.1.0",
@@ -13,52 +13,6 @@ export type ValidatorLeaderboard = {
13
13
  "description": "Created with Anchor"
14
14
  },
15
15
  "instructions": [
16
- {
17
- "name": "getCachedTop10",
18
- "discriminator": [
19
- 28,
20
- 77,
21
- 207,
22
- 225,
23
- 217,
24
- 150,
25
- 249,
26
- 51
27
- ],
28
- "accounts": [
29
- {
30
- "name": "cache",
31
- "pda": {
32
- "seeds": [
33
- {
34
- "kind": "const",
35
- "value": [
36
- 116,
37
- 111,
38
- 112,
39
- 95,
40
- 49,
41
- 48,
42
- 95,
43
- 99,
44
- 97,
45
- 99,
46
- 104,
47
- 101
48
- ]
49
- }
50
- ]
51
- }
52
- }
53
- ],
54
- "args": [],
55
- "returns": {
56
- "array": [
57
- "pubkey",
58
- 10
59
- ]
60
- }
61
- },
62
16
  {
63
17
  "name": "initialize",
64
18
  "discriminator": [
@@ -116,6 +70,60 @@ export type ValidatorLeaderboard = {
116
70
  ],
117
71
  "args": []
118
72
  },
73
+ {
74
+ "name": "updateCommission",
75
+ "discriminator": [
76
+ 2,
77
+ 202,
78
+ 72,
79
+ 156,
80
+ 19,
81
+ 253,
82
+ 91,
83
+ 174
84
+ ],
85
+ "accounts": [
86
+ {
87
+ "name": "registrant",
88
+ "writable": true,
89
+ "signer": true
90
+ },
91
+ {
92
+ "name": "voteAccount"
93
+ },
94
+ {
95
+ "name": "validatorRecord",
96
+ "writable": true,
97
+ "pda": {
98
+ "seeds": [
99
+ {
100
+ "kind": "const",
101
+ "value": [
102
+ 118,
103
+ 97,
104
+ 108,
105
+ 105,
106
+ 100,
107
+ 97,
108
+ 116,
109
+ 111,
110
+ 114
111
+ ]
112
+ },
113
+ {
114
+ "kind": "account",
115
+ "path": "voteAccount"
116
+ }
117
+ ]
118
+ }
119
+ },
120
+ {
121
+ "name": "systemProgram",
122
+ "address": "11111111111111111111111111111111"
123
+ }
124
+ ],
125
+ "args": []
126
+ },
119
127
  {
120
128
  "name": "updateTop10Cache",
121
129
  "discriminator": [
@@ -159,6 +167,34 @@ export type ValidatorLeaderboard = {
159
167
  ]
160
168
  }
161
169
  },
170
+ {
171
+ "name": "leaderboardHead",
172
+ "pda": {
173
+ "seeds": [
174
+ {
175
+ "kind": "const",
176
+ "value": [
177
+ 108,
178
+ 101,
179
+ 97,
180
+ 100,
181
+ 101,
182
+ 114,
183
+ 98,
184
+ 111,
185
+ 97,
186
+ 114,
187
+ 100,
188
+ 95,
189
+ 104,
190
+ 101,
191
+ 97,
192
+ 100
193
+ ]
194
+ }
195
+ ]
196
+ }
197
+ },
162
198
  {
163
199
  "name": "systemProgram",
164
200
  "address": "11111111111111111111111111111111"
@@ -411,6 +447,11 @@ export type ValidatorLeaderboard = {
411
447
  "code": 6016,
412
448
  "name": "brokenLinkage",
413
449
  "msg": "Broken linked list continuity"
450
+ },
451
+ {
452
+ "code": 6017,
453
+ "name": "commissionNotUpdated",
454
+ "msg": "Commission must be updated for current epoch before updating validator"
414
455
  }
415
456
  ],
416
457
  "types": [
@@ -5,7 +5,7 @@
5
5
  * IDL can be found at `target/idl/validator_registry.json`.
6
6
  */
7
7
  export type ValidatorRegistry = {
8
- "address": "DqaNZkyhg6ASSkut8tyQGjwMtv35Yj5rA9JZvzmzZb3e",
8
+ "address": "EgUbYv1coMTXsdRc5HBqTv32SNhTcsRS1nPiUDw5LbQK",
9
9
  "metadata": {
10
10
  "name": "validatorRegistry",
11
11
  "version": "0.1.0",
@@ -131,16 +131,45 @@ export type ValidatorRegistry = {
131
131
  ]
132
132
  },
133
133
  {
134
- "name": "syncValidatorsFromChain",
134
+ "name": "moveTransientToActive",
135
135
  "discriminator": [
136
- 247,
137
- 11,
138
- 19,
139
- 18,
140
- 37,
141
- 20,
136
+ 140,
137
+ 99,
138
+ 170,
139
+ 186,
140
+ 84,
141
+ 61,
142
+ 184,
143
+ 75
144
+ ],
145
+ "accounts": [
146
+ {
147
+ "name": "validatorRegistry",
148
+ "writable": true
149
+ }
150
+ ],
151
+ "args": [
152
+ {
153
+ "name": "voteAccount",
154
+ "type": "pubkey"
155
+ },
156
+ {
157
+ "name": "amount",
158
+ "type": "u64"
159
+ }
160
+ ]
161
+ },
162
+ {
163
+ "name": "syncValidatorScores",
164
+ "discriminator": [
165
+ 10,
166
+ 26,
142
167
  245,
143
- 232
168
+ 222,
169
+ 183,
170
+ 46,
171
+ 70,
172
+ 181
144
173
  ],
145
174
  "accounts": [
146
175
  {
@@ -175,22 +204,47 @@ export type ValidatorRegistry = {
175
204
  ]
176
205
  },
177
206
  {
178
- "name": "updatePerformance",
207
+ "name": "updateMaxResolvedStake",
179
208
  "discriminator": [
209
+ 241,
210
+ 21,
211
+ 28,
212
+ 14,
213
+ 58,
180
214
  11,
181
- 251,
182
- 66,
183
- 148,
184
- 20,
185
- 86,
186
- 149,
187
- 20
215
+ 76,
216
+ 44
188
217
  ],
189
218
  "accounts": [
190
219
  {
191
- "name": "authority",
192
- "signer": true
220
+ "name": "validatorRegistry",
221
+ "writable": true
222
+ }
223
+ ],
224
+ "args": [
225
+ {
226
+ "name": "voteAccount",
227
+ "type": "pubkey"
193
228
  },
229
+ {
230
+ "name": "newValue",
231
+ "type": "u64"
232
+ }
233
+ ]
234
+ },
235
+ {
236
+ "name": "updateValidatorInfo",
237
+ "discriminator": [
238
+ 120,
239
+ 41,
240
+ 183,
241
+ 100,
242
+ 13,
243
+ 154,
244
+ 196,
245
+ 200
246
+ ],
247
+ "accounts": [
194
248
  {
195
249
  "name": "validatorRegistry",
196
250
  "writable": true
@@ -202,16 +256,34 @@ export type ValidatorRegistry = {
202
256
  "type": "pubkey"
203
257
  },
204
258
  {
205
- "name": "performanceScore",
206
- "type": "u32"
259
+ "name": "currentActiveStakeAmount",
260
+ "type": {
261
+ "option": "u64"
262
+ }
207
263
  },
208
264
  {
209
- "name": "activeStake",
210
- "type": "u64"
265
+ "name": "epochRewardAmount",
266
+ "type": {
267
+ "option": "u64"
268
+ }
211
269
  },
212
270
  {
213
- "name": "commission",
214
- "type": "u64"
271
+ "name": "transientActiveStakeAmount",
272
+ "type": {
273
+ "option": "u64"
274
+ }
275
+ },
276
+ {
277
+ "name": "epoch",
278
+ "type": {
279
+ "option": "u64"
280
+ }
281
+ },
282
+ {
283
+ "name": "performanceScore",
284
+ "type": {
285
+ "option": "u32"
286
+ }
215
287
  }
216
288
  ]
217
289
  }
@@ -286,6 +358,16 @@ export type ValidatorRegistry = {
286
358
  "code": 6007,
287
359
  "name": "invalidStakeAccount",
288
360
  "msg": "Invalid Stake Account"
361
+ },
362
+ {
363
+ "code": 6008,
364
+ "name": "arithmeticOverflow",
365
+ "msg": "Arithmetic overflow"
366
+ },
367
+ {
368
+ "code": 6009,
369
+ "name": "insufficientTransientStake",
370
+ "msg": "Insufficient transient stake"
289
371
  }
290
372
  ],
291
373
  "types": [
@@ -299,48 +381,35 @@ export type ValidatorRegistry = {
299
381
  "type": "pubkey"
300
382
  },
301
383
  {
302
- "name": "name",
303
- "type": {
304
- "array": [
305
- "u8",
306
- 32
307
- ]
308
- }
309
- },
310
- {
311
- "name": "performanceScore",
384
+ "name": "vpp",
312
385
  "type": "u32"
313
386
  },
314
387
  {
315
- "name": "activeStake",
388
+ "name": "currentActiveStake",
316
389
  "type": "u64"
317
390
  },
318
391
  {
319
- "name": "activatingStake",
392
+ "name": "epochReward",
320
393
  "type": "u64"
321
394
  },
322
395
  {
323
- "name": "deactivatingStake",
324
- "type": "u64"
325
- },
326
- {
327
- "name": "commission",
396
+ "name": "transientActiveStake",
328
397
  "type": "u64"
329
398
  },
330
399
  {
331
- "name": "lastUpdatedEpoch",
400
+ "name": "lastChainSyncEpoch",
332
401
  "type": "u64"
333
402
  },
334
403
  {
335
- "name": "initialStake",
404
+ "name": "lastUpdatedSlot",
336
405
  "type": "u64"
337
406
  },
338
407
  {
339
- "name": "previousEpochActiveStake",
408
+ "name": "maxResolvedEpochDeactivations",
340
409
  "type": "u64"
341
410
  },
342
411
  {
343
- "name": "previousEpochSnapshot",
412
+ "name": "maxResolvedActivatingStake",
344
413
  "type": "u64"
345
414
  }
346
415
  ]
@@ -5,7 +5,7 @@
5
5
  * IDL can be found at `target/idl/yield_oracle.json`.
6
6
  */
7
7
  export type YieldOracle = {
8
- "address": "ABMUzgJCoJ17WPYvxZg4Biuo5oCaEbuD4svUVGFBTWCz",
8
+ "address": "6eQiRLG19udrDwK3TM17gTsPrHczoXVDusTErdD9pH8h",
9
9
  "metadata": {
10
10
  "name": "yieldOracle",
11
11
  "version": "0.1.0",
package/src/index.ts CHANGED
@@ -1,21 +1,20 @@
1
1
  // Export all utilities from the utils module
2
- export * from './utils';
2
+ export * from './common/utils';
3
3
 
4
4
  // Staker utilities
5
5
  export * from './staker/staker';
6
6
  export * from './staker/types';
7
7
 
8
8
  // NETWORKS
9
-
10
- // Ethereum
11
9
  export * from './networks/ethereum/ethereum';
12
10
  export * from './networks/ethereum/contract';
13
11
  export * as ETH from './networks/ethereum/types';
14
12
 
15
13
  export * from './networks/solana/solana';
16
14
  export * from './networks/solana/constants';
17
- export * from './networks/solana/utils';
15
+ export * as SOL from './networks/solana/types';
18
16
 
17
+ // CLIENTS
19
18
  export * from './networks/solana/clients/deposit.client';
20
19
  export * from './networks/solana/clients/distribution.client';
21
20
  export * from './networks/solana/clients/leaderboard.client';
@@ -4,12 +4,12 @@ import { ethers } from 'ethers';
4
4
  import { IStakingClient, StakerConfig } from '../../staker/types';
5
5
  import { PublicKey as WirePubKey } from '@wireio/core';
6
6
  import { ERC20Abi } from './contract'; // TODO replace with staking contract ABI
7
- import axios from 'axios';
8
7
 
9
8
  // — replace with your actual staking contract ABI & address —
10
9
  const STAKING_CONTRACT_ADDRESS = '0xYourStakingContractAddress';
11
10
 
12
- export class EthereumStakingClient implements IStakingClient {
11
+ // TODO extend to implement ISTAKINGCLIENT
12
+ export class EthereumStakingClient {
13
13
  public readonly pubKey: WirePubKey;
14
14
  private readonly provider: ethers.providers.Web3Provider;
15
15
  private readonly signer: ethers.Signer;