@wireio/stake 0.4.0 → 0.4.2
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 +1802 -582
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +66 -24
- package/lib/stake.js +1885 -633
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +1802 -582
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- 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 +133 -133
- package/src/networks/ethereum/types.ts +1 -0
- package/src/networks/solana/solana.ts +35 -18
- package/src/types.ts +60 -1
- package/src/networks/ethereum/clients/liq.client.ts +0 -47
package/lib/stake.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { BN, AnchorProvider, Program } from '@coral-xyz/anchor';
|
|
|
10
10
|
|
|
11
11
|
type StakerConfig = {
|
|
12
12
|
network: ExternalNetwork;
|
|
13
|
-
provider
|
|
13
|
+
provider?: BaseSignerWalletAdapter | ethers.providers.Web3Provider;
|
|
14
14
|
pubKey?: PublicKey;
|
|
15
15
|
};
|
|
16
16
|
interface IStakingClient {
|
|
@@ -24,6 +24,8 @@ interface IStakingClient {
|
|
|
24
24
|
buy(amount: bigint): Promise<string>;
|
|
25
25
|
/** Fetch the complete user portfolio */
|
|
26
26
|
getPortfolio(): Promise<Portfolio>;
|
|
27
|
+
getSystemAPY(): Promise<number>;
|
|
28
|
+
getDepositFee(amount: bigint): Promise<bigint>;
|
|
27
29
|
/**
|
|
28
30
|
* Program-level prelaunch WIRE/tranche snapshot for this chain.
|
|
29
31
|
*
|
|
@@ -192,6 +194,37 @@ interface TrancheSnapshot {
|
|
|
192
194
|
*/
|
|
193
195
|
ladder: TrancheLadderItem[];
|
|
194
196
|
}
|
|
197
|
+
declare enum PurchaseAsset {
|
|
198
|
+
SOL = "SOL",
|
|
199
|
+
LIQSOL = "LIQSOL",
|
|
200
|
+
ETH = "ETH",
|
|
201
|
+
LIQETH = "LIQETH",
|
|
202
|
+
YIELD = "YIELD"
|
|
203
|
+
}
|
|
204
|
+
interface PurchaseQuote {
|
|
205
|
+
purchaseAsset: PurchaseAsset;
|
|
206
|
+
amountIn: bigint;
|
|
207
|
+
/** Expected pretoken “shares” (pretokens) and decimals */
|
|
208
|
+
wireShares: bigint;
|
|
209
|
+
wireDecimals: number;
|
|
210
|
+
/** Current price + notional in USD (1e8 scale) */
|
|
211
|
+
wirePriceUsd: bigint;
|
|
212
|
+
notionalUsd: bigint;
|
|
213
|
+
}
|
|
214
|
+
interface OPPAssertion {
|
|
215
|
+
type: 'liq_pretoken_purchase' | 'yield_pretoken_purchase' | 'pretoken_purchase' | 'stake' | 'unstake' | 'bonded_actor' | 'unbonded_actor' | 'unknown';
|
|
216
|
+
data: any;
|
|
217
|
+
chain: 'ETH' | 'SOL';
|
|
218
|
+
timestamp: number | null;
|
|
219
|
+
from: string | null;
|
|
220
|
+
to: string | null;
|
|
221
|
+
txHash: string;
|
|
222
|
+
raw: any;
|
|
223
|
+
}
|
|
224
|
+
declare enum ReceiptNFTKind {
|
|
225
|
+
STAKE = 0,
|
|
226
|
+
PRETOKEN_PURCHASE = 1
|
|
227
|
+
}
|
|
195
228
|
|
|
196
229
|
declare class Staker {
|
|
197
230
|
selectedChainID?: ChainID;
|
|
@@ -213,7 +246,7 @@ declare class Staker {
|
|
|
213
246
|
setChain(chainID: ChainID): boolean;
|
|
214
247
|
}
|
|
215
248
|
|
|
216
|
-
declare const CONTRACT_NAMES: readonly ["Accounting", "DepositManager", "LiqEth", "StakingModule", "WithdrawalQueue", "WithdrawalVault", "Depositor", "ReceiptNFT", "OutpostManager", "BAR", "OPP", "OPPCommon", "OPPInbound", "Pretoken", "Aggregator", "EthUsdPriceConsumer"];
|
|
249
|
+
declare const CONTRACT_NAMES: readonly ["Accounting", "DepositManager", "LiqEth", "StakingModule", "WithdrawalQueue", "WithdrawalVault", "Depositor", "ReceiptNFT", "OutpostManager", "BAR", "OPP", "OPPCommon", "OPPInbound", "Pretoken", "Aggregator", "EthUsdPriceConsumer", "Pool"];
|
|
217
250
|
type ContractName = typeof CONTRACT_NAMES[number];
|
|
218
251
|
type AddressBook = Record<ContractName, string>;
|
|
219
252
|
interface Result {
|
|
@@ -299,14 +332,15 @@ declare namespace types$1 {
|
|
|
299
332
|
|
|
300
333
|
declare class EthereumStakingClient implements IStakingClient {
|
|
301
334
|
private config;
|
|
302
|
-
readonly pubKey?: PublicKey;
|
|
303
335
|
private readonly provider;
|
|
304
|
-
|
|
336
|
+
readonly pubKey?: PublicKey;
|
|
337
|
+
private readonly signer?;
|
|
305
338
|
private readonly contractService;
|
|
306
|
-
private
|
|
307
|
-
private liqClient;
|
|
339
|
+
private convertClient;
|
|
308
340
|
private pretokenClient;
|
|
309
341
|
private stakeClient;
|
|
342
|
+
private oppClient;
|
|
343
|
+
private receiptClient;
|
|
310
344
|
get contract(): {
|
|
311
345
|
Accounting: ethers.Contract;
|
|
312
346
|
DepositManager: ethers.Contract;
|
|
@@ -324,6 +358,7 @@ declare class EthereumStakingClient implements IStakingClient {
|
|
|
324
358
|
Pretoken: ethers.Contract;
|
|
325
359
|
Aggregator: ethers.Contract;
|
|
326
360
|
EthUsdPriceConsumer: ethers.Contract;
|
|
361
|
+
Pool: ethers.Contract;
|
|
327
362
|
};
|
|
328
363
|
get network(): _wireio_core.ExternalNetwork;
|
|
329
364
|
constructor(config: StakerConfig);
|
|
@@ -342,8 +377,7 @@ declare class EthereumStakingClient implements IStakingClient {
|
|
|
342
377
|
withdraw(amount: bigint): Promise<string>;
|
|
343
378
|
/**
|
|
344
379
|
* Stake liqETH via DepositManager.
|
|
345
|
-
* @param amount Amount in wei
|
|
346
|
-
* Keep this as a bigint / string in the caller; avoid JS floats.
|
|
380
|
+
* @param amount Amount in wei - Keep this as a bigint / string in the caller; avoid JS floats.
|
|
347
381
|
* @returns transaction hash
|
|
348
382
|
*/
|
|
349
383
|
stake(amount: bigint): Promise<string>;
|
|
@@ -356,14 +390,6 @@ declare class EthereumStakingClient implements IStakingClient {
|
|
|
356
390
|
*/
|
|
357
391
|
unstakePrelaunch(tokenId: bigint, recipient: string): Promise<string>;
|
|
358
392
|
buy(amount: bigint): Promise<string>;
|
|
359
|
-
getOPPStatus(): Promise<any>;
|
|
360
|
-
/**
|
|
361
|
-
* ETH Prelaunch function to list the ReceiptNFTs owned by a specific user
|
|
362
|
-
* @param address address to query the receipts for
|
|
363
|
-
* @returns array of receipts
|
|
364
|
-
*/
|
|
365
|
-
fetchPrelaunchReceipts(address?: string): Promise<preLaunchReceipt[]>;
|
|
366
|
-
getEthStats(): Promise<any>;
|
|
367
393
|
/**
|
|
368
394
|
* Resolve the user's ETH + liqETH balances.
|
|
369
395
|
*
|
|
@@ -372,8 +398,22 @@ declare class EthereumStakingClient implements IStakingClient {
|
|
|
372
398
|
* tracked = liqETH tracked balance (protocol/accounting view)
|
|
373
399
|
*/
|
|
374
400
|
getPortfolio(): Promise<Portfolio>;
|
|
401
|
+
/**
|
|
402
|
+
* ETH Prelaunch function to list the Stake ReceiptNFTs owned by a specific user
|
|
403
|
+
* @param address address to query the receipts for
|
|
404
|
+
* @returns array of receipts
|
|
405
|
+
*/
|
|
406
|
+
fetchPrelaunchReceipts(address?: string): Promise<preLaunchReceipt[]>;
|
|
407
|
+
getOPPMessages(address?: string): Promise<OPPAssertion[]>;
|
|
408
|
+
private ensureUser;
|
|
409
|
+
getSystemAPY(): Promise<number>;
|
|
410
|
+
getDepositFee(amount: bigint): Promise<bigint>;
|
|
411
|
+
getOPPStatus(): Promise<any>;
|
|
412
|
+
getEthStats(): Promise<any>;
|
|
375
413
|
/**
|
|
376
414
|
* Program-level prelaunch WIRE / tranche snapshot for Ethereum
|
|
415
|
+
*
|
|
416
|
+
* SUPPORTS READ-ONLY ACcESS
|
|
377
417
|
*/
|
|
378
418
|
getTrancheSnapshot(options?: {
|
|
379
419
|
chainID?: ChainID;
|
|
@@ -7399,6 +7439,13 @@ declare class SolanaStakingClient implements IStakingClient {
|
|
|
7399
7439
|
* - extras: useful internal addresses and raw state for debugging/UX
|
|
7400
7440
|
*/
|
|
7401
7441
|
getPortfolio(): Promise<Portfolio>;
|
|
7442
|
+
/**
|
|
7443
|
+
* Convenience helper to fetch the distribution userRecord for the current user.
|
|
7444
|
+
* Used by balance-correction flows and debugging.
|
|
7445
|
+
*/
|
|
7446
|
+
getUserRecord(): Promise<DistributionUserRecord | null>;
|
|
7447
|
+
getSystemAPY(): Promise<number>;
|
|
7448
|
+
getDepositFee(amount: bigint): Promise<bigint>;
|
|
7402
7449
|
/**
|
|
7403
7450
|
* Unified, chain-agnostic tranche snapshot for Solana.
|
|
7404
7451
|
*
|
|
@@ -7414,11 +7461,6 @@ declare class SolanaStakingClient implements IStakingClient {
|
|
|
7414
7461
|
windowBefore?: number;
|
|
7415
7462
|
windowAfter?: number;
|
|
7416
7463
|
}): Promise<TrancheSnapshot>;
|
|
7417
|
-
/**
|
|
7418
|
-
* Convenience helper to fetch the distribution userRecord for the current user.
|
|
7419
|
-
* Used by balance-correction flows and debugging.
|
|
7420
|
-
*/
|
|
7421
|
-
getUserRecord(): Promise<DistributionUserRecord | null>;
|
|
7422
7464
|
/**
|
|
7423
7465
|
* Send a signed transaction over HTTP RPC and wait for confirmation.
|
|
7424
7466
|
* Throws if the transaction fails.
|
|
@@ -7446,7 +7488,7 @@ declare class SolanaStakingClient implements IStakingClient {
|
|
|
7446
7488
|
* Guard for all write operations (deposit/withdraw/stake/unstake/buy).
|
|
7447
7489
|
* Ensures we have a Wire pubKey and an Anchor wallet pubKey, and that they match.
|
|
7448
7490
|
*/
|
|
7449
|
-
|
|
7491
|
+
ensureUser(): void;
|
|
7450
7492
|
}
|
|
7451
7493
|
|
|
7452
7494
|
/**
|
|
@@ -7598,5 +7640,5 @@ declare const INDEX_SCALE: bigint;
|
|
|
7598
7640
|
declare const lamportsToSol: (lamports: number | bigint) => number;
|
|
7599
7641
|
declare const solToLamports: (sol: number) => bigint;
|
|
7600
7642
|
|
|
7601
|
-
export { ADDRESSES, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DepositClient, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, INDEX_SCALE, LAMPORTS_PER_SOL, LIQSOL_CORE, LIQSOL_TOKEN, LeaderboardClient, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS, types as SOL, SolanaStakingClient, Staker, TRANSFER_HOOK, TokenClient, VALIDATOR_LEADERBOARD, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, calculateExpectedFee, deriveBarConfigPda, deriveBondLevelPda, deriveBondedActorPda, deriveBucketAuthorityPda, deriveDepositAuthorityPda, deriveDistributionStatePda, deriveEphemeralStakeAddress, deriveExtraAccountMetaListPda, deriveLeaderboardStatePda, deriveLiqReceiptDataPda, deriveLiqsolMintAuthorityPda, deriveLiqsolMintPda, deriveMaintenanceLedgerPda, deriveOutpostAccountPda, deriveOutpostGlobalStatePda, deriveOutpostPoolAuthorityPda, derivePayRateHistoryPda, derivePayoutStatePda, derivePriceHistoryPda, deriveReservePoolPda, deriveStakeAllocationStatePda, deriveStakeControllerStatePda, deriveStakeControllerVaultPda, deriveStakeMetricsPda, deriveTrancheStatePda, deriveUserPretokenRecordPda, deriveUserRecordPda, deriveValidatorRecordPda, deriveVaultPda, deriveWithdrawGlobalPda, deriveWithdrawMintAuthorityPda, deriveWithdrawMintMetadataPda, deriveWithdrawNftMintPda, generateRandomDepositAmount, generateTestKeypair, getAveragePayRate, getBucketLiqSolBalance, getEpochSnapshot, getErrorMessage, getLiqsolCoreProgram, getPayoutStateRaw, getReservePoolBalance, getStakeControllerStateRaw, getUserLiqSolBalance, getUserRecordRaw, lamportsToSol, msToEpochEnd, previewDepositEffects, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
|
|
7602
|
-
export type { BalanceView, ContractConfig, ContractOptions, Contracts, EpochSnapshot, IStakingClient, OutpostAccounts, Portfolio, ScheduleConfig, StakerConfig, TrancheLadderItem, TrancheSnapshot, YieldView };
|
|
7643
|
+
export { ADDRESSES, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DepositClient, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, INDEX_SCALE, LAMPORTS_PER_SOL, LIQSOL_CORE, LIQSOL_TOKEN, LeaderboardClient, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS, PurchaseAsset, ReceiptNFTKind, types as SOL, SolanaStakingClient, Staker, TRANSFER_HOOK, TokenClient, VALIDATOR_LEADERBOARD, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, calculateExpectedFee, deriveBarConfigPda, deriveBondLevelPda, deriveBondedActorPda, deriveBucketAuthorityPda, deriveDepositAuthorityPda, deriveDistributionStatePda, deriveEphemeralStakeAddress, deriveExtraAccountMetaListPda, deriveLeaderboardStatePda, deriveLiqReceiptDataPda, deriveLiqsolMintAuthorityPda, deriveLiqsolMintPda, deriveMaintenanceLedgerPda, deriveOutpostAccountPda, deriveOutpostGlobalStatePda, deriveOutpostPoolAuthorityPda, derivePayRateHistoryPda, derivePayoutStatePda, derivePriceHistoryPda, deriveReservePoolPda, deriveStakeAllocationStatePda, deriveStakeControllerStatePda, deriveStakeControllerVaultPda, deriveStakeMetricsPda, deriveTrancheStatePda, deriveUserPretokenRecordPda, deriveUserRecordPda, deriveValidatorRecordPda, deriveVaultPda, deriveWithdrawGlobalPda, deriveWithdrawMintAuthorityPda, deriveWithdrawMintMetadataPda, deriveWithdrawNftMintPda, generateRandomDepositAmount, generateTestKeypair, getAveragePayRate, getBucketLiqSolBalance, getEpochSnapshot, getErrorMessage, getLiqsolCoreProgram, getPayoutStateRaw, getReservePoolBalance, getStakeControllerStateRaw, getUserLiqSolBalance, getUserRecordRaw, lamportsToSol, msToEpochEnd, previewDepositEffects, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
|
|
7644
|
+
export type { BalanceView, ContractConfig, ContractOptions, Contracts, EpochSnapshot, IStakingClient, OPPAssertion, OutpostAccounts, Portfolio, PurchaseQuote, ScheduleConfig, StakerConfig, TrancheLadderItem, TrancheSnapshot, YieldView };
|