@wireio/stake 2.2.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -243
- package/lib/stake.browser.js +302 -202
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +93 -24
- package/lib/stake.js +364 -250
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +302 -202
- package/lib/stake.m.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -2
- package/src/networks/ethereum/clients/receipt.client.ts +54 -69
- package/src/networks/ethereum/ethereum.ts +1 -1
- package/src/networks/ethereum/types.ts +14 -17
- package/src/networks/solana/clients/convert.client.ts +339 -0
- package/src/networks/solana/solana.ts +35 -6
- package/src/networks/solana/types.ts +22 -0
- package/src/networks/solana/utils.ts +8 -1
- package/src/types.ts +39 -3
- package/src/networks/solana/clients/deposit.client.ts +0 -291
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,10 @@ 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
|
+
/** Enumerate withdrawal receipt NFTs held by the user (queued/ready/claimed). */
|
|
45
|
+
getPendingWithdraws(): Promise<WithdrawReceipt$1[]>;
|
|
40
46
|
/** Fetch the complete user portfolio */
|
|
41
47
|
getPortfolio(): Promise<Portfolio | null>;
|
|
42
48
|
getSystemAPY(): Promise<number>;
|
|
@@ -65,7 +71,6 @@ interface IStakingClient {
|
|
|
65
71
|
minBufferLamports?: bigint;
|
|
66
72
|
balanceOverrideLamports?: bigint;
|
|
67
73
|
}): Promise<bigint>;
|
|
68
|
-
validatorDeposit(): Promise<string>;
|
|
69
74
|
}
|
|
70
75
|
/**
|
|
71
76
|
* Cross-chain portfolio view for a single account/wallet.
|
|
@@ -252,6 +257,33 @@ declare enum ReceiptNFTKind {
|
|
|
252
257
|
STAKE = 0,
|
|
253
258
|
PRETOKEN_PURCHASE = 1
|
|
254
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Unified cross-chain withdraw receipt (ETH + SOL).
|
|
262
|
+
*
|
|
263
|
+
* tokenId – NFT id (ERC721 on ETH, PDA-seeded mint on SOL)
|
|
264
|
+
* receipt – chain-specific data normalized for UI
|
|
265
|
+
*/
|
|
266
|
+
interface WithdrawReceipt$1 {
|
|
267
|
+
tokenId: bigint;
|
|
268
|
+
receipt: {
|
|
269
|
+
/** Display balance (wei or lamports) with symbol/decimals. */
|
|
270
|
+
amount: BalanceView;
|
|
271
|
+
/** Claimable time in ms since epoch (readyAt on ETH; ETA from epoch on SOL). */
|
|
272
|
+
readyAt: number;
|
|
273
|
+
/** Chain discriminator. */
|
|
274
|
+
chain: ChainSymbol;
|
|
275
|
+
/** Solana-only: epoch when claimable. */
|
|
276
|
+
epoch?: bigint;
|
|
277
|
+
/** queued | ready | claimed */
|
|
278
|
+
status?: WithdrawStatus;
|
|
279
|
+
/** NFT mint (SOL) or ERC721 contract address (ETH queue address). */
|
|
280
|
+
mint?: string;
|
|
281
|
+
/** Owner token account (SOL) for the NFT. */
|
|
282
|
+
ownerAta?: string;
|
|
283
|
+
/** Optional explicit contract address for ETH queue NFT. */
|
|
284
|
+
contractAddress?: string;
|
|
285
|
+
};
|
|
286
|
+
}
|
|
255
287
|
|
|
256
288
|
declare class Staker {
|
|
257
289
|
selectedChainID?: ChainID;
|
|
@@ -326,6 +358,9 @@ interface SharesBurnedEvent {
|
|
|
326
358
|
shares: BigNumber;
|
|
327
359
|
tokenValue: BigNumber;
|
|
328
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Legacy stake/pretoken receipt (kept for compatibility; not used in withdraw UI).
|
|
363
|
+
*/
|
|
329
364
|
interface preLaunchReceipt {
|
|
330
365
|
tokenId: bigint;
|
|
331
366
|
receipt: {
|
|
@@ -342,14 +377,7 @@ interface ClaimedEvent {
|
|
|
342
377
|
user: string;
|
|
343
378
|
amount: BigNumber;
|
|
344
379
|
}
|
|
345
|
-
|
|
346
|
-
tokenId: bigint;
|
|
347
|
-
receipt: {
|
|
348
|
-
ethAmount: BigNumber;
|
|
349
|
-
ethBalance: BalanceView;
|
|
350
|
-
readyAt: number;
|
|
351
|
-
};
|
|
352
|
-
}
|
|
380
|
+
type WithdrawReceipt = WithdrawReceipt$1;
|
|
353
381
|
interface ValidatorDepositedEvent {
|
|
354
382
|
sender: string;
|
|
355
383
|
amount: BigNumber;
|
|
@@ -436,7 +464,7 @@ declare class EthereumStakingClient implements IStakingClient {
|
|
|
436
464
|
* @param amount Amount in wei (or something convertible to BigNumber).
|
|
437
465
|
* @returns transaction hash
|
|
438
466
|
*/
|
|
439
|
-
|
|
467
|
+
getPendingWithdraws(): Promise<WithdrawReceipt[]>;
|
|
440
468
|
/**
|
|
441
469
|
* 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
470
|
* @param tokenId The ID of the withdrawal request NFT
|
|
@@ -1299,6 +1327,24 @@ type ValidatorRecord = {
|
|
|
1299
1327
|
*/
|
|
1300
1328
|
bump: number;
|
|
1301
1329
|
};
|
|
1330
|
+
/**
|
|
1331
|
+
* IDL: `receiptData`
|
|
1332
|
+
*
|
|
1333
|
+
* Withdrawal receipt data structure tracking pending withdrawals.
|
|
1334
|
+
* Each receipt represents a user's request to withdraw liqSOL,
|
|
1335
|
+
* with the withdrawal contingent on sufficient encumbered funds
|
|
1336
|
+
* being available at the serviceable epoch.
|
|
1337
|
+
*/
|
|
1338
|
+
type ReceiptData = {
|
|
1339
|
+
/** Unique receipt identifier (monotonically increasing, u64) */
|
|
1340
|
+
receiptId: bigint;
|
|
1341
|
+
/** Amount of liqSOL requested for withdrawal (Token-2022 raw amount, u64) */
|
|
1342
|
+
liqports: bigint;
|
|
1343
|
+
/** Epoch at which this receipt becomes claimable (u64) */
|
|
1344
|
+
epoch: bigint;
|
|
1345
|
+
/** Flag indicating whether this receipt has been fulfilled/claimed (bool) */
|
|
1346
|
+
fulfilled: boolean;
|
|
1347
|
+
};
|
|
1302
1348
|
|
|
1303
1349
|
type types_DistributionState = DistributionState;
|
|
1304
1350
|
type types_DistributionUserRecord = DistributionUserRecord;
|
|
@@ -1312,6 +1358,7 @@ type types_ParsedAccountInfo = ParsedAccountInfo;
|
|
|
1312
1358
|
type types_PayRateEntry = PayRateEntry;
|
|
1313
1359
|
type types_PayRateHistory = PayRateHistory;
|
|
1314
1360
|
type types_PriceHistory = PriceHistory;
|
|
1361
|
+
type types_ReceiptData = ReceiptData;
|
|
1315
1362
|
type types_Role = Role;
|
|
1316
1363
|
type types_SharesPreview = SharesPreview;
|
|
1317
1364
|
type types_SolanaTransaction = SolanaTransaction;
|
|
@@ -1324,7 +1371,7 @@ type types_WalletLike = WalletLike;
|
|
|
1324
1371
|
type types_WireReceipt = WireReceipt;
|
|
1325
1372
|
type types_WireState = WireState;
|
|
1326
1373
|
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 };
|
|
1374
|
+
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
1375
|
}
|
|
1329
1376
|
|
|
1330
1377
|
/**
|
|
@@ -15387,7 +15434,14 @@ declare class SolanaProgramService {
|
|
|
15387
15434
|
deriveEphemeralStakeAddress(user: PublicKey$1, seed: number): Promise<PublicKey$1>;
|
|
15388
15435
|
}
|
|
15389
15436
|
|
|
15390
|
-
|
|
15437
|
+
/**
|
|
15438
|
+
* ConvertClient (Solana):
|
|
15439
|
+
* - deposit SOL -> liqSOL
|
|
15440
|
+
* - request withdraw (liqSOL burn -> NFT receipt)
|
|
15441
|
+
* - list withdrawal receipts owned by a user
|
|
15442
|
+
* - build claim_withdraw instruction
|
|
15443
|
+
*/
|
|
15444
|
+
declare class ConvertClient {
|
|
15391
15445
|
private readonly provider;
|
|
15392
15446
|
private readonly pgs;
|
|
15393
15447
|
private program;
|
|
@@ -15395,20 +15449,25 @@ declare class DepositClient {
|
|
|
15395
15449
|
get wallet(): WalletLike;
|
|
15396
15450
|
constructor(provider: AnchorProvider, pgs: SolanaProgramService);
|
|
15397
15451
|
/**
|
|
15398
|
-
* Build a deposit
|
|
15399
|
-
* SOL -> liqSOL via liqsol_core::deposit.
|
|
15452
|
+
* Build a deposit instruction (SOL -> liqSOL).
|
|
15400
15453
|
*/
|
|
15401
15454
|
buildDepositTx(amount: bigint, user?: PublicKey$1): Promise<TransactionInstruction>;
|
|
15402
15455
|
/**
|
|
15403
|
-
* Build a withdraw-request
|
|
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)
|
|
15456
|
+
* Build a withdraw-request instruction (liqSOL burn -> NFT receipt).
|
|
15410
15457
|
*/
|
|
15411
15458
|
buildWithdrawTx(amount: bigint, user?: PublicKey$1): Promise<TransactionInstruction>;
|
|
15459
|
+
/**
|
|
15460
|
+
* Enumerate withdrawal receipt NFTs owned by `owner`.
|
|
15461
|
+
*/
|
|
15462
|
+
fetchWithdrawReceipts(owner: PublicKey$1): Promise<WithdrawReceipt$1[]>;
|
|
15463
|
+
/**
|
|
15464
|
+
* Build the claim_withdraw instruction for a given receiptId.
|
|
15465
|
+
*/
|
|
15466
|
+
buildClaimWithdrawTx(receiptId: bigint, user: PublicKey$1): Promise<TransactionInstruction>;
|
|
15467
|
+
/**
|
|
15468
|
+
* Estimate ready time for target epoch using recent slot time.
|
|
15469
|
+
*/
|
|
15470
|
+
private estimateEpochEta;
|
|
15412
15471
|
}
|
|
15413
15472
|
|
|
15414
15473
|
/**
|
|
@@ -15617,6 +15676,7 @@ interface ScheduleConfig {
|
|
|
15617
15676
|
late?: number;
|
|
15618
15677
|
}
|
|
15619
15678
|
declare function ceilDiv(n: BN, d: BN): BN;
|
|
15679
|
+
declare function normalizeToBigInt(x: any): bigint;
|
|
15620
15680
|
|
|
15621
15681
|
/**
|
|
15622
15682
|
* OutpostClient
|
|
@@ -15759,7 +15819,7 @@ declare class SolanaStakingClient implements IStakingClient {
|
|
|
15759
15819
|
pubKey?: PublicKey;
|
|
15760
15820
|
connection: Connection;
|
|
15761
15821
|
anchor: AnchorProvider;
|
|
15762
|
-
|
|
15822
|
+
convertClient: ConvertClient;
|
|
15763
15823
|
distributionClient: DistributionClient;
|
|
15764
15824
|
leaderboardClient: LeaderboardClient;
|
|
15765
15825
|
outpostClient: OutpostClient;
|
|
@@ -15788,6 +15848,15 @@ declare class SolanaStakingClient implements IStakingClient {
|
|
|
15788
15848
|
* Actual SOL payout happens later via the operator-side flow.
|
|
15789
15849
|
*/
|
|
15790
15850
|
withdraw(amountLamports: bigint): Promise<string>;
|
|
15851
|
+
/**
|
|
15852
|
+
* Enumerate withdrawal receipt NFTs held by the user (queued/ready/claimed).
|
|
15853
|
+
* Mirrors the ETH getPendingWithdraws helper for UI parity.
|
|
15854
|
+
*/
|
|
15855
|
+
getPendingWithdraws(): Promise<WithdrawReceipt$1[]>;
|
|
15856
|
+
/**
|
|
15857
|
+
* Claim a withdrawal receipt (burn NFT + receive SOL) via claim_withdraw.
|
|
15858
|
+
*/
|
|
15859
|
+
claimWithdraw(tokenId: bigint): Promise<string>;
|
|
15791
15860
|
/**
|
|
15792
15861
|
* Stake liqSOL into Outpost (liqSOL → pool) via liqsol_core::synd.
|
|
15793
15862
|
*/
|
|
@@ -15923,5 +15992,5 @@ declare class SolanaStakingClient implements IStakingClient {
|
|
|
15923
15992
|
private getSingleTxFeeLamports;
|
|
15924
15993
|
}
|
|
15925
15994
|
|
|
15926
|
-
export { ADDRESSES, ADDRESS_BOOK_BY_CHAIN, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS_BY_CHAIN, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK,
|
|
15927
|
-
export type { BalanceView, ContractConfig, ContractOptions, Contracts, EpochSnapshot, IStakingClient, OPPAssertion, OutpostAccounts, Portfolio, PurchaseQuote, ScheduleConfig, SolanaProgramIds, SquadsXConfig, StakerConfig, TrancheLadderItem, TrancheSnapshot, YieldView };
|
|
15995
|
+
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 };
|
|
15996
|
+
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 };
|