@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.
- package/lib/stake.browser.js +12887 -10017
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +3305 -1364
- package/lib/stake.js +16298 -13436
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +12887 -10017
- package/lib/stake.m.js.map +1 -1
- package/package.json +3 -1
- package/src/assets/solana/idl/liqsol_core.json +2327 -887
- package/src/assets/solana/idl/liqsol_token.json +1 -1
- package/src/assets/solana/idl/transfer_hook.json +192 -0
- package/src/assets/solana/idl/validator_leaderboard.json +147 -4
- package/src/assets/solana/types/liqsol_core.ts +2327 -887
- package/src/assets/solana/types/liqsol_token.ts +1 -1
- package/src/assets/solana/types/transfer_hook.ts +198 -0
- package/src/assets/solana/types/validator_leaderboard.ts +147 -4
- package/src/networks/ethereum/clients/{deposit.client.ts → convert.client.ts} +36 -4
- package/src/networks/ethereum/clients/opp.client.ts +390 -0
- package/src/networks/ethereum/clients/pretoken.client.ts +88 -49
- package/src/networks/ethereum/clients/receipt.client.ts +129 -0
- package/src/networks/ethereum/clients/stake.client.ts +1 -148
- package/src/networks/ethereum/contract.ts +7 -4
- package/src/networks/ethereum/ethereum.ts +44 -70
- package/src/networks/ethereum/types.ts +1 -0
- package/src/networks/ethereum/utils.ts +1 -1
- package/src/networks/solana/clients/deposit.client.ts +154 -8
- package/src/networks/solana/clients/distribution.client.ts +72 -291
- package/src/networks/solana/clients/leaderboard.client.ts +59 -14
- package/src/networks/solana/clients/outpost.client.ts +188 -359
- package/src/networks/solana/clients/token.client.ts +85 -100
- package/src/networks/solana/constants.ts +155 -64
- package/src/networks/solana/solana.ts +273 -154
- package/src/networks/solana/types.ts +532 -71
- package/src/networks/solana/utils.ts +68 -51
- package/src/types.ts +161 -17
- package/src/networks/ethereum/clients/liq.client.ts +0 -47
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { PublicKey, TokenAmount, Transaction, VersionedTransaction } from "@solana/web3.js";
|
|
2
2
|
import { BN } from '@coral-xyz/anchor';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* ============================================================
|
|
6
|
+
* Common / Wallet Types
|
|
7
|
+
* ============================================================
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type SolanaTransaction = Transaction | VersionedTransaction;
|
|
5
11
|
|
|
6
12
|
export type WalletLike = {
|
|
7
13
|
publicKey: PublicKey;
|
|
@@ -9,139 +15,594 @@ export type WalletLike = {
|
|
|
9
15
|
signAllTransactions?: (txs: Transaction[]) => Promise<Transaction[]>;
|
|
10
16
|
};
|
|
11
17
|
|
|
12
|
-
export type UserRecord = {
|
|
13
|
-
userAta: PublicKey;
|
|
14
|
-
trackedBalance: bigint; // What we think they have (for reward calculations)
|
|
15
|
-
claimBalance: bigint; // Accumulated unclaimed rewards
|
|
16
|
-
lastClaimTimestamp: bigint; // When they last claimed (unix timestamp)
|
|
17
|
-
bump: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
18
|
export type ParsedAccountInfo = {
|
|
21
19
|
extensions: Array<{ extension: string }>;
|
|
22
20
|
isNative: boolean;
|
|
23
21
|
mint: string;
|
|
24
22
|
owner: string;
|
|
25
23
|
state: string;
|
|
26
|
-
tokenAmount: TokenAmount
|
|
24
|
+
tokenAmount: TokenAmount;
|
|
27
25
|
};
|
|
28
|
-
export interface MismatchCandidate {
|
|
29
|
-
owner: PublicKey;
|
|
30
|
-
actual: bigint;
|
|
31
|
-
tracked: bigint;
|
|
32
|
-
delta: bigint; // tracked - actual
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface CorrectRegisterPlan {
|
|
36
|
-
deficit: bigint;
|
|
37
|
-
willFree: bigint;
|
|
38
|
-
selected: MismatchCandidate[];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface CorrectRegisterBuildResult {
|
|
42
|
-
needToRegister: boolean;
|
|
43
|
-
canSucceed: boolean;
|
|
44
|
-
reason?: string;
|
|
45
|
-
transaction?: Transaction;
|
|
46
|
-
plan: CorrectRegisterPlan;
|
|
47
|
-
}
|
|
48
26
|
|
|
49
27
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
28
|
+
* ============================================================
|
|
29
|
+
* Wire Outpost Snapshot
|
|
30
|
+
* ============================================================
|
|
31
|
+
*
|
|
32
|
+
* This is the high-level “view model” the SDK returns after
|
|
33
|
+
* fetching all relevant on-chain accounts for a given user.
|
|
52
34
|
*/
|
|
35
|
+
|
|
53
36
|
export type OutpostWireStateSnapshot = {
|
|
54
37
|
globalState: GlobalState;
|
|
55
|
-
distributionState: DistributionState;
|
|
56
38
|
|
|
57
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Per-user Outpost account (old “wire receipt”), or null if user
|
|
41
|
+
* hasn’t interacted yet.
|
|
42
|
+
*/
|
|
43
|
+
outpostAccount: OutpostAccount | null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Index-based liqSOL distribution state, or null if not initialized.
|
|
47
|
+
*/
|
|
48
|
+
distributionState: DistributionState | null;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Global tranche pricing/supply state (`trancheState`).
|
|
52
|
+
* May be null if not initialized.
|
|
53
|
+
*/
|
|
58
54
|
trancheState: TrancheState | null;
|
|
59
|
-
userWarrantRecord: UserWarrantRecord | null;
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Per-user pretoken purchase record (`userPretokenRecord` in the IDL).
|
|
58
|
+
* May be null if the user never purchased.
|
|
59
|
+
*/
|
|
60
|
+
userPretokenRecord: UserPretokenRecord | null;
|
|
61
|
+
|
|
62
|
+
// Balances
|
|
63
|
+
/** liqSOL in the pool ATA (Token-2022 raw amount) */
|
|
64
|
+
liqsolPoolBalance: BN;
|
|
65
|
+
|
|
66
|
+
/** liqSOL in the user’s ATA (Token-2022 raw amount) */
|
|
67
|
+
userLiqsolBalance: BN;
|
|
65
68
|
};
|
|
66
69
|
|
|
70
|
+
/**
|
|
71
|
+
* ============================================================
|
|
72
|
+
* Core Enums / Aliases (from IDL variants)
|
|
73
|
+
* ============================================================
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* `wireState` enum from IDL:
|
|
78
|
+
* - preLaunch: pretokens phase, no refunds
|
|
79
|
+
* - postLaunch: normal operation
|
|
80
|
+
* - refund: refund mode active
|
|
81
|
+
*/
|
|
82
|
+
export type WireState = 'preLaunch' | 'postLaunch' | 'refund';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* `role` enum from IDL:
|
|
86
|
+
* Yield operator, batch operator, underwriter, pool operator.
|
|
87
|
+
*/
|
|
88
|
+
export type Role =
|
|
89
|
+
| 'yieldOperator'
|
|
90
|
+
| 'batchOperator'
|
|
91
|
+
| 'underwriter'
|
|
92
|
+
| 'poolOperator';
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Validator reputation from IDL `validatorReputation`.
|
|
96
|
+
*/
|
|
97
|
+
export type ValidatorReputation =
|
|
98
|
+
| 'trusted'
|
|
99
|
+
| 'blacklisted'
|
|
100
|
+
| 'underPerforming';
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Validator lifecycle state from IDL `validatorState`.
|
|
104
|
+
*/
|
|
105
|
+
export type ValidatorState =
|
|
106
|
+
| 'warming'
|
|
107
|
+
| 'notDelegated'
|
|
108
|
+
| 'cooling'
|
|
109
|
+
| 'warm'
|
|
110
|
+
| 'readyToCool';
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* ============================================================
|
|
114
|
+
* Distribution / Index Types
|
|
115
|
+
* ============================================================
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* IDL: `distributionState`
|
|
120
|
+
*
|
|
121
|
+
* Index-based distribution for liqSOL earnings.
|
|
122
|
+
* Note: this is separate from your local `UserRecord` type above.
|
|
123
|
+
*/
|
|
67
124
|
export type DistributionState = {
|
|
125
|
+
/** liqSOL mint (Token-2022) */
|
|
68
126
|
liqsolMint: PublicKey;
|
|
69
|
-
|
|
70
|
-
|
|
127
|
+
|
|
128
|
+
/** Current index (scaled) */
|
|
129
|
+
currentIndex: BN;
|
|
130
|
+
|
|
131
|
+
/** Total shares across all distribution users */
|
|
132
|
+
totalShares: BN;
|
|
133
|
+
|
|
134
|
+
/** Last observed bucket balance (for incremental index updates) */
|
|
135
|
+
lastBucketBalance: BN;
|
|
136
|
+
|
|
137
|
+
/** PDA bumps and cached authorities for bucket/pool */
|
|
71
138
|
bump: number;
|
|
139
|
+
bucketBump: number;
|
|
140
|
+
poolBump: number;
|
|
141
|
+
bucketAuthority: PublicKey;
|
|
142
|
+
poolAuthority: PublicKey;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* IDL: `userRecord`
|
|
147
|
+
*
|
|
148
|
+
* On-chain distribution user record; tracks shares only.
|
|
149
|
+
*/
|
|
150
|
+
export type DistributionUserRecord = {
|
|
151
|
+
shares: BN;
|
|
152
|
+
bump: number;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Simple preview container for “how many pretokens do I get?”
|
|
157
|
+
* Matches the calculateExpectedPretokens math from capital-staking.
|
|
158
|
+
*/
|
|
159
|
+
export interface SharesPreview {
|
|
160
|
+
// Input
|
|
161
|
+
liqsolAmountLamports: BN;
|
|
162
|
+
solPriceUsd: BN; // 1e8 scale
|
|
163
|
+
pretokenPriceUsd: BN; // 1e8 scale
|
|
164
|
+
// Output
|
|
165
|
+
estimatedPretokens: BN; // 1e8 scale
|
|
72
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* ============================================================
|
|
169
|
+
* Global / GlobalState (New IDL Layout)
|
|
170
|
+
* ============================================================
|
|
171
|
+
*/
|
|
73
172
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
173
|
+
/**
|
|
174
|
+
* IDL: `global`
|
|
175
|
+
*
|
|
176
|
+
* Withdraw operator state:
|
|
177
|
+
* - NFT withdrawal receipts
|
|
178
|
+
* - Encumbered funds for pending withdrawals
|
|
179
|
+
*/
|
|
180
|
+
export type Global = {
|
|
181
|
+
/** PDA bump */
|
|
182
|
+
bump: number;
|
|
183
|
+
|
|
184
|
+
/** Authority that can update serviceable epochs / receipts */
|
|
185
|
+
authority: PublicKey;
|
|
186
|
+
|
|
187
|
+
/** liqSOL mint used/burned when processing withdrawals */
|
|
188
|
+
liqsolMint: PublicKey;
|
|
189
|
+
|
|
190
|
+
/** Highest epoch which can currently be serviced/claimed */
|
|
191
|
+
serviceableEpoch: BN;
|
|
192
|
+
|
|
193
|
+
/** Total SOL encumbered (reserved for open withdrawal receipts) */
|
|
194
|
+
totalEncumberedFunds: BN;
|
|
195
|
+
|
|
196
|
+
/** Monotonic counter for generating unique receipt IDs */
|
|
197
|
+
nextReceiptId: BN;
|
|
79
198
|
};
|
|
80
199
|
|
|
200
|
+
/**
|
|
201
|
+
* IDL: `globalState`
|
|
202
|
+
*
|
|
203
|
+
* Wire pretokens + outpost configuration:
|
|
204
|
+
* - Admin / deployment timing
|
|
205
|
+
* - Refund delay
|
|
206
|
+
* - Total staked/purchased liqSOL via outpost
|
|
207
|
+
* - Global share accounting
|
|
208
|
+
* - Protocol shares
|
|
209
|
+
* - Role bonding requirements and warmup
|
|
210
|
+
* - `wireState` lifecycle (preLaunch/postLaunch/refund)
|
|
211
|
+
*/
|
|
81
212
|
export type GlobalState = {
|
|
213
|
+
/** Admin authority for pretokens/outpost config */
|
|
82
214
|
admin: PublicKey;
|
|
83
|
-
|
|
84
|
-
|
|
215
|
+
|
|
216
|
+
/** Deployment timestamp (Unix, seconds) */
|
|
85
217
|
deployedAt: BN;
|
|
218
|
+
|
|
219
|
+
/** Delay before refunds are permitted (seconds) */
|
|
86
220
|
refundDelaySeconds: BN;
|
|
221
|
+
|
|
222
|
+
/** Global pause flag (if true, most ops are disabled) */
|
|
87
223
|
paused: boolean;
|
|
224
|
+
|
|
225
|
+
/** Total liqSOL staked via outpost (principal) */
|
|
88
226
|
totalStakedLiqsol: BN;
|
|
227
|
+
|
|
228
|
+
/** Total liqSOL used to purchase pretokens */
|
|
89
229
|
totalPurchasedLiqsol: BN;
|
|
90
|
-
|
|
230
|
+
|
|
231
|
+
/** Total shares issued to all users (staking + purchases) */
|
|
91
232
|
totalShares: BN;
|
|
233
|
+
|
|
234
|
+
/** Total shares allocated to protocol */
|
|
235
|
+
protocolShares: BN;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Current share-to-liqSOL index
|
|
239
|
+
* (scaled by a fixed INDEX_SCALE constant from the program).
|
|
240
|
+
*/
|
|
92
241
|
currentIndex: BN;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Last observed liqSOL pool balance
|
|
245
|
+
* used for computing incremental yield.
|
|
246
|
+
*/
|
|
93
247
|
lastPoolLiqsolBalance: BN;
|
|
94
|
-
|
|
95
|
-
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Accumulated liqSOL yield available to the protocol
|
|
251
|
+
* (used for `purchaseFromYield`-style flows).
|
|
252
|
+
*/
|
|
253
|
+
yieldAccumulatedLiqsol: BN;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Role principals in liqSOL; index by Role:
|
|
257
|
+
* [YieldOperator, BatchOperator, Underwriter, PoolOperator]
|
|
258
|
+
*/
|
|
259
|
+
rolePrincipals: BN[];
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Global warmup duration in seconds for newly bonded roles.
|
|
263
|
+
* Before this time passes, roles are not considered active.
|
|
264
|
+
*/
|
|
265
|
+
roleWarmupDuration: BN;
|
|
266
|
+
|
|
267
|
+
/** Wire lifecycle state (preLaunch / postLaunch / refund) */
|
|
268
|
+
wireState: WireState;
|
|
269
|
+
|
|
270
|
+
/** PDA bump */
|
|
96
271
|
bump: number;
|
|
97
|
-
}
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* ============================================================
|
|
276
|
+
* Outpost / Pretoken Accounts
|
|
277
|
+
* ============================================================
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* IDL: `outpostAccount`
|
|
282
|
+
*
|
|
283
|
+
* Per-user Wire Outpost state:
|
|
284
|
+
* - Staked liqSOL + shares
|
|
285
|
+
* - Purchased liqSOL + shares
|
|
286
|
+
* - Role bonding principals and bitmap flags
|
|
287
|
+
* - Warmup timestamp
|
|
288
|
+
*/
|
|
289
|
+
export type OutpostAccount = {
|
|
290
|
+
/** User owner of this outpost account */
|
|
291
|
+
user: PublicKey;
|
|
292
|
+
|
|
293
|
+
/** Principal liqSOL staked via outpost */
|
|
294
|
+
stakedLiqsol: BN;
|
|
295
|
+
|
|
296
|
+
/** Shares from staking (index-based accounting) */
|
|
297
|
+
stakedShares: BN;
|
|
298
|
+
|
|
299
|
+
/** Principal liqSOL used for purchases */
|
|
300
|
+
purchasedLiqsol: BN;
|
|
301
|
+
|
|
302
|
+
/** Shares from liqSOL purchases */
|
|
303
|
+
purchasedShares: BN;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* LiqSOL principals locked by roles:
|
|
307
|
+
* [YieldOperator, BatchOperator, Underwriter, PoolOperator]
|
|
308
|
+
*/
|
|
309
|
+
bondedPrincipals: BN[];
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Bitmap of bonded roles (bits 0–3 correspond to Role enum order).
|
|
313
|
+
*/
|
|
314
|
+
bondedRoles: number;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Bitmap of roles that have requested unbonding (bits 0–3).
|
|
318
|
+
*/
|
|
319
|
+
unbondRequested: number;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Warmup end time; roles are not active until this timestamp.
|
|
323
|
+
*/
|
|
324
|
+
warmupEndsAt: BN;
|
|
325
|
+
|
|
326
|
+
/** PDA bump */
|
|
327
|
+
bump: number;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Backwards-compat: old name `WireReceipt` used in SDK now maps
|
|
332
|
+
* directly to the new `OutpostAccount` layout.
|
|
333
|
+
*/
|
|
334
|
+
export type WireReceipt = OutpostAccount;
|
|
98
335
|
|
|
99
|
-
|
|
336
|
+
/**
|
|
337
|
+
* IDL: `userPretokenRecord`
|
|
338
|
+
*
|
|
339
|
+
* Per-user pretoken purchase history:
|
|
340
|
+
* - Total SOL deposited
|
|
341
|
+
* - Total pretokens purchased (8-decimal i128)
|
|
342
|
+
* - Last tranche number & price used
|
|
343
|
+
*/
|
|
344
|
+
export type UserPretokenRecord = {
|
|
100
345
|
user: PublicKey;
|
|
346
|
+
|
|
347
|
+
/** Total SOL deposited for pretokens (unscaled u64) */
|
|
101
348
|
totalSolDeposited: BN;
|
|
102
|
-
|
|
349
|
+
|
|
350
|
+
/** Total pretokens purchased (8-decimal scaled i128) */
|
|
351
|
+
totalPretokensPurchased: BN;
|
|
352
|
+
|
|
353
|
+
/** Last tranche number used for a purchase */
|
|
103
354
|
lastTrancheNumber: BN;
|
|
355
|
+
|
|
356
|
+
/** Last tranche price in USD (8-decimal scaled i128) */
|
|
104
357
|
lastTranchePriceUsd: BN;
|
|
358
|
+
|
|
105
359
|
bump: number;
|
|
106
|
-
}
|
|
360
|
+
};
|
|
107
361
|
|
|
362
|
+
/**
|
|
363
|
+
* IDL: `trancheState`
|
|
364
|
+
*
|
|
365
|
+
* Global tranche configuration and pricing.
|
|
366
|
+
* All price/supply fields use 8-decimal precision (SCALE = 1e8).
|
|
367
|
+
*/
|
|
108
368
|
export type TrancheState = {
|
|
369
|
+
/** Admin authority for tranche parameters */
|
|
109
370
|
admin: PublicKey;
|
|
371
|
+
|
|
372
|
+
/** Current tranche number */
|
|
110
373
|
currentTrancheNumber: BN;
|
|
374
|
+
|
|
375
|
+
/** Remaining supply in the current tranche (8-decimal i128) */
|
|
111
376
|
currentTrancheSupply: BN;
|
|
377
|
+
|
|
378
|
+
/** Current tranche price in USD (8-decimal i128) */
|
|
112
379
|
currentTranchePriceUsd: BN;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
380
|
+
|
|
381
|
+
/** Total pretokens sold across all tranches (8-decimal i128) */
|
|
382
|
+
totalPretokensSold: BN;
|
|
383
|
+
|
|
384
|
+
/** Initial per-tranche supply (8-decimal i128) */
|
|
117
385
|
initialTrancheSupply: BN;
|
|
386
|
+
|
|
387
|
+
/** Supply growth in basis points per tranche */
|
|
118
388
|
supplyGrowthBps: number;
|
|
389
|
+
|
|
390
|
+
/** Price growth in basis points per tranche */
|
|
119
391
|
priceGrowthBps: number;
|
|
392
|
+
|
|
393
|
+
/** Minimum valid SOL/USD price for Chainlink validation (8-decimal i128) */
|
|
120
394
|
minPriceUsd: BN;
|
|
395
|
+
|
|
396
|
+
/** Maximum valid SOL/USD price for Chainlink validation (8-decimal i128) */
|
|
121
397
|
maxPriceUsd: BN;
|
|
398
|
+
|
|
399
|
+
/** Maximum staleness in seconds for Chainlink price data */
|
|
122
400
|
maxStalenessSeconds: BN;
|
|
401
|
+
|
|
402
|
+
/** Chainlink program address */
|
|
123
403
|
chainlinkProgram: PublicKey;
|
|
404
|
+
|
|
405
|
+
/** Chainlink SOL/USD feed address */
|
|
124
406
|
chainlinkFeed: PublicKey;
|
|
125
|
-
bump: number;
|
|
126
|
-
}
|
|
127
407
|
|
|
128
|
-
|
|
129
|
-
user: PublicKey;
|
|
130
|
-
stakedLiqsol: BN;
|
|
131
|
-
stakedShares: BN;
|
|
132
|
-
purchasedLiqsol: BN;
|
|
133
|
-
purchasedShares: BN;
|
|
134
|
-
purchasedWithSol: BN;
|
|
135
|
-
purchasedSolShares: BN;
|
|
408
|
+
/** PDA bump */
|
|
136
409
|
bump: number;
|
|
137
|
-
}
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* ============================================================
|
|
414
|
+
* Pay Rate / Price History
|
|
415
|
+
* ============================================================
|
|
416
|
+
*/
|
|
138
417
|
|
|
418
|
+
/**
|
|
419
|
+
* IDL: `payRateEntry`
|
|
420
|
+
*/
|
|
421
|
+
export type PayRateEntry = {
|
|
422
|
+
/** Unix timestamp for this rate sample */
|
|
423
|
+
timestamp: BN;
|
|
139
424
|
|
|
425
|
+
/** Scaled pay rate (u64; program defines scale) */
|
|
426
|
+
scaledRate: BN;
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* IDL: `payRateHistory`
|
|
431
|
+
*
|
|
432
|
+
* Circular buffer of recent pay rates.
|
|
433
|
+
*/
|
|
434
|
+
export type PayRateHistory = {
|
|
435
|
+
/** Current index in the circular buffer */
|
|
436
|
+
currentIndex: number;
|
|
437
|
+
|
|
438
|
+
/** Total entries ever added (monotonic counter) */
|
|
439
|
+
totalEntriesAdded: BN;
|
|
440
|
+
|
|
441
|
+
/** Buffer of entries (fixed-capacity on-chain) */
|
|
442
|
+
entries: PayRateEntry[];
|
|
443
|
+
|
|
444
|
+
/** Maximum entries the buffer can hold */
|
|
445
|
+
maxEntries: number;
|
|
446
|
+
|
|
447
|
+
/** PDA bump */
|
|
448
|
+
bump: number;
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* IDL: `priceHistory`
|
|
453
|
+
*
|
|
454
|
+
* Circular buffer of recent SOL/USD prices, 8-decimal precision.
|
|
455
|
+
*/
|
|
140
456
|
export type PriceHistory = {
|
|
457
|
+
/** Window size used for moving average, etc. */
|
|
141
458
|
windowSize: number;
|
|
459
|
+
|
|
460
|
+
/** Recent prices (8-decimal scaled i128) */
|
|
142
461
|
prices: BN[];
|
|
462
|
+
|
|
463
|
+
/** Number of valid entries in the buffer */
|
|
143
464
|
count: number;
|
|
465
|
+
|
|
466
|
+
/** Index to write the next price into */
|
|
144
467
|
nextIndex: number;
|
|
468
|
+
|
|
469
|
+
/** PDA bump */
|
|
145
470
|
bump: number;
|
|
146
|
-
}
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* ============================================================
|
|
475
|
+
* Leaderboard Types
|
|
476
|
+
* ============================================================
|
|
477
|
+
*/
|
|
147
478
|
|
|
479
|
+
/**
|
|
480
|
+
* On-chain leaderboard snapshot.
|
|
481
|
+
*
|
|
482
|
+
* IDL account: `leaderboardState`
|
|
483
|
+
*
|
|
484
|
+
* - `scores[i]` is the numeric score for validator with registry index `i`
|
|
485
|
+
* - `sortedIndices` is a permutation of [0..N) giving indices from
|
|
486
|
+
* highest score to lowest.
|
|
487
|
+
* - `voteAccounts[i]` is the vote account pubkey corresponding to
|
|
488
|
+
* validator registry index `i`.
|
|
489
|
+
*/
|
|
490
|
+
export type LeaderboardState = {
|
|
491
|
+
/**
|
|
492
|
+
* Per-validator scores (i64 on-chain).
|
|
493
|
+
* Index corresponds to `registryIndex` in ValidatorRecord.
|
|
494
|
+
*/
|
|
495
|
+
scores: BN[];
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Sorted indices into `scores[]` / `voteAccounts[]`,
|
|
499
|
+
* typically highest score first.
|
|
500
|
+
*/
|
|
501
|
+
sortedIndices: number[]; // u32 on-chain
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Vote accounts for validators. Parallel array to `scores`.
|
|
505
|
+
* `voteAccounts[i]` is the vote account for validator with
|
|
506
|
+
* `registryIndex == i`.
|
|
507
|
+
*/
|
|
508
|
+
voteAccounts: PublicKey[];
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Number of active validators currently tracked in the leaderboard.
|
|
512
|
+
* Only the first `numValidators` entries of the arrays are meaningful.
|
|
513
|
+
*/
|
|
514
|
+
numValidators: number; // u32 on-chain
|
|
515
|
+
|
|
516
|
+
/** PDA bump seed for leaderboardState. */
|
|
517
|
+
bump: number; // u8 on-chain
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Reserved padding / future-proofing on-chain (u64[8]).
|
|
521
|
+
* Not used by client logic, but surfaced for completeness.
|
|
522
|
+
*/
|
|
523
|
+
padding: BN[];
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Per-validator record tying Solana vote account to
|
|
528
|
+
* Wire staking / MEV metadata.
|
|
529
|
+
*
|
|
530
|
+
* IDL account: `validatorRecord`
|
|
531
|
+
*/
|
|
532
|
+
export type ValidatorRecord = {
|
|
533
|
+
/**
|
|
534
|
+
* The validator's Solana vote account.
|
|
535
|
+
*/
|
|
536
|
+
voteAccount: PublicKey;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Index into the global validator registry / leaderboard arrays.
|
|
540
|
+
* This is the index used for `scores[]`, `voteAccounts[]`, etc.
|
|
541
|
+
*/
|
|
542
|
+
registryIndex: number;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Last observed vote credits for this validator,
|
|
546
|
+
* used for rewards / performance accounting.
|
|
547
|
+
*/
|
|
548
|
+
creditsObserved: BN;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Historical commission values over time (e.g., per epoch).
|
|
552
|
+
* Exact semantics depend on on-chain implementation, but this is
|
|
553
|
+
* typically a ring buffer of u8/u16 basis-point values.
|
|
554
|
+
*/
|
|
555
|
+
commissionHistory: number[];
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Current index into `commissionHistory` ring buffer.
|
|
559
|
+
*/
|
|
560
|
+
commissionIndex: number;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Last time (unix timestamp or slot-aligned time) the base
|
|
564
|
+
* commission was updated.
|
|
565
|
+
*/
|
|
566
|
+
lastCommissionUpdate: BN;
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* Last epoch for which this record was updated.
|
|
570
|
+
*/
|
|
571
|
+
epoch: BN;
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Last observed slot for this validator record.
|
|
575
|
+
*/
|
|
576
|
+
slot: BN;
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Whether this validator is operated by a Wire-approved operator.
|
|
580
|
+
* Used for preferential routing / UX labeling.
|
|
581
|
+
*/
|
|
582
|
+
wireOperator: boolean;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Current MEV commission (e.g., bps or percentage).
|
|
586
|
+
*/
|
|
587
|
+
mevCommission: number;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Historical MEV commission values over time.
|
|
591
|
+
*/
|
|
592
|
+
mevCommissionHistory: number[];
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Current index into `mevCommissionHistory` ring buffer.
|
|
596
|
+
*/
|
|
597
|
+
mevCommissionIndex: number;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Last time the MEV commission was updated.
|
|
601
|
+
*/
|
|
602
|
+
lastMevCommissionUpdate: BN;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* PDA bump seed for validatorRecord.
|
|
606
|
+
*/
|
|
607
|
+
bump: number;
|
|
608
|
+
};
|