@wireio/stake 2.4.4 → 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 +46 -41
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +11 -6
- package/lib/stake.js +54 -48
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +46 -41
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/networks/solana/clients/outpost.client.ts +33 -44
- package/src/networks/solana/solana.ts +9 -0
- package/src/networks/solana/types.ts +10 -6
- package/src/networks/solana/utils.ts +8 -0
package/lib/stake.d.ts
CHANGED
|
@@ -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
|
|
@@ -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) => {
|
|
@@ -16567,52 +16575,41 @@ class OutpostClient {
|
|
|
16567
16575
|
}
|
|
16568
16576
|
getTokenBalance(ata) {
|
|
16569
16577
|
return __async$c(this, null, function* () {
|
|
16570
|
-
|
|
16571
|
-
|
|
16572
|
-
return new anchor.BN(bal.value.amount);
|
|
16573
|
-
} catch (e) {
|
|
16574
|
-
return new anchor.BN(0);
|
|
16575
|
-
}
|
|
16578
|
+
const bal = yield this.connection.getTokenAccountBalance(ata);
|
|
16579
|
+
return new anchor.BN(bal.value.amount);
|
|
16576
16580
|
});
|
|
16577
16581
|
}
|
|
16578
16582
|
fetchWireState(user) {
|
|
16579
16583
|
return __async$c(this, null, function* () {
|
|
16580
16584
|
const userPk = user != null ? user : this.wallet.publicKey;
|
|
16581
|
-
if (!userPk)
|
|
16582
|
-
throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16583
|
-
}
|
|
16585
|
+
if (!userPk) throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16584
16586
|
const pdas = yield this.buildAccounts(userPk);
|
|
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
|
-
|
|
16611
|
-
};
|
|
16612
|
-
} catch (err) {
|
|
16613
|
-
console.error("Error fetching Outpost wire state:", err);
|
|
16614
|
-
throw err;
|
|
16615
|
-
}
|
|
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
|
+
};
|
|
16616
16613
|
});
|
|
16617
16614
|
}
|
|
16618
16615
|
buildStakeIx(_0) {
|
|
@@ -17386,7 +17383,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17386
17383
|
}
|
|
17387
17384
|
getPortfolio(address) {
|
|
17388
17385
|
return __async$9(this, null, function* () {
|
|
17389
|
-
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;
|
|
17390
17387
|
try {
|
|
17391
17388
|
const user = address ? new web3_js.PublicKey(address) : !!this.squadsX ? this.squadsVaultPDA : this.solPubKey;
|
|
17392
17389
|
const reservePoolPDA = this.program.deriveReservePoolPda();
|
|
@@ -17413,9 +17410,17 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17413
17410
|
const userPretokenRecord = (_f = snapshot == null ? void 0 : snapshot.userPretokenRecord) != null ? _f : null;
|
|
17414
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";
|
|
17415
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";
|
|
17416
|
-
|
|
17417
|
-
|
|
17418
|
-
|
|
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";
|
|
17419
17424
|
const stakedLiqsol = BigInt(stakedLiqsolStr);
|
|
17420
17425
|
const currentIndex = BigInt(currentIndexStr);
|
|
17421
17426
|
const totalShares = BigInt(totalSharesStr);
|
|
@@ -17468,10 +17473,10 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17468
17473
|
userLiqsolAta: userLiqsolAta.toBase58(),
|
|
17469
17474
|
reservePoolPDA: reservePoolPDA.toBase58(),
|
|
17470
17475
|
vaultPDA: vaultPDA.toBase58(),
|
|
17471
|
-
globalIndex: (
|
|
17472
|
-
totalShares: (
|
|
17473
|
-
currentTrancheNumber: (
|
|
17474
|
-
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()
|
|
17475
17480
|
},
|
|
17476
17481
|
chainID: this.network.chainId
|
|
17477
17482
|
};
|
|
@@ -43699,6 +43704,7 @@ exports.getProgramIds = getProgramIds;
|
|
|
43699
43704
|
exports.lamportsToSol = lamportsToSol;
|
|
43700
43705
|
exports.msToEpochEnd = msToEpochEnd;
|
|
43701
43706
|
exports.normalizeToBigInt = normalizeToBigInt;
|
|
43707
|
+
exports.safeFetch = safeFetch;
|
|
43702
43708
|
exports.scheduledInstruction = scheduledInstruction;
|
|
43703
43709
|
exports.sleep = sleep;
|
|
43704
43710
|
exports.solToLamports = solToLamports;
|