@wireio/stake 0.3.1 → 0.4.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.
Files changed (36) hide show
  1. package/lib/stake.browser.js +12887 -10017
  2. package/lib/stake.browser.js.map +1 -1
  3. package/lib/stake.d.ts +3305 -1364
  4. package/lib/stake.js +16298 -13436
  5. package/lib/stake.js.map +1 -1
  6. package/lib/stake.m.js +12887 -10017
  7. package/lib/stake.m.js.map +1 -1
  8. package/package.json +3 -1
  9. package/src/assets/solana/idl/liqsol_core.json +2327 -887
  10. package/src/assets/solana/idl/liqsol_token.json +1 -1
  11. package/src/assets/solana/idl/transfer_hook.json +192 -0
  12. package/src/assets/solana/idl/validator_leaderboard.json +147 -4
  13. package/src/assets/solana/types/liqsol_core.ts +2327 -887
  14. package/src/assets/solana/types/liqsol_token.ts +1 -1
  15. package/src/assets/solana/types/transfer_hook.ts +198 -0
  16. package/src/assets/solana/types/validator_leaderboard.ts +147 -4
  17. package/src/networks/ethereum/clients/{deposit.client.ts → convert.client.ts} +36 -4
  18. package/src/networks/ethereum/clients/opp.client.ts +390 -0
  19. package/src/networks/ethereum/clients/pretoken.client.ts +88 -49
  20. package/src/networks/ethereum/clients/receipt.client.ts +129 -0
  21. package/src/networks/ethereum/clients/stake.client.ts +1 -148
  22. package/src/networks/ethereum/contract.ts +7 -4
  23. package/src/networks/ethereum/ethereum.ts +44 -70
  24. package/src/networks/ethereum/types.ts +1 -0
  25. package/src/networks/ethereum/utils.ts +1 -1
  26. package/src/networks/solana/clients/deposit.client.ts +154 -8
  27. package/src/networks/solana/clients/distribution.client.ts +72 -291
  28. package/src/networks/solana/clients/leaderboard.client.ts +59 -14
  29. package/src/networks/solana/clients/outpost.client.ts +188 -359
  30. package/src/networks/solana/clients/token.client.ts +85 -100
  31. package/src/networks/solana/constants.ts +155 -64
  32. package/src/networks/solana/solana.ts +273 -154
  33. package/src/networks/solana/types.ts +532 -71
  34. package/src/networks/solana/utils.ts +68 -51
  35. package/src/types.ts +161 -17
  36. package/src/networks/ethereum/clients/liq.client.ts +0 -47
@@ -5,7 +5,7 @@
5
5
  * IDL can be found at `target/idl/liqsol_token.json`.
6
6
  */
