@wireio/stake 2.4.3 → 2.5.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/lib/stake.browser.js +55 -48
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +14 -9
- package/lib/stake.js +63 -55
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +55 -48
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/networks/ethereum/ethereum.ts +2 -2
- package/src/networks/solana/clients/convert.client.ts +5 -3
- package/src/networks/solana/clients/outpost.client.ts +33 -44
- package/src/networks/solana/solana.ts +12 -2
- package/src/networks/solana/types.ts +10 -6
- package/src/networks/solana/utils.ts +8 -0
- package/src/types.ts +1 -1
package/lib/stake.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ interface IStakingClient {
|
|
|
46
46
|
/** Enumerate withdrawal receipt NFTs held by the user (queued/ready/claimed). */
|
|
47
47
|
getPendingWithdraws(address?: string): Promise<WithdrawReceipt$1[]>;
|
|
48
48
|
/** Fetch the complete user portfolio */
|
|
49
|
-
getPortfolio(): Promise<Portfolio | null>;
|
|
49
|
+
getPortfolio(address?: string): Promise<Portfolio | null>;
|
|
50
50
|
getSystemAPY(): Promise<number>;
|
|
51
51
|
/**
|
|
52
52
|
* Program-level prelaunch WIRE/tranche snapshot for this chain.
|
|
@@ -505,7 +505,7 @@ declare class EthereumStakingClient implements IStakingClient {
|
|
|
505
505
|
* actual = liqETH token balance (ERC-20)
|
|
506
506
|
* tracked = liqETH tracked balance (protocol/accounting view)
|
|
507
507
|
*/
|
|
508
|
-
getPortfolio(): Promise<Portfolio | null>;
|
|
508
|
+
getPortfolio(address?: string): Promise<Portfolio | null>;
|
|
509
509
|
/**
|
|
510
510
|
* ETH Prelaunch function to list the Stake ReceiptNFTs owned by a specific user
|
|
511
511
|
* @param address address to query the receipts for
|
|
@@ -784,7 +784,11 @@ type ParsedAccountInfo = {
|
|
|
784
784
|
* fetching all relevant on-chain accounts for a given user.
|
|
785
785
|
*/
|
|
786
786
|
type OutpostWireStateSnapshot = {
|
|
787
|
-
|
|
787
|
+
/**
|
|
788
|
+
* Global Wire/outpost state.
|
|
789
|
+
* May be null if the fetch fails.
|
|
790
|
+
*/
|
|
791
|
+
globalState: GlobalState | null;
|
|
788
792
|
/**
|
|
789
793
|
* Per-user Outpost account (old “wire receipt”), or null if user
|
|
790
794
|
* hasn’t interacted yet.
|
|
@@ -804,10 +808,10 @@ type OutpostWireStateSnapshot = {
|
|
|
804
808
|
* May be null if the user never purchased.
|
|
805
809
|
*/
|
|
806
810
|
userPretokenRecord: UserPretokenRecord | null;
|
|
807
|
-
/** liqSOL in the pool ATA (Token-2022 raw amount) */
|
|
808
|
-
liqsolPoolBalance: BN;
|
|
809
|
-
/** liqSOL in the user’s ATA (Token-2022 raw amount) */
|
|
810
|
-
userLiqsolBalance: BN;
|
|
811
|
+
/** liqSOL in the pool ATA (Token-2022 raw amount), or null on fetch failure */
|
|
812
|
+
liqsolPoolBalance: BN | null;
|
|
813
|
+
/** liqSOL in the user’s ATA (Token-2022 raw amount), or null on fetch failure */
|
|
814
|
+
userLiqsolBalance: BN | null;
|
|
811
815
|
};
|
|
812
816
|
/**
|
|
813
817
|
* ============================================================
|
|
@@ -16660,6 +16664,7 @@ interface ScheduleConfig {
|
|
|
16660
16664
|
}
|
|
16661
16665
|
declare function ceilDiv(n: BN, d: BN): BN;
|
|
16662
16666
|
declare function normalizeToBigInt(x: any): bigint;
|
|
16667
|
+
declare const safeFetch: <T>(promise: Promise<T>, label?: string) => Promise<T | null>;
|
|
16663
16668
|
|
|
16664
16669
|
/**
|
|
16665
16670
|
* OutpostClient
|
|
@@ -16868,7 +16873,7 @@ declare class SolanaStakingClient implements IStakingClient {
|
|
|
16868
16873
|
* - yield: on-chain index/shares plus an estimated accrued liqSOL yield
|
|
16869
16874
|
* - extras: useful internal addresses and raw state for debugging/UX
|
|
16870
16875
|
*/
|
|
16871
|
-
getPortfolio(): Promise<Portfolio>;
|
|
16876
|
+
getPortfolio(address?: string): Promise<Portfolio>;
|
|
16872
16877
|
/**
|
|
16873
16878
|
* Convenience helper to fetch the distribution userRecord for the current user.
|
|
16874
16879
|
* Used by balance-correction flows and debugging.
|
|
@@ -16979,5 +16984,5 @@ declare class SolanaStakingClient implements IStakingClient {
|
|
|
16979
16984
|
private getSingleTxFeeLamports;
|
|
16980
16985
|
}
|
|
16981
16986
|
|
|
16982
|
-
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 };
|
|
16987
|
+
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, safeFetch, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
|
|
16983
16988
|
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 };
|
package/lib/stake.js
CHANGED
|
@@ -15915,6 +15915,14 @@ function normalizeToBigInt(x) {
|
|
|
15915
15915
|
if (typeof x === "number") return BigInt(x);
|
|
15916
15916
|
throw new Error(`normalizeToBigInt: unsupported type ${typeof x}`);
|
|
15917
15917
|
}
|
|
15918
|
+
const safeFetch = (promise, label) => __async$g(null, null, function* () {
|
|
15919
|
+
try {
|
|
15920
|
+
return yield promise;
|
|
15921
|
+
} catch (err) {
|
|
15922
|
+
console.error(`Safe Fetch Failed${label ? ` (${label})` : ""}:`, err);
|
|
15923
|
+
return null;
|
|
15924
|
+
}
|
|
15925
|
+
});
|
|
15918
15926
|
|
|
15919
15927
|
var __pow = Math.pow;
|
|
15920
15928
|
var __async$f = (__this, __arguments, generator) => {
|
|
@@ -16169,10 +16177,12 @@ let ConvertClient$1 = class ConvertClient {
|
|
|
16169
16177
|
}
|
|
16170
16178
|
let slotTimeSec = 0.4;
|
|
16171
16179
|
try {
|
|
16172
|
-
const samples = yield conn.getRecentPerformanceSamples(
|
|
16180
|
+
const samples = yield conn.getRecentPerformanceSamples(60);
|
|
16173
16181
|
if (samples == null ? void 0 : samples.length) {
|
|
16174
|
-
const
|
|
16175
|
-
|
|
16182
|
+
const valid = samples.filter((s) => s.numSlots > 0);
|
|
16183
|
+
if (valid.length) {
|
|
16184
|
+
slotTimeSec = valid.reduce((sum, s) => sum + s.samplePeriodSecs / s.numSlots, 0) / valid.length;
|
|
16185
|
+
}
|
|
16176
16186
|
}
|
|
16177
16187
|
} catch (_) {
|
|
16178
16188
|
}
|
|
@@ -16565,52 +16575,41 @@ class OutpostClient {
|
|
|
16565
16575
|
}
|
|
16566
16576
|
getTokenBalance(ata) {
|
|
16567
16577
|
return __async$c(this, null, function* () {
|
|
16568
|
-
|
|
16569
|
-
|
|
16570
|
-
return new anchor.BN(bal.value.amount);
|
|
16571
|
-
} catch (e) {
|
|
16572
|
-
return new anchor.BN(0);
|
|
16573
|
-
}
|
|
16578
|
+
const bal = yield this.connection.getTokenAccountBalance(ata);
|
|
16579
|
+
return new anchor.BN(bal.value.amount);
|
|
16574
16580
|
});
|
|
16575
16581
|
}
|
|
16576
16582
|
fetchWireState(user) {
|
|
16577
16583
|
return __async$c(this, null, function* () {
|
|
16578
16584
|
const userPk = user != null ? user : this.wallet.publicKey;
|
|
16579
|
-
if (!userPk)
|
|
16580
|
-
throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16581
|
-
}
|
|
16585
|
+
if (!userPk) throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16582
16586
|
const pdas = yield this.buildAccounts(userPk);
|
|
16583
|
-
|
|
16584
|
-
|
|
16585
|
-
|
|
16586
|
-
|
|
16587
|
-
|
|
16588
|
-
|
|
16589
|
-
|
|
16590
|
-
|
|
16591
|
-
|
|
16592
|
-
|
|
16593
|
-
|
|
16594
|
-
|
|
16595
|
-
|
|
16596
|
-
|
|
16597
|
-
|
|
16598
|
-
|
|
16599
|
-
|
|
16600
|
-
|
|
16601
|
-
|
|
16602
|
-
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
|
|
16607
|
-
|
|
16608
|
-
|
|
16609
|
-
};
|
|
16610
|
-
} catch (err) {
|
|
16611
|
-
console.error("Error fetching Outpost wire state:", err);
|
|
16612
|
-
throw err;
|
|
16613
|
-
}
|
|
16587
|
+
const [
|
|
16588
|
+
globalState,
|
|
16589
|
+
outpostAccount,
|
|
16590
|
+
distributionState,
|
|
16591
|
+
userPretokenRecord,
|
|
16592
|
+
trancheState,
|
|
16593
|
+
liqsolPoolBalance,
|
|
16594
|
+
userLiqsolBalance
|
|
16595
|
+
] = yield Promise.all([
|
|
16596
|
+
safeFetch(this.program.account.globalState.fetch(pdas.globalState), "globalState"),
|
|
16597
|
+
safeFetch(this.program.account.outpostAccount.fetchNullable(pdas.outpostAccount), "outpostAccount"),
|
|
16598
|
+
safeFetch(this.program.account.distributionState.fetchNullable(pdas.distributionState), "distributionState"),
|
|
16599
|
+
safeFetch(this.program.account.userPretokenRecord.fetchNullable(pdas.userPretokenRecord), "userPretokenRecord"),
|
|
16600
|
+
safeFetch(this.program.account.trancheState.fetchNullable(pdas.trancheState), "trancheState"),
|
|
16601
|
+
safeFetch(this.getTokenBalance(pdas.liqsolPoolAta), "liqsolPoolAta"),
|
|
16602
|
+
safeFetch(this.getTokenBalance(pdas.userAta), "userAta")
|
|
16603
|
+
]);
|
|
16604
|
+
return {
|
|
16605
|
+
globalState,
|
|
16606
|
+
outpostAccount,
|
|
16607
|
+
distributionState,
|
|
16608
|
+
trancheState,
|
|
16609
|
+
userPretokenRecord,
|
|
16610
|
+
liqsolPoolBalance,
|
|
16611
|
+
userLiqsolBalance
|
|
16612
|
+
};
|
|
16614
16613
|
});
|
|
16615
16614
|
}
|
|
16616
16615
|
buildStakeIx(_0) {
|
|
@@ -17382,11 +17381,11 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17382
17381
|
}
|
|
17383
17382
|
});
|
|
17384
17383
|
}
|
|
17385
|
-
getPortfolio() {
|
|
17384
|
+
getPortfolio(address) {
|
|
17386
17385
|
return __async$9(this, null, function* () {
|
|
17387
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
17386
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
17388
17387
|
try {
|
|
17389
|
-
const user = !!this.squadsX ? this.squadsVaultPDA : this.solPubKey;
|
|
17388
|
+
const user = address ? new web3_js.PublicKey(address) : !!this.squadsX ? this.squadsVaultPDA : this.solPubKey;
|
|
17390
17389
|
const reservePoolPDA = this.program.deriveReservePoolPda();
|
|
17391
17390
|
const vaultPDA = this.program.deriveVaultPda();
|
|
17392
17391
|
const liqsolMint = this.program.deriveLiqsolMintPda();
|
|
@@ -17411,9 +17410,17 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17411
17410
|
const userPretokenRecord = (_f = snapshot == null ? void 0 : snapshot.userPretokenRecord) != null ? _f : null;
|
|
17412
17411
|
const stakedLiqsolStr = (_i = (_h = (_g = outpostAccount == null ? void 0 : outpostAccount.stakedLiqsol) == null ? void 0 : _g.toString) == null ? void 0 : _h.call(_g)) != null ? _i : "0";
|
|
17413
17412
|
const wirePretokensStr = (_l = (_k = (_j = userPretokenRecord == null ? void 0 : userPretokenRecord.totalPretokensPurchased) == null ? void 0 : _j.toString) == null ? void 0 : _k.call(_j)) != null ? _l : "0";
|
|
17414
|
-
|
|
17415
|
-
|
|
17416
|
-
|
|
17413
|
+
console.log("userPretokenRecord", userPretokenRecord);
|
|
17414
|
+
console.log("address", address);
|
|
17415
|
+
console.log("userPretokenRecord?.totalPretokensPurchased?.toString", (_m = userPretokenRecord == null ? void 0 : userPretokenRecord.totalPretokensPurchased) == null ? void 0 : _m.toString);
|
|
17416
|
+
if (userPretokenRecord) {
|
|
17417
|
+
for (const [key, value] of Object.entries(userPretokenRecord)) {
|
|
17418
|
+
console.log(`userPretokenRecord.${key}: ${(_o = (_n = value == null ? void 0 : value.toString) == null ? void 0 : _n.call(value)) != null ? _o : value}`);
|
|
17419
|
+
}
|
|
17420
|
+
}
|
|
17421
|
+
const currentIndexStr = (_r = (_q = (_p = globalState == null ? void 0 : globalState.currentIndex) == null ? void 0 : _p.toString) == null ? void 0 : _q.call(_p)) != null ? _r : "0";
|
|
17422
|
+
const totalSharesStr = (_u = (_t = (_s = globalState == null ? void 0 : globalState.totalShares) == null ? void 0 : _s.toString) == null ? void 0 : _t.call(_s)) != null ? _u : "0";
|
|
17423
|
+
const userSharesStr = (_x = (_w = (_v = outpostAccount == null ? void 0 : outpostAccount.stakedShares) == null ? void 0 : _v.toString) == null ? void 0 : _w.call(_v)) != null ? _x : "0";
|
|
17417
17424
|
const stakedLiqsol = BigInt(stakedLiqsolStr);
|
|
17418
17425
|
const currentIndex = BigInt(currentIndexStr);
|
|
17419
17426
|
const totalShares = BigInt(totalSharesStr);
|
|
@@ -17466,10 +17473,10 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17466
17473
|
userLiqsolAta: userLiqsolAta.toBase58(),
|
|
17467
17474
|
reservePoolPDA: reservePoolPDA.toBase58(),
|
|
17468
17475
|
vaultPDA: vaultPDA.toBase58(),
|
|
17469
|
-
globalIndex: (
|
|
17470
|
-
totalShares: (
|
|
17471
|
-
currentTrancheNumber: (
|
|
17472
|
-
currentTranchePriceUsd: (
|
|
17476
|
+
globalIndex: (_y = globalState == null ? void 0 : globalState.currentIndex) == null ? void 0 : _y.toString(),
|
|
17477
|
+
totalShares: (_z = globalState == null ? void 0 : globalState.totalShares) == null ? void 0 : _z.toString(),
|
|
17478
|
+
currentTrancheNumber: (_A = trancheState == null ? void 0 : trancheState.currentTrancheNumber) == null ? void 0 : _A.toString(),
|
|
17479
|
+
currentTranchePriceUsd: (_B = trancheState == null ? void 0 : trancheState.currentTranchePriceUsd) == null ? void 0 : _B.toString()
|
|
17473
17480
|
},
|
|
17474
17481
|
chainID: this.network.chainId
|
|
17475
17482
|
};
|
|
@@ -43364,12 +43371,12 @@ class EthereumStakingClient {
|
|
|
43364
43371
|
return result && result.txHash ? result.txHash : "Error - no resulting txHash";
|
|
43365
43372
|
});
|
|
43366
43373
|
}
|
|
43367
|
-
getPortfolio() {
|
|
43374
|
+
getPortfolio(address) {
|
|
43368
43375
|
return __async(this, null, function* () {
|
|
43369
43376
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
43370
43377
|
try {
|
|
43371
43378
|
if (!this.signer) return Promise.resolve(null);
|
|
43372
|
-
const walletAddress = yield this.address;
|
|
43379
|
+
const walletAddress = address != null ? address : yield this.address;
|
|
43373
43380
|
const nativeBalance = yield this.provider.getBalance(walletAddress);
|
|
43374
43381
|
const nativeDecimals = (_c = (_b = (_a = this.network) == null ? void 0 : _a.nativeCurrency) == null ? void 0 : _b.decimals) != null ? _c : 18;
|
|
43375
43382
|
const nativeSymbol = (_f = (_e = (_d = this.network) == null ? void 0 : _d.nativeCurrency) == null ? void 0 : _e.symbol) != null ? _f : "ETH";
|
|
@@ -43697,6 +43704,7 @@ exports.getProgramIds = getProgramIds;
|
|
|
43697
43704
|
exports.lamportsToSol = lamportsToSol;
|
|
43698
43705
|
exports.msToEpochEnd = msToEpochEnd;
|
|
43699
43706
|
exports.normalizeToBigInt = normalizeToBigInt;
|
|
43707
|
+
exports.safeFetch = safeFetch;
|
|
43700
43708
|
exports.scheduledInstruction = scheduledInstruction;
|
|
43701
43709
|
exports.sleep = sleep;
|
|
43702
43710
|
exports.solToLamports = solToLamports;
|