@wireio/stake 2.2.2 → 2.3.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.d.ts CHANGED
@@ -28,6 +28,8 @@ declare enum SupportedSolChainID {
28
28
  Mainnet = "mainnet-beta",
29
29
  Devnet = "devnet"
30
30
  }
31
+ type ChainSymbol = 'ETH' | 'SOL';
32
+ type WithdrawStatus = 'queued' | 'ready' | 'claimed';
31
33
  interface IStakingClient {
32
34
  pubKey?: PublicKey;
33
35
  network: ExternalNetwork;
@@ -37,6 +39,12 @@ interface IStakingClient {
37
39
  stake(amount: bigint): Promise<string>;
38
40
  unstake(amount: bigint): Promise<string>;
39
41
  buy(amount: bigint): Promise<string>;
42
+ /** Claim a withdrawal receipt (burn NFT + receive ETH/SOL) via claim_withdraw. */
43
+ claimWithdraw(tokenId: bigint): Promise<string>;
44
+ /** Solana only: claim accrued liqSOL distribution rewards. */
45
+ claimLiqsolRewards?(): Promise<string>;
46
+ /** Enumerate withdrawal receipt NFTs held by the user (queued/ready/claimed). */
47
+ getPendingWithdraws(): Promise<WithdrawReceipt$1[]>;
40
48
  /** Fetch the complete user portfolio */
41
49
  getPortfolio(): Promise<Portfolio | null>;
42
50
  getSystemAPY(): Promise<number>;
@@ -65,7 +73,6 @@ interface IStakingClient {
65
73
  minBufferLamports?: bigint;
66
74
  balanceOverrideLamports?: bigint;
67
75
  }): Promise<bigint>;
68
- validatorDeposit(): Promise<string>;
69
76
  }
70
77
  /**
71
78
  * Cross-chain portfolio view for a single account/wallet.
@@ -86,6 +93,11 @@ interface Portfolio {
86
93
  native: BalanceView;
87
94
  /** Liquid staking token balance (LiqETH, LiqSOL, etc.). */
88
95
  liq: BalanceView;
96
+ /**
97
+ * Solana-only liqSOL rewards currently claimable from the distribution bucket.
98
+ * Not populated on Ethereum.
99
+ */
100
+ claimable?: BalanceView;
89
101
  /**
90
102
  * Outpost-staked balance:
91
103
  * - On Solana: liqSOL staked via `synd` (stakedLiqsol, in lamports).
@@ -252,6 +264,33 @@ declare enum ReceiptNFTKind {
252
264
  STAKE = 0,
253
265
  PRETOKEN_PURCHASE = 1
254
266
  }
267
+ /**
268
+ * Unified cross-chain withdraw receipt (ETH + SOL).
269
+ *
270
+ * tokenId – NFT id (ERC721 on ETH, PDA-seeded mint on SOL)
271
+ * receipt – chain-specific data normalized for UI
272
+ */
273
+ interface WithdrawReceipt$1 {
274
+ tokenId: bigint;
275
+ receipt: {
276
+ /** Display balance (wei or lamports) with symbol/decimals. */
277
+ amount: BalanceView;
278
+ /** Claimable time in ms since epoch (readyAt on ETH; ETA from epoch on SOL). */
279
+ readyAt: number;
280
+ /** Chain discriminator. */
281
+ chain: ChainSymbol;
282
+ /** Solana-only: epoch when claimable. */
283
+ epoch?: bigint;
284
+ /** queued | ready | claimed */
285
+ status?: WithdrawStatus;
286
+ /** NFT mint (SOL) or ERC721 contract address (ETH queue address). */
287
+ mint?: string;
288
+ /** Owner token account (SOL) for the NFT. */
289
+ ownerAta?: string;
290
+ /** Optional explicit contract address for ETH queue NFT. */
291
+ contractAddress?: string;
292
+ };
293
+ }
255
294
 
