@wireio/stake 0.1.0 → 0.1.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/README.md +57 -0
- package/lib/stake.browser.js +4623 -3451
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +372 -537
- package/lib/stake.js +4801 -3574
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +4623 -3451
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/solana/idl/liqsol_core.json +4239 -0
- package/src/assets/solana/idl/liqsol_token.json +183 -0
- package/src/assets/solana/idl/validator_leaderboard.json +270 -265
- package/src/assets/solana/types/liqsol_core.ts +4245 -0
- package/src/assets/solana/types/liqsol_token.ts +189 -0
- package/src/assets/solana/types/validator_leaderboard.ts +270 -265
- package/src/index.ts +1 -3
- package/src/networks/ethereum/contract.ts +138 -36
- package/src/networks/ethereum/ethereum.ts +167 -38
- package/src/networks/ethereum/types.ts +32 -1
- package/src/networks/solana/clients/deposit.client.ts +71 -109
- package/src/networks/solana/clients/distribution.client.ts +256 -383
- package/src/networks/solana/clients/leaderboard.client.ts +38 -133
- package/src/networks/solana/constants.ts +214 -130
- package/src/networks/solana/program.ts +25 -38
- package/src/networks/solana/solana.ts +100 -89
- package/src/networks/solana/types.ts +37 -47
- package/src/networks/solana/utils.ts +551 -0
- package/src/scripts/tsconfig.json +17 -0
- package/src/staker/staker.ts +5 -4
- package/src/staker/types.ts +2 -2
- package/src/assets/solana/idl/deposit.json +0 -296
- package/src/assets/solana/idl/distribution.json +0 -768
- package/src/assets/solana/idl/liq_sol_token.json +0 -298
- package/src/assets/solana/idl/mint_helper.json +0 -110
- package/src/assets/solana/idl/read_tracked_balance.json +0 -140
- package/src/assets/solana/idl/stake_controller.json +0 -2149
- package/src/assets/solana/idl/treasury.json +0 -110
- package/src/assets/solana/idl/validator_registry.json +0 -487
- package/src/assets/solana/idl/yield_oracle.json +0 -32
- package/src/assets/solana/types/deposit.ts +0 -302
- package/src/assets/solana/types/distribution.ts +0 -774
- package/src/assets/solana/types/liq_sol_token.ts +0 -304
- package/src/assets/solana/types/mint_helper.ts +0 -116
- package/src/assets/solana/types/read_tracked_balance.ts +0 -146
- package/src/assets/solana/types/stake_controller.ts +0 -2155
- package/src/assets/solana/types/stake_registry.ts +0 -441
- package/src/assets/solana/types/treasury.ts +0 -116
- package/src/assets/solana/types/validator_registry.ts +0 -493
- package/src/assets/solana/types/yield_oracle.ts +0 -38
- package/src/common/utils.ts +0 -9
package/lib/stake.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
+
import * as _wireio_core from '@wireio/core';
|
|
1
2
|
import { PublicKey, ExternalNetwork, ChainID } from '@wireio/core';
|
|
2
3
|
import { BaseSignerWalletAdapter } from '@solana/wallet-adapter-base';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
4
|
+
import * as _solana_web3_js from '@solana/web3.js';
|
|
5
|
+
import { PublicKey as PublicKey$1, Transaction, VersionedTransaction, TokenAmount, Connection, TransactionSignature, Keypair } from '@solana/web3.js';
|
|
6
|
+
import { ethers, BigNumberish, BigNumber, Signer, Contract } from 'ethers';
|
|
5
7
|
import { JsonFragment } from '@ethersproject/abi';
|
|
6
8
|
import { ErrorDescription } from '@ethersproject/abi/lib/interface';
|
|
7
|
-
import { AnchorProvider, Program } from '@coral-xyz/anchor';
|
|
8
|
-
export { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID } from '@solana/spl-token';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Static utility functions for working with Wire Network Staking Protocol.
|
|
12
|
-
*
|
|
13
|
-
* @module utils
|
|
14
|
-
*/
|
|
15
|
-
declare const hi: (name: string) => string;
|
|
9
|
+
import { AnchorProvider, Program, BN } from '@coral-xyz/anchor';
|
|
16
10
|
|
|
17
11
|
interface IStakingClient {
|
|
18
12
|
pubKey: PublicKey;
|
|
@@ -40,7 +34,7 @@ interface Portfolio {
|
|
|
40
34
|
extras?: Record<string, any>;
|
|
41
35
|
}
|
|
42
36
|
type BalanceView = {
|
|
43
|
-
amount:
|
|
37
|
+
amount: BigNumberish;
|
|
44
38
|
decimals: number;
|
|
45
39
|
symbol?: string;
|
|
46
40
|
ata?: PublicKey$1;
|
|
@@ -66,53 +60,96 @@ declare class Staker {
|
|
|
66
60
|
setChain(chainID: ChainID): boolean;
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
declare class EthereumStakingClient {
|
|
63
|
+
declare class EthereumStakingClient implements IStakingClient {
|
|
70
64
|
private config;
|
|
71
65
|
readonly pubKey: PublicKey;
|
|
72
66
|
private readonly provider;
|
|
73
67
|
private readonly signer;
|
|
74
|
-
private readonly
|
|
68
|
+
private readonly contractService;
|
|
69
|
+
get contract(): {
|
|
70
|
+
Stake: ethers.Contract;
|
|
71
|
+
LiqEth: ethers.Contract;
|
|
72
|
+
DepositManager: ethers.Contract;
|
|
73
|
+
LiqEthMint: ethers.Contract;
|
|
74
|
+
LiqEthBurn: ethers.Contract;
|
|
75
|
+
LiqEthTreasury: ethers.Contract;
|
|
76
|
+
LiqEthCommon: ethers.Contract;
|
|
77
|
+
RewardsERC20: ethers.Contract;
|
|
78
|
+
ValidatorBalanceVerifier: ethers.Contract;
|
|
79
|
+
Yield: ethers.Contract;
|
|
80
|
+
Accounting: ethers.Contract;
|
|
81
|
+
StakingModule: ethers.Contract;
|
|
82
|
+
WithdrawalQueue: ethers.Contract;
|
|
83
|
+
WithdrawalVault: ethers.Contract;
|
|
84
|
+
};
|
|
85
|
+
get network(): _wireio_core.ExternalNetwork;
|
|
75
86
|
constructor(config: StakerConfig);
|
|
76
|
-
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Deposit native ETH into the liqETH protocol via DepositManager.
|
|
89
|
+
* @param amount Amount in wei (or something convertible to BigNumber).
|
|
90
|
+
* Keep this as a bigint / string in the caller; avoid JS floats.
|
|
91
|
+
* @returns transaction hash
|
|
92
|
+
*/
|
|
93
|
+
deposit(amount: number | string | bigint | BigNumber): Promise<string>;
|
|
94
|
+
/**
|
|
95
|
+
* Simulate a deposit via callStatic.
|
|
96
|
+
*
|
|
97
|
+
* Useful for pre-flight checks; will throw with the same revert
|
|
98
|
+
* reason as a real tx if it would fail.
|
|
99
|
+
*/
|
|
100
|
+
simulateDeposit(amount: number | string | bigint | BigNumber): Promise<void>;
|
|
101
|
+
private performDeposit;
|
|
102
|
+
/**
|
|
103
|
+
* Build, sign, and submit a single transaction that:
|
|
104
|
+
* - Corrects other users (if needed) to free available balance, then
|
|
105
|
+
* - Registers the caller’s untracked liqSOL.
|
|
106
|
+
*
|
|
107
|
+
* @param amount Optional: register a smaller amount than your full untracked balance.
|
|
108
|
+
* @returns signature string
|
|
109
|
+
*/
|
|
110
|
+
register(amount?: bigint): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Resolve the user's ETH + liqETH balances.
|
|
113
|
+
*
|
|
114
|
+
* native = ETH in wallet
|
|
115
|
+
* actual = liqETH token balance (ERC-20)
|
|
116
|
+
* tracked = liqETH tracked balance (protocol/accounting view)
|
|
117
|
+
*/
|
|
118
|
+
getPortfolio(): Promise<Portfolio>;
|
|
80
119
|
}
|
|
81
120
|
|
|
82
|
-
declare const CONTRACT_NAMES: readonly ["Stake"];
|
|
121
|
+
declare const CONTRACT_NAMES: readonly ["Stake", "LiqEth", "DepositManager", "LiqEthMint", "LiqEthBurn", "LiqEthTreasury", "LiqEthCommon", "RewardsERC20", "ValidatorBalanceVerifier", "Yield", "Accounting", "StakingModule", "WithdrawalQueue", "WithdrawalVault"];
|
|
83
122
|
type ContractName = typeof CONTRACT_NAMES[number];
|
|
84
123
|
type AddressBook = Record<ContractName, string>;
|
|
124
|
+
interface DepositEvent {
|
|
125
|
+
user: string;
|
|
126
|
+
netEth: BigNumber;
|
|
127
|
+
fee: BigNumber;
|
|
128
|
+
shares: BigNumber;
|
|
129
|
+
}
|
|
130
|
+
interface DepositResult {
|
|
131
|
+
/** EVM transaction hash */
|
|
132
|
+
txHash: string;
|
|
133
|
+
/** Full receipt, if you want it */
|
|
134
|
+
receipt: ethers.providers.TransactionReceipt;
|
|
135
|
+
/** Parsed Deposited event, if present */
|
|
136
|
+
deposited?: DepositEvent;
|
|
137
|
+
}
|
|
85
138
|
|
|
86
139
|
type types$1_AddressBook = AddressBook;
|
|
87
140
|
declare const types$1_CONTRACT_NAMES: typeof CONTRACT_NAMES;
|
|
88
141
|
type types$1_ContractName = ContractName;
|
|
142
|
+
type types$1_DepositEvent = DepositEvent;
|
|
143
|
+
type types$1_DepositResult = DepositResult;
|
|
89
144
|
declare namespace types$1 {
|
|
90
145
|
export { types$1_CONTRACT_NAMES as CONTRACT_NAMES };
|
|
91
|
-
export type { types$1_AddressBook as AddressBook, types$1_ContractName as ContractName };
|
|
146
|
+
export type { types$1_AddressBook as AddressBook, types$1_ContractName as ContractName, types$1_DepositEvent as DepositEvent, types$1_DepositResult as DepositResult };
|
|
92
147
|
}
|
|
93
148
|
|
|
94
149
|
/**
|
|
95
150
|
* @module EthereumContractService
|
|
96
151
|
*
|
|
97
152
|
* Provides a unified service for interacting with Ethereum smart contracts using ethers.js.
|
|
98
|
-
*
|
|
99
|
-
* This module includes:
|
|
100
|
-
* - ABI imports for ERC20, ERC721, and ERC1155 token standards.
|
|
101
|
-
* - Address book and contract configuration types.
|
|
102
|
-
* - A service class for managing contract instances, interfaces, and utility methods for read/write access.
|
|
103
|
-
* - Utility for decoding custom errors and events using a combined interface of all known ABIs.
|
|
104
|
-
*
|
|
105
|
-
* @remarks
|
|
106
|
-
* - Update the `ADDRESSES` and `CONTRACTS` objects to match your deployment.
|
|
107
|
-
* - The service supports both read-only and write-enabled contract handles, depending on the presence of a signer.
|
|
108
|
-
* - The `omniInterface` property allows decoding of errors and events across all included ABIs.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```typescript
|
|
112
|
-
* const service = new EthereumContractService({ provider, signer });
|
|
113
|
-
* const stakeContract = service.getContract('Stake');
|
|
114
|
-
* const address = service.getAddress('Stake');
|
|
115
|
-
* ```
|
|
116
153
|
*/
|
|
117
154
|
|
|
118
155
|
declare const ERC20Abi: ({
|
|
@@ -298,69 +335,64 @@ declare class EthereumContractService {
|
|
|
298
335
|
getInterface(name: ContractName): ethers.utils.Interface;
|
|
299
336
|
/** Get live Contract instance */
|
|
300
337
|
getContract(name: ContractName): ethers.Contract;
|
|
301
|
-
/** A unified Interface containing all ABIs
|
|
302
|
-
* to parse custom errors or events. */
|
|
338
|
+
/** A unified Interface containing all ABIs to parse custom errors or events. */
|
|
303
339
|
get omniInterface(): ethers.utils.Interface;
|
|
304
340
|
/** Decode a revert or custom error payload */
|
|
305
341
|
parseError(revertData: string): ErrorDescription;
|
|
306
342
|
}
|
|
307
343
|
|
|
308
344
|
type SolanaTransaction = Transaction | VersionedTransaction;
|
|
309
|
-
|
|
310
|
-
type MismatchCandidate = {
|
|
311
|
-
/** Wallet that owns the ATA (decoded from token account) */
|
|
312
|
-
owner: PublicKey$1;
|
|
313
|
-
/** user_record PDA */
|
|
314
|
-
userRecordPda: PublicKey$1;
|
|
315
|
-
/** user’s ATA for liqSOL */
|
|
345
|
+
type UserRecord = {
|
|
316
346
|
userAta: PublicKey$1;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
347
|
+
trackedBalance: bigint;
|
|
348
|
+
claimBalance: bigint;
|
|
349
|
+
lastClaimTimestamp: bigint;
|
|
350
|
+
bump: number;
|
|
351
|
+
};
|
|
352
|
+
type DistributionState = {
|
|
353
|
+
liqsolMint: PublicKey$1;
|
|
354
|
+
availableBalance: bigint;
|
|
355
|
+
totalTrackedBalance: bigint;
|
|
356
|
+
bump: number;
|
|
357
|
+
};
|
|
358
|
+
type ParsedAccountInfo = {
|
|
359
|
+
extensions: Array<{
|
|
360
|
+
extension: string;
|
|
361
|
+
}>;
|
|
362
|
+
isNative: boolean;
|
|
363
|
+
mint: string;
|
|
364
|
+
owner: string;
|
|
365
|
+
state: string;
|
|
366
|
+
tokenAmount: TokenAmount;
|
|
367
|
+
};
|
|
368
|
+
interface MismatchCandidate {
|
|
369
|
+
owner: PublicKey$1;
|
|
320
370
|
actual: bigint;
|
|
321
|
-
|
|
371
|
+
tracked: bigint;
|
|
322
372
|
delta: bigint;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
type CorrectionPlan = {
|
|
326
|
-
/** selected candidates sorted by delta desc */
|
|
327
|
-
selected: MismatchCandidate[];
|
|
328
|
-
/** total delta we’ll free by correcting selected */
|
|
329
|
-
willFree: bigint;
|
|
330
|
-
/** how much still missing after selection (0 if we can meet the target) */
|
|
373
|
+
}
|
|
374
|
+
interface CorrectRegisterPlan {
|
|
331
375
|
deficit: bigint;
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
/** True if the tx can succeed with current state */
|
|
376
|
+
willFree: bigint;
|
|
377
|
+
selected: MismatchCandidate[];
|
|
378
|
+
}
|
|
379
|
+
interface CorrectRegisterBuildResult {
|
|
380
|
+
needToRegister: boolean;
|
|
338
381
|
canSucceed: boolean;
|
|
339
|
-
/** Explanation if not buildable */
|
|
340
382
|
reason?: string;
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
needToRegister: bigint;
|
|
345
|
-
/** Distribution “availableBalance” before this action */
|
|
346
|
-
availableBefore: bigint;
|
|
347
|
-
/** Candidates we scanned (already sorted by delta desc) */
|
|
348
|
-
candidates: MismatchCandidate[];
|
|
349
|
-
/** Subset we’d correct (maybe empty) */
|
|
350
|
-
plan: CorrectionPlan;
|
|
351
|
-
/** Convenience for caller */
|
|
352
|
-
accounts: {
|
|
353
|
-
selfUserRecordPda: PublicKey$1;
|
|
354
|
-
selfUserAta: PublicKey$1;
|
|
355
|
-
};
|
|
356
|
-
};
|
|
383
|
+
transaction?: Transaction;
|
|
384
|
+
plan: CorrectRegisterPlan;
|
|
385
|
+
}
|
|
357
386
|
|
|
358
|
-
type
|
|
359
|
-
type
|
|
387
|
+
type types_CorrectRegisterBuildResult = CorrectRegisterBuildResult;
|
|
388
|
+
type types_CorrectRegisterPlan = CorrectRegisterPlan;
|
|
389
|
+
type types_DistributionState = DistributionState;
|
|
360
390
|
type types_MismatchCandidate = MismatchCandidate;
|
|
391
|
+
type types_ParsedAccountInfo = ParsedAccountInfo;
|
|
361
392
|
type types_SolanaTransaction = SolanaTransaction;
|
|
393
|
+
type types_UserRecord = UserRecord;
|
|
362
394
|
declare namespace types {
|
|
363
|
-
export type {
|
|
395
|
+
export type { types_CorrectRegisterBuildResult as CorrectRegisterBuildResult, types_CorrectRegisterPlan as CorrectRegisterPlan, types_DistributionState as DistributionState, types_MismatchCandidate as MismatchCandidate, types_ParsedAccountInfo as ParsedAccountInfo, types_SolanaTransaction as SolanaTransaction, types_UserRecord as UserRecord };
|
|
364
396
|
}
|
|
365
397
|
|
|
366
398
|
declare class SolanaStakingClient implements IStakingClient {
|
|
@@ -370,6 +402,7 @@ declare class SolanaStakingClient implements IStakingClient {
|
|
|
370
402
|
anchor: AnchorProvider;
|
|
371
403
|
private depositClient;
|
|
372
404
|
private distributionClient;
|
|
405
|
+
private leaderboardClient;
|
|
373
406
|
get solPubKey(): PublicKey$1;
|
|
374
407
|
get network(): ExternalNetwork;
|
|
375
408
|
constructor(config: StakerConfig);
|
|
@@ -383,8 +416,9 @@ declare class SolanaStakingClient implements IStakingClient {
|
|
|
383
416
|
/**
|
|
384
417
|
* Optional: fetch your Distribution program user record
|
|
385
418
|
* (often contains per-user deposit/claim state).
|
|
419
|
+
* @returns UserRecord or null
|
|
386
420
|
*/
|
|
387
|
-
getUserRecord(): Promise<
|
|
421
|
+
getUserRecord(): Promise<UserRecord | null>;
|
|
388
422
|
getProtocolFee(): void;
|
|
389
423
|
/**
|
|
390
424
|
* Build, sign, and submit a single transaction that:
|
|
@@ -417,496 +451,297 @@ interface TxResult {
|
|
|
417
451
|
}
|
|
418
452
|
|
|
419
453
|
/**
|
|
420
|
-
*
|
|
454
|
+
* ---------------------------------------------------------------------------
|
|
455
|
+
* PROGRAM IDS
|
|
456
|
+
* ---------------------------------------------------------------------------
|
|
421
457
|
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
458
|
+
* These should match:
|
|
459
|
+
* - `metadata.address` in your Anchor IDLs under src/assets/solana/idl/*.json
|
|
460
|
+
* - The program IDs printed by your deploy scripts
|
|
424
461
|
*/
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
"version": "0.1.0";
|
|
430
|
-
"spec": "0.1.0";
|
|
431
|
-
"description": "Created with Anchor";
|
|
432
|
-
};
|
|
433
|
-
"instructions": [
|
|
434
|
-
{
|
|
435
|
-
"name": "deposit";
|
|
436
|
-
"discriminator": [
|
|
437
|
-
242,
|
|
438
|
-
35,
|
|
439
|
-
198,
|
|
440
|
-
137,
|
|
441
|
-
82,
|
|
442
|
-
225,
|
|
443
|
-
242,
|
|
444
|
-
182
|
|
445
|
-
];
|
|
446
|
-
"accounts": [
|
|
447
|
-
{
|
|
448
|
-
"name": "user";
|
|
449
|
-
"writable": true;
|
|
450
|
-
"signer": true;
|
|
451
|
-
},
|
|
452
|
-
{
|
|
453
|
-
"name": "programAuthority";
|
|
454
|
-
"writable": true;
|
|
455
|
-
"pda": {
|
|
456
|
-
"seeds": [
|
|
457
|
-
{
|
|
458
|
-
"kind": "const";
|
|
459
|
-
"value": [
|
|
460
|
-
112,
|
|
461
|
-
114,
|
|
462
|
-
111,
|
|
463
|
-
103,
|
|
464
|
-
114,
|
|
465
|
-
97,
|
|
466
|
-
109,
|
|
467
|
-
95,
|
|
468
|
-
97,
|
|
469
|
-
117,
|
|
470
|
-
116,
|
|
471
|
-
104,
|
|
472
|
-
111,
|
|
473
|
-
114,
|
|
474
|
-
105,
|
|
475
|
-
116,
|
|
476
|
-
121
|
|
477
|
-
];
|
|
478
|
-
}
|
|
479
|
-
];
|
|
480
|
-
};
|
|
481
|
-
},
|
|
482
|
-
{
|
|
483
|
-
"name": "systemProgram";
|
|
484
|
-
"address": "11111111111111111111111111111111";
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
"name": "tokenProgram";
|
|
488
|
-
},
|
|
489
|
-
{
|
|
490
|
-
"name": "associatedTokenProgram";
|
|
491
|
-
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
"name": "stakeControllerProgram";
|
|
495
|
-
"address": "4Ab1SwV6RPUN5Btnf95qvQCyNVR3iHnXjnMYaKsgimTp";
|
|
496
|
-
},
|
|
497
|
-
{
|
|
498
|
-
"name": "liqsolProgram";
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
"name": "payRateHistory";
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
"name": "stakeProgram";
|
|
505
|
-
"address": "Stake11111111111111111111111111111111111111";
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
"name": "distributionProgram";
|
|
509
|
-
"address": "26LF4typrWwBapujpvUPFpdfs4pBb6RwcWoBBy7Awf5j";
|
|
510
|
-
},
|
|
511
|
-
{
|
|
512
|
-
"name": "liqsolMint";
|
|
513
|
-
"writable": true;
|
|
514
|
-
},
|
|
515
|
-
{
|
|
516
|
-
"name": "userAta";
|
|
517
|
-
"writable": true;
|
|
518
|
-
"pda": {
|
|
519
|
-
"seeds": [
|
|
520
|
-
{
|
|
521
|
-
"kind": "account";
|
|
522
|
-
"path": "user";
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
"kind": "account";
|
|
526
|
-
"path": "tokenProgram";
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
"kind": "account";
|
|
530
|
-
"path": "liqsolMint";
|
|
531
|
-
}
|
|
532
|
-
];
|
|
533
|
-
"program": {
|
|
534
|
-
"kind": "const";
|
|
535
|
-
"value": [
|
|
536
|
-
140,
|
|
537
|
-
151,
|
|
538
|
-
37,
|
|
539
|
-
143,
|
|
540
|
-
78,
|
|
541
|
-
36,
|
|
542
|
-
137,
|
|
543
|
-
241,
|
|
544
|
-
187,
|
|
545
|
-
61,
|
|
546
|
-
16,
|
|
547
|
-
41,
|
|
548
|
-
20,
|
|
549
|
-
142,
|
|
550
|
-
13,
|
|
551
|
-
131,
|
|
552
|
-
11,
|
|
553
|
-
90,
|
|
554
|
-
19,
|
|
555
|
-
153,
|
|
556
|
-
218,
|
|
557
|
-
255,
|
|
558
|
-
16,
|
|
559
|
-
132,
|
|
560
|
-
4,
|
|
561
|
-
142,
|
|
562
|
-
123,
|
|
563
|
-
216,
|
|
564
|
-
219,
|
|
565
|
-
233,
|
|
566
|
-
248,
|
|
567
|
-
89
|
|
568
|
-
];
|
|
569
|
-
};
|
|
570
|
-
};
|
|
571
|
-
},
|
|
572
|
-
{
|
|
573
|
-
"name": "liqsolMintAuthority";
|
|
574
|
-
},
|
|
575
|
-
{
|
|
576
|
-
"name": "reservePool";
|
|
577
|
-
"writable": true;
|
|
578
|
-
},
|
|
579
|
-
{
|
|
580
|
-
"name": "vault";
|
|
581
|
-
"writable": true;
|
|
582
|
-
},
|
|
583
|
-
{
|
|
584
|
-
"name": "ephemeralStake";
|
|
585
|
-
"writable": true;
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
"name": "controllerState";
|
|
589
|
-
"writable": true;
|
|
590
|
-
},
|
|
591
|
-
{
|
|
592
|
-
"name": "globalStakeInfo";
|
|
593
|
-
"writable": true;
|
|
594
|
-
},
|
|
595
|
-
{
|
|
596
|
-
"name": "bucketAuthority";
|
|
597
|
-
"pda": {
|
|
598
|
-
"seeds": [
|
|
599
|
-
{
|
|
600
|
-
"kind": "const";
|
|
601
|
-
"value": [
|
|
602
|
-
108,
|
|
603
|
-
105,
|
|
604
|
-
113,
|
|
605
|
-
115,
|
|
606
|
-
111,
|
|
607
|
-
108,
|
|
608
|
-
95,
|
|
609
|
-
98,
|
|
610
|
-
117,
|
|
611
|
-
99,
|
|
612
|
-
107,
|
|
613
|
-
101,
|
|
614
|
-
116
|
|
615
|
-
];
|
|
616
|
-
}
|
|
617
|
-
];
|
|
618
|
-
"program": {
|
|
619
|
-
"kind": "account";
|
|
620
|
-
"path": "stakeControllerProgram";
|
|
621
|
-
};
|
|
622
|
-
};
|
|
623
|
-
},
|
|
624
|
-
{
|
|
625
|
-
"name": "bucketTokenAccount";
|
|
626
|
-
"docs": [
|
|
627
|
-
"The bucket's associated token account"
|
|
628
|
-
];
|
|
629
|
-
"writable": true;
|
|
630
|
-
},
|
|
631
|
-
{
|
|
632
|
-
"name": "userRecord";
|
|
633
|
-
"writable": true;
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
"name": "distributionState";
|
|
637
|
-
"writable": true;
|
|
638
|
-
},
|
|
639
|
-
{
|
|
640
|
-
"name": "instructionsSysvar";
|
|
641
|
-
"address": "Sysvar1nstructions1111111111111111111111111";
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
"name": "clock";
|
|
645
|
-
"address": "SysvarC1ock11111111111111111111111111111111";
|
|
646
|
-
},
|
|
647
|
-
{
|
|
648
|
-
"name": "stakeHistory";
|
|
649
|
-
"address": "SysvarStakeHistory1111111111111111111111111";
|
|
650
|
-
},
|
|
651
|
-
{
|
|
652
|
-
"name": "rent";
|
|
653
|
-
"address": "SysvarRent111111111111111111111111111111111";
|
|
654
|
-
}
|
|
655
|
-
];
|
|
656
|
-
"args": [
|
|
657
|
-
{
|
|
658
|
-
"name": "amount";
|
|
659
|
-
"type": "u64";
|
|
660
|
-
},
|
|
661
|
-
{
|
|
662
|
-
"name": "seed";
|
|
663
|
-
"type": "u32";
|
|
664
|
-
}
|
|
665
|
-
];
|
|
666
|
-
}
|
|
667
|
-
];
|
|
668
|
-
"errors": [
|
|
669
|
-
{
|
|
670
|
-
"code": 6000;
|
|
671
|
-
"name": "depositTooSmall";
|
|
672
|
-
"msg": "Deposit amount is below minimum required";
|
|
673
|
-
},
|
|
674
|
-
{
|
|
675
|
-
"code": 6001;
|
|
676
|
-
"name": "notInitialized";
|
|
677
|
-
"msg": "Deposit Router not initialized";
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
"code": 6002;
|
|
681
|
-
"name": "invalidAuthority";
|
|
682
|
-
"msg": "Invalid authority";
|
|
683
|
-
},
|
|
684
|
-
{
|
|
685
|
-
"code": 6003;
|
|
686
|
-
"name": "insufficientFunds";
|
|
687
|
-
"msg": "Insufficient funds";
|
|
688
|
-
},
|
|
689
|
-
{
|
|
690
|
-
"code": 6004;
|
|
691
|
-
"name": "overflow";
|
|
692
|
-
"msg": "Arithmetic overflow";
|
|
693
|
-
},
|
|
694
|
-
{
|
|
695
|
-
"code": 6005;
|
|
696
|
-
"name": "calculationFailure";
|
|
697
|
-
"msg": "Calculation failure";
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
"code": 6006;
|
|
701
|
-
"name": "nothingToMint";
|
|
702
|
-
"msg": "Cannot mint zero tokens";
|
|
703
|
-
},
|
|
704
|
-
{
|
|
705
|
-
"code": 6007;
|
|
706
|
-
"name": "invalidAccount";
|
|
707
|
-
"msg": "Invalid account provided";
|
|
708
|
-
},
|
|
709
|
-
{
|
|
710
|
-
"code": 6008;
|
|
711
|
-
"name": "insufficientFundsForStake";
|
|
712
|
-
"msg": "Insufficient funds remaining after reserving fees to proceed with staking";
|
|
713
|
-
},
|
|
714
|
-
{
|
|
715
|
-
"code": 6009;
|
|
716
|
-
"name": "unauthorizedProgram";
|
|
717
|
-
"msg": "Unauthorized program attempting to call this instruction";
|
|
718
|
-
}
|
|
719
|
-
];
|
|
462
|
+
declare const PROGRAM_IDS: {
|
|
463
|
+
readonly LIQSOL_CORE: PublicKey$1;
|
|
464
|
+
readonly LIQSOL_TOKEN: PublicKey$1;
|
|
465
|
+
readonly VALIDATOR_LEADERBOARD: PublicKey$1;
|
|
720
466
|
};
|
|
467
|
+
declare const LIQSOL_CORE: PublicKey$1;
|
|
468
|
+
declare const LIQSOL_TOKEN: PublicKey$1;
|
|
469
|
+
declare const VALIDATOR_LEADERBOARD: PublicKey$1;
|
|
470
|
+
/**
|
|
471
|
+
* ---------------------------------------------------------------------------
|
|
472
|
+
* PDA SEEDS (must match on-chain programs)
|
|
473
|
+
* ---------------------------------------------------------------------------
|
|
474
|
+
*
|
|
475
|
+
* These strings are baked into the on-chain programs and are already used in
|
|
476
|
+
* your test utils. We centralize them here so all clients share them.
|
|
477
|
+
*/
|
|
478
|
+
declare const PDA_SEEDS: {
|
|
479
|
+
readonly DEPOSIT_AUTHORITY: "deposit_authority";
|
|
480
|
+
readonly VAULT: "vault";
|
|
481
|
+
readonly RESERVE_POOL: "reserve_pool";
|
|
482
|
+
readonly STAKE_CONTROLLER_STATE: "stake_controller";
|
|
483
|
+
readonly PAYOUT_STATE: "payout-state";
|
|
484
|
+
readonly LIQSOL_MINT: "liqsol_mint";
|
|
485
|
+
readonly LIQSOL_MINT_AUTHORITY: "mint_authority";
|
|
486
|
+
readonly BUCKET_AUTHORITY: "liqsol_bucket";
|
|
487
|
+
readonly DISTRIBUTION_STATE: "distribution_state";
|
|
488
|
+
readonly USER_RECORD: "user_record";
|
|
489
|
+
readonly PAY_RATE_HISTORY: "pay_rate_history";
|
|
490
|
+
readonly LEADERBOARD_STATE: "leaderboard_state";
|
|
491
|
+
readonly VALIDATOR_RECORD: "validator";
|
|
492
|
+
readonly GLOBAL_STAKE_INFO: "global_stake_info";
|
|
493
|
+
};
|
|
494
|
+
/**
|
|
495
|
+
* Helpers for PDA derivation so clients don’t duplicate logic.
|
|
496
|
+
*/
|
|
497
|
+
declare const deriveLiqsolMintPda: () => PublicKey$1;
|
|
498
|
+
declare const deriveLiqsolMintAuthorityPda: () => PublicKey$1;
|
|
499
|
+
declare const deriveDepositAuthorityPda: () => PublicKey$1;
|
|
500
|
+
declare const deriveVaultPda: () => PublicKey$1;
|
|
501
|
+
declare const deriveReservePoolPda: () => PublicKey$1;
|
|
502
|
+
declare const deriveStakeControllerStatePda: () => PublicKey$1;
|
|
503
|
+
declare const derivePayoutStatePda: () => PublicKey$1;
|
|
504
|
+
declare const deriveBucketAuthorityPda: () => PublicKey$1;
|
|
505
|
+
declare const deriveDistributionStatePda: () => PublicKey$1;
|
|
506
|
+
declare const deriveUserRecordPda: (user: PublicKey$1) => PublicKey$1;
|
|
507
|
+
declare const derivePayRateHistoryPda: () => PublicKey$1;
|
|
508
|
+
declare const deriveLeaderboardStatePda: () => PublicKey$1;
|
|
509
|
+
declare const deriveValidatorRecordPda: (voteAccount: PublicKey$1) => PublicKey$1;
|
|
510
|
+
/**
|
|
511
|
+
* Stake controller vault PDA (reserve pool SOL vault).
|
|
512
|
+
* This is the same as VAULT, but named more explicitly for SDK callers.
|
|
513
|
+
*/
|
|
514
|
+
declare const deriveStakeControllerVaultPda: () => PublicKey$1;
|
|
515
|
+
/**
|
|
516
|
+
* Ephemeral stake account address used per-deposit.
|
|
517
|
+
* On-chain convention: seed = `ephemeral_<u32>` under StakeProgram.programId.
|
|
518
|
+
*/
|
|
519
|
+
declare const deriveEphemeralStakeAddress: (user: PublicKey$1, seed: any) => Promise<PublicKey$1>;
|
|
520
|
+
/**
|
|
521
|
+
* ---------------------------------------------------------------------------
|
|
522
|
+
* ECONOMICS & MATH CONSTANTS
|
|
523
|
+
* ---------------------------------------------------------------------------
|
|
524
|
+
*/
|
|
525
|
+
declare const PAY_RATE_SCALE_FACTOR: bigint;
|
|
526
|
+
declare const DEFAULT_AVERAGE_PAY_RATE: bigint;
|
|
527
|
+
declare const DEFAULT_PAY_RATE_LOOKBACK = 5;
|
|
528
|
+
declare const EPHEMERAL_RENT_EXEMPTION = 2282880;
|
|
529
|
+
declare const LAMPORTS_PER_SOL = 1000000000;
|
|
530
|
+
declare const lamportsToSol: (lamports: number | bigint) => number;
|
|
531
|
+
declare const solToLamports: (sol: number) => number;
|
|
532
|
+
/**
|
|
533
|
+
* ---------------------------------------------------------------------------
|
|
534
|
+
* CLUSTER / ENVIRONMENT CONFIG (optional but handy)
|
|
535
|
+
* ---------------------------------------------------------------------------
|
|
536
|
+
*/
|
|
537
|
+
type SolanaCluster = 'localnet' | 'devnet' | 'mainnet';
|
|
721
538
|
|
|
722
|
-
declare
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
declare
|
|
749
|
-
|
|
750
|
-
declare
|
|
751
|
-
|
|
539
|
+
declare function getLiqsolCoreProgram(connection: Connection): Program;
|
|
540
|
+
interface DepositAccounts {
|
|
541
|
+
user: PublicKey$1;
|
|
542
|
+
depositAuthority: PublicKey$1;
|
|
543
|
+
liqsolMint: PublicKey$1;
|
|
544
|
+
liqsolMintAuthority: PublicKey$1;
|
|
545
|
+
userAta: PublicKey$1;
|
|
546
|
+
stakeControllerVault: PublicKey$1;
|
|
547
|
+
stakeControllerReservePool: PublicKey$1;
|
|
548
|
+
stakeControllerState: PublicKey$1;
|
|
549
|
+
payoutState: PublicKey$1;
|
|
550
|
+
bucketAuthority: PublicKey$1;
|
|
551
|
+
bucketTokenAccount: PublicKey$1;
|
|
552
|
+
distributionState: PublicKey$1;
|
|
553
|
+
userRecord: PublicKey$1;
|
|
554
|
+
payRateHistory: PublicKey$1;
|
|
555
|
+
ephemeralStake: PublicKey$1;
|
|
556
|
+
ephemeralSeed: string;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Build a complete DepositAccounts set for a given user, matching the
|
|
560
|
+
* on-chain PDAs used by the liqSOL core program.
|
|
561
|
+
*
|
|
562
|
+
* The optional `seed` lets you make deposit flows replayable/deterministic.
|
|
563
|
+
* If omitted, a random u32 seed is generated.
|
|
564
|
+
*/
|
|
565
|
+
declare function buildDepositAccounts(connection: Connection, user: PublicKey$1): Promise<DepositAccounts>;
|
|
566
|
+
declare function getUserLiqSolBalance(connection: Connection, user: PublicKey$1): Promise<number>;
|
|
567
|
+
declare function getBucketLiqSolBalance(connection: Connection): Promise<number>;
|
|
568
|
+
declare function getReservePoolBalance(connection: Connection): Promise<number>;
|
|
569
|
+
/**
|
|
570
|
+
* Raw account info for the stake_controller state (Anchor decode is left
|
|
571
|
+
* to the caller so the SDK can stay IDL-agnostic at this layer).
|
|
572
|
+
*/
|
|
573
|
+
declare function getStakeControllerStateRaw(connection: Connection): Promise<Uint8Array | null>;
|
|
574
|
+
/**
|
|
575
|
+
* Raw account info for the payout-state account.
|
|
576
|
+
*/
|
|
577
|
+
declare function getPayoutStateRaw(connection: Connection): Promise<Uint8Array | null>;
|
|
578
|
+
/**
|
|
579
|
+
* Raw account info for a user's distribution user_record.
|
|
580
|
+
*/
|
|
581
|
+
declare function getUserRecordRaw(connection: Connection, user: PublicKey$1): Promise<Uint8Array | null>;
|
|
582
|
+
declare function getAveragePayRate(connection: Connection, lookback?: number): Promise<bigint>;
|
|
583
|
+
/**
|
|
584
|
+
* On-chain fee formula:
|
|
585
|
+
* fee = (average_pay_rate * 4 * deposit_amount_lamports) / 10^12
|
|
586
|
+
*/
|
|
587
|
+
declare function calculateExpectedFee(depositAmountLamports: BN, averagePayRate: BN): BN;
|
|
752
588
|
/**
|
|
753
|
-
*
|
|
589
|
+
* Convenience helper to preview how a deposit splits between user + bucket
|
|
590
|
+
* and how much goes into the reserve, assuming the simple model:
|
|
754
591
|
*
|
|
592
|
+
* - userLiqSol = amount - fee + EPHEMERAL_RENT_EXEMPTION
|
|
593
|
+
* - bucketLiqSol = fee
|
|
594
|
+
* - reserveLamports = amount + EPHEMERAL_RENT_EXEMPTION
|
|
755
595
|
*/
|
|
596
|
+
declare function previewDepositEffects(params: {
|
|
597
|
+
depositAmountLamports: BN;
|
|
598
|
+
averagePayRate: BN;
|
|
599
|
+
rentExemptionLamports?: number;
|
|
600
|
+
}): {
|
|
601
|
+
feeLamports: BN;
|
|
602
|
+
userLiqSolLamports: BN;
|
|
603
|
+
bucketLiqSolLamports: BN;
|
|
604
|
+
reserveIncreaseLamports: BN;
|
|
605
|
+
};
|
|
606
|
+
type EpochSnapshot = {
|
|
607
|
+
epoch: number;
|
|
608
|
+
slot: number;
|
|
609
|
+
firstSlot: number;
|
|
610
|
+
slotsInEpoch: number;
|
|
611
|
+
slotMs: number;
|
|
612
|
+
};
|
|
613
|
+
declare function getEpochSnapshot(connection: Connection): Promise<EpochSnapshot>;
|
|
614
|
+
declare function msToEpochEnd(snapshot: EpochSnapshot): number;
|
|
615
|
+
/**
|
|
616
|
+
* Generic "execute around epoch boundaries" helper:
|
|
617
|
+
*
|
|
618
|
+
* - If current progress is within [early, late], run immediately.
|
|
619
|
+
* - If too early, sleep until `early` percentage into the epoch.
|
|
620
|
+
* - If too late, sleep until `early` percentage into the *next* epoch.
|
|
621
|
+
*
|
|
622
|
+
* This is generic; you can wrap any instruction builder in here (including
|
|
623
|
+
* deposit flows) without baking in program-specific logic.
|
|
624
|
+
*/
|
|
625
|
+
declare function scheduledInstruction<T>(connection: Connection, config: ScheduleConfig, instruction: () => Promise<T>): Promise<T>;
|
|
626
|
+
declare function getErrorMessage(error: any): string;
|
|
627
|
+
declare function generateRandomDepositAmount(minSol?: number, maxSol?: number): BN;
|
|
628
|
+
declare function generateTestKeypair(): Keypair;
|
|
629
|
+
declare function airdropSol(connection: Connection, publicKey: PublicKey$1, amountSol: number): Promise<void>;
|
|
630
|
+
declare function waitForConfirmation(connection: Connection, signature: string): Promise<void>;
|
|
631
|
+
declare function sleep(ms: number): Promise<void>;
|
|
632
|
+
/**
|
|
633
|
+
* Simple helper used in tests: wait until safe zone, no-op.
|
|
634
|
+
*/
|
|
635
|
+
declare function waitUntilSafeToExecuteFunction(connection: Connection, config?: ScheduleConfig): Promise<void>;
|
|
636
|
+
interface ScheduleConfig {
|
|
637
|
+
early?: number;
|
|
638
|
+
late?: number;
|
|
639
|
+
}
|
|
640
|
+
|
|
756
641
|
declare class DepositClient {
|
|
757
642
|
private provider;
|
|
758
|
-
private
|
|
643
|
+
private program;
|
|
759
644
|
constructor(provider: AnchorProvider);
|
|
760
|
-
|
|
761
|
-
* Build the deposit transaction (compute-budget bump + deposit Ix).
|
|
762
|
-
* Returns the Transaction and the derived ephemeral stake pubkey.
|
|
763
|
-
*/
|
|
764
|
-
buildDepositTx(user: PublicKey$1, amount: number): Promise<{
|
|
645
|
+
buildDepositTx(user: PublicKey$1, lamports: number): Promise<{
|
|
765
646
|
transaction: Transaction;
|
|
766
|
-
|
|
767
|
-
}>;
|
|
768
|
-
/** Simulate a transaction (dry-run). */
|
|
769
|
-
simulate(tx: Transaction): Promise<{
|
|
770
|
-
err: any;
|
|
771
|
-
unitsConsumed: number;
|
|
647
|
+
ephemeralStake: PublicKey$1;
|
|
772
648
|
}>;
|
|
773
|
-
/** Build + send. Returns confirmed signature. */
|
|
774
|
-
deposit(user: PublicKey$1, amount: number, signers?: Signer$1[]): Promise<TransactionSignature>;
|
|
775
649
|
}
|
|
776
650
|
|
|
651
|
+
/**
|
|
652
|
+
* Distribution client – wraps the distribution portion of the liqsol_core
|
|
653
|
+
* program. Responsible for:
|
|
654
|
+
* - Reading DistributionState + UserRecord
|
|
655
|
+
* - Computing mismatch candidates (tracked > actual)
|
|
656
|
+
* - Building a "correct then register" transaction for the caller
|
|
657
|
+
*
|
|
658
|
+
* Aligned with the on-chain `update_user` script:
|
|
659
|
+
* - Single `updateUser()` entrypoint that:
|
|
660
|
+
* * Can create userRecord if missing
|
|
661
|
+
* * Reconciles tracked vs actual using user, userAta, bucket, pay-rate
|
|
662
|
+
*/
|
|
777
663
|
declare class DistributionClient {
|
|
778
664
|
private provider;
|
|
779
|
-
private
|
|
665
|
+
private program;
|
|
780
666
|
constructor(provider: AnchorProvider);
|
|
781
|
-
|
|
782
|
-
private get program();
|
|
783
|
-
/**
|
|
784
|
-
* Fetch Distribution global state.
|
|
785
|
-
*/
|
|
786
|
-
getDistributionState(): Promise<any>;
|
|
667
|
+
get connection(): _solana_web3_js.Connection;
|
|
787
668
|
/**
|
|
788
|
-
* Fetch
|
|
669
|
+
* Fetch the global distribution state account.
|
|
789
670
|
*/
|
|
790
|
-
|
|
671
|
+
getDistributionState(): Promise<DistributionState | null>;
|
|
791
672
|
/**
|
|
792
|
-
*
|
|
793
|
-
* Returns (amount, decimals).
|
|
794
|
-
* @default decimals=9
|
|
673
|
+
* Fetch a user's distribution userRecord (or null if missing).
|
|
795
674
|
*/
|
|
796
|
-
|
|
797
|
-
amount: bigint;
|
|
798
|
-
decimals: number;
|
|
799
|
-
}>;
|
|
800
|
-
/**
|
|
801
|
-
* Read *actual* liqSOL token balance (ATA) for a user.
|
|
802
|
-
* If user has no ATA yet, returns 0.
|
|
803
|
-
* @returns { amount, decimals, ata }
|
|
804
|
-
*/
|
|
805
|
-
getActualBalance(user: PublicKey$1): Promise<{
|
|
806
|
-
amount: bigint;
|
|
807
|
-
decimals: number;
|
|
808
|
-
ata: PublicKey$1;
|
|
809
|
-
}>;
|
|
675
|
+
getUserRecord(user: PublicKey$1): Promise<UserRecord | null>;
|
|
810
676
|
/**
|
|
811
|
-
*
|
|
812
|
-
*
|
|
813
|
-
*
|
|
814
|
-
* Returns the tx signature.
|
|
677
|
+
* Helper: get actual liqSOL balances for all token holders.
|
|
678
|
+
*
|
|
679
|
+
* Returns a map: owner (base58) -> actual balance (BigInt)
|
|
815
680
|
*/
|
|
681
|
+
private getActualBalancesByOwner;
|
|
816
682
|
/**
|
|
817
|
-
*
|
|
818
|
-
*
|
|
683
|
+
* Helper: get tracked balances from all userRecord accounts,
|
|
684
|
+
* keyed by *actual wallet owner*, not the userRecord PDA.
|
|
685
|
+
*
|
|
686
|
+
* userRecord struct:
|
|
687
|
+
* - userAta: pubkey
|
|
688
|
+
* - trackedBalance: u64
|
|
689
|
+
* - claimBalance: u64
|
|
690
|
+
* - lastClaimTimestamp: i64
|
|
691
|
+
* - bump: u8
|
|
819
692
|
*/
|
|
820
|
-
|
|
821
|
-
/** Build-only variant (returns the IX) so you can batch. */
|
|
822
|
-
buildUpdateUserIx(targetUser: PublicKey$1): Promise<TransactionInstruction>;
|
|
693
|
+
private getTrackedBalances;
|
|
823
694
|
/**
|
|
824
|
-
*
|
|
825
|
-
*
|
|
695
|
+
* Discover all mismatch candidates where tracked > actual.
|
|
696
|
+
*
|
|
697
|
+
* - actual balances are derived from token accounts for the liqSOL mint
|
|
698
|
+
* - tracked balances come from Distribution.userRecord
|
|
826
699
|
*/
|
|
827
|
-
|
|
700
|
+
private deriveMismatchCandidates;
|
|
828
701
|
/**
|
|
829
|
-
*
|
|
830
|
-
*
|
|
702
|
+
* Canonical helper to build an `updateUser` instruction for a given user,
|
|
703
|
+
* matching the standalone update-user.ts script.
|
|
831
704
|
*/
|
|
832
|
-
|
|
833
|
-
/** Single prep path used by both send & build. */
|
|
834
|
-
private prepareUpdateUser;
|
|
705
|
+
private buildUpdateUserIx;
|
|
835
706
|
/**
|
|
836
|
-
* Build
|
|
837
|
-
*
|
|
838
|
-
*
|
|
839
|
-
*
|
|
707
|
+
* Build the "correct & register" transaction.
|
|
708
|
+
*
|
|
709
|
+
* - Fetches DistributionState + all userRecords + token holders
|
|
710
|
+
* - Computes caller's untracked amount (actual - tracked)
|
|
711
|
+
* - If DistributionState.availableBalance already covers that, we only
|
|
712
|
+
* send updateUser(caller).
|
|
713
|
+
* - Otherwise we select top mismatch candidates until their freed deltas
|
|
714
|
+
* cover the shortfall, then build updateUser(target) for each,
|
|
715
|
+
* followed by updateUser(caller).
|
|
840
716
|
*
|
|
841
|
-
*
|
|
842
|
-
*
|
|
717
|
+
* NOTE:
|
|
718
|
+
* - This no longer uses a separate updateSpecificUser; the single
|
|
719
|
+
* updateUser entrypoint accepts any `user` as long as authority/payer
|
|
720
|
+
* are valid, per your script.
|
|
843
721
|
*/
|
|
844
722
|
buildCorrectRegisterTx(opts?: {
|
|
845
|
-
/** optional override of computed mismatch; may be positive (register) or negative (self-correct) */
|
|
846
723
|
amount?: bigint;
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
}): Promise<CorrectAndRegisterBuild>;
|
|
850
|
-
/**
|
|
851
|
-
* Fetch all distribution user records and turn them into mismatch candidates:
|
|
852
|
-
* rows where `tracked > actual` (delta > 0). Sorted by largest delta first.
|
|
853
|
-
*
|
|
854
|
-
* NOTE: This reads each user’s token account (`getAccount`) to recover
|
|
855
|
-
* the owner and actual balance — simpler and reliable for Token-2022 ATAs.
|
|
856
|
-
*/
|
|
857
|
-
fetchMismatchCandidates(): Promise<MismatchCandidate[]>;
|
|
858
|
-
/**
|
|
859
|
-
* Given a required amount to free (in base units), choose the
|
|
860
|
-
* smallest prefix of candidates (already sorted desc) that can cover it.
|
|
861
|
-
*/
|
|
862
|
-
chooseCandidatesFor(required: bigint, candidates: MismatchCandidate[]): CorrectionPlan;
|
|
724
|
+
maxCandidates?: number;
|
|
725
|
+
}): Promise<CorrectRegisterBuildResult>;
|
|
863
726
|
}
|
|
864
727
|
|
|
865
|
-
|
|
728
|
+
/**
|
|
729
|
+
* Simple read client for the validator_leaderboard program.
|
|
730
|
+
*
|
|
731
|
+
* Adjust account names/fields to match your IDL (state, validatorRecord, etc).
|
|
732
|
+
*/
|
|
733
|
+
declare class LeaderboardClient {
|
|
866
734
|
private provider;
|
|
867
|
-
private
|
|
735
|
+
private program;
|
|
868
736
|
constructor(provider: AnchorProvider);
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
/** Initialize the leaderboard head account. */
|
|
872
|
-
buildInitializeIx(authority: PublicKey$1): Promise<TransactionInstruction>;
|
|
737
|
+
getState(): Promise<any | null>;
|
|
738
|
+
getValidatorRecord(voteAccount: PublicKey$1): Promise<any | null>;
|
|
873
739
|
/**
|
|
874
|
-
*
|
|
875
|
-
*
|
|
740
|
+
* Convenience helper to fetch and sort top validators by score.
|
|
741
|
+
* Assumes `validatorRecord` has a numeric `score` field in the IDL.
|
|
876
742
|
*/
|
|
877
|
-
|
|
878
|
-
registrant: PublicKey$1;
|
|
879
|
-
voteAccount: PublicKey$1;
|
|
880
|
-
vpp: number;
|
|
881
|
-
insertAfter?: PublicKey$1;
|
|
882
|
-
insertBefore?: PublicKey$1;
|
|
883
|
-
currentPrev?: PublicKey$1;
|
|
884
|
-
currentNext?: PublicKey$1;
|
|
885
|
-
}): Promise<TransactionInstruction>;
|
|
886
|
-
/** Update the Top-10 cache. Requires exactly 10 validator vote accounts. */
|
|
887
|
-
buildUpdateTop10CacheIx(params: {
|
|
888
|
-
authority: PublicKey$1;
|
|
889
|
-
top10Validators: PublicKey$1[];
|
|
890
|
-
}): Promise<TransactionInstruction>;
|
|
891
|
-
buildInitializeTx(authority: PublicKey$1): Promise<Transaction>;
|
|
892
|
-
buildUpdateValidatorTx(params: {
|
|
893
|
-
registrant: PublicKey$1;
|
|
894
|
-
voteAccount: PublicKey$1;
|
|
895
|
-
vpp: number;
|
|
896
|
-
insertAfter?: PublicKey$1;
|
|
897
|
-
insertBefore?: PublicKey$1;
|
|
898
|
-
currentPrev?: PublicKey$1;
|
|
899
|
-
currentNext?: PublicKey$1;
|
|
900
|
-
}): Promise<Transaction>;
|
|
901
|
-
buildUpdateTop10CacheTx(params: {
|
|
902
|
-
authority: PublicKey$1;
|
|
903
|
-
top10Validators: PublicKey$1[];
|
|
904
|
-
}): Promise<Transaction>;
|
|
905
|
-
/** Traverse the linked-list leaderboard, returning vote accounts in order. */
|
|
906
|
-
getLeaderboard(): Promise<PublicKey$1[]>;
|
|
907
|
-
/** Fetch a single validator record (or null if it doesn't exist). */
|
|
908
|
-
getValidatorRecord(voteAccount: PublicKey$1): Promise<any | null>;
|
|
743
|
+
getTopValidators(limit?: number): Promise<any[]>;
|
|
909
744
|
}
|
|
910
745
|
|
|
911
|
-
export { ADDRESSES, CONTRACTS,
|
|
912
|
-
export type { BalanceView, ContractConfig, ContractOptions, Contracts, IStakingClient, Portfolio, StakerConfig, TxResult };
|
|
746
|
+
export { ADDRESSES, CONTRACTS, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DepositClient, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, LAMPORTS_PER_SOL, LIQSOL_CORE, LIQSOL_TOKEN, LeaderboardClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS, types as SOL, SolanaStakingClient, Staker, VALIDATOR_LEADERBOARD, airdropSol, buildDepositAccounts, calculateExpectedFee, deriveBucketAuthorityPda, deriveDepositAuthorityPda, deriveDistributionStatePda, deriveEphemeralStakeAddress, deriveLeaderboardStatePda, deriveLiqsolMintAuthorityPda, deriveLiqsolMintPda, derivePayRateHistoryPda, derivePayoutStatePda, deriveReservePoolPda, deriveStakeControllerStatePda, deriveStakeControllerVaultPda, deriveUserRecordPda, deriveValidatorRecordPda, deriveVaultPda, generateRandomDepositAmount, generateTestKeypair, getAveragePayRate, getBucketLiqSolBalance, getEpochSnapshot, getErrorMessage, getLiqsolCoreProgram, getPayoutStateRaw, getReservePoolBalance, getStakeControllerStateRaw, getUserLiqSolBalance, getUserRecordRaw, lamportsToSol, msToEpochEnd, previewDepositEffects, scheduledInstruction, sleep, solToLamports, waitForConfirmation, waitUntilSafeToExecuteFunction };
|
|
747
|
+
export type { BalanceView, ContractConfig, ContractOptions, Contracts, DepositAccounts, EpochSnapshot, IStakingClient, Portfolio, ScheduleConfig, SolanaCluster, StakerConfig, TxResult };
|