@wireio/stake 0.2.2 → 0.2.3

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
@@ -1,5 +1,5 @@
1
1
  import * as _wireio_core from '@wireio/core';
2
- import { PublicKey, ExternalNetwork, ChainID } from '@wireio/core';
2
+ import { ExternalNetwork, PublicKey, ChainID } from '@wireio/core';
3
3
  import { BaseSignerWalletAdapter } from '@solana/wallet-adapter-base';
4
4
  import * as _solana_web3_js from '@solana/web3.js';
5
5
  import { PublicKey as PublicKey$1, Transaction, VersionedTransaction, TokenAmount, Connection, TransactionSignature, Keypair, TransactionInstruction } from '@solana/web3.js';
@@ -8,6 +8,11 @@ import { JsonFragment } from '@ethersproject/abi';
8
8
  import { ErrorDescription } from '@ethersproject/abi/lib/interface';
9
9
  import { BN, AnchorProvider, Program } from '@coral-xyz/anchor';
10
10
 
11
+ type StakerConfig = {
12
+ network: ExternalNetwork;
13
+ provider: BaseSignerWalletAdapter | ethers.providers.Web3Provider;
14
+ pubKey: PublicKey;
15
+ };
11
16
  interface IStakingClient {
12
17
  pubKey: PublicKey;
13
18
  network: ExternalNetwork;
@@ -16,15 +21,20 @@ interface IStakingClient {
16
21
  withdraw(amount: bigint): Promise<string>;
17
22
  stake(amount: bigint): Promise<string>;
18
23
  unstake(amount: bigint): Promise<string>;
19
- /** Register any untracked LIQ staked tokens */
20
- /** Fetch the portfolio for the LIQ stake user */
24
+ buy(amount: bigint, asset: PurchaseAsset): Promise<string>;
25
+ /** Fetch the complete user portfolio */
21
26
  getPortfolio(): Promise<Portfolio>;
27
+ /**
28
+ * Program-level prelaunch WIRE/tranche snapshot for this chain.
29
+ *
30
+ * Returns:
31
+ * - `TrancheSnapshot` when the chain supports pretoken/tranches
32
+ * - `null` if this chain has no WIRE/pretoken integration
33
+ */
34
+ getTrancheSnapshot(): Promise<TrancheSnapshot | null>;
35
+ /** */
36
+ getBuyQuote(amount: bigint, asset: PurchaseAsset): Promise<PurchaseQuote>;
22
37
  }
23
- type StakerConfig = {
24
- network: ExternalNetwork;
25
- provider: BaseSignerWalletAdapter | ethers.providers.Web3Provider;
26
- pubKey: PublicKey;
27
- };
28
38
  interface Portfolio {
29
39
  /** Native balance on chain: ETH, SOL */
30
40
  native: BalanceView;
@@ -32,6 +42,8 @@ interface Portfolio {
32
42
  liq: BalanceView;
33
43
  /** Outpost Staked balance */
34
44
  staked: BalanceView;
45
+ /** Prelaunch WIRE “shares” (warrants/pretokens) */
46
+ wire: BalanceView;
35
47
  /** SOL ONLY!
36
48
  * Tracked liqSOL balance from distribution program */
37
49
  tracked?: BalanceView;
@@ -43,9 +55,41 @@ interface Portfolio {
43
55
  type BalanceView = {
44
56
  amount: bigint;
45
57
  decimals: number;
46
- symbol?: string;
58
+ symbol: string;
47
59
  ata?: PublicKey$1;
48
60
  };
61
+ /**
62
+ * Program-global prelaunch WIRE / tranche state for a single chain.
63
+ *
64
+ * All integer values are raw on-chain integers:
65
+ * - `currentTranchePriceUsd`: 1e8 USD
66
+ * - supplies / warrants / shares: 1e8 WIRE units (per liqsol_core/ETH analog)
67
+ * - index: same scale the program uses (INDEX_SCALE = 1e12 on Solana today)
68
+ */
69
+ interface TrancheSnapshot {
70
+ chainID: ChainID;
71
+ totalShares: bigint;
72
+ currentIndex: bigint;
73
+ currentTrancheNumber: bigint;
74
+ currentTrancheSupply: bigint;
75
+ totalWarrantsSold: bigint;
76
+ currentTranchePriceUsd: bigint;
77
+ }
78
+ declare enum PurchaseAsset {
79
+ SOL = "SOL",
80
+ LIQSOL = "LIQSOL",
81
+ ETH = "ETH",
82
+ LIQETH = "LIQETH",
83
+ YIELD = "YIELD"
84
+ }
85
+ interface PurchaseQuote {
86
+ purchaseAsset: PurchaseAsset;
87
+ amountIn: bigint;
88
+ wireShares: bigint;
89
+ wireDecimals: number;
90
+ wirePriceUsd: bigint;
91
+ notionalUsd: bigint;
92
+ }
49
93
 
50
94
  declare class Staker {
51
95
  selectedChainID?: ChainID;
@@ -184,6 +228,8 @@ declare class EthereumStakingClient implements IStakingClient {
184
228
  unstakePrelaunch(tokenId: bigint, recipient: string): Promise<string>;
185
229
  fetchPrelaunchReceipts(address?: string): Promise<preLaunchReceipt[]>;
186
230
  getEthStats(): Promise<any>;
231
+ buy(amount: bigint, purchaseAsset: PurchaseAsset): Promise<string>;
232
+ getBuyQuote(amount: bigint, purchaseAsset: PurchaseAsset): Promise<PurchaseQuote>;
187
233
  /**
188
234
  * Resolve the user's ETH + liqETH balances.
189
235
  *
@@ -192,6 +238,12 @@ declare class EthereumStakingClient implements IStakingClient {
192
238
  * tracked = liqETH tracked balance (protocol/accounting view)
193
239
  */
194
240
  getPortfolio(): Promise<Portfolio>;
241
+ /**
242
+ * Program-level prelaunch WIRE / tranche snapshot for Solana.
243
+ * Uses the same OutpostWireStateSnapshot primitive as getPortfolio().
244
+ * TODO! for eth
245
+ */
246
+ getTrancheSnapshot(): Promise<TrancheSnapshot | null>;
195
247
  private requestWithdraw;
196
248
  }
197
249
 
@@ -502,6 +554,13 @@ type WireReceipt = {
502
554
  purchasedSolShares: BN;
503
555
  bump: number;
504
556
  };
557
+ type PriceHistory = {
558
+ windowSize: number;
559
+ prices: BN[];
560
+ count: number;
561
+ nextIndex: number;
562
+ bump: number;
563
+ };
505
564
 
506
565
  type types_CorrectRegisterBuildResult = CorrectRegisterBuildResult;
507
566
  type types_CorrectRegisterPlan = CorrectRegisterPlan;
@@ -510,6 +569,7 @@ type types_GlobalState = GlobalState;
510
569
  type types_MismatchCandidate = MismatchCandidate;
511
570
  type types_OutpostWireStateSnapshot = OutpostWireStateSnapshot;
512
571
  type types_ParsedAccountInfo = ParsedAccountInfo;
572
+ type types_PriceHistory = PriceHistory;
513
573
  type types_SharesPreview = SharesPreview;
514
574
  type types_SolanaTransaction = SolanaTransaction;
515
575
  type types_TrancheState = TrancheState;
@@ -518,7 +578,7 @@ type types_UserWarrantRecord = UserWarrantRecord;
518
578
  type types_WalletLike = WalletLike;
519
579
  type types_WireReceipt = WireReceipt;
520
580
  declare namespace types {
521
- export type { types_CorrectRegisterBuildResult as CorrectRegisterBuildResult, types_CorrectRegisterPlan as CorrectRegisterPlan, types_DistributionState as DistributionState, types_GlobalState as GlobalState, types_MismatchCandidate as MismatchCandidate, types_OutpostWireStateSnapshot as OutpostWireStateSnapshot, types_ParsedAccountInfo as ParsedAccountInfo, types_SharesPreview as SharesPreview, types_SolanaTransaction as SolanaTransaction, types_TrancheState as TrancheState, types_UserRecord as UserRecord, types_UserWarrantRecord as UserWarrantRecord, types_WalletLike as WalletLike, types_WireReceipt as WireReceipt };
581
+ export type { types_CorrectRegisterBuildResult as CorrectRegisterBuildResult, types_CorrectRegisterPlan as CorrectRegisterPlan, types_DistributionState as DistributionState, types_GlobalState as GlobalState, types_MismatchCandidate as MismatchCandidate, types_OutpostWireStateSnapshot as OutpostWireStateSnapshot, types_ParsedAccountInfo as ParsedAccountInfo, types_PriceHistory as PriceHistory, types_SharesPreview as SharesPreview, types_SolanaTransaction as SolanaTransaction, types_TrancheState as TrancheState, types_UserRecord as UserRecord, types_UserWarrantRecord as UserWarrantRecord, types_WalletLike as WalletLike, types_WireReceipt as WireReceipt };
522
582
  }
523
583
 
524
584
  declare class SolanaStakingClient implements IStakingClient {
@@ -530,6 +590,7 @@ declare class SolanaStakingClient implements IStakingClient {
530
590
  private distributionClient;
531
591
  private leaderboardClient;
532
592
  private outpostClient;
593
+ private tokenClient;
533
594
  get solPubKey(): PublicKey$1;
534
595
  get network(): ExternalNetwork;
535
596
  constructor(config: StakerConfig);
@@ -556,15 +617,40 @@ declare class SolanaStakingClient implements IStakingClient {
556
617
  * @param amountLamports Amount of liqSOL principal to unstake (smallest unit)
557
618
  */
558
619
  unstake(amountLamports: bigint): Promise<string>;
620
+ /** Buy pretoken (warrants) using specified asset.
621
+ * @param amount Amount in smallest units (lamports / wei / token units).
622
+ * Required for SOL / LIQSOL / ETH / LIQETH.
623
+ * Ignored for YIELD (the program uses tracked yield).
624
+ * @param purchaseAsset Asset used to buy pretoken.
625
+ * @returns Transaction signature
626
+ */
627
+ buy(amountLamports: bigint, purchaseAsset: PurchaseAsset): Promise<string>;
559
628
  /**
560
629
  * native = SOL in wallet
561
630
  * liq = liqSOL token balance (from Token-2022 ATA)
562
631
  * staked = Outpost staked liqSOL principal (from wireReceipt.stakedLiqsol)
563
632
  * tracked = liqSOL tracked balance (from Distribution.userRecord)
633
+ * wire = prelaunch WIRE “shares” (UserWarrantRecord.totalWarrantsPurchased, 1e8)
564
634
  */
565
635
  getPortfolio(): Promise<Portfolio>;
636
+ /**
637
+ * Program-level prelaunch WIRE / tranche snapshot for Solana.
638
+ * Uses the same OutpostWireStateSnapshot primitive as getPortfolio().
639
+ */
640
+ getTrancheSnapshot(): Promise<TrancheSnapshot | null>;
641
+ getBuyQuote(amount: bigint, purchaseAsset: PurchaseAsset): Promise<PurchaseQuote>;
642
+ /**
643
+ * Exact warrant math reused from your old utils, just phrased in terms
644
+ * of already-computed USD notional:
645
+ *
646
+ * expectedWarrants = (notionalUsd * 1e8) / wirePriceUsd
647
+ *
648
+ * where:
649
+ * - notionalUsd, wirePriceUsd are 1e8-scaled USD
650
+ * - result is 1e8-scaled WIRE "shares"
651
+ */
652
+ private calculateExpectedWarrants;
566
653
  getUserRecord(): Promise<UserRecord | null>;
567
- getProtocolFee(): void;
568
654
  correctBalance(amount?: bigint): Promise<string>;
569
655
  private sendAndConfirmHttp;
570
656
  signTransaction(tx: SolanaTransaction): Promise<SolanaTransaction>;
@@ -630,6 +716,7 @@ declare const PDA_SEEDS: {
630
716
  readonly BAR_STATE_SEED: "bar_state";
631
717
  readonly BONDED_ACTOR_SEED: "bonded_actor";
632
718
  readonly BOND_LEVEL_SEED: "bond_level";
719
+ readonly PRICE_HISTORY: "price_history";
633
720
  };
634
721
  /**
635
722
  * Helpers for PDA derivation so clients don’t duplicate logic.
@@ -662,6 +749,7 @@ declare const deriveUserWarrantRecordPda: (user: PublicKey$1) => PublicKey$1;
662
749
  declare const deriveBarConfigPda: () => PublicKey$1;
663
750
  declare const deriveBondLevelPda: (bondLevelId: number[]) => PublicKey$1;
664
751
  declare const deriveBondedActorPda: (actor: PublicKey$1) => PublicKey$1;
752
+ declare const derivePriceHistoryPda: () => PublicKey$1;
665
753
  /**
666
754
  * Ephemeral stake account address used per-deposit.
667
755
  * On-chain convention: seed = `ephemeral_<u32>` under StakeProgram.programId.
@@ -692,7 +780,7 @@ declare const solToLamports: (sol: number) => bigint;
692
780
  * IDL can be found at `target/idl/liqsol_core.json`.
693
781
  */
694
782
  type LiqsolCore = {
695
- "address": "HR3t8mA25TdJpwLph2h2L7KhK7ynWoAByYYzgUAfd5rk";
783
+ "address": "BBkVcNWNQz1vZ6esv5US4QnNFWPRqxWbdpJHur9GVXSu";
696
784
  "metadata": {
697
785
  "name": "liqsolCore";
698
786
  "version": "0.1.0";
@@ -3844,58 +3932,8 @@ type LiqsolCore = {
3844
3932
  "errors": [
3845
3933
  {
3846
3934
  "code": 6000;
3847
- "name": "noRewardsToClaim";
3848
- "msg": "No rewards to claim";
3849
- },
3850
- {
3851
- "code": 6001;
3852
- "name": "insufficientBalance";
3853
- "msg": "Insufficient balance";
3854
- },
3855
- {
3856
- "code": 6002;
3857
- "name": "insufficientFunds";
3858
- "msg": "Insufficient funds";
3859
- },
3860
- {
3861
- "code": 6003;
3862
- "name": "unauthorized";
3863
- "msg": "Unauthorized - caller is not the distribution authority";
3864
- },
3865
- {
3866
- "code": 6004;
3867
- "name": "invalidMint";
3868
- "msg": "Invalid mint";
3869
- },
3870
- {
3871
- "code": 6005;
3872
- "name": "invalidOwner";
3873
- "msg": "Invalid owner";
3874
- },
3875
- {
3876
- "code": 6006;
3877
- "name": "invalidUserRecord";
3878
- "msg": "Invalid user record";
3879
- },
3880
- {
3881
- "code": 6007;
3882
- "name": "invalidWithdrawal";
3883
- "msg": "Invalid withdrawal - balance increased instead of decreased";
3884
- },
3885
- {
3886
- "code": 6008;
3887
- "name": "invalidProgramId";
3888
- "msg": "Invalid program ID";
3889
- },
3890
- {
3891
- "code": 6009;
3892
- "name": "instructionIntrospectionFailed";
3893
- "msg": "Instruction introspection failed";
3894
- },
3895
- {
3896
- "code": 6010;
3897
- "name": "receiptFulfilled";
3898
- "msg": "Receipt already fulfilled";
3935
+ "name": "accountBorrowFailed";
3936
+ "msg": "Util Acc borrow Failed";
3899
3937
  }
3900
3938
  ];
3901
3939
  "types": [
@@ -5494,5 +5532,58 @@ declare class OutpostClient {
5494
5532
  private getTokenBalanceSafe;
5495
5533
  }
5496
5534
 
5497
- 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, LAMPORTS_PER_SOL, LIQSOL_CORE, LIQSOL_TOKEN, LeaderboardClient, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS, types as SOL, SolanaStakingClient, Staker, VALIDATOR_LEADERBOARD, airdropSol, buildOutpostAccounts, calculateExpectedFee, deriveBarConfigPda, deriveBondLevelPda, deriveBondedActorPda, deriveBucketAuthorityPda, deriveDepositAuthorityPda, deriveDistributionStatePda, deriveEphemeralStakeAddress, deriveLeaderboardStatePda, deriveLiqsolMintAuthorityPda, deriveLiqsolMintPda, deriveOutpostGlobalStatePda, deriveOutpostPoolAuthorityPda, derivePayRateHistoryPda, derivePayoutStatePda, derivePoolUserRecordPda, deriveReservePoolPda, deriveSolBucketPda, deriveStakeControllerStatePda, deriveStakeControllerVaultPda, deriveTrancheStatePda, deriveUserRecordPda, deriveUserUserRecordPda, deriveUserWarrantRecordPda, deriveValidatorRecordPda, deriveVaultPda, deriveWireReceiptPda, generateRandomDepositAmount, generateTestKeypair, getAveragePayRate, getBucketLiqSolBalance, getEpochSnapshot, getErrorMessage, getLiqsolCoreProgram, getPayoutStateRaw, getReservePoolBalance, getStakeControllerStateRaw, getUserLiqSolBalance, getUserRecordRaw, lamportsToSol, msToEpochEnd, previewDepositEffects, scheduledInstruction, sleep, solToLamports, waitForConfirmation, waitUntilSafeToExecuteFunction };
5498
- export type { BalanceView, ContractConfig, ContractOptions, Contracts, EpochSnapshot, IStakingClient, OutpostAccounts, Portfolio, ScheduleConfig, StakerConfig, TxResult };
5535
+ /**
5536
+ * Client for interacting with the Pretoken (Outpost) program on Solana.
5537
+ *
5538
+ * Provides account fetching and instruction building for pretoken operations.
5539
+ * Does NOT send or confirm transactions; keeps SDK composable.
5540
+ *
5541
+ * TODO: Update to $WIRE Token implementation Post-Launch
5542
+ */
5543
+ declare class TokenClient {
5544
+ private readonly provider;
5545
+ private readonly program;
5546
+ get wallet(): WalletLike;
5547
+ constructor(provider: AnchorProvider);
5548
+ /**
5549
+ * Single source of truth for outpost/pretoken accounts.
5550
+ * Uses your existing PDA + ATA derivations in buildOutpostAccounts().
5551
+ */
5552
+ getAccounts(user: PublicKey$1): Promise<OutpostAccounts>;
5553
+ /**
5554
+ * Lightweight, UI-friendly snapshot fetchers.
5555
+ * (No decoding assumptions beyond what Anchor already provides.)
5556
+ */
5557
+ fetchGlobalState(): Promise<GlobalState>;
5558
+ fetchTrancheState(): Promise<TrancheState>;
5559
+ fetchWireReceipt(user: PublicKey$1): Promise<WireReceipt>;
5560
+ fetchUserWarrantRecord(user: PublicKey$1): Promise<UserWarrantRecord>;
5561
+ /**
5562
+ * purchase_with_sol(amount u64)
5563
+ *
5564
+ * amountLamports is bigint to match your SDK convention.
5565
+ */
5566
+ buildPurchaseWithSolIx(amountLamports: bigint, user?: PublicKey$1): Promise<TransactionInstruction>;
5567
+ /**
5568
+ * purchase_with_liqsol(amount u64)
5569
+ *
5570
+ * amount is liqSOL *raw base units* (Token-2022 amount).
5571
+ */
5572
+ buildPurchaseWithLiqsolIx(amountLamports: bigint, user?: PublicKey$1): Promise<TransactionInstruction>;
5573
+ /**
5574
+ * purchase_warrants_from_yield()
5575
+ *
5576
+ * No amount arg; it consumes tracked yield according to on-chain rules.
5577
+ */
5578
+ buildPurchaseFromYieldIx(user?: PublicKey$1): Promise<TransactionInstruction>;
5579
+ /**
5580
+ * Fetch the SOL price in 1e8 USD units from liqsol_core.priceHistory.
5581
+ *
5582
+ * This uses the same ring-buffer semantics as the on-chain program:
5583
+ * the latest price is the entry just before `nextIndex`.
5584
+ */
5585
+ getSolPriceUsd(): Promise<BN>;
5586
+ }
5587
+
5588
+ 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, LAMPORTS_PER_SOL, LIQSOL_CORE, LIQSOL_TOKEN, LeaderboardClient, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS, PurchaseAsset, types as SOL, SolanaStakingClient, Staker, TokenClient, VALIDATOR_LEADERBOARD, airdropSol, buildOutpostAccounts, calculateExpectedFee, deriveBarConfigPda, deriveBondLevelPda, deriveBondedActorPda, deriveBucketAuthorityPda, deriveDepositAuthorityPda, deriveDistributionStatePda, deriveEphemeralStakeAddress, deriveLeaderboardStatePda, deriveLiqsolMintAuthorityPda, deriveLiqsolMintPda, deriveOutpostGlobalStatePda, deriveOutpostPoolAuthorityPda, derivePayRateHistoryPda, derivePayoutStatePda, derivePoolUserRecordPda, derivePriceHistoryPda, deriveReservePoolPda, deriveSolBucketPda, deriveStakeControllerStatePda, deriveStakeControllerVaultPda, deriveTrancheStatePda, deriveUserRecordPda, deriveUserUserRecordPda, deriveUserWarrantRecordPda, deriveValidatorRecordPda, deriveVaultPda, deriveWireReceiptPda, generateRandomDepositAmount, generateTestKeypair, getAveragePayRate, getBucketLiqSolBalance, getEpochSnapshot, getErrorMessage, getLiqsolCoreProgram, getPayoutStateRaw, getReservePoolBalance, getStakeControllerStateRaw, getUserLiqSolBalance, getUserRecordRaw, lamportsToSol, msToEpochEnd, previewDepositEffects, scheduledInstruction, sleep, solToLamports, waitForConfirmation, waitUntilSafeToExecuteFunction };
5589
+ export type { BalanceView, ContractConfig, ContractOptions, Contracts, EpochSnapshot, IStakingClient, OutpostAccounts, Portfolio, PurchaseQuote, ScheduleConfig, StakerConfig, TrancheSnapshot, TxResult };