256
295
  declare class Staker {
257
296
  selectedChainID?: ChainID;
@@ -326,6 +365,9 @@ interface SharesBurnedEvent {
326
365
  shares: BigNumber;
327
366
  tokenValue: BigNumber;
328
367
  }
368
+ /**
369
+ * Legacy stake/pretoken receipt (kept for compatibility; not used in withdraw UI).
370
+ */
329
371
  interface preLaunchReceipt {
330
372
  tokenId: bigint;
331
373
  receipt: {
@@ -342,14 +384,7 @@ interface ClaimedEvent {
342
384
  user: string;
343
385
  amount: BigNumber;
344
386
  }
345
- interface WithdrawReceipt {
346
- tokenId: bigint;
347
- receipt: {
348
- ethAmount: BigNumber;
349
- ethBalance: BalanceView;
350
- readyAt: number;
351
- };
352
- }
387
+ type WithdrawReceipt = WithdrawReceipt$1;
353
388
  interface ValidatorDepositedEvent {
354
389
  sender: string;
355
390
  amount: BigNumber;
@@ -417,6 +452,7 @@ declare class EthereumStakingClient implements IStakingClient {
417
452
  MockAggregator: ethers.Contract;
418
453
  };
419
454
  get network(): _wireio_core.ExternalNetwork;
455
+ get address(): Promise<string> | undefined;
420
456
  constructor(config: StakerConfig);
421
457
  /**
422
458
  * Deposit native ETH into the liqETH protocol via DepositManager.
@@ -436,7 +472,7 @@ declare class EthereumStakingClient implements IStakingClient {
436
472
  * @param amount Amount in wei (or something convertible to BigNumber).
437
473
  * @returns transaction hash
438
474
  */
439
- loadPendingWithdraws(): Promise<WithdrawReceipt[]>;
475
+ getPendingWithdraws(): Promise<WithdrawReceipt[]>;
440
476
  /**
441
477
  * Withdraw native ETH from the liqETH protocol via the liqeth safeBurn function, which burns the LiqETH and adds the user to the withdrawal queue.
442
478
  * @param tokenId The ID of the withdrawal request NFT
@@ -1299,6 +1335,24 @@ type ValidatorRecord = {
1299
1335
  */
1300
1336
  bump: number;
1301
1337
  };
1338
+ /**
1339
+ * IDL: `receiptData`
1340
+ *
1341
+ * Withdrawal receipt data structure tracking pending withdrawals.
1342
+ * Each receipt represents a user's request to withdraw liqSOL,
1343
+ * with the withdrawal contingent on sufficient encumbered funds
1344
+ * being available at the serviceable epoch.
1345
+ */
1346
+ type ReceiptData = {
1347
+ /** Unique receipt identifier (monotonically increasing, u64) */
1348
+ receiptId: bigint;
1349
+ /** Amount of liqSOL requested for withdrawal (Token-2022 raw amount, u64) */
1350
+ liqports: bigint;
1351
+ /** Epoch at which this receipt becomes claimable (u64) */
1352
+ epoch: bigint;
1353
+ /** Flag indicating whether this receipt has been fulfilled/claimed (bool) */
1354
+ fulfilled: boolean;
1355
+ };
1302
1356
 
1303
1357
  type types_DistributionState = DistributionState;
1304
1358
  type types_DistributionUserRecord = DistributionUserRecord;
@@ -1312,6 +1366,7 @@ type types_ParsedAccountInfo = ParsedAccountInfo;
1312
1366
  type types_PayRateEntry = PayRateEntry;
1313
1367
  type types_PayRateHistory = PayRateHistory;
1314
1368
  type types_PriceHistory = PriceHistory;
1369
+ type types_ReceiptData = ReceiptData;
1315
1370
  type types_Role = Role;
1316
1371
  type types_SharesPreview = SharesPreview;
1317
1372
  type types_SolanaTransaction = SolanaTransaction;
@@ -1324,7 +1379,7 @@ type types_WalletLike = WalletLike;
1324
1379
  type types_WireReceipt = WireReceipt;
1325
1380
  type types_WireState = WireState;
1326
1381
  declare namespace types {
1327
- export type { types_DistributionState as DistributionState, types_DistributionUserRecord as DistributionUserRecord, types_GlobalAccount as GlobalAccount, types_GlobalConfig as GlobalConfig, types_GlobalState as GlobalState, types_LeaderboardState as LeaderboardState, types_OutpostAccount as OutpostAccount, types_OutpostWireStateSnapshot as OutpostWireStateSnapshot, types_ParsedAccountInfo as ParsedAccountInfo, types_PayRateEntry as PayRateEntry, types_PayRateHistory as PayRateHistory, types_PriceHistory as PriceHistory, types_Role as Role, types_SharesPreview as SharesPreview, types_SolanaTransaction as SolanaTransaction, types_TrancheState as TrancheState, types_UserPretokenRecord as UserPretokenRecord, types_ValidatorRecord as ValidatorRecord, types_ValidatorReputation as ValidatorReputation, types_ValidatorState as ValidatorState, types_WalletLike as WalletLike, types_WireReceipt as WireReceipt, types_WireState as WireState };
1382
+ export type { types_DistributionState as DistributionState, types_DistributionUserRecord as DistributionUserRecord, types_GlobalAccount as GlobalAccount, types_GlobalConfig as GlobalConfig, types_GlobalState as GlobalState, types_LeaderboardState as LeaderboardState, types_OutpostAccount as OutpostAccount, types_OutpostWireStateSnapshot as OutpostWireStateSnapshot, types_ParsedAccountInfo as ParsedAccountInfo, types_PayRateEntry as PayRateEntry, types_PayRateHistory as PayRateHistory, types_PriceHistory as PriceHistory, types_ReceiptData as ReceiptData, types_Role as Role, types_SharesPreview as SharesPreview, types_SolanaTransaction as SolanaTransaction, types_TrancheState as TrancheState, types_UserPretokenRecord as UserPretokenRecord, types_ValidatorRecord as ValidatorRecord, types_ValidatorReputation as ValidatorReputation, types_ValidatorState as ValidatorState, types_WalletLike as WalletLike, types_WireReceipt as WireReceipt, types_WireState as WireState };
1328
1383
  }
1329
1384
 
1330
1385
  /**
@@ -15387,7 +15442,14 @@ declare class SolanaProgramService {
15387
15442
  deriveEphemeralStakeAddress(user: PublicKey$1, seed: number): Promise<PublicKey$1>;
15388
15443
  }
15389
15444
 
15390
- declare class DepositClient {
15445
+ /**
15446
+ * ConvertClient (Solana):
15447
+ * - deposit SOL -> liqSOL
15448
+ * - request withdraw (liqSOL burn -> NFT receipt)
15449
+ * - list withdrawal receipts owned by a user
15450
+ * - build claim_withdraw instruction
15451
+ */
15452
+ declare class ConvertClient {
15391
15453
  private readonly provider;
15392
15454
  private readonly pgs;
15393
15455
  private program;
@@ -15395,20 +15457,25 @@ declare class DepositClient {
15395
15457
  get wallet(): WalletLike;
15396
15458
  constructor(provider: AnchorProvider, pgs: SolanaProgramService);
15397
15459
  /**
15398
- * Build a deposit transaction:
15399
- * SOL -> liqSOL via liqsol_core::deposit.
15460
+ * Build a deposit instruction (SOL -> liqSOL).
15400
15461
  */
15401
15462
  buildDepositTx(amount: bigint, user?: PublicKey$1): Promise<TransactionInstruction>;
15402
15463
  /**
15403
- * Build a withdraw-request transaction:
15404
- * liqSOL -> SOL via liqsol_core::requestWithdraw.
15405
- *
15406
- * This:
15407
- * - burns liqSOL from the user
15408
- * - increments totalEncumberedFunds in global state
15409
- * - mints an NFT receipt (liqReceiptData + NFT ATA for owner)
15464
+ * Build a withdraw-request instruction (liqSOL burn -> NFT receipt).
15410
15465
  */
15411
15466
  buildWithdrawTx(amount: bigint, user?: PublicKey$1): Promise<TransactionInstruction>;
15467
+ /**
15468
+ * Enumerate withdrawal receipt NFTs owned by `owner`.
15469
+ */
15470
+ fetchWithdrawReceipts(owner: PublicKey$1): Promise<WithdrawReceipt$1[]>;
15471
+ /**
15472
+ * Build the claim_withdraw instruction for a given receiptId.
15473
+ */
15474
+ buildClaimWithdrawTx(receiptId: bigint, user: PublicKey$1): Promise<TransactionInstruction>;
15475
+ /**
15476
+ * Estimate ready time for target epoch using recent slot time.
15477
+ */
15478
+ private estimateEpochEta;
15412
15479
  }
15413
15480
 
15414
15481
  /**
@@ -15435,6 +15502,7 @@ declare class DistributionClient {
15435
15502
  private program;
15436
15503
  constructor(provider: AnchorProvider, pgs: SolanaProgramService);
15437
15504
  get connection(): _solana_web3_js.Connection;
15505
+ private getTokenBalance;
15438
15506
  /**
15439
15507
  * Fetch the global distribution state account.
15440
15508
  *
@@ -15477,6 +15545,19 @@ declare class DistributionClient {
15477
15545
  totalShares: BN;
15478
15546
  ratio: number;
15479
15547
  }>;
15548
+ /**
15549
+ * Compute claimable liqSOL for a wallet:
15550
+ * claimable = max(0, entitled - actual)
15551
+ * entitled = floor(shares * syncedIndex / 1e12)
15552
+ *
15553
+ * `syncedIndex` mirrors on-chain `sync_index` behavior by incorporating any
15554
+ * unsynced bucket delta (bucket_balance - last_bucket_balance).
15555
+ */
15556
+ getClaimableLiqsol(user: PublicKey$1): Promise<BN>;
15557
+ /**
15558
+ * Build claim_rewards instruction for a wallet.
15559
+ */
15560
+ buildClaimRewardsIx(user: PublicKey$1): Promise<TransactionInstruction>;
15480
15561
  /**
15481
15562
  * Compute an average scaled pay rate over the most recent `windowSize`
15482
15563
  * valid entries in the pay-rate history circular buffer.
@@ -15617,6 +15698,7 @@ interface ScheduleConfig {
15617
15698
  late?: number;
15618
15699
  }
15619
15700
  declare function ceilDiv(n: BN, d: BN): BN;
15701
+ declare function normalizeToBigInt(x: any): bigint;
15620
15702
 
15621
15703
  /**
15622
15704
  * OutpostClient
@@ -15759,7 +15841,7 @@ declare class SolanaStakingClient implements IStakingClient {
15759
15841
  pubKey?: PublicKey;
15760
15842
  connection: Connection;
15761
15843
  anchor: AnchorProvider;
15762
- depositClient: DepositClient;
15844
+ convertClient: ConvertClient;
15763
15845
  distributionClient: DistributionClient;
15764
15846
  leaderboardClient: LeaderboardClient;
15765
15847
  outpostClient: OutpostClient;
@@ -15788,6 +15870,19 @@ declare class SolanaStakingClient implements IStakingClient {
15788
15870
  * Actual SOL payout happens later via the operator-side flow.
15789
15871
  */
15790
15872
  withdraw(amountLamports: bigint): Promise<string>;
15873
+ /**
15874
+ * Enumerate withdrawal receipt NFTs held by the user (queued/ready/claimed).
15875
+ * Mirrors the ETH getPendingWithdraws helper for UI parity.
15876
+ */
15877
+ getPendingWithdraws(): Promise<WithdrawReceipt$1[]>;
15878
+ /**
15879
+ * Claim a withdrawal receipt (burn NFT + receive SOL) via claim_withdraw.
15880
+ */
15881
+ claimWithdraw(tokenId: bigint): Promise<string>;
15882
+ /**
15883
+ * Claim accrued liqSOL distribution rewards (liqsol_core::claim_rewards).
15884
+ */
15885
+ claimLiqsolRewards(): Promise<string>;
15791
15886
  /**
15792
15887
  * Stake liqSOL into Outpost (liqSOL → pool) via liqsol_core::synd.
15793
15888
  */
@@ -15923,5 +16018,5 @@ declare class SolanaStakingClient implements IStakingClient {
15923
16018
  private getSingleTxFeeLamports;
15924
16019
  }
15925
16020
 
15926
- export { ADDRESSES, ADDRESS_BOOK_BY_CHAIN, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS_BY_CHAIN, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DepositClient, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, HOODI_ADDRESSES, INDEX_SCALE, INITIAL_TRANCHE_SUPPLY, LAMPORTS_PER_SOL, LeaderboardClient, MAINNET_ADDRESSES, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS_BY_CHAIN, PurchaseAsset, ReceiptNFTKind, SCALE, types as SOL, SolanaStakingClient, Staker, SupportedEvmChainID, SupportedSolChainID, TokenClient, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, ceilDiv, deriveEphemeralStakeAddress, generateRandomDepositAmount, generateTestKeypair, getEpochSnapshot, getErrorMessage, getProgramIds, lamportsToSol, msToEpochEnd, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
15927
- export type { BalanceView, ContractConfig, ContractOptions, Contracts, EpochSnapshot, IStakingClient, OPPAssertion, OutpostAccounts, Portfolio, PurchaseQuote, ScheduleConfig, SolanaProgramIds, SquadsXConfig, StakerConfig, TrancheLadderItem, TrancheSnapshot, YieldView };
16021
+ export { ADDRESSES, ADDRESS_BOOK_BY_CHAIN, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS_BY_CHAIN, ConvertClient, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, HOODI_ADDRESSES, INDEX_SCALE, INITIAL_TRANCHE_SUPPLY, LAMPORTS_PER_SOL, LeaderboardClient, MAINNET_ADDRESSES, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS_BY_CHAIN, PurchaseAsset, ReceiptNFTKind, SCALE, types as SOL, SolanaStakingClient, Staker, SupportedEvmChainID, SupportedSolChainID, TokenClient, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, ceilDiv, deriveEphemeralStakeAddress, generateRandomDepositAmount, generateTestKeypair, getEpochSnapshot, getErrorMessage, getProgramIds, lamportsToSol, msToEpochEnd, normalizeToBigInt, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
16022
+ export type { BalanceView, ChainSymbol, ContractConfig, ContractOptions, Contracts, EpochSnapshot, IStakingClient, OPPAssertion, OutpostAccounts, Portfolio, PurchaseQuote, ScheduleConfig, SolanaProgramIds, SquadsXConfig, StakerConfig, TrancheLadderItem, TrancheSnapshot, WithdrawReceipt$1 as WithdrawReceipt, WithdrawStatus, YieldView };