7
7
  export type LiqsolToken = {
8
- "address": "6cDoerqdV6UQDsGvUEq5Qj5HRxxyDxSuUaB2J6iK8cio",
8
+ "address": "6hiJ8PrSyYLr7H9MA9VYh9fvGoHxZ2TXdDAMzjeUVSXZ",
9
9
  "metadata": {
10
10
  "name": "liqsolToken",
11
11
  "version": "0.1.0",
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Program IDL in camelCase format in order to be used in JS/TS.
3
+ *
4
+ * Note that this is only a type helper and is not the actual IDL. The original
5
+ * IDL can be found at `target/idl/transfer_hook.json`.
6
+ */
7
+ export type TransferHook = {
8
+ "address": "EtqCLddkPNGjkgiH9rVUmK3M5X2FKFprQvgscBJ8g6hX",
9
+ "metadata": {
10
+ "name": "transferHook",
11
+ "version": "0.1.0",
12
+ "spec": "0.1.0",
13
+ "description": "Created with Anchor"
14
+ },
15
+ "instructions": [
16
+ {
17
+ "name": "initializeExtraAccountMetaList",
18
+ "discriminator": [
19
+ 43,
20
+ 34,
21
+ 13,
22
+ 49,
23
+ 167,
24
+ 88,
25
+ 235,
26
+ 235
27
+ ],
28
+ "accounts": [
29
+ {
30
+ "name": "payer",
31
+ "writable": true,
32
+ "signer": true
33
+ },
34
+ {
35
+ "name": "extraAccountMetaList",
36
+ "writable": true
37
+ },
38
+ {
39
+ "name": "mint"
40
+ },
41
+ {
42
+ "name": "systemProgram"
43
+ },
44
+ {
45
+ "name": "liqsolCore"
46
+ }
47
+ ],
48
+ "args": []
49
+ },
50
+ {
51
+ "name": "transferHook",
52
+ "discriminator": [
53
+ 105,
54
+ 37,
55
+ 101,
56
+ 197,
57
+ 75,
58
+ 251,
59
+ 102,
60
+ 26
61
+ ],
62
+ "accounts": [
63
+ {
64
+ "name": "sourceToken"
65
+ },
66
+ {
67
+ "name": "mint"
68
+ },
69
+ {
70
+ "name": "destinationToken"
71
+ },
72
+ {
73
+ "name": "authority"
74
+ },
75
+ {
76
+ "name": "extraAccountMetaList"
77
+ },
78
+ {
79
+ "name": "liqsolCore"
80
+ },
81
+ {
82
+ "name": "senderUserRecord",
83
+ "writable": true
84
+ },
85
+ {
86
+ "name": "receiverUserRecord",
87
+ "writable": true
88
+ },
89
+ {
90
+ "name": "distributionState",
91
+ "writable": true
92
+ },
93
+ {
94
+ "name": "bucketTokenAccount"
95
+ }
96
+ ],
97
+ "args": [
98
+ {
99
+ "name": "amount",
100
+ "type": "u64"
101
+ }
102
+ ]
103
+ }
104
+ ],
105
+ "accounts": [
106
+ {
107
+ "name": "distributionState",
108
+ "discriminator": [
109
+ 7,
110
+ 25,
111
+ 94,
112
+ 15,
113
+ 208,
114
+ 170,
115
+ 4,
116
+ 103
117
+ ]
118
+ }
119
+ ],
120
+ "errors": [
121
+ {
122
+ "code": 6000,
123
+ "name": "amountTooBig"
124
+ },
125
+ {
126
+ "code": 6001,
127
+ "name": "isNotCurrentlyTransferring"
128
+ },
129
+ {
130
+ "code": 6002,
131
+ "name": "tlvAccountResolutionError"
132
+ }
133
+ ],
134
+ "types": [
135
+ {
136
+ "name": "distributionState",
137
+ "type": {
138
+ "kind": "struct",
139
+ "fields": [
140
+ {
141
+ "name": "liqsolMint",
142
+ "type": "pubkey"
143
+ },
144
+ {
145
+ "name": "currentIndex",
146
+ "type": "u64"
147
+ },
148
+ {
149
+ "name": "totalShares",
150
+ "docs": [
151
+ "Sum of all user shares across the system"
152
+ ],
153
+ "type": "u64"
154
+ },
155
+ {
156
+ "name": "lastBucketBalance",
157
+ "docs": [
158
+ "Last observed bucket balance used for incremental index updates"
159
+ ],
160
+ "type": "u64"
161
+ },
162
+ {
163
+ "name": "bump",
164
+ "type": "u8"
165
+ },
166
+ {
167
+ "name": "bucketBump",
168
+ "docs": [
169
+ "Cached bucket authority bump to avoid repeated find_program_address calls"
170
+ ],
171
+ "type": "u8"
172
+ },
173
+ {
174
+ "name": "poolBump",
175
+ "docs": [
176
+ "Cached pool authority bump to avoid repeated find_program_address calls"
177
+ ],
178
+ "type": "u8"
179
+ },
180
+ {
181
+ "name": "bucketAuthority",
182
+ "docs": [
183
+ "Cached bucket authority pubkey for transfer-hook optimization"
184
+ ],
185
+ "type": "pubkey"
186
+ },
187
+ {
188
+ "name": "poolAuthority",
189
+ "docs": [
190
+ "Cached pool authority pubkey for transfer-hook optimization"
191
+ ],
192
+ "type": "pubkey"
193
+ }
194
+ ]
195
+ }
196
+ }
197
+ ]
198
+ };
@@ -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": "C4ddPrB1ALYpW4G1Qz4ffvETBA8YGUL7TVZaLiE6bb1q",
8
+ "address": "H6CWj2PgxCE9Z5dPi9nMrR2VxT1C4DQcqR1QjmLeon47",
9
9
  "metadata": {
10
10
  "name": "validatorLeaderboard",
11
11
  "version": "0.1.0",
@@ -69,6 +69,149 @@ export type ValidatorLeaderboard = {
69
69
  ],
70
70
  "args": []
71
71
  },
72
+ {
73
+ "name": "testClearLeaderboard",
74
+ "discriminator": [
75
+ 118,
76
+ 207,
77
+ 26,
78
+ 205,
79
+ 180,
80
+ 7,
81
+ 75,
82
+ 244
83
+ ],
84
+ "accounts": [
85
+ {
86
+ "name": "leaderboardState",
87
+ "writable": true
88
+ },
89
+ {
90
+ "name": "authority",
91
+ "signer": true
92
+ }
93
+ ],
94
+ "args": []
95
+ },
96
+ {
97
+ "name": "testForceRegisterValidator",
98
+ "discriminator": [
99
+ 136,
100
+ 156,
101
+ 132,
102
+ 32,
103
+ 96,
104
+ 240,
105
+ 7,
106
+ 115
107
+ ],
108
+ "accounts": [
109
+ {
110
+ "name": "registrant",
111
+ "writable": true,
112
+ "signer": true
113
+ },
114
+ {
115
+ "name": "voteAccount"
116
+ },
117
+ {
118
+ "name": "validatorRecord",
119
+ "writable": true
120
+ },
121
+ {
122
+ "name": "leaderboardState",
123
+ "writable": true
124
+ },
125
+ {
126
+ "name": "systemProgram"
127
+ }
128
+ ],
129
+ "args": [
130
+ {
131
+ "name": "vpp",
132
+ "type": "u8"
133
+ }
134
+ ]
135
+ },
136
+ {
137
+ "name": "testForceUpdateVpp",
138
+ "discriminator": [
139
+ 67,
140
+ 51,
141
+ 28,
142
+ 174,
143
+ 200,
144
+ 214,
145
+ 203,
146
+ 162
147
+ ],
148
+ "accounts": [
149
+ {
150
+ "name": "registrant",
151
+ "writable": true,
152
+ "signer": true
153
+ },
154
+ {
155
+ "name": "voteAccount"
156
+ },
157
+ {
158
+ "name": "validatorRecord",
159
+ "writable": true
160
+ },
161
+ {
162
+ "name": "leaderboardState",
163
+ "writable": true
164
+ }
165
+ ],
166
+ "args": [
167
+ {
168
+ "name": "vpp",
169
+ "type": "u8"
170
+ }
171
+ ]
172
+ },
173
+ {
174
+ "name": "testSeedRandomValidators",
175
+ "discriminator": [
176
+ 48,
177
+ 155,
178
+ 181,
179
+ 112,
180
+ 163,
181
+ 242,
182
+ 43,
183
+ 146
184
+ ],
185
+ "accounts": [
186
+ {
187
+ "name": "registrant",
188
+ "writable": true,
189
+ "signer": true
190
+ },
191
+ {
192
+ "name": "leaderboardState",
193
+ "writable": true
194
+ }
195
+ ],
196
+ "args": [
197
+ {
198
+ "name": "count",
199
+ "type": "u16"
200
+ },
201
+ {
202
+ "name": "seed",
203
+ "type": "u64"
204
+ },
205
+ {
206
+ "name": "minVpp",
207
+ "type": "u8"
208
+ },
209
+ {
210
+ "name": "maxVpp",
211
+ "type": "u8"
212
+ }
213
+ ]
214
+ },
72
215
  {
73
216
  "name": "updateCommission",
74
217
  "discriminator": [
@@ -163,7 +306,7 @@ export type ValidatorLeaderboard = {
163
306
  "args": [
164
307
  {
165
308
  "name": "vpp",
166
- "type": "u64"
309
+ "type": "u8"
167
310
  },
168
311
  {
169
312
  "name": "proposedRank",
@@ -360,12 +503,12 @@ export type ValidatorLeaderboard = {
360
503
  {
361
504
  "name": "scores",
362
505
  "docs": [
363
- "VPP scores indexed by registry_index",
506
+ "VPP scores indexed by registry_index (0-100 range)",
364
507
  "registry_index is assigned on first validator registration and never changes"
365
508
  ],
366
509
  "type": {
367
510
  "array": [
368
- "u64",
511
+ "u8",
369
512
  1024
370
513
  ]
371
514
  }
@@ -1,10 +1,9 @@
1
- import { BigNumber, ethers, Signer } from "ethers";
2
- import { DepositEvent, DepositResult, WithdrawRequestedEvent, WithdrawResult } from "../types";
1
+ import { BigNumber, ethers } from "ethers";
2
+ import { DepositEvent, DepositResult, SharesBurnedEvent } from "../types";
3
3
  import { EthereumContractService } from "../contract";
4
- import { ChainID } from "@wireio/core";
5
4
  import { formatContractErrors } from "../utils";
6
5
 
7
- export class DepositClient {
6
+ export class ConvertClient {
8
7
 
9
8
  private readonly contractService: EthereumContractService;
10
9
 
@@ -84,7 +83,39 @@ export class DepositClient {
84
83
  }
85
84
 
86
85
 
86
+ public async performWithdraw(signerAddress: string, amountWei: BigNumber): Promise<any> {
87
+ let tx, receipt;
88
+ try {
89
+ tx = await this.contract.LiqEth.safeBurn(signerAddress, amountWei);
90
+ receipt = await tx.wait(1);
91
+ } catch (err: any) {
92
+ let errorObj = formatContractErrors(err);
93
+ throw new Error(errorObj.name ?? errorObj.raw)
94
+ }
95
+
96
+ // Parse SharesBurned event if present
97
+ let event: SharesBurnedEvent | undefined;
98
+ const ev = receipt.events?.find((e) => e.event === 'SharesBurned');
87
99
 
100
+ if (ev && ev.args) {
101
+ const { from, shares, tokenValue } = ev.args;
102
+ event = {
103
+ from,
104
+ shares: BigNumber.from(shares),
105
+ tokenValue: BigNumber.from(tokenValue),
106
+ };
107
+ }
108
+
109
+ return {
110
+ txHash: tx.hash,
111
+ receipt,
112
+ event,
113
+ };
114
+ }
115
+
116
+
117
+
118
+ /*
88
119
  // OLD - this was replaced with LiqEth.safeBurn() on 1/13/26
89
120
  async requestWithdraw(amountWei: BigNumber, signer: Signer, chainId: ChainID): Promise<WithdrawResult> {
90
121
  // deadline is a period of time in the future that the signature is valid for
@@ -153,6 +184,7 @@ export class DepositClient {
153
184
  withdrawRequested,
154
185
  } as WithdrawResult;
155
186
  }
187
+ */
156
188
 
157
189
 
158